Browse Source

新工作票修改

zhongwei
段飞宇 2 years ago
parent
commit
6218f64ec5
  1. 4
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/WorkTicketConstants.java
  2. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java
  3. 1
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java
  4. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/ProcessWorkFlowResponse.java
  5. 17
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java
  6. 7
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java
  7. 266
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  8. 7
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java
  9. 71
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java

4
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/WorkTicketConstants.java

@ -19,7 +19,9 @@ public interface WorkTicketConstants {
TWO("2","matterLibraryListTwo"),
/**第三种安措**/
THREE("3","matterLibraryListThree"),
FOUR("4","matterLibraryListFour")
FOUR("4","matterLibraryListFour"),
Five("5","matterLibraryListFive"),
Flow("6","matterLibraryListFlow"),
;
@Getter
private String type;

3
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java

@ -10,6 +10,5 @@ package com.hnac.hzims.ticket.processflow.constant;
*/
public class TicketProcessConstant {
// public final static String STARTEVENT = "startEvent1";
public final static String STARTEVENT = "workTicket";
public final static String STARTEVENT = "workTicketFlow";
}

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

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

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

@ -55,4 +55,7 @@ public class ProcessWorkFlowResponse implements Serializable {
*/
private String handleType;
private Integer num;
}

17
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java

@ -50,22 +50,7 @@ public class TicketProcessController {
@PostMapping("/startUp")
public R start(@RequestBody WorkTicketVo workTicketVo) {
ticketProcessService.startUp(workTicketVo);
return R.success("启动流程成功");
}
/**
* 预览
*
* @param ticketType
* @param ticketId
*/
@GetMapping("/preview")
@ApiOperation(value = "预览")
@ApiOperationSupport(order = 11)
public R preview(@RequestParam @ApiParam("票据类型") String ticketType, @RequestParam @ApiParam("票据ID") Long ticketId) {
String preview = ticketProcessService.preview(ticketType, ticketId);
return R.data(preview);
return R.success("申请开票成功");
}

7
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java

@ -27,13 +27,6 @@ public interface TicketProcessService {
void findPending(ProcessWorkFlowResponse response);
/**
* 预览
* @param ticketType
* @param ticketId
*/
String preview(String ticketType, Long ticketId);
/**
* 新预览

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

@ -8,8 +8,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient;
@ -22,9 +20,11 @@ import com.hnac.hzims.ticket.constants.TicketConstants;
import com.hnac.hzims.ticket.constants.WorkTicketConstants;
import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker;
import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse;
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger;
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish;
import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService;
import com.hnac.hzims.ticket.twoTicket.service.IWorkTicketFinishService;
import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService;
import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService;
import com.hnac.hzims.ticket.twoTicket.vo.process.FristWorkTicketVo;
import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo;
@ -34,14 +34,12 @@ import com.hnac.hzims.ticket.workTicket.entity.*;
import com.hnac.hzims.ticket.workTicket.service.*;
import com.hnac.hzims.ticket.workTicket.service.impl.WorkTicketDelayServiceImpl;
import com.hnac.hzims.ticket.workTicket.service.impl.WorkTicketOperateTimeServiceImpl;
import io.swagger.annotations.ApiModelProperty;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
@ -60,7 +58,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.time.LocalDateTime;
import java.util.*;
@ -136,6 +133,9 @@ public class TicketProcessServiceImpl implements TicketProcessService {
private String templatePath;
private final TicketInfoDangerService ticketInfoDangerService;
/**
* 启动开票流程
*
@ -147,28 +147,28 @@ public class TicketProcessServiceImpl implements TicketProcessService {
public void startUp(WorkTicketVo workTicketVo) {
log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法");
if (workTicketVo.getWorkTicket().getSignage() == null) {
throw new ServiceException("站点标识-两票编码不能为空");
throw new ServiceException("站点编码不能为空");
}
StationEntity stationEntity = new StationEntity();
stationEntity.setCode(workTicketVo.getWorkTicket().getSignageCode());
R<StationEntity> stationClientOne = stationClient.getOne(stationEntity);
if (!stationClientOne.isSuccess()) {
throw new IllegalArgumentException("根据条件获取唯一站点出错呢");
throw new IllegalArgumentException("站点编码不能为空");
}
StationEntity station = stationClientOne.getData();
if (station == null) {
throw new ServiceException("根据条件获取唯一站点暂无数据");
throw new ServiceException("站点编码不能为空");
}
log.info("前端查的站点编号 :{}", workTicketVo.getWorkTicket().getSignage());
log.info("后端查寻的站点编码 :{}", station.getSignage());
if (!workTicketVo.getWorkTicket().getSignage().equals(station.getSignage())) {
throw new ServiceException("站点标识-两票编码不能为空");
throw new ServiceException("站点编码不能为空");
}
//获取站点编号
String signage = station.getSignage();
if (StringUtils.isBlank(signage) || signage.length() < 2) {
throw new ServiceException("站点标识-两票编码不能为空");
throw new ServiceException("站点编码不能为空");
}
signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2);
@ -219,14 +219,32 @@ public class TicketProcessServiceImpl implements TicketProcessService {
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
//2.流程处理
String businessKey = response.getBusinessKey();
WorkTicketInfoEntity workTicketInfo = firstWorkTicketService.getById(businessKey);
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;
}
//更新工作票
workTicket.setId(workTicketInfo.getId());
//保存流程描述
workTicketInfo.setCreateDept(workTicketInfo.getCreateDept());
workTicket.setTenantId(workTicketInfo.getTenantId());
saveWorkTicket(workTicket, response);
//工作流ID
workTicket.setProcessInstanceId(response.getProcessInstanceId());
@ -335,6 +353,14 @@ public class TicketProcessServiceImpl implements TicketProcessService {
e.printStackTrace();
}
//工作票危险点分析及控制措施票
if (workTicketInfo.getIsHazard()) {
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
if (CollectionUtils.isNotEmpty(ticketInfoDangers)) {
ticketInfoDangerService.saveBatch(ticketInfoDangers);
}
}
}
@ -346,27 +372,35 @@ public class TicketProcessServiceImpl implements TicketProcessService {
*/
private void saveWorkTicket(WorkTicketInfoEntity workTicket, ProcessWorkFlowResponse response) {
String taskId = response.getTaskId();
workTicket.setFlowTaskId(taskId);
workTicket.setFlowTaskName(response.getTaskName());
String nextStepOperator = response.getNextStepOperator();
//1.获取状态
Integer flowStatus = workTicket.getFlowStatus();
//2.根据流程获取描述信息
String description = getWorkTicketDescription(flowStatus);
String flowDescription = "";
//当前审批人
String stepOperator = workTicket.getStepOperator();
Integer flowStatus = workTicket.getFlowStatus();
if ("0".equals(response.getHandleType())) {
Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ? nextStepOperator.substring(9) : null);
//下一个审批人
User stepUser = UserCache.getUser(taskUser);
flowDescription =
"审批中,当前环节是".concat(description).concat(",待").concat(stepUser.getName()).concat("审批");
flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(stepUser.getName()).concat("审批");
workTicket.setNextStepOperator(stepUser.getName());
}
if ("1".equals(response.getHandleType())) {
System.out.println("获取角色信息" + response.getNextStepOperator());
flowDescription = "审批中,当前环节是".concat(description).concat(",当前操作人是").concat(stepOperator);
//根据角色别名获取用户信息
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("获取用户信息失败");
}
}
//如果taskId为空 或 flowStatus = 99
if (StringUtils.isEmpty(taskId) || 99 == flowStatus) {
@ -378,9 +412,8 @@ public class TicketProcessServiceImpl implements TicketProcessService {
workTicket.setStepOperator(null);
} else {
workTicket.setFlowDescription(flowDescription);
workTicket.setFlowTaskId(taskId);
workTicket.setFlowTaskName(response.getTaskName());
}
//如果下一个审批人【nextStepOperator】是null设为-1
if (StringUtils.isEmpty(nextStepOperator)) {
workTicket.setNextStepOperator(null);
@ -398,8 +431,9 @@ public class TicketProcessServiceImpl implements TicketProcessService {
String value = null;
switch (flowStatus) {
case 1:
value = "签发人签发";
value = "许可人确认工作终结、工作票终结";
break;
case 2:
value = "运行人接收";
break;
@ -491,8 +525,11 @@ public class TicketProcessServiceImpl implements TicketProcessService {
log.info("processInstanceContainNameByKey.getData() : {}", processInstanceContainNameByKey.getData());
log.info("BladeFlow processInstanceContainNameByKey:{}", processInstanceContainNameByKey);
if (!processInstanceContainNameByKey.isSuccess() && processInstanceContainNameByKey.getCode() == 500) {
throw new ServiceException("启动流程失败...");
log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg());
throw new ServiceException("不好意思,您暂无权限...");
}
log.info("获取启动流程数据 : {}", processInstanceContainNameByKey);
}
@ -580,7 +617,8 @@ public class TicketProcessServiceImpl implements TicketProcessService {
//班组成员
Long principal = workTicket.getPrincipal();
if (ObjectUtils.isNotEmpty(principal)) {
return UserCache.getUser(principal).getName();
User user = UserCache.getUser(principal);
return user == null ? null : user.getName();
}
return workTicket.getPrincipalManual();
}
@ -612,43 +650,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
/**
* 预览
*
* @param ticketType
* @param ticketId
*/
@SneakyThrows
@Override
public String preview(String ticketType, Long ticketId) {
WorkTicketVo workTicketVo = ticketInfoService.selectDetailsById(ticketId);
//将查询的数据转换为map
Map<String, Object> workTicketInfoMap = this.convertMap(workTicketVo);
String fileName = TicketConstants.WordFileNameEnum.getFileNameByType(ticketType) + PdfUtils.XLSX_SUFFIX;
log.info("工作票模板为:{}", fileName);
XWPFDocument doc = WordExportUtil.exportWord07("template/电气第一种工作票模版.docx", workTicketInfoMap);
FileOutputStream fos = null;
String name = null;
String os = System.getProperty("os.name");
//Windows操作系统
if (os != null && os.toLowerCase().startsWith("windows")) {
log.info("当前系统版本是:{}", os);
name = "D:/导出excel/电气第一种工作票模版.docx";
fos = new FileOutputStream(name);
} else {
//其它操作系统
log.info("当前系统版本是:{}", os);
String prefix = IdWorker.get32UUID();
name = templatePath + prefix + ".docx";
fos = new FileOutputStream(name);
}
doc.write(fos);
fos.close();
return name;
}
/**
* 新预览
*
* @param ticketId
@ -665,18 +666,15 @@ public class TicketProcessServiceImpl implements TicketProcessService {
// response.addHeader("Pargam", "no-cache");
// response.addHeader("Cache-Control", "no-cache");
WorkTicketVo workTicketVo = ticketInfoService.selectDetailsById(ticketId);
log.info("新工作票 {}", workTicketVo);
//将查询的数据转换为map
Map<String, Object> workTicketInfoMap = this.convertMap(workTicketVo);
//创建新的map
Map<String, Object> objectObjectHashMap = new HashMap<>();
for (Map.Entry<String, Object> stringObjectEntry : workTicketInfoMap.entrySet()) {
System.out.println("获取map : " + stringObjectEntry.getKey() + "=====>" + stringObjectEntry.getValue());
log.info("获取map : " + stringObjectEntry.getKey() + "=====>" + stringObjectEntry.getValue());
}
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;
}
@ -737,16 +735,8 @@ public class TicketProcessServiceImpl implements TicketProcessService {
Map<String, Object> result = new HashMap<>();
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
Map<String,Object> map1 = JSONObject.parseObject(JSONObject.toJSONString(workTicket), Map.class);
for (Map.Entry<String, Object> stringObjectEntry : map1.entrySet()) {
System.out.println("stringObjectEntry : " + stringObjectEntry.getKey() + "=====>" + stringObjectEntry.getValue());
}
//1. 工作对象
// log.info("工作对象: {}", workTicket);
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMap(workTicket, true);
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMapResult(workTicket, result);
//安全隔离措施附页 (true,展示附件,false,不展示附件
getDataConversion(workTicketInfoMap, "isSafety", workTicketInfoMap.get("isSafety"));
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
@ -755,18 +745,15 @@ public class TicketProcessServiceImpl implements TicketProcessService {
getDataConversion(workTicketInfoMap, "isRailway", workTicketInfoMap.get("isRailway"));
//有限空间监测记录单(true,展示附件,false,不展示附件)
getDataConversion(workTicketInfoMap, "isLimited", workTicketInfoMap.get("isLimited"));
result.putAll(workTicketInfoMap);
//2. 安全措施
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList();
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());
@ -785,20 +772,57 @@ public class TicketProcessServiceImpl implements TicketProcessService {
mapList.add(map);
index++;
}
workTicketInfoMap.put(measureEnum.getConvertAttributes(), mapList);
workTicketInfoMap1.put(measureEnum.getConvertAttributes(), mapList);
} else {
workTicketInfoMap.put(measureEnum.getConvertAttributes(), new ArrayList<Map<String, String>>(1));
workTicketInfoMap1.put(measureEnum.getConvertAttributes(), new ArrayList<WorkTicketSafetyMeasureEntity>());
}
});
result.putAll(workTicketInfoMap);
} else {
result.put("matterLibraryListOne", new ArrayList<>());
result.put("matterLibraryListTwo", new ArrayList<>());
result.put("matterLibraryListThree", new ArrayList<>());
result.put("matterLibraryListFour", new ArrayList<>());
// 工作地点保留带电部位或注意事项
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<>());
}
result.putAll(workTicketInfoMap1);
}
//3. 工作票工作任务组
List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList();
if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) {
@ -809,26 +833,43 @@ public class TicketProcessServiceImpl implements TicketProcessService {
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay();
log.info("工作票延期: {}", workTicketDelay);
if (ObjectUtils.isNotEmpty(workTicketDelay)) {
result.putAll(PdfUtils.objectToMap(workTicketDelay, true));
result.putAll(PdfUtils.objectToMapResult(workTicket, result));
} else {
result.putAll(PdfUtils.objectToMap(new WorkTicketDelayEntity(), true));
result.putAll(PdfUtils.objectToMapResult(new WorkTicketDelayEntity(), result));
}
//5. 工作结束
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish();
log.info("工作结束: {}", workTicketFinish);
if (ObjectUtils.isNotEmpty(workTicketFinish)) {
result.putAll(PdfUtils.objectToMap(workTicketFinish, true));
result.putAll(PdfUtils.objectToMapResult(workTicketFinish, result));
} else {
result.putAll(PdfUtils.objectToMap(new WorkTicketFinish(), true));
result.putAll(PdfUtils.objectToMapResult(new WorkTicketFinish(), result));
}
//5. 工作票负责人变更
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange();
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange)) {
result.putAll(PdfUtils.objectToMap(workTicketPrincipalChange, true));
result.putAll(PdfUtils.objectToMapResult(workTicketPrincipalChange, result));
} else {
result.putAll(PdfUtils.objectToMap(new WorkTicketPrincipalChangeEntity(), true));
result.putAll(PdfUtils.objectToMapResult(new WorkTicketPrincipalChangeEntity(), result));
}
//6. 工作票危险点分析及控制措施票
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
if (CollectionUtils.isNotEmpty(ticketInfoDangers)) {
Map<String, List<Map<String, Object>>> map = new HashMap<>();
int index = 1;
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());
return newItem;
}).collect(Collectors.toList());
map.put("ticketInfoDangers", collect);
result.putAll(map);
}
return result;
}
@ -836,6 +877,41 @@ public class TicketProcessServiceImpl implements TicketProcessService {
/**
* 对象转map
*
* @param value
* @param result
* @return
*/
public Map<String, Object> getTicketObjectVo(Object value, Map<String, Object> result) {
String jsonString = JSON.toJSONString(value);
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());
//如果包含直接跳过
if (result.containsKey(stringObjectEntry.getKey())) {
System.out.println("跳过key : " + stringObjectEntry.getKey());
continue;
}
Object newValue = stringObjectEntry.getValue();
if (newValue == null) {
newValue = "\u00A0";
}
newMap.put(stringObjectEntry.getKey(), newValue);
}
for (Map.Entry<String, Object> stringObjectEntry : newMap.entrySet()) {
System.out.println("数据转换的数据 " + 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);

7
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java

@ -1,5 +1,6 @@
package com.hnac.hzims.ticket.twoTicket.vo.process;
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger;
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish;
import com.hnac.hzims.ticket.workTicket.entity.*;
import io.swagger.annotations.ApiModel;
@ -79,4 +80,10 @@ public class WorkTicketVo {
private String ticketType;
/**
* 工作票危险点分析及控制措施票
*/
private List<TicketInfoDanger> ticketInfoDangers;
}

71
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java

@ -25,8 +25,10 @@ import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketWithAreaVo;
import com.hnac.hzims.ticket.areamonthly.vo.StandardWorkVo;
import com.hnac.hzims.ticket.aspect.AroundFlow;
import com.hnac.hzims.ticket.constants.TicketConstants;
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger;
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish;
import com.hnac.hzims.ticket.twoTicket.enums.FlowWorkTicketConstants;
import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService;
import com.hnac.hzims.ticket.twoTicket.service.impl.WorkTicketFinishServiceImpl;
import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo;
import com.hnac.hzims.ticket.utils.ExcelUtil;
@ -105,6 +107,7 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
private final TicketInfoEvaluateService ticketInfoEvaluateService;
private final IWorkTicketContentService workTicketContentService;
private final WorkTicketFinishServiceImpl workTicketFinishService;
private final TicketInfoDangerService ticketInfoDangerService;
/** 生成两票编号锁 **/
private Lock lock = new ReentrantLock();
@ -245,13 +248,16 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
lqw.orderByDesc(WorkTicketInfoEntity::getCreateTime).orderByDesc(WorkTicketInfoEntity::getUpdateTime);
IPage<WorkTicketInfoEntity> pages = this.page(Condition.getPage(query), lqw);
//数据转换
IPage<WorkTicketInfoVO> workTicketInfoVOIPage = new Page<>(pages.getCurrent(),pages.getSize());
IPage<WorkTicketInfoVO> workTicketInfoVOIPage = new Page<>(pages.getCurrent(), pages.getSize());
workTicketInfoVOIPage.setRecords(WorkTicketInfoWrapper.build().listVO(pages.getRecords()));
workTicketInfoVOIPage.setPages(pages.getPages());
workTicketInfoVOIPage.setTotal(pages.getTotal());
//获取创建人
workTicketInfoVOIPage.getRecords().forEach(item -> {
User user = UserCache.getUser(item.getCreateUser());
if (user != null) {
item.setCreateUserName(UserCache.getUser(item.getCreateUser()).getName());
}
});
@ -951,48 +957,75 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
}
//赋值签发人
if (workTicketInfo.getSignerName() != null) {
workTicketInfo.setSignerName(UserCache.getUser(workTicketInfo.getSigner()).getName());
if (workTicketInfo.getSigner() != null) {
User user = UserCache.getUser(workTicketInfo.getSigner());
workTicketInfo.setSignerName(user == null ? null : user.getName());
}
if (workTicketInfo.getSigner() != null && workTicketInfo.getSignerName() == null) {
User user = UserCache.getUser(workTicketInfo.getSigner());
workTicketInfo.setSignerName(user == null ? null : user.getName());
}
//赋值许可人名称
if (workTicketInfo.getLicensorName() != null) {
workTicketInfo.setLicensorName(UserCache.getUser(workTicketInfo.getLicensor()).getName());
if (workTicketInfo.getLicensor() != null) {
User user = UserCache.getUser(workTicketInfo.getLicensor());
workTicketInfo.setLicensorName(user == null ? null : user.getName());
}
if (workTicketInfo.getLicensor() != null && workTicketInfo.getLicensorName() == null) {
User user = UserCache.getUser(workTicketInfo.getLicensor());
workTicketInfo.setLicensorName(user == null ? null : user.getName());
}
// 负责值班负责人
if (workTicketInfo.getWatchPrincipalName() != null) {
workTicketInfo.setWatchPrincipalName(UserCache.getUser(workTicketInfo.getWatchPrincipal()).getName());
if (workTicketInfo.getWatchPrincipal() != null) {
User user = UserCache.getUser(workTicketInfo.getWatchPrincipal());
workTicketInfo.setWatchPrincipalName(user == null ? null : user.getName());
}
String classGroupMembers = workTicketVo.getWorkTicket().getClassGroupMembers();
if (workTicketInfo.getWatchPrincipal() != null && workTicketInfo.getWatchPrincipalName() == null) {
User user = UserCache.getUser(workTicketInfo.getWatchPrincipal());
workTicketInfo.setWatchPrincipalName(user == null ? null : user.getName());
}
StringBuilder sb = new StringBuilder();
String classGroupMembers = workTicketInfo.getClassGroupMembers();
if (StringUtils.isNoneBlank(classGroupMembers)) {
// System.out.println("获取classGroupMembers ==> " + classGroupMembers);
String[] split = classGroupMembers.split(",");
StringBuilder sb = new StringBuilder();
for (String classGroupMember : split) {
System.out.println(classGroupMember);
if (StringUtils.isNoneBlank(classGroupMember)) {
boolean matches = classGroupMember.matches("[0-9]+");
if (matches) {
String name = UserCache.getUser(Long.valueOf(classGroupMember)).getName();
// System.out.println("获取用户信息 ==> " + name);
User user = UserCache.getUser(Long.valueOf(classGroupMember));
String name = user == null ? null : user.getName();
if (StringUtils.isNotBlank(name)) {
sb.append(name).append(",");
}
}
}
}
//统计人数
if (workTicketInfo.getTotalPerson() == null) {
workTicketInfo.setTotalPerson(sb.toString().trim().split(",").length);
}
//成员信息
if (workTicketInfo.getClassGroupMembersName() == null) {
workTicketInfo.setClassGroupMembersName(sb.toString().endsWith(",") ?
sb.toString().substring(0,sb.length() - 1) : sb.toString());
sb.toString().substring(0, sb.length() - 1) : sb.toString());
}
//统计人数
if (workTicketInfo.getTotalPerson() == null) {
workTicketInfo.setTotalPerson(split.length);
}
//负责人名称
if (workTicketInfo.getPrincipalName() == null && workTicketInfo.getPrincipal() != null) {
workTicketInfo.setPrincipalName(UserCache.getUser(workTicketInfo.getPrincipal()).getName());
User user = UserCache.getUser(workTicketInfo.getPrincipal());
workTicketInfo.setPrincipalName(user == null ? "" : user.getName());
}
@ -1052,6 +1085,12 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
workTicketVo.setWorkTicketPrincipalChange(workTicketPrincipalChangeEntity);
}
//7. 根据工作票Id查询工作票危险点分析及控制措施票
List<TicketInfoDanger> list = ticketInfoDangerService.selectAllByTicket(workTicketInfo.getId());
if (CollectionUtils.isNotEmpty(list)) {
workTicketVo.setTicketInfoDangers(list);
}
return workTicketVo;
}
}

Loading…
Cancel
Save