Browse Source

预案演练代码提交

jingyuanchao 2 năm trước cách đây
mục cha
commit
32ad9ef3e0

+ 8 - 1
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteOrgService.java

@@ -2,6 +2,8 @@ package com.xunmei.system.api;
 
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.constant.ServiceNameConstants;
+import com.xunmei.common.core.domain.OrgTreeReq;
+import com.xunmei.common.core.domain.OrgTreeResp;
 import com.xunmei.common.core.domain.R;
 import com.xunmei.common.core.vo.IdNameVo;
 import com.xunmei.system.api.Eto.OrgListByTypesConditionEto;
@@ -133,12 +135,17 @@ public interface RemoteOrgService {
 
     @GetMapping("/extend/selectSysOrgExtendById")
     SysOrgExtend selectSysOrgExtendById(@RequestParam("orgId") Long orgId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
     @GetMapping("/dept/findByOrgTypeAndParent")
-    List<SysOrg> findByOrgTypeAndParent(@RequestParam("orgType")Integer orgType,@RequestParam("path") String path, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+    List<SysOrg> findByOrgTypeAndParent(@RequestParam("orgType") Integer orgType, @RequestParam("path") String path, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
 
     @PostMapping("/dept/deptTree/hangshewhole")
     R<List<SysOrgVO>> hangsheWholePathTree(@RequestBody Long orgId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
 //    @PostMapping("/dept/selectParentHs")
 //    List<SysOrg> selectParentHs(@RequestBody List<Long> orgList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
 
+    // 此接口需要获取当前登陆人信息,不可异步
+    @GetMapping("/dept/selectOrgTreeReq")
+    OrgTreeResp getOrgTreeResp(@RequestParam("orgId") Long orgId,@RequestParam("checkSub") Boolean checkSub);
+
 }

+ 9 - 1
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteOrgFallbackFactory.java

@@ -1,6 +1,8 @@
 package com.xunmei.system.api.factory;
 
 import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.OrgTreeReq;
+import com.xunmei.common.core.domain.OrgTreeResp;
 import com.xunmei.common.core.domain.R;
 import com.xunmei.common.core.vo.IdNameVo;
 import com.xunmei.system.api.Eto.OrgListByTypesConditionEto;
@@ -15,6 +17,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -30,7 +33,7 @@ public class RemoteOrgFallbackFactory implements FallbackFactory<RemoteOrgServic
 
     @Override
     public RemoteOrgService create(Throwable throwable) {
-        log.error("用户服务调用失败:{}", throwable.getMessage());
+        log.error("机构服务调用失败:{}", throwable.getMessage());
         return new RemoteOrgService() {
             @Override
             public R<List<SysOrg>> getAllOrg(String source) {
@@ -156,6 +159,11 @@ public class RemoteOrgFallbackFactory implements FallbackFactory<RemoteOrgServic
             public R<List<SysOrgVO>> hangsheWholePathTree(Long orgId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source) {
                 return null;
             }
+
+            @Override
+            public OrgTreeResp getOrgTreeResp(Long orgId, Boolean checkSub) {
+                return null;
+            }
         };
     }
 }

+ 19 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/OrgTreeReq.java

@@ -0,0 +1,19 @@
+package com.xunmei.common.core.domain;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class OrgTreeReq {
+
+    private Long orgId;
+
+
+    private Boolean checkSub=Boolean.FALSE;
+
+
+}

+ 18 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/OrgTreeResp.java

@@ -0,0 +1,18 @@
+package com.xunmei.common.core.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class OrgTreeResp {
+    @ApiModelProperty(value = "机构id")
+    private Long orgId;
+
+    @ApiModelProperty(value = "当前机构path")
+    private String orgPath;
+
+    @ApiModelProperty(value = "父级机构id数组")
+    private List<Long> orgIdList;
+}

+ 4 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/edu/dto/SysLearningMaterialsPageDto.java

@@ -17,12 +17,16 @@ import java.util.List;
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
 public class SysLearningMaterialsPageDto extends PageRequest {
+
     @ApiModelProperty(value = "资料类型(知识库标签)")
     private Long knowledgeId;
+
     @ApiModelProperty(value = "公开状态,0:未公开,1:已公开")
     private Integer isOpen;
+
     @ApiModelProperty(value = "资料标题")
     private String title;
+
     @ApiModelProperty(value = "上级机构id集合",notes = "学习资料分页列表默认查询上级机构且公开的数据,此字段无需传递,后端自行获取")
     private List<Long> orgIdList;
 

+ 2 - 2
soc-common/soc-common-security/src/main/java/com/xunmei/common/security/config/WebMvcConfig.java

@@ -45,7 +45,7 @@ public class WebMvcConfig implements WebMvcConfigurer, ApplicationContextAware {
 
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
-        final AbstractJackson2HttpMessageConverter httpMessageConverter = applicationContext.getBean(AbstractJackson2HttpMessageConverter.class);
+       /* final AbstractJackson2HttpMessageConverter httpMessageConverter = applicationContext.getBean(AbstractJackson2HttpMessageConverter.class);
         final ObjectMapper objectMapper = httpMessageConverter.getObjectMapper();
         SimpleModule simpleModule = new SimpleModule();
 
@@ -55,6 +55,6 @@ public class WebMvcConfig implements WebMvcConfigurer, ApplicationContextAware {
 
         objectMapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
         objectMapper.registerModule(simpleModule);
-        httpMessageConverter.setObjectMapper(objectMapper);
+        httpMessageConverter.setObjectMapper(objectMapper);*/
     }
 }

+ 18 - 6
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/SysLearningMaterialsServiceImpl.java

@@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xunmei.common.core.constant.Constants;
 import com.xunmei.common.core.constant.ErrorMsgConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.OrgTreeReq;
+import com.xunmei.common.core.domain.OrgTreeResp;
 import com.xunmei.common.core.domain.edu.domain.SysLearningMaterials;
 import com.xunmei.common.core.domain.edu.dto.SysLearningMaterialsFileListPageDto;
 import com.xunmei.common.core.domain.edu.dto.SysLearningMaterialsInsertDto;
@@ -60,18 +62,28 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
         if (sysOrg == null || ObjectUtil.isEmpty(sysOrg.getPath())) {
             throw new RuntimeException("机构不存在或机构信息缺失!");
         }
-        final List<Long> list = dealParentOrgId(request, sysOrg);
+       /* final List<Long> list = dealParentOrgId(request, sysOrg);
         boolean isTopOrg = ObjectUtil.equal(sysOrg.getParentId(), TOP_ORG_PARENT_ID);
         list.remove(request.getOrgId());
         request.setOrgIdList(list);
-        request.setUserId(SecurityUtils.getUserId());
+        request.setUserId(SecurityUtils.getUserId());*/
         //获取数据 默认查询当前及上级机构公开,当前用户创建的的数据
+        OrgTreeReq orgTreeReq = new OrgTreeReq(request.getOrgId(), request.getCheckSub());
+
+
+        OrgTreeResp orgTreeResp = remoteOrgService.getOrgTreeResp(request.getOrgId(),request.getCheckSub());
+
+
+        request.setOrgId(orgTreeResp.getOrgId());
+        request.setOrgPath(orgTreeResp.getOrgPath());
+        request.setOrgIdList(orgTreeResp.getOrgIdList());
+
         Page<SysLearningMaterialsPageVo> page;
-        if (isTopOrg) {
+       /* if (isTopOrg) {
             page = sysLearningMaterialsMapper.selectPageDataByTopOrg(request.getPageRequest(), request);
-        } else {
-            page = sysLearningMaterialsMapper.selectPageData(request.getPageRequest(), request);
-        }
+        } else {*/
+        page = sysLearningMaterialsMapper.selectPageData(request.getPageRequest(), request);
+        // }
         for (SysLearningMaterialsPageVo record : page.getRecords()) {
             record.setNo(page.getRecords().indexOf(record));
         }

+ 2 - 2
soc-modules/soc-modules-core/src/main/resources/mapper/drill/CoreDrillPlanMapper.xml

@@ -478,8 +478,8 @@
         p.plan_status as planStatus,
         p.issue as issue,
         p.standard as standard,
-        P.belong_org_id as belongOrgId,
-        P.belong_org_name as belongOrgName,
+        p.belong_org_id as belongOrgId,
+        p.belong_org_name as belongOrgName,
         p.parent_id as parentId
 
         from core_drill_plan p left join sys_user u on p.update_by=u.id

+ 1 - 1
soc-modules/soc-modules-core/src/main/resources/mapper/edu/SysLearningMaterialsMapper.xml

@@ -122,7 +122,7 @@
         <if test="request.checkSub==false">
             and m.org_id=#{request.orgId}
         </if>
-        <if test="request.orgIdList.size>0">
+        <if test="request.orgIdList != null and request.orgIdList.size>0">
             or ( m.org_id in
             <foreach collection="request.orgIdList" item="item" open="(" separator="," close=")">
                 #{item}

+ 10 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysDeptController.java

@@ -3,6 +3,8 @@ package com.xunmei.system.controller;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.xunmei.common.core.constant.Constants;
+import com.xunmei.common.core.domain.OrgTreeReq;
+import com.xunmei.common.core.domain.OrgTreeResp;
 import com.xunmei.common.core.domain.R;
 import com.xunmei.common.core.utils.StringUtils;
 import com.xunmei.common.core.web.controller.BaseController;
@@ -327,4 +329,12 @@ public class SysDeptController extends BaseController {
     List<SysOrg> findByOrgTypeAndParent(Integer orgType, String path) {
         return orgService.findByOrgTypeAndParent(orgType,path);
     }
+
+
+    @ApiOperation(value = "获取机构查询参数")
+    @GetMapping("/selectOrgTreeReq")
+    @InnerAuth
+    OrgTreeResp getOrgTreeResp( Long orgId,Boolean checkSub){
+        return orgService.getOrgTreeReq(null);
+    }
 }

+ 4 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysOrgService.java

@@ -1,6 +1,8 @@
 package com.xunmei.system.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.xunmei.common.core.domain.OrgTreeReq;
+import com.xunmei.common.core.domain.OrgTreeResp;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.vo.SysOrgVO;
@@ -133,4 +135,6 @@ public interface ISysOrgService extends IService<SysOrg> {
     List<SysOrg> selectByOrgIdList(List<Long> orgList);
 
     List<SysOrg> findAllOrg();
+
+    OrgTreeResp getOrgTreeReq(OrgTreeReq req);
 }

+ 65 - 31
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysOrgServiceImpl.java

@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xunmei.common.core.constant.CacheConstants;
 import com.xunmei.common.core.constant.Constants;
+import com.xunmei.common.core.domain.OrgTreeReq;
+import com.xunmei.common.core.domain.OrgTreeResp;
 import com.xunmei.common.core.exception.ServiceException;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.core.web.page.TableDataInfo;
@@ -72,7 +74,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
 //        org.setParentId(null);
         //查询条件
 //        QueryWrapper<SysOrg> query = new QueryWrapper<>(org);
-        if(sysOrg!=null) {
+        if (sysOrg != null) {
             //下穿
             if (org.getCheckSub()) {
                 org.setParentId(null);
@@ -119,7 +121,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
 
     @Override
     public List<SysOrg> listByTypes(Long topId, List<String> types) {
-        List<SysOrg> top = sysOrgMapper.selectList(new LambdaQueryWrapper<SysOrg>().eq(SysOrg::getId,topId).select(SysOrg::getPath));
+        List<SysOrg> top = sysOrgMapper.selectList(new LambdaQueryWrapper<SysOrg>().eq(SysOrg::getId, topId).select(SysOrg::getPath));
         if (CollectionUtil.isEmpty(top)) {
             return new ArrayList<>();
         }
@@ -132,14 +134,14 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     }
 
     @Override
-    public List<SysOrg> listByParentIdAndType(Long parentId, Integer type,String path) {
-        QueryWrapper queryWrapper=new QueryWrapper();
-        queryWrapper.eq("type",type);
-        if (null!=parentId){
-            queryWrapper.eq("parent_id",parentId);
+    public List<SysOrg> listByParentIdAndType(Long parentId, Integer type, String path) {
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.eq("type", type);
+        if (null != parentId) {
+            queryWrapper.eq("parent_id", parentId);
         }
-        queryWrapper.likeRight("path",path);
-        queryWrapper.eq("deleted",0);
+        queryWrapper.likeRight("path", path);
+        queryWrapper.eq("deleted", 0);
         List list = baseMapper.selectList(queryWrapper);
         return list;
     }
@@ -228,7 +230,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
         LambdaQueryWrapper<SysOrg> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(SysOrg::getParentId, orgId);
         List<SysOrg> selectList = sysOrgMapper.selectList(wrapper);
-        if (selectList.size()>0){
+        if (selectList.size() > 0) {
             return selectList.get(0);
         }
         return null;
@@ -243,9 +245,9 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     }
 
     @Override
-    public List<SysOrg> selectByOrgPathAndOrgType(String orgPath,Integer orgType) {
+    public List<SysOrg> selectByOrgPathAndOrgType(String orgPath, Integer orgType) {
         LambdaQueryWrapper<SysOrg> wrapper = new LambdaQueryWrapper<>();
-        wrapper.likeRight(SysOrg::getPath,orgPath);
+        wrapper.likeRight(SysOrg::getPath, orgPath);
         wrapper.eq(SysOrg::getType, orgType);
         wrapper.eq(SysOrg::getDeleted, 0);
         return sysOrgMapper.selectList(wrapper);
@@ -260,10 +262,12 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     public List<Long> selectOrgTypeByIdList(List<Long> execOrgIdList) {
         return sysOrgMapper.selectOrgTypeByIdList(execOrgIdList);
     }
+
     @Override
     public List<SysOrg> findByOrgTypeAndParent(Integer orgType, String path) {
         return sysOrgMapper.findByOrgTypeAndParent(orgType, path);
     }
+
     @Override
     public List<SysOrg> selectDeptTreeList(SysOrg dept) {
         Long userId = SecurityUtils.getUserId();
@@ -293,7 +297,6 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     }
 
 
-
     @Override
     public void clearOrgCache() {
         RedisUtils.deleteObject(CacheConstants.ORG_CACHE_LIST_KEY);
@@ -311,9 +314,9 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
             //修改前的原始机构对象
             final SysOrg originalOrg = getById(org.getId());
             //仅系统新增的机构可以修改层级,同步到系统的机构不允许修改机构层级
-            if(ObjectUtil.equal(originalOrg.getSource(),0)) {
+            if (ObjectUtil.equal(originalOrg.getSource(), 0)) {
                 //父级机构发生变化后,修改机构path ,以及下级机构path
-                if(!ObjectUtil.equal(originalOrg.getParentId(),org.getParentId())){
+                if (!ObjectUtil.equal(originalOrg.getParentId(), org.getParentId())) {
                     //获取选择的父机构数据
                     SysOrg parentOrg = getById(org.getParentId());
                     //更新机构对应的业务path
@@ -323,7 +326,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
                     org.setTreeShowParentId(parentOrg.getId());
 
                     //ToDo 刷新当前机构下所有子机构 path
-                    List<SysOrg> allChildOrgList= reSetOrgAllChildOrgPath(org,originalOrg);
+                    List<SysOrg> allChildOrgList = reSetOrgAllChildOrgPath(org, originalOrg);
                     this.saveOrUpdateBatch(allChildOrgList);
                 }
             }
@@ -359,34 +362,30 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
         return rel;
     }
 
-    private List<SysOrg> getAllChildOrgList(String path)
-    {
+    private List<SysOrg> getAllChildOrgList(String path) {
         return sysOrgMapper.selectList(new LambdaQueryWrapper<SysOrg>()
                 .likeRight(SysOrg::getPath, path)
                 .eq(SysOrg::getDeleted, 0));
     }
 
-    private List<SysOrg> reSetOrgAllChildOrgPath(SysOrg newOrg,SysOrg originalOrg)
-    {
+    private List<SysOrg> reSetOrgAllChildOrgPath(SysOrg newOrg, SysOrg originalOrg) {
         final List<SysOrg> allChildOrgList = getAllChildOrgList(originalOrg.getPath());
-        if(ObjectUtil.isEmpty(allChildOrgList))
-        {
-           return allChildOrgList;
+        if (ObjectUtil.isEmpty(allChildOrgList)) {
+            return allChildOrgList;
         }
-        reSetOrgPath(newOrg,allChildOrgList);
+        reSetOrgPath(newOrg, allChildOrgList);
         return allChildOrgList;
     }
 
-    private void reSetOrgPath(SysOrg parentOrg,List<SysOrg> allChildOrgList)
-    {
+    private void reSetOrgPath(SysOrg parentOrg, List<SysOrg> allChildOrgList) {
         final List<SysOrg> chillOrgList = allChildOrgList.stream().filter(child -> ObjectUtil.equal(parentOrg.getId(), child.getParentId())).collect(Collectors.toList());
-        if(ObjectUtil.isEmpty(chillOrgList)){
+        if (ObjectUtil.isEmpty(chillOrgList)) {
             return;
         }
-        chillOrgList.stream().forEach(child->{
-            child.setPath(parentOrg.getPath()+child.getId()+"-");
-            child.setTreeShowPath(parentOrg.getTreeShowPath()+child.getId()+"-");
-            reSetOrgPath(child,allChildOrgList);
+        chillOrgList.stream().forEach(child -> {
+            child.setPath(parentOrg.getPath() + child.getId() + "-");
+            child.setTreeShowPath(parentOrg.getTreeShowPath() + child.getId() + "-");
+            reSetOrgPath(child, allChildOrgList);
         });
     }
 
@@ -443,4 +442,39 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     public List<SysOrg> findAllOrg() {
         return this.list();
     }
+
+    @Override
+    public OrgTreeResp getOrgTreeReq(OrgTreeReq req) {
+        OrgTreeResp resp = new OrgTreeResp();
+        Long curOrgId = SecurityUtils.getLoginUser().getOrgId();
+        Long queryOrgId = req.getOrgId();
+        Map<Long, String> idPathMap = lambdaQuery().in(SysOrg::getId, Arrays.asList(curOrgId, queryOrgId))
+                .select(SysOrg::getId, SysOrg::getPath).list().stream().collect(Collectors.toMap(SysOrg::getId, SysOrg::getPath));
+        String curOrgPath = idPathMap.get(curOrgId);
+        String queryOrgPath = idPathMap.get(queryOrgId);
+        if (req.getCheckSub()) {
+            //1.如果当前机构是查询机构的上级机构,那么应查询当前机构到 查询机构之间的所有机构id,与当前机构的所有下级
+            if (curOrgPath.startsWith(queryOrgPath)){
+                List<Long> list = Arrays.stream(queryOrgPath.split("-")).map(Long::valueOf).collect(Collectors.toList());
+                //移除当前机构id,当前机构的数据以path字段查询
+                list.remove(curOrgId);
+                resp.setOrgIdList(list);
+                resp.setOrgPath(queryOrgPath);
+            }else {
+                resp.setOrgPath(curOrgPath);
+            }
+            return resp;
+        }
+        //不下穿查询:
+        if (queryOrgPath.startsWith(curOrgPath)){
+            //查询父机构: 返回当前机构至查询机构之间的所有机构id
+            List<Long> list = Arrays.stream(queryOrgPath.split("-")).map(Long::valueOf).collect(Collectors.toList());
+            resp.setOrgIdList(list);
+            return resp;
+        }
+        //查询的是下级机构,返回下级机构id
+        resp.setOrgId(queryOrgId);
+        return resp;
+    }
+
 }