Преглед изворни кода

新增 行社机构缓存; 机构管理页面 列表 查询返回当前机构是否在行社之下

zhulu пре 1 година
родитељ
комит
4a551072d5

+ 4 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/domain/SysOrg.java

@@ -150,6 +150,10 @@ public class SysOrg extends BaseEntity {
     @ApiModelProperty(value = "机构所属行社")
     private String affiliatedBank;
 
+    @ApiModelProperty(value = "行社之下")
+    @TableField(exist = false)
+    private Boolean underBank ;
+
     /**
      * 子机构
      */

+ 5 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/constant/CacheConstants.java

@@ -63,6 +63,11 @@ public class CacheConstants
     public static final String ORG_CACHE_LIST_KEY = "sys_org_list";
 
     /**
+     * 所有行社机构缓存
+     */
+    public static final String HS_ORG_CACHE_LIST_KEY = "sys_hs_org_list";
+
+    /**
      * 所有角色缓存
      */
     public static final String ROLE_CACHE_LIST_KEY = "sys_role_list";

+ 37 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysOrgServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.io.LineHandler;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
@@ -125,11 +126,44 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
             }
             page = baseMapper.selectOrgList(page, org);
         }
+        dealTableData(page);
         //抓换为TableDataInfo适配前端
         return TableDataInfo.build(page);
 
     }
 
+    private void dealTableData(Page<SysOrg> page)
+    {
+        if(ObjectUtil.isEmpty(page.getRecords()))
+        {
+            return ;
+        }
+       List<SysOrgVO> hsOrgList= getHSOrgCache();
+        page.getRecords().stream().forEach(x->{
+            if(ObjectUtil.isEmpty(x.getPath()))
+            {
+                return;
+            }
+            if(Arrays.stream(x.getPath().split("-")).anyMatch(id->hsOrgList.stream().anyMatch(hsOrg->ObjectUtil.equal(id,hsOrg.getId().toString()))))
+            {
+                x.setUnderBank(true);
+            }
+        });
+
+    }
+
+    private List<SysOrgVO> getHSOrgCache() {
+        List<SysOrgVO> cacheList = null;
+        Boolean isOk = RedisUtils.hasKey(CacheConstants.HS_ORG_CACHE_LIST_KEY);
+        if (!isOk) {
+            cacheList = loadingOrgCache();
+        } else {
+            cacheList = RedisUtils.getCacheList(CacheConstants.HS_ORG_CACHE_LIST_KEY);
+        }
+
+        return cacheList;
+    }
+
     @Override
     public List<OrgPhysicalDefenseConstructionExport> excel(SysOrg dept) {
 
@@ -748,14 +782,17 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     @Override
     public List<SysOrgVO> loadingOrgCache() {
         List<SysOrgVO> sysOrgVOS = baseMapper.selectSysOrgVOList();
+        List<SysOrgVO> hsOrgs = sysOrgVOS.stream().filter(x -> ObjectUtil.equal(x.getType(), 3)).collect(Collectors.toList());
         clearOrgCache();
         RedisUtils.setCacheList(CacheConstants.ORG_CACHE_LIST_KEY, sysOrgVOS);
+        RedisUtils.setCacheList(CacheConstants.HS_ORG_CACHE_LIST_KEY, hsOrgs);
         return sysOrgVOS;
     }
 
     @Override
     public void clearOrgCache() {
         RedisUtils.deleteObject(CacheConstants.ORG_CACHE_LIST_KEY);
+        RedisUtils.deleteObject(CacheConstants.HS_ORG_CACHE_LIST_KEY);
         //redisService.deleteObject(CacheConstants.ORG_CACHE_LIST_KEY);
     }