Pārlūkot izejas kodu

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

jingyuanchao 1 gadu atpakaļ
vecāks
revīzija
77ef2e3a65

+ 11 - 4
project_data/sql/0.0.7.409/soc/soc.sql

@@ -30,10 +30,10 @@ CALL schema_change ();
 DELETE from `sys_dict_type` WHERE  `dict_type`='alarm_deal_type';
 DELETE from `sys_dict_data` WHERE  `dict_type`='alarm_deal_type';
 INSERT INTO `sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('告警处置类型', 'alarm_deal_type', '0', '超级管理员', '2024-04-02 18:02:13', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2, '误报', '5', 'alarm_deal_type', NULL, 'default', 'N', '0', '超级管理员', '2024-04-02 18:03:16', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (3, '正常报警', '2', 'alarm_deal_type', NULL, 'default', 'N', '0', '超级管理员', '2024-04-02 18:03:35', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (4, '报修', '3', 'alarm_deal_type', NULL, 'default', 'N', '0', '超级管理员', '2024-04-02 18:03:46', '', NULL, NULL);
-INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (5, '测试', '4', 'alarm_deal_type', NULL, 'default', 'N', '0', '超级管理员', '2024-04-02 18:03:56', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (5, '误报', '2', 'alarm_deal_type', NULL, 'default', 'N', '0', '超级管理员', '2024-04-02 18:03:16', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2, '正常报警', '3', 'alarm_deal_type', NULL, 'default', 'N', '0', '超级管理员', '2024-04-02 18:03:35', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (3, '报修', '4', 'alarm_deal_type', NULL, 'default', 'N', '0', '超级管理员', '2024-04-02 18:03:46', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (4, '测试', '5', 'alarm_deal_type', NULL, 'default', 'N', '0', '超级管理员', '2024-04-02 18:03:56', '', NULL, NULL);
 
 delete from `iot_alarm_system_field` WHERE  `source_type`='41881';
 INSERT INTO `iot_alarm_system_field` (`source_type`, `source_type_des`, `sys_field_code`, `name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (41881, '盗情', '41881', '被盗告警', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, '2022-07-26 16:14:26', NULL, '2022-07-26 16:14:30', NULL);
@@ -44,3 +44,10 @@ INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`
 
 delete from `sys_dict_data` WHERE  `dict_value`='41881' AND `dict_type`='app_sensor_device_type';
 INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 6, '被盗', '41881', 'app_sensor_device_type', NULL, 'default', 'N', '0', '超级管理员', '2024-03-04 16:23:49', '', NULL, NULL);
+
+delete from `sys_dict_type` WHERE  `dict_type`='alarm_deal_status';
+INSERT INTO `sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('告警处置状态', 'alarm_deal_status', '0', '超级管理员', '2024-04-08 09:38:40', '', NULL, NULL);
+
+delete from `sys_dict_data` WHERE  `dict_type`='alarm_deal_status';
+INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 0, '未处置', '0', 'alarm_deal_status', NULL, 'default', 'N', '0', '超级管理员', '2024-04-08 09:39:03', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 1, '已处置', '1', 'alarm_deal_status', NULL, 'default', 'N', '0', '超级管理员', '2024-04-08 09:39:12', '', NULL, NULL);

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

@@ -1085,9 +1085,14 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
             if (sysConfig == null || ObjectUtil.isEmpty(sysConfig.getConfigValue())) {
                 return true;
             }
+
+            DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.QUARTERLY);
+
             final Long count = coreDrillTaskMapper.selectCount(new LambdaQueryWrapper<CoreDrillTask>()
                     .in(CoreDrillTask::getRecStatus, Arrays.asList(DrillRecStatus.HS_EXCELLENT_CASE.getCode(), DrillRecStatus.REC_REGION_EXCELLENT_CASE.getCode()))
-                    .likeRight(CoreDrillTask::getOrgPath, sysOrg.getPath()));
+                    .likeRight(CoreDrillTask::getOrgPath, sysOrg.getPath())
+                    .ge(CoreDrillTask::getStartDate,range.getStartTime())
+                    .le(CoreDrillTask::getEndDate,range.getEndTime()));
             //如果 小于设置推荐上限则返回true,反之false
             return count < Integer.parseInt(sysConfig.getConfigValue());
         }
@@ -1099,9 +1104,12 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
             if (sysConfig == null || ObjectUtil.isEmpty(sysConfig.getConfigValue())) {
                 return true;
             }
+            DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.QUARTERLY);
             final int count = coreDrillTaskMapper.selectCount(new LambdaQueryWrapper<CoreDrillTask>()
                     .in(CoreDrillTask::getRecStatus, Arrays.asList(DrillRecStatus.REGION_EXCELLENT_CASE.getCode(), DrillRecStatus.REC_PROVINCE_EXCELLENT_CASE.getCode()))
-                    .likeRight(CoreDrillTask::getOrgPath, sysOrg.getPath())).intValue();
+                    .likeRight(CoreDrillTask::getOrgPath, sysOrg.getPath())
+                    .ge(CoreDrillTask::getStartDate,range.getStartTime())
+                    .le(CoreDrillTask::getEndDate,range.getEndTime())).intValue();
             //如果 小于设置推荐上限则返回true,反之false
             return count < Integer.parseInt(sysConfig.getConfigValue());
         }
@@ -1128,9 +1136,12 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
             SysOrg sysOrg = sysOrgList.stream().filter(org -> ObjectUtil.equal(org.getType(), OrgTypeEnum.HANG_SHE.getCode()))
                     .findFirst().orElseThrow(() -> new SystemException(ErrorMsgConstants.QUERY_ORG_DATA_ERROR));
 
+            DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.QUARTERLY);
             List<CoreDrillTask> coreDrillTasks = coreDrillTaskMapper.selectList(new LambdaQueryWrapper<CoreDrillTask>()
                     .eq(CoreDrillTask::getRecStatus, DrillRecStatus.REC_REGION_EXCELLENT_CASE.getCode())
-                    .likeRight(CoreDrillTask::getOrgPath, sysOrg.getPath()).select(CoreDrillTask::getId, CoreDrillTask::getOrgId));
+                    .likeRight(CoreDrillTask::getOrgPath, sysOrg.getPath())
+                    .ge(CoreDrillTask::getStartDate,range.getStartTime())
+                    .le(CoreDrillTask::getEndDate,range.getEndTime()).select(CoreDrillTask::getId, CoreDrillTask::getOrgId));
             List<Long> list = coreDrillTasks.stream().map(CoreDrillTask::getId).collect(Collectors.toList());
             //判断重复推优评优
             if ((!list.contains(drillTask.getId())) && coreDrillTasks.size() >= Integer.parseInt(sysConfig.getConfigValue())) {
@@ -1146,9 +1157,12 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
             SysOrg sysOrg = sysOrgList.stream().filter(org -> ObjectUtil.equal(org.getType(), OrgTypeEnum.BAN_SHI_CHU.getCode()))
                     .findFirst().orElseThrow(() -> new SystemException(ErrorMsgConstants.QUERY_ORG_DATA_ERROR));
 
+            DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.QUARTERLY);
             List<CoreDrillTask> coreDrillTasks = coreDrillTaskMapper.selectList(new LambdaQueryWrapper<CoreDrillTask>()
                     .eq(CoreDrillTask::getRecStatus, DrillRecStatus.REC_PROVINCE_EXCELLENT_CASE.getCode())
-                    .likeRight(CoreDrillTask::getOrgPath, sysOrg.getPath()).select(CoreDrillTask::getId, CoreDrillTask::getOrgId));
+                    .likeRight(CoreDrillTask::getOrgPath, sysOrg.getPath())
+                    .ge(CoreDrillTask::getStartDate,range.getStartTime())
+                    .le(CoreDrillTask::getEndDate,range.getEndTime()).select(CoreDrillTask::getId, CoreDrillTask::getOrgId));
             List<Long> list = coreDrillTasks.stream().map(CoreDrillTask::getId).collect(Collectors.toList());
             //判断重复推优评优
             if ((!list.contains(drillTask.getId())) && coreDrillTasks.size() >= Integer.parseInt(sysConfig.getConfigValue())) {

+ 4 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/reportForms/resumption/controller/ResumptionReportController.java

@@ -28,6 +28,8 @@ import java.time.LocalDate;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
 
 /**
  * @author :LuoWei
@@ -47,7 +49,7 @@ public class ResumptionReportController {
     @RequiresPermissions("core:resumptionReport:export")
     @Log(title = "履职报表导出", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(ResumptionDTO request, HttpServletResponse response) throws IOException {
+    public void export(ResumptionDTO request, HttpServletResponse response) throws IOException, ExecutionException, InterruptedException, TimeoutException {
         if (null == request.getSearchTime()) {
             LocalDate currentDate = LocalDate.now();
             if (null == request.getCycle() || request.getCycle() == 1) {
@@ -62,7 +64,7 @@ public class ResumptionReportController {
     @ApiOperation(value = "每日安全保卫履职-日报表")
     @RequiresPermissions("core:resumptionReport:list")
     @GetMapping("/list")
-    public AjaxResult list(ResumptionDTO resumptionDTO) {
+    public AjaxResult list(ResumptionDTO resumptionDTO) throws ExecutionException, InterruptedException, TimeoutException {
         if (null == resumptionDTO.getSearchTime()) {
             LocalDate currentDate = LocalDate.now();
             if (null == resumptionDTO.getCycle() || resumptionDTO.getCycle() == 1) {

+ 4 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/reportForms/resumption/service/ResumptionReportService.java

@@ -8,15 +8,17 @@ import com.xunmei.core.reportForms.resumption.vo.ResumptionDayVO;
 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/11/8
  */
 public interface ResumptionReportService {
-    List<ResumptionDayVO> report(ResumptionDTO resumptionDTO);
+    List<ResumptionDayVO> report(ResumptionDTO resumptionDTO) throws ExecutionException, InterruptedException, TimeoutException;
 
-    void export(ResumptionDTO resumptionDTO, HttpServletResponse response) throws IOException;
+    void export(ResumptionDTO resumptionDTO, HttpServletResponse response) throws IOException, ExecutionException, InterruptedException, TimeoutException;
 
     void intrusionTestExport(ResumptionDTO resumptionDTO, HttpServletResponse response)throws IOException;
 

+ 171 - 65
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/reportForms/resumption/service/impl/ResumptionReportServiceImpl.java

@@ -3,6 +3,10 @@ package com.xunmei.core.reportForms.resumption.service.impl;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.excel.EasyExcel;
 import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingPlan;
+import com.xunmei.common.core.domain.panel.vo.PanelListVo;
+import com.xunmei.common.core.enums.edu.EduTrainingPlanStatus;
+import com.xunmei.common.core.thread.ThreadPoolConfig;
 import com.xunmei.common.core.utils.DateHelper;
 import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.core.edu.service.impl.ValueCellWriteHandler;
@@ -17,6 +21,8 @@ import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
 import org.springframework.beans.BeanUtils;
 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.servlet.http.HttpServletResponse;
@@ -24,6 +30,14 @@ import java.io.IOException;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.bouncycastle.asn1.x500.style.RFC4519Style.o;
 
 /**
  * @author :LuoWei
@@ -38,8 +52,12 @@ public class ResumptionReportServiceImpl implements ResumptionReportService {
     @Autowired
     private ResumptionReportMapper resumptionReportMapper;
 
+    @Autowired
+    @Qualifier(ThreadPoolConfig.SOC_EXECUTOR)
+    private ThreadPoolTaskExecutor threadPoolTaskExecutor;
+
     @Override
-    public List<ResumptionDayVO> report(ResumptionDTO resumptionDTO) {
+    public List<ResumptionDayVO> report(ResumptionDTO resumptionDTO) throws ExecutionException, InterruptedException, TimeoutException {
         if (null == resumptionDTO.getOrgId()) {
             resumptionDTO.setOrgId(SecurityUtils.getLoginUser().getOrgId());
         }
@@ -57,78 +75,166 @@ public class ResumptionReportServiceImpl implements ResumptionReportService {
             return Collections.emptyList();
         }
         List<ResumptionDayVO> resumptionDayVOS = new ArrayList<>();
+//        sysOrgs.forEach(o -> {
+//            ResumptionDayVO resumptionDayVO = new ResumptionDayVO();
+////            SysOrg sysOrg1;
+////            if (sysOrg.getType() < 3 || sysOrg.getShortName().endsWith("地区行社") || sysOrg.getType() == 9) {
+////                sysOrg1 = orgService.selectOrgById(o.getParentId(), SecurityConstants.INNER);
+////            } else {
+////                sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(o.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
+////                if (-1 == sysOrg1.getShortName().indexOf("地区行社")) {
+////                    sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(orgService.selectOrgById(o.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
+////                }
+////            }
+//            resumptionDayVO.setCity(o.getAffiliatedArea());
+//            resumptionDayVO.setOrgName(o.getShortName());
+//            Integer integer = monitorAccessReportMapper.selectNetworkNumberByPath(o.getPath());
+//            ResumptionDayVO resumptionDayVO1 =null;
+//            ResumptionDayVO resumptionDayVO2 =null;
+//            ResumptionDayVO resumptionDayVO3 =null;
+//
+//            if(o.getType()!=4) {
+//                //营业前
+//                resumptionDayVO1 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 1, null, resumptionDTO.getSearchTime(), o.getPath());
+//                //营业中
+//                resumptionDayVO2 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 2, null, resumptionDTO.getSearchTime(), o.getPath());
+//                //后
+//                resumptionDayVO3 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 3, null, resumptionDTO.getSearchTime(), o.getPath());
+//            }
+//            if (o.getType() == 4) {
+//                integer = 1;
+//                resumptionDayVO1 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 1, o.getId(), resumptionDTO.getSearchTime(), null);
+//                resumptionDayVO2 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 2, o.getId(), resumptionDTO.getSearchTime(), null);
+//                resumptionDayVO3 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 3, o.getId(), resumptionDTO.getSearchTime(), null);
+//            }
+//
+//            resumptionDayVO.setNetworkNumber(integer);
+//
+//            resumptionDayVO.setFrontRate(resumptionDayVO1.getFrontRate());
+//            resumptionDayVO.setFrontAbnormalNumber(resumptionDayVO1.getFrontAbnormalNumber());
+//            resumptionDayVO.setFrontPlanNumber(resumptionDayVO1.getFrontPlanNumber());
+//            resumptionDayVO.setFrontRealityNumber(resumptionDayVO1.getFrontRealityNumber());
+//
+//            resumptionDayVO.setCentreRate(resumptionDayVO2.getFrontRate());
+//            resumptionDayVO.setCentreAbnormalNumber(resumptionDayVO2.getFrontAbnormalNumber());
+//            resumptionDayVO.setCentrePlanNumber(resumptionDayVO2.getFrontPlanNumber());
+//            resumptionDayVO.setCentreRealityNumber(resumptionDayVO2.getFrontRealityNumber());
+//
+//            resumptionDayVO.setAfterRate(resumptionDayVO3.getFrontRate());
+//            resumptionDayVO.setAfterAbnormalNumber(resumptionDayVO3.getFrontAbnormalNumber());
+//            resumptionDayVO.setAfterPlanNumber(resumptionDayVO3.getFrontPlanNumber());
+//            resumptionDayVO.setAfterRealityNumber(resumptionDayVO3.getFrontRealityNumber());
+//            Integer totalPlan = resumptionDayVO3.getFrontPlanNumber() + resumptionDayVO2.getFrontPlanNumber() + resumptionDayVO1.getFrontPlanNumber();
+//            //总计实际履职次数
+//            Integer totalReality = resumptionDayVO3.getFrontRealityNumber() + resumptionDayVO2.getFrontRealityNumber() + resumptionDayVO1.getFrontRealityNumber();
+//            //总计隐患问题数
+//            Integer totalAbnormal = resumptionDayVO3.getFrontAbnormalNumber() + resumptionDayVO2.getFrontAbnormalNumber() + resumptionDayVO1.getFrontAbnormalNumber();
+//            //总计已整改数量
+//            Integer totalRealityRectificationNumber = resumptionDayVO3.getTotalRealityRectificationNumber() + resumptionDayVO2.getTotalRealityRectificationNumber() + resumptionDayVO1.getTotalRealityRectificationNumber();
+//            //总计应履职次数
+//            resumptionDayVO.setTotalPlanNumber(totalPlan);
+//            resumptionDayVO.setTotalRealityNumber(totalReality);
+//            Double i = 0d;
+//            if (totalReality != 0 && totalPlan != 0) {
+//                i = (double) totalReality / totalPlan * 100;
+//            }
+//            resumptionDayVO.setTotalRate(String.format("%.2f", i) + "%");
+//            resumptionDayVO.setTotalAbnormalNumber(totalAbnormal);
+//            Double n = 0d;
+//            if (totalAbnormal != 0 && totalRealityRectificationNumber != 0) {
+//                n = (double) totalRealityRectificationNumber / totalAbnormal * 100;
+//            }
+//            resumptionDayVO.setTotalRealityRectificationRate(String.format("%.2f", n) + "%");
+//            resumptionDayVO.setTotalRealityRectificationNumber(totalRealityRectificationNumber);
+//            resumptionDayVOS.add(resumptionDayVO);
+//        });
+
+        List<CompletableFuture<ResumptionDayVO>> completableFutureList=new ArrayList<>();
         sysOrgs.forEach(o -> {
-            ResumptionDayVO resumptionDayVO = new ResumptionDayVO();
-            SysOrg sysOrg1;
-            if (sysOrg.getType() < 3 || sysOrg.getShortName().endsWith("地区行社") || sysOrg.getType() == 9) {
-                sysOrg1 = orgService.selectOrgById(o.getParentId(), SecurityConstants.INNER);
-            } else {
-                sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(o.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
-                if (-1 == sysOrg1.getShortName().indexOf("地区行社")) {
-                    sysOrg1 = orgService.selectOrgById(orgService.selectOrgById(orgService.selectOrgById(o.getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER).getParentId(), SecurityConstants.INNER);
-                }
-            }
-            resumptionDayVO.setCity(sysOrg1.getShortName().indexOf("地区行社") == -1 ? sysOrg1.getShortName().substring(0, 2) : sysOrg1.getShortName().split("地区行社")[0]);
-            resumptionDayVO.setOrgName(o.getShortName());
-            Integer integer = monitorAccessReportMapper.selectNetworkNumberByPath(o.getPath());
+            CompletableFuture<ResumptionDayVO> getOneOrgResumptionDayVO = CompletableFuture.supplyAsync(() ->
+                    getOneOrgResumptionDayVO(o,resumptionDTO),threadPoolTaskExecutor
+            );
+            completableFutureList.add(getOneOrgResumptionDayVO);
+        });
+
+        CompletableFuture<Void> allQueries = CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0]));
+
+        allQueries.get(10L, TimeUnit.SECONDS);
+
+        completableFutureList.forEach(x->{
+            resumptionDayVOS.add(x.join());
+        });
+        return resumptionDayVOS;
+    }
+
+    private ResumptionDayVO getOneOrgResumptionDayVO(SysOrg org,ResumptionDTO resumptionDTO)
+    {
+        ResumptionDayVO resumptionDayVO = new ResumptionDayVO();
+        resumptionDayVO.setCity(org.getAffiliatedArea());
+        resumptionDayVO.setOrgName(org.getShortName());
+        Integer integer = monitorAccessReportMapper.selectNetworkNumberByPath(org.getPath());
+        ResumptionDayVO resumptionDayVO1 =null;
+        ResumptionDayVO resumptionDayVO2 =null;
+        ResumptionDayVO resumptionDayVO3 =null;
+
+        if(org.getType()!=4) {
             //营业前
-            ResumptionDayVO resumptionDayVO1 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 1, null, resumptionDTO.getSearchTime(), o.getPath());
+            resumptionDayVO1 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 1, null, resumptionDTO.getSearchTime(), org.getPath());
             //营业中
-            ResumptionDayVO resumptionDayVO2 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 2, null, resumptionDTO.getSearchTime(), o.getPath());
+            resumptionDayVO2 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 2, null, resumptionDTO.getSearchTime(), org.getPath());
             //后
-            ResumptionDayVO resumptionDayVO3 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 3, null, resumptionDTO.getSearchTime(), o.getPath());
-            if (o.getType() == 4) {
-                integer = 1;
-                resumptionDayVO1 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 1, o.getId(), resumptionDTO.getSearchTime(), o.getPath());
-                resumptionDayVO2 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 2, o.getId(), resumptionDTO.getSearchTime(), o.getPath());
-                resumptionDayVO3 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 3, o.getId(), resumptionDTO.getSearchTime(), o.getPath());
-            }
+            resumptionDayVO3 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 3, null, resumptionDTO.getSearchTime(), org.getPath());
+        }
+        if (org.getType() == 4) {
+            integer = 1;
+            resumptionDayVO1 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 1, org.getId(), resumptionDTO.getSearchTime(), null);
+            resumptionDayVO2 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 2, org.getId(), resumptionDTO.getSearchTime(), null);
+            resumptionDayVO3 = resumptionReportMapper.selectReport(resumptionDTO.getCycle(), 3, org.getId(), resumptionDTO.getSearchTime(), null);
+        }
 
-            resumptionDayVO.setNetworkNumber(integer);
-
-            resumptionDayVO.setFrontRate(resumptionDayVO1.getFrontRate());
-            resumptionDayVO.setFrontAbnormalNumber(resumptionDayVO1.getFrontAbnormalNumber());
-            resumptionDayVO.setFrontPlanNumber(resumptionDayVO1.getFrontPlanNumber());
-            resumptionDayVO.setFrontRealityNumber(resumptionDayVO1.getFrontRealityNumber());
-
-            resumptionDayVO.setCentreRate(resumptionDayVO2.getFrontRate());
-            resumptionDayVO.setCentreAbnormalNumber(resumptionDayVO2.getFrontAbnormalNumber());
-            resumptionDayVO.setCentrePlanNumber(resumptionDayVO2.getFrontPlanNumber());
-            resumptionDayVO.setCentreRealityNumber(resumptionDayVO2.getFrontRealityNumber());
-
-            resumptionDayVO.setAfterRate(resumptionDayVO3.getFrontRate());
-            resumptionDayVO.setAfterAbnormalNumber(resumptionDayVO3.getFrontAbnormalNumber());
-            resumptionDayVO.setAfterPlanNumber(resumptionDayVO3.getFrontPlanNumber());
-            resumptionDayVO.setAfterRealityNumber(resumptionDayVO3.getFrontRealityNumber());
-            Integer totalPlan = resumptionDayVO3.getFrontPlanNumber() + resumptionDayVO2.getFrontPlanNumber() + resumptionDayVO1.getFrontPlanNumber();
-            //总计实际履职次数
-            Integer totalReality = resumptionDayVO3.getFrontRealityNumber() + resumptionDayVO2.getFrontRealityNumber() + resumptionDayVO1.getFrontRealityNumber();
-            //总计隐患问题数
-            Integer totalAbnormal = resumptionDayVO3.getFrontAbnormalNumber() + resumptionDayVO2.getFrontAbnormalNumber() + resumptionDayVO1.getFrontAbnormalNumber();
-            //总计已整改数量
-            Integer totalRealityRectificationNumber = resumptionDayVO3.getTotalRealityRectificationNumber() + resumptionDayVO2.getTotalRealityRectificationNumber() + resumptionDayVO1.getTotalRealityRectificationNumber();
-            //总计应履职次数
-            resumptionDayVO.setTotalPlanNumber(totalPlan);
-            resumptionDayVO.setTotalRealityNumber(totalReality);
-            Double i = 0d;
-            if (totalReality != 0 && totalPlan != 0) {
-                i = (double) totalReality / totalPlan * 100;
-            }
-            resumptionDayVO.setTotalRate(String.format("%.2f", i) + "%");
-            resumptionDayVO.setTotalAbnormalNumber(totalAbnormal);
-            Double n = 0d;
-            if (totalAbnormal != 0 && totalRealityRectificationNumber != 0) {
-                n = (double) totalRealityRectificationNumber / totalAbnormal * 100;
-            }
-            resumptionDayVO.setTotalRealityRectificationRate(String.format("%.2f", n) + "%");
-            resumptionDayVO.setTotalRealityRectificationNumber(totalRealityRectificationNumber);
-            resumptionDayVOS.add(resumptionDayVO);
-        });
-        return resumptionDayVOS;
+        resumptionDayVO.setNetworkNumber(integer);
+
+        resumptionDayVO.setFrontRate(resumptionDayVO1.getFrontRate());
+        resumptionDayVO.setFrontAbnormalNumber(resumptionDayVO1.getFrontAbnormalNumber());
+        resumptionDayVO.setFrontPlanNumber(resumptionDayVO1.getFrontPlanNumber());
+        resumptionDayVO.setFrontRealityNumber(resumptionDayVO1.getFrontRealityNumber());
+
+        resumptionDayVO.setCentreRate(resumptionDayVO2.getFrontRate());
+        resumptionDayVO.setCentreAbnormalNumber(resumptionDayVO2.getFrontAbnormalNumber());
+        resumptionDayVO.setCentrePlanNumber(resumptionDayVO2.getFrontPlanNumber());
+        resumptionDayVO.setCentreRealityNumber(resumptionDayVO2.getFrontRealityNumber());
+
+        resumptionDayVO.setAfterRate(resumptionDayVO3.getFrontRate());
+        resumptionDayVO.setAfterAbnormalNumber(resumptionDayVO3.getFrontAbnormalNumber());
+        resumptionDayVO.setAfterPlanNumber(resumptionDayVO3.getFrontPlanNumber());
+        resumptionDayVO.setAfterRealityNumber(resumptionDayVO3.getFrontRealityNumber());
+        Integer totalPlan = resumptionDayVO3.getFrontPlanNumber() + resumptionDayVO2.getFrontPlanNumber() + resumptionDayVO1.getFrontPlanNumber();
+        //总计实际履职次数
+        Integer totalReality = resumptionDayVO3.getFrontRealityNumber() + resumptionDayVO2.getFrontRealityNumber() + resumptionDayVO1.getFrontRealityNumber();
+        //总计隐患问题数
+        Integer totalAbnormal = resumptionDayVO3.getFrontAbnormalNumber() + resumptionDayVO2.getFrontAbnormalNumber() + resumptionDayVO1.getFrontAbnormalNumber();
+        //总计已整改数量
+        Integer totalRealityRectificationNumber = resumptionDayVO3.getTotalRealityRectificationNumber() + resumptionDayVO2.getTotalRealityRectificationNumber() + resumptionDayVO1.getTotalRealityRectificationNumber();
+        //总计应履职次数
+        resumptionDayVO.setTotalPlanNumber(totalPlan);
+        resumptionDayVO.setTotalRealityNumber(totalReality);
+        Double i = 0d;
+        if (totalReality != 0 && totalPlan != 0) {
+            i = (double) totalReality / totalPlan * 100;
+        }
+        resumptionDayVO.setTotalRate(String.format("%.2f", i) + "%");
+        resumptionDayVO.setTotalAbnormalNumber(totalAbnormal);
+        Double n = 0d;
+        if (totalAbnormal != 0 && totalRealityRectificationNumber != 0) {
+            n = (double) totalRealityRectificationNumber / totalAbnormal * 100;
+        }
+        resumptionDayVO.setTotalRealityRectificationRate(String.format("%.2f", n) + "%");
+        resumptionDayVO.setTotalRealityRectificationNumber(totalRealityRectificationNumber);
+        return resumptionDayVO;
     }
 
     @Override
-    public void export(ResumptionDTO resumptionDTO, HttpServletResponse response) throws IOException {
+    public void export(ResumptionDTO resumptionDTO, HttpServletResponse response) throws IOException, ExecutionException, InterruptedException, TimeoutException {
         String orgName = null;
         if (null != resumptionDTO.getOrgId()) {
             SysOrg sysOrg = orgService.selectSysOrgById(resumptionDTO.getOrgId(), SecurityConstants.INNER);

+ 1 - 0
soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmDataMapper.xml

@@ -50,6 +50,7 @@
         <if test="param.isDo == 0">
             and a.is_do is null
         </if>
+        order by a.end_time ,a.time desc
     </select>
     <select id="selectAppPageList" resultType="com.xunmei.iot.vo.alarmData.AppAlarmDataPageVo">
         SELECT

+ 22 - 7
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/IotAlarmDataServiceImpl.java

@@ -152,14 +152,22 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
                 iotSensor.setStateStartTime(LocalDateTime.now());
                 iotSensorMapper.updateById(iotSensor);
             }
-
         }
         if (isExpress && !isAlarm) {
             //报警恢复
             if( alarms.size() != 0){
-                IotAlarmData iotAlarmData = alarms.get(0);
-                iotAlarmData.setEndTime(LocalDateTime.now());
-                this.updateById(iotAlarmData);
+                if(alarms.size()>1)
+                {
+                    for (IotAlarmData oldAlarm : alarms) {
+                        oldAlarm.setEndTime(LocalDateTime.now());
+                        this.updateById(oldAlarm);
+                    }
+                }
+                else {
+                    IotAlarmData iotAlarmData = alarms.get(0);
+                    iotAlarmData.setEndTime(LocalDateTime.now());
+                    this.updateById(iotAlarmData);
+                }
             }
 
             if (ObjectUtil.notEqual(iotSensor.getState(),0)) {
@@ -330,7 +338,8 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         //此处认为大于,大于等于,小于,小于等于 规则中传感器上报值与规则中的设定值皆为数字,
         //所以在判断此类规则的时候将值转为了BigDecimal进行判断; parseInt会在有小数的时候报错
         if (AlarmRuleExpressOperateEnum.EQUALS.getText().equals(operator)) {
-            if (sensorValue.equals(settingValue)) {
+            // sensorValue 存在为null的情况, deviceType和 infos.name 不对应的情况
+            if (ObjectUtil.equal(sensorValue,settingValue)) {
                 //对上了
                 iotAlarmData = builderAlarm(sensorValue, field, express, iotSensor);
             }
@@ -379,7 +388,13 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         IotAlarmData iotAlarmData = new IotAlarmData();
         iotAlarmData.setAlarmValue("异常");
         iotAlarmData.setTime(LocalDateTime.now());
-        iotAlarmData.setDeviceName(deviceName + "-" + channelName);
+        if(ObjectUtil.equal(deviceName,channelName)){
+            iotAlarmData.setDeviceName(channelName);
+        }
+        else
+        {
+            iotAlarmData.setDeviceName(deviceName + "-" + channelName);
+        }
         iotAlarmData.setRuleId(1L);
         iotAlarmData.setSourceType(diagnosisType);
         iotAlarmData.setSourceTypeDes(AlarmVideoTypeEnum.getTextByValue(diagnosisType) + "告警");
@@ -396,7 +411,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
 
     private IotAlarmData builderAlarm(String sensorValue, IotAlarmSystemField field, IotAlarmRuleExpress express, IotSensor iotSensor) {
         IotAlarmData iotAlarmData = new IotAlarmData();
-        iotAlarmData.setAlarmValue(sensorValue + field.getUnit() == null ? "" : field.getUnit());
+        iotAlarmData.setAlarmValue(sensorValue + (field.getUnit() == null ? "" : field.getUnit()));
         iotAlarmData.setTime(LocalDateTime.now());
         iotAlarmData.setDeviceName(iotSensor.getDeviceName());
         iotAlarmData.setRuleId(express.getRuleId());