|
@@ -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;
|