Browse Source

策略模式

zhongwei
段飞宇 2 years ago
parent
commit
6b21f9ac1f
  1. 21
      hzims-service/ticket/pom.xml
  2. 25
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/consumer/StandardWorkTicketConsumer.java
  3. 34
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardWorkTicketController.java
  4. 38
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/abstracts/TicketAbstractService.java
  5. 29
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/service/TicketService.java
  6. 40
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/serviceimpl/OperatorTicketServiceImpl.java
  7. 43
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/serviceimpl/SignatureTicketServiceImpl.java
  8. 54
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/consumer/StandardWorkTicketConsumer.java
  9. 30
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/properties/TicketProperties.java
  10. 22
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/properties/WorkTicketProperties.java
  11. 37
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/abstracts/TicketAbstractService.java
  12. 10
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/core/TicketIdWorker.java
  13. 15
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/entity/Ticket.java
  14. 28
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/service/TicketService.java
  15. 53
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/serviceimpl/MakeTicketServiceImpl.java
  16. 53
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/serviceimpl/OperatorTicketServiceImpl.java
  17. 54
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/serviceimpl/SignatureTicketServiceImpl.java
  18. 45
      hzims-service/ticket/src/main/resources/application.yml
  19. 12
      hzims-service/ticket/src/main/resources/bootstrap.yml
  20. 4
      hzims-service/ticket/src/test/resources/application.yml

21
hzims-service/ticket/pom.xml

@ -134,6 +134,12 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
@ -250,7 +256,20 @@
<artifactId>equipment-api</artifactId> <artifactId>equipment-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-spring-context -->
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-spring-context</artifactId>
<version>0.2.3-RC1</version>
</dependency>
</dependencies> </dependencies>
<repositories> <repositories>

25
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/consumer/StandardWorkTicketConsumer.java

@ -1,25 +0,0 @@
package com.hnac.hzims.ticket.standardTicket.consumer;
import lombok.extern.slf4j.Slf4j;
import org.springblade.queue.annotation.RedisQueue;
import org.springblade.queue.consume.IQueueConsume;
import org.springframework.stereotype.Service;
/**
* 监听数据的
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/24 9:46
*/
@Service
@RedisQueue(topicName = "blade:queue:flow")
@Slf4j
public class StandardWorkTicketConsumer implements IQueueConsume {
@Override
public void handlerMessage(String message) {
log.info("监听到数据:{}", message);
}
}

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

@ -4,9 +4,12 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.hnac.hzims.ticket.response.WorkTicketMessageResponse; import com.hnac.hzims.ticket.response.WorkTicketMessageResponse;
import com.hnac.hzims.ticket.standardTicket.service.StandardWorkTicketService; import com.hnac.hzims.ticket.standardTicket.service.StandardWorkTicketService;
import com.hnac.hzims.ticket.standardTicket.strategy.entity.Ticket; import com.hnac.hzims.ticket.twoTicket.properties.TicketProperties;
import com.hnac.hzims.ticket.standardTicket.strategy.service.TicketService; import com.hnac.hzims.ticket.twoTicket.properties.WorkTicketProperties;
import com.hnac.hzims.ticket.standardTicket.utils.StandardTicketIdWorker; import com.hnac.hzims.ticket.twoTicket.strategy.entity.Ticket;
import com.hnac.hzims.ticket.twoTicket.strategy.service.TicketService;
import com.hnac.hzims.ticket.twoTicket.strategy.core.TicketIdWorker;
import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -16,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -42,12 +44,16 @@ public class StandardWorkTicketController {
@Autowired @Autowired
private StandardTicketIdWorker standardTicketIdWorker; private TicketIdWorker standardTicketIdWorker;
@Autowired @Autowired
List<TicketService> ticketService; List<TicketService> ticketService;
@Autowired
private TicketProperties ticketProperties;
@ApiOperation("测试开票") @ApiOperation("测试开票")
@PostMapping("/createTicket") @PostMapping("/createTicket")
public R createTicket() { public R createTicket() {
@ -72,13 +78,23 @@ public class StandardWorkTicketController {
@ApiOperation("测试") @ApiOperation("测试")
@GetMapping("/hello/{type}") @GetMapping("/hello/{type}")
public R hello(@PathVariable int type) { public R hello(@PathVariable String type) {
Ticket ticket = new Ticket();
TicketService service = ticketService.stream().filter(item -> item.isCurrentTicket(type)) ticket.setDeploymentId(type);
TicketService service = ticketService.stream().filter(item -> item.isWorkflowTicket(ticket))
.findFirst().orElse(null); .findFirst().orElse(null);
String calculate = service.calculate(new Ticket()); String calculate = service.calculate(new WorkTicketInfoDto());
return R.data(calculate); return R.data(calculate);
} }
@ApiOperation("测试1")
@GetMapping("/hello1")
public R hello1() {
List<WorkTicketProperties> workTickets = ticketProperties.getWorkTickets();
System.out.println("workTickets = " + workTickets);
return R.data(workTickets);
}
} }

38
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/abstracts/TicketAbstractService.java

@ -1,38 +0,0 @@
package com.hnac.hzims.ticket.standardTicket.strategy.abstracts;
import com.hnac.hzims.ticket.standardTicket.strategy.service.TicketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/28 9:02
*/
@Slf4j
public abstract class TicketAbstractService implements TicketService {
@Autowired
private RedisTemplate redisTemplate;
/**
* 查询所有的方法
*
* @return
*/
public List<Integer> getTicketList() {
System.out.println("实例化:" +redisTemplate);
List<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
return list;
}
}

29
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/service/TicketService.java

@ -1,29 +0,0 @@
package com.hnac.hzims.ticket.standardTicket.strategy.service;
import com.hnac.hzims.ticket.standardTicket.strategy.entity.Ticket;
import java.util.List;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/27 16:39
*/
public interface TicketService {
/**
* 设置执行那种实现类
* @param type
* @return
*/
Boolean isCurrentTicket(int type);
/**
* 两票管理业务方法
* @param ticket
*/
String calculate(Ticket ticket);
}

40
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/serviceimpl/OperatorTicketServiceImpl.java

@ -1,40 +0,0 @@
package com.hnac.hzims.ticket.standardTicket.strategy.serviceimpl;
import com.hnac.hzims.ticket.standardTicket.strategy.abstracts.TicketAbstractService;
import com.hnac.hzims.ticket.standardTicket.strategy.entity.Ticket;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 运行人接收
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/28 8:47
*/
@Service
public class OperatorTicketServiceImpl extends TicketAbstractService {
/**
* 设置执行那种实现类
*
* @param type
* @return
*/
@Override
public Boolean isCurrentTicket(int type) {
List<Integer> ticketList = this.getTicketList();
return type == ticketList.get(1);
}
/**
* 两票管理业务方法
*
* @param ticket
*/
@Override
public String calculate(Ticket ticket) {
System.out.println("OperatorTicketServiceImpl");
return "运行人接收";
}
}

43
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/serviceimpl/SignatureTicketServiceImpl.java

@ -1,43 +0,0 @@
package com.hnac.hzims.ticket.standardTicket.strategy.serviceimpl;
import com.hnac.hzims.ticket.standardTicket.strategy.abstracts.TicketAbstractService;
import com.hnac.hzims.ticket.standardTicket.strategy.entity.Ticket;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 签发人签发
*
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/27 16:40
*/
@Service
public class SignatureTicketServiceImpl extends TicketAbstractService {
/**
* 设置执行那种实现类
*
* @param type
* @return
*/
@Override
public Boolean isCurrentTicket(int type) {
List<Integer> ticketList = this.getTicketList();
return type == ticketList.get(0);
}
/**
* 两票管理业务方法
*
* @param ticket
*/
@Override
public String calculate(Ticket ticket) {
System.out.println("SignatureTicketServiceImpl");
return "签发人签发";
}
}

54
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/consumer/StandardWorkTicketConsumer.java

@ -0,0 +1,54 @@
package com.hnac.hzims.ticket.twoTicket.consumer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.ticket.response.WorkTicketMessageResponse;
import com.hnac.hzims.ticket.twoTicket.strategy.entity.Ticket;
import com.hnac.hzims.ticket.twoTicket.strategy.service.TicketService;
import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto;
import lombok.extern.slf4j.Slf4j;
import org.springblade.queue.annotation.RedisQueue;
import org.springblade.queue.consume.IQueueConsume;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 监听数据的
*
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/24 9:46
*/
@Service
@RedisQueue(topicName = "blade:queue:flow")
@Slf4j
public class StandardWorkTicketConsumer implements IQueueConsume {
@Autowired
private List<TicketService> ticketServiceList;
@Override
public void handlerMessage(String message) {
log.info("监听到数据:{}", message);
WorkTicketMessageResponse response = JSONObject.parseObject(message, WorkTicketMessageResponse.class);
String taskDefinitionKey = response.getTaskDefinitionKey();
Ticket ticker = new Ticket();
ticker.setDeploymentId(taskDefinitionKey);
//判断执行具体的实现类
TicketService ticketService = ticketServiceList.stream().filter(item -> item.isWorkflowTicket(ticker))
.findFirst().orElse(null);
if (ObjectUtils.isNotEmpty(ticketService)){
Object formData = response.getFormData();
String jsonString = JSON.toJSONString(formData);
WorkTicketInfoDto workTicketInfoDto = JSON.parseObject(jsonString, WorkTicketInfoDto.class);
//执行业务方法
ticketService.calculate(workTicketInfoDto);
}
}
}

30
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/properties/TicketProperties.java

@ -0,0 +1,30 @@
package com.hnac.hzims.ticket.twoTicket.properties;
import com.alibaba.nacos.api.config.annotation.NacosConfigurationProperties;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 读取nacos 开票的数据
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/28 12:06
*/
@Data
@Accessors(chain = true)
@Component
@NacosPropertySource(dataId = "hzims-ticket-dev.yaml", autoRefreshed = true)
@ConfigurationProperties(prefix = "ticket")
@RefreshScope
public class TicketProperties {
private List<WorkTicketProperties> workTickets;
}

22
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/properties/WorkTicketProperties.java

@ -0,0 +1,22 @@
package com.hnac.hzims.ticket.twoTicket.properties;
import lombok.Data;
import lombok.Getter;
import lombok.experimental.Accessors;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/28 12:09
*/
@Data
@Accessors(chain = true)
public class WorkTicketProperties {
private Integer status;
private String flowId;
private String segment;
}

37
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/abstracts/TicketAbstractService.java

@ -0,0 +1,37 @@
package com.hnac.hzims.ticket.twoTicket.strategy.abstracts;
import com.hnac.hzims.ticket.twoTicket.properties.TicketProperties;
import com.hnac.hzims.ticket.twoTicket.properties.WorkTicketProperties;
import com.hnac.hzims.ticket.twoTicket.strategy.service.TicketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.ArrayList;
import java.util.List;
/**
* @Author dfy
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/28 9:02
*/
@Slf4j
public abstract class TicketAbstractService implements TicketService {
@Autowired
private TicketProperties ticketProperties;
/**
* 查询所有的方法
*
* @return
*/
public List<WorkTicketProperties> getTicketList() {
log.info("实例化:" + ticketProperties);
List<WorkTicketProperties> workTickets = ticketProperties.getWorkTickets();
return workTickets;
}
}

10
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/utils/StandardTicketIdWorker.java → hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/core/TicketIdWorker.java

@ -1,19 +1,15 @@
package com.hnac.hzims.ticket.standardTicket.utils; package com.hnac.hzims.ticket.twoTicket.strategy.core;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.xnio.sasl.SaslQop;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -27,7 +23,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* @Date 2023/3/27 10:11 * @Date 2023/3/27 10:11
*/ */
@Component @Component
public class StandardTicketIdWorker { public class TicketIdWorker {
private static Map<String, TicketCode> cacheMap = new HashMap<>(); private static Map<String, TicketCode> cacheMap = new HashMap<>();
@ -177,7 +173,7 @@ public class StandardTicketIdWorker {
public static void main(String[] args) { public static void main(String[] args) {
StandardTicketIdWorker standardTicketIdWorker = new StandardTicketIdWorker(); TicketIdWorker standardTicketIdWorker = new TicketIdWorker();
int count = 1; int count = 1;
while (count <= 1000) { while (count <= 1000) {

15
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/entity/Ticket.java → hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/entity/Ticket.java

@ -1,11 +1,11 @@
package com.hnac.hzims.ticket.standardTicket.strategy.entity; package com.hnac.hzims.ticket.twoTicket.strategy.entity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
/** /**
* @Author WL * @Author dfy
* @Version v1.0 * @Version v1.0
* @Serial 1.0 * @Serial 1.0
* @Date 2023/3/27 16:49 * @Date 2023/3/27 16:49
@ -15,16 +15,9 @@ import lombok.experimental.Accessors;
public class Ticket { public class Ticket {
/** /**
* 实例Id * 实例 key
*/ */
private String flowId; private String deploymentId ;
/**
* 实例Id说明
*/
private String segment;
} }

28
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/service/TicketService.java

@ -0,0 +1,28 @@
package com.hnac.hzims.ticket.twoTicket.strategy.service;
import com.hnac.hzims.ticket.twoTicket.strategy.entity.Ticket;
import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto;
/**
* @Author dfy
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/27 16:39
*/
public interface TicketService {
/**
* 设置执行那种实现类
* @param ticket
* @return
*/
Boolean isWorkflowTicket(Ticket ticket);
/**
* 两票管理业务方法
* @param workflowTicket
*/
String calculate(WorkTicketInfoDto workflowTicket);
}

53
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/serviceimpl/MakeTicketServiceImpl.java

@ -0,0 +1,53 @@
package com.hnac.hzims.ticket.twoTicket.strategy.serviceimpl;
import com.hnac.hzims.ticket.twoTicket.properties.WorkTicketProperties;
import com.hnac.hzims.ticket.twoTicket.strategy.abstracts.TicketAbstractService;
import com.hnac.hzims.ticket.twoTicket.strategy.entity.Ticket;
import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 开工作票流程实现类
*
* @Author dfy
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/28 8:47
*/
@Slf4j
@Service
public class MakeTicketServiceImpl extends TicketAbstractService {
/**
* 设置执行那种实现类
*
* @param ticket
* @return
*/
@Override
public Boolean isWorkflowTicket(Ticket ticket) {
log.info("是否执行开工作票流程环节操作~~~~,流程ticket: {}", ticket);
List<WorkTicketProperties> ticketList = this.getTicketList();
WorkTicketProperties properties = ticketList.get(0);
if (properties.getFlowId().equals(ticket.getDeploymentId())) {
log.info("已执行开工作票流程环节操作~~~~");
return true;
}
log.info("未是否执行开工作票流程环节操作,请联系管理员~~~~");
return false;
}
/**
* 两票管理业务方法
*
* @param workflowTicket
*/
@Override
public String calculate(WorkTicketInfoDto workflowTicket) {
System.out.println("OperatorTicketServiceImpl");
return "开票";
}
}

53
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/serviceimpl/OperatorTicketServiceImpl.java

@ -0,0 +1,53 @@
package com.hnac.hzims.ticket.twoTicket.strategy.serviceimpl;
import com.hnac.hzims.ticket.twoTicket.properties.WorkTicketProperties;
import com.hnac.hzims.ticket.twoTicket.strategy.abstracts.TicketAbstractService;
import com.hnac.hzims.ticket.twoTicket.strategy.entity.Ticket;
import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 运行人实例类 运行人接收
*
* @Author dfy
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/28 8:47
*/
@Slf4j
@Service
public class OperatorTicketServiceImpl extends TicketAbstractService {
/**
* 设置执行那种实现类
*
* @param ticket
* @return
*/
@Override
public Boolean isWorkflowTicket(Ticket ticket) {
log.info("是否执行运行人接收操作~~~~,流程ticket: {}", ticket);
List<WorkTicketProperties> ticketList = this.getTicketList();
WorkTicketProperties properties = ticketList.get(2);
if (properties.getFlowId().equals(ticket.getDeploymentId())) {
log.info("已执行运行人接收操作~~~~");
return true;
}
log.info("未执行运行人接收操作,请联系管理员~~~~");
return false;
}
/**
* 两票管理业务方法
*
* @param workflowTicket
*/
@Override
public String calculate(WorkTicketInfoDto workflowTicket) {
System.out.println("OperatorTicketServiceImpl");
return "运行人接收";
}
}

54
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/strategy/serviceimpl/SignatureTicketServiceImpl.java

@ -0,0 +1,54 @@
package com.hnac.hzims.ticket.twoTicket.strategy.serviceimpl;
import com.hnac.hzims.ticket.twoTicket.properties.WorkTicketProperties;
import com.hnac.hzims.ticket.twoTicket.strategy.abstracts.TicketAbstractService;
import com.hnac.hzims.ticket.twoTicket.strategy.entity.Ticket;
import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 签发人实现类签发人签发
*
* @Author dfy
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/27 16:40
*/
@Slf4j
@Service
public class SignatureTicketServiceImpl extends TicketAbstractService {
/**
* 设置执行那种实现类
*
* @param ticket
* @return
*/
@Override
public Boolean isWorkflowTicket(Ticket ticket) {
log.info("是否执行运行人接收操作~~~~,流程ticket: {}", ticket);
List<WorkTicketProperties> ticketList = this.getTicketList();
WorkTicketProperties properties = ticketList.get(1);
if (properties.getFlowId().equals(ticket.getDeploymentId())){
log.info("已执行运行人接收操作~~~~");
return true;
}
log.info("未执行运行人接收操作,请联系管理员~~~~");
return false;
}
/**
* 两票管理业务方法
*
* @param workflowTicket
*/
@Override
public String calculate(WorkTicketInfoDto workflowTicket) {
System.out.println("SignatureTicketServiceImpl");
return "签发人签发";
}
}

45
hzims-service/ticket/src/main/resources/application.yml

@ -9,3 +9,48 @@ swagger:
base-packages: base-packages:
- org.springbalde - org.springbalde
- com.hnac - com.hnac
#ticket:
# workTickets:
# - status: 1
# flowId: startEvent1
# segment: 开票
# - status: 2
# flowId: sid-5E7013A9-385A-4EE4-91B6-FD5328D05E2A
# segment: 签发人签发
# - status: 3
# flowId: sid-355DB6EC-7D54-4537-B80F-C26CD716ADA1
# segment: 运行人员接收
# - status: 4
# flowId: sid-F35C4A79-53AF-40B8-AFBD-AF7283CC5708
# segment: 运行人员布置安全措施
# - status: 5
# flowId: sid-0CB1456A-D85C-4473-A032-FAEF62EFBF22
# segment: 工作负责人确认安全措施
# - status: 6
# flowId: sid-5476EB52-438F-4C74-94FB-88A6EA6625EA
# segment: 工作负责人确认工作内容执行
# - status: 7
# flowId: sid-72E8C993-D426-476F-BF7F-F7EC3B783022
# segment: 许可人确认工作票结束、终结
# - status: 8
# flowId: sid-308606FE-820A-4A23-AF2A-4B1E9BBD267C
# segment: 工作负责人确认工作票结束、终结
# - status: 9
# flowId: sid-DABC1AF3-EB78-4913-8BFE-EA44C887B418
# segment: 签发人审核
# - status: 10
# flowId: sid-48995D69-1E09-4ED2-8C81-5D1A6D015FA5
# segment: 许可人许可
# - status: 11
# flowId: sid-FB7BF0B3-5189-437F-B29D-B87E22A81460
# segment: 工作票转移
# - status: 12
# flowId: sid-6358A80D-F592-4875-B281-A5B14A0EA39E
# segment: 工作票延期

12
hzims-service/ticket/src/main/resources/bootstrap.yml

@ -0,0 +1,12 @@
spring:
cloud:
nacos:
discovery:
server-addr: 175.6.40.67:10042
config:
extension-configs:
- data-id: hzims-ticket-dev.yaml
group: DEFAULT_GROUP
refresh: true
namespace: public

4
hzims-service/ticket/src/test/resources/application.yml

@ -9,3 +9,7 @@ swagger:
base-packages: base-packages:
- org.springbalde - org.springbalde
- com.hnac - com.hnac

Loading…
Cancel
Save