Forráskód Böngészése

统计报表性能优化

zhulu 1 éve
szülő
commit
38ab26d4ef

+ 4 - 4
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/reportForms/safetyInspect/controller/SafetyInspectReportController.java

@@ -42,7 +42,7 @@ public class SafetyInspectReportController {
     @ApiOperation(value = "行社全面检查情况表",notes = "web端与App共用此接口")
     @RequiresPermissions("core:safetyInspectReport:list")
     @PostMapping("/list")
-    public AjaxResult list(@RequestBody SafetyInspectDTO safetyInspectDTO) {
+    public AjaxResult list(@RequestBody SafetyInspectDTO safetyInspectDTO) throws Exception {
         if (null == safetyInspectDTO.getYear()) {
             LocalDate localDate = LocalDate.now();
             safetyInspectDTO.setYear(String.valueOf(localDate.getYear()));
@@ -62,7 +62,7 @@ public class SafetyInspectReportController {
     @ApiOperation(value = "网点负责人自查情况表",notes = "web端与App共用此接口")
     @RequiresPermissions("core:safetyInspectReport:list")
     @PostMapping("/selfInspectList")
-    public AjaxResult selfInspectList(@RequestBody SafetyInspectDTO safetyInspectDTO) {
+    public AjaxResult selfInspectList(@RequestBody SafetyInspectDTO safetyInspectDTO)throws Exception {
         AjaxResult ajax = AjaxResult.success();
         String title;
         if (ObjectUtil.equal(1,safetyInspectDTO.getCycle())){
@@ -99,7 +99,7 @@ public class SafetyInspectReportController {
     @RequiresPermissions("core:safetyInspectReport:export")
     @Log(title = "行社全面检查情况表", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(SafetyInspectDTO request, HttpServletResponse response) throws IOException {
+    public void export(SafetyInspectDTO request, HttpServletResponse response) throws  Exception {
         if (null == request.getYear()) {
             LocalDate localDate = LocalDate.now();
             request.setYear(String.valueOf(localDate.getYear()));
@@ -111,7 +111,7 @@ public class SafetyInspectReportController {
     @RequiresPermissions("core:safetyInspectReport:export")
     @Log(title = "网点负责人自查情况表导出", businessType = BusinessType.EXPORT)
     @PostMapping("/selfInspectExport")
-    public void selfInspectExport(SafetyInspectDTO request, HttpServletResponse response) throws IOException {
+    public void selfInspectExport(SafetyInspectDTO request, HttpServletResponse response) throws Exception {
 //        if (null == request.getYear()) {
 //            request.setCycle(1);
 //            LocalDate localDate = LocalDate.now();

+ 6 - 5
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/reportForms/safetyInspect/service/SafetyInspectService.java

@@ -11,25 +11,26 @@ import com.xunmei.system.api.domain.SysOrg;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
 
 /**
  * @author :LuoWei
  * @date : 2023/10/31
  */
 public interface SafetyInspectService {
-    List<SafetyInspectVO> report(SafetyInspectDTO safetyInspectDTO);
-
+    List<SafetyInspectVO> report(SafetyInspectDTO safetyInspectDTO) throws ExecutionException, InterruptedException, TimeoutException;
     /**
      * 自查
      *
      * @param safetyInspectDTO
      * @return
      */
-    List<SelfInspectVO> selfInspectReport(SafetyInspectDTO safetyInspectDTO);
+    List<SelfInspectVO> selfInspectReport(SafetyInspectDTO safetyInspectDTO) throws ExecutionException, InterruptedException, TimeoutException;
 
-    void export(SafetyInspectDTO safetyInspectDTO, HttpServletResponse response) throws IOException;
+    void export(SafetyInspectDTO safetyInspectDTO, HttpServletResponse response) throws IOException,ExecutionException, InterruptedException, TimeoutException;
 
-    void selfInspectExport(SafetyInspectDTO safetyInspectDTO, HttpServletResponse response) throws IOException;
+    void selfInspectExport(SafetyInspectDTO safetyInspectDTO, HttpServletResponse response) throws IOException,ExecutionException, InterruptedException, TimeoutException;
 
     List<SysOrg> selectAllOrg();
 }

+ 204 - 89
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/reportForms/safetyInspect/service/impl/SafetyInspectServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.excel.EasyExcel;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.enums.OrgTypeEnum;
+import com.xunmei.common.core.thread.ThreadPoolConfig;
 import com.xunmei.common.core.utils.DateHelper;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.security.utils.SecurityUtils;
@@ -18,6 +19,8 @@ import com.xunmei.core.reportForms.safetyInspect.vo.SelfInspectVO;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -25,6 +28,10 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.net.URLEncoder;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 /**
  * @author :LuoWei
@@ -41,8 +48,12 @@ public class SafetyInspectServiceImpl implements SafetyInspectService {
     @Autowired
     private RemoteOrgService orgService;
 
+    @Autowired
+    @Qualifier(ThreadPoolConfig.SOC_EXECUTOR)
+    private ThreadPoolTaskExecutor threadPoolTaskExecutor;
+
     @Override
-    public List<SafetyInspectVO> report(SafetyInspectDTO safetyInspectDTO) {
+    public List<SafetyInspectVO> report(SafetyInspectDTO safetyInspectDTO) throws ExecutionException, InterruptedException, TimeoutException {
         if (null == safetyInspectDTO.getOrgId()) {
             safetyInspectDTO.setOrgId(SecurityUtils.getLoginUser().getOrgId());
         }
@@ -64,57 +75,112 @@ public class SafetyInspectServiceImpl implements SafetyInspectService {
             return Collections.emptyList();
         }
         List<SafetyInspectVO> safetyInspectVOList = new ArrayList<>();
-        sysOrgs.forEach(s -> {
-            SafetyInspectVO safetyInspectVO = new SafetyInspectVO();
-            SysOrg sysOrg1;
-            if (sysOrg.getType() < 3 || sysOrg.getShortName().endsWith("地区行社") || sysOrg.getType() == 9) {
-                sysOrg1 = orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER);
-            } else {
-                sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
-                if (!sysOrg1.getShortName().contains("地区行社")) {
-                    sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
-                }
-            }
-            safetyInspectVO.setCity(!sysOrg1.getShortName().contains("地区行社") ? sysOrg1.getShortName().substring(0, 2) : sysOrg1.getShortName().split("地区行社")[0]);
-            safetyInspectVO.setOrgName(s.getShortName());
-            SafetyInspectVO safetyInspectVOS;
-            Integer planInspectOrg;
-            Integer realityInspectOrg;
-            Map map1;
-            if (!Objects.equals(s.getType(), OrgTypeEnum.YINGYE_WANGDIAN.getCode())) {
-                //次数
-                safetyInspectVOS = safetyInspectMapper.selectAllByPath(null, s.getPath(), safetyInspectDTO);
-                //机构维度
-                planInspectOrg = safetyInspectMapper.orgDimensionPlanInspectOrg(null, s.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
-                realityInspectOrg = safetyInspectMapper.orgDimensionRealityInspectOrg(null, s.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
-                map1 = safetyInspectMapper.pitfallDimension(null, s.getPath(), safetyInspectDTO, safetyInspectDTO.getOrgType(), 4);
-            } else {
-                safetyInspectVOS = safetyInspectMapper.selectAllByPath(s.getId(), null, safetyInspectDTO);
-                planInspectOrg = safetyInspectMapper.orgDimensionPlanInspectOrg(s.getId(), s.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
-                realityInspectOrg = safetyInspectMapper.orgDimensionRealityInspectOrg(s.getId(), s.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
-                map1 = safetyInspectMapper.pitfallDimension(s.getId(), null, safetyInspectDTO, safetyInspectDTO.getOrgType(), 4);
-            }
-            double i = 0d;
-            if (planInspectOrg != 0 && realityInspectOrg != 0) {
-                i = (double) realityInspectOrg / planInspectOrg * 100;
-            }
-            safetyInspectVO.setPlanInspectOrg(planInspectOrg);
-            safetyInspectVO.setRealityInspectOrg(realityInspectOrg);
-            safetyInspectVO.setInspectCoverRate(String.format("%.2f", i) + "%");
-            safetyInspectVO.setOrgName(s.getShortName());
-            safetyInspectVO.setPitfallNumber(Integer.valueOf(map1.get("pitfallNumber").toString()));
-            safetyInspectVO.setRectificationNumber(Integer.valueOf(map1.get("rectificationNumber").toString()));
-            safetyInspectVO.setRectificationRate(map1.get("rectificationRate").toString());
-            safetyInspectVO.setPlanInspectNumber(safetyInspectVOS.getPlanInspectNumber());
-            safetyInspectVO.setRealityInspectNumber(safetyInspectVOS.getRealityInspectNumber());
-            safetyInspectVO.setInspectRate(safetyInspectVOS.getInspectRate());
-            safetyInspectVOList.add(safetyInspectVO);
+//        sysOrgs.forEach(s -> {
+//            SafetyInspectVO safetyInspectVO = new SafetyInspectVO();
+////            SysOrg sysOrg1;
+////            if (sysOrg.getType() < 3 || sysOrg.getShortName().endsWith("地区行社") || sysOrg.getType() == 9) {
+////                sysOrg1 = orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER);
+////            } else {
+////                sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
+////                if (!sysOrg1.getShortName().contains("地区行社")) {
+////                    sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
+////                }
+////            }
+//            safetyInspectVO.setCity(s.getAffiliatedArea());
+//            safetyInspectVO.setOrgName(s.getShortName());
+//            SafetyInspectVO safetyInspectVOS;
+//            Integer planInspectOrg;
+//            Integer realityInspectOrg;
+//            Map map1;
+//            if (!Objects.equals(s.getType(), OrgTypeEnum.YINGYE_WANGDIAN.getCode())) {
+//                //次数
+//                safetyInspectVOS = safetyInspectMapper.selectAllByPath(null, s.getPath(), safetyInspectDTO);
+//                //机构维度
+//                planInspectOrg = safetyInspectMapper.orgDimensionPlanInspectOrg(null, s.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
+//                realityInspectOrg = safetyInspectMapper.orgDimensionRealityInspectOrg(null, s.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
+//                map1 = safetyInspectMapper.pitfallDimension(null, s.getPath(), safetyInspectDTO, safetyInspectDTO.getOrgType(), 4);
+//            } else {
+//                safetyInspectVOS = safetyInspectMapper.selectAllByPath(s.getId(), null, safetyInspectDTO);
+//                planInspectOrg = safetyInspectMapper.orgDimensionPlanInspectOrg(s.getId(), s.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
+//                realityInspectOrg = safetyInspectMapper.orgDimensionRealityInspectOrg(s.getId(), s.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
+//                map1 = safetyInspectMapper.pitfallDimension(s.getId(), null, safetyInspectDTO, safetyInspectDTO.getOrgType(), 4);
+//            }
+//            double i = 0d;
+//            if (planInspectOrg != 0 && realityInspectOrg != 0) {
+//                i = (double) realityInspectOrg / planInspectOrg * 100;
+//            }
+//            safetyInspectVO.setPlanInspectOrg(planInspectOrg);
+//            safetyInspectVO.setRealityInspectOrg(realityInspectOrg);
+//            safetyInspectVO.setInspectCoverRate(String.format("%.2f", i) + "%");
+//            safetyInspectVO.setOrgName(s.getShortName());
+//            safetyInspectVO.setPitfallNumber(Integer.valueOf(map1.get("pitfallNumber").toString()));
+//            safetyInspectVO.setRectificationNumber(Integer.valueOf(map1.get("rectificationNumber").toString()));
+//            safetyInspectVO.setRectificationRate(map1.get("rectificationRate").toString());
+//            safetyInspectVO.setPlanInspectNumber(safetyInspectVOS.getPlanInspectNumber());
+//            safetyInspectVO.setRealityInspectNumber(safetyInspectVOS.getRealityInspectNumber());
+//            safetyInspectVO.setInspectRate(safetyInspectVOS.getInspectRate());
+//            safetyInspectVOList.add(safetyInspectVO);
+//        });
+        List<CompletableFuture<SafetyInspectVO>> completableFutureList = new ArrayList<>();
+        sysOrgs.forEach(o -> {
+            CompletableFuture<SafetyInspectVO> getOneOrgSafetyInspectVO = CompletableFuture.supplyAsync(() ->
+                    getOneOrgSafetyInspectData(o, safetyInspectDTO), threadPoolTaskExecutor
+            );
+            completableFutureList.add(getOneOrgSafetyInspectVO);
+        });
+
+        CompletableFuture<Void> allQueries = CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0]));
+
+        allQueries.get(15L, TimeUnit.SECONDS);
+
+        completableFutureList.forEach(x -> {
+            safetyInspectVOList.add(x.join());
         });
         return safetyInspectVOList;
     }
 
+    private SafetyInspectVO getOneOrgSafetyInspectData(SysOrg org,SafetyInspectDTO safetyInspectDTO)
+    {
+        SafetyInspectVO safetyInspectVO = new SafetyInspectVO();
+
+        safetyInspectVO.setCity(org.getAffiliatedArea());
+        safetyInspectVO.setOrgName(org.getShortName());
+        SafetyInspectVO safetyInspectVOS;
+        Integer planInspectOrg;
+        Integer realityInspectOrg;
+        Map map1;
+        if (!Objects.equals(org.getType(), OrgTypeEnum.YINGYE_WANGDIAN.getCode())) {
+            //次数
+            safetyInspectVOS = safetyInspectMapper.selectAllByPath(null, org.getPath(), safetyInspectDTO);
+            //机构维度
+            planInspectOrg = safetyInspectMapper.orgDimensionPlanInspectOrg(null, org.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
+            realityInspectOrg = safetyInspectMapper.orgDimensionRealityInspectOrg(null, org.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
+            map1 = safetyInspectMapper.pitfallDimension(null, org.getPath(), safetyInspectDTO, safetyInspectDTO.getOrgType(), 4);
+        } else {
+            safetyInspectVOS = safetyInspectMapper.selectAllByPath(org.getId(), null, safetyInspectDTO);
+            planInspectOrg = safetyInspectMapper.orgDimensionPlanInspectOrg(org.getId(), org.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
+            realityInspectOrg = safetyInspectMapper.orgDimensionRealityInspectOrg(org.getId(), org.getPath(), safetyInspectDTO.getYear(), safetyInspectDTO.getOrgType(), 4);
+            map1 = safetyInspectMapper.pitfallDimension(org.getId(), null, safetyInspectDTO, safetyInspectDTO.getOrgType(), 4);
+        }
+        double i = 0d;
+        if (planInspectOrg != 0 && realityInspectOrg != 0) {
+            i = (double) realityInspectOrg / planInspectOrg * 100;
+        }
+        safetyInspectVO.setPlanInspectOrg(planInspectOrg);
+        safetyInspectVO.setRealityInspectOrg(realityInspectOrg);
+        safetyInspectVO.setInspectCoverRate(String.format("%.2f", i) + "%");
+        safetyInspectVO.setOrgName(org.getShortName());
+        safetyInspectVO.setPitfallNumber(Integer.valueOf(map1.get("pitfallNumber").toString()));
+        safetyInspectVO.setRectificationNumber(Integer.valueOf(map1.get("rectificationNumber").toString()));
+        safetyInspectVO.setRectificationRate(map1.get("rectificationRate").toString());
+        safetyInspectVO.setPlanInspectNumber(safetyInspectVOS.getPlanInspectNumber());
+        safetyInspectVO.setRealityInspectNumber(safetyInspectVOS.getRealityInspectNumber());
+        safetyInspectVO.setInspectRate(safetyInspectVOS.getInspectRate());
+        return safetyInspectVO;
+    }
+
     @Override
-    public List<SelfInspectVO> selfInspectReport(SafetyInspectDTO safetyInspectDTO) {
+    public List<SelfInspectVO> selfInspectReport(SafetyInspectDTO safetyInspectDTO) throws ExecutionException, InterruptedException, TimeoutException {
         if (null == safetyInspectDTO.getOrgId()) {
             safetyInspectDTO.setOrgId(SecurityUtils.getLoginUser().getOrgId());
         }
@@ -137,52 +203,101 @@ public class SafetyInspectServiceImpl implements SafetyInspectService {
             return Collections.emptyList();
         }
         List<SelfInspectVO> safetyInspectVOList = new ArrayList<>();
-        sysOrgs.forEach(s -> {
-            SelfInspectVO safetyInspectVO = new SelfInspectVO();
-            SysOrg sysOrg1;
-            if (sysOrg.getType() < 3 || sysOrg.getShortName().endsWith("地区行社") || sysOrg.getType() == 9) {
-                sysOrg1 = orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER);
-            } else {
-                sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
-                if (!sysOrg1.getShortName().contains("地区行社")) {
-                    sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
-                }
-            }
-            SafetyInspectVO safetyInspectVOS;
-            Map map1;
-            Map map;
-            Integer integer = monitorAccessReportMapper.selectOrgNumByPathAndType(s.getPath(), OrgTypeEnum.YINGYE_WANGDIAN.getCode());
-            if (s.getType() != 4) {
-                //次数
-                safetyInspectVOS = safetyInspectMapper.selectSelfByPath(null, s.getPath(), safetyInspectDTO);
-                map1 = safetyInspectMapper.pitfallDimension(null, s.getPath(), safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
-                //机构维度
-                map = safetyInspectMapper.orgDimension(null, s.getPath(), safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
-            } else {
-                integer = 1;
-                safetyInspectVOS = safetyInspectMapper.selectSelfByPath(s.getId(), null, safetyInspectDTO);
-                map1 = safetyInspectMapper.pitfallDimension(s.getId(), null, safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
-                map = safetyInspectMapper.orgDimension(s.getId(), null, safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
-            }
-            safetyInspectVO.setPlanInspectOrg(integer);
-            safetyInspectVO.setCity(!sysOrg1.getShortName().contains("地区行社") ? sysOrg1.getShortName().substring(0, 2) : sysOrg1.getShortName().split("地区行社")[0]);
-            safetyInspectVO.setOrgName(s.getShortName());
-            safetyInspectVO.setRealityInspectOrg(Integer.valueOf(map.get("realityInspectOrg").toString()));
-            safetyInspectVO.setInspectCoverRate(map.get("inspectCoverRate").toString());
-            safetyInspectVO.setOrgName(s.getShortName());
-            safetyInspectVO.setPitfallNumber(Integer.valueOf(map1.get("pitfallNumber").toString()));
-            safetyInspectVO.setRectificationNumber(Integer.valueOf(map1.get("rectificationNumber").toString()));
-            safetyInspectVO.setRectificationRate(map1.get("rectificationRate").toString());
-            safetyInspectVO.setPlanInspectNumber(safetyInspectVOS.getPlanInspectNumber());
-            safetyInspectVO.setRealityInspectNumber(safetyInspectVOS.getRealityInspectNumber());
-            safetyInspectVO.setInspectRate(safetyInspectVOS.getInspectRate());
-            safetyInspectVOList.add(safetyInspectVO);
+//        sysOrgs.forEach(s -> {
+//            SelfInspectVO safetyInspectVO = new SelfInspectVO();
+////            SysOrg sysOrg1;
+////            if (sysOrg.getType() < 3 || sysOrg.getShortName().endsWith("地区行社") || sysOrg.getType() == 9) {
+////                sysOrg1 = orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER);
+////            } else {
+////                sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
+////                if (!sysOrg1.getShortName().contains("地区行社")) {
+////                    sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(orgService.selectOrgById(s.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
+////                }
+////            }
+//            SafetyInspectVO safetyInspectVOS;
+//            Map map1;
+//            Map map;
+//            Integer integer = monitorAccessReportMapper.selectOrgNumByPathAndType(s.getPath(), OrgTypeEnum.YINGYE_WANGDIAN.getCode());
+//            if (s.getType() != 4) {
+//                //次数
+//                safetyInspectVOS = safetyInspectMapper.selectSelfByPath(null, s.getPath(), safetyInspectDTO);
+//                map1 = safetyInspectMapper.pitfallDimension(null, s.getPath(), safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
+//                //机构维度
+//                map = safetyInspectMapper.orgDimension(null, s.getPath(), safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
+//            } else {
+//                integer = 1;
+//                safetyInspectVOS = safetyInspectMapper.selectSelfByPath(s.getId(), null, safetyInspectDTO);
+//                map1 = safetyInspectMapper.pitfallDimension(s.getId(), null, safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
+//                map = safetyInspectMapper.orgDimension(s.getId(), null, safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
+//            }
+//            safetyInspectVO.setPlanInspectOrg(integer);
+//            safetyInspectVO.setCity(s.getAffiliatedArea());
+//            safetyInspectVO.setOrgName(s.getShortName());
+//            safetyInspectVO.setRealityInspectOrg(Integer.valueOf(map.get("realityInspectOrg").toString()));
+//            safetyInspectVO.setInspectCoverRate(map.get("inspectCoverRate").toString());
+//            safetyInspectVO.setOrgName(s.getShortName());
+//            safetyInspectVO.setPitfallNumber(Integer.valueOf(map1.get("pitfallNumber").toString()));
+//            safetyInspectVO.setRectificationNumber(Integer.valueOf(map1.get("rectificationNumber").toString()));
+//            safetyInspectVO.setRectificationRate(map1.get("rectificationRate").toString());
+//            safetyInspectVO.setPlanInspectNumber(safetyInspectVOS.getPlanInspectNumber());
+//            safetyInspectVO.setRealityInspectNumber(safetyInspectVOS.getRealityInspectNumber());
+//            safetyInspectVO.setInspectRate(safetyInspectVOS.getInspectRate());
+//            safetyInspectVOList.add(safetyInspectVO);
+//        });
+        List<CompletableFuture<SelfInspectVO>> completableFutureList = new ArrayList<>();
+        sysOrgs.forEach(o -> {
+            CompletableFuture<SelfInspectVO> getOneOrgSafetyInspectVO = CompletableFuture.supplyAsync(() ->
+                    getOneOrgSelfInspectData(o, safetyInspectDTO), threadPoolTaskExecutor
+            );
+            completableFutureList.add(getOneOrgSafetyInspectVO);
+        });
+
+        CompletableFuture<Void> allQueries = CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0]));
+
+        allQueries.get(15L, TimeUnit.SECONDS);
+
+        completableFutureList.forEach(x -> {
+            safetyInspectVOList.add(x.join());
         });
         return safetyInspectVOList;
     }
 
+    private SelfInspectVO getOneOrgSelfInspectData(SysOrg org,SafetyInspectDTO safetyInspectDTO)
+    {
+        SelfInspectVO safetyInspectVoResult = new SelfInspectVO();
+        SafetyInspectVO safetyInspectVOS;
+        Map map1;
+        Map map;
+        Integer integer = monitorAccessReportMapper.selectOrgNumByPathAndType(org.getPath(), OrgTypeEnum.YINGYE_WANGDIAN.getCode());
+        if (org.getType() != 4) {
+            //次数
+            safetyInspectVOS = safetyInspectMapper.selectSelfByPath(null, org.getPath(), safetyInspectDTO);
+            map1 = safetyInspectMapper.pitfallDimension(null, org.getPath(), safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
+            //机构维度
+            map = safetyInspectMapper.orgDimension(null, org.getPath(), safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
+        } else {
+            integer = 1;
+            safetyInspectVOS = safetyInspectMapper.selectSelfByPath(org.getId(), null, safetyInspectDTO);
+            map1 = safetyInspectMapper.pitfallDimension(org.getId(), null, safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
+            map = safetyInspectMapper.orgDimension(org.getId(), null, safetyInspectDTO, safetyInspectDTO.getOrgType(), 3);
+        }
+        safetyInspectVoResult.setPlanInspectOrg(integer);
+        safetyInspectVoResult.setCity(org.getAffiliatedArea());
+        safetyInspectVoResult.setOrgName(org.getShortName());
+        safetyInspectVoResult.setRealityInspectOrg(Integer.valueOf(map.get("realityInspectOrg").toString()));
+        safetyInspectVoResult.setInspectCoverRate(map.get("inspectCoverRate").toString());
+        safetyInspectVoResult.setOrgName(org.getShortName());
+        safetyInspectVoResult.setPitfallNumber(Integer.valueOf(map1.get("pitfallNumber").toString()));
+        safetyInspectVoResult.setRectificationNumber(Integer.valueOf(map1.get("rectificationNumber").toString()));
+        safetyInspectVoResult.setRectificationRate(map1.get("rectificationRate").toString());
+        safetyInspectVoResult.setPlanInspectNumber(safetyInspectVOS.getPlanInspectNumber());
+        safetyInspectVoResult.setRealityInspectNumber(safetyInspectVOS.getRealityInspectNumber());
+        safetyInspectVoResult.setInspectRate(safetyInspectVOS.getInspectRate());
+        return safetyInspectVoResult;
+    }
+
     @Override
-    public void export(SafetyInspectDTO safetyInspectDTO, HttpServletResponse response) throws IOException {
+    public void export(SafetyInspectDTO safetyInspectDTO, HttpServletResponse response) throws IOException,ExecutionException, InterruptedException, TimeoutException {
         String orgName = null;
         SysOrg sysOrg;
         if (null == safetyInspectDTO.getOrgId()) {
@@ -218,7 +333,7 @@ public class SafetyInspectServiceImpl implements SafetyInspectService {
     }
 
     @Override
-    public void selfInspectExport(SafetyInspectDTO safetyInspectDTO, HttpServletResponse response) throws IOException {
+    public void selfInspectExport(SafetyInspectDTO safetyInspectDTO, HttpServletResponse response) throws IOException,ExecutionException, InterruptedException, TimeoutException {
         String orgName = null;
         SysOrg sysOrg;
         if (null == safetyInspectDTO.getOrgId()) {

+ 111 - 105
soc-modules/soc-modules-core/src/main/resources/mapper/reportForms/ResumptionReportMapper.xml

@@ -75,37 +75,38 @@
         COALESCE(CONCAT(ROUND(COUNT(a.exception_reform_count) / COALESCE(SUM(a.exception_count), 0) * 100, 2), '%'),
         '0%') AS totalRealityRectificationRate
         FROM (
-        SELECT
-        r.*,
-        b.plan_cycle as planType,
-        (SELECT COUNT(d.id) FROM core_question d WHERE r.id = d.src_task_id AND d.reform_status IN (11,13)) AS
-        exception_reform_count
-        FROM
-        core_resumption r
-        INNER JOIN sys_org o ON r.org_id = o.id AND o.deleted = 0 AND o.is_lock = 0
-        LEFT JOIN core_resumption_plan b ON r.plan_id = b.id
-        ) a
+            SELECT
+                r.*,
+                b.plan_cycle as planType,
+                (SELECT COUNT(d.id) FROM core_question d WHERE r.id = d.src_task_id AND d.reform_status IN (11,13)) AS
+                exception_reform_count
+            FROM
+            core_resumption r
+            INNER JOIN sys_org o ON r.org_id = o.id AND o.deleted = 0 AND o.is_lock = 0
+            LEFT JOIN core_resumption_plan b ON r.plan_id = b.id
         WHERE
-        a.type = 2 and a.planType in (2,3,4)
-        <if test="orgId !=null">
-            AND a.org_id = #{orgId}
-        </if>
-        <choose>
-            <when test="req.appSelect ==1">
-                and a.ymd_date between #{req.startTime} and #{req.endTime}
-            </when>
-            <otherwise>
-                <if test=" req.cycle ==2">
-                    AND a.ymd_date like concat(#{req.searchTime},'%')
-                </if>
-                <if test="req.cycle ==1 || req.cycle ==null">
-                    AND a.ymd_date = #{req.searchTime}
-                </if>
-            </otherwise>
-        </choose>
-        <if test="orgPath !=null">
-            and a.org_path like concat(#{orgPath},'%')
-        </if>
+            r.type = 2 and b.plan_cycle in (2,3,4)
+            <if test="orgId !=null">
+                AND r.org_id = #{orgId}
+            </if>
+            <choose>
+                <when test="req.appSelect ==1">
+                    and r.ymd_date between #{req.startTime} and #{req.endTime}
+                </when>
+                <otherwise>
+                    <if test=" req.cycle ==2">
+                        AND r.ymd_date like concat(#{req.searchTime},'%')
+                    </if>
+                    <if test="req.cycle ==1 || req.cycle ==null">
+                        AND r.ymd_date = #{req.searchTime}
+                    </if>
+                </otherwise>
+            </choose>
+            <if test="orgPath !=null">
+                and o.path like concat(#{orgPath},'%')
+            </if>
+        ) a
+
         GROUP BY a.planType
     </select>
     <select id="planRectification" resultType="java.lang.Integer">
@@ -138,29 +139,30 @@
         FROM
         (
                 SELECT
-                r.*,
-                b.plan_type,
-                (SELECT COUNT(d.id) from core_question d WHERE r.id = d.src_task_id AND d.reform_status IN (11,13)) as exception_reform_count
-                FROM
-                core_resumption r
+                    r.*,
+                    b.plan_type,
+                    (SELECT COUNT(d.id) from core_question d WHERE r.id = d.src_task_id AND d.reform_status IN (11,13)) as exception_reform_count
+                    FROM
+                    core_resumption r
                 INNER JOIN sys_org o ON r.org_id=o.id AND o.deleted=0 AND o.is_lock =0
-                LEFT JOIN core_resumption_plan b ON r.plan_id = b.id
+                INNER JOIN core_resumption_plan b ON r.plan_id = b.id
+                WHERE
+                b.plan_type =4
+                <if test="orgId !=null">
+                    and o.id=#{orgId}
+                </if>
+                <if test="dto !=null and dto.startTime != null and dto.endTime != null">
+                    AND
+                    (
+                    #{dto.startTime}   <![CDATA[<=]]> r.ymd_date
+                    and #{dto.endTime}     <![CDATA[>=]]> r.ymd_date
+                    )
+                </if>
+                <if test="orgPath !=null">
+                    and o.path  like concat(#{orgPath},'%')
+                </if>
         ) a
-        WHERE
-            a.plan_type =4
-          <if test="orgId !=null">
-              and a.org_id=#{orgId}
-          </if>
-        <if test="dto !=null and dto.startTime != null and dto.endTime != null">
-            AND
-            (
-            #{dto.startTime}   <![CDATA[<=]]> a.ymd_date
-            and #{dto.endTime}     <![CDATA[>=]]> a.ymd_date
-            )
-        </if>
-        <if test="orgPath !=null">
-            and a.org_path  like concat(#{orgPath},'%')
-        </if>
+
     </select>
     <select id="selectStandbyPower"
             resultType="com.xunmei.core.reportForms.resumption.vo.IntrusionTestReportVO">
@@ -189,36 +191,37 @@
         FROM
         (
             SELECT
-            r.*,
-            b.plan_type,
-            (SELECT COUNT(d.id) from core_question d WHERE r.id = d.src_task_id AND d.reform_status IN (11,13)) as exception_reform_count
+                r.*,
+                b.plan_type,
+                (SELECT COUNT(d.id) from core_question d WHERE r.id = d.src_task_id AND d.reform_status IN (11,13)) as exception_reform_count
             FROM
-            core_resumption r
-            INNER JOIN sys_org o ON r.org_id=o.id AND o.deleted=0 AND o.is_lock =0
-            LEFT JOIN core_resumption_plan b ON r.plan_id = b.id
+                core_resumption r
+                INNER JOIN sys_org o ON r.org_id=o.id AND o.deleted=0 AND o.is_lock =0
+                LEFT JOIN core_resumption_plan b ON r.plan_id = b.id
+            WHERE
+                b.plan_type =5
+                <if test="startTime !=null and endTime !=null">
+                    and ((
+                    #{startTime} &lt;= r.plan_start_time
+                    and #{endTime} >= r.plan_start_time
+                    )
+                    or (
+                    #{startTime} &lt;= r.plan_end_time
+                    and #{endTime} >= r.plan_end_time
+                    )
+                    or (
+                    #{startTime} >= r.plan_start_time
+                    and #{endTime} &lt;= r.plan_end_time
+                    ))
+                </if>
+                <if test="orgId !=null">
+                    and o.id=#{orgId}
+                </if>
+                <if test="orgPath !=null">
+                    and o.path  like concat(#{orgPath},'%')
+                </if>
         ) a
-        WHERE
-        a.plan_type =5
-        <if test="startTime !=null and endTime !=null">
-            and ((
-            #{startTime} &lt;= a.plan_start_time
-            and #{endTime} >= a.plan_start_time
-            )
-            or (
-            #{startTime} &lt;= a.plan_end_time
-            and #{endTime} >= a.plan_end_time
-            )
-            or (
-            #{startTime} >= a.plan_start_time
-            and #{endTime} &lt;= a.plan_end_time
-            ))
-        </if>
-          <if test="orgId !=null">
-              and a.org_id=#{orgId}
-          </if>
-        <if test="orgPath !=null">
-            and a.org_path  like concat(#{orgPath},'%')
-        </if>
+
     </select>
     <select id="selectServiceBankReport"
             resultType="com.xunmei.core.reportForms.resumption.vo.LhSelfBankInspectionReport">
@@ -248,29 +251,30 @@
         FROM
         (
             SELECT
-            r.*,
-            b.plan_type,
-            (SELECT COUNT(d.id) from core_question d WHERE r.id = d.src_task_id AND d.reform_status IN (11,13)) as exception_reform_count
+                r.*,
+                b.plan_type,
+                (SELECT COUNT(d.id) from core_question d WHERE r.id = d.src_task_id AND d.reform_status IN (11,13)) as exception_reform_count
             FROM
-            core_resumption r
-            INNER JOIN sys_org o ON r.org_id=o.id AND o.deleted=0 AND o.is_lock =0
-            LEFT JOIN core_resumption_plan b ON r.plan_id = b.id
+                core_resumption r
+                INNER JOIN sys_org o ON r.org_id=o.id AND o.deleted=0 AND o.is_lock =0
+                INNER JOIN core_resumption_plan b ON r.plan_id = b.id
+            WHERE
+                b.plan_type =6
+                <if test="dto !=null and dto.startTime != null and dto.endTime != null">
+                    AND
+                    (
+                    #{dto.startTime}   <![CDATA[<=]]> r.ymd_date
+                    and #{dto.endTime}     <![CDATA[>=]]> r.ymd_date
+                    )
+                </if>
+                <if test="orgId !=null">
+                    and o.id=#{orgId}
+                </if>
+                <if test="orgPath !=null">
+                    and o.path  like concat(#{orgPath},'%')
+                </if>
         ) a
-        WHERE
-        a.plan_type =6
-        <if test="dto !=null and dto.startTime != null and dto.endTime != null">
-            AND
-            (
-            #{dto.startTime}   <![CDATA[<=]]> a.ymd_date
-            and #{dto.endTime}     <![CDATA[>=]]> a.ymd_date
-            )
-        </if>
-        <if test="orgId !=null">
-          and a.org_id=#{orgId}
-        </if>
-        <if test="orgPath !=null">
-            and a.org_path  like concat(#{orgPath},'%')
-        </if>
+
     </select>
     <select id="selectStandbyPowerAbnormalNumber" resultType="java.util.Map">
         SELECT
@@ -289,7 +293,8 @@
         '0%'
         ) AS realityRectificationRate
         FROM
-            core_resumption a
+                core_resumption a
+                INNER JOIN sys_org o ON a.org_id=o.id AND o.deleted=0 AND o.is_lock =0
                 LEFT JOIN core_resumption_plan b ON a.plan_id = b.id
                 LEFT JOIN core_question c ON c.src_task_id = a.id
         WHERE
@@ -310,10 +315,10 @@
             ))
         </if>
           <if test="orgId !=null">
-              and a.org_id=#{orgId}
+              and o.id=#{orgId}
           </if>
         <if test="orgPath !=null">
-            and a.org_path  like concat(#{orgPath},'%')
+            and o.path  like concat(#{orgPath},'%')
         </if>
     </select>
     <select id="selectIntrusionTestAbnormalNumber" resultType="java.util.Map">
@@ -334,6 +339,7 @@
         ) AS realityRectificationRate
         FROM
         core_resumption a
+        INNER JOIN sys_org o ON a.org_id=o.id AND o.deleted=0 AND o.is_lock =0
         LEFT JOIN core_resumption_plan b ON a.plan_id = b.id
         LEFT JOIN core_question c ON c.src_task_id = a.id
         WHERE
@@ -347,10 +353,10 @@
             )
         </if>
         <if test="orgId !=null">
-            and a.org_id=#{orgId}
+            and o.id=#{orgId}
         </if>
         <if test="orgPath !=null">
-            and a.org_path  like concat(#{orgPath},'%')
+            and o.path  like concat(#{orgPath},'%')
         </if>
     </select>
 </mapper>

+ 16 - 16
soc-modules/soc-modules-core/src/main/resources/mapper/reportForms/SafetyInspectMapper.xml

@@ -90,8 +90,8 @@
         ) AS inspectRate
         FROM
         core_safety_task a
-        LEFT JOIN sys_org b ON a.org_id = b.id
-        LEFT JOIN core_safecheck_plan c ON a.plan_id = c.id
+        INNER JOIN sys_org b ON a.org_id = b.id
+        INNER JOIN core_safecheck_plan c ON a.plan_id = c.id
         WHERE
         a.deleted = 0 and b.deleted=0
         AND c.check_type =4
@@ -99,7 +99,7 @@
               and a.org_id=#{orgId}
           </if>
         <if test="orgPath !=null and orgPath !=''">
-            and a.org_path like concat(#{orgPath},'%')
+            and b.path like concat(#{orgPath},'%')
         </if>
         <choose>
             <when test="req.appSelect==1">
@@ -128,15 +128,15 @@
         ) AS inspectCoverRate
         FROM
         core_safety_task a
-        LEFT JOIN core_safecheck_plan b ON a.plan_id = b.id
-        LEFT JOIN sys_org c ON a.org_id = c.id
+        INNER JOIN core_safecheck_plan b ON a.plan_id = b.id
+        INNER JOIN sys_org c ON a.org_id = c.id
         WHERE
         a.deleted = 0
           <if test="orgId !=null">
               and a.org_id =#{orgId}
           </if>
         <if test="orgPath !=null and orgPath !=''">
-            and a.org_path like concat(#{orgPath},'%')
+            and c.path like concat(#{orgPath},'%')
         </if>
         <if test="dto != null and dto.year !=null and dto.year !=''">
             AND a.ymd_year = #{dto.year}
@@ -183,7 +183,7 @@
               and a.org_id =#{orgId}
           </if>
         <if test="orgPath !=null and orgPath !=''">
-            and a.org_path like concat(#{orgPath},'%')
+            and b.path like concat(#{orgPath},'%')
         </if>
         <if test="dto !=null and dto.year !=null and dto.year !=''">
             AND c.ymd_year = #{dto.year}
@@ -218,8 +218,8 @@
         ) AS inspectRate
         FROM
         core_safety_task a
-        LEFT JOIN sys_org b ON a.org_id = b.id
-        LEFT JOIN core_safecheck_plan c ON a.plan_id = c.id
+        INNER JOIN sys_org b ON a.org_id = b.id
+        INNER JOIN core_safecheck_plan c ON a.plan_id = c.id
         WHERE
         a.deleted = 0 and b.deleted=0
         AND c.check_type =3
@@ -227,7 +227,7 @@
             and a.org_id =#{orgId}
         </if>
         <if test="orgPath !=null and orgPath !=''">
-            and a.org_path like concat(#{orgPath},'%')
+            and b.path like concat(#{orgPath},'%')
         </if>
 
         <choose>
@@ -256,15 +256,15 @@
         COUNT(distinct a.org_id ) AS planInspectOrg
         FROM
         core_safety_task a
-        LEFT JOIN core_safecheck_plan b ON a.plan_id = b.id
-        LEFT JOIN sys_org c ON a.org_id = c.id
+        INNER JOIN core_safecheck_plan b ON a.plan_id = b.id
+        INNER JOIN sys_org c ON a.org_id = c.id
         WHERE
         a.deleted = 0 and c.is_lock=0 and c.deleted = 0
           <if test="orgId !=null">
               and a.org_id =#{orgId}
           </if>
         <if test="orgPath !=null and orgPath !=''">
-            and a.org_path like concat(#{orgPath},'%')
+            and c.path like concat(#{orgPath},'%')
         </if>
         <if test="year !=null and year !=''">
             AND a.ymd_year = #{year}
@@ -281,8 +281,8 @@
         COUNT( DISTINCT a.org_id ) AS planInspectOrg
         FROM
         core_safety_task a
-        LEFT JOIN core_safecheck_plan b ON a.plan_id = b.id
-        LEFT JOIN sys_org c ON a.org_id = c.id
+        INNER JOIN core_safecheck_plan b ON a.plan_id = b.id
+        INNER JOIN sys_org c ON a.org_id = c.id
         WHERE
         a.deleted = 0 and c.is_lock=0 and c.deleted = 0
         AND a.`status` =3
@@ -290,7 +290,7 @@
               and a.org_id=#{orgId}
           </if>
         <if test="orgPath !=null and orgPath !=''">
-            and a.org_path like concat(#{orgPath},'%')
+            and c.path like concat(#{orgPath},'%')
         </if>
         <if test="year !=null and year !=''">
             AND a.ymd_year = #{year}

+ 0 - 1
soc-modules/soc-modules-system/src/main/resources/mapper/system/SysOrgMapper.xml

@@ -1345,7 +1345,6 @@ and
          is_lock=0 AND
             type = #{type}
           AND deleted = 0
-          AND is_lock = 0
           <if test="path != null">
               AND path LIKE concat(#{path}, '%')
           </if>