Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 2 years ago
parent
commit
c7942dbb14
  1. 3
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/request/StationInfoReq.java
  2. 1
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java
  3. 58
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java
  4. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java
  5. 6
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java
  6. 7
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java
  7. 20
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessDictController.java
  8. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java
  9. 6
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java
  10. 69
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java
  11. 47
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java
  12. 28
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java
  13. 360
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java
  14. 79
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  15. 120
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java
  16. 57
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketMeasureVo.java

3
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/request/StationInfoReq.java

@ -36,4 +36,7 @@ public class StationInfoReq implements Serializable {
@ApiModelProperty("站点描述")
private String stationDesc;
@ApiModelProperty("租户ID")
private String tenantId;
}

1
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;

58
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;
}

4
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java

@ -20,6 +20,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
@ -51,13 +52,16 @@ public class FdpQuestionServiceImpl implements IFdpQuestionService {
R<StationEntity> stationResult = stationClient.getStationByCode(stationCode);
if(stationResult.isSuccess()) {
StationEntity stationEntity = stationResult.getData();
log.info("请求体为:{}",AuthUtil.getTenantId());
StationInfoReq infoReq = StationInfoReq.builder()
.stationId(stationCode)
.stationName(stationEntity.getName())
.type(this.getStationType(stationEntity.getType()))
.stationDesc(Optional.ofNullable(stationDesc).orElse(""))
.tenantId("200000")
.build();
if(Func.isNotEmpty(infoReq.getType())) {
log.info("请求体为:{}",JSON.toJSONString(infoReq));
HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getSubmitStationInfo())
.body(JSON.toJSONString(infoReq))
.execute();

6
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";
}

7
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 业务出错误 做补偿

20
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);
}

2
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();

6
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;
}

69
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);
}
}

47
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("申请开票成功");
}
}

28
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);
}

360
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<StationEntity> 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<StandardTicketMeasureVo> 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<StandardTicketMeasureVo> standardTicketMeasureVos = standardTicketInfoVo.getStandardTicketMeasureVos();
if (CollectionUtils.isNotEmpty(standardTicketMeasureVos)) {
List<StandardTicketMeasureEntity> 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<String> 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<String, Object> params = new HashMap<>(4);
params.put("standardTicketInfoVo", standardTicketInfoVo);
params.put("taskId", standardTicketInfoVo.getId());
params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString()));
//已开启流程
R<BladeFlow> 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<StandardTicketMeasureEntity> saveStandardTicketMeasureWichTicket(StandardTicketInfoVo standardTicketInfoVo) {
List<StandardTicketMeasureVo> standardTicketMeasureVos = standardTicketInfoVo.getStandardTicketMeasureVos();
if (CollectionUtils.isNotEmpty(standardTicketMeasureVos)) {
List<StandardTicketMeasureEntity> measureEntityList = BeanUtil.copyProperties(standardTicketMeasureVos,
StandardTicketMeasureEntity.class);
List<StandardTicketMeasureEntity> collect = measureEntityList.stream().map(item -> {
item.setTicketId(standardTicketInfoVo.getId());
return item;
}).collect(Collectors.toList());
return collect;
}
return null;
}
/**
* 保存安全措施
*
* @param measureEntityList
* @return
*/
private List<StandardTicketMeasureVo> saveStandardTicketMeasure(List<StandardTicketMeasureEntity> 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;
}
}

79
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());
@ -279,20 +277,24 @@ public class TicketProcessServiceImpl implements TicketProcessService {
} catch (Exception e) {
e.printStackTrace();
}
//工作票工作任务组
// List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList();
// if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) {
// log.info("获取工作票工作任务组:{}", workTicketContentDtoList);
// workTicketContentDtoList.forEach(item -> {
// if (ObjectUtils.isEmpty(item.getId())) {
// LambdaQueryWrapper<WorkTicketContentEntity> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(WorkTicketContentEntity::getTicketId, workTicketInfo.getId());
// contentService.update(item, queryWrapper);
// } else {
// contentService.updateById(item);
// }
// });
// }
// 第二种 工作票工作任务组
List<WorkTicketContentEntity> 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,6 +316,8 @@ public class TicketProcessServiceImpl implements TicketProcessService {
} catch (Exception e) {
e.printStackTrace();
}
//工作结束
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish();
try {
@ -398,8 +402,9 @@ 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());
@ -436,6 +441,10 @@ public class TicketProcessServiceImpl implements TicketProcessService {
message.setCreateUser(NumberUtils.toLong(userId));
messageClient.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@ -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为空
@ -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;
}
}

120
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<StandardTicketMeasureVo> standardTicketMeasureVos;
}

57
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;
}
Loading…
Cancel
Save