Browse Source

feature 隐患排查任务相关代码提交

xiahan 10 months ago
parent
commit
34c4b2d298

+ 15 - 0
js-security/security-common/src/main/java/com/rongwei/sfcommon/sys/dao/AspMajorHazardSourcesDao.java

@@ -0,0 +1,15 @@
+package com.rongwei.sfcommon.sys.dao;
+
+import com.rongwe.scentity.domian.AspMajorHazardSourcesDo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @Entity generator.domain.AspMajorHazardSources
+ */
+public interface AspMajorHazardSourcesDao extends BaseMapper<AspMajorHazardSourcesDo> {
+
+}
+
+
+
+

+ 11 - 0
js-security/security-common/src/main/java/com/rongwei/sfcommon/sys/service/AspMajorHazardSourcesService.java

@@ -0,0 +1,11 @@
+package com.rongwei.sfcommon.sys.service;
+
+import com.rongwe.scentity.domian.AspMajorHazardSourcesDo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *
+ */
+public interface AspMajorHazardSourcesService extends IService<AspMajorHazardSourcesDo> {
+
+}

+ 1 - 1
js-security/security-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/ApsDetailsHazardInvestigationTasksServiceImpl.java

@@ -88,7 +88,7 @@ implements ApsDetailsHazardInvestigationTasksService {
             HiddenDangerTrackDo hiddenDangerTrack = new HiddenDangerTrackDo();
             hiddenDangerTrack.setId(SecurityUtil.getUUID());
             //风险分析对象编码
-            hiddenDangerTrack.setRiskanalysisobjectcode(info.getRiskunitcode());
+            hiddenDangerTrack.setRiskanalysisobjectcode(apsDetailsHazardInvestigationTasksDo.getRiskanalysisobjectcode());
             //隐患等级hazardlevel
             hiddenDangerTrack.setHazardlevel(info.getGrade());
             //隐患来源

+ 21 - 0
js-security/security-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/AspMajorHazardSourcesServiceImpl.java

@@ -0,0 +1,21 @@
+package com.rongwei.sfcommon.sys.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwe.scentity.domian.AspMajorHazardSourcesDo;
+import com.rongwei.sfcommon.sys.dao.AspMajorHazardSourcesDao;
+
+import com.rongwei.sfcommon.sys.service.AspMajorHazardSourcesService;
+import org.springframework.stereotype.Service;
+
+/**
+ *
+ */
+@Service
+public class AspMajorHazardSourcesServiceImpl extends ServiceImpl<AspMajorHazardSourcesDao, AspMajorHazardSourcesDo>
+implements AspMajorHazardSourcesService {
+
+}
+
+
+
+

+ 63 - 17
js-security/security-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/HazardInvestigationServiceImpl.java

@@ -17,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * HazardInvestigationServiceImpl class
@@ -40,6 +42,23 @@ public class HazardInvestigationServiceImpl implements HazardInvestigationServic
     private ApsDetailsHazardInvestigationTasksServiceImpl apsDetailsHazardInvestigationTasksServiceImpl;
     @Autowired
     private ApsDetailsHazardInvestigationTasksJcxzibiaoServiceImpl apsDetailsHazardInvestigationTasksJcxzibiaoService;
+    @Autowired
+    private AspMajorHazardSourcesServiceImpl aspMajorHazardSourcesService;
+
+    public static final Map<String, List<Function<AspMajorHazardSourcesDo, String>>>getCheckUserInfoFunctionMap=new HashMap<String, List<Function<AspMajorHazardSourcesDo, String>>>(){{
+        put("1",new ArrayList<Function<AspMajorHazardSourcesDo, String>>(){{
+            add(AspMajorHazardSourcesDo::getMainresponsible);
+            add(AspMajorHazardSourcesDo::getMainresponsibleid);
+        }});
+        put("2",new ArrayList<Function<AspMajorHazardSourcesDo, String>>(){{
+            add(AspMajorHazardSourcesDo::getTechnicalresponsible);
+            add(AspMajorHazardSourcesDo::getTechnicalresponsibleid);
+        }});
+        put("3",new ArrayList<Function<AspMajorHazardSourcesDo, String>>(){{
+            add(AspMajorHazardSourcesDo::getOperationresponsible);
+            add(AspMajorHazardSourcesDo::getOperationresponsibleid);
+        }});
+    }};
 
     @Override
     public R createTask(String id) {
@@ -58,7 +77,7 @@ public class HazardInvestigationServiceImpl implements HazardInvestigationServic
             return R.ok("模板检查项为空");
         }
         // 生成隐患排查任务
-        assembleTask(tempData);
+        assembleTask(tempData, templateZibiaoDos);
 
         return R.ok();
     }
@@ -68,30 +87,31 @@ public class HazardInvestigationServiceImpl implements HazardInvestigationServic
      *
      * @param tempData
      */
-    public void assembleTask(ApsHazardInvestigationTemplateDo tempData) {
+    public void assembleTask(ApsHazardInvestigationTemplateDo tempData,
+                             List<ApsHazardInvestigationTemplateZibiaoDo> templateZibiaoDos) {
 
         SysUserVo currentUser = JSCommonUtils.getCurrentUser();
 
         if (StringUtils.isBlank(tempData.getHiddendangerid())) {
-            log.error("风险为空");
-            throw new RuntimeException("模板对应需检查的风险为空");
+            log.error("风险分析单元为空");
+            throw new RuntimeException("模板对应需检查的风险分析单元为空");
         }
 
-        // 获取模板对应的检查项
-        List<ApsHazardInvestigationTemplateZibiaoDo> checkItemList = apsHazardInvestigationTemplateZibiaoService.list(new LambdaQueryWrapper<ApsHazardInvestigationTemplateZibiaoDo>()
-                .eq(BaseDo::getDeleted, "0")
-                .eq(ApsHazardInvestigationTemplateZibiaoDo::getMubanid, tempData.getId()));
-        if (checkItemList.isEmpty()) {
+        if (templateZibiaoDos.isEmpty()) {
             log.error("当前模板:{}不存在检查项", tempData.getTemplatename());
             throw new CustomException("当前模板不存在检查项");
         }
-        // 风险
+        // 风险分析单元
         List<String> riskPointIds = Arrays.asList(tempData.getHiddendangerid().split(","));
         List<AspRiskUnitDo> aspRiskUnitDos = (List<AspRiskUnitDo>) aspRiskUnitService.listByIds(riskPointIds);
         if (aspRiskUnitDos.isEmpty()) {
             log.error("无法根据id:{}找到对应的风险点", riskPointIds);
             throw new CustomException("无法获取对应的风险点");
         }
+        // 重大危险源ID
+        List<String> collect = aspRiskUnitDos.stream().map(AspRiskUnitDo::getMajorhazardid).collect(Collectors.toList());
+        List<AspMajorHazardSourcesDo> aspMajorHazardSourcesDos = aspMajorHazardSourcesService.getBaseMapper().selectBatchIds(collect);
+
         List<ApsDetailsHazardInvestigationTasksDo> taskSaveList = new ArrayList<>();
         List<ApsDetailsHazardInvestigationTasksJcxzibiaoDo> taskDetailSaveList = new ArrayList<>();
         // 按照风险点 分开生成隐患排查任务
@@ -115,18 +135,22 @@ public class HazardInvestigationServiceImpl implements HazardInvestigationServic
             apsDetailsHazardInvestigationTasksDo.setId(SecurityUtil.getUUID());
             apsDetailsHazardInvestigationTasksDo.setRiskunit(tempData.getHiddendangerid());
             apsDetailsHazardInvestigationTasksDo.setRiskanalysisobjectcode(tempData.getHiddendanger());
+            apsDetailsHazardInvestigationTasksDo.setTempcode(tempData.getTemplatenumber());
+            apsDetailsHazardInvestigationTasksDo.setTempname(tempData.getTemplatename());
             apsDetailsHazardInvestigationTasksDo.setNumber(
                     JSCommonUtils.streamCodeGeneration("aps_details_hazard_investigation_tasks_NUMBER",
                             "YH@{date:yyyyMMdd}@{serialNumber:#000000}", "date:yyyyMM",
                             ""));
-            apsDetailsHazardInvestigationTasksDo.setIdentifyperple(s.getDutyofficername());
-            apsDetailsHazardInvestigationTasksDo.setIdentifyperpleid(s.getDutyofficerid());
-
+            String checkUserInfo = getCheckUserInfo(s, aspMajorHazardSourcesDos, tempData);
+            apsDetailsHazardInvestigationTasksDo.setIdentifyperple(checkUserInfo.split("-;-")[0]);
+            apsDetailsHazardInvestigationTasksDo.setIdentifyperpleid(checkUserInfo.split("-;-")[1]);
             apsDetailsHazardInvestigationTasksDo.setPlannedstarttime(startTime);
+            apsDetailsHazardInvestigationTasksDo.setTasktype(tempData.getChecktype());
             apsDetailsHazardInvestigationTasksDo.setPlannedendtime(endTime);
             apsDetailsHazardInvestigationTasksDo.setTenantid(tempData.getTenantid());
             taskSaveList.add(apsDetailsHazardInvestigationTasksDo);
-            taskDetailSaveList.addAll(assembleTaskDetails(currentUser, apsDetailsHazardInvestigationTasksDo, checkItemList));
+            taskDetailSaveList.addAll(assembleTaskDetails(currentUser, apsDetailsHazardInvestigationTasksDo,
+                    templateZibiaoDos));
         }
         apsDetailsHazardInvestigationTasksServiceImpl.saveBatch(taskSaveList);
         apsDetailsHazardInvestigationTasksJcxzibiaoService.saveBatch(taskDetailSaveList);
@@ -162,11 +186,33 @@ public class HazardInvestigationServiceImpl implements HazardInvestigationServic
             apsHazardInvestigationTemplateZibiaoDo.setDescriptionofcontrolmeasures(s.getDescriptionofcontrolmeasures());
             apsHazardInvestigationTemplateZibiaoDo.setClassificationofcontrolmeasures3(s.getClassificationofcontrolmeasures3());
             apsHazardInvestigationTemplateZibiaoDo.setTenantid(apsDetailsHazardInvestigationTasksDo.getTenantid());
-        subSaveList.add(apsHazardInvestigationTemplateZibiaoDo);
+            subSaveList.add(apsHazardInvestigationTemplateZibiaoDo);
         }
         return subSaveList;
     }
 
+    /**
+     * 获取隐患排查任务的排查人
+     *
+     * @param aspRiskUnitDo
+     * @param aspMajorHazardSourcesDos
+     * @param tempData
+     * @return
+     */
+    public String getCheckUserInfo(AspRiskUnitDo aspRiskUnitDo,
+                                   List<AspMajorHazardSourcesDo> aspMajorHazardSourcesDos,
+                                   ApsHazardInvestigationTemplateDo tempData) {
+        // 不是重大危险源直接返回责任人
+        if (!"1".equals(aspRiskUnitDo.getMajorhazard()) || "0".equals(tempData.getChecktype())) {
+            return aspRiskUnitDo.getDutyofficername() + "-;-" + aspRiskUnitDo.getDutyofficerid();
+        }
+        Optional<AspMajorHazardSourcesDo> hazardSources = aspMajorHazardSourcesDos.stream().filter(data -> data.getId().equals(aspRiskUnitDo.getMajorhazardid())).findFirst();
+        JSCommonUtils.parameterCheck(hazardSources::isPresent,"无法获取到重大危险源","无法获取到重大危险源");
+        AspMajorHazardSourcesDo aspMajorHazardSourcesDo = hazardSources.get();
+        List<Function<AspMajorHazardSourcesDo, String>> functions = getCheckUserInfoFunctionMap.get(tempData.getChecktype());
+        return functions.get(0).apply(aspMajorHazardSourcesDo) + "-;-" + functions.get(1).apply(aspMajorHazardSourcesDo);
+    }
+
     /**
      * 校验模板中的检查项是否需要生成任务信息
      */
@@ -177,7 +223,7 @@ public class HazardInvestigationServiceImpl implements HazardInvestigationServic
         Integer inspectioncycle = investigationTemplateZibiaoDo.getInspectioncycle();
         // 周期单位
         String inspectioncycleunit = investigationTemplateZibiaoDo.getInspectioncycleunit();
-        int generationFrequency=0;
+        int generationFrequency = 0;
         if (inspectioncycle == null || inspectioncycle == 0) {
             log.error("巡检周期为空");
             throw new CustomException("巡检周期为空");
@@ -185,7 +231,7 @@ public class HazardInvestigationServiceImpl implements HazardInvestigationServic
         Calendar instance = Calendar.getInstance();
         switch (inspectioncycleunit) {
             case "0": // 小时  每几小时巡检一次
-                generationFrequency = 24/inspectioncycle;
+                generationFrequency = 24 / inspectioncycle;
                 break;
             case "1": //天  每几天巡检一次
                 generationFrequency = inspectioncycle;

+ 2 - 0
js-security/security-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/ScheduledTasksService.java

@@ -22,4 +22,6 @@ public interface ScheduledTasksService {
     R hiddenDangerTask();
 
     R createCheckPlanByTemp();
+
+    R creatHazardInvestigationTask();
 }

+ 48 - 1
js-security/security-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/ScheduledTasksServiceImpl.java

@@ -1,6 +1,8 @@
 package com.rongwei.sfcommon.sys.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.rongwe.scentity.domian.ApsHazardInvestigationTemplateDo;
+import com.rongwe.scentity.domian.ApsHazardInvestigationTemplateZibiaoDo;
 import com.rongwe.scentity.domian.CheckTemplateDo;
 import com.rongwe.scentity.domian.HiddenDangerTrackDo;
 import com.rongwe.scentity.vo.ExportHiddenDangerVo;
@@ -65,6 +67,8 @@ public class ScheduledTasksServiceImpl implements ScheduledTasksService {
      */
     public static final String AFFIRM_REMIND_MAIL_CONTENT = "【%s】 已验证完成,请您确认关闭";
 
+    @Autowired
+    private ApsHazardInvestigationTemplateServiceImpl apsHazardInvestigationTemplateService;
     @Autowired
     private SaveCheckCommonDao saveCheckCommonDao;
     @Autowired
@@ -73,7 +77,8 @@ public class ScheduledTasksServiceImpl implements ScheduledTasksService {
     private HiddenDangerTrackServiceImpl hiddenDangerTrackService;
     @Autowired
     private CheckTemplateServiceImpl checkTemplateService;
-
+    @Autowired
+    private ApsHazardInvestigationTemplateZibiaoServiceImpl apsHazardInvestigationTemplateZibiaoService;
 
     @Override
     public void rectificationSystem() {
@@ -185,6 +190,48 @@ public class ScheduledTasksServiceImpl implements ScheduledTasksService {
         });
 
 
+        return R.ok();
+    }
+
+    /**
+     * 生成隐患排查任务
+     * @return
+     */
+    @Override
+    public R creatHazardInvestigationTask() {
+        // 获取所有开启的定时任务
+        List<ApsHazardInvestigationTemplateDo> tempList = apsHazardInvestigationTemplateService.list(
+                new LambdaQueryWrapper<ApsHazardInvestigationTemplateDo>()
+                        .eq(BaseDo::getDeleted, "0")
+                        .eq(ApsHazardInvestigationTemplateDo::getTaskgenerator, "1")
+                        .eq(ApsHazardInvestigationTemplateDo::getTempstate,"10")
+        );
+        if(tempList.isEmpty()){
+            log.debug("暂无开启的定时任务模板");
+            return R.ok();
+        }
+        // 模板ID
+        List<String> tempIds = tempList.stream().map(ApsHazardInvestigationTemplateDo::getId).collect(Collectors.toList());
+        // 模板检查项
+        List<ApsHazardInvestigationTemplateZibiaoDo> templateZibiaoDos = apsHazardInvestigationTemplateZibiaoService.list(new LambdaQueryWrapper<ApsHazardInvestigationTemplateZibiaoDo>()
+                .in(ApsHazardInvestigationTemplateZibiaoDo::getMubanid, tempIds)
+                .eq(BaseDo::getDeleted, "0"));
+        List<ApsHazardInvestigationTemplateZibiaoDo> subList;
+        for (ApsHazardInvestigationTemplateDo mainData : tempList) {
+            String tempId =mainData.getId();
+            subList = templateZibiaoDos.stream().filter(subData -> tempId.equals(subData.getMubanid())).collect(Collectors.toList());
+            if(subList.isEmpty()){
+                continue;
+            }
+            for (ApsHazardInvestigationTemplateZibiaoDo apsHazardInvestigationTemplateZibiaoDo : subList) {
+
+            }
+
+        }
+
+
+
+
         return R.ok();
     }
 

+ 12 - 2
js-security/security-entity/src/main/java/com/rongwe/scentity/domian/ApsDetailsHazardInvestigationTasksDo.java

@@ -46,7 +46,6 @@ public class ApsDetailsHazardInvestigationTasksDo extends BaseDo implements Seri
     /**
      * 任务类型
      */
-    @Deprecated
     private String tasktype;
 
     /**
@@ -88,7 +87,18 @@ public class ApsDetailsHazardInvestigationTasksDo extends BaseDo implements Seri
      * 隐患排查编号
      */
     private String number;
-
+    /**
+     * 排查模板编号
+     */
+    private String tempcode;
+    /**
+     * 排查模板名称
+     */
+    private String tempname;
+    /**
+     * 排查结果
+     */
+    private String result;
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 }

+ 92 - 0
js-security/security-entity/src/main/java/com/rongwe/scentity/domian/AspMajorHazardSourcesDo.java

@@ -0,0 +1,92 @@
+package com.rongwe.scentity.domian;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+
+import com.rongwei.rwcommon.base.BaseDo;
+import lombok.Data;
+
+/**
+ * 重大危险源
+ * @TableName asp_major_hazard_sources
+ */
+@TableName(value ="asp_major_hazard_sources")
+@Data
+public class AspMajorHazardSourcesDo extends BaseDo implements Serializable {
+    /**
+     * 主键ID
+     */
+    @TableId
+    private String id;
+
+    /**
+     * 租户ID
+     */
+    private String tenantid;
+
+    /**
+     * 扩展json格式配置
+     */
+    private String roption;
+
+
+    /**
+     * 重大危险源编码
+     */
+    private String majorhazardsourcecode;
+
+    /**
+     * 重大危险源名称
+     */
+    private String majorhazardsourcename;
+
+    /**
+     * 级别
+     */
+    private String wxlevel;
+
+    /**
+     * 重大危险源区域
+     */
+    private String majorhazardsourcearea;
+
+    /**
+     * 主要负责人
+     */
+    private String mainresponsible;
+
+    /**
+     * 技术负责人
+     */
+    private String technicalresponsible;
+
+    /**
+     * 操作负责人
+     */
+    private String operationresponsible;
+    /**
+     * 主要负责人ID
+     */
+    private String mainresponsibleid;
+
+    /**
+     * 技术负责人ID
+     */
+    private String technicalresponsibleid;
+
+    /**
+     * 操作负责人ID
+     */
+    private String operationresponsibleid;
+
+    /**
+     * 附件
+     */
+    private String file;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 15 - 0
js-security/security-entity/src/main/java/com/rongwe/scentity/domian/AspRiskUnitDo.java

@@ -72,6 +72,21 @@ public class AspRiskUnitDo extends BaseDo implements Serializable {
      */
     private String dutyofficername;
 
+
+    /**
+     * 是否重大危险源
+     */
+    private String majorhazard;
+    /**
+     * 重大危险源ID
+     */
+    private String majorhazardid;
+    /**
+     * 重大危险源名称
+     */
+    private String majorhazardname;
+
+
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 }

+ 10 - 0
js-security/security-server/src/main/java/com/rongwei/savecheck/controller/ScheduledTasksController.java

@@ -94,4 +94,14 @@ public class ScheduledTasksController {
         scheduledTasksService.createCheckPlanByTemp();
         return R.ok();
     }
+
+    @Scheduled(cron = "0 0 6 ? * *")
+    @PostMapping("/hazard-investigation")
+    public R creatHazardInvestigationTask(){
+        log.info("隐患排查任务定时提醒");
+       return scheduledTasksService.creatHazardInvestigationTask();
+    }
+
+
+
 }