Bläddra i källkod

查字典dubbo接口

czh 2 år sedan
förälder
incheckning
b5d33bee2a

+ 20 - 2
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteSystemService.java

@@ -12,6 +12,24 @@ import java.util.Map;
  */
 public interface RemoteSystemService {
 
+    /**
+     * @param keys type#value,type#value
+     * @return Map<String, SysDictResDto>
+     * @desc: 根据类型id查字典,先查redis,没查到查数据库,查出来了存redis
+     * @author: czh
+     * @date: 2023/7/5
+     */
+    Map<String, SysDictResDto> queryDictMapByTypeValues(String keys);
+
+    /**
+     * @param type 类型
+     * @return Map<String, SysDictResDto>
+     * @desc: 根据类型id查字典,先查redis,没查到查数据库,查出来了存redis
+     * @author: czh
+     * @date: 2023/7/5
+     */
+    Map<String, SysDictResDto> queryDictMapByType(String type);
+
     /**
      * @param type 类型
      * @return SysDictResDto
@@ -85,13 +103,13 @@ public interface RemoteSystemService {
     List<EntCacheResDto> queryEntCacheByName(String entName);
 
     /**
-     * @param endIdList 企业id集合
+     * @param entIdList 企业id集合
      * @return Map<Long, EntCacheResDto>
      * @desc: 查企业树
      * @author: czh
      * @date: 2023/7/17
      */
-    Map<Long, EntCacheResDto> queryEntTreeByIds(List<Long> endIdList);
+    Map<Long, EntCacheResDto> queryEntTreeByIds(List<Long> entIdList);
 
     /**
      * @param userId 用户id

+ 1 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEntDeptDao.java

@@ -41,7 +41,7 @@ public interface KwsEntDeptDao {
      * @author: czh
      * @date: 2023/7/17
      */
-    List<KwsEntDept> selectByEntId(Long entId);
+    KwsEntDept selectByEntId(Long entId);
 
     /**
      * @param entPid 企业pid

+ 10 - 8
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteBaseService.java

@@ -124,14 +124,16 @@ public class RemoteBaseService {
      */
     public void fillRelate(EntCacheResDto entCacheResDto) {
         Long id = entCacheResDto.getId();
-//        List<KwsEntDept> kwsEntDepts = kwsEntDeptDao.selectByEntID(id);
-//        if (CollectionUtils.isNotEmpty(kwsEntDepts)) {
-//            entCacheResDto.setEntDeptIds(String.join(Global.COMMA, kwsEntDepts.stream().map(KwsEntDept::getEntPid).map(String::valueOf).toList()));
-//            return;
-//        }
-//
-//        kwsEntDepts = kwsEntDeptDao.selectByEntPid(id);
-
+        KwsEntDept kwsEntDept = kwsEntDeptDao.selectByEntId(id);
+        //不为空则是主体单位
+        if (Objects.nonNull(kwsEntDept)) {
+            entCacheResDto.setParentId(kwsEntDept.getEntPid());
+            return;
+        }
 
+        List<KwsEntDept> kwsEntDepts = kwsEntDeptDao.selectByEntPid(id);
+        if (CollectionUtils.isNotEmpty(kwsEntDepts)) {
+            entCacheResDto.setEntDeptIds(String.join(Global.COMMA, kwsEntDepts.stream().map(KwsEntDept::getEntPid).map(String::valueOf).toList()));
+        }
     }
 }

+ 69 - 5
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteSystemServiceImpl.java

@@ -45,6 +45,44 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
     @Autowired
     private SysAreaService sysAreaService;
 
+    /**
+     * @param keys type#value,type#value
+     * @return Map<String, SysDictResDto>
+     * @desc: 根据类型id查字典,先查redis,没查到查数据库,查出来了存redis
+     * @author: czh
+     * @date: 2023/7/5
+     */
+    @Override
+    public Map<String, SysDictResDto> queryDictMapByTypeValues(String keys) {
+        Map<String, SysDictResDto> map = new HashMap<>();
+        String[] typeValueArr = keys.split(Global.COMMA);
+        for (int i = 0; i < typeValueArr.length; i++) {
+            String typeValue = typeValueArr[i];
+            String[] split = typeValue.split(Global.POUND);
+            SysDictResDto sysDictResDto = queryDictByTypeAndValue(split[0], split[1]);
+            map.put(typeValue, sysDictResDto);
+        }
+
+        return map;
+    }
+
+    /**
+     * @param type 类型
+     * @return Map<String, SysDictResDto>
+     * @desc: 根据类型id查字典,先查redis,没查到查数据库,查出来了存redis
+     * @author: czh
+     * @date: 2023/7/5
+     */
+    @Override
+    public Map<String, SysDictResDto> queryDictMapByType(String type) {
+        List<SysDictResDto> sysDictResDtos = queryDictByType(type);
+        if (CollectionUtils.isEmpty(sysDictResDtos)) {
+            return new HashMap<>();
+        }
+
+        return sysDictResDtos.stream().collect(Collectors.toMap(SysDictResDto::getValue, v->v));
+    }
+
     /**
      * @param type 类型
      * @return SysDictResDto
@@ -127,7 +165,7 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
     }
 
     /**
-     * @param  type 字典类型,value key
+     * @param type 字典类型,value key
      * @return SysDictGroupResDto
      * @desc: 根据字典类型和key查字典组
      * @author: czh
@@ -180,6 +218,7 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
             BeanUtils.copyProperties(kwsEnterpriseResDto, entCacheResDto);
             entCacheResDto.setDeptInfo(remoteBaseService.queryDeftInfoByEntId(entId));
             entCacheResDto.setCertificateInfo(remoteBaseService.queryCertificateByEntId(entId));
+            remoteBaseService.fillRelate(entCacheResDto);
             RedissonUtils.putString(key, JSON.toJSONString(entCacheResDto), Global.COMMON_EXPIRE);
             return entCacheResDto;
         }
@@ -211,12 +250,37 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
         return list;
     }
 
+    /**
+     * @param entIdList 企业id集合
+     * @return Map<Long, EntCacheResDto>
+     * @desc: 查企业树
+     * @author: czh
+     * @date: 2023/7/17
+     */
     @Override
-    public Map<Long, EntCacheResDto> queryEntTreeByIds(List<Long> endIdList) {
-        for (Long entId : endIdList) {
-            queryEntCacheById(entId);
+    public Map<Long, EntCacheResDto> queryEntTreeByIds(List<Long> entIdList) {
+        Map<Long, EntCacheResDto> result = new HashMap<>();
+        for (Long entId : entIdList) {
+            EntCacheResDto entCacheResDto = queryEntCacheById(entId);
+
+            //有主体单位
+            String entDeptIds = entCacheResDto.getEntDeptIds();
+            if (StringUtils.isNotBlank(entDeptIds)) {
+                List<Long> entDeptIdList = Arrays.stream(entDeptIds.split(Global.COMMA)).map(Long::parseLong).toList();
+                List<EntCacheResDto> child = queryEntCacheByIds(entDeptIdList);
+                entCacheResDto.setChild(child);
+                result.put(entId, entCacheResDto);
+            }
+
+            //有父企业
+            Long parentId = entCacheResDto.getParentId();
+            if (Objects.nonNull(parentId)) {
+                EntCacheResDto parent = queryEntCacheById(parentId);
+                parent.setChild(Collections.singletonList(entCacheResDto));
+                result.put(entId, parent);
+            }
         }
-        return null;
+        return result;
     }
 
     @Override