Commit 63a037be authored by 韩桐桐's avatar 韩桐桐

fix(tcm):新增人员接口兼容非json类型

parent 22fe4a13
...@@ -13,7 +13,10 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisKey; ...@@ -13,7 +13,10 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tcm.api.dto.*; import com.yeejoin.amos.boot.module.tcm.api.dto.*;
import com.yeejoin.amos.boot.module.tcm.api.entity.*; import com.yeejoin.amos.boot.module.tcm.api.entity.*;
import com.yeejoin.amos.boot.module.tcm.api.enums.*; import com.yeejoin.amos.boot.module.tcm.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.tcm.api.enums.PersonManageRoleEnum;
import com.yeejoin.amos.boot.module.tcm.api.enums.TwoStipulateGroupEnum;
import com.yeejoin.amos.boot.module.tcm.api.enums.UnitTypeEnum;
import com.yeejoin.amos.boot.module.tcm.api.mapper.TzsBaseIndividualityMapper; import com.yeejoin.amos.boot.module.tcm.api.mapper.TzsBaseIndividualityMapper;
import com.yeejoin.amos.boot.module.tcm.api.mapper.TzsUserEquipMapper; import com.yeejoin.amos.boot.module.tcm.api.mapper.TzsUserEquipMapper;
import com.yeejoin.amos.boot.module.tcm.api.mapper.TzsUserInfoMapper; import com.yeejoin.amos.boot.module.tcm.api.mapper.TzsUserInfoMapper;
...@@ -46,46 +49,35 @@ import java.util.stream.Collectors; ...@@ -46,46 +49,35 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserInfo, TzsUserInfoMapper> implements ITzsUserInfoService { public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserInfo, TzsUserInfoMapper> implements ITzsUserInfoService {
@Autowired // 企业人员角色
private TzsUserInfoMapper tzsUserInfoMapper; private final String USER_ROLE = "QYRYJS";
// 企业人员用户组
@Autowired private final String ROLE_GROUP = "QYRYYHZ";
private TzsUserEquipMapper tzsUserEquipMapper; // 两个规定用户组-对应企业人员的人员类型前缀
private final String QYRYGW = "QYRYGW";
@Autowired // 两个规定用户组-对应企业人员的人员类型前缀
private TzsUserEquipServiceImpl tzsUserEquipService; private final String QYRYGW_NAME = "企业人员类型";
// 平台用户锁定状态
private final String UNLOCK = "UNLOCK";
private final String LOCK = "LOCK";
@Autowired @Autowired
DataDictionaryServiceImpl iDataDictionaryService; DataDictionaryServiceImpl iDataDictionaryService;
@Autowired
private RedisUtils redisUtils;
@Autowired @Autowired
TzBaseEnterpriseInfoServiceImpl baseEnterpriseInfoService; TzBaseEnterpriseInfoServiceImpl baseEnterpriseInfoService;
@Autowired @Autowired
TzsBaseIndividualityServiceImpl individualityService; TzsBaseIndividualityServiceImpl individualityService;
@Autowired @Autowired
TzsBaseIndividualityMapper individualityMapper; TzsBaseIndividualityMapper individualityMapper;
//企业人员角色
private final String USER_ROLE = "QYRYJS";
//企业人员用户组
private final String ROLE_GROUP = "QYRYYHZ";
//两个规定用户组-对应企业人员的人员类型前缀
private final String QYRYGW = "QYRYGW";
//两个规定用户组-对应企业人员的人员类型前缀
private final String QYRYGW_NAME = "企业人员类型";
//平台用户锁定状态
private final String UNLOCK = "UNLOCK";
private final String LOCK = "LOCK";
@Autowired @Autowired
AmosRequestContext amosRequestContext; AmosRequestContext amosRequestContext;
@Autowired
private TzsUserInfoMapper tzsUserInfoMapper;
@Autowired
private TzsUserEquipMapper tzsUserEquipMapper;
@Autowired
private TzsUserEquipServiceImpl tzsUserEquipService;
@Autowired
private RedisUtils redisUtils;
@Autowired @Autowired
private TzsUserQualificationsServiceImpl tzsUserQualificationsService; private TzsUserQualificationsServiceImpl tzsUserQualificationsService;
...@@ -107,15 +99,32 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -107,15 +99,32 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
return tzsUserInfoDtoPage; return tzsUserInfoDtoPage;
} }
// 判断字符串是否为合法的 JSON 格式
public boolean isJSONValid(String test) {
try {
JSON.parseArray(test);
return true;
} catch (Exception ex) {
return false;
}
}
public String setPostName(String postKey) { public String setPostName(String postKey) {
JSONArray dictIds = JSON.parseArray(postKey); // 兼容前端只传一个值,并且非json类型的情况
JSONArray dictIds = new JSONArray();
if (this.isJSONValid(postKey)) {
dictIds = JSON.parseArray(postKey);
} else {
dictIds.add(postKey);
}
if (dictIds == null || dictIds.isEmpty()) { if (dictIds == null || dictIds.isEmpty()) {
return ""; return "";
} }
LambdaQueryWrapper<DataDictionary> lambda = new QueryWrapper<DataDictionary>().lambda(); LambdaQueryWrapper<DataDictionary> lambda = new QueryWrapper<DataDictionary>().lambda();
lambda.in(DataDictionary::getSequenceNbr, dictIds); lambda.in(DataDictionary::getSequenceNbr, dictIds);
List<DataDictionary> dataDictionaries = iDataDictionaryService.getByTypeAndDesc(QYRYGW, QYRYGW_NAME); List<DataDictionary> dataDictionaries = iDataDictionaryService.getByTypeAndDesc(QYRYGW, QYRYGW_NAME);
List<DataDictionary> postDataList = dataDictionaries.stream().filter(d -> dictIds.stream().anyMatch(id -> id.toString().equals(d.getSequenceNbr().toString()))).collect(Collectors.toList()); JSONArray finalDictIds = dictIds;
List<DataDictionary> postDataList = dataDictionaries.stream().filter(d -> finalDictIds.stream().anyMatch(id -> id.toString().equals(d.getSequenceNbr().toString()))).collect(Collectors.toList());
return postDataList.stream().map(DataDictionary::getName).collect(Collectors.joining(",")); return postDataList.stream().map(DataDictionary::getName).collect(Collectors.joining(","));
} }
...@@ -175,9 +184,9 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -175,9 +184,9 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
List<TzsUserInfo> tzsUserInfos = tzsUserInfoMapper.selectList(lambda); List<TzsUserInfo> tzsUserInfos = tzsUserInfoMapper.selectList(lambda);
for (TzsUserInfo userInfo : tzsUserInfos) { for (TzsUserInfo userInfo : tzsUserInfos) {
tzsUserEquipMapper.delete(new QueryWrapper<TzsUserEquip>().eq("user_seq", userInfo.getSequenceNbr())); tzsUserEquipMapper.delete(new QueryWrapper<TzsUserEquip>().eq("user_seq", userInfo.getSequenceNbr()));
if(!ObjectUtils.isEmpty(userInfo.getAmosUserId())){ if (!ObjectUtils.isEmpty(userInfo.getAmosUserId())) {
Privilege.agencyUserClient.multDeleteUser(userInfo.getAmosUserId()); Privilege.agencyUserClient.multDeleteUser(userInfo.getAmosUserId());
deleteGroupAndPersonRelation(userInfo.getPostName(),userInfo.getAmosUserId()); deleteGroupAndPersonRelation(userInfo.getPostName(), userInfo.getAmosUserId());
} }
} }
} }
...@@ -187,7 +196,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -187,7 +196,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
public void deleteGroupAndPersonRelation(String postName, String amosUserId) { public void deleteGroupAndPersonRelation(String postName, String amosUserId) {
String[] split = postName.split(","); String[] split = postName.split(",");
for (String s : split) { for (String s : split) {
if(!ObjectUtils.isEmpty(TwoStipulateGroupEnum.getId.get(s))){ if (!ObjectUtils.isEmpty(TwoStipulateGroupEnum.getId.get(s))) {
Privilege.groupUserClient.deleteGroupUser(TwoStipulateGroupEnum.getId.get(s), amosUserId); Privilege.groupUserClient.deleteGroupUser(TwoStipulateGroupEnum.getId.get(s), amosUserId);
} }
} }
...@@ -270,18 +279,18 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -270,18 +279,18 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
} }
}); });
//添加人员管理角色 // 添加人员管理角色
String post = tzsUserInfo.getPost(); String post = tzsUserInfo.getPost();
if(post.contains(PersonManageRoleEnum.code.getId().toString())){ if (post.contains(PersonManageRoleEnum.code.getId().toString())) {
String companyType = tzsUserInfoMapper.selectCompanyTypeById(companySeq); String companyType = tzsUserInfoMapper.selectCompanyTypeById(companySeq);
if(companyType.contains(PersonManageRoleEnum.jyjc.getName())){ if (companyType.contains(PersonManageRoleEnum.jyjc.getName())) {
roleIds.add(PersonManageRoleEnum.jyjc.getId()); roleIds.add(PersonManageRoleEnum.jyjc.getId());
} }
if(companyType.contains(PersonManageRoleEnum.use.getName())){ if (companyType.contains(PersonManageRoleEnum.use.getName())) {
roleIds.add(PersonManageRoleEnum.use.getId()); roleIds.add(PersonManageRoleEnum.use.getId());
} }
if(companyType.contains(PersonManageRoleEnum.agw.getName())){ if (companyType.contains(PersonManageRoleEnum.agw.getName())) {
roleIds.add(PersonManageRoleEnum.agw.getId()); roleIds.add(PersonManageRoleEnum.agw.getId());
} }
} }
...@@ -299,7 +308,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -299,7 +308,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
tzsUserInfo.setAmosUserId(userResult.getResult().getUserId()); tzsUserInfo.setAmosUserId(userResult.getResult().getUserId());
tzsUserInfo.setAmosUserName(userResult.getResult().getUserName()); tzsUserInfo.setAmosUserName(userResult.getResult().getUserName());
tzsUserInfo.setLockStatus(status); tzsUserInfo.setLockStatus(status);
//绑定企业整改用户组 // 绑定企业整改用户组
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
userIds.add(userResult.getResult().getUserId()); userIds.add(userResult.getResult().getUserId());
DataDictionary roleGroup = iDataDictionaryService DataDictionary roleGroup = iDataDictionaryService
...@@ -307,7 +316,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -307,7 +316,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
if (!ObjectUtils.isEmpty(roleGroup) && roleGroup.getExtend() != null) { if (!ObjectUtils.isEmpty(roleGroup) && roleGroup.getExtend() != null) {
Privilege.groupUserClient.create(Long.valueOf(roleGroup.getExtend()), userIds); Privilege.groupUserClient.create(Long.valueOf(roleGroup.getExtend()), userIds);
} }
//绑定两个规定用户组 // 绑定两个规定用户组
post = post.replace("[", "").replace("]", "").replace("\"", ""); post = post.replace("[", "").replace("]", "").replace("\"", "");
for (String code : post.split(",")) { for (String code : post.split(",")) {
DataDictionary groupId = iDataDictionaryService DataDictionary groupId = iDataDictionaryService
...@@ -406,10 +415,10 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -406,10 +415,10 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
if (companyType.contains("充装单位") || companyType.contains("安装改造维修单位") || companyType.contains("制造单位") || companyType.contains("设计单位")) { if (companyType.contains("充装单位") || companyType.contains("安装改造维修单位") || companyType.contains("制造单位") || companyType.contains("设计单位")) {
productCompany = true; productCompany = true;
} }
if (companyType.contains("安装改造维修单位")){ if (companyType.contains("安装改造维修单位")) {
installCompany = true; installCompany = true;
} }
if (companyType.contains("检验检测机构")){ if (companyType.contains("检验检测机构")) {
inspectionCompany = true; inspectionCompany = true;
} }
} }
...@@ -467,7 +476,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -467,7 +476,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
@Override @Override
public List<TzsUserInfo> getSafetyList(String companyCode) { public List<TzsUserInfo> getSafetyList(String companyCode) {
return tzsUserInfoMapper.selectList(new QueryWrapper<TzsUserInfo>().eq("unit_code", companyCode).eq("is_delete",false).like("post", 6549)); return tzsUserInfoMapper.selectList(new QueryWrapper<TzsUserInfo>().eq("unit_code", companyCode).eq("is_delete", false).like("post", 6549));
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment