|
|
@ -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.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
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.common.logs.utils.StringUtils; |
|
|
|
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; |
|
|
|
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; |
|
|
|
import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient; |
|
|
|
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.constants.WorkTicketConstants; |
|
|
|
import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker; |
|
|
|
import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker; |
|
|
|
import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; |
|
|
|
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.entity.WorkTicketFinish; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.service.IWorkTicketFinishService; |
|
|
|
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.service.TicketProcessService; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.process.FristWorkTicketVo; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.process.FristWorkTicketVo; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; |
|
|
|
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.*; |
|
|
|
import com.hnac.hzims.ticket.workTicket.service.impl.WorkTicketDelayServiceImpl; |
|
|
|
import com.hnac.hzims.ticket.workTicket.service.impl.WorkTicketDelayServiceImpl; |
|
|
|
import com.hnac.hzims.ticket.workTicket.service.impl.WorkTicketOperateTimeServiceImpl; |
|
|
|
import com.hnac.hzims.ticket.workTicket.service.impl.WorkTicketOperateTimeServiceImpl; |
|
|
|
import io.swagger.annotations.ApiModelProperty; |
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.BooleanUtils; |
|
|
|
import org.apache.commons.lang3.BooleanUtils; |
|
|
|
import org.apache.commons.lang3.math.NumberUtils; |
|
|
|
import org.apache.commons.lang3.math.NumberUtils; |
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument; |
|
|
|
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.log.exception.ServiceException; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
@ -60,7 +58,6 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
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.FileInputStream; |
|
|
|
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
@ -136,6 +133,9 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
private String templatePath; |
|
|
|
private String templatePath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final TicketInfoDangerService ticketInfoDangerService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 启动开票流程 |
|
|
|
* 启动开票流程 |
|
|
|
* |
|
|
|
* |
|
|
@ -147,28 +147,28 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
public void startUp(WorkTicketVo workTicketVo) { |
|
|
|
public void startUp(WorkTicketVo workTicketVo) { |
|
|
|
log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法"); |
|
|
|
log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法"); |
|
|
|
if (workTicketVo.getWorkTicket().getSignage() == null) { |
|
|
|
if (workTicketVo.getWorkTicket().getSignage() == null) { |
|
|
|
throw new ServiceException("站点标识-两票编码不能为空"); |
|
|
|
throw new ServiceException("站点编码不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
StationEntity stationEntity = new StationEntity(); |
|
|
|
StationEntity stationEntity = new StationEntity(); |
|
|
|
stationEntity.setCode(workTicketVo.getWorkTicket().getSignageCode()); |
|
|
|
stationEntity.setCode(workTicketVo.getWorkTicket().getSignageCode()); |
|
|
|
R<StationEntity> stationClientOne = stationClient.getOne(stationEntity); |
|
|
|
R<StationEntity> stationClientOne = stationClient.getOne(stationEntity); |
|
|
|
if (!stationClientOne.isSuccess()) { |
|
|
|
if (!stationClientOne.isSuccess()) { |
|
|
|
throw new IllegalArgumentException("根据条件获取唯一站点出错呢"); |
|
|
|
throw new IllegalArgumentException("站点编码不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
StationEntity station = stationClientOne.getData(); |
|
|
|
StationEntity station = stationClientOne.getData(); |
|
|
|
if (station == null) { |
|
|
|
if (station == null) { |
|
|
|
throw new ServiceException("根据条件获取唯一站点暂无数据"); |
|
|
|
throw new ServiceException("站点编码不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("前端查的站点编号 :{}", workTicketVo.getWorkTicket().getSignage()); |
|
|
|
log.info("前端查的站点编号 :{}", workTicketVo.getWorkTicket().getSignage()); |
|
|
|
log.info("后端查寻的站点编码 :{}", station.getSignage()); |
|
|
|
log.info("后端查寻的站点编码 :{}", station.getSignage()); |
|
|
|
if (!workTicketVo.getWorkTicket().getSignage().equals(station.getSignage())) { |
|
|
|
if (!workTicketVo.getWorkTicket().getSignage().equals(station.getSignage())) { |
|
|
|
throw new ServiceException("站点标识-两票编码不能为空"); |
|
|
|
throw new ServiceException("站点编码不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取站点编号
|
|
|
|
//获取站点编号
|
|
|
|
String signage = station.getSignage(); |
|
|
|
String signage = station.getSignage(); |
|
|
|
if (StringUtils.isBlank(signage) || signage.length() < 2) { |
|
|
|
if (StringUtils.isBlank(signage) || signage.length() < 2) { |
|
|
|
throw new ServiceException("站点标识-两票编码不能为空"); |
|
|
|
throw new ServiceException("站点编码不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2); |
|
|
|
signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2); |
|
|
|
|
|
|
|
|
|
|
@ -219,14 +219,32 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
//2.流程处理
|
|
|
|
//2.流程处理
|
|
|
|
String businessKey = response.getBusinessKey(); |
|
|
|
String businessKey = response.getBusinessKey(); |
|
|
|
WorkTicketInfoEntity workTicketInfo = firstWorkTicketService.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; |
|
|
|
} |
|
|
|
} |
|
|
|
//更新工作票
|
|
|
|
//更新工作票
|
|
|
|
workTicket.setId(workTicketInfo.getId()); |
|
|
|
workTicket.setId(workTicketInfo.getId()); |
|
|
|
//保存流程描述
|
|
|
|
//保存流程描述
|
|
|
|
|
|
|
|
workTicketInfo.setCreateDept(workTicketInfo.getCreateDept()); |
|
|
|
|
|
|
|
workTicket.setTenantId(workTicketInfo.getTenantId()); |
|
|
|
saveWorkTicket(workTicket, response); |
|
|
|
saveWorkTicket(workTicket, response); |
|
|
|
//工作流ID
|
|
|
|
//工作流ID
|
|
|
|
workTicket.setProcessInstanceId(response.getProcessInstanceId()); |
|
|
|
workTicket.setProcessInstanceId(response.getProcessInstanceId()); |
|
|
@ -335,6 +353,14 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
e.printStackTrace(); |
|
|
|
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) { |
|
|
|
private void saveWorkTicket(WorkTicketInfoEntity workTicket, ProcessWorkFlowResponse response) { |
|
|
|
String taskId = response.getTaskId(); |
|
|
|
String taskId = response.getTaskId(); |
|
|
|
|
|
|
|
workTicket.setFlowTaskId(taskId); |
|
|
|
|
|
|
|
workTicket.setFlowTaskName(response.getTaskName()); |
|
|
|
String nextStepOperator = response.getNextStepOperator(); |
|
|
|
String nextStepOperator = response.getNextStepOperator(); |
|
|
|
//1.获取状态
|
|
|
|
|
|
|
|
Integer flowStatus = workTicket.getFlowStatus(); |
|
|
|
|
|
|
|
//2.根据流程获取描述信息
|
|
|
|
|
|
|
|
String description = getWorkTicketDescription(flowStatus); |
|
|
|
|
|
|
|
String flowDescription = ""; |
|
|
|
String flowDescription = ""; |
|
|
|
//当前审批人
|
|
|
|
Integer flowStatus = workTicket.getFlowStatus(); |
|
|
|
String stepOperator = workTicket.getStepOperator(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("0".equals(response.getHandleType())) { |
|
|
|
if ("0".equals(response.getHandleType())) { |
|
|
|
Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ? nextStepOperator.substring(9) : null); |
|
|
|
Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ? nextStepOperator.substring(9) : null); |
|
|
|
//下一个审批人
|
|
|
|
//下一个审批人
|
|
|
|
User stepUser = UserCache.getUser(taskUser); |
|
|
|
User stepUser = UserCache.getUser(taskUser); |
|
|
|
flowDescription = |
|
|
|
flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(stepUser.getName()).concat("审批"); |
|
|
|
"审批中,当前环节是".concat(description).concat(",待").concat(stepUser.getName()).concat("审批"); |
|
|
|
|
|
|
|
workTicket.setNextStepOperator(stepUser.getName()); |
|
|
|
workTicket.setNextStepOperator(stepUser.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ("1".equals(response.getHandleType())) { |
|
|
|
if ("1".equals(response.getHandleType())) { |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("获取角色信息" + response.getNextStepOperator()); |
|
|
|
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
|
|
|
|
//如果taskId为空 或 flowStatus = 99
|
|
|
|
if (StringUtils.isEmpty(taskId) || 99 == flowStatus) { |
|
|
|
if (StringUtils.isEmpty(taskId) || 99 == flowStatus) { |
|
|
@ -378,9 +412,8 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
workTicket.setStepOperator(null); |
|
|
|
workTicket.setStepOperator(null); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
workTicket.setFlowDescription(flowDescription); |
|
|
|
workTicket.setFlowDescription(flowDescription); |
|
|
|
workTicket.setFlowTaskId(taskId); |
|
|
|
|
|
|
|
workTicket.setFlowTaskName(response.getTaskName()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//如果下一个审批人【nextStepOperator】是null设为-1
|
|
|
|
//如果下一个审批人【nextStepOperator】是null设为-1
|
|
|
|
if (StringUtils.isEmpty(nextStepOperator)) { |
|
|
|
if (StringUtils.isEmpty(nextStepOperator)) { |
|
|
|
workTicket.setNextStepOperator(null); |
|
|
|
workTicket.setNextStepOperator(null); |
|
|
@ -398,8 +431,9 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
String value = null; |
|
|
|
String value = null; |
|
|
|
switch (flowStatus) { |
|
|
|
switch (flowStatus) { |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
value = "签发人签发"; |
|
|
|
value = "许可人确认工作终结、工作票终结"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
value = "运行人接收"; |
|
|
|
value = "运行人接收"; |
|
|
|
break; |
|
|
|
break; |
|
|
@ -491,8 +525,11 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
log.info("processInstanceContainNameByKey.getData() : {}", processInstanceContainNameByKey.getData()); |
|
|
|
log.info("processInstanceContainNameByKey.getData() : {}", processInstanceContainNameByKey.getData()); |
|
|
|
log.info("BladeFlow processInstanceContainNameByKey:{}", processInstanceContainNameByKey); |
|
|
|
log.info("BladeFlow processInstanceContainNameByKey:{}", processInstanceContainNameByKey); |
|
|
|
if (!processInstanceContainNameByKey.isSuccess() && processInstanceContainNameByKey.getCode() == 500) { |
|
|
|
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(); |
|
|
|
Long principal = workTicket.getPrincipal(); |
|
|
|
if (ObjectUtils.isNotEmpty(principal)) { |
|
|
|
if (ObjectUtils.isNotEmpty(principal)) { |
|
|
|
return UserCache.getUser(principal).getName(); |
|
|
|
User user = UserCache.getUser(principal); |
|
|
|
|
|
|
|
return user == null ? null : user.getName(); |
|
|
|
} |
|
|
|
} |
|
|
|
return workTicket.getPrincipalManual(); |
|
|
|
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 |
|
|
|
* @param ticketId |
|
|
@ -665,18 +666,15 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
// response.addHeader("Pargam", "no-cache");
|
|
|
|
// response.addHeader("Pargam", "no-cache");
|
|
|
|
// response.addHeader("Cache-Control", "no-cache");
|
|
|
|
// response.addHeader("Cache-Control", "no-cache");
|
|
|
|
WorkTicketVo workTicketVo = ticketInfoService.selectDetailsById(ticketId); |
|
|
|
WorkTicketVo workTicketVo = ticketInfoService.selectDetailsById(ticketId); |
|
|
|
log.info("新工作票 {}", workTicketVo); |
|
|
|
|
|
|
|
//将查询的数据转换为map
|
|
|
|
//将查询的数据转换为map
|
|
|
|
Map<String, Object> workTicketInfoMap = this.convertMap(workTicketVo); |
|
|
|
Map<String, Object> workTicketInfoMap = this.convertMap(workTicketVo); |
|
|
|
//创建新的map
|
|
|
|
//创建新的map
|
|
|
|
Map<String, Object> objectObjectHashMap = new HashMap<>(); |
|
|
|
|
|
|
|
for (Map.Entry<String, Object> stringObjectEntry : workTicketInfoMap.entrySet()) { |
|
|
|
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(); |
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
|
|
|
|
|
|
|
|
if ((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)) { |
|
|
|
|| (workTicket.getIsSafety() == null || workTicket.getIsHazard() == null || workTicket.getIsLimited() == null || workTicket.getIsRailway() == null)) { |
|
|
|
|
|
|
|
extractedWithWord(response, workTicketInfoMap); |
|
|
|
extractedWithWord(response, workTicketInfoMap); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -737,16 +735,8 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
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. 工作对象
|
|
|
|
//1. 工作对象
|
|
|
|
// log.info("工作对象: {}", workTicket);
|
|
|
|
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMapResult(workTicket, result); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMap(workTicket, true); |
|
|
|
|
|
|
|
//安全隔离措施附页 (true,展示附件,false,不展示附件
|
|
|
|
//安全隔离措施附页 (true,展示附件,false,不展示附件
|
|
|
|
getDataConversion(workTicketInfoMap, "isSafety", workTicketInfoMap.get("isSafety")); |
|
|
|
getDataConversion(workTicketInfoMap, "isSafety", workTicketInfoMap.get("isSafety")); |
|
|
|
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
|
|
|
|
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
|
|
|
@ -755,18 +745,15 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
getDataConversion(workTicketInfoMap, "isRailway", workTicketInfoMap.get("isRailway")); |
|
|
|
getDataConversion(workTicketInfoMap, "isRailway", workTicketInfoMap.get("isRailway")); |
|
|
|
//有限空间监测记录单(true,展示附件,false,不展示附件)
|
|
|
|
//有限空间监测记录单(true,展示附件,false,不展示附件)
|
|
|
|
getDataConversion(workTicketInfoMap, "isLimited", workTicketInfoMap.get("isLimited")); |
|
|
|
getDataConversion(workTicketInfoMap, "isLimited", workTicketInfoMap.get("isLimited")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.putAll(workTicketInfoMap); |
|
|
|
result.putAll(workTicketInfoMap); |
|
|
|
//2. 安全措施
|
|
|
|
//2. 安全措施
|
|
|
|
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList(); |
|
|
|
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList(); |
|
|
|
log.info("安全措施: {}", safetyMeasuresList); |
|
|
|
log.info("安全措施: {}", safetyMeasuresList); |
|
|
|
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) { |
|
|
|
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) { |
|
|
|
|
|
|
|
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().collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType)); |
|
|
|
Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants()).forEach(measureEnum -> { |
|
|
|
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()); |
|
|
@ -785,20 +772,57 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
mapList.add(map); |
|
|
|
mapList.add(map); |
|
|
|
index++; |
|
|
|
index++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
workTicketInfoMap1.put(measureEnum.getConvertAttributes(), mapList); |
|
|
|
workTicketInfoMap.put(measureEnum.getConvertAttributes(), mapList); |
|
|
|
|
|
|
|
} else { |
|
|
|
} 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<>()); |
|
|
|
List<Map<String, Object>> matterLibraryListFive1 = workTicketInfoMap1.get("matterLibraryListFive") == null ? new ArrayList<Map<String, Object>>() : (List<Map<String, Object>>) workTicketInfoMap1.get("matterLibraryListFive"); |
|
|
|
result.put("matterLibraryListTwo", new ArrayList<>()); |
|
|
|
List<Map<String, Object>> matterLibraryListFlow1 = workTicketInfoMap1.get("matterLibraryListFlow") == null ? new ArrayList<Map<String, Object>>() : (List<Map<String, Object>>) workTicketInfoMap1.get("matterLibraryListFlow"); |
|
|
|
result.put("matterLibraryListThree", new ArrayList<>()); |
|
|
|
|
|
|
|
result.put("matterLibraryListFour", new ArrayList<>()); |
|
|
|
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. 工作票工作任务组
|
|
|
|
//3. 工作票工作任务组
|
|
|
|
List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList(); |
|
|
|
List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList(); |
|
|
|
if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) { |
|
|
|
if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) { |
|
|
@ -809,26 +833,43 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay(); |
|
|
|
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay(); |
|
|
|
log.info("工作票延期: {}", workTicketDelay); |
|
|
|
log.info("工作票延期: {}", workTicketDelay); |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketDelay)) { |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketDelay)) { |
|
|
|
result.putAll(PdfUtils.objectToMap(workTicketDelay, true)); |
|
|
|
result.putAll(PdfUtils.objectToMapResult(workTicket, result)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
result.putAll(PdfUtils.objectToMap(new WorkTicketDelayEntity(), true)); |
|
|
|
result.putAll(PdfUtils.objectToMapResult(new WorkTicketDelayEntity(), result)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//5. 工作结束
|
|
|
|
//5. 工作结束
|
|
|
|
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish(); |
|
|
|
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish(); |
|
|
|
log.info("工作结束: {}", workTicketFinish); |
|
|
|
log.info("工作结束: {}", workTicketFinish); |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketFinish)) { |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketFinish)) { |
|
|
|
result.putAll(PdfUtils.objectToMap(workTicketFinish, true)); |
|
|
|
result.putAll(PdfUtils.objectToMapResult(workTicketFinish, result)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
result.putAll(PdfUtils.objectToMap(new WorkTicketFinish(), true)); |
|
|
|
result.putAll(PdfUtils.objectToMapResult(new WorkTicketFinish(), result)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//5. 工作票负责人变更
|
|
|
|
//5. 工作票负责人变更
|
|
|
|
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange(); |
|
|
|
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange(); |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange)) { |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange)) { |
|
|
|
result.putAll(PdfUtils.objectToMap(workTicketPrincipalChange, true)); |
|
|
|
result.putAll(PdfUtils.objectToMapResult(workTicketPrincipalChange, result)); |
|
|
|
} else { |
|
|
|
} 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; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -836,6 +877,41 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 对象转map |
|
|
|
* 对象转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) { |
|
|
|
private static <T> Map<String, Object> parseObjectMap(T target, Class clas) { |
|
|
|
return JSONObject.parseObject(JSONObject.toJSONString(target), Map.class); |
|
|
|
return JSONObject.parseObject(JSONObject.toJSONString(target), Map.class); |
|
|
|