Browse Source

processFlow 修复

zhongwei
段飞宇 1 year ago
parent
commit
7df7086b3a
  1. 2
      hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/constant/TicketProcessConstant.java
  2. 43
      hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/fegin/ProcessDictFeignService.java
  3. 43
      hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/fegin/fallback/ProcessDictFeignServiceFallback.java
  4. 33
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/controller/ProcessDictController.java
  5. 1
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/controller/ProcessTypeController.java
  6. 2
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MachineryTicketProcessServiceImpl.java
  7. 3
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MaintenanceProcessServiceImpl.java
  8. 2
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java
  9. 2
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java
  10. 78
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardWorkTicketController.java
  11. 26
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java
  12. 26
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

2
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/constant/TicketProcessConstant.java → hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/constant/TicketProcessConstant.java

@ -1,4 +1,4 @@
package com.hnac.hzims.middle.processflow.constant;
package com.hnac.hzims.common.logs.constant;
/**
* 开票常量类

43
hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/fegin/ProcessDictFeignService.java

@ -0,0 +1,43 @@
package com.hnac.hzims.common.logs.fegin;
import com.hnac.hzims.common.logs.fegin.fallback.ProcessDictFeignServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.time.LocalDateTime;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/6/15 15:16
*/
@Repository
@FeignClient(value = "hzims-middle", fallback = ProcessDictFeignServiceFallback.class)
public interface ProcessDictFeignService {
/**
* 获取工作票工作票唯一ID
*
* @param staff
* @param typeInstrument
* @param createTime
* @return
*/
@GetMapping("/process-dict/getTicketByCode")
public String getTicketByCode(@RequestParam("staff") String staff,
@RequestParam("typeInstrument") String typeInstrument,
@RequestParam("createTime") LocalDateTime createTime);
/**
* 根据工作流key获取工作流value
*
* @param dictKey
* @return
*/
@GetMapping("/process-dict/selectDictValueByKey")
public String selectDictValueByKey(@RequestParam("dictKey") String dictKey);
}

43
hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/fegin/fallback/ProcessDictFeignServiceFallback.java

@ -0,0 +1,43 @@
package com.hnac.hzims.common.logs.fegin.fallback;
import com.hnac.hzims.common.logs.fegin.ProcessDictFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/6/15 15:17
*/
@Slf4j
@Service
public class ProcessDictFeignServiceFallback implements ProcessDictFeignService {
/**
* 获取工作票工作票唯一ID
*
* @param staff
* @param typeInstrument
* @param createTime
* @return
*/
@Override
public String getTicketByCode(String staff, String typeInstrument, LocalDateTime createTime) {
log.error("获取工作票工作票唯一ID 熔断措施");
return null;
}
/**
* 根据工作流key获取工作流value
*
* @param dictKey
* @return
*/
@Override
public String selectDictValueByKey(String dictKey) {
log.error("根据工作流key获取工作流value 熔断措施");
return null;
}
}

33
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/controller/ProcessDictController.java

@ -3,12 +3,16 @@ package com.hnac.hzims.middle.processflow.controller;
import com.hnac.hzims.middle.processflow.entity.ProcessDict;
import com.hnac.hzims.middle.processflow.service.ProcessDictService;
import com.hnac.hzims.middle.processflow.strategy.core.ProcessIdWorker;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
/**
* @Author WL
* @Version v1.0
@ -26,6 +30,7 @@ public class ProcessDictController {
private final ProcessDictService processDictService;
private final ProcessIdWorker processIdWorker;
@GetMapping("/test")
@ -52,4 +57,32 @@ public class ProcessDictController {
}
/**
* 获取工作票工作票唯一ID
*
* @param staff
* @param typeInstrument
* @param createTime
* @return
*/
@GetMapping("/getTicketByCode")
public String getTicketByCode(@RequestParam("staff") String staff,
@RequestParam("typeInstrument") String typeInstrument,
@RequestParam("createTime") LocalDateTime createTime) {
return processIdWorker.getTicketByCode(staff, typeInstrument, createTime);
}
/**
* 根据工作流key获取工作流value
*
* @param dictKey
* @return
*/
@GetMapping("/selectDictValueByKey")
public String selectDictValueByKey(@RequestParam("dictKey") String dictKey) {
return processDictService.selectDictValueByKey(dictKey);
}
}

1
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/controller/ProcessTypeController.java

@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.stream.Collectors;

2
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MachineryTicketProcessServiceImpl.java

@ -10,7 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springframework.stereotype.Service;
import static com.hnac.hzims.middle.processflow.constant.TicketProcessConstant.MACHINERY_TICKET_KEY;
import static com.hnac.hzims.common.logs.constant.TicketProcessConstant.MACHINERY_TICKET_KEY;
/**

3
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MaintenanceProcessServiceImpl.java

@ -10,8 +10,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springframework.stereotype.Service;
import static com.hnac.hzims.middle.processflow.constant.TicketProcessConstant.MAINTENANCE_KEY;
import static com.hnac.hzims.common.logs.constant.TicketProcessConstant.MAINTENANCE_KEY;
/**

2
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java

@ -11,7 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springframework.stereotype.Service;
import static com.hnac.hzims.middle.processflow.constant.TicketProcessConstant.FIRST_TICKET_KEY;
import static com.hnac.hzims.common.logs.constant.TicketProcessConstant.FIRST_TICKET_KEY;
/**

2
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java

@ -10,7 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springframework.stereotype.Service;
import static com.hnac.hzims.middle.processflow.constant.TicketProcessConstant.OPERATION_TICKET_KEY;
import static com.hnac.hzims.common.logs.constant.TicketProcessConstant.OPERATION_TICKET_KEY;
/**

78
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardWorkTicketController.java

@ -1,25 +1,10 @@
package com.hnac.hzims.ticket.standardTicket.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.hnac.hzims.ticket.standardTicket.service.StandardWorkTicketService;
import com.hnac.hzims.ticket.processflow.properties.TicketProperties;
import com.hnac.hzims.ticket.processflow.properties.WorkTicketProperties;
import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue;
import com.hnac.hzims.ticket.processflow.strategy.service.ProcessService;
import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 工作票管理
@ -36,65 +21,6 @@ import java.util.List;
@RequestMapping("/standard/wordTicket")
public class StandardWorkTicketController {
private final StandardWorkTicketService standardWorkTicketService;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private ProcessIdWorker standardTicketIdWorker;
@Autowired
List<ProcessService> ticketService;
@Autowired
private TicketProperties ticketProperties;
@ApiOperation("测试开票")
@PostMapping("/createTicket")
public R createTicket() {
ProcessWorkFlowResponse workTicketMessageResponse = new ProcessWorkFlowResponse();
workTicketMessageResponse.setTaskId(IdWorker.get32UUID());
workTicketMessageResponse.setTaskName("工作流");
String jsonString = JSON.toJSONString(workTicketMessageResponse);
redisTemplate.convertAndSend("blade:queue:flow", jsonString);
standardWorkTicketService.createTicket();
redisTemplate.opsForValue().set("1", "2");
return R.success("成功");
}
@ApiOperation("测试生成唯一编码")
@GetMapping("/idWored")
public R idWored() {
String ticketCode = standardTicketIdWorker.getTicketByCode("aa", "bb", LocalDateTime.now());
return R.data(ticketCode);
}
@ApiOperation("测试")
@GetMapping("/hello/{type}")
public R hello(@PathVariable String type) {
WorkflowQueue ticket = new WorkflowQueue();
ticket.setProcessDefinitionKey(type);
ProcessService service = ticketService.stream().filter(item -> item.isWorkflowProcess(ticket))
.findFirst().orElse(null);
service.calculate(new ProcessWorkFlowResponse());
return R.data("hello");
}
@ApiOperation("测试1")
@GetMapping("/hello1")
public R hello1() {
List<WorkTicketProperties> workTickets = ticketProperties.getWorkTickets();
System.out.println("workTickets = " + workTickets);
return R.data(workTickets);
}
}

26
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java

@ -5,15 +5,15 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.common.logs.fegin.ProcessDictFeignService;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
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.constants.TicketConstants;
import com.hnac.hzims.ticket.processflow.service.ProcessDictService;
import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker;
import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity;
import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketMeasureEntity;
import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService;
@ -25,7 +25,6 @@ import com.hnac.hzims.ticket.twoTicket.utils.WordMapUtils;
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo;
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketMeasureVo;
import com.hnac.hzims.ticket.utils.PdfUtils;
import com.hnac.hzims.common.to.process.ProcessWorkFlowResponse;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
@ -53,7 +52,8 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import static com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant.OPERATION_TICKET_KEY;
import static com.hnac.hzims.common.logs.constant.TicketProcessConstant.OPERATION_TICKET_KEY;
/**
* @Author WL
@ -74,11 +74,9 @@ public class OperationTicketServiceImpl implements OperationTicketService {
private final IStationClient stationClient;
private final ProcessIdWorker processIdWorker;
private final ProcessDictFeignService processDictFeignService;
private final ProcessDictService processDictService;
private final IFlowClient flowClient;
@ -126,7 +124,11 @@ public class OperationTicketServiceImpl implements OperationTicketService {
standardTicketInfoVo.setSignage(signage);
standardTicketInfoVo.setSignageCode(station.getCode());
//2. 获取编码
String code = processIdWorker.getTicketByCode(standardTicketInfoVo.getSignage(), this.getTicketWichCode(standardTicketInfoVo.getTicketType()), LocalDateTime.now());
String code = processDictFeignService.getTicketByCode(standardTicketInfoVo.getSignage(), this.getTicketWichCode(standardTicketInfoVo.getTicketType()), LocalDateTime.now());
log.info("获取编码: {}", code);
if (StringUtils.isBlank(code)) {
throw new ServiceException("服务器异常,请联系管理员");
}
standardTicketInfoVo.setCode(code);
//3. 保存操作对象
this.saveStandardTicketInfo(standardTicketInfoVo);
@ -134,8 +136,12 @@ public class OperationTicketServiceImpl implements OperationTicketService {
List<StandardTicketMeasureVo> standardTicketInfoVos = this.saveStandardTicketMeasure(
this.saveStandardTicketMeasureWichTicket(standardTicketInfoVo));
standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos);
//6. 查询第一种工作票值
String dictValue = processDictService.selectDictValueByKey(OPERATION_TICKET_KEY);
//6. 查询第操作票值
String dictValue = processDictFeignService.selectDictValueByKey(OPERATION_TICKET_KEY);
log.info("查询第操作票值: {}", dictValue);
if (StringUtils.isBlank(dictValue)) {
throw new ServiceException("服务器异常,请联系管理员");
}
// 7.启动流程
this.startProcess(standardTicketInfoVo, dictValue);
}

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

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.common.logs.fegin.ProcessDictFeignService;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.MessagePushRecordDto;
@ -20,8 +21,6 @@ import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzims.ticket.constants.TicketConstants;
import com.hnac.hzims.ticket.constants.WorkTicketConstants;
import com.hnac.hzims.ticket.processflow.service.ProcessDictService;
import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker;
import com.hnac.hzims.ticket.twoTicket.constant.TicketConstant;
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger;
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish;
@ -72,8 +71,8 @@ import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant.FIRST_TICKET_KEY;
import static com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant.MACHINERY_TICKET_KEY;
import static com.hnac.hzims.common.logs.constant.TicketProcessConstant.FIRST_TICKET_KEY;
import static com.hnac.hzims.common.logs.constant.TicketProcessConstant.MACHINERY_TICKET_KEY;
/**
@ -96,9 +95,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
private final IWorkTicketInfoService workTicketInfoService;
private final ProcessIdWorker processIdWorker;
private final IFirstWorkTicketService firstWorkTicketService;
@ -146,7 +142,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
private final TicketInfoDangerService ticketInfoDangerService;
private final ProcessDictService processDictService;
private final ProcessDictFeignService processDictFeignService;
private final IMessageClient messageClient;
@ -194,8 +190,12 @@ public class TicketProcessServiceImpl implements TicketProcessService {
workTicketVo.getWorkTicket().setSignage(station.getSignage());
workTicketVo.getWorkTicket().setSignageCode(station.getCode());
//2. 获取编码
String code = processIdWorker.getTicketByCode(signage, this.getTicketWichCode(workTicketVo.getWorkTicket().getType()),
String code = processDictFeignService.getTicketByCode(signage, this.getTicketWichCode(workTicketVo.getWorkTicket().getType()),
LocalDateTime.now());
log.info("获取编码: {}", code);
if (StringUtils.isBlank(code)) {
throw new ServiceException("服务器异常,请联系管理员");
}
workTicketVo.getWorkTicket().setCode(code);
//3 .保存工作对象
this.saveWorkTicketInfo(workTicketVo.getWorkTicket());
@ -203,8 +203,12 @@ public class TicketProcessServiceImpl implements TicketProcessService {
this.saveSafetyMeasures(workTicketVo.getSafetyMeasuresList(), workTicketVo.getWorkTicket());
//5. 保存工作任务
this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket());
//6. 查询第一种工作票值
//6. 查询第工作票值
String dictValue = getDictValue(workTicketVo);
log.info("查询第工作票值: {}", dictValue);
if (StringUtils.isBlank(dictValue)) {
throw new ServiceException("服务器异常,请联系管理员");
}
//7. 开启动作流
this.dealProcess(dictValue, workTicketVo);
//8. 处理任务
@ -232,7 +236,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
} else if ("8".equals(workTicketVo.getWorkTicket().getType()) && userId.longValue() != principal.longValue()) {
key = MACHINERY_TICKET_KEY;
}
String dictValue = processDictService.selectDictValueByKey(key);
String dictValue = processDictFeignService.selectDictValueByKey(key);
return dictValue;
}

Loading…
Cancel
Save