Commit 8bc5d3a3 authored by suhuiguang's avatar suhuiguang

feat(jg): 人员管理

1.人员类型增加业务负责人(使用单位、按改为单位、检验机构、检测机构)
parent 5cf598a3
......@@ -8,7 +8,8 @@
"6616": [],
"6761": [],
"6762": [],
"6766": []
"6766": [],
"6767": []
},
"检测机构": {
"6660": [],
......@@ -19,7 +20,8 @@
"6616": [],
"6761": [],
"6762": [],
"6766": []
"6766": [],
"6767": []
},
"设计单位": {
"6660": [],
......@@ -80,7 +82,8 @@
"6551": [],
"6616": [],
"6553": [],
"6766": []
"6766": [],
"6767": []
},
"使用单位": {
"6552": ["6713"],
......@@ -93,7 +96,8 @@
"66151": [],
"66152": [],
"6667": [],
"6766": []
"6766": [],
"6767": []
},
"个人主体": {
"6552": ["6713"],
......@@ -106,7 +110,8 @@
"66151": [],
"66152": [],
"6667": [],
"6766": []
"6766": [],
"6767": []
},
"监管机构": {
"6766": []
......
......@@ -43,4 +43,30 @@ public interface BizCommonConstant {
* */
String REGULATOR_UNIT_LIST = "REGULATOR_UNIT_LIST";
/**
* 业务负责人人员类型
*/
String POST_TYPE_JYJC_CHANGE_PERSON = "6767";
/**
* 业务负责人,角色字段类型
*/
String YWFZR_DICT_TYPE = "YWFZR";
/**
* 业务负责人,角色字段类型
*/
String YWFZR_DICT_CODE = "YWFZR";
/**
* 业务类型-检验
*/
String BIZ_TYPE_JY = "jy";
/**
* 业务类型-检测
*/
String BIZ_TYPE_JC = "jc";
}
......@@ -39,6 +39,7 @@ import com.yeejoin.amos.boot.module.common.biz.event.CommonPublisher;
import com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent;
import com.yeejoin.amos.boot.module.common.biz.refresh.listener.DataRefreshListener;
import com.yeejoin.amos.boot.module.common.biz.service.impl.TZSCommonServiceImpl;
import com.yeejoin.amos.boot.module.tcm.api.common.BizCommonConstant;
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.enums.EquipmentClassifityEnum;
......@@ -173,6 +174,8 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
private static Map<String, String> statusColorMap = new HashMap<>();
static {
statusColorMap.put("无资质要求", "#868686");
statusColorMap.put("资质超期", "#FF0000");
......@@ -523,7 +526,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
Long companySeq = reginParams.getCompany().getSequenceNbr();
List<String> appCodesSet = reginParams.getUserModel().getAppCodes();
List<RoleModel> allRoleList = new ArrayList<>();
List<Long> roleIds = new ArrayList<>();
Set<Long> roleIds = new HashSet<>();
DataDictionary unitType = iDataDictionaryService
.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getCode, roles).eq(DataDictionary::getType, USER_ROLE));
String role = unitType.getExtend() != null ? unitType.getExtend() : "";
......@@ -532,9 +535,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
allRoleList.add(roleModel);
}
allRoleList.forEach(r -> {
if (!roleIds.contains(r.getSequenceNbr())) {
roleIds.add(r.getSequenceNbr());
}
roleIds.add(r.getSequenceNbr());
});
// 添加人员管理角色
......@@ -542,18 +543,21 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
String newPostStr = tzsUserInfo.getNewPost();
if (newPostStr != null) {
JSONArray newPost = JSON.parseArray(newPostStr);
String companyType = tzsUserInfoMapper.selectCompanyTypeById(companySeq);
if (newPost.contains(PersonManageRoleEnum.code.getId().toString())) {
String companyType = tzsUserInfoMapper.selectCompanyTypeById(companySeq);
setBizOperateUserRole(companyType, roleIds);
}
if (newPost.contains(PersonManageRoleEnum.risk_code.getId().toString())) {
setBizOperateUserRoleWithPost(newPost, roleIds);
}
if (newPost.contains(BizCommonConstant.POST_TYPE_JYJC_CHANGE_PERSON)) {
setBizChargePersonRoleByUnitType(companyType, roleIds);
}
}
Map<Long, List<Long>> roleSeqMap = new HashMap<>();
Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
roleSeqMap.put(companySeq, roleIds);
roleSeqMap.put(companySeq, new ArrayList<>(roleIds));
orgRoles.put(companySeq, allRoleList);
agencyUserModel.setAppCodes(new ArrayList<>(appCodesSet));
agencyUserModel.setOrgRoles(orgRoles);
......@@ -2137,11 +2141,9 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
String passwd = DesUtil.encode("a_" + tzsUserInfo.getPhone(), "qaz");
// 获取对应单位类型下的引用并去重
Set<String> appCodesSet = getAppKeys(userImportDto, dataDictionaryMap);
List<Long> roleIds = new ArrayList<>();
Set<Long> roleIds = new HashSet<>();
allRoleList.forEach(r -> {
if (!roleIds.contains(r.getSequenceNbr())) {
roleIds.add(r.getSequenceNbr());
}
roleIds.add(r.getSequenceNbr());
});
AgencyUserModel agencyUserModel = new AgencyUserModel();
agencyUserModel.setUserName(tzsUserInfo.getPhone());
......@@ -2162,10 +2164,13 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
if (newPost.contains(PersonManageRoleEnum.risk_code.getId().toString())) {
setBizOperateUserRoleWithPost(newPost, roleIds);
}
if (newPost.contains(BizCommonConstant.POST_TYPE_JYJC_CHANGE_PERSON)) {
setBizChargePersonRoleByUnitType(companyType, roleIds);
}
}
Map<Long, List<Long>> roleSeqMap = new HashMap<>();
Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
roleSeqMap.put(companyModel.getSequenceNbr(), roleIds);
roleSeqMap.put(companyModel.getSequenceNbr(), new ArrayList<>(roleIds));
orgRoles.put(companyModel.getSequenceNbr(), allRoleList);
agencyUserModel.setAppCodes(new ArrayList<>(appCodesSet));
agencyUserModel.setOrgRoles(orgRoles);
......@@ -2193,6 +2198,22 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
}
}
private void setBizChargePersonRoleByUnitType(String companyType, Set<Long> roleIds) {
// 角色id维护到字典extend字段,多个用逗号分隔(不再写死的代码,便于调整)
List<DataDictionary> dataDictionaries = iDataDictionaryService.getByType(BizCommonConstant.YWFZR_DICT_TYPE);
Map<String,List<Long>> bizTypeRoleMap = dataDictionaries.stream().collect(Collectors.toMap(DataDictionary::getCode,
d-> Arrays.stream(d.getExtend().split(",")).map(Long::parseLong).collect(Collectors.toList())));
// TODO 注意人所在单位为多单位类型时,在任意一个单位类型绑定账号时,会将所有单位类型下需要绑定的角色都进行分配
// 使用单位、安改维修、检测机构有检测业务负责人的角色
if(companyType.contains(UnitTypeEnum.sydw.getName()) || companyType.contains(UnitTypeEnum.azgzwxdw.getName()) || companyType.contains(UnitTypeEnum.jcjg.getName())){
roleIds.addAll(bizTypeRoleMap.get(BizCommonConstant.BIZ_TYPE_JC));
}
// 检验机构有检验机构负责夫人角色
if(companyType.contains(UnitTypeEnum.jyjg.getName())){
roleIds.addAll(bizTypeRoleMap.get(BizCommonConstant.BIZ_TYPE_JY));
}
}
private CompanyModel getCompanyModelUseCache(TzsUserInfo tzsUserInfo, Map<String, CompanyModel> companyCodeCompanyMap) {
CompanyModel companyModel;
if (companyCodeCompanyMap.get(tzsUserInfo.getUnitCode()) != null) {
......@@ -2218,7 +2239,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
return appCodesSet;
}
private void setBizOperateUserRole(String companyType, List<Long> roleIds) {
private void setBizOperateUserRole(String companyType, Set<Long> roleIds) {
if (companyType.contains(PersonManageRoleEnum.jyjg.getName())) {
roleIds.add(PersonManageRoleEnum.jyjg.getId());
}
......@@ -2521,7 +2542,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
String roleGroupCode = qyryyhzList.get(0).getCode();
List<RoleModel> allRoleList = new ArrayList<>();
List<Long> roleIds = new ArrayList<>();
Set<Long> roleIds = new HashSet<>();
DataDictionary unitType = iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getCode, roles).eq(DataDictionary::getType, USER_ROLE));
String role = unitType.getExtend() != null ? unitType.getExtend() : "";
for (String s : role.split(",")) {
......@@ -2529,28 +2550,26 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
allRoleList.add(roleModel);
}
allRoleList.forEach(r -> {
if (!roleIds.contains(r.getSequenceNbr())) {
roleIds.add(r.getSequenceNbr());
}
roleIds.add(r.getSequenceNbr());
});
// 添加人员管理角色
String newPostStr = tzsUserInfoDto.getNewPost();
if (newPostStr != null) {
JSONArray newPost = JSON.parseArray(newPostStr);
String companyType = tzsUserInfoMapper.selectCompanyTypeById(companySeq);
if (newPost.contains(PersonManageRoleEnum.code.getId().toString())) {
CompanyModel companyModel = Optional.ofNullable(Privilege.companyClient.seleteOne(companySeq)).map(FeignClientResult::getResult).orElse(null);
if (!ValidationUtil.isEmpty(companyModel)) {
String companyType = companyModel.getCompanyType();
setBizOperateUserRole(companyType, roleIds);
}
setBizOperateUserRole(companyType, roleIds);
}
if (newPost.contains(PersonManageRoleEnum.risk_code.getId().toString())) {
setBizOperateUserRoleWithPost(newPost, roleIds);
}
if (newPost.contains(BizCommonConstant.POST_TYPE_JYJC_CHANGE_PERSON)) {
setBizChargePersonRoleByUnitType(companyType, roleIds);
}
}
Map<Long, List<Long>> roleSeqMap = new HashMap<>();
Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
roleSeqMap.put(companySeq, roleIds);
roleSeqMap.put(companySeq, new ArrayList<>(roleIds));
orgRoles.put(companySeq, allRoleList);
AgencyUserModel agencyUserModel = userFeignClientResult.getResult();
......@@ -2581,7 +2600,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
}
}
private void setBizOperateUserRoleWithPost(JSONArray newPost, List<Long> roleIds) {
private void setBizOperateUserRoleWithPost(JSONArray newPost, Set<Long> roleIds) {
if (newPost.contains(PersonManageRoleEnum.risk_code.getId().toString())) {
roleIds.add(PersonManageRoleEnum.fxbsy.getId());
}
......
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