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. 389
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  5. 26
      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. 146
      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)) {
//执行业务方法
try {
response.setNum(1);
ticketService.calculate(response);
} catch (Exception e) {
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 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;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
//@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;

389
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 java.io.File;
import java.io.FileOutputStream;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@ -202,6 +203,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
log.info("获取businessKey: {}", response.getBusinessKey());
log.info("获取taskId: {}", response.getTaskId());
log.info("获取下一个审批人是: {}", response.getNextStepOperator());
log.info("获取下一个用户Id是: {}", response.getUserId());
log.info("获取当前任务名称是: {}", response.getTaskName());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单
@ -222,22 +224,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey);
if (ObjectUtils.isEmpty(workTicketInfo)) {
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;
}
try {
@ -258,12 +244,10 @@ public class TicketProcessServiceImpl implements TicketProcessService {
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
log.info("获取安全措施的数据:{}", safetyMeasuresList);
safetyMeasuresList.forEach(item -> {
if (ObjectUtils.isEmpty(item.getId())) {
if (ObjectUtils.isNotEmpty(item.getTicketId())) {
LambdaQueryWrapper<WorkTicketSafetyMeasureEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(WorkTicketSafetyMeasureEntity::getTicketId, workTicketInfo.getId());
queryWrapper.eq(WorkTicketSafetyMeasureEntity::getTicketId, item.getTicketId());
workTicketSafetyMeasureService.update(item, queryWrapper);
} else {
workTicketSafetyMeasureService.updateById(item);
}
});
}
@ -364,10 +348,18 @@ public class TicketProcessServiceImpl implements TicketProcessService {
//工作票危险点分析及控制措施票
try {
if (workTicketInfo.getIsHazard()) {
if (workTicket.getIsHazard()) {
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
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) {
@ -383,14 +375,10 @@ public class TicketProcessServiceImpl implements TicketProcessService {
* @param 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 = "";
Integer flowStatus = workTicket.getFlowStatus();
//如果response.getHandleType() 是0使用户
if ("0".equals(response.getHandleType())) {
String nextStepOperator = response.getNextStepOperator();
Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ? nextStepOperator.substring(9) : null);
if (taskUser != null) {
//下一个审批人
@ -399,47 +387,40 @@ public class TicketProcessServiceImpl implements TicketProcessService {
flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(stepUser.getName()).concat("审批");
workTicket.setNextStepOperator(stepUser.getName());
}
}else {
} else {
workTicket.setNextStepOperator(null);
}
}
//如果response.getHandleType() 是1使角色
if ("1".equals(response.getHandleType())) {
log.info("获取角色信息" + response.getNextStepOperator());
//根据角色别名获取用户信息
try {
R<List<User>> roleAlias = userClient.relationUserListByRoleAlias(workTicket.getTenantId(), workTicket.getCreateDept(), response.getNextStepOperator());
String collect = roleAlias.getData().stream().map(item -> item.getName()).collect(Collectors.joining(","));
flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(collect).concat("审批");
workTicket.setNextStepOperator(collect);
} catch (Exception e) {
e.printStackTrace();
log.error("R<List<User>> roleAlias = userClient.userListByRoleAlias(workTicket.getTenantId(), response.getNextStepOperator())");
log.error("获取用户信息失败");
workTicket.setNextStepOperator(null);
}
// try {
// R<List<User>> roleAlias = userClient.relationUserListByRoleAlias(workTicket.getTenantId(), workTicket.getCreateDept(), response.getNextStepOperator());
// String collect = roleAlias.getData().stream().map(item -> item.getName()).collect(Collectors.joining(","));
// flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(collect).concat("审批");
// workTicket.setNextStepOperator(collect);
// } catch (Exception e) {
// e.printStackTrace();
// log.error("R<List<User>> roleAlias = userClient.userListByRoleAlias(workTicket.getTenantId(), response.getNextStepOperator())");
// log.error("获取用户信息失败");
// workTicket.setNextStepOperator(null);
// }
workTicket.setNextStepOperator(response.getNextStepOperator());
}
//如果taskId为空 或 flowStatus = 99
if (StringUtils.isEmpty(taskId) || 99 == flowStatus) {
flowDescription = "结束";
workTicket.setFlowDescription(flowDescription);
workTicket.setFlowTaskId("");
//如果taskId为空
String taskId = response.getTaskId();
if (StringUtils.isEmpty(taskId)) {
workTicket.setFlowDescription("结束");
workTicket.setFlowTaskId(" ");
workTicket.setFlowTaskName("结束");
workTicket.setNextStepOperator(null);
workTicket.setStepOperator(null);
workTicket.setNextStepOperator(" ");
workTicket.setStepOperator(" ");
} else {
workTicket.setFlowTaskId(taskId);
workTicket.setFlowTaskName(response.getTaskName());
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();
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);
return;
}
@ -711,24 +693,59 @@ public class TicketProcessServiceImpl implements TicketProcessService {
return;
}
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,不展示附件)
if (workTicket.getIsSafety()) {
setWorkTicketPrincipalChange(docFileList);
addFile(prefix, "/secondary/工作票安全措施附页.docx", docFileList);
// setWorkTicketPrincipalChange(docFileList);
}
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
if (workTicket.getIsSafety()) {
setWorkTicketHazardPointChange(docFileList);
addFile(prefix, "/secondary/工作票危险点分析及控制措施票.docx", docFileList);
// setWorkTicketHazardPointChange(docFileList);
}
//动火工作票 (true,展示附件,false,不展示附件)
if (workTicket.getIsRailway()) {
setWorkTicketRailwayChange(docFileList);
addFile(prefix, "/secondary/动火工作票.docx", docFileList);
// setWorkTicketRailwayChange(docFileList);
}
//有限空间监测记录单(true,展示附件,false,不展示附件)
if (workTicket.getIsLimited()) {
setWorkTicketLimitedChange(docFileList);
addFile(prefix, "/secondary/有限空间监测记录单.docx", docFileList);
// setWorkTicketLimitedChange(docFileList);
}
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/";
}
MergeDocUtils.mergeDoc(docFileList, response);
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) {
Map<String, Object> result = new HashMap<>();
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
//1. 工作对象
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMapResult(workTicket, result);
//安全隔离措施附页 (true,展示附件,false,不展示附件
@ -777,74 +793,40 @@ public class TicketProcessServiceImpl implements TicketProcessService {
log.info("安全措施: {}", safetyMeasuresList);
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
Map<String, Object> workTicketInfoMap1 = new HashMap<>();
Map<String, List<WorkTicketSafetyMeasureEntity>> measureMap = safetyMeasuresList.stream().collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType));
Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants()).forEach(measureEnum -> {
if (CollectionUtil.isNotEmpty(measureMap.get(measureEnum.getType()))) {
List<Map<String, Object>> mapList = new ArrayList<>();
int tempIndex = 1, index = 1;
List<WorkTicketSafetyMeasureEntity> workTicketSafetyMeasureEntities = measureMap.get(measureEnum.getType());
for (WorkTicketSafetyMeasureEntity measureVO : workTicketSafetyMeasureEntities) {
String type = measureEnum.getType();
if (tempIndex != Integer.valueOf(type)) {
index = 1;
tempIndex++;
Map<String, List<WorkTicketSafetyMeasureEntity>> measureMap = safetyMeasuresList.stream().
collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType));
Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants())
.forEach(measureEnum -> {
if (CollectionUtil.isNotEmpty(measureMap.get(measureEnum.getType()))) {
List<Map<String, Object>> mapList = new ArrayList<>();
int tempIndex = 1, index = 1;
List<WorkTicketSafetyMeasureEntity> workTicketSafetyMeasureEntities = measureMap
.get(measureEnum.getType());
for (WorkTicketSafetyMeasureEntity measureVO : workTicketSafetyMeasureEntities) {
String type = measureEnum.getType();
if (tempIndex != Integer.valueOf(type)) {
index = 1;
tempIndex++;
}
log.info("获取安全措施的信息: {}", measureVO);
Map<String, Object> map = PdfUtils.objectToMap(measureVO, true);
map.put("index", index);
map.put("safetyMeasure", ObjectUtil.isNotEmpty(map.get("measure")) ? map.get("measure") : null);
String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus()
.equals(measureVO.getStatus()) ? "√" : "";
map.put("status", status);
mapList.add(map);
index++;
}
workTicketInfoMap1.put(measureEnum.getConvertAttributes(), mapList);
} else {
workTicketInfoMap1.put(measureEnum.getConvertAttributes(),
new ArrayList<WorkTicketSafetyMeasureEntity>());
}
log.info("获取安全措施的信息: {}", measureVO);
Map<String, Object> map = PdfUtils.objectToMap(measureVO, true);
map.put("index", index);
map.put("safetyMeasure", ObjectUtil.isNotEmpty(map.get("measure")) ? map.get("measure") : null);
String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus().equals(measureVO.getStatus()) ? "√" : "";
map.put("status", status);
mapList.add(map);
index++;
}
workTicketInfoMap1.put(measureEnum.getConvertAttributes(), mapList);
} else {
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");
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<>());
}
this.matterLibraryListWithMap(workTicketInfoMap1);
result.putAll(workTicketInfoMap1);
}
@ -889,19 +871,105 @@ public class TicketProcessServiceImpl implements TicketProcessService {
List<Map<String, Object>> collect = ticketInfoDangers.stream().map(item -> {
Map<String, Object> newItem = new HashMap<>();
newItem.put("index", index);
newItem.put("maintenance", item.getMaintenance());
newItem.put("dangerousPoint", item.getDangerousPoint());
newItem.put("maintenance", item.getMaintenance() == null ? "\u00A0" : item.getMaintenance());
newItem.put("dangerousPoint", item.getDangerousPoint() == null ? "\u00A0" : item.getDangerousPoint());
return newItem;
}).collect(Collectors.toList());
map.put("ticketInfoDangers", collect);
map.put("ticketInfoDangers", CollectionUtils.isNotEmpty(collect) ? collect
: new ArrayList<Map<String, Object>>());
result.putAll(map);
}
//7. 是否包含
isExists(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
*
* @param value
@ -913,11 +981,11 @@ public class TicketProcessServiceImpl implements TicketProcessService {
Map<String, Object> map = JSONObject.parseObject(jsonString, Map.class);
Map<String, Object> newMap = new HashMap<>();
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())) {
System.out.println("跳过key : " + stringObjectEntry.getKey());
log.info("跳过key : " + stringObjectEntry.getKey());
continue;
}
@ -929,59 +997,27 @@ public class TicketProcessServiceImpl implements TicketProcessService {
}
for (Map.Entry<String, Object> stringObjectEntry : newMap.entrySet()) {
System.out.println("数据转换的数据 " + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue());
log.info("数据转换的数据 " + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue());
}
return newMap;
}
/**
* 对象转map
*/
private static <T> Map<String, Object> parseObjectMap(T target, Class clas) {
return JSONObject.parseObject(JSONObject.toJSONString(target), Map.class);
}
/**
* 安全隔离措施附页
*/
@SneakyThrows
public void setWorkTicketPrincipalChange(List<File> docFileList) {
docFileList.add(new File("template/secondary/工作票安全措施附页.docx"));
}
/**
* 危险点分析与预控措施票
*/
@SneakyThrows
public void setWorkTicketHazardPointChange(List<File> docFileList) {
docFileList.add(new File("template/secondary/工作票危险点分析及控制措施票.docx"));
}
/**
* 动火工作票
* 添加文件
*
* @param prefix
* @param pathName
* @param docFileList
*/
@SneakyThrows
public void setWorkTicketRailwayChange(List<File> docFileList) {
File file = new File("template/secondary/动火工作票.docx");
private void addFile(String prefix, String pathName, List<File> docFileList) {
File file = new File(prefix + pathName);
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转
@ -997,7 +1033,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
}
}
}

26
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
* @Date 2023/5/23 16:42
*/
import cn.afterturn.easypoi.word.entity.MyXWPFDocument;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.BreakType;
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.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.time.LocalDate;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 参数1:需要合并的word的文件对象list
* 参数2:合并之后word存储的全路径file对象
*/
public class MergeDocUtils {
/**
* word文档合并
* @param fileList 合并文档的路径
* @param response 新的word
* word文档合并
*
* @param fileList 合并文档的路径
* @throws Exception
*/
public static void mergeDoc(List<File> fileList, HttpServletResponse response)throws Exception {
OutputStream dest = response.getOutputStream();
ArrayList<XWPFDocument> documentList = new ArrayList<XWPFDocument>();
XWPFDocument doc = null;
public static void mergeDoc(List<File> fileList, File ouput)throws Exception {
OutputStream dest = new FileOutputStream(ouput);
ArrayList<MyXWPFDocument> documentList = new ArrayList<>();
MyXWPFDocument doc = null;
for (int i = 0; i < fileList.size(); i++) {
FileInputStream in = new FileInputStream(fileList.get(i).getPath());
OPCPackage open = OPCPackage.open(in);
XWPFDocument document = new XWPFDocument(open);
MyXWPFDocument document = new MyXWPFDocument(open);
documentList.add(document);
}
for (int i = 0; i < documentList.size(); i++) {
doc = documentList.get(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())
|| "principalName".equals(field.getName())
|| "jobReceiver".equals(field.getName())
|| "jobReceiverDateTime".equals(field.getName())
|| "jobReceiverTime".equals(field.getName())
|| "watchPrincipalEndTime".equals(field.getName())
|| "licenseTime".equals(field.getName())
|| "licensorName".equals(field.getName())

146
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.UpdateWrapper;
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.twoTicket.entity.WorkTicketFinish;
import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto;
@ -40,82 +41,85 @@ import java.util.List;
@Slf4j
public class WorkTicketPrincipalChangeServiceImpl extends BaseServiceImpl<WorkTicketPrincipalChangeMapper, WorkTicketPrincipalChangeEntity> implements IWorkTicketPrincipalChangeService {
private final WorkTicketInfoMapper workTicketInfoMapper;
private final WorkTicketInfoMapper workTicketInfoMapper;
@Override
public R<IPage<WorkTicketPrincipalChangeVO>> queryList(WorkTicketPrincipalChangeDto req, Query query) {
IPage pages = super.page(Condition.getPage(query),this.getQueryWrapper(req));
return R.data(pages.setRecords(WorkTicketPrincipalChangeWrappper.build().listVO(pages.getRecords())));
}
@Override
public R<IPage<WorkTicketPrincipalChangeVO>> queryList(WorkTicketPrincipalChangeDto req, Query query) {
IPage pages = super.page(Condition.getPage(query), this.getQueryWrapper(req));
return R.data(pages.setRecords(WorkTicketPrincipalChangeWrappper.build().listVO(pages.getRecords())));
}
@Override
public List<WorkTicketPrincipalChangeVO> list(WorkTicketPrincipalChangeDto req) {
List<WorkTicketPrincipalChangeEntity> workTicketPrincipalChangeEntityList = this.list(this.getQueryWrapper(req));
return WorkTicketPrincipalChangeWrappper.build().listVO(workTicketPrincipalChangeEntityList);
}
@Override
public List<WorkTicketPrincipalChangeVO> list(WorkTicketPrincipalChangeDto req) {
List<WorkTicketPrincipalChangeEntity> workTicketPrincipalChangeEntityList = this.list(this.getQueryWrapper(req));
return WorkTicketPrincipalChangeWrappper.build().listVO(workTicketPrincipalChangeEntityList);
}
@Override
public R changePrincipal(WorkTicketInfoDto infoDto, WorkTicketPrincipalChangeDto changeDto) {
/**当前流程只能在签发阶段进行**/
if(!TicketConstants.FirstWorkTicketFlowStatusEnum.SIGN.getStatus().equals(infoDto.getStatus())){
return R.fail("该操作目前只支持在签发阶段签发人操作");
}
LambdaUpdateWrapper<WorkTicketInfoEntity> updateWrapper = new LambdaUpdateWrapper();
updateWrapper.set(WorkTicketInfoEntity::getPrincipal,infoDto.getPrincipal());
updateWrapper.eq(WorkTicketInfoEntity::getId,infoDto.getId());
workTicketInfoMapper.update(null,updateWrapper);
/**保存负责人变更信息**/
this.save(changeDto);
return R.success("变更成功");
}
@Override
public R changePrincipal(WorkTicketInfoDto infoDto, WorkTicketPrincipalChangeDto changeDto) {
/**当前流程只能在签发阶段进行**/
if (!TicketConstants.FirstWorkTicketFlowStatusEnum.SIGN.getStatus().equals(infoDto.getStatus())) {
return R.fail("该操作目前只支持在签发阶段签发人操作");
}
LambdaUpdateWrapper<WorkTicketInfoEntity> updateWrapper = new LambdaUpdateWrapper();
updateWrapper.set(WorkTicketInfoEntity::getPrincipal, infoDto.getPrincipal());
updateWrapper.eq(WorkTicketInfoEntity::getId, infoDto.getId());
workTicketInfoMapper.update(null, updateWrapper);
/**保存负责人变更信息**/
this.save(changeDto);
return R.success("变更成功");
}
/**
* 获取WorkTicketPrincipalChangeEntity - queryWrapper
* @param req
* @return
*/
private LambdaQueryWrapper getQueryWrapper(WorkTicketPrincipalChangeDto req){
LambdaQueryWrapper<WorkTicketPrincipalChangeEntity> queryWrapper = new LambdaQueryWrapper<>();
if(Func.isNotEmpty(req.getTicketId())){
queryWrapper.eq(WorkTicketPrincipalChangeEntity::getTicketId,req.getTicketId());
}
if(Func.isNotEmpty(req.getInitialPrincipal())){
queryWrapper.eq(WorkTicketPrincipalChangeEntity::getInitialPrincipal,req.getInitialPrincipal());
}
if(Func.isNotEmpty(req.getChangePrincipal())){
queryWrapper.eq(WorkTicketPrincipalChangeEntity::getChangePrincipal,req.getChangePrincipal());
}
return queryWrapper;
}
/**
* 获取WorkTicketPrincipalChangeEntity - queryWrapper
*
* @param req
* @return
*/
private LambdaQueryWrapper getQueryWrapper(WorkTicketPrincipalChangeDto req) {
LambdaQueryWrapper<WorkTicketPrincipalChangeEntity> queryWrapper = new LambdaQueryWrapper<>();
if (Func.isNotEmpty(req.getTicketId())) {
queryWrapper.eq(WorkTicketPrincipalChangeEntity::getTicketId, req.getTicketId());
}
if (Func.isNotEmpty(req.getInitialPrincipal())) {
queryWrapper.eq(WorkTicketPrincipalChangeEntity::getInitialPrincipal, req.getInitialPrincipal());
}
if (Func.isNotEmpty(req.getChangePrincipal())) {
queryWrapper.eq(WorkTicketPrincipalChangeEntity::getChangePrincipal, req.getChangePrincipal());
}
return queryWrapper;
}
/**
* 工作票负责人变更
*
* @param ticketId
* @return
*/
@Override
public WorkTicketPrincipalChangeEntity selectByTicketId(Long ticketId) {
LambdaQueryWrapper<WorkTicketPrincipalChangeEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(WorkTicketPrincipalChangeEntity::getTicketId,ticketId);
queryWrapper.orderByDesc(BaseEntity::getCreateTime);
queryWrapper.last("limit 1");
return this.list(queryWrapper).get(0);
}
/**
* 工作票负责人变更
*
* @param ticketId
* @return
*/
@Override
public WorkTicketPrincipalChangeEntity selectByTicketId(Long ticketId) {
LambdaQueryWrapper<WorkTicketPrincipalChangeEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(WorkTicketPrincipalChangeEntity::getTicketId, ticketId);
queryWrapper.orderByDesc(BaseEntity::getCreateTime);
queryWrapper.last("limit 1");
List<WorkTicketPrincipalChangeEntity> list = this.list(queryWrapper);
return CollectionUtils.isNotEmpty(list) ? list.get(0) : null;
}
/**
* 更新
* @param workTicketPrincipalChange
*/
@Override
public void updateByTicketId(WorkTicketPrincipalChangeEntity workTicketPrincipalChange) {
if (workTicketPrincipalChange.getId() == null) {
UpdateWrapper<WorkTicketPrincipalChangeEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda().eq(WorkTicketPrincipalChangeEntity::getTicketId, workTicketPrincipalChange.getTicketId());
this.update(workTicketPrincipalChange, updateWrapper);
return;
}
this.updateById(workTicketPrincipalChange);
}
/**
* 更新
*
* @param workTicketPrincipalChange
*/
@Override
public void updateByTicketId(WorkTicketPrincipalChangeEntity workTicketPrincipalChange) {
if (workTicketPrincipalChange.getId() == null) {
UpdateWrapper<WorkTicketPrincipalChangeEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda().eq(WorkTicketPrincipalChangeEntity::getTicketId, workTicketPrincipalChange.getTicketId());
this.update(workTicketPrincipalChange, updateWrapper);
return;
}
this.updateById(workTicketPrincipalChange);
}
}

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