czh 2 yıl önce
ebeveyn
işleme
4dd0d4f4e4

+ 5 - 19
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/CommonBusinessService.java

@@ -57,6 +57,9 @@ public class CommonBusinessService {
     @Resource
     private StreamBridge streamBridge;
 
+    @Autowired
+    private CommonBusinessService commonBusinessService;
+
 
     /**
      * @param keywords 关键字 resDto查询结果集
@@ -210,26 +213,9 @@ public class CommonBusinessService {
             cooperateManageQueryResVo.setEntId(cooperateManageQueryResDto.getOurEntId());
             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.equals(cooperateManageQueryResDto.getEntId())) {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviteeContacts());
@@ -238,7 +224,7 @@ public class CommonBusinessService {
                 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());
@@ -246,8 +232,8 @@ public class CommonBusinessService {
                 cooperateManageQueryResVo.setManager(cooperateManageQueryResDto.getInviteeContacts());
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviteeContactsId());
+                cooperateManageQueryResVo.setCooperateTypes(commonBusinessService.changeCooperateType(cooperateManageQueryResDto.getTypes()));
             }
-
             result.add(cooperateManageQueryResVo);
         }
         return result;

+ 11 - 2
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateApplyService.java

@@ -157,7 +157,7 @@ public class KwmCooperateApplyService {
                 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());
@@ -165,9 +165,15 @@ public class KwmCooperateApplyService {
                 cooperateManageQueryResVo.setManager(cooperateManageQueryResDto.getInviteeContacts());
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviteeContactsId());
+            }
+
+            if (entId.equals(cooperateManageQueryResDto.getEntId())) {
+                cooperateManageQueryResVo.setCooperateTypes(cooperateManageQueryResDto.getTypes());
+            } else {
                 cooperateManageQueryResVo.setCooperateTypes(commonBusinessService.changeCooperateType(cooperateManageQueryResDto.getTypes()));
             }
 
+
             result.add(cooperateManageQueryResVo);
         }
         return result;
@@ -335,7 +341,6 @@ public class KwmCooperateApplyService {
             kwmCooperate.setInviteeEntId(reqVo.getTargetEntId());
 
             //我方联系人
-
             UserCacheResDto contactDto = remoteSystemService.queryUserCacheById(reqVo.getUserId());
             if (Objects.nonNull(contactDto)) {
                 kwmCooperate.setInviterContactsId(contactDto.getId());
@@ -364,10 +369,14 @@ public class KwmCooperateApplyService {
             }
         }
 
+        KwmCooperate kwmCooperate = kwmCooperateMapper.selectById(id);
         for (Integer item : chooseCooperateTypes) {
             KwmCooperateType kwmCooperateType = new KwmCooperateType();
             kwmCooperateType.setId(new IdWorker(1L).nextId());
             kwmCooperateType.setCooperateId(id);
+            if (!kwmCooperate.getEntId().equals(LoginUserHolder.getEntId())) {
+                item = commonBusinessService.changeCooperateType(item);
+            }
             kwmCooperateType.setType(item);
             kwmCooperateType.setStatus(CooperateStatusEnum.PROCESS.getCode());
             kwmCooperateType.setCreateBy(LoginUserHolder.getUserId());

+ 5 - 8
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java

@@ -435,10 +435,13 @@ public class KwmCooperateManageService {
             return Collections.emptyList();
         }
 
+        EntCacheResDto topEnt = remoteSystemService.queryEntTreeById(id);
+        Long topEntId = topEnt.getId();
         List<KwmCooperateType> kwmCooperateTypeList = new ArrayList<>();
         for (KwmCooperate kwmCooperate : kwmCooperates) {
             Integer type = reqVo.getCooperateType();
-            if (kwmCooperate.getInviteeEntId().equals(reqVo.getId())) {
+            //不是我方发起
+            if (!topEntId.equals(kwmCooperate.getEntId())) {
                 type = commonBusinessService.changeCooperateType(type);
             }
             LambdaQueryWrapper<KwmCooperateType> kwmCooperateTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -568,17 +571,11 @@ public class KwmCooperateManageService {
             String inviterEntName = Objects.isNull(inviterEntCacheResDto) ? null : inviterEntCacheResDto.getFirmName();
             String inviteeEntName = Objects.isNull(inviteeEntCacheResDto) ? null : inviteeEntCacheResDto.getFirmName();
 
-
             //设置合作属性
             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();
                 Integer type;
-                if (id.equals(topId)) {
+                if (kwmCooperate.getEntId().equals(topId)) {
                     type = kwmCooperateType.getType();
                 } else {
                     type = commonBusinessService.changeCooperateType(kwmCooperateType.getType());

+ 11 - 12
sckw-modules/sckw-manage/src/main/resources/mapper/KwmCooperateMapper.xml

@@ -83,7 +83,7 @@
                                    and c.status = b.status
                                    and c.del_flag = 0
                                    and c.type = #{item}
-                    )
+                                )
                 </foreach>
            </if>
 
@@ -140,7 +140,7 @@
     <select id="findManageList" resultType="com.sckw.manage.model.dto.res.CooperateManageQueryResDto">
         SELECT a.id,
                 min(a.status) status,
-                group_concat(concat(b.type, '#', b.create_by)) types,
+                group_concat(b.type) types,
                 min(a.ent_id) entId,
                 min(a.invitee_ent_id) inviteeEntId,
                 min(a.inviter_ent_id) inviterEntId,
@@ -279,16 +279,15 @@
          WHERE a.del_flag = 0
            and a.status in (1,2)
         <if test="reqDto.cooperateTypes != null and reqDto.cooperateTypes.size() > 0">
-            and exists (select 1
-                          from kwm_cooperate_type c
-                         where c.cooperate_id = a.id
-                           and c.status = b.status
-                           and c.del_flag = 0
-                           and c.type in
-                        <foreach collection="reqDto.cooperateTypes" item="item" open="(" close=")" separator=",">
-                            #{item}
-                        </foreach>
-                        )
+            <foreach collection="reqDto.cooperateTypes" item="item">
+                and exists (select 1
+                            from kwm_cooperate_type c
+                            where c.cooperate_id = a.id
+                            and c.status = b.status
+                            and c.del_flag = 0
+                            and c.type = #{item}
+                )
+            </foreach>
         </if>
         <if test="reqDto.startTime != null">
             and b.create_time >= #{reqDto.startTime}