Browse Source

工作票修改及优化

zhongwei
段飞宇 2 years ago
parent
commit
ecbfde0aad
  1. 1
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java
  2. 6
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/ProcessWorkFlowResponse.java
  3. 4
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/TicketInfoDanger.java
  4. 345
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  5. 22
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/MergeDocUtils.java
  6. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/PdfUtils.java
  7. 6
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketPrincipalChangeServiceImpl.java
  8. BIN
      hzims-service/ticket/src/main/resources/template/secondary/工作票危险点分析及控制措施票.docx
  9. BIN
      hzims-service/ticket/src/main/resources/template/电气第一种工作票模版.docx

1
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java

@ -48,7 +48,6 @@ public class StandardWorkTicketConsumer implements IQueueConsume {
if (ObjectUtils.isNotEmpty(ticketService)) { if (ObjectUtils.isNotEmpty(ticketService)) {
//执行业务方法 //执行业务方法
try { try {
response.setNum(1);
ticketService.calculate(response); ticketService.calculate(response);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

6
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/ProcessWorkFlowResponse.java

@ -56,6 +56,8 @@ public class ProcessWorkFlowResponse implements Serializable {
private String handleType; private String handleType;
/**
private Integer num; * 用户Id
*/
private String userId;
} }

4
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/TicketInfoDanger.java

@ -47,14 +47,14 @@ public class TicketInfoDanger {
/** /**
* 创建时间 * 创建时间
*/ */
@TableField(value = "update_time", fill = FieldFill.INSERT) //@TableField(value = "update_time", fill = FieldFill.INSERT)
private LocalDateTime createTime; private LocalDateTime createTime;
/** /**
* 更新时间 * 更新时间
*/ */
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) //@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime; private LocalDateTime updateTime;

345
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

@ -59,6 +59,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -202,6 +203,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
log.info("获取businessKey: {}", response.getBusinessKey()); log.info("获取businessKey: {}", response.getBusinessKey());
log.info("获取taskId: {}", response.getTaskId()); log.info("获取taskId: {}", response.getTaskId());
log.info("获取下一个审批人是: {}", response.getNextStepOperator()); log.info("获取下一个审批人是: {}", response.getNextStepOperator());
log.info("获取下一个用户Id是: {}", response.getUserId());
log.info("获取当前任务名称是: {}", response.getTaskName()); log.info("获取当前任务名称是: {}", response.getTaskName());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType()); log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单 //json转换表单
@ -222,22 +224,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey); WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey);
if (ObjectUtils.isEmpty(workTicketInfo)) { if (ObjectUtils.isEmpty(workTicketInfo)) {
log.error("获取工作票的数据为不存在"); log.error("获取工作票的数据为不存在");
int num = response.getNum();
while (true) {
if (num == 0) {
break;
}
try {
//睡眠2秒防止cpu飚高
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
log.info("进入重试机制 {}", response);
num--;
response.setNum(num);
findPending(response);
}
return; return;
} }
try { try {
@ -258,12 +244,10 @@ public class TicketProcessServiceImpl implements TicketProcessService {
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) { if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
log.info("获取安全措施的数据:{}", safetyMeasuresList); log.info("获取安全措施的数据:{}", safetyMeasuresList);
safetyMeasuresList.forEach(item -> { safetyMeasuresList.forEach(item -> {
if (ObjectUtils.isEmpty(item.getId())) { if (ObjectUtils.isNotEmpty(item.getTicketId())) {
LambdaQueryWrapper<WorkTicketSafetyMeasureEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WorkTicketSafetyMeasureEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(WorkTicketSafetyMeasureEntity::getTicketId, workTicketInfo.getId()); queryWrapper.eq(WorkTicketSafetyMeasureEntity::getTicketId, item.getTicketId());
workTicketSafetyMeasureService.update(item, queryWrapper); workTicketSafetyMeasureService.update(item, queryWrapper);
} else {
workTicketSafetyMeasureService.updateById(item);
} }
}); });
} }
@ -364,10 +348,18 @@ public class TicketProcessServiceImpl implements TicketProcessService {
//工作票危险点分析及控制措施票 //工作票危险点分析及控制措施票
try { try {
if (workTicketInfo.getIsHazard()) { if (workTicket.getIsHazard()) {
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers(); List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
if (CollectionUtils.isNotEmpty(ticketInfoDangers)) { if (CollectionUtils.isNotEmpty(ticketInfoDangers)) {
ticketInfoDangerService.saveBatch(ticketInfoDangers); List<TicketInfoDanger> collect = ticketInfoDangers.stream().map(item -> {
item.setTicketId(workTicketInfo.getId());
return item;
}).collect(Collectors.toList());
System.out.println("工作票危险点分析及控制措施票 : " + collect);
ticketInfoDangerService.saveBatch(collect);
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -383,14 +375,10 @@ public class TicketProcessServiceImpl implements TicketProcessService {
* @param response * @param response
*/ */
private void saveWorkTicket(WorkTicketInfoEntity workTicket, ProcessWorkFlowResponse response) { private void saveWorkTicket(WorkTicketInfoEntity workTicket, ProcessWorkFlowResponse response) {
String taskId = response.getTaskId();
workTicket.setFlowTaskId(taskId);
workTicket.setFlowTaskName(response.getTaskName());
String nextStepOperator = response.getNextStepOperator();
String flowDescription = ""; String flowDescription = "";
Integer flowStatus = workTicket.getFlowStatus(); //如果response.getHandleType() 是0使用户
if ("0".equals(response.getHandleType())) { if ("0".equals(response.getHandleType())) {
String nextStepOperator = response.getNextStepOperator();
Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ? nextStepOperator.substring(9) : null); Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ? nextStepOperator.substring(9) : null);
if (taskUser != null) { if (taskUser != null) {
//下一个审批人 //下一个审批人
@ -403,43 +391,36 @@ public class TicketProcessServiceImpl implements TicketProcessService {
workTicket.setNextStepOperator(null); workTicket.setNextStepOperator(null);
} }
} }
//如果response.getHandleType() 是1使角色
if ("1".equals(response.getHandleType())) { if ("1".equals(response.getHandleType())) {
log.info("获取角色信息" + response.getNextStepOperator());
//根据角色别名获取用户信息 //根据角色别名获取用户信息
try { // try {
R<List<User>> roleAlias = userClient.relationUserListByRoleAlias(workTicket.getTenantId(), workTicket.getCreateDept(), response.getNextStepOperator()); // R<List<User>> roleAlias = userClient.relationUserListByRoleAlias(workTicket.getTenantId(), workTicket.getCreateDept(), response.getNextStepOperator());
String collect = roleAlias.getData().stream().map(item -> item.getName()).collect(Collectors.joining(",")); // String collect = roleAlias.getData().stream().map(item -> item.getName()).collect(Collectors.joining(","));
flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(collect).concat("审批"); // flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(collect).concat("审批");
workTicket.setNextStepOperator(collect); // workTicket.setNextStepOperator(collect);
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
log.error("R<List<User>> roleAlias = userClient.userListByRoleAlias(workTicket.getTenantId(), response.getNextStepOperator())"); // log.error("R<List<User>> roleAlias = userClient.userListByRoleAlias(workTicket.getTenantId(), response.getNextStepOperator())");
log.error("获取用户信息失败"); // log.error("获取用户信息失败");
workTicket.setNextStepOperator(null); // workTicket.setNextStepOperator(null);
} // }
workTicket.setNextStepOperator(response.getNextStepOperator());
} }
//如果taskId为空 或 flowStatus = 99 //如果taskId为空
if (StringUtils.isEmpty(taskId) || 99 == flowStatus) { String taskId = response.getTaskId();
flowDescription = "结束"; if (StringUtils.isEmpty(taskId)) {
workTicket.setFlowDescription(flowDescription); workTicket.setFlowDescription("结束");
workTicket.setFlowTaskId(" "); workTicket.setFlowTaskId(" ");
workTicket.setFlowTaskName("结束"); workTicket.setFlowTaskName("结束");
workTicket.setNextStepOperator(null); workTicket.setNextStepOperator(" ");
workTicket.setStepOperator(null); workTicket.setStepOperator(" ");
} else { } else {
workTicket.setFlowTaskId(taskId);
workTicket.setFlowTaskName(response.getTaskName());
workTicket.setFlowDescription(flowDescription); workTicket.setFlowDescription(flowDescription);
} }
//如果下一个审批人【nextStepOperator】是null设为-1
if (StringUtils.isEmpty(nextStepOperator)) {
workTicket.setNextStepOperator(null);
}
System.out.println("workTicket = " + workTicket);
} }
@ -700,7 +681,8 @@ public class TicketProcessServiceImpl implements TicketProcessService {
} }
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
if ((workTicket.getIsSafety() == null && workTicket.getIsHazard() == null && workTicket.getIsLimited() == null && workTicket.getIsRailway() == null) || (workTicket.getIsSafety() == null || workTicket.getIsHazard() == null || workTicket.getIsLimited() == null || workTicket.getIsRailway() == null)) { if ((workTicket.getIsSafety() == null && workTicket.getIsHazard() == null && workTicket.getIsLimited() == null && workTicket.getIsRailway() == null)
|| (workTicket.getIsSafety() == null || workTicket.getIsHazard() == null || workTicket.getIsLimited() == null || workTicket.getIsRailway() == null)) {
extractedWithWord(response, workTicketInfoMap); extractedWithWord(response, workTicketInfoMap);
return; return;
} }
@ -711,24 +693,59 @@ public class TicketProcessServiceImpl implements TicketProcessService {
return; return;
} }
List<File> docFileList = new ArrayList<>(); List<File> docFileList = new ArrayList<>();
docFileList.add(new File("template/电气第一种工作票模版.docx"));
// /template/secondary/工作票安全措施附页.docx
String os = System.getProperty("os.name");
String prefix = null;
//Windows操作系统
if (os != null && os.toLowerCase().startsWith("windows")) {
prefix = "hzims-service/ticket/src/main/resources/template";
} else {
prefix = "/data/hzims/ticket/word/template/ticket";
}
docFileList.add(new File(prefix + "/电气第一种工作票模版.docx"));
//安全隔离措施附页 (true,展示附件,false,不展示附件) //安全隔离措施附页 (true,展示附件,false,不展示附件)
if (workTicket.getIsSafety()) { if (workTicket.getIsSafety()) {
setWorkTicketPrincipalChange(docFileList); addFile(prefix, "/secondary/工作票安全措施附页.docx", docFileList);
// setWorkTicketPrincipalChange(docFileList);
} }
//危险点分析与预控措施票 (true,展示附件,false,不展示附件) //危险点分析与预控措施票 (true,展示附件,false,不展示附件)
if (workTicket.getIsSafety()) { if (workTicket.getIsSafety()) {
setWorkTicketHazardPointChange(docFileList); addFile(prefix, "/secondary/工作票危险点分析及控制措施票.docx", docFileList);
// setWorkTicketHazardPointChange(docFileList);
} }
//动火工作票 (true,展示附件,false,不展示附件) //动火工作票 (true,展示附件,false,不展示附件)
if (workTicket.getIsRailway()) { if (workTicket.getIsRailway()) {
setWorkTicketRailwayChange(docFileList); addFile(prefix, "/secondary/动火工作票.docx", docFileList);
// setWorkTicketRailwayChange(docFileList);
} }
//有限空间监测记录单(true,展示附件,false,不展示附件) //有限空间监测记录单(true,展示附件,false,不展示附件)
if (workTicket.getIsLimited()) { if (workTicket.getIsLimited()) {
setWorkTicketLimitedChange(docFileList); addFile(prefix, "/secondary/有限空间监测记录单.docx", docFileList);
// setWorkTicketLimitedChange(docFileList);
} }
MergeDocUtils.mergeDoc(docFileList, response);
String name = LocalDate.now() + "-" + UUID.randomUUID().toString().replaceAll("-", "");
String docPath = null;
if (os != null && os.toLowerCase().startsWith("windows")) {
docPath = "D:\\导出excel\\";
} else {
docPath = "/data/hzims/ticket/word/template/ticket/ouput/";
}
docPath = docPath + name + ".docx";
log.info("输出word路径:{}", docPath);
//导入文档
File file = new File(docPath);
MergeDocUtils.mergeDoc(docFileList, file);
XWPFDocument xwpfDocument = WordExportUtil.exportWord07(docPath, workTicketInfoMap);
xwpfDocument.write(response.getOutputStream());
//删除路径
file.delete();
} }
@ -760,7 +777,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
private Map<String, Object> convertMap(WorkTicketVo workTicketVo) { private Map<String, Object> convertMap(WorkTicketVo workTicketVo) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
//1. 工作对象 //1. 工作对象
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMapResult(workTicket, result); Map<String, Object> workTicketInfoMap = PdfUtils.objectToMapResult(workTicket, result);
//安全隔离措施附页 (true,展示附件,false,不展示附件 //安全隔离措施附页 (true,展示附件,false,不展示附件
@ -777,12 +793,15 @@ public class TicketProcessServiceImpl implements TicketProcessService {
log.info("安全措施: {}", safetyMeasuresList); log.info("安全措施: {}", safetyMeasuresList);
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) { if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
Map<String, Object> workTicketInfoMap1 = new HashMap<>(); Map<String, Object> workTicketInfoMap1 = new HashMap<>();
Map<String, List<WorkTicketSafetyMeasureEntity>> measureMap = safetyMeasuresList.stream().collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType)); Map<String, List<WorkTicketSafetyMeasureEntity>> measureMap = safetyMeasuresList.stream().
Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants()).forEach(measureEnum -> { collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType));
Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants())
.forEach(measureEnum -> {
if (CollectionUtil.isNotEmpty(measureMap.get(measureEnum.getType()))) { if (CollectionUtil.isNotEmpty(measureMap.get(measureEnum.getType()))) {
List<Map<String, Object>> mapList = new ArrayList<>(); List<Map<String, Object>> mapList = new ArrayList<>();
int tempIndex = 1, index = 1; int tempIndex = 1, index = 1;
List<WorkTicketSafetyMeasureEntity> workTicketSafetyMeasureEntities = measureMap.get(measureEnum.getType()); List<WorkTicketSafetyMeasureEntity> workTicketSafetyMeasureEntities = measureMap
.get(measureEnum.getType());
for (WorkTicketSafetyMeasureEntity measureVO : workTicketSafetyMeasureEntities) { for (WorkTicketSafetyMeasureEntity measureVO : workTicketSafetyMeasureEntities) {
String type = measureEnum.getType(); String type = measureEnum.getType();
if (tempIndex != Integer.valueOf(type)) { if (tempIndex != Integer.valueOf(type)) {
@ -793,58 +812,21 @@ public class TicketProcessServiceImpl implements TicketProcessService {
Map<String, Object> map = PdfUtils.objectToMap(measureVO, true); Map<String, Object> map = PdfUtils.objectToMap(measureVO, true);
map.put("index", index); map.put("index", index);
map.put("safetyMeasure", ObjectUtil.isNotEmpty(map.get("measure")) ? map.get("measure") : null); map.put("safetyMeasure", ObjectUtil.isNotEmpty(map.get("measure")) ? map.get("measure") : null);
String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus().equals(measureVO.getStatus()) ? "√" : ""; String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus()
.equals(measureVO.getStatus()) ? "√" : "";
map.put("status", status); map.put("status", status);
mapList.add(map); mapList.add(map);
index++; index++;
} }
workTicketInfoMap1.put(measureEnum.getConvertAttributes(), mapList); workTicketInfoMap1.put(measureEnum.getConvertAttributes(), mapList);
} else { } else {
workTicketInfoMap1.put(measureEnum.getConvertAttributes(), new ArrayList<WorkTicketSafetyMeasureEntity>()); workTicketInfoMap1.put(measureEnum.getConvertAttributes(),
new ArrayList<WorkTicketSafetyMeasureEntity>());
} }
}); });
// 工作地点保留带电部位或注意事项 // 工作地点保留带电部位或注意事项
List<Map<String, Object>> matterLibraryListFive1 = workTicketInfoMap1.get("matterLibraryListFive") == null ? new ArrayList<Map<String, Object>>() : (List<Map<String, Object>>) workTicketInfoMap1.get("matterLibraryListFive"); this.matterLibraryListWithMap(workTicketInfoMap1);
List<Map<String, Object>> matterLibraryListFlow1 = workTicketInfoMap1.get("matterLibraryListFlow") == null ? new ArrayList<Map<String, Object>>() : (List<Map<String, Object>>) workTicketInfoMap1.get("matterLibraryListFlow");
System.out.println("matterLibraryListFive1 = " + matterLibraryListFive1);
System.out.println("matterLibraryListFlow1 = " + matterLibraryListFlow1);
if (matterLibraryListFive1 != null && matterLibraryListFlow1 != null) {
List<Map<String, Object>> matterLibraryListFive = matterLibraryListFive1;
// (4)补充工作地点保留带电部位和补充安全措施
List<Map<String, Object>> matterLibraryListFlow = matterLibraryListFlow1;
if (CollectionUtils.isNotEmpty(matterLibraryListFive) && CollectionUtils.isNotEmpty(matterLibraryListFlow)) {
if (matterLibraryListFive.size() < matterLibraryListFlow.size()) {
for (Map<String, Object> stringObjectMap : matterLibraryListFlow) {
matterLibraryListFive.add(new HashMap<>());
}
}
if (matterLibraryListFive.size() > matterLibraryListFlow.size()) {
for (Map<String, Object> stringObjectMap : matterLibraryListFive) {
matterLibraryListFlow.add(new HashMap<>());
}
}
workTicketInfoMap1.put("matterLibraryListFive", CollectionUtils.isEmpty(matterLibraryListFive) ? new ArrayList<>() : matterLibraryListFive);
workTicketInfoMap1.put("matterLibraryListFlow", CollectionUtils.isEmpty(matterLibraryListFlow) ? new ArrayList<>() : matterLibraryListFlow);
}
}
if (CollectionUtils.isEmpty(matterLibraryListFive1)) {
workTicketInfoMap1.put("matterLibraryListFive", new ArrayList<>());
}
if (CollectionUtils.isEmpty(matterLibraryListFlow1)) {
workTicketInfoMap1.put("matterLibraryListFlow", new ArrayList<>());
}
result.putAll(workTicketInfoMap1); result.putAll(workTicketInfoMap1);
} }
@ -889,19 +871,105 @@ public class TicketProcessServiceImpl implements TicketProcessService {
List<Map<String, Object>> collect = ticketInfoDangers.stream().map(item -> { List<Map<String, Object>> collect = ticketInfoDangers.stream().map(item -> {
Map<String, Object> newItem = new HashMap<>(); Map<String, Object> newItem = new HashMap<>();
newItem.put("index", index); newItem.put("index", index);
newItem.put("maintenance", item.getMaintenance()); newItem.put("maintenance", item.getMaintenance() == null ? "\u00A0" : item.getMaintenance());
newItem.put("dangerousPoint", item.getDangerousPoint()); newItem.put("dangerousPoint", item.getDangerousPoint() == null ? "\u00A0" : item.getDangerousPoint());
return newItem; return newItem;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
map.put("ticketInfoDangers", collect); map.put("ticketInfoDangers", CollectionUtils.isNotEmpty(collect) ? collect
: new ArrayList<Map<String, Object>>());
result.putAll(map); result.putAll(map);
} }
//7. 是否包含
isExists(result);
return result; return result;
} }
/** /**
* 工作地点保留带电部位或注意事项
* 2 个map集合转成一个map集合
* @param workTicketInfoMap
*/
private static void matterLibraryListWithMap(Map<String, Object> workTicketInfoMap) {
List<Map<String, Object>> matterLibraryListFive1 =
workTicketInfoMap.get("matterLibraryListFive") == null ? new ArrayList<Map<String, Object>>()
: (List<Map<String, Object>>) workTicketInfoMap.get("matterLibraryListFive");
List<Map<String, Object>> matterLibraryListFlow1 = workTicketInfoMap.get("matterLibraryListFlow") == null
? new ArrayList<Map<String, Object>>()
: (List<Map<String, Object>>) workTicketInfoMap.get("matterLibraryListFlow");
if (matterLibraryListFive1 != null && matterLibraryListFlow1 != null) {
List<Map<String, Object>> matterLibraryListFive = matterLibraryListFive1;
// (4)补充工作地点保留带电部位和补充安全措施
List<Map<String, Object>> matterLibraryListFlow = matterLibraryListFlow1;
//合成一个map
List<Map<String, Object>> maps = new ArrayList<>();
if (matterLibraryListFive.size() < matterLibraryListFlow.size()) {
for (int i = 0; i < matterLibraryListFlow.size(); i++) {
listWichMap(matterLibraryListFive, matterLibraryListFlow, maps, i);
}
}
if (matterLibraryListFive.size() > matterLibraryListFlow.size()) {
for (int i = 0; i < matterLibraryListFive.size(); i++) {
listWichMap(matterLibraryListFive, matterLibraryListFlow, maps, i);
}
}
if (matterLibraryListFive.size() == matterLibraryListFlow.size()) {
for (int i = 0; i < matterLibraryListFive.size(); i++) {
listWichMap(matterLibraryListFive, matterLibraryListFlow, maps, i);
}
}
workTicketInfoMap.put("matterLibraryList", CollectionUtils.isEmpty(maps) ? new ArrayList<>() : maps);
}
}
/**
* 判断是否包含是否存在
* @param result
*/
private static void isExists(Map<String, Object> result) {
if (!result.containsKey("ticketInfoDangers")) {
result.put("ticketInfoDangers",new ArrayList<Map<String, Object>>());
}
//项目名称
if (!result.containsKey("projectName")) {
result.put("projectName","\u00A0 ");
}
}
/**
* 两个List转成一个Map
*
* @param matterLibraryListFive 第一个List
* @param matterLibraryListFlow 第二个list
* @param maps 新的Map
* @param i 索引
*/
private static void listWichMap(List<Map<String, Object>> matterLibraryListFive, List<Map<String, Object>> matterLibraryListFlow, List<Map<String, Object>> maps, int i) {
Map<String, Object> stringObjectMap = matterLibraryListFive.get(i);
Map<String, Object> stringObjectMap1 = matterLibraryListFlow.get(i);
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("safetyMeasure", stringObjectMap.get("safetyMeasure"));
objectObjectHashMap.put("safetyMeasure1", stringObjectMap1.get("safetyMeasure"));
maps.add(objectObjectHashMap);
}
/**
* 对象转map * 对象转map
* *
* @param value * @param value
@ -913,11 +981,11 @@ public class TicketProcessServiceImpl implements TicketProcessService {
Map<String, Object> map = JSONObject.parseObject(jsonString, Map.class); Map<String, Object> map = JSONObject.parseObject(jsonString, Map.class);
Map<String, Object> newMap = new HashMap<>(); Map<String, Object> newMap = new HashMap<>();
for (Map.Entry<String, Object> stringObjectEntry : map.entrySet()) { for (Map.Entry<String, Object> stringObjectEntry : map.entrySet()) {
System.out.println("没转换的数据 " + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue()); log.info("没转换的数据 " + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue());
//如果包含直接跳过 //如果包含直接跳过
if (result.containsKey(stringObjectEntry.getKey())) { if (result.containsKey(stringObjectEntry.getKey())) {
System.out.println("跳过key : " + stringObjectEntry.getKey()); log.info("跳过key : " + stringObjectEntry.getKey());
continue; continue;
} }
@ -929,59 +997,27 @@ public class TicketProcessServiceImpl implements TicketProcessService {
} }
for (Map.Entry<String, Object> stringObjectEntry : newMap.entrySet()) { for (Map.Entry<String, Object> stringObjectEntry : newMap.entrySet()) {
System.out.println("数据转换的数据 " + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue()); log.info("数据转换的数据 " + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue());
} }
return newMap; return newMap;
} }
/**
* 对象转map
*/
private static <T> Map<String, Object> parseObjectMap(T target, Class clas) {
return JSONObject.parseObject(JSONObject.toJSONString(target), Map.class);
}
/** /**
* 安全隔离措施附页 * 添加文件
*/ *
@SneakyThrows * @param prefix
public void setWorkTicketPrincipalChange(List<File> docFileList) { * @param pathName
docFileList.add(new File("template/secondary/工作票安全措施附页.docx")); * @param docFileList
}
/**
* 危险点分析与预控措施票
*/
@SneakyThrows
public void setWorkTicketHazardPointChange(List<File> docFileList) {
docFileList.add(new File("template/secondary/工作票危险点分析及控制措施票.docx"));
}
/**
* 动火工作票
*/ */
@SneakyThrows private void addFile(String prefix, String pathName, List<File> docFileList) {
public void setWorkTicketRailwayChange(List<File> docFileList) { File file = new File(prefix + pathName);
File file = new File("template/secondary/动火工作票.docx");
docFileList.add(file); docFileList.add(file);
} }
/**
* 有限空间监测记录单(true,展示附件,false,不展示附件)
*/
@SneakyThrows
public void setWorkTicketLimitedChange(List<File> docFileList) {
File file = new File("template/secondary/有限空间监测记录单.docx");
docFileList.add(file);
}
/** /**
* value true转 false转 * value true转 false转
@ -997,7 +1033,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
} }
} }
} }

22
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/MergeDocUtils.java

@ -6,6 +6,7 @@ package com.hnac.hzims.ticket.utils;
* @Serial 1.0 * @Serial 1.0
* @Date 2023/5/23 16:42 * @Date 2023/5/23 16:42
*/ */
import cn.afterturn.easypoi.word.entity.MyXWPFDocument;
import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.BreakType; import org.apache.poi.xwpf.usermodel.BreakType;
import org.apache.poi.xwpf.usermodel.Document; import org.apache.poi.xwpf.usermodel.Document;
@ -14,44 +15,35 @@ import org.apache.poi.xwpf.usermodel.XWPFPictureData;
import org.apache.xmlbeans.XmlOptions; import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody;
import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/**
* 参数1:需要合并的word的文件对象list
* 参数2:合并之后word存储的全路径file对象
*/
public class MergeDocUtils { public class MergeDocUtils {
/** /**
* word文档合并 * word文档合并
*
* @param fileList 合并文档的路径 * @param fileList 合并文档的路径
* @param response 新的word
* @throws Exception * @throws Exception
*/ */
public static void mergeDoc(List<File> fileList, HttpServletResponse response)throws Exception { public static void mergeDoc(List<File> fileList, File ouput)throws Exception {
OutputStream dest = new FileOutputStream(ouput);
OutputStream dest = response.getOutputStream(); ArrayList<MyXWPFDocument> documentList = new ArrayList<>();
ArrayList<XWPFDocument> documentList = new ArrayList<XWPFDocument>(); MyXWPFDocument doc = null;
XWPFDocument doc = null;
for (int i = 0; i < fileList.size(); i++) { for (int i = 0; i < fileList.size(); i++) {
FileInputStream in = new FileInputStream(fileList.get(i).getPath()); FileInputStream in = new FileInputStream(fileList.get(i).getPath());
OPCPackage open = OPCPackage.open(in); OPCPackage open = OPCPackage.open(in);
XWPFDocument document = new XWPFDocument(open); MyXWPFDocument document = new MyXWPFDocument(open);
documentList.add(document); documentList.add(document);
} }
for (int i = 0; i < documentList.size(); i++) { for (int i = 0; i < documentList.size(); i++) {
doc = documentList.get(0); doc = documentList.get(0);
if (i == 0) { if (i == 0) {

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/PdfUtils.java

@ -261,7 +261,7 @@ public class PdfUtils {
|| "principalChangeTime".equals(field.getName()) || "principalChangeTime".equals(field.getName())
|| "principalName".equals(field.getName()) || "principalName".equals(field.getName())
|| "jobReceiver".equals(field.getName()) || "jobReceiver".equals(field.getName())
|| "jobReceiverDateTime".equals(field.getName()) || "jobReceiverTime".equals(field.getName())
|| "watchPrincipalEndTime".equals(field.getName()) || "watchPrincipalEndTime".equals(field.getName())
|| "licenseTime".equals(field.getName()) || "licenseTime".equals(field.getName())
|| "licensorName".equals(field.getName()) || "licensorName".equals(field.getName())

6
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketPrincipalChangeServiceImpl.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.hnac.hzims.ticket.constants.TicketConstants; import com.hnac.hzims.ticket.constants.TicketConstants;
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish; import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish;
import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto; import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto;
@ -71,6 +72,7 @@ public class WorkTicketPrincipalChangeServiceImpl extends BaseServiceImpl<WorkTi
/** /**
* 获取WorkTicketPrincipalChangeEntity - queryWrapper * 获取WorkTicketPrincipalChangeEntity - queryWrapper
*
* @param req * @param req
* @return * @return
*/ */
@ -101,11 +103,13 @@ public class WorkTicketPrincipalChangeServiceImpl extends BaseServiceImpl<WorkTi
queryWrapper.eq(WorkTicketPrincipalChangeEntity::getTicketId, ticketId); queryWrapper.eq(WorkTicketPrincipalChangeEntity::getTicketId, ticketId);
queryWrapper.orderByDesc(BaseEntity::getCreateTime); queryWrapper.orderByDesc(BaseEntity::getCreateTime);
queryWrapper.last("limit 1"); queryWrapper.last("limit 1");
return this.list(queryWrapper).get(0); List<WorkTicketPrincipalChangeEntity> list = this.list(queryWrapper);
return CollectionUtils.isNotEmpty(list) ? list.get(0) : null;
} }
/** /**
* 更新 * 更新
*
* @param workTicketPrincipalChange * @param workTicketPrincipalChange
*/ */
@Override @Override

BIN
hzims-service/ticket/src/main/resources/template/secondary/工作票危险点分析及控制措施票.docx

Binary file not shown.

BIN
hzims-service/ticket/src/main/resources/template/电气第一种工作票模版.docx

Binary file not shown.
Loading…
Cancel
Save