段飞宇
2 years ago
22 changed files with 657 additions and 416 deletions
@ -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); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
|
||||
} |
@ -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); |
||||
|
||||
} |
@ -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 "运行人接收"; |
||||
|
||||
} |
||||
} |
@ -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 "签发人签发"; |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
||||
|
||||
} |
@ -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); |
||||
|
||||
} |
@ -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 "开票"; |
||||
|
||||
} |
||||
} |
@ -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 "运行人接收"; |
||||
|
||||
} |
||||
} |
@ -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 "签发人签发"; |
||||
} |
||||
} |
@ -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 |
||||
|
Loading…
Reference in new issue