diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java index 0e7e508c8..38331b390 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java @@ -183,8 +183,9 @@ public class ParamsCollectManifestEOController extends JeroController getLoginUserTypes(ParamsCollectManifestVO paramsCollectManifestVO) { - String loginUserType = paramsCollectManifestEOService.getLoginUserTypes(paramsCollectManifestVO); + public Result getLoginUserTypes(ParamsCollectManifestVO paramsCollectManifestVO, + @RequestParam(name="cut") String cut) { + List> loginUserType = paramsCollectManifestEOService.getLoginUserTypes(paramsCollectManifestVO, cut); return Result.OK(loginUserType); } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestRoleIdEnum.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestRoleIdEnum.java new file mode 100644 index 000000000..88eb054be --- /dev/null +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestRoleIdEnum.java @@ -0,0 +1,100 @@ +package com.jero.modules.cert.collect.enums; + +import cn.hutool.core.collection.CollectionUtil; +import com.jero.modules.project.entity.ConditionAssessmentEO; +import com.jero.modules.split.enums.StandFileClassifyEnum; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +/** + * @Author: liyawei + * @Description: + * @Date: Created in 10:56 2022/6/11 + */ +public enum CollectManifestRoleIdEnum { + STUDIO_ID("R&H Studio","R&H Studio","studio","1534019911296118786",1), + ADMIN_ID("R&H Manager","Administrator","admin","f6817f48af4fb3af11b9e8bf182f618b",2), + MANAGER_ID("系统管理员","R&H Manager","manager","1534020391015444481",3); + + String name; + String enName; + String value; + String id; + Integer order; + + CollectManifestRoleIdEnum(String name, String enName, String value, String id, Integer order) { + this.name = name; + this.enName = enName; + this.value = value; + this.id = id; + this.order = order; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getEnName() { + return enName; + } + + public void setEnName(String enName) { + this.enName = enName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getOrder() { + return order; + } + + public void setOrder(Integer order) { + this.order = order; + } + + public static List getIdList() { + List idList = new ArrayList<>(); + CollectManifestRoleIdEnum[] values = values(); + for (CollectManifestRoleIdEnum collectManifestRoleIdEnum : values) { + idList.add(collectManifestRoleIdEnum.getId()); + } + return idList; + } + + public static List getByIdList(List idList) { + List collectManifestRoleIdEnums = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(idList)) { + CollectManifestRoleIdEnum[] values = values(); + for (CollectManifestRoleIdEnum collectManifestRoleIdEnum : values) { + if (idList.contains(collectManifestRoleIdEnum.getId())) { + collectManifestRoleIdEnums.add(collectManifestRoleIdEnum); + } + } + } + if (CollectionUtil.isNotEmpty(collectManifestRoleIdEnums) && collectManifestRoleIdEnums.size() > 1) { + collectManifestRoleIdEnums.stream().sorted(Comparator.comparing(CollectManifestRoleIdEnum :: getOrder)); + } + return collectManifestRoleIdEnums; + } +} diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestUserTypeEnum.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestUserTypeEnum.java index aa858d512..b9a2956e3 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestUserTypeEnum.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestUserTypeEnum.java @@ -1,21 +1,29 @@ package com.jero.modules.cert.collect.enums; +import java.util.ArrayList; +import java.util.List; + /** * @Author: liyawei * @Description: * @Date: Created in 16:47 2022/5/11 */ public enum CollectManifestUserTypeEnum { - HOMO("认证工程师","homo"), - SDT("工程接口人","sdt"), - DRE("填写人","dre"), - GUEST("游客","guest"); + HOMO("认证工程师", "Homologation Engineer", "homo"), + SDT("工程接口人", "Sdt People","sdt"), + DRE("填写人", "Dre People","dre"), + STUDIO("R&H Studio","R&H Studio","studio"), + MANAGER("R&H Manager","R&H Manager","manager"), + ADMIN("系统管理员","Administrator","admin"), + GUEST("游客", "Guest","guest"); String name; + String enName; String value; - CollectManifestUserTypeEnum(String name, String value) { + CollectManifestUserTypeEnum(String name, String enName, String value) { this.name = name; + this.enName = enName; this.value = value; } @@ -27,6 +35,14 @@ public enum CollectManifestUserTypeEnum { this.name = name; } + public String getEnName() { + return enName; + } + + public void setEnName(String enName) { + this.enName = enName; + } + public String getValue() { return value; } @@ -34,4 +50,18 @@ public enum CollectManifestUserTypeEnum { public void setValue(String value) { this.value = value; } + + public static boolean doesValueExist(String value) { + CollectManifestUserTypeEnum[] values = values(); + + List valueList = new ArrayList<>(); + for (CollectManifestUserTypeEnum collectManifestUserTypeEnum : values) { + valueList.add(collectManifestUserTypeEnum.getValue()); + } + + if (valueList.contains(value)) { + return true; + } + return false; + } } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java index 89c250855..bbbaef140 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java @@ -89,7 +89,7 @@ public interface IParamsCollectManifestEOService extends IService> querySdtList(ParamsCollectManifestVO paramsCollectManifestVO); - String getLoginUserTypes(ParamsCollectManifestVO paramsCollectManifestVO); + List> getLoginUserTypes(ParamsCollectManifestVO paramsCollectManifestVO, String cut); Map isCollectFinished(String paramsManifestId); diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java index 458ceb583..dd6164bb3 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java @@ -3,6 +3,7 @@ package com.jero.modules.cert.collect.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Lists; import com.jero.common.constant.CommonConstant; @@ -17,10 +18,7 @@ import com.jero.modules.cert.collect.entity.ParamsCollectManifestEO; import com.jero.modules.cert.collect.entity.ParamsConfigDataEO; import com.jero.modules.cert.collect.entity.ParamsConfigEO; import com.jero.modules.cert.collect.entity.ParamsManifestEO; -import com.jero.modules.cert.collect.enums.CollectManifestStateEnum; -import com.jero.modules.cert.collect.enums.CollectManifestUserTypeEnum; -import com.jero.modules.cert.collect.enums.ConfigDataTypeEnum; -import com.jero.modules.cert.collect.enums.ConfigLockEnum; +import com.jero.modules.cert.collect.enums.*; import com.jero.modules.cert.collect.mapper.ParamsCollectManifestEOMapper; import com.jero.modules.cert.collect.service.IParamsCollectManifestEOService; import com.jero.modules.cert.collect.service.IParamsConfigDataEOService; @@ -44,8 +42,10 @@ import com.jero.modules.project.service.IProjectRelatedPersonnelService; import com.jero.modules.system.entity.SysAnnouncement; import com.jero.modules.system.entity.SysDictItem; import com.jero.modules.system.entity.SysUser; +import com.jero.modules.system.entity.SysUserRole; import com.jero.modules.system.service.ISysAnnouncementService; import com.jero.modules.system.service.ISysDictItemService; +import com.jero.modules.system.service.ISysUserRoleService; import com.jero.modules.system.service.ISysUserService; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; @@ -107,6 +107,8 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl> getLoginUserTypes(ParamsCollectManifestVO paramsCollectManifestVO, String cut) { String projectId = paramsCollectManifestVO.getProjectId(); String paramsManifestId = paramsCollectManifestVO.getParamsManifestId(); - StringBuilder userTypesBuilder=new StringBuilder(); // 一个用户可以有多个用户类型 + List> userTypeList = new ArrayList<>(); // 一个用户可以有多个用户类型 LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); // 获取当前登录用户 // 查询项目下所有责任领域下的 homo,sdt人员 @@ -760,7 +773,15 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl homoIdList = Arrays.asList(homoIdStr.split(",")).stream().distinct().collect(Collectors.toList()); homoList = sysUserService.listByIds(homoIdList).stream().map(SysUser::getUsername).collect(Collectors.toList()); } else { - return CollectManifestUserTypeEnum.GUEST.getValue(); + Map map = new HashMap<>(); + if (CutEnum.CN.getValue().equals(cut)) { + map.put("label", CollectManifestUserTypeEnum.GUEST.getName()); + } else { + map.put("label", CollectManifestUserTypeEnum.GUEST.getEnName()); + } + map.put("value", CollectManifestUserTypeEnum.GUEST.getValue()); + userTypeList.add(map); + return userTypeList; } // 项目下有homo-->必定有sdt List sdtIdList = Arrays.asList(sdtIdStr.split(",")).stream().distinct().collect(Collectors.toList()); @@ -783,26 +804,77 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl userRoles = sysUserRoleService.list(new QueryWrapper().lambda().eq(SysUserRole::getUserId, loginUser.getId())); // 查询用户所有角色 + List userRoleIds = new ArrayList<>(); // 用户管理员/领导/studio角色 + if (CollectionUtil.isNotEmpty(userRoles)) { + List roleIdList = CollectManifestRoleIdEnum.getIdList(); + List userRoleIdList = userRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()); + userRoleIds = roleIdList.stream().filter(e->userRoleIdList.contains(e)).collect(Collectors.toList()); + } + if (CollectionUtil.isEmpty(userRoleIds) && !homoList.contains(loginUser.getUsername()) && !sdtList.contains(loginUser.getUsername()) && !dreListOfPCM.contains(loginUser.getUsername())) { - return CollectManifestUserTypeEnum.GUEST.getValue(); + Map map = new HashMap<>(); + if (CutEnum.CN.getValue().equals(cut)) { + map.put("label", CollectManifestUserTypeEnum.GUEST.getName()); + } else { + map.put("label", CollectManifestUserTypeEnum.GUEST.getEnName()); + } + map.put("value", CollectManifestUserTypeEnum.GUEST.getValue()); + userTypeList.add(map); + return userTypeList; } if (homoList.contains(loginUser.getUsername())) { - userTypesBuilder.append(CollectManifestUserTypeEnum.HOMO.getValue()).append(","); + Map map = new HashMap<>(); + if (CutEnum.CN.getValue().equals(cut)) { + map.put("label", CollectManifestUserTypeEnum.HOMO.getName()); + } else { + map.put("label", CollectManifestUserTypeEnum.HOMO.getEnName()); + } + map.put("value", CollectManifestUserTypeEnum.HOMO.getValue()); + userTypeList.add(map); } if (sdtList.contains(loginUser.getUsername())) { - userTypesBuilder.append(CollectManifestUserTypeEnum.SDT.getValue()).append(","); + Map map = new HashMap<>(); + if (CutEnum.CN.getValue().equals(cut)) { + map.put("label", CollectManifestUserTypeEnum.SDT.getName()); + } else { + map.put("label", CollectManifestUserTypeEnum.SDT.getEnName()); + } + map.put("value", CollectManifestUserTypeEnum.SDT.getValue()); + userTypeList.add(map); } if (dreListOfPCM.contains(loginUser.getUsername())) { - userTypesBuilder.append(CollectManifestUserTypeEnum.DRE.getValue()).append(","); + Map map = new HashMap<>(); + if (CutEnum.CN.getValue().equals(cut)) { + map.put("label", CollectManifestUserTypeEnum.DRE.getName()); + } else { + map.put("label", CollectManifestUserTypeEnum.DRE.getEnName()); + } + map.put("value", CollectManifestUserTypeEnum.DRE.getValue()); + userTypeList.add(map); } - return userTypesBuilder.substring(0, userTypesBuilder.toString().length() - 1); + if (CollectionUtil.isNotEmpty(userRoleIds)) { + List collectManifestRoleIdEnumList = CollectManifestRoleIdEnum.getByIdList(userRoleIds); + for (CollectManifestRoleIdEnum collectManifestRoleIdEnum : collectManifestRoleIdEnumList) { + Map map = new HashMap<>(); + if (CutEnum.CN.getValue().equals(cut)) { + map.put("label", collectManifestRoleIdEnum.getName()); + } else { + map.put("label", collectManifestRoleIdEnum.getEnName()); + } + map.put("value", collectManifestRoleIdEnum.getValue()); + userTypeList.add(map); + } + } + + return userTypeList; } @Override