浏览代码

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

jingyuanchao 1 年之前
父节点
当前提交
8b73a3666c

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

@@ -131,6 +131,16 @@ public interface RemoteOrgService {
     @GetMapping("/org/getUpOrgs/{orgId}")
     List<Long> getUpOrgs(@PathVariable("orgId") Long orgId);
 
+
+    /**
+     * 获取机构及其上级机构的id列表
+     *
+     * @param orgId
+     * @return
+     */
+    @GetMapping("/dept/selfAndAllParentOrgs/{orgId}")
+    List<SysOrgVO> getSelfAndAllParentOrgs(@PathVariable("orgId") Long orgId);
+
     /**
      * @param source
      * @return

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

@@ -126,6 +126,11 @@ public class RemoteOrgFallbackFactory implements FallbackFactory<RemoteOrgServic
             }
 
             @Override
+            public List<SysOrgVO> getSelfAndAllParentOrgs(Long orgId) {
+                return null;
+            }
+
+            @Override
             public R<List<IdNameVo>> getParentName(List<Long> ids, String source) {
                 return R.ok(new ArrayList<>());
             }

+ 70 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/drill/service/impl/CoreDrillTaskServiceImpl.java

@@ -967,9 +967,14 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
         return TableDataInfo.build(page);
     }
 
+    /**
+     * 优秀案例学习列表查询
+     * @param request
+     * @return
+     */
     @Override
     public TableDataInfo<CoreDrillTaskRecTaskPageVo> recTaskList(CoreDrillTaskRecPageDto request) {
-        dealRecListParam(request);
+        dealRecTaskListParam(request);
 
         IPage<CoreDrillTaskRecTaskPageVo> page = coreDrillTaskMapper.selectRecTaskListPage(request.getPageRequest(), request);
         List<CoreDrillTaskRecTaskPageVo> records = page.getRecords();
@@ -982,6 +987,69 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
         }
         return TableDataInfo.build(page);
     }
+    private void dealRecTaskListParam(CoreDrillTaskRecPageDto request) {
+
+        //App的查询, App 默认下穿
+        request.setCheckSub(true);
+        //App端的时间按季度查询
+        request.setStartTime(DateUtil.beginOfMonth(request.getStartTime()));
+        request.setEndTime(DateUtil.endOfMonth(request.getEndTime()));
+        // 查询行社优秀
+        if(ObjectUtil.equals(request.getRecStatus(),1))
+        {
+            List<SysOrgVO> sysOrgVOS = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.getSelfAndAllParentOrgs(request.getOrgId()), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
+
+            String orgPath = dealRecTaskOrgPathParam(request.getOrgId(),4);
+            request.setOrgPath(orgPath);
+//            // 如果当前机构或者机构的上级存在 行社 取 该行社的机构Path
+//            final Optional<SysOrgVO> first = sysOrgVOS.stream().filter(x -> ObjectUtil.equal(x.getType(), 3)).findFirst();
+//            if(first.isPresent())
+//            {
+//                request.setOrgPath(first.get().getPath());
+//            }
+//            // 不存在行社 这说明该机构是在 行社之上 取当前查询条件机构的Path
+//            else{
+//                final Optional<SysOrgVO> self = sysOrgVOS.stream().filter(x -> ObjectUtil.equal(x.getId(), request.getOrgId())).findFirst();
+//
+//                request.setOrgPath(self.get().getPath());
+//            }
+
+        }
+        // 查询地区优秀
+        else if(ObjectUtil.equals(request.getRecStatus(),3))
+        {
+            String orgPath = dealRecTaskOrgPathParam(request.getOrgId(),2);
+            request.setOrgPath(orgPath);
+        }
+        // 查询省级优秀
+        else if(ObjectUtil.equals(request.getRecStatus(),5))
+        {
+//            SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
+            request.setOrgPath(null);
+        }
+    }
+
+    private  String dealRecTaskOrgPathParam(Long requestOrgId,Integer orgType)
+    {
+        List<SysOrgVO> sysOrgVOS = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.getSelfAndAllParentOrgs(requestOrgId), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
+
+        // 如果当前机构或者机构的上级存在 指定机构类型的机构 该类型的机构Path
+        final Optional<SysOrgVO> first = sysOrgVOS.stream().filter(x -> ObjectUtil.equal(x.getType(), orgType)).findFirst();
+        if(first.isPresent())
+        {
+            return  first.get().getPath();
+        }
+        // 不存在 这说明该机构是在 指定机构类型之上 取当前查询条件机构的Path
+        else{
+            final Optional<SysOrgVO> self = sysOrgVOS.stream().filter(x -> ObjectUtil.equal(x.getId(), requestOrgId)).findFirst();
+
+            if(self.isPresent())
+            {
+                return  self.get().getPath();
+            }
+        }
+        return null;
+    }
 
     private void dealRecListParam(CoreDrillTaskRecPageDto request) {
 
@@ -1273,7 +1341,7 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
                 }
             });
         }
-        waitRecTaskList.removeIf(item -> DateUtil.date().before(item.getStartTime()) || DateUtil.date().after(item.getEndTime()));
+        waitRecTaskList.removeIf(item -> DateUtil.date().before(item.getStartTime()) );
         waitRecTaskList.forEach(item -> {
             item.setType(PanelTypeEnums.DRILL_REC.getCode());
         });

+ 10 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/panel/service/impl/PanelServiceImpl.java

@@ -1,5 +1,6 @@
 package com.xunmei.core.panel.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson2.JSONObject;
 
 import cn.hutool.core.util.ObjectUtil;
@@ -46,6 +47,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.time.LocalDate;
+import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
@@ -142,8 +145,13 @@ public class PanelServiceImpl implements PanelService {
                 drillTaskService.selectCurUserTaskList(panelListDto), threadPoolTaskExecutor
         );
         //预案演练-推优评优任务
-        CompletableFuture<List<PanelListVo>> recLitFuture = CompletableFuture.supplyAsync(() ->
-                drillTaskService.selectRecList(panelListDto), threadPoolTaskExecutor
+        CompletableFuture<List<PanelListVo>> recLitFuture = CompletableFuture.supplyAsync(() ->{
+                PanelListDto tempReqest=new PanelListDto();
+                BeanUtils.copyProperties(panelListDto,tempReqest);
+                tempReqest.setStartTime(DateUtil.offsetMonth(DateUtil.beginOfQuarter(new Date()),-3));
+                tempReqest.setEndTime(DateUtil.endOfQuarter(new Date()));
+                return drillTaskService.selectRecList(tempReqest);
+            }, threadPoolTaskExecutor
         );
 
         //教育培训任务

+ 8 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/question/service/impl/QuestionServiceImpl.java

@@ -37,6 +37,7 @@ import com.xunmei.core.safetyCheck.domain.CoreSafetyTaskDataRemarkimg;
 import com.xunmei.core.safetyCheck.service.ICoreSafetyTaskDataRemarkimgService;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.RemoteUserService;
+import io.netty.util.internal.StringUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -105,8 +106,14 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
     @Override
     public QuestionVo selectQuestionById(Long id) {
         QuestionVo vo = new QuestionVo();
-        Question q = baseMapper.selectById(id);
+        Question q = baseMapper.selectCoreQuestionById(id);
         BeanUtils.copyProperties(q, vo);
+        if (!StringUtil.isNullOrEmpty(q.getAffiliatedArea()) ) {
+            vo.setOrgName(vo.getAffiliatedArea()+"-"+vo.getAffiliatedBank()+"-"+vo.getOrgName());
+        }
+        else {
+            vo.setOrgName(vo.getAffiliatedBank()+"-"+vo.getOrgName());
+        }
 
         LambdaQueryWrapper<QuestionFlow> flowWrapper = new LambdaQueryWrapper<QuestionFlow>();
         flowWrapper.eq(QuestionFlow::getQuestionId, id);

+ 14 - 6
soc-modules/soc-modules-core/src/main/resources/mapper/question/QuestionMapper.xml

@@ -65,10 +65,13 @@
         </where>
     </select>
 
-    <select id="selectCoreQuestionById" parameterType="Long"
-            resultMap="CoreQuestionResult">
-        <include refid="selectCoreQuestionVo"/>
-        where id = #{id}
+    <select id="selectCoreQuestionById" parameterType="Long" resultType="com.xunmei.core.question.domain.Question">
+        select q.*,
+               o.affiliated_area,
+               o.affiliated_bank
+        FROM core_question q
+        LEFT JOIN sys_org o on q.org_id = o.id
+        where q.id = #{id}
     </select>
 
     <insert id="insertCoreQuestion" parameterType="com.xunmei.core.question.domain.Question">
@@ -323,10 +326,15 @@
         order by q.submit_time desc,q.id desc
     </select>
     <select id="pageApp" resultType="com.xunmei.core.question.domain.Question">
-        select * from core_question q
+        select q.*,
+        o.affiliated_area,
+        o.affiliated_bank
+        FROM
+        core_question q
+        LEFT JOIN sys_org o on q.org_id = o.id
         where 1=1
         <if test="params.checkSub==true">
-            and q.org_path like concat((select path from sys_org where id=#{params.orgId}),"%")
+            and q.org_path like concat((select t.path from sys_org t where t.id=#{params.orgId}),"%")
         </if>
         <if test="params.checkSub!=true">
             and q.org_id=#{params.orgId}

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

@@ -360,6 +360,13 @@ public class SysDeptController extends BaseController {
         return orgService.listByParentIdAndType(sysOrg.getParentId(), sysOrg.getType(), sysOrg.getPath());
     }
 
+
+    @GetMapping("/selfAndAllParentOrgs/{orgId}")
+    public List<SysOrgVO> getSelfAndAllParentOrgs(@PathVariable("orgId") Long orgId) {
+        return deptService.getSelfAndAllParentOrgById(orgId);
+    }
+
+
     /**
      * 获取顶级机构
      *

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

@@ -168,4 +168,12 @@ public interface ISysDeptService extends IService<SysDept> {
      * @return 结果
      */
     int deleteDeptById(Long deptId);
+
+    /**
+     * 根据机构Id获取 机构自身以及所有 直接上级
+     *
+     * @param deptId id
+     * @return 树结构列表
+     */
+    List<SysOrgVO> getSelfAndAllParentOrgById(Long deptId);
 }

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

@@ -681,6 +681,33 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
         return deptMapper.deleteDeptById(deptId);
     }
 
+    @Override
+    public List<SysOrgVO> getSelfAndAllParentOrgById(Long deptId) {
+        SysOrgVO sysOrg = null;
+        if (ObjectUtil.isEmpty(deptId)) {
+            deptId = SecurityUtils.getLoginUser().getOrgId();
+        }
+
+        List<SysOrgVO> cacheList = getOrgCache();
+        if (ObjectUtil.isNotEmpty(deptId)) {
+            Long finalOrgId = deptId;
+            final Optional<SysOrgVO> first = cacheList.stream().filter(x -> ObjectUtil.equal(x.getId(), finalOrgId)).findFirst();
+            if (first.isPresent()) {
+                sysOrg = first.get();
+            }
+        }
+        if (ObjectUtil.isEmpty(sysOrg)) {
+            return new ArrayList<>();
+        }
+
+        final List<Long> orgIds = Arrays.stream(sysOrg.getPath().split("-")).map(p -> Long.parseLong(p)).collect(Collectors.toList());
+
+        return cacheList.stream()
+                .filter(o -> orgIds.contains(o.getId()))
+                .collect(Collectors.toList());
+
+    }
+
     /**
      * 递归列表
      */