|
@@ -1,6 +1,4 @@
|
|
|
package com.rongwei.sfcommon.sys.service.impl;
|
|
|
-
|
|
|
-import com.aspose.cells.DocumentPropertyCollection;
|
|
|
import com.aspose.words.Document;
|
|
|
import com.aspose.words.DocumentBuilder;
|
|
|
import com.aspose.words.MailMergeCleanupOptions;
|
|
@@ -13,6 +11,7 @@ import com.rongwei.rwadmincommon.system.domain.SysDictDo;
|
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
|
|
|
+import com.rongwei.safecommon.fegin.WFFeginClient;
|
|
|
import com.rongwei.sfcommon.sys.service.*;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -28,8 +27,13 @@ import java.net.URLEncoder;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.OffsetDateTime;
|
|
|
+import java.time.ZonedDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.format.DateTimeParseException;
|
|
|
+import java.time.temporal.TemporalAccessor;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -38,7 +42,8 @@ import java.util.stream.Collectors;
|
|
|
public class RiskJobServiceImpl implements RiskJobService {
|
|
|
private static final Logger logger = LoggerFactory.getLogger(RiskJobServiceImpl.class.getName());
|
|
|
public static final String DEFAULT_FONT_NAME = "仿宋";
|
|
|
-
|
|
|
+// private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
|
|
public static final Map<String, String> CHECK_BOX= new HashMap<String, String>() {{
|
|
|
put("DHFS", "dhfs");
|
|
|
put("FHYP", "fhyp");
|
|
@@ -49,7 +54,6 @@ public class RiskJobServiceImpl implements RiskJobService {
|
|
|
put("吊装作业", "吊装作业.docx");
|
|
|
put("受限空间作业", "受限空间作业.docx");
|
|
|
put("临时用电作业", "临时用电作业.docx");
|
|
|
-
|
|
|
put("动土作业", "动土作业.docx");
|
|
|
put("断路作业", "断路作业.docx");
|
|
|
put("盲板抽堵", "盲板抽堵作业.docx");
|
|
@@ -93,6 +97,9 @@ public class RiskJobServiceImpl implements RiskJobService {
|
|
|
@Autowired
|
|
|
AspMbcdzyService aspMbcdzyService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WFFeginClient wfFeginClient;
|
|
|
+
|
|
|
@Autowired
|
|
|
AspCombustibleGasDetectionService aspCombustibleGasDetectionService;
|
|
|
|
|
@@ -179,7 +186,7 @@ public class RiskJobServiceImpl implements RiskJobService {
|
|
|
// return subList3;
|
|
|
// }
|
|
|
|
|
|
- private List<Map<String, String>> getAqcsList(String id) {
|
|
|
+ private List<Map<String, String>> getAqcsList(String id,Map<String, String> wordMap) {
|
|
|
List<AspInspectionInformationTableDo> aqcsList = aspInspectionInformationTableService.list(new QueryWrapper<AspInspectionInformationTableDo>()
|
|
|
.eq("jobid",id)
|
|
|
.eq("deleted", '0'));
|
|
@@ -189,7 +196,12 @@ public class RiskJobServiceImpl implements RiskJobService {
|
|
|
Map<String, String> subItem2 = new HashMap<>();
|
|
|
subItem2.put("MAINSAFETYMEASURES", defaultEmptyStr(item.getMainsafetymeasures()));
|
|
|
subItem2.put("WHETHERITINVOLVES", defaultEmptyStr(item.getWhetheritinvolves()));
|
|
|
+ // 检查人
|
|
|
subItem2.put("CHECKUSER", defaultEmptyStr(item.getCheckuser()));
|
|
|
+
|
|
|
+ // 插入图片签名
|
|
|
+// insertImageToBookmark(doc, "CHECKUSER", wordMap.get("SDBMFZRQZ"));
|
|
|
+
|
|
|
subList2.add(subItem2);
|
|
|
}
|
|
|
}
|
|
@@ -198,18 +210,18 @@ public class RiskJobServiceImpl implements RiskJobService {
|
|
|
|
|
|
|
|
|
// 获取动火人信息
|
|
|
- private String getDhrxx(String id,Map<String, String> wordMap) {
|
|
|
- List<AspSpecialPersonalInformationDo> dhrList = aspSpecialPersonalInformationService.list(new QueryWrapper<AspSpecialPersonalInformationDo>()
|
|
|
- .eq("jobid", id)
|
|
|
- .eq("deleted", "0"));
|
|
|
- if (dhrList != null && !dhrList.isEmpty()) {
|
|
|
- String dhrxx = dhrList.stream()
|
|
|
- .map(item -> defaultEmptyStr(item.getName()) + "," + defaultEmptyStr(item.getCertificateno()))
|
|
|
- .collect(Collectors.joining(" "));
|
|
|
- wordMap.put("DHRJZSBH", defaultEmptyStr(dhrxx));
|
|
|
- }
|
|
|
- return ""; // 如果没有动火人信息,返回空字符串
|
|
|
- }
|
|
|
+// private String getDhrxx(String id,Map<String, String> wordMap) {
|
|
|
+// List<AspSpecialPersonalInformationDo> dhrList = aspSpecialPersonalInformationService.list(new QueryWrapper<AspSpecialPersonalInformationDo>()
|
|
|
+// .eq("jobid", id)
|
|
|
+// .eq("deleted", "0"));
|
|
|
+// if (dhrList != null && !dhrList.isEmpty()) {
|
|
|
+// String dhrxx = dhrList.stream()
|
|
|
+// .map(item -> defaultEmptyStr(item.getName()) + "," + defaultEmptyStr(item.getCertificateno()))
|
|
|
+// .collect(Collectors.joining(" "));
|
|
|
+// wordMap.put("DHRJZSBH", defaultEmptyStr(dhrxx));
|
|
|
+// }
|
|
|
+// return ""; // 如果没有动火人信息,返回空字符串
|
|
|
+// }
|
|
|
private String getryxx(String id,Map<String, String> wordMap) {
|
|
|
List<AspSpecialPersonalInformationDo> dhrList = aspSpecialPersonalInformationService.list(new QueryWrapper<AspSpecialPersonalInformationDo>()
|
|
|
.eq("jobid", id)
|
|
@@ -233,12 +245,59 @@ public class RiskJobServiceImpl implements RiskJobService {
|
|
|
return ""; // 如果没有信息,返回空字符串
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void riskJobExport2(String id, String jobtype, String tenantid, HttpServletResponse response) {
|
|
|
+ riskJobExportCommon(id, jobtype, tenantid, null, response);
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void riskJobExport2(String id, String jobtype, String tenantid, String processinstid, HttpServletResponse response) {
|
|
|
+ riskJobExportCommon(id, jobtype, tenantid, processinstid, response);
|
|
|
+ }
|
|
|
|
|
|
- public void riskJobExport2(String id, String jobtype,String tenantid,HttpServletResponse response) {
|
|
|
+
|
|
|
+ private void riskJobExportCommon(String id, String jobtype, String tenantid, String processinstid, HttpServletResponse response) {
|
|
|
Map<String, String> wordMap = new HashMap<>();
|
|
|
// 获取通用数据字典数据
|
|
|
List<SysDictDo> sysDictDoList = getSysDictDoList();
|
|
|
+
|
|
|
+ // 根据作业类型获取并处理数据
|
|
|
+ processJobDataByType(id, jobtype, wordMap, sysDictDoList);
|
|
|
+
|
|
|
+ // 气体检查数据
|
|
|
+ List<Map<String, String>> subList1 = getCombustibleGasDetectionList(id, sysDictDoList);
|
|
|
+
|
|
|
+ // 关联作业
|
|
|
+ getJobData(id, wordMap);
|
|
|
+
|
|
|
+ // 安全措施数据
|
|
|
+ List<Map<String, String>> subList2 = getAqcsList(id, wordMap);
|
|
|
+
|
|
|
+ // 作业人信息
|
|
|
+ getryxx(id, wordMap);
|
|
|
+
|
|
|
+ // 如果有流程实例ID,处理流程评论信息
|
|
|
+ if (processinstid != null) {
|
|
|
+ processWorkflowComments(processinstid, wordMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 风险辨识
|
|
|
+ List<AspJobConfigFxbsDo> fxbsList = aspJobConfigFxbsService.list(new QueryWrapper<AspJobConfigFxbsDo>()
|
|
|
+ .eq("tenantid", tenantid)
|
|
|
+ .eq("jobtype", jobtype)
|
|
|
+ .eq("deleted", '0'));
|
|
|
+ String[] fxbs = fxbsList != null
|
|
|
+ ? fxbsList.stream()
|
|
|
+ .sorted(Comparator.comparing(AspJobConfigFxbsDo::getSon))
|
|
|
+ .map(AspJobConfigFxbsDo::getFxbsx)
|
|
|
+ .toArray(String[]::new)
|
|
|
+ : new String[0];
|
|
|
+
|
|
|
+ response(wordMap, response, subList1, subList2, fxbs, sysDictDoList, jobtype);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void processJobDataByType(String id, String jobtype, Map<String, String> wordMap, List<SysDictDo> sysDictDoList) {
|
|
|
if ("动火作业".equals(jobtype)) {
|
|
|
AspDhzyDo dhzyDo = dhzyService.getById(id);
|
|
|
if (dhzyDo == null) {
|
|
@@ -247,79 +306,138 @@ public class RiskJobServiceImpl implements RiskJobService {
|
|
|
processAspDhzyDo(dhzyDo, wordMap, sysDictDoList);
|
|
|
} else if ("受限空间作业".equals(jobtype)) {
|
|
|
AspSxkjzyDo sxkjzyDo = sxkjzyService.getById(id);
|
|
|
-
|
|
|
if (sxkjzyDo == null) {
|
|
|
throw new RuntimeException("未找到该受限空间作业信息!");
|
|
|
}
|
|
|
processAspSxkjzyDo(sxkjzyDo, wordMap, sysDictDoList);
|
|
|
- }else if ("高处作业".equals(jobtype)) {
|
|
|
+ } else if ("高处作业".equals(jobtype)) {
|
|
|
AspGczyDo aspGczyDo = aspGczyService.getById(id);
|
|
|
- if(aspGczyDo == null){
|
|
|
+ if (aspGczyDo == null) {
|
|
|
throw new RuntimeException("未找到该高处作业信息!");
|
|
|
}
|
|
|
processAspGczyDo(aspGczyDo, wordMap, sysDictDoList);
|
|
|
- }else if ("吊装作业".equals(jobtype)) {
|
|
|
+ } else if ("吊装作业".equals(jobtype)) {
|
|
|
AspDzzyDo aspDzzyDo = aspDzzyService.getById(id);
|
|
|
- if(aspDzzyDo == null){
|
|
|
+ if (aspDzzyDo == null) {
|
|
|
throw new RuntimeException("未找到该吊装作业信息!");
|
|
|
}
|
|
|
processAspDzzyDo(aspDzzyDo, wordMap, sysDictDoList);
|
|
|
- }else if ("临时用电作业".equals(jobtype)) {
|
|
|
+ } else if ("临时用电作业".equals(jobtype)) {
|
|
|
AspLsydzyDo aspLsydzyDo = aspLsydzyService.getById(id);
|
|
|
- if(aspLsydzyDo == null){
|
|
|
+ if (aspLsydzyDo == null) {
|
|
|
throw new RuntimeException("未找到该临时用电作业信息!");
|
|
|
}
|
|
|
- processAspLsydzyDo(aspLsydzyDo,wordMap,sysDictDoList);
|
|
|
- }else if ("动土作业".equals(jobtype)) {
|
|
|
+ processAspLsydzyDo(aspLsydzyDo, wordMap, sysDictDoList);
|
|
|
+ } else if ("动土作业".equals(jobtype)) {
|
|
|
AspDtzyDo aspdtzyDo = aspDtzyService.getById(id);
|
|
|
- if(aspdtzyDo == null){
|
|
|
+ if (aspdtzyDo == null) {
|
|
|
throw new RuntimeException("未找到该动土作业信息!");
|
|
|
}
|
|
|
- processAspDtzyDo(aspdtzyDo,wordMap,sysDictDoList);
|
|
|
- }else if ("断路作业".equals(jobtype)) {
|
|
|
+ processAspDtzyDo(aspdtzyDo, wordMap, sysDictDoList);
|
|
|
+ } else if ("断路作业".equals(jobtype)) {
|
|
|
AspDlzzDo aspdlzzDo = aspDlzzService.getById(id);
|
|
|
- if(aspdlzzDo == null){
|
|
|
+ if (aspdlzzDo == null) {
|
|
|
throw new RuntimeException("未找到该断路作业信息!");
|
|
|
}
|
|
|
- processAspDlzzDo(aspdlzzDo,wordMap,sysDictDoList);
|
|
|
- }else if ("盲板抽堵".equals(jobtype)) {
|
|
|
+ processAspDlzzDo(aspdlzzDo, wordMap, sysDictDoList);
|
|
|
+ } else if ("盲板抽堵".equals(jobtype)) {
|
|
|
AspMbcdzyDo aspmbcdzyDo = aspMbcdzyService.getById(id);
|
|
|
- if(aspmbcdzyDo == null){
|
|
|
+ if (aspmbcdzyDo == null) {
|
|
|
throw new RuntimeException("未找到该盲板抽堵作业信息!");
|
|
|
}
|
|
|
- processAspMbcdDo(aspmbcdzyDo,wordMap,sysDictDoList);
|
|
|
- }else {
|
|
|
+ processAspMbcdDo(aspmbcdzyDo, wordMap, sysDictDoList);
|
|
|
+ } else {
|
|
|
throw new RuntimeException("未找到作业信息!");
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // 气体检查数据
|
|
|
- List<Map<String, String>> subList1 = getCombustibleGasDetectionList(id,sysDictDoList);
|
|
|
|
|
|
- // 关联作业
|
|
|
- getJobData(id,wordMap);
|
|
|
-
|
|
|
- // 安全措施数据
|
|
|
- List<Map<String, String>> subList2 = getAqcsList(id);
|
|
|
|
|
|
- // 作业人信息
|
|
|
- getryxx(id,wordMap);
|
|
|
+ private void processWorkflowComments(String processinstid, Map<String, String> wordMap) {
|
|
|
+ //获取流程评论信息 取每个节点最新的 留下审批人名字 和审批人评论 签名使用流程控制
|
|
|
+ List<Map<String, Object>> wfinfolist = wfFeginClient.getCommentsByProcInstId(processinstid);
|
|
|
+ List<Map<String, Object>> resultList = processComments(wfinfolist);
|
|
|
+
|
|
|
+ //去resultList里找
|
|
|
+ for (Map<String, Object> map : resultList) {
|
|
|
+ String taskName = defaultEmptyStr(map.get("taskname"));
|
|
|
+ if ("安环部".equals(taskName)) {
|
|
|
+ wordMap.put("AQGLBYJ", defaultEmptyStr(map.get("taskcomment")));
|
|
|
+ wordMap.put("AHBWXZYZG", defaultEmptyStr(map.get("assigneename")));
|
|
|
+ wordMap.put("AQGLBMSPRQ", defaultEmptyStr(map.get("provedate")));
|
|
|
+ } else if ("部门副总".equals(taskName)) {
|
|
|
+ wordMap.put("FGLDYJ", defaultEmptyStr(map.get("taskcomment")));
|
|
|
+ wordMap.put("BMFZQZ", defaultEmptyStr(map.get("assigneename")));
|
|
|
+ wordMap.put("FGLDSPRQ", defaultEmptyStr(map.get("provedate")));
|
|
|
+ } else if ("总经理".equals(taskName)) {
|
|
|
+ // 补充逻辑
|
|
|
+ } else if ("总工程师".equals(taskName)) {
|
|
|
+ // 补充逻辑
|
|
|
+ } else if ("属地部门经理".equals(taskName)) {
|
|
|
+ wordMap.put("SDBMYJ", defaultEmptyStr(map.get("taskcomment")));
|
|
|
+ wordMap.put("BMJLQM", defaultEmptyStr(map.get("assigneename")));
|
|
|
+ wordMap.put("SDBMSPRQ", defaultEmptyStr(map.get("provedate")));
|
|
|
+ } else if ("开始".equals(taskName)) {
|
|
|
+ wordMap.put("ZYFZRYJ", "同意开始");
|
|
|
+ wordMap.put("ZYFZRSPRQ", defaultEmptyStr(map.get("provedate")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 风险辨识
|
|
|
- List<AspJobConfigFxbsDo> fxbsList = aspJobConfigFxbsService.list(new QueryWrapper<AspJobConfigFxbsDo>()
|
|
|
- .eq("tenantid",tenantid)
|
|
|
- .eq("jobtype",jobtype)
|
|
|
- .eq("deleted", '0'));
|
|
|
- String[] fxbs = fxbsList != null
|
|
|
- ? fxbsList.stream()
|
|
|
- .sorted(Comparator.comparing(AspJobConfigFxbsDo::getSon))
|
|
|
- .map(AspJobConfigFxbsDo::getFxbsx)
|
|
|
- .toArray(String[]::new)
|
|
|
- : new String[0];
|
|
|
|
|
|
- response(wordMap,response,subList1,subList2,fxbs,sysDictDoList,jobtype);
|
|
|
+ // 处理评论列表,按TASKNAME分组并保留CREATEDATE最新的记录
|
|
|
+ public static List<Map<String, Object>> processComments(List<Map<String, Object>> wfinfolist) {
|
|
|
+ return wfinfolist.stream()
|
|
|
+ .filter(comment ->
|
|
|
+ comment.get("taskname") instanceof String &&
|
|
|
+ comment.get("createdate") instanceof String
|
|
|
+// &&
|
|
|
+// comment.get("assigneename") instanceof String &&
|
|
|
+// !((String) comment.get("assigneename")).trim().isEmpty()
|
|
|
+ )
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ comment -> (String) comment.get("taskname"),
|
|
|
+ Collectors.collectingAndThen(
|
|
|
+ Collectors.maxBy(Comparator.comparing(
|
|
|
+ comment -> (String) comment.get("createdate")
|
|
|
+ )),
|
|
|
+ Optional::get
|
|
|
+ )
|
|
|
+ ))
|
|
|
+ .values()
|
|
|
+ .stream()
|
|
|
+ .map(comment -> {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("taskname", comment.get("taskname"));
|
|
|
+ result.put("assigneename", comment.get("assigneename"));
|
|
|
+ result.put("taskcomment", comment.get("taskcomment"));
|
|
|
+
|
|
|
+ // 处理provedate字段,将字符串转换为LocalDateTime
|
|
|
+ Object provedateObj = comment.get("provedate");
|
|
|
+ if (provedateObj instanceof String) {
|
|
|
+ try {
|
|
|
+ // 解析为OffsetDateTime以处理时区,然后转换为LocalDateTime
|
|
|
+ OffsetDateTime offsetDateTime = OffsetDateTime.parse((String) provedateObj, DATE_TIME_FORMATTER);
|
|
|
+ result.put("provedate", offsetDateTime.toLocalDateTime());
|
|
|
+ } catch (DateTimeParseException e) {
|
|
|
+ // 解析失败时保留原始值或设置为null
|
|
|
+ System.err.println("Failed to parse date: " + provedateObj);
|
|
|
+ result.put("provedate", null);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.put("provedate", null);
|
|
|
+ }
|
|
|
|
|
|
+ return result;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public void processAspDhzyDo(AspDhzyDo dhzyDo, Map<String, String> wordMap, List<SysDictDo> sysDictDoList) {
|
|
|
// 动火方式处理
|
|
|
// String dhfs = dhzyDo.getDhfs();
|
|
@@ -451,8 +569,6 @@ public class RiskJobServiceImpl implements RiskJobService {
|
|
|
wordMap.put("JSJDRQM", defaultEmptyStr(GczyDo.getJsjdrqm()));
|
|
|
wordMap.put("FXBSX", defaultEmptyStr(GczyDo.getFxbs()));
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -643,19 +759,39 @@ public class RiskJobServiceImpl implements RiskJobService {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
public String defaultEmptyStr(Object str) {
|
|
|
if (str == null) {
|
|
|
return "";
|
|
|
}
|
|
|
if (str instanceof Date) {
|
|
|
-// return new SimpleDateFormat("yyyy-MM-dd").format(str);
|
|
|
+ // 处理旧版 Date 类型
|
|
|
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) str);
|
|
|
+ } else if (str instanceof java.time.temporal.TemporalAccessor) {
|
|
|
+ // 统一处理 Java 8 时间类型(LocalDateTime、LocalDate、ZonedDateTime 等)
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ if (str instanceof LocalDateTime) {
|
|
|
+ return ((LocalDateTime) str).format(formatter);
|
|
|
+ } else if (str instanceof LocalDate) {
|
|
|
+ return ((LocalDate) str).atStartOfDay().format(formatter);
|
|
|
+ } else if (str instanceof ZonedDateTime) {
|
|
|
+ return ((ZonedDateTime) str).format(formatter);
|
|
|
+ }
|
|
|
+ return formatter.format((TemporalAccessor) str);
|
|
|
}
|
|
|
return str.toString();
|
|
|
}
|
|
|
|
|
|
+// public String defaultEmptyStr(Object str) {
|
|
|
+// if (str == null) {
|
|
|
+// return "";
|
|
|
+// }
|
|
|
+// if (str instanceof Date) {
|
|
|
+//// return new SimpleDateFormat("yyyy-MM-dd").format(str);
|
|
|
+// return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) str);
|
|
|
+// }
|
|
|
+// return str.toString();
|
|
|
+// }
|
|
|
+
|
|
|
public void checkBoxDispose(Map<String, String> wordMap, Document document, String[] fxbs, List<SysDictDo> sysDictDoList) {
|
|
|
try {
|
|
|
DocumentBuilder builder = new DocumentBuilder(document);
|