浏览代码

Merge remote-tracking branch 'origin/V0.0.2' into V0.0.2

ouyang 2 年之前
父节点
当前提交
c6318dd44d
共有 15 个文件被更改,包括 277 次插入135 次删除
  1. 3 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteOrgService.java
  2. 9 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteOrgFallbackFactory.java
  3. 14 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/drill/domain/CoreDrillDictionary.java
  4. 12 1
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/drill/dto/CoreDrillDictionaryInsertDto.java
  5. 1 1
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/drill/dto/CoreDrillDictionaryUpdateDto.java
  6. 3 17
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/drill/dto/CoreDrillTaskEditDto.java
  7. 3 2
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/drill/controller/CoreDrillDictionaryController.java
  8. 14 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/drill/service/impl/CoreDrillDictionaryServiceImpl.java
  9. 21 12
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/AppRuleItemServiceImpl.java
  10. 21 11
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/safetyCheck/service/impl/SafetyCheckRuleItemServiceImpl.java
  11. 90 64
      soc-modules/soc-modules-core/src/main/resources/mapper/drill/CoreDrillDictionaryMapper.xml
  12. 10 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysDeptController.java
  13. 14 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysDeptService.java
  14. 60 27
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysDeptServiceImpl.java
  15. 2 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysOrgServiceImpl.java

+ 3 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteOrgService.java

@@ -8,6 +8,7 @@ import com.xunmei.system.api.Eto.OrgListByTypesConditionEto;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.SysOrgExtend;
 import com.xunmei.system.api.factory.RemoteOrgFallbackFactory;
+import com.xunmei.system.api.vo.SysOrgVO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.*;
 
@@ -126,6 +127,8 @@ public interface RemoteOrgService {
     @GetMapping("/extend/selectSysOrgExtendById")
     SysOrgExtend selectSysOrgExtendById(@RequestParam("orgId") Long orgId,  @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);
 

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

@@ -1,17 +1,20 @@
 package com.xunmei.system.api.factory;
 
+import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.R;
 import com.xunmei.common.core.vo.IdNameVo;
 import com.xunmei.system.api.Eto.OrgListByTypesConditionEto;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.SysOrgExtend;
+import com.xunmei.system.api.vo.SysOrgVO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.cloud.openfeign.FallbackFactory;
 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 java.util.ArrayList;
 import java.util.List;
@@ -133,10 +136,16 @@ public class RemoteOrgFallbackFactory implements FallbackFactory<RemoteOrgServic
             public List<SysOrg> selectChildHs(Long orgId, String source) {
                 return new ArrayList<>();
             }
+
             @Override
             public SysOrgExtend selectSysOrgExtendById(Long orgId, String source) {
                 return null;
             }
+
+            @Override
+            public R<List<SysOrgVO>> hangsheWholePathTree(Long orgId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source) {
+                return null;
+            }
         };
     }
 }

+ 14 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/drill/domain/CoreDrillDictionary.java

@@ -28,6 +28,20 @@ public class CoreDrillDictionary extends BaseEntity {
     @TableId
     private Integer id;
 
+    @TableField("org_id")
+    @ApiModelProperty(value = "机构")
+    private Long orgId;
+
+
+    @TableField("org_name")
+    @ApiModelProperty(value = "机构名称")
+    private String orgName;
+
+
+    @TableField("org_path")
+    @ApiModelProperty(value = "机构")
+    private String orgPath;
+
     @TableField("drill_type")
     @ApiModelProperty(value = "演练类型,字典表关联取值")
     private String drillType;

+ 12 - 1
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/drill/dto/CoreDrillDictionaryInsertDto.java

@@ -4,18 +4,29 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
 /**
  * @author jingyuanchao
  * @date 2023/9/8 19:15
  */
 @Data
 public class CoreDrillDictionaryInsertDto {
+
+    @NotNull(message = "机构不能为空")
+    @ApiModelProperty(value = "机构")
+    private Long orgId;
+
+    @NotNull(message = "演练类型不能为空")
     @ApiModelProperty(value = "演练类型,字典表关联取值")
     private String drillType;
 
-    @ApiModelProperty(value = "演练项目")
+    @NotEmpty(message = "解决方案不能为空")
+    @ApiModelProperty(value = "解决方案")
     private String drillProjects;
 
+    @NotEmpty(message = "解决方案不能为空")
     @ApiModelProperty(value = "预设案由")
     private String defaultCause;
 }

+ 1 - 1
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/drill/dto/CoreDrillDictionaryUpdateDto.java

@@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull;
  */
 @Data
 public class CoreDrillDictionaryUpdateDto {
-
+    @NotNull(message = "id不能为空")
     private Integer id;
 
     @NotNull(message = "演练类型不能为空")

+ 3 - 17
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/drill/dto/CoreDrillTaskEditDto.java

@@ -19,32 +19,18 @@ public class CoreDrillTaskEditDto {
     @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
     private Long id;
 
-    /**
-     * @see com.xunmei.common.core.enums.drill.DrillType
-     * 类型
-     */
-    @ApiModelProperty(value = "类型")
-    private Integer type;
 
-//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-//    @ApiModelProperty(value = "培训开始时间")
-//    private LocalDateTime trainingStartDateTime;
-//
-//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-//    @ApiModelProperty(value = "培训截止时间")
-//    private LocalDateTime trainingEndDateTime;
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @ApiModelProperty(value = "演练时间")
     private LocalDateTime drillTime;
 
 
-
     @ApiModelProperty(value = "演练地点")
     private String drillSite;
 
-//
-//    @ApiModelProperty(value = "总结")
-//    private String note;
+    @ApiModelProperty(value = "类型")
+    private Integer type;
+
 
     @ApiModelProperty(value = "预设案由")
     private String presetCase;

+ 3 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/drill/controller/CoreDrillDictionaryController.java

@@ -9,6 +9,7 @@ import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.core.domain.drill.domain.CoreDrillDictionary;
 import com.xunmei.core.drill.service.ICoreDrillDictionaryService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
@@ -66,7 +67,7 @@ public class CoreDrillDictionaryController extends BaseController {
     @RequiresPermissions("core:drillDictionary:add")
     @Log(title = "预案演练库", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody CoreDrillDictionaryInsertDto coreDrillDictionary) {
+    public AjaxResult add(@RequestBody @Validated CoreDrillDictionaryInsertDto coreDrillDictionary) {
         return toAjax(coreDrillDictionaryService.insertCoreDrillDictionary(coreDrillDictionary));
     }
 
@@ -77,7 +78,7 @@ public class CoreDrillDictionaryController extends BaseController {
     @RequiresPermissions("core:drillDictionary:edit")
     @Log(title = "预案演练库", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody CoreDrillDictionaryUpdateDto request) {
+    public AjaxResult edit(@RequestBody @Validated CoreDrillDictionaryUpdateDto request) {
         return toAjax(coreDrillDictionaryService.updateCoreDrillDictionary(request));
     }
 

+ 14 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/drill/service/impl/CoreDrillDictionaryServiceImpl.java

@@ -52,6 +52,12 @@ public class CoreDrillDictionaryServiceImpl extends ServiceImpl<CoreDrillDiction
 
     @Override
     public TableDataInfo<CoreDrillDictionaryPageVo> selectPage(CoreDrillDictionaryPageDto request) {
+
+        if (request.getCheckSub()) {
+            SysOrg org = getOrg(request.getOrgId());
+            request.setOrgPath(org.getPath());
+        }
+
         //获取数据
         Page<CoreDrillDictionaryPageVo> page = coreDrillDictionaryMapper.selectPageData(request.getPageRequest(), request);
         //抓换为TableDataInfo适配前端
@@ -60,6 +66,10 @@ public class CoreDrillDictionaryServiceImpl extends ServiceImpl<CoreDrillDiction
 
     }
 
+    private SysOrg getOrg(Long orgId) {
+        return RemoteCallHandlerExecutor.executeRemoteCall(() ->
+                orgService.selectOrgById(orgId, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
+    }
 
     /**
      * 查询预案演练库
@@ -88,6 +98,10 @@ public class CoreDrillDictionaryServiceImpl extends ServiceImpl<CoreDrillDiction
         if (null != drillTypeDictList && ObjectUtil.isNotEmpty(drillTypeDictList)) {
             drillTypeDictList.stream().filter(dict -> ObjectUtil.equal(dict.getDictValue(), request.getDrillType())).findFirst().ifPresent(dict -> dictionary.setDrillTypeName(dict.getDictLabel()));
         }
+        SysOrg sysOrg = getOrg(request.getOrgId());
+        dictionary.setOrgName(sysOrg.getName());
+        dictionary.setOrgPath(sysOrg.getPath());
+        dictionary.setOrgId(sysOrg.getId());
         dictionary.setCreateBy(SecurityUtils.getUserId().toString());
         dictionary.setUpdateBy(SecurityUtils.getUserId().toString());
         dictionary.setCreateTime(new Date());

+ 21 - 12
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/AppRuleItemServiceImpl.java

@@ -6,6 +6,8 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.R;
 import com.xunmei.common.core.utils.IDHelper;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.core.resumption.domain.AppRule;
@@ -25,9 +27,8 @@ import com.xunmei.core.resumption.service.IAppRulePointService;
 import com.xunmei.core.resumption.vo.appRuleItem.AppRuleItemPageVo;
 import com.xunmei.core.resumption.vo.appRuleItem.AppRulePointSelectVo;
 import com.xunmei.core.resumption.vo.appRuleItem.RuleTreeItem;
-import com.xunmei.system.api.Eto.OrgListByTypesConditionEto;
 import com.xunmei.system.api.RemoteOrgService;
-import com.xunmei.system.api.domain.SysOrg;
+import com.xunmei.system.api.vo.SysOrgVO;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -188,36 +189,44 @@ public class AppRuleItemServiceImpl extends ServiceImpl<AppRuleItemMapper, AppRu
     @Override
     public List<RuleTreeItem> getRuleTree(Long orgId) {
         List<RuleTreeItem> tree = new ArrayList<>();
-        List<SysOrg> orgs = remoteOrgService
-                .listByTypes(OrgListByTypesConditionEto.builder().orgId(orgId).orgTypes(Arrays.asList("1", "2", "3","11",null)).build())
-                .getData();
+        R<List<SysOrgVO>> r = remoteOrgService.hangsheWholePathTree(orgId,SecurityConstants.INNER);
+        if (ObjectUtil.isNull(r) || ObjectUtil.isNull(r.getData())) {
+            return tree;
+        }
+
+        List<SysOrgVO> orgs = r.getData();
         if (ObjectUtil.isEmpty(orgs)) {
             return tree;
         }
-        Map<Long, SysOrg> orgMap = orgs.stream().collect(Collectors.toMap(o -> o.getId(), o -> o));
-        List<SysOrg> tops = orgs.stream().filter(o -> !orgMap.containsKey(o.getTreeShowParentId())).collect(Collectors.toList());
+
+        Map<Long, SysOrgVO> orgMap = orgs.stream().collect(Collectors.toMap(o -> o.getId(), o -> o));
+        if (!orgMap.containsKey(orgId)) {
+            return tree;
+        }
+
+        List<SysOrgVO> tops = orgs.stream().filter(o -> !orgMap.containsKey(o.getTreeShowParentId())).collect(Collectors.toList());
         if (CollectionUtil.isEmpty(tops)) {
             return tree;
         }
-        List<Long> orgIds = orgs.stream().map(o -> o.getId()).collect(Collectors.toList());
-        List<AppRule> rules = appRuleMapper.selectList(new LambdaQueryWrapper<AppRule>().in(AppRule::getOrgId, orgIds));
+
+        List<AppRule> rules = appRuleMapper.selectList(new LambdaQueryWrapper<AppRule>().in(AppRule::getOrgId, orgMap.keySet()));
 
         tree = tops.stream().map(o -> generateTree(o, orgs, rules)).collect(Collectors.toList());
 
         return tree;
     }
 
-    private RuleTreeItem generateTree(SysOrg parent, List<SysOrg> allOrg, List<AppRule> allRule) {
+    private RuleTreeItem generateTree(SysOrgVO parent, List<SysOrgVO> allOrg, List<AppRule> allRule) {
         RuleTreeItem item = RuleTreeItem.builder().isRule(0).id(parent.getId()).label(parent.getName()).children(new ArrayList<>()).build();
         List<RuleTreeItem> ruleItems = allRule.stream().filter(r -> ObjectUtil.equal(r.getOrgId(), parent.getId()))
                 .map(o -> RuleTreeItem.builder().isRule(1).id(o.getId()).label(o.getName()).orgType(o.getOrgType()).build())
                 .collect(Collectors.toList());
         item.getChildren().addAll(ruleItems);
 
-        List<SysOrg> children = allOrg.stream()
+        List<SysOrgVO> children = allOrg.stream()
                 .filter(o -> ObjectUtil.equal(o.getTreeShowParentId(), parent.getId()))
                 .collect(Collectors.toList());
-        for (SysOrg child : children) {
+        for (SysOrgVO child : children) {
             item.getChildren().add(generateTree(child, allOrg, allRule));
         }
 

+ 21 - 11
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/safetyCheck/service/impl/SafetyCheckRuleItemServiceImpl.java

@@ -6,6 +6,8 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.R;
 import com.xunmei.common.core.utils.IDHelper;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.core.resumption.domain.AppRule;
@@ -38,6 +40,7 @@ import com.xunmei.core.safetyCheck.vo.ruleItem.SafetyCheckRulePointSelectVo;
 import com.xunmei.system.api.Eto.OrgListByTypesConditionEto;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
+import com.xunmei.system.api.vo.SysOrgVO;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -201,36 +204,43 @@ public class SafetyCheckRuleItemServiceImpl
     @Override
     public List<RuleTreeItem> getRuleTree(Long orgId) {
         List<RuleTreeItem> tree = new ArrayList<>();
-        List<SysOrg> orgs = remoteOrgService
-                .listByTypes(OrgListByTypesConditionEto.builder().orgId(orgId).orgTypes(Arrays.asList("1", "2", "3")).build())
-                .getData();
+        R<List<SysOrgVO>> r = remoteOrgService.hangsheWholePathTree(orgId, SecurityConstants.INNER);
+        if (ObjectUtil.isNull(r) || ObjectUtil.isNull(r.getData())) {
+            return tree;
+        }
+
+        List<SysOrgVO> orgs = r.getData();
         if (ObjectUtil.isEmpty(orgs)) {
             return tree;
         }
-        Map<Long, SysOrg> orgMap = orgs.stream().collect(Collectors.toMap(o -> o.getId(), o -> o));
-        List<SysOrg> tops = orgs.stream().filter(o -> !orgMap.containsKey(o.getParentId())).collect(Collectors.toList());
+
+        Map<Long, SysOrgVO> orgMap = orgs.stream().collect(Collectors.toMap(o -> o.getId(), o -> o));
+        if (!orgMap.containsKey(orgId)) {
+            return tree;
+        }
+
+        List<SysOrgVO> tops = orgs.stream().filter(o -> !orgMap.containsKey(o.getTreeShowParentId())).collect(Collectors.toList());
         if (CollectionUtil.isEmpty(tops)) {
             return tree;
         }
-        List<Long> orgIds = orgs.stream().map(o -> o.getId()).collect(Collectors.toList());
-        List<SafetyCheckRule> rules = safetyCheckRuleMapper.selectList(new LambdaQueryWrapper<SafetyCheckRule>().in(SafetyCheckRule::getOrgId, orgIds));
+        List<SafetyCheckRule> rules = safetyCheckRuleMapper.selectList(new LambdaQueryWrapper<SafetyCheckRule>().in(SafetyCheckRule::getOrgId, orgMap.keySet()));
 
         tree = tops.stream().map(o -> generateTree(o, orgs, rules)).collect(Collectors.toList());
 
         return tree;
     }
 
-    private RuleTreeItem generateTree(SysOrg parent, List<SysOrg> allOrg, List<SafetyCheckRule> allRule) {
+    private RuleTreeItem generateTree(SysOrgVO parent, List<SysOrgVO> allOrg, List<SafetyCheckRule> allRule) {
         RuleTreeItem item = RuleTreeItem.builder().isRule(0).id(parent.getId()).label(parent.getName()).children(new ArrayList<>()).build();
         List<RuleTreeItem> ruleItems = allRule.stream().filter(r -> ObjectUtil.equal(r.getOrgId(), parent.getId()))
                 .map(o -> RuleTreeItem.builder().isRule(1).id(o.getId()).label(o.getName()).orgType(o.getOrgType()).build())
                 .collect(Collectors.toList());
         item.getChildren().addAll(ruleItems);
 
-        List<SysOrg> children = allOrg.stream()
-                .filter(o -> ObjectUtil.equal(o.getParentId(), parent.getId()))
+        List<SysOrgVO> children = allOrg.stream()
+                .filter(o -> ObjectUtil.equal(o.getTreeShowParentId(), parent.getId()))
                 .collect(Collectors.toList());
-        for (SysOrg child : children) {
+        for (SysOrgVO child : children) {
             item.getChildren().add(generateTree(child, allOrg, allRule));
         }
 

+ 90 - 64
soc-modules/soc-modules-core/src/main/resources/mapper/drill/CoreDrillDictionaryMapper.xml

@@ -3,14 +3,13 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.xunmei.core.drill.mapper.CoreDrillDictionaryMapper">
-
     <resultMap type="com.xunmei.common.core.domain.drill.domain.CoreDrillDictionary" id="CoreDrillDictionaryResult">
-                <result property="id" column="id"/>
-                <result property="drillType" column="drill_type"/>
-                <result property="drillTypeName" column="drill_type_name"/>
-                <result property="drillProjects" column="drill_projects"/>
-                <result property="defaultCause" column="default_cause"/>
-                <result property="deleted" column="deleted"/>
+        <result property="id" column="id"/>
+        <result property="drillType" column="drill_type"/>
+        <result property="drillTypeName" column="drill_type_name"/>
+        <result property="drillProjects" column="drill_projects"/>
+        <result property="defaultCause" column="default_cause"/>
+        <result property="deleted" column="deleted"/>
     </resultMap>
 
     <sql id="selectCoreDrillDictionaryVo">
@@ -18,88 +17,109 @@
         from core_drill_dictionary
     </sql>
 
-    <select id="selectCoreDrillDictionaryList" parameterType="com.xunmei.common.core.domain.drill.domain.CoreDrillDictionary"
+    <select id="selectCoreDrillDictionaryList"
+            parameterType="com.xunmei.common.core.domain.drill.domain.CoreDrillDictionary"
             resultMap="CoreDrillDictionaryResult">
         <include refid="selectCoreDrillDictionaryVo"/>
         <where>
-                        <if test="drillType != null  and drillType != ''">
-                            and drill_type = #{drillType}
-                        </if>
-                        <if test="drillTypeName != null  and drillTypeName != ''">
-                            and drill_type_name like concat('%', #{drillTypeName}, '%')
-                        </if>
-                        <if test="drillProjects != null  and drillProjects != ''">
-                            and drill_projects = #{drillProjects}
-                        </if>
-                        <if test="defaultCause != null  and defaultCause != ''">
-                            and default_cause = #{defaultCause}
-                        </if>
+            <if test="drillType != null  and drillType != ''">
+                and drill_type = #{drillType}
+            </if>
+            <if test="drillTypeName != null  and drillTypeName != ''">
+                and drill_type_name like concat('%', #{drillTypeName}, '%')
+            </if>
+            <if test="drillProjects != null  and drillProjects != ''">
+                and drill_projects = #{drillProjects}
+            </if>
+            <if test="defaultCause != null  and defaultCause != ''">
+                and default_cause = #{defaultCause}
+            </if>
         </where>
     </select>
 
     <select id="selectCoreDrillDictionaryById" parameterType="Long"
             resultMap="CoreDrillDictionaryResult">
-            <include refid="selectCoreDrillDictionaryVo"/>
-            where id = #{id}
+        <include refid="selectCoreDrillDictionaryVo"/>
+        where id = #{id}
     </select>
 
-    <insert id="insertCoreDrillDictionary" parameterType="com.xunmei.common.core.domain.drill.domain.CoreDrillDictionary">
+    <insert id="insertCoreDrillDictionary"
+            parameterType="com.xunmei.common.core.domain.drill.domain.CoreDrillDictionary">
         insert into core_drill_dictionary
         <trim prefix="(" suffix=")" suffixOverrides=",">
-                    <if test="id != null">id,
-                    </if>
-                    <if test="drillType != null">drill_type,
-                    </if>
-                    <if test="drillTypeName != null">drill_type_name,
-                    </if>
-                    <if test="drillProjects != null">drill_projects,
-                    </if>
-                    <if test="defaultCause != null">default_cause,
-                    </if>
-                    <if test="deleted != null">deleted,
-                    </if>
+            <if test="id != null">
+                id,
+            </if>
+            <if test="drillType != null">
+                drill_type,
+            </if>
+            <if test="drillTypeName != null">
+                drill_type_name,
+            </if>
+            <if test="drillProjects != null">
+                drill_projects,
+            </if>
+            <if test="defaultCause != null">
+                default_cause,
+            </if>
+            <if test="deleted != null">
+                deleted,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-                    <if test="id != null">#{id},
-                    </if>
-                    <if test="drillType != null">#{drillType},
-                    </if>
-                    <if test="drillTypeName != null">#{drillTypeName},
-                    </if>
-                    <if test="drillProjects != null">#{drillProjects},
-                    </if>
-                    <if test="defaultCause != null">#{defaultCause},
-                    </if>
-                    <if test="deleted != null">#{deleted},
-                    </if>
+            <if test="id != null">
+                #{id},
+            </if>
+            <if test="drillType != null">
+                #{drillType},
+            </if>
+            <if test="drillTypeName != null">
+                #{drillTypeName},
+            </if>
+            <if test="drillProjects != null">
+                #{drillProjects},
+            </if>
+            <if test="defaultCause != null">
+                #{defaultCause},
+            </if>
+            <if test="deleted != null">
+                #{deleted},
+            </if>
         </trim>
     </insert>
 
-    <update id="updateCoreDrillDictionary" parameterType="com.xunmei.common.core.domain.drill.domain.CoreDrillDictionary">
+    <update id="updateCoreDrillDictionary"
+            parameterType="com.xunmei.common.core.domain.drill.domain.CoreDrillDictionary">
         update core_drill_dictionary
         <trim prefix="SET" suffixOverrides=",">
-                    <if test="drillType != null">drill_type =
-                        #{drillType},
-                    </if>
-                    <if test="drillTypeName != null">drill_type_name =
-                        #{drillTypeName},
-                    </if>
-                    <if test="drillProjects != null">drill_projects =
-                        #{drillProjects},
-                    </if>
-                    <if test="defaultCause != null">default_cause =
-                        #{defaultCause},
-                    </if>
-                    <if test="deleted != null">deleted =
-                        #{deleted},
-                    </if>
+            <if test="drillType != null">
+                drill_type =
+                #{drillType},
+            </if>
+            <if test="drillTypeName != null">
+                drill_type_name =
+                #{drillTypeName},
+            </if>
+            <if test="drillProjects != null">
+                drill_projects =
+                #{drillProjects},
+            </if>
+            <if test="defaultCause != null">
+                default_cause =
+                #{defaultCause},
+            </if>
+            <if test="deleted != null">
+                deleted =
+                #{deleted},
+            </if>
         </trim>
         where id = #{id}
     </update>
 
     <delete id="deleteCoreDrillDictionaryById" parameterType="Long">
         delete
-        from core_drill_dictionary where id = #{id}
+        from core_drill_dictionary
+        where id = #{id}
     </delete>
 
     <delete id="deleteCoreDrillDictionaryByIds" parameterType="String">
@@ -118,6 +138,12 @@
         <if test="request.drillType != null">
             and d.drill_type=#{request.drillType}
         </if>
+        <if test="request.checkSub==false">
+            and d.org_id=#{request.orgId}
+        </if>
+        <if test="request.checkSub==true">
+            and d.org_path like concat(#{request.orgPath},'%')
+        </if>
     </select>
 
     <select id="selectDetailData" resultType="com.xunmei.common.core.domain.drill.vo.CoreDrillDictionaryDetailVo">

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

@@ -17,6 +17,7 @@ import com.xunmei.system.api.Eto.OrgListByTypesConditionEto;
 import com.xunmei.system.api.domain.SysDept;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.SysUser;
+import com.xunmei.system.api.vo.SysOrgVO;
 import com.xunmei.system.service.ISysDeptService;
 import com.xunmei.system.service.ISysOrgService;
 import com.xunmei.system.service.ISysUserService;
@@ -147,6 +148,15 @@ public class SysDeptController extends BaseController {
     }
 
     /**
+     * 获取缓存的行社及行社上级机构
+     */
+    @PostMapping("/deptTree/hangshewhole")
+    @InnerAuth
+    public R<List<SysOrgVO>> hangsheWholePathTree(@RequestBody Long orgId) {
+        return R.ok(deptService.hangsheWholePathTree(orgId));
+    }
+
+    /**
      * @param dept
      * @return 获取部门树(全量信息)
      */

+ 14 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysDeptService.java

@@ -38,6 +38,20 @@ public interface ISysDeptService extends IService<SysDept> {
     List<SysOrgVO> selectHangsheTreeList();
 
     /**
+     * 获取缓存的行社及行社上级机构
+     * @param path
+     * @return
+     */
+    List<SysOrgVO> getHangsheTreeCache(String path);
+
+    /**
+     * 获取指定机构树,包含到顶级节点的路径及下级所有机构
+     * @param orgId
+     * @return
+     */
+    List<SysOrgVO> hangsheWholePathTree(Long orgId);
+
+    /**
      * 部门管理
      *
      * @param dept

+ 60 - 27
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysDeptServiceImpl.java

@@ -113,18 +113,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
     @Override
     public List<SysOrgVO> selectDeptTreeList() {
         Long s = System.currentTimeMillis();
-        Long userId = SecurityUtils.getUserId();
-        SysOrg sysOrg = orgMapper.selectSysOrgByUserId(userId);
-        if (ObjectUtil.isNull(sysOrg)) {
-            throw new ServiceException("当前用户没有部门信息");
-        }
-        List<SysOrgVO> cacheList = null;
-        Boolean isOk = RedisUtils.hasKey(CacheConstants.ORG_CACHE_LIST_KEY);
-        if (!isOk) {
-            cacheList = orgService.loadingOrgCache();
-        } else {
-            cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
-        }
+        SysOrg sysOrg= getLoginUserOrg();
+        List<SysOrgVO> cacheList = getOrgCache();
+
         List<SysOrgVO> orgs = new ArrayList<>();
         for (SysOrgVO org : cacheList) {
             String path = org.getPath();
@@ -141,23 +132,24 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
         return generateTree(orgs, sysOrg);
     }
 
+    @Override
     public List<SysOrgVO> selectHangsheTreeList() {
-        Long userId = SecurityUtils.getUserId();
-        SysOrg sysOrg = orgMapper.selectSysOrgByUserId(userId);
-        if (ObjectUtil.isNull(sysOrg)) {
-            throw new ServiceException("当前用户没有部门信息");
-        }
+        SysOrg sysOrg= getLoginUserOrg();
+        List<SysOrgVO> hangshelist = getHangsheTreeCache(sysOrg.getPath());
 
-        List<SysOrgVO> cacheList = null;
-        Boolean isOk = RedisUtils.hasKey(CacheConstants.ORG_CACHE_LIST_KEY);
-        if (!isOk) {
-            cacheList = orgService.loadingOrgCache();
-        } else {
-            cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
-        }
+        return generateTree(hangshelist, sysOrg);
+    }
 
+    /**
+     * 获取缓存的行社及行社上级机构
+     * @param path
+     * @return
+     */
+    @Override
+    public List<SysOrgVO> getHangsheTreeCache(String path){
+        List<SysOrgVO> cacheList = getOrgCache();
         List<SysOrgVO> hangshelist = cacheList.stream().filter(c -> ObjectUtil.equal(c.getType(), 3)
-                        && ObjectUtil.isNotEmpty(c.getPath()) && c.getPath().startsWith(sysOrg.getPath()))
+                        && ObjectUtil.isNotEmpty(c.getPath()) && c.getPath().startsWith(path))
                 .collect(Collectors.toList());
         Set<Long> hangsheSet=hangshelist.stream().map(o->o.getId()).collect(Collectors.toSet());
         Set<Long> parentIds = new HashSet<>();
@@ -171,13 +163,54 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
                     });
         });
         hangshelist.addAll(cacheList.stream()
-                .filter(o -> parentIds.contains(o.getId()) && ObjectUtil.isNotEmpty(o.getPath()) && o.getPath().startsWith(sysOrg.getPath()))
+                .filter(o -> parentIds.contains(o.getId()) && ObjectUtil.isNotEmpty(o.getPath()) && o.getPath().startsWith(path))
                 .collect(Collectors.toList()));
 
-        return generateTree(hangshelist, sysOrg);
+        return  hangshelist;
+    }
+
+    /**
+     * 获取指定机构树,包含到顶级节点的路径及下级所有机构。不组装树结构
+     * @param orgId
+     * @return
+     */
+    @Override
+    public List<SysOrgVO> hangsheWholePathTree(Long orgId){
+        List<SysOrgVO> orgs= getHangsheTreeCache("");
+        Map<Long, SysOrgVO> orgMap = orgs.stream().collect(Collectors.toMap(o -> o.getId(), o -> o));
+        if (!orgMap.containsKey(orgId)) {
+            return new ArrayList<>();
+        }
+
+        SysOrgVO self = orgMap.get(orgId);
+        List<SysOrgVO> orgVOS = orgs.stream().filter(o -> o.getTreeShowPath().startsWith(self.getTreeShowPath()))
+                .collect(Collectors.toList());
+        List<Long> parentIds = Arrays.stream(self.getTreeShowPath().split("-")).map(o -> Long.parseLong(o)).collect(Collectors.toList());
+        parentIds = parentIds.stream().limit(parentIds.size() - 1).collect(Collectors.toList());
+        orgVOS.addAll(parentIds.stream().map(id->orgMap.get(id)).collect(Collectors.toList()));
+
+        return orgVOS;
+    }
+    private SysOrg getLoginUserOrg(){
+        Long userId = SecurityUtils.getUserId();
+        SysOrg sysOrg = orgMapper.selectSysOrgByUserId(userId);
+        if (ObjectUtil.isNull(sysOrg)) {
+            throw new ServiceException("当前用户没有部门信息");
+        }
+        return  sysOrg;
     }
 
+    private List<SysOrgVO> getOrgCache(){
+        List<SysOrgVO> cacheList = null;
+        Boolean isOk = RedisUtils.hasKey(CacheConstants.ORG_CACHE_LIST_KEY);
+        if (!isOk) {
+            cacheList = orgService.loadingOrgCache();
+        } else {
+            cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
+        }
 
+        return  cacheList;
+    }
 
     private List<SysOrgVO> generateTree(List<SysOrgVO> orgs, SysOrg sysOrg) {
         Long parentId = Constants.TOP_ORG_PARENT_ID;

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

@@ -279,6 +279,8 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
         return sysOrgVOS;
     }
 
+
+
     @Override
     public void clearOrgCache() {
         RedisUtils.deleteObject(CacheConstants.ORG_CACHE_LIST_KEY);