From 8a89d867993bfd31d78d2467841a0bc6db239d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Wed, 7 Jun 2023 10:52:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=93=8D=E4=BD=9C=E7=A5=A8?= =?UTF-8?q?=E6=A8=A1=E5=9D=97,=E5=90=AF=E5=8A=A8=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=EF=BC=8C=E5=BE=85=E5=A4=84=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/message/MessageConstants.java | 1 + .../entity/StandardTicketInfoEntity.java | 58 ++++ .../constant/TicketProcessConstant.java | 6 + .../consumer/StandardWorkTicketConsumer.java | 7 +- .../controller/ProcessDictController.java | 20 +- .../processflow/strategy/core/ProcessIdWorker.java | 2 +- .../serviceimpl/OneTicketProcessServiceImpl.java | 6 +- .../OperationTicketProcessServiceImpl.java | 69 ++++ .../controller/OperationTicketController.java | 47 +++ .../service/OperationTicketService.java | 28 ++ .../service/impl/OperationTicketServiceImpl.java | 360 +++++++++++++++++++++ .../service/impl/TicketProcessServiceImpl.java | 153 +++++---- .../vo/operation/StandardTicketInfoVo.java | 120 +++++++ .../vo/operation/StandardTicketMeasureVo.java | 57 ++++ 14 files changed, 863 insertions(+), 71 deletions(-) create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketMeasureVo.java diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java index 7b7fbdb..6741a3f 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java @@ -54,6 +54,7 @@ public class MessageConstants { SAFE("safe","安全消息"), ACCESS("access","检修消息"), TICKETMESSAGE("ticket-message","工作票消息"), + OPERATIONTICKETMESSAGE("operation-ticket-message","操作票消息"), ; @Getter private String key; diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java index 9d273d7..62c627d 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java @@ -125,4 +125,62 @@ public class StandardTicketInfoEntity extends TenantEntity implements Serializab @ApiModelProperty("是否评价") private Integer isEvaluate; + + + /** + * AA/AAA/AAAA由建站时建站人填写必须系统验证唯一性 + * 站点标识-两票编码 + */ + @ApiModelProperty("站点标识-两票编码") + private String signage; + + + /** + * 编号(原站点ID) + */ + @ApiModelProperty("编号(原站点ID)") + private String signageCode; + + + /** + * 流程状态' + */ + @ApiModelProperty("流程状态") + private Integer flowStatus; + + /** + * 流程描述 + */ + @ApiModelProperty("流程描述") + private String flowDescription; + + + /** + * 下一个审批人 + */ + @ApiModelProperty("下一个审批人") + private String nextStepOperator; + + + /** + * 用户Id + */ + @ApiModelProperty("用户Id") + private String flowUserId; + + + /** + * 当前任务名 + */ + @ApiModelProperty("当前任务名") + private String flowTaskName; + + + /** + * 当前任务名 + */ + @ApiModelProperty("当前任务名") + private String flowTaskId; + + } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java index 7bef5ea..1ad02a8 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java @@ -14,4 +14,10 @@ public class TicketProcessConstant { * 第一种工作票的key */ public static final String FIRST_TICKET_KEY = "networking"; + + + /** + * 操作票 + */ + public static final String OPERATION_TICKET_KEY = "moreActionBankDirect"; } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java index 5936bed..956dc1e 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java @@ -44,11 +44,12 @@ public class StandardWorkTicketConsumer implements IQueueConsume { WorkflowQueue ticker = new WorkflowQueue(); ticker.setProcessDefinitionKey(taskDefinitionKey); //判断执行具体的实现类 - ProcessService ticketService = ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)).findFirst().orElse(null); - if (ObjectUtils.isNotEmpty(ticketService)) { + ProcessService processService = + ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)).findFirst().orElse(null); + if (ObjectUtils.isNotEmpty(processService)) { //执行业务方法 try { - ticketService.calculate(response); + processService.calculate(response); } catch (Exception e) { e.printStackTrace(); //todo 业务出错误 做补偿 diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessDictController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessDictController.java index f6b6fdf..f267139 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessDictController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessDictController.java @@ -29,14 +29,24 @@ public class ProcessDictController { @GetMapping("/test") public void test(){ + // ProcessDict processDict = new ProcessDict(); + // processDict.setDictKey("networking"); + // processDict.setDictSort(0); + // processDict.setDictValue("workTicketFlow"); + // processDict.setDictLabel("第一种工作票"); + // processDict.setIsDefault("Y"); + // processDict.setRemark("第一种工作票"); + // processDict.setDictType("工作票"); + // processDictService.save(processDict); + ProcessDict processDict = new ProcessDict(); - processDict.setDictKey("networking"); + processDict.setDictKey("moreActionBankDirect"); processDict.setDictSort(0); - processDict.setDictValue("workTicketFlow"); - processDict.setDictLabel("第一种工作票"); + processDict.setDictValue("standardTicketFlow"); + processDict.setDictLabel("操作票"); processDict.setIsDefault("Y"); - processDict.setRemark("第一种工作票"); - processDict.setDictType("工作票"); + processDict.setRemark("操作票"); + processDict.setDictType("两票管理"); processDictService.save(processDict); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java index 6fcddf2..6e1fdf9 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java @@ -136,7 +136,7 @@ public class ProcessIdWorker { //6. sequencing 大于等于1000 的话,从头开始 if (sequencing.get() >= 1000) { sequencing.compareAndSet(sequencing.get(), 1); - System.out.println("sequencing >= 1000 被执行呢"); + log.error("sequencing >= 1000 被执行呢"); redisTemplate.delete(key); // cacheMap.remove(key); return sequencing.get(); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java index 1255079..4b1c653 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java @@ -47,13 +47,13 @@ public class OneTicketProcessServiceImpl extends ProcessAbstractService { */ @Override public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { - log.info("是否执行开第一种工作票流程环节操作~~~~,流程ticket: {}", flowQueue); + log.info("是否执行开工作票流程环节操作~~~~,流程ticket: {}", flowQueue); String dictValue = processDictService.selectDictValueByKey(FIRST_TICKET_KEY); if (dictValue.equals(flowQueue.getProcessDefinitionKey())) { - log.info("已执行第一种开工作票流程环节操作~~~~"); + log.info("已执行工作票流程环节操作~~~~"); return true; } - log.error("未是否执行第一种开工作票流程环节操作,请联系管理员~~~~"); + log.error("未是否执行工作票流程环节操作,请联系管理员~~~~"); return false; } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java new file mode 100644 index 0000000..7590575 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java @@ -0,0 +1,69 @@ +package com.hnac.hzims.ticket.processflow.strategy.serviceimpl; + +import com.hnac.hzims.ticket.processflow.service.ProcessDictService; +import com.hnac.hzims.ticket.processflow.strategy.abstracts.ProcessAbstractService; +import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; +import com.hnac.hzims.ticket.standardTicket.service.OperationTicketService; +import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import static com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant.OPERATION_TICKET_KEY; + +/** + * 开工作票流程实现类 + * + * @Author dfy + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/3/28 8:47 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class OperationTicketProcessServiceImpl extends ProcessAbstractService { + + + + private final OperationTicketService operationTicketService; + + + + private final ProcessDictService processDictService; + + + + + + + + /** + * 设置执行那种实现类 + * + * @param flowQueue + * @return + */ + @Override + public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { + log.info("是否执行开操作票流程环节操作~~~~,流程flowQueue: {}", flowQueue); + String dictValue = processDictService.selectDictValueByKey(OPERATION_TICKET_KEY); + if (dictValue.equals(flowQueue.getProcessDefinitionKey())) { + log.info("已执行操作票流程环节操作~~~~"); + return true; + } + log.error("未是否执行操作票流程环节操作,请联系管理员~~~~"); + return false; + } + + /** + * 两票管理业务方法 + * + * @param response + */ + @Override + public void calculate(ProcessWorkFlowResponse response) { + operationTicketService.findPending(response); + } +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java new file mode 100644 index 0000000..b47e1e2 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.ticket.standardTicket.controller; + +import com.hnac.hzims.ticket.standardTicket.service.OperationTicketService; +import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; +import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 操作票 + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/6 13:46 + */ +@RequiredArgsConstructor +@Slf4j +@RequestMapping("/operation-ticket") +@RestController +public class OperationTicketController { + + + private final OperationTicketService operationTicketService; + + + /** + * 启动流程 + * + * @return + */ + @ApiOperation("启动流程") + @PostMapping("/startUp") + public R start(@RequestBody StandardTicketInfoVo StandardTicketInfoVo) { + operationTicketService.startUp(StandardTicketInfoVo); + return R.success("申请开票成功"); + } + + + + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java new file mode 100644 index 0000000..f92497d --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.ticket.standardTicket.service; + +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; +import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; +import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/6 13:48 + */ +public interface OperationTicketService { + + + /** + * 启动流程 + * @param standardTicketInfoVo + */ + void startUp(StandardTicketInfoVo standardTicketInfoVo); + + + /** + * 待处理 + * @param response + */ + void findPending(ProcessWorkFlowResponse response); +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java new file mode 100644 index 0000000..7934a21 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java @@ -0,0 +1,360 @@ +package com.hnac.hzims.ticket.standardTicket.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.MessagePushRecordDto; +import com.hnac.hzims.message.fegin.IMessageClient; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.ticket.processflow.service.ProcessDictService; +import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; +import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; +import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketMeasureEntity; +import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; +import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketMeasureService; +import com.hnac.hzims.ticket.standardTicket.service.OperationTicketService; +import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; +import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketMeasureVo; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.flow.core.entity.BladeFlow; +import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +import static com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant.OPERATION_TICKET_KEY; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/6 13:49 + */ + +@Slf4j +@Service +@RequiredArgsConstructor +public class OperationTicketServiceImpl implements OperationTicketService { + + private final IStandardTicketInfoService standardTicketInfoService; + + private final IStandardTicketMeasureService standardTicketMeasureService; + + private final IStationClient stationClient; + + + private final ProcessIdWorker processIdWorker; + + + private final ProcessDictService processDictService; + + + private final IFlowClient flowClient; + + + private final IMessageClient messageClient; + + + private final ISysClient sysClient; + + + /** + * 启动流程 + * + * @param standardTicketInfoVo + */ + @Override + public void startUp(StandardTicketInfoVo standardTicketInfoVo) { + log.info("执行 com.hnac.hzims.ticket.standardTicket.service.impl【startUp】 。。。方法"); + if (standardTicketInfoVo.getSignage() == null) { + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); + } + StationEntity stationEntity = new StationEntity(); + stationEntity.setCode(standardTicketInfoVo.getSignageCode()); + R stationClientOne = stationClient.getOne(stationEntity); + if (!stationClientOne.isSuccess()) { + throw new IllegalArgumentException("票据抬头未配置,请您到站点管理配置?"); + } + StationEntity station = stationClientOne.getData(); + if (station == null) { + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); + } + log.info("前端查的站点编号 :{}", standardTicketInfoVo.getSignage()); + log.info("后端查寻的站点编码 :{}", station.getSignage()); + if (!standardTicketInfoVo.getSignage().equals(station.getSignage())) { + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); + } + + //获取站点编号 + String signage = station.getSignage(); + if (StringUtils.isBlank(signage) || signage.length() < 2) { + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); + } + signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2); + + standardTicketInfoVo.setSignage(signage); + standardTicketInfoVo.setSignageCode(station.getCode()); + //2. 获取编码 + String code = processIdWorker.getTicketByCode(standardTicketInfoVo.getSignage(), this.getTicketWichCode(standardTicketInfoVo.getTicketType()), LocalDateTime.now()); + standardTicketInfoVo.setCode(code); + //3. 保存操作对象 + this.saveStandardTicketInfo(standardTicketInfoVo); + //5. 保存安全措施 + List standardTicketInfoVos = this.saveStandardTicketMeasure( + this.saveStandardTicketMeasureWichTicket(standardTicketInfoVo)); + standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos); + //6. 查询第一种工作票值 + String dictValue = processDictService.selectDictValueByKey(OPERATION_TICKET_KEY); + // 7.启动流程 + this.startProcess(standardTicketInfoVo, dictValue); + } + + /** + * 待处理 + * + * @param response + */ + @Override + public void findPending(ProcessWorkFlowResponse response) { + 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转换表单 + String formData = JSON.toJSONString(response.getVariables()); + log.info("获取表单的数据:{}", formData); + StandardTicketInfoVo standardTicketInfoVo = null; + try { + JSONObject jsonObject = JSONObject.parseObject(formData); + standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, StandardTicketInfoVo.class); + } catch (Exception e) { + log.error("获取表单出现异常了~~~~"); + throw new IllegalArgumentException(e.getMessage()); + } + + //1.查询操作票信息 + Long id = NumberUtils.toLong(response.getBusinessKey()); + StandardTicketInfoEntity standardTicketInfoEntity = standardTicketInfoService.getById(id); + if (ObjectUtils.isEmpty(standardTicketInfoEntity)) { + log.error("获取操作票不存在"); + return; + } + //设置id + StandardTicketInfoEntity newStandardTicketInfoEntity = new StandardTicketInfoEntity(); + BeanUtils.copyProperties(standardTicketInfoVo, newStandardTicketInfoEntity); + newStandardTicketInfoEntity.setId(id); + //填充操作票信息 + saveStandardTicketInfoEntity(newStandardTicketInfoEntity, response); + newStandardTicketInfoEntity.setProcessInstanceId(response.getProcessInstanceId()); + standardTicketInfoService.updateById(newStandardTicketInfoEntity); + + //更新安全措施 + List standardTicketMeasureVos = standardTicketInfoVo.getStandardTicketMeasureVos(); + if (CollectionUtils.isNotEmpty(standardTicketMeasureVos)) { + List standardTicketMeasureEntities = standardTicketMeasureVos.stream().map(standardTicketMeasureVo -> { + StandardTicketMeasureEntity standardTicketMeasureEntity = new StandardTicketMeasureEntity(); + BeanUtils.copyProperties(standardTicketMeasureVo, standardTicketMeasureEntity); + return standardTicketMeasureEntity; + }).collect(Collectors.toList()); + standardTicketMeasureService.updateBatchById(standardTicketMeasureEntities); + } + + + //推送消息 + if (response.getTaskId() != null) { + MessagePushRecordDto message = new MessagePushRecordDto(); + message.setBusinessClassify("business"); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getKey()); + message.setSubject(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getDescription()); + message.setTaskId(standardTicketInfoEntity.getId()); + message.setTenantId("200000"); + message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); + message.setPushType(MessageConstants.IMMEDIATELY); + //您有一张工作票待审批,工作内容:*****,审批环节:*****; + String countent = + "您有一张工作票待审批,工作内容:".concat(standardTicketInfoEntity.getTitle()) + .concat(",审批环节:") + .concat(response.getTaskName()); + message.setContent(countent); + message.setDeptId(standardTicketInfoEntity.getCreateDept()); + R deptName = sysClient.getDeptName(standardTicketInfoEntity.getCreateDept()); + if (deptName.isSuccess()) { + message.setDeptName(deptName.getData()); + } + String userIds = response.getUserId(); + if (StringUtils.isBlank(userIds)) { + log.error("推送的消息不能为空哦,{}", userIds); + return; + } + String[] split = userIds.split(","); + for (String userId : split) { + message.setPusher(userId); + User user = UserCache.getUser(NumberUtils.toLong(userId)); + if (ObjectUtils.isNotEmpty(user)) { + message.setPusherName(user.getName()); + } + message.setAccount(userId); + + message.setCreateUser(NumberUtils.toLong(userId)); + messageClient.sendMessage(message); + } + } + } + + /** + * 填充数据 + * + * @param newStandardTicketInfoEntity + * @param response + */ + private void saveStandardTicketInfoEntity(StandardTicketInfoEntity newStandardTicketInfoEntity, ProcessWorkFlowResponse response) { + String flowDescription = ""; + //如果response.getHandleType() 是0使用户 + newStandardTicketInfoEntity.setFlowUserId(response.getUserId()); + newStandardTicketInfoEntity.setNextStepOperator(response.getNextStepOperator()); + flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(response.getNextStepOperator()).concat("审批"); + //如果taskId为空 + String taskId = response.getTaskId(); + if (StringUtils.isEmpty(taskId)) { + newStandardTicketInfoEntity.setFlowDescription("结束"); + newStandardTicketInfoEntity.setFlowTaskId(" "); + newStandardTicketInfoEntity.setFlowTaskName("结束"); + newStandardTicketInfoEntity.setNextStepOperator(" "); + newStandardTicketInfoEntity.setFlowStatus(999); + } else { + newStandardTicketInfoEntity.setFlowTaskId(taskId); + newStandardTicketInfoEntity.setFlowTaskName(response.getTaskName()); + newStandardTicketInfoEntity.setFlowDescription(flowDescription); + } + } + + /** + * 启动流程 + * + * @param standardTicketInfoVo + * @param dictValue + */ + private void startProcess(StandardTicketInfoVo standardTicketInfoVo, String dictValue) { + Instant start = Instant.now(); + Map params = new HashMap<>(4); + params.put("standardTicketInfoVo", standardTicketInfoVo); + params.put("taskId", standardTicketInfoVo.getId()); + params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString())); + //已开启流程 + R processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, + String.valueOf(standardTicketInfoVo.getId()), standardTicketInfoVo.getTitle(), params); + if (!processInstanceContainNameByKey.isSuccess()) { + log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg()); + throw new ServiceException("不好意思,您暂无权限..."); + } + Duration between = Duration.between(start, Instant.now()); + log.info("================================================================"); + log.info("耗时: " + (between.getSeconds()) + "秒"); + log.info("耗时: " + (between.toMillis()) + "毫秒"); + log.info("================================================================"); + } + + + /** + * 设置安全措施值 + * + * @param standardTicketInfoVo + * @return + */ + private List saveStandardTicketMeasureWichTicket(StandardTicketInfoVo standardTicketInfoVo) { + List standardTicketMeasureVos = standardTicketInfoVo.getStandardTicketMeasureVos(); + if (CollectionUtils.isNotEmpty(standardTicketMeasureVos)) { + List measureEntityList = BeanUtil.copyProperties(standardTicketMeasureVos, + StandardTicketMeasureEntity.class); + List collect = measureEntityList.stream().map(item -> { + item.setTicketId(standardTicketInfoVo.getId()); + return item; + }).collect(Collectors.toList()); + return collect; + + } + return null; + } + + /** + * 保存安全措施 + * + * @param measureEntityList + * @return + */ + private List saveStandardTicketMeasure(List measureEntityList) { + if (CollectionUtils.isEmpty(measureEntityList)) { + log.error("安全措施为空哦"); + return new ArrayList<>(); + } + boolean save = standardTicketMeasureService.saveBatch(measureEntityList); + if (!save) { + throw new ServiceException("Save failed"); + } + + return measureEntityList.stream().map(item -> { + StandardTicketMeasureVo standardTicketMeasureVo = new StandardTicketMeasureVo(); + BeanUtils.copyProperties(item, standardTicketMeasureVo); + return standardTicketMeasureVo; + }).collect(Collectors.toList()); + } + + /** + * 保存工作对象 + * + * @param standardTicketInfoVo + * @return + */ + private void saveStandardTicketInfo(StandardTicketInfoVo standardTicketInfoVo) { + StandardTicketInfoEntity standardTicketInfo = new StandardTicketInfoEntity(); + BeanUtils.copyProperties(standardTicketInfoVo, standardTicketInfo); + boolean save = standardTicketInfoService.save(standardTicketInfo); + if (!save) { + throw new ServiceException("Save failed"); + } + BeanUtils.copyProperties(standardTicketInfo, standardTicketInfoVo); + } + + + /** + * 工作类型生成工作票类型 + */ + private String getTicketWichCode(String type) { + String result = null; + switch (type) { + case "3": + result = "DZ"; + break; + case "4": + result = type; + break; + case "5": + result = type; + break; + default: + result = "DZ"; + break; + } + return result; + } +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java index 15202c8..d536b9d 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java @@ -4,12 +4,10 @@ package com.hnac.hzims.ticket.twoTicket.service.impl; import cn.afterturn.easypoi.word.WordExportUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import com.google.common.collect.Lists; import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.MessagePushRecordDto; @@ -151,7 +149,6 @@ public class TicketProcessServiceImpl implements TicketProcessService { private final ProcessDictService processDictService; - private final IMessageClient messageClient; @@ -184,20 +181,21 @@ public class TicketProcessServiceImpl implements TicketProcessService { 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); workTicketVo.getWorkTicket().setSignage(signage); workTicketVo.getWorkTicket().setSignageCode(station.getCode()); //2. 获取编码 - String code = processIdWorker.getTicketByCode(workTicketVo.getWorkTicket().getSignage(), workTicketVo.getWorkTicket().getType(), LocalDateTime.now()); + String code = processIdWorker.getTicketByCode(workTicketVo.getWorkTicket().getSignage(), this.getTicketWichCode(workTicketVo.getWorkTicket().getType()), + LocalDateTime.now()); workTicketVo.getWorkTicket().setCode(code); //3 .保存工作对象 this.saveWorkTicketInfo(workTicketVo.getWorkTicket()); @@ -270,7 +268,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { for (WorkTicketSafetyMeasureEntity item : safetyMeasuresList) { if (ObjectUtils.isNotEmpty(item.getId())) { workTicketSafetyMeasureService.updateById(item); - }else { + } else { item.setTicketId(workTicketInfo.getId()); workTicketSafetyMeasureService.save(item); } @@ -279,20 +277,24 @@ public class TicketProcessServiceImpl implements TicketProcessService { } catch (Exception e) { e.printStackTrace(); } - //工作票工作任务组 - // List workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList(); - // if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) { - // log.info("获取工作票工作任务组:{}", workTicketContentDtoList); - // workTicketContentDtoList.forEach(item -> { - // if (ObjectUtils.isEmpty(item.getId())) { - // LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - // queryWrapper.eq(WorkTicketContentEntity::getTicketId, workTicketInfo.getId()); - // contentService.update(item, queryWrapper); - // } else { - // contentService.updateById(item); - // } - // }); - // } + // 第二种 工作票工作任务组 + List workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList(); + try { + if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) { + log.info("获取工作票工作任务组:{}", workTicketContentDtoList); + workTicketContentDtoList.forEach(item -> { + if (ObjectUtils.isEmpty(item.getId())) { + contentService.save(item); + } else { + contentService.updateById(item); + } + }); + } + } catch (Exception e) { + e.printStackTrace(); + } + + // 工作票延期 WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay(); try { @@ -314,10 +316,12 @@ public class TicketProcessServiceImpl implements TicketProcessService { } catch (Exception e) { e.printStackTrace(); } + + //工作结束 WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish(); try { - log.info("工作结束==============>"+ (workTicket.getFlowStatus().intValue())); + log.info("工作结束==============>" + (workTicket.getFlowStatus().intValue())); if (ObjectUtils.isNotEmpty(workTicketFinish)) { WorkTicketFinish ticketFinish = workTicketFinishService.selectByTicketId(workTicketInfo.getId()); log.info("获取工作结束:{}", workTicketFinish); @@ -398,43 +402,48 @@ public class TicketProcessServiceImpl implements TicketProcessService { } + if (response.getTaskId() != null || response.getUserId() != null) { + //推送消息 + try { + MessagePushRecordDto message = new MessagePushRecordDto(); + message.setBusinessClassify("business"); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey()); + message.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription()); + message.setTaskId(workTicketInfo.getId()); + message.setTenantId("200000"); + message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); + message.setPushType(MessageConstants.IMMEDIATELY); + //您有一张工作票待审批,工作内容:*****,审批环节:*****; + String countent = + "您有一张工作票待审批,工作内容:".concat(workTicketInfo.getWorkContent()) + .concat(",审批环节:") + .concat(response.getTaskName()); + message.setContent(countent); + message.setDeptId(workTicketInfo.getCreateDept()); + R deptName = sysClient.getDeptName(workTicketInfo.getCreateDept()); + if (deptName.isSuccess()) { + message.setDeptName(deptName.getData()); + } + String userIds = response.getUserId(); + if (StringUtils.isBlank(userIds)) { + log.error("推送的消息不能为空哦,{}", userIds); + return; + } + String[] split = userIds.split(","); + for (String userId : split) { + message.setPusher(userId); + User user = UserCache.getUser(NumberUtils.toLong(userId)); + if (ObjectUtils.isNotEmpty(user)) { + message.setPusherName(user.getName()); + } + message.setAccount(userId); - //推送消息 - MessagePushRecordDto message = new MessagePushRecordDto(); - message.setBusinessClassify("business"); - message.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey()); - message.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription()); - message.setTaskId(workTicketInfo.getId()); - message.setTenantId("200000"); - message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); - message.setPushType(MessageConstants.IMMEDIATELY); - //您有一张工作票待审批,工作内容:*****,审批环节:*****; - String countent = - "您有一张工作票待审批,工作内容:".concat(workTicketInfo.getWorkContent()) - .concat(",审批环节:") - .concat(response.getTaskName()); - message.setContent(countent); - message.setDeptId(workTicketInfo.getCreateDept()); - R deptName = sysClient.getDeptName(workTicketInfo.getCreateDept()); - if (deptName.isSuccess()) { - message.setDeptName(deptName.getData()); - } - String userIds = response.getUserId(); - if (StringUtils.isBlank(userIds)){ - log.error("推送的消息不能为空哦,{}",userIds); - return; - } - String[] split = userIds.split(","); - for (String userId : split) { - message.setPusher(userId); - User user = UserCache.getUser(NumberUtils.toLong(userId)); - if (ObjectUtils.isNotEmpty(user)) { - message.setPusherName(user.getName()); + message.setCreateUser(NumberUtils.toLong(userId)); + messageClient.sendMessage(message); + } + } catch (Exception e) { + e.printStackTrace(); } - message.setAccount(userId); - - message.setCreateUser(NumberUtils.toLong(userId)); - messageClient.sendMessage(message); } } @@ -479,6 +488,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { // } workTicket.setFlowUserId(response.getUserId()); workTicket.setNextStepOperator(response.getNextStepOperator()); + flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(response.getNextStepOperator()).concat("审批"); } //如果taskId为空 @@ -1149,7 +1159,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { Map stringObjectMap = matterLibraryListFive.get(i); objectObjectHashMap.put("safetyMeasure1", stringObjectMap.get("safetyMeasure")); } - }else { + } else { objectObjectHashMap.put("safetyMeasure1", ""); } @@ -1217,7 +1227,32 @@ public class TicketProcessServiceImpl implements TicketProcessService { if (StringUtils.isNoneBlank(newValue)) { dataConversion.put(key, BooleanUtils.toBoolean(newValue) ? "☑" : "□"); } + + } + + /** + * 工作类型生成工作票类型 + */ + private String getTicketWichCode(String type) { + String result = null; + switch (type) { + case "6": + result = "D1"; + break; + case "7": + result = "D2"; + break; + case "8": + result = "JX"; + break; + default: + result = "D1"; + break; + } + return result; + } + } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java new file mode 100644 index 0000000..70ca8e5 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java @@ -0,0 +1,120 @@ +package com.hnac.hzims.ticket.twoTicket.vo.operation; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; +import org.springblade.core.tenant.mp.TenantEntity; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/6 15:39 + */ +@Data +@Accessors(chain = true) +public class StandardTicketInfoVo extends TenantEntity { + + + @ApiModelProperty("票据类型") + private String ticketType; + + + + @ApiModelProperty("单位") + private String company; + + @ApiModelProperty("工作流ID") + private String processInstanceId; + + + @ApiModelProperty("编号") + private String code; + + @ApiModelProperty("发令人") + private Long issueOrderPerson; + + @ApiModelProperty("受令人") + private Long accessOrderPerson; + + @ApiModelProperty("发令时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime issueOrderTime; + + @ApiModelProperty("操作开始时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime startTime; + + @ApiModelProperty("操作结束时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime endTime; + + @ApiModelProperty("操作任务") + private String title; + + @ApiModelProperty("任务类型") + private String taskType; + + @ApiModelProperty("关联业务任务ID") + private Long taskId; + + @ApiModelProperty("关联业务名称") + private String taskName; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("监护人") + private Long guardian; + + @ApiModelProperty("操作人") + private Long operator; + + @ApiModelProperty("操作时间") + private LocalDateTime operateTime; + + @ApiModelProperty("负责人确认时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime guardianshipTime; + + @ApiModelProperty("值班负责人") + private Long principal; + + @ApiModelProperty("值班负责人确认时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime principalTime; + + @ApiModelProperty("是否评价") + private Integer isEvaluate; + + + /** + * AA/AAA/AAAA由建站时建站人填写必须系统验证唯一性 + * 站点标识-两票编码 + */ + @ApiModelProperty("站点标识-两票编码") + private String signage; + + + /** + * 编号(原站点ID) + */ + @ApiModelProperty("编号(原站点ID)") + private String signageCode; + + + /** + * 安全措施 + */ + private List standardTicketMeasureVos; +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketMeasureVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketMeasureVo.java new file mode 100644 index 0000000..03702a7 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketMeasureVo.java @@ -0,0 +1,57 @@ +package com.hnac.hzims.ticket.twoTicket.vo.operation; + +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/6 15:47 + */ +@Data +public class StandardTicketMeasureVo extends TenantEntity { + + + private static final long serialVersionUID = 8503146008417850183L; + + @ApiModelProperty("标准票ID") + private Long ticketId; + + @ApiModelProperty("分组") + private Long matterGroup; + + @ApiModelProperty("安全措施ID") + private Long measureId; + + @ApiModelProperty("安全措施") + private String measure; + + @ApiModelProperty("执行人") + private Long executor; + + @ApiModelProperty("执行时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime executeTime; + + @ApiModelProperty("执行图片") + private String executeImgUrl; + + @ApiModelProperty("执行备注") + private String remark; + + @ApiModelProperty("操作事项排序") + private Integer sort; +}