Przeglądaj źródła

合作管理修改+菜单权限

czh 2 lat temu
rodzic
commit
861deafb81

+ 1 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java

@@ -89,7 +89,7 @@ public class HttpStatus {
     public static final String LEGAL_NAME_ERROR = "法人格式不正确";
     public static final String LEGAL_PHONE_ERROR = "法人手机号格式不正确";
     public static final String LEGAL_ID_CARD_ERROR = "法人身份证号格式不正确";
-    public static final String ENT_CODE_ERROR = "企业编号格式不正确";
+    public static final String ENT_CODE_ERROR = "营业执照编号格式不正确";
 
     /**账号在别处登录状态码*/
     public static final int ACCOUNT_OTHER_LOGIN_CODE = 60900;

+ 32 - 22
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/CommonBusinessService.java

@@ -93,7 +93,7 @@ public class CommonBusinessService {
      * @author: czh
      * @date: 2023/7/12
      */
-    public Map<Long, UserCacheResDto> queryUserCacheMapByIds(List<Long> userIds){
+    public Map<Long, UserCacheResDto> queryUserCacheMapByIds(List<Long> userIds) {
         return remoteSystemService.queryUserCacheMapByIds(userIds);
     }
 
@@ -174,19 +174,23 @@ public class CommonBusinessService {
     public List<CooperateManageQueryResVo> getCooperateManageQueryResVos(List<CooperateManageQueryResDto> list) {
         //dubbo接口查用户和企业
         Long entId = LoginUserHolder.getEntId();
-        List<Long> userIds = list.stream().map(CooperateManageQueryResDto::getCreateBy).distinct().toList();
+        List<String> createByList = list.stream().map(CooperateManageQueryResDto::getCreateByStr).toList();
+        List<Long> userIds = new ArrayList<>();
+        for (String createByStr : createByList) {
+            String[] split = createByStr.split(Global.COMMA);
+            for (int n = 0; n < split.length; n ++) {
+                userIds.add(Long.valueOf(split[n]));
+            }
+        }
+
         List<Long> allEntIds = new ArrayList<>();
         List<Long> targetEntIds = list.stream().map(CooperateManageQueryResDto::getTargetEntId).distinct().toList();
         List<Long> ourEntIds = list.stream().map(CooperateManageQueryResDto::getOurEntId).distinct().toList();
         allEntIds.addAll(targetEntIds);
         allEntIds.addAll(ourEntIds);
-        List<UserCacheResDto> userCacheResDtos = remoteSystemService.queryUserCacheByIds(userIds);
+        Map<Long, UserCacheResDto> userCacheResDtoMap = remoteSystemService.queryUserCacheMapByIds(userIds);
         List<EntCacheResDto> entCacheResDtos = remoteSystemService.queryEntCacheByIds(allEntIds);
-        Map<Long, String> userMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         Map<Long, String> entMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
-        if (!CollectionUtils.isEmpty(userCacheResDtos)) {
-            userMap = userCacheResDtos.stream().collect(Collectors.toMap(UserCacheResDto::getId, UserCacheResDto::getName, (oldValue, newValue) -> newValue));
-        }
         if (!CollectionUtils.isEmpty(entCacheResDtos)) {
             entMap = entCacheResDtos.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (oldValue, newValue) -> newValue));
         }
@@ -201,7 +205,6 @@ public class CommonBusinessService {
             cooperateManageQueryResVo.setRemark(cooperateManageQueryResDto.getRemark());
             cooperateManageQueryResVo.setStatus(cooperateManageQueryResDto.getStatus());
             cooperateManageQueryResVo.setApplyTypeCode(cooperateManageQueryResDto.getApplyTypeCode());
-            cooperateManageQueryResVo.setCreateByName(userMap.get(cooperateManageQueryResDto.getCreateBy()));
             cooperateManageQueryResVo.setCreateTime(cooperateManageQueryResDto.getCreateTime());
             cooperateManageQueryResVo.setTargetEntName(targetEntName);
             cooperateManageQueryResVo.setTargetEntId(targetEntId);
@@ -209,15 +212,34 @@ public class CommonBusinessService {
             cooperateManageQueryResVo.setEntName(entMap.get(cooperateManageQueryResDto.getOurEntId()));
             cooperateManageQueryResVo.setApprovalRemark(cooperateManageQueryResDto.getApprovalRemark());
 
+            UserCacheResDto userCacheResDto = userCacheResDtoMap.get(cooperateManageQueryResDto.getCreateBy());
+            cooperateManageQueryResVo.setCreateByName(userCacheResDto.getName());
+
+            String typesStr = cooperateManageQueryResDto.getTypes();
+            List<Integer> typelist = new ArrayList<>();
+            String[] split = typesStr.split(Global.COMMA);
+            for (String typeStr : split) {
+                String[] split1 = typeStr.split(Global.POUND);
+                Integer type = Integer.valueOf(split1[0]);
+                Long userId = Long.valueOf(split1[1]);
+                UserCacheResDto userCacheResDto1 = userCacheResDtoMap.get(userId);
+                if (userCacheResDto1.getEntInfo().getId().equals(entId)) {
+                    typelist.add(type);
+                } else {
+                    typelist.add(changeAttribute(type));
+                }
+            }
+            cooperateManageQueryResVo.setCooperateTypes(String.join(Global.COMMA, typelist.stream().distinct().map(String::valueOf).toList()));
+
             //我方是发起方
-            if (entId.compareTo(cooperateManageQueryResDto.getEntId()) == 0) {
+            if (entId.equals(cooperateManageQueryResDto.getEntId())) {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviteeContacts());
                 cooperateManageQueryResVo.setPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setContactsId(cooperateManageQueryResDto.getInviteeContactsId());
                 cooperateManageQueryResVo.setManager(cooperateManageQueryResDto.getInviterContacts());
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviterPhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviterContactsId());
-                cooperateManageQueryResVo.setCooperateTypes(cooperateManageQueryResDto.getTypes());
+
             } else {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviterContacts());
                 cooperateManageQueryResVo.setPhone(cooperateManageQueryResDto.getInviterPhone());
@@ -225,18 +247,6 @@ public class CommonBusinessService {
                 cooperateManageQueryResVo.setManager(cooperateManageQueryResDto.getInviteeContacts());
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviteeContactsId());
-                cooperateManageQueryResVo.setCooperateTypes(changeCooperateType(cooperateManageQueryResDto.getTypes()));
-            }
-
-            //转换合作属性
-            String types = cooperateManageQueryResDto.getTypes();
-            List<Integer> typeList = Arrays.stream(types.split(Global.COMMA)).map(Integer::parseInt).distinct().toList();
-            if (!Objects.equals(LoginUserHolder.getEntId(), cooperateManageQueryResDto.getEntId())) {
-                List<Integer> targetTypes = new ArrayList<>();
-                for (Integer type : typeList) {
-                    targetTypes.add(changeCooperateType(type));
-                }
-                cooperateManageQueryResVo.setCooperateTypes(String.join(Global.COMMA,targetTypes.stream().distinct().map(String::valueOf).toList()));
             }
 
             result.add(cooperateManageQueryResVo);

+ 37 - 29
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateApplyService.java

@@ -116,7 +116,6 @@ public class KwmCooperateApplyService {
         allEntIds.addAll(targetEntIds);
         Map<Long, UserCacheResDto> userCacheResDtoMap = remoteSystemService.queryUserCacheMapByIds(userIds);
         List<EntCacheResDto> entCacheResDtos = remoteSystemService.queryEntCacheByIds(allEntIds);
-        Map<Long, String> userMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         Map<Long, String> entMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         if (!CollectionUtils.isEmpty(entCacheResDtos)) {
             entMap = entCacheResDtos.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (oldValue, newValue) -> newValue));
@@ -134,13 +133,11 @@ public class KwmCooperateApplyService {
             cooperateManageQueryResVo.setStatus(cooperateManageQueryResDto.getStatus());
 
             UserCacheResDto userCacheResDto = userCacheResDtoMap.get(cooperateManageQueryResDto.getCreateBy());
-            if (Objects.nonNull(userCacheResDto)) {
-                cooperateManageQueryResVo.setCreateByName(userCacheResDto.getName());
-                EntCacheResDto entInfo = userCacheResDto.getEntInfo();
-                if (Objects.nonNull(entInfo)) {
-                    cooperateManageQueryResVo.setApplyTypeCode(entId.equals(entInfo.getId()) ? Global.NUMERICAL_ONE : Global.NUMERICAL_TWO);
-                }
-            }
+            cooperateManageQueryResVo.setCreateByName(userCacheResDto.getName());
+            EntCacheResDto entInfo = userCacheResDto.getEntInfo();
+            boolean isOur = entId.equals(entInfo.getId());
+            cooperateManageQueryResVo.setApplyTypeCode(isOur ? Global.NUMERICAL_ONE : Global.NUMERICAL_TWO);
+
             cooperateManageQueryResVo.setTargetEntName(targetEntName);
             cooperateManageQueryResVo.setTargetEntId(targetEntId);
             cooperateManageQueryResVo.setEntId(cooperateManageQueryResDto.getOurEntId());
@@ -148,7 +145,7 @@ public class KwmCooperateApplyService {
             cooperateManageQueryResVo.setApprovalRemark(cooperateManageQueryResDto.getApprovalRemark());
 
             //我方是发起方
-            if (entId.compareTo(cooperateManageQueryResDto.getEntId()) == 0) {
+            if (isOur) {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviteeContacts());
                 cooperateManageQueryResVo.setPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setContactsId(cooperateManageQueryResDto.getInviteeContactsId());
@@ -156,7 +153,6 @@ public class KwmCooperateApplyService {
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviterPhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviterContactsId());
                 cooperateManageQueryResVo.setCooperateTypes(cooperateManageQueryResDto.getTypes());
-
             } else {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviterContacts());
                 cooperateManageQueryResVo.setPhone(cooperateManageQueryResDto.getInviterPhone());
@@ -165,7 +161,6 @@ public class KwmCooperateApplyService {
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviteeContactsId());
                 cooperateManageQueryResVo.setCooperateTypes(commonBusinessService.changeCooperateType(cooperateManageQueryResDto.getTypes()));
-
             }
 
             result.add(cooperateManageQueryResVo);
@@ -257,30 +252,28 @@ public class KwmCooperateApplyService {
                 }
 
                 for (KwmCooperateType kwmCooperateType : kwmCooperateTypeList) {
-                    if (cooperateQueryDto.getKwmCooperate().getEntId().equals(currentEntId) && kwmCooperateType.getStatus() == CooperateStatusEnum.PROCESS.getCode()) {
+                    if (kwmCooperateType.getStatus().equals(CooperateStatusEnum.PROCESS.getCode())) {
                         throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.MSG_015);
                     }
                 }
 
                 //已合作的可以新增,但不能重复新增
                 List<Integer> typeList = kwmCooperateTypeList.stream().map(KwmCooperateType::getType).toList();
-                if (cooperateQueryDto.getKwmCooperate().getInviterEntId().equals(currentEntId)) {
-                    chooseCooperateTypes.forEach(item -> {
-                        if (typeList.contains(item)) {
-                            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_016);
-                        }
-                    });
-                }
+                chooseCooperateTypes.forEach(item -> {
+                    if (typeList.contains(item)) {
+                        throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_016);
+                    }
+                });
 
-                //对方发起了与之相对的申请,也不能再申请
-                if (cooperateQueryDto.getKwmCooperate().getInviteeEntId().equals(currentEntId)) {
-                    chooseCooperateTypes.forEach(item -> {
-                        Integer relative = commonBusinessService.changeAttribute(item);
-                        if (typeList.contains(relative)) {
-                            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_016);
-                        }
-                    });
-                }
+//                //对方发起了与之相对的申请,也不能再申请
+//                if (cooperateQueryDto.getKwmCooperate().getInviteeEntId().equals(currentEntId)) {
+//                    chooseCooperateTypes.forEach(item -> {
+//                        Integer relative = commonBusinessService.changeAttribute(item);
+//                        if (typeList.contains(relative)) {
+//                            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_016);
+//                        }
+//                    });
+//                }
             }
         }
         //保存发起申请
@@ -448,10 +441,25 @@ public class KwmCooperateApplyService {
         }
 
         List<CooperateQueryDto> list = new ArrayList<>();
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(currentEntId);
+
         for (KwmCooperate kwmCooperate : kwmCooperates) {
             CooperateQueryDto cooperateQueryDto = new CooperateQueryDto();
             cooperateQueryDto.setKwmCooperate(kwmCooperate);
-            cooperateQueryDto.setKwmCooperateTypeList(map.get(kwmCooperate.getId()));
+
+            List<KwmCooperateType> kwmCooperateTypeList = map.get(kwmCooperate.getId());
+            if (CollectionUtils.isNotEmpty(kwmCooperateTypeList)) {
+                List<Long> longs = kwmCooperateTypeList.stream().map(KwmCooperateType::getCreateBy).toList();
+                Map<Long, UserCacheResDto> longUserCacheResDtoMap = remoteSystemService.queryUserCacheMapByIds(longs);
+                for (KwmCooperateType kwmCooperateType : kwmCooperateTypeList) {
+                    Long createBy = kwmCooperateType.getCreateBy();
+                    if (!entCacheResDto.getId().equals(longUserCacheResDtoMap.get(createBy).getEntInfo().getId())) {
+                        kwmCooperateType.setType(commonBusinessService.changeCooperateType(kwmCooperateType.getType()));
+                    }
+                }
+            }
+
+            cooperateQueryDto.setKwmCooperateTypeList(kwmCooperateTypeList);
             list.add(cooperateQueryDto);
         }
 

+ 21 - 9
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java

@@ -423,7 +423,7 @@ public class KwmCooperateManageService {
         Long id = reqVo.getId();
         List<KwmCooperate> kwmCooperates = kwmCooperateMapper.findEntCooperate(reqVo);
         if (CollectionUtils.isEmpty(kwmCooperates)) {
-            return null;
+            return Collections.emptyList();
         }
 
         List<KwmCooperateType> kwmCooperateTypeList = new ArrayList<>();
@@ -517,6 +517,7 @@ public class KwmCooperateManageService {
         LambdaQueryWrapper<KwmCooperateType> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(KwmCooperateType::getCooperateId, cooperateIdList);
         wrapper.eq(KwmCooperateType::getDelFlag, Global.NO);
+        wrapper.eq(KwmCooperateType::getStatus, CooperateStatusEnum.OK.getCode());
         List<KwmCooperateType> kwmCooperateTypes = kwmCooperateTypeMapper.selectList(wrapper);
         Map<Long, List<KwmCooperateType>> collect = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         if (CollectionUtils.isNotEmpty(kwmCooperateTypes)) {
@@ -537,6 +538,7 @@ public class KwmCooperateManageService {
         }
 
         List<FindCooperateByEntResVo> list = new ArrayList<>();
+        List<Integer> cooperateTypeList = new ArrayList<>();
         for (KwmCooperate kwmCooperate : kwmCooperates) {
             FindCooperateByEntResVo findCooperateByEntResVo = new FindCooperateByEntResVo();
             findCooperateByEntResVo.setId(kwmCooperate.getId());
@@ -555,13 +557,24 @@ public class KwmCooperateManageService {
 
 
             Long entId = reqVo.getEntId();
-
-            Map<Long, EntCacheResDto> longEntCacheResDtoMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(entId));
-            Long topId = longEntCacheResDtoMap.get(entId).getId();
+            Map<Long, EntCacheResDto> entCacheResDtoMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(entId));
+            Long topId = entCacheResDtoMap.get(entId).getId();
             //设置合作属性
-            List<KwmCooperateType> kwmCooperateTypes1 = collect.get(kwmCooperate.getId());
-            String cooperateTypes = String.join(Global.COMMA, kwmCooperateTypes1.stream().map(KwmCooperateType::getType).map(String::valueOf).toList());
-
+            List<KwmCooperateType> kwmCooperateTypeList = collect.get(kwmCooperate.getId());
+            List<Long> userIds = kwmCooperateTypeList.stream().map(KwmCooperateType::getCreateBy).toList();
+            Map<Long, UserCacheResDto> userCacheResDtoMap = remoteSystemService.queryUserCacheMapByIds(userIds);
+            for (KwmCooperateType kwmCooperateType : kwmCooperateTypeList) {
+                Long createBy = kwmCooperateType.getCreateBy();
+                UserCacheResDto userCacheResDto = userCacheResDtoMap.get(createBy);
+                Long id = userCacheResDto.getEntInfo().getId();
+                if (id.equals(topId)) {
+                    cooperateTypeList.add(kwmCooperateType.getType());
+                } else {
+                    cooperateTypeList.add(commonBusinessService.changeCooperateType(kwmCooperateType.getType()));
+                }
+            }
+            String cooperateTypes = String.join(Global.COMMA, cooperateTypeList.stream().map(String::valueOf).distinct().toList());
+            findCooperateByEntResVo.setCooperateTypes(cooperateTypes);
             //设置我方和对方企业信息、联系人
             if (topId.equals(kwmCooperate.getEntId())) {
                 findCooperateByEntResVo.setEntId(kwmCooperate.getInviterEntId());
@@ -574,7 +587,6 @@ public class KwmCooperateManageService {
                 findCooperateByEntResVo.setTargetContactsId(kwmCooperate.getInviteeContactsId());
                 findCooperateByEntResVo.setTargetContacts(kwmCooperate.getInviteeContacts());
                 findCooperateByEntResVo.setTargetPhone(kwmCooperate.getInviteePhone());
-                findCooperateByEntResVo.setCooperateTypes(cooperateTypes);
             } else {
                 findCooperateByEntResVo.setEntId(kwmCooperate.getInviteeEntId());
                 findCooperateByEntResVo.setEntName(inviteeEntName);
@@ -586,9 +598,9 @@ public class KwmCooperateManageService {
                 findCooperateByEntResVo.setTargetContactsId(kwmCooperate.getInviterContactsId());
                 findCooperateByEntResVo.setTargetContacts(kwmCooperate.getInviterContacts());
                 findCooperateByEntResVo.setTargetPhone(kwmCooperate.getInviterPhone());
-                findCooperateByEntResVo.setCooperateTypes(commonBusinessService.changeCooperateType(cooperateTypes));
             }
             list.add(findCooperateByEntResVo);
+            cooperateTypeList.clear();
         }
         return list;
     }

+ 2 - 1
sckw-modules/sckw-manage/src/main/resources/mapper/KwmCooperateMapper.xml

@@ -134,7 +134,7 @@
     <select id="findManageList" resultType="com.sckw.manage.model.dto.res.CooperateManageQueryResDto">
         SELECT a.id,
                 min(a.status) status,
-                group_concat(b.type) types,
+                group_concat(concat(b.type, '#', b.create_by)) types,
                 min(a.ent_id) entId,
                 min(a.invitee_ent_id) inviteeEntId,
                 min(a.inviter_ent_id) inviterEntId,
@@ -146,6 +146,7 @@
                 min(a.inviter_phone) inviterPhone,
                 min(b.create_time) createTime,
                 min(b.create_by) createBy,
+                group_concat(b.create_by) createByStr,
                 min(a.remark) remark,
                 min(a.approval_remark) approvalRemark,
                 case when min(a.ent_id) = #{reqDto.currentEntId} then min(a.invitee_ent_id) else min(a.inviter_ent_id) end targetEntId,

+ 5 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/pojo/FindMenuTreePojo.java

@@ -37,4 +37,9 @@ public class FindMenuTreePojo {
      */
     private List<Long> roleIds;
 
+    /**
+     * 企业类型
+     */
+    private List<String> entTypeList;
+
 }

+ 6 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsMenuService.java

@@ -53,6 +53,9 @@ public class KwsMenuService {
     @Autowired
     KwsMenuMappingDao kwsMenuMappingDao;
 
+    @Autowired
+    KwsEntTypeDao kwsEntTypeDao;
+
     /**
      * @param params 实体
      * @desc: 添加新纪录
@@ -319,6 +322,9 @@ public class KwsMenuService {
             return;
         }
         if (Objects.equals(LoginUserHolder.getIsMain(), Global.YES)) {
+            Long entId = LoginUserHolder.getEntId();
+            List<KwsEntType> listByEntId = kwsEntTypeDao.findListByEntId(entId);
+            findMenuTreePojo.setEntTypeList(listByEntId.stream().map(KwsEntType::getType).map(String::valueOf).toList());
             findMenuTreePojo.setEntId(LoginUserHolder.getEntId());
             return;
         }

+ 6 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsMenuDao.xml

@@ -276,6 +276,12 @@
     <if test="name != null and name != ''">
       and sm.name = #{name, jdbcType=VARCHAR}
     </if>
+      <if test="entTypeList != null and entTypeList.size() > 0">
+        and
+        <foreach collection="entTypeList" item="item" open="(" close=")" separator=" or ">
+          using_roles like concat('%', #{item}, '%')
+        </foreach>
+      </if>
     <if test="entId != null">
       and smr.ent_id = #{entId}
       and smr.role_id is null