Commit e30b529b by duanhq

新增用户所属集团字段,根据集团搜索商户bug修复 by duanht 2019/3/6

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@18159 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent b5914677
......@@ -10,6 +10,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.validation.groups.Default;
import com.glsx.usercenter.mapper.SysOrganizationMapper;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.service.ISysOrganizationService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.ExcessiveAttemptsException;
......@@ -85,6 +88,10 @@ public class UserController extends BaseController {
@Autowired
private IAreaService iAreaService;
@Autowired
private ISysOrganizationService iSysOrganizationService;
/**
* @param userQueryVo
* @return ResultObject
......@@ -175,6 +182,12 @@ public class UserController extends BaseController {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
if (sysManager.getOrgId() != null) {
//根据组织id查询出所属集团
Integer groupId = iSysOrganizationService.getGroupIdByOrgId(sysManager.getOrgId());
sysManager.setGroupId(groupId);
}
SysUser user = sysUserService.selectByPrimaryKey(sysManager.getId());
if (user == null) {
// 新增用户
......@@ -188,7 +201,7 @@ public class UserController extends BaseController {
}
//性别默认为未知
if (StringUtils.isEmpty(sysManager.getSex())) {
sysManager.setSex("3");
sysManager.setSex("sys_user_sex_unknown");
}
sysManager.setUpdateBy(UserUtils.getUserName(request));
sysManager.setUpdateTime(DateUtil.getCurrentTime());
......@@ -235,6 +248,12 @@ public class UserController extends BaseController {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
if (sysMerchant.getOrgId() != null) {
//根据组织id查询出所属集团
Integer groupId = iSysOrganizationService.getGroupIdByOrgId(sysMerchant.getOrgId());
sysMerchant.setGroupId(groupId);
}
SysUser user = sysUserService.selectByPrimaryKey(sysMerchant.getId());
if (user == null) {
// 新增商户
......@@ -277,6 +296,13 @@ public class UserController extends BaseController {
} else {
sysMechanic.setMechanicStatus("sys_user_status_uncheck");
}
//根据组织id查询出所属集团
if (sysMechanic.getOrgId() != null) {
Integer groupId = iSysOrganizationService.getGroupIdByOrgId(sysMechanic.getOrgId());
sysMechanic.setGroupId(groupId);
}
//技工用手机号作为登录账号
sysMechanic.setUsername(sysMechanic.getPhoneNumber());
// 新增技工
......@@ -286,9 +312,9 @@ public class UserController extends BaseController {
sysMechanic.setPassword(sysUserService.encryptPassword(sysMechanic.getPhoneNumber()));
sysMechanic.setCreateTime(DateUtil.getCurrentTime());
//小程序端注册创建人是自己
if(StringUtils.isEmpty(UserUtils.getUserName(request))){
if (StringUtils.isEmpty(UserUtils.getUserName(request))) {
sysMechanic.setCreateBy(sysMechanic.getUsername());
}else{
} else {
sysMechanic.setCreateBy(UserUtils.getUserName(request));
}
//设置默认技工角色
......@@ -315,6 +341,12 @@ public class UserController extends BaseController {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg(), errorMap);
}
//根据组织id查询出所属集团
if (sysMechanic.getOrgId() != null) {
Integer groupId = iSysOrganizationService.getGroupIdByOrgId(sysMechanic.getOrgId());
sysMechanic.setGroupId(groupId);
}
//技工用手机号作为登录账号
sysMechanic.setUsername(sysMechanic.getPhoneNumber());
sysMechanic.setUserType(Constants.USER_TYPE_MECHANIC);
......@@ -334,6 +366,13 @@ public class UserController extends BaseController {
@RequestMapping(value = "/updateUserById", method = {RequestMethod.GET, RequestMethod.POST})
@ResponseBody
public ResultObject updateUserById(SysUser sysUser) {
//根据组织id查询出所属集团
if (sysUser.getOrgId() != null) {
Integer groupId = iSysOrganizationService.getGroupIdByOrgId(sysUser.getOrgId());
sysUser.setGroupId(groupId);
}
sysUser.setUpdateBy(UserUtils.getUserName(request));
sysUser.setUpdateTime(DateUtil.getCurrentTime());
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), sysUserService.updateUserById(sysUser));
......
......@@ -84,6 +84,11 @@ public class SysUser extends BaseModel implements Serializable{
private String serviceKey;
/**
*集团id
*/
private Integer groupId;
/**
*服务项信息
*/
private List<SysUserServices> userService = new ArrayList<>();
......@@ -314,5 +319,13 @@ public class SysUser extends BaseModel implements Serializable{
public void setUrlList(List<String> urlList) {
this.urlList = urlList;
}
public Integer getGroupId() {
return groupId;
}
public void setGroupId(Integer groupId) {
this.groupId = groupId;
}
}
......@@ -76,6 +76,11 @@ public class UserQueryVo extends BaseQueryVo {
*/
private String dataKey;
/**
* 字典键值
*/
private Integer groupId;
public String getDataKey() {
return dataKey;
}
......@@ -189,4 +194,12 @@ public class UserQueryVo extends BaseQueryVo {
public void setServiceKey(String serviceKey) {
this.serviceKey = serviceKey;
}
public Integer getGroupId() {
return groupId;
}
public void setGroupId(Integer groupId) {
this.groupId = groupId;
}
}
......@@ -34,5 +34,14 @@ public interface ISysOrganizationService {
List<SysOrganization> findOrgById(Integer id);
SysOrganization selectDetailById(Integer id);
/**
* @param orgId
* @return Integer
* @author duanht
* @Title: getGroupIdByOrgId
* @Description: TODO 根据组织id获取集团id
*/
public Integer getGroupIdByOrgId(Integer orgId);
}
......@@ -378,4 +378,14 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{
// TODO Auto-generated method stub
return orgDao.selectDetailById(id);
}
@Override
public Integer getGroupIdByOrgId(Integer orgId) {
SysOrganization sysOrganization = orgDao.selectByPrimaryKey(orgId);
int parentId = sysOrganization.getId();
if (sysOrganization.getParentId() != 0) {
parentId = getGroupIdByOrgId(sysOrganization.getParentId());
}
return parentId;
}
}
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import com.glsx.common.utils.UserUtils;
import com.glsx.usercenter.service.ISysOrganizationService;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.LockedAccountException;
......@@ -81,6 +82,9 @@ public class SysUserServiceImpl implements SysUserService {
@Autowired
private IAreaService iAreaService;
@Autowired
private ISysOrganizationService iSysOrganizationService;
public Logger logger = LoggerFactory.getLogger(getClass());
......@@ -125,50 +129,23 @@ public class SysUserServiceImpl implements SysUserService {
userQueryVo.setName(shopContactsInfo);
}
}
List<SysMerchant> sysMerchantList = sysUserMapper.getSysMerchantList(userQueryVo);
//匹配集团
for (SysMerchant sysMerchant : sysMerchantList) {
//1.根据商户组织id查询出集团 2.设置省市区
if (sysMerchant.getOrgId() != null) {
Integer groupId = getGroupIdByOrgId(sysMerchant.getOrgId());
SysOrganization sysOrganization = sysOrganizationMapper.selectByPrimaryKey(groupId);
sysMerchant.setOrgName(sysOrganization.getName());
//2.设置省市区
if (StringUtils.isNotEmpty(sysMerchant.getDistrict())) {
sysMerchant.setSysArea(iAreaService.getAllChargeItems(Integer.valueOf(sysMerchant.getDistrict())));
}
for (SysMerchant sysMerchant : sysMerchantList) {
//设置省市区
if (StringUtils.isNotEmpty(sysMerchant.getDistrict())) {
sysMerchant.setSysArea(iAreaService.getAllChargeItems(Integer.valueOf(sysMerchant.getDistrict())));
}
}
//根据集团名筛选
List<SysMerchant> merchantRemove = new ArrayList<SysMerchant>();
if (StringUtils.isNotEmpty(userQueryVo.getOrgName())) {
for (SysMerchant sysMerchant : sysMerchantList) {
if (!sysMerchant.getOrgName().equals(userQueryVo.getOrgName())) {
merchantRemove.add(sysMerchant);
}
//设置集团名
if (sysMerchant.getGroupId() != null) {
SysOrganization sysOrganization = sysOrganizationMapper.selectByPrimaryKey(sysMerchant.getGroupId());
sysMerchant.setOrgName(sysOrganization.getName());
}
}
sysMerchantList.removeAll(merchantRemove);
return sysMerchantList;
}
/**
* @param orgId
* @return Integer
* @author duanht
* @Title: getGroupIdByOrgId
* @Description: TODO 根据组织id获取集团id
*/
private Integer getGroupIdByOrgId(Integer orgId) {
SysOrganization sysOrganization = sysOrganizationMapper.selectByPrimaryKey(orgId);
int parentId = sysOrganization.getId();
if (sysOrganization.getParentId() != 0) {
parentId = getGroupIdByOrgId(sysOrganization.getParentId());
}
return parentId;
}
@Override
public List<SysMechanic> getSysMechanicList(UserQueryVo userQueryVo) {
......@@ -193,16 +170,6 @@ public class SysUserServiceImpl implements SysUserService {
sysMechanic.setSysArea(iAreaService.getAllChargeItems(Integer.valueOf(sysMechanic.getDistrict())));
}
}
//删除不符合服务项条件的数据
List<SysMechanic> userRemove = new ArrayList<SysMechanic>();
if (StringUtils.isNotEmpty(userQueryVo.getServiceKey())) {
for (SysMechanic sysMechanic : sysMechanicList) {
if (!sysMechanic.getServiceKey().contains(userQueryVo.getServiceKey())) {
userRemove.add(sysMechanic);
}
}
}
sysMechanicList.removeAll(userRemove);
return sysMechanicList;
}
......@@ -562,7 +529,7 @@ public class SysUserServiceImpl implements SysUserService {
List<SysUser> removeUserList = new ArrayList<>();
for (SysUser sysUser : sysUserList) {
//根据商户组织id查询出集团
Integer groupIds = getGroupIdByOrgId(sysUser.getOrgId());
Integer groupIds = iSysOrganizationService.getGroupIdByOrgId(sysUser.getOrgId());
if (!groupIds.equals(userQueryVo.getOrgId())) {
removeUserList.add(sysUser);
}
......
......@@ -174,6 +174,9 @@
<if test="userType != null">
user_type,
</if>
<if test="groupId != null">
group_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="username != null">
......@@ -215,6 +218,9 @@
<if test="userType != null">
#{userType,jdbcType=VARCHAR},
</if>
<if test="groupId != null">
#{groupId,jdbcType=INTEGER},
</if>
</trim>
</insert>
......@@ -472,6 +478,9 @@
<if test="record.remark != null">
remark = #{record.remark,jdbcType=VARCHAR},
</if>
<if test="record.groupId != null">
group_id = #{record.groupId,jdbcType=INTEGER},
</if>
</set>
where id = #{record.id,jdbcType=INTEGER}
</update>
......@@ -515,6 +524,9 @@
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="groupId != null">
groupId = #{groupId,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
......@@ -686,7 +698,8 @@
sm.address address,
sdd.data_key serviceKey,
sdd.data_value serviceItems,
sm.merchant_status
sm.merchant_status,
u.org_id groupId
<choose>
<when test="userId != 0 and userId!=''">
FROM
......@@ -729,6 +742,14 @@
and u.phone_number like "%"#{phoneNumber,jdbcType=VARCHAR}"%"
</if>
<if test="groupId != null and groupId!=''">
and u.group_id = #{groupId,jdbcType=INTEGER}
</if>
<if test="sTime != null and eTime!=null and sTime !='' and eTime !=''">
and u.create_time between #{sTime,jdbcType=TIMESTAMP} and #{eTime,jdbcType=TIMESTAMP}
</if>
<if test="listType == 2">
<choose>
<when test="userStatus != null and userStatus!=''">
......@@ -812,7 +833,7 @@
and u.id = #{id,jdbcType=TINYINT}
</if>
<if test="serviceType != null and serviceType!=''">
and sm.service_type like "%"#{serviceType,jdbcType=VARCHAR}"%"
and sm.service_type = #{serviceType,jdbcType=VARCHAR}
</if>
<if test="name != null and name!=''">
......@@ -822,6 +843,12 @@
<if test="phoneNumber != null and phoneNumber!=''">
and u.phone_number like "%"#{phoneNumber,jdbcType=VARCHAR}"%"
</if>
<if test="serviceKey != null and serviceKey!=''">
AND sdd.data_key LIKE "%"#{serviceKey,jdbcType=VARCHAR}"%"
</if>
<if test="sTime != null and eTime!=null and sTime !='' and eTime !=''">
and u.create_time between #{sTime,jdbcType=TIMESTAMP} and #{eTime,jdbcType=TIMESTAMP}
</if>
<choose>
<when test="userStatus != null and userStatus!=''">
and u.user_status = #{userStatus,jdbcType=VARCHAR}
......@@ -870,9 +897,16 @@
and u.name like "%"#{name,jdbcType=VARCHAR}"%"
</if>
<if test="serviceKey != null and serviceKey!=''">
AND sdd.data_key LIKE "%"#{serviceKey,jdbcType=VARCHAR}"%"
</if>
<if test="phoneNumber != null and phoneNumber!=''">
and u.phone_number like "%"#{phoneNumber,jdbcType=VARCHAR}"%"
</if>
<if test="sTime != null and eTime!=null and sTime !='' and eTime !=''">
and u.create_time between #{sTime,jdbcType=TIMESTAMP} and #{eTime,jdbcType=TIMESTAMP}
</if>
<choose>
<when test="userStatus != null and userStatus!=''">
and sm.mechanic_status = #{userStatus,jdbcType=VARCHAR}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!