Browse Source

移除lettuce-core

zhongwei
段飞宇 2 years ago
parent
commit
4c9d69c8c0
  1. 32
      hzims-service/ticket/pom.xml
  2. 26
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardWorkTicketController.java
  3. 38
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/abstracts/TicketAbstractService.java
  4. 30
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/entity/Ticket.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. 8
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/utils/StandardTicketIdWorker.java

32
hzims-service/ticket/pom.xml

@ -102,7 +102,39 @@
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-core-boot</artifactId> <artifactId>blade-core-boot</artifactId>
<exclusions>
<exclusion>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-redis</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-redis</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-core-cloud</artifactId> <artifactId>blade-core-cloud</artifactId>

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

@ -4,6 +4,8 @@ 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.standardTicket.strategy.service.TicketService;
import com.hnac.hzims.ticket.standardTicket.utils.StandardTicketIdWorker; import com.hnac.hzims.ticket.standardTicket.utils.StandardTicketIdWorker;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -12,10 +14,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
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.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import java.util.ArrayList;
import org.springframework.web.bind.annotation.RestController; import java.util.List;
/** /**
* 工作票管理 * 工作票管理
@ -42,6 +44,10 @@ public class StandardWorkTicketController {
@Autowired @Autowired
private StandardTicketIdWorker standardTicketIdWorker; private StandardTicketIdWorker standardTicketIdWorker;
@Autowired
List<TicketService> ticketService;
@ApiOperation("测试开票") @ApiOperation("测试开票")
@PostMapping("/createTicket") @PostMapping("/createTicket")
public R createTicket() { public R createTicket() {
@ -63,4 +69,16 @@ public class StandardWorkTicketController {
return R.data(ticketCode); return R.data(ticketCode);
} }
@ApiOperation("测试")
@GetMapping("/hello/{type}")
public R hello(@PathVariable int type) {
TicketService service = ticketService.stream().filter(item -> item.isCurrentTicket(type))
.findFirst().orElse(null);
String calculate = service.calculate(new Ticket());
return R.data(calculate);
}
} }

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

@ -0,0 +1,38 @@
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;
}
}

30
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/strategy/entity/Ticket.java

@ -0,0 +1,30 @@
package com.hnac.hzims.ticket.standardTicket.strategy.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/27 16:49
*/
@Data
@Accessors(chain = true)
public class Ticket {
/**
* 实例Id
*/
private String flowId;
/**
* 实例Id说明
*/
private String segment;
}

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

@ -0,0 +1,29 @@
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

@ -0,0 +1,40 @@
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

@ -0,0 +1,43 @@
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 "签发人签发";
}
}

8
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/utils/StandardTicketIdWorker.java

@ -8,9 +8,12 @@ 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;
@ -55,13 +58,13 @@ public class StandardTicketIdWorker {
AtomicInteger atomicInteger = new AtomicInteger(1); AtomicInteger atomicInteger = new AtomicInteger(1);
String key = staff + ":" + typeInstrument + ":" + YearMonth; String key = staff + ":" + typeInstrument + ":" + YearMonth;
// TicketCode ticketCode1 = cacheMap.get(key); // TicketCode ticketCode1 = cacheMap.get(key);
TicketCode ticketCode = JSON.parseObject(operations.get(key),TicketCode.class); TicketCode ticketCode = JSON.parseObject(operations.get(key), TicketCode.class);
if (ticketCode == null) { if (ticketCode == null) {
ticketCode = new TicketCode(); ticketCode = new TicketCode();
ticketCode.setYearMonth(YearMonth); ticketCode.setYearMonth(YearMonth);
ticketCode.setSequencing(atomicInteger); ticketCode.setSequencing(atomicInteger);
// cacheMap.put(key, ticketCode); // cacheMap.put(key, ticketCode);
operations.set(key,JSON.toJSONString(ticketCode)); operations.set(key, JSON.toJSONString(ticketCode));
String result = getTicketCode(staff, typeInstrument, YearMonth, atomicInteger.get()); String result = getTicketCode(staff, typeInstrument, YearMonth, atomicInteger.get());
return result; return result;
} }
@ -192,7 +195,6 @@ public class StandardTicketIdWorker {
// //
// String format = numberFormatter.format(2); // String format = numberFormatter.format(2);
// System.out.println(format); // System.out.println(format);
} }

Loading…
Cancel
Save