18482106067 2 лет назад
Родитель
Сommit
da67d442bb

+ 12 - 0
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/controller/KwmCooperateManageController.java

@@ -150,4 +150,16 @@ public class KwmCooperateManageController {
         return HttpResult.ok(kwmCooperateManageService.findCooperateByEnt(reqVo));
     }
 
+    /**
+     * @param reqVo 企业id
+     * @return HttpResult
+     * @desc: 查询对方企业的合作单位有哪些是我方的
+     * @author: czh
+     * @date: 2023/7/22
+     */
+    @PostMapping("findTargetEntCooperateInOur")
+    public HttpResult findTargetEntCooperateInOur(@RequestBody FindCooperateByEntReqVo reqVo) throws SystemException {
+        return HttpResult.ok(kwmCooperateManageService.findTargetEntCooperateInOur(reqVo));
+    }
+
 }

+ 5 - 0
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/vo/req/FindCooperateByEntReqVo.java

@@ -28,4 +28,9 @@ public class FindCooperateByEntReqVo implements Serializable {
      */
     private Long targetEntId;
 
+    /**
+     * 合作属性
+     */
+    private Integer cooperateType;
+
 }

+ 43 - 3
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java

@@ -401,12 +401,10 @@ public class KwmCooperateManageService {
         }
 
         List<FindCooperateByEntResVo> list = new ArrayList<>();
-        Long currentEntId = LoginUserHolder.getEntId();
         for (KwmCooperate kwmCooperate : kwmCooperates) {
             FindCooperateByEntResVo findCooperateByEntResVo = new FindCooperateByEntResVo();
             findCooperateByEntResVo.setId(kwmCooperate.getId());
 
-
             //设置合作属性
             List<KwmCooperateType> kwmCooperateTypes1 = collect.get(kwmCooperate.getId());
             if (CollectionUtils.isNotEmpty(kwmCooperateTypes1)) {
@@ -425,8 +423,13 @@ public class KwmCooperateManageService {
             String inviterEntName = Objects.isNull(inviterEntCacheResDto) ? null : inviterEntCacheResDto.getFirmName();
             String inviteeEntName = Objects.isNull(inviteeEntCacheResDto) ? null : inviteeEntCacheResDto.getFirmName();
 
+
+            Long entId = reqVo.getEntId();
+
+            Map<Long, EntCacheResDto> longEntCacheResDtoMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(entId));
+            Long topId = longEntCacheResDtoMap.get(entId).getId();
             //设置我方和对方企业信息、联系人
-            if (currentEntId.equals(kwmCooperate.getEntId())) {
+            if (topId.equals(kwmCooperate.getEntId())) {
                 findCooperateByEntResVo.setEntId(kwmCooperate.getInviterEntId());
                 findCooperateByEntResVo.setEntName(inviterEntName);
                 findCooperateByEntResVo.setContactsId(kwmCooperate.getInviterContactsId());
@@ -457,4 +460,41 @@ public class KwmCooperateManageService {
     public void restore(String ids, Integer type) {
         dissolve(ids, type);
     }
+
+
+    /**
+     * @param reqVo 企业id
+     * @return FindCooperateByEntResVo
+     * @desc: 查询对方企业的合作单位有哪些是我方的
+     * @author: czh
+     * @date: 2023/7/22
+     */
+    public List<FindCooperateByEntResVo> findTargetEntCooperateInOur(FindCooperateByEntReqVo reqVo) {
+        FindCooperateByEntReqVo param = new FindCooperateByEntReqVo();
+        param.setEntId(reqVo.getTargetEntId());
+        param.setCooperateType(reqVo.getCooperateType());
+        //查对方有哪些合作单位,再筛选出我方的单位(包括我方主体单位)
+        List<FindCooperateByEntResVo> cooperateByEnt = findCooperateByEnt(param);
+        if (CollectionUtils.isEmpty(cooperateByEnt)) {
+            return Collections.emptyList();
+        }
+
+        Map<Long, EntCacheResDto> longEntCacheResDtoMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(reqVo.getEntId()));
+        if (longEntCacheResDtoMap.isEmpty()) {
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENT_NOT_EXISTS);
+        }
+
+        EntCacheResDto entCacheResDto = longEntCacheResDtoMap.get(reqVo.getEntId());
+        if (Objects.isNull(entCacheResDto)) {
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENT_NOT_EXISTS);
+        }
+
+        List<Long> longs = new ArrayList<>();
+        longs.add(reqVo.getEntId());
+        List<EntCacheResDto> child = entCacheResDto.getChild();
+        if (CollectionUtils.isNotEmpty(child)) {
+            longs.addAll(child.stream().map(EntCacheResDto::getId).toList());
+        }
+        return cooperateByEnt.stream().filter(item -> longs.contains(item.getTargetEntId())).toList();
+    }
 }

+ 9 - 0
sckw-modules/sckw-manage/src/main/resources/mapper/KwmCooperateMapper.xml

@@ -118,6 +118,15 @@
                     and a.inviter_ent_id = #{targetEntId}
                 </if>
                 ))
+
+            <if test="cooperateType != null">
+                and exists (select 1
+                              from kwm_cooperate_type c
+                             where c.cooperate_id = a.id
+                               and c.del_flag = 0
+                               and c.type = #{cooperateType}
+                            )
+            </if>
     </select>
 
     <select id="findManageList" resultType="com.sckw.manage.model.dto.res.CooperateManageQueryResDto">