提交 2c7bd992 authored 作者: liuhaiquan's avatar liuhaiquan

Merge remote-tracking branch 'origin/v4.9_create_goods_child_20230918' into…

Merge remote-tracking branch 'origin/v4.9_create_goods_child_20230918' into v4.9_create_goods_child_20230918
package com.clx.performance.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.Optional;
public enum PendingOrderWayStatusEnum {
;
@Getter
@AllArgsConstructor
public enum Status {
GK(1, "GK"),
DX(2, "DX")
;
private final Integer code;
private final String name;
public static Optional<Status> getByCode(Integer code) {
return Arrays.stream(values()).filter(e -> e.code == code).findFirst();
}
}
}
......@@ -19,15 +19,17 @@ public class OrderGoodsIdGenerate {
@Autowired
private OrderGoodsDao orderGoodsDao;
private static final String type = "id";
public long getOrderGoodsId(String type, Integer size) {
public long getOrderGoodsId(Integer size) {
long baseStart = Long.parseLong(DateUtils.formatDate(LocalDate.now(), "yyyyMMdd").get() + "00001");
Object o = redisTemplate.opsForHash().get(RedisConstants.ORDER_GOODS_ID, type);
if (o == null ) {
Long maxOrderGoodsId = null;
String maxID = orderGoodsDao.getMaxOrderGoodsId(type);
if (StringUtils.isNotBlank(maxID)) {
maxOrderGoodsId = Long.valueOf(maxID.substring(0, 2));
maxOrderGoodsId = Long.valueOf(maxID);
}
if (maxOrderGoodsId == null) {
......
......@@ -4,6 +4,7 @@ public class RabbitKeyConstants {
public static final String ORDER_POSTED_QUEUE = "clx-order.order.posted.queue";
//改订单状态为已挂单
public static final String ORDER_POSTED_EXCHANGE = "clx-order.order.posted.exchange";
public static final String ORDER_POSTED_ROUTE_KEY ="clx-order.order.posted.route.key";
......@@ -17,6 +18,7 @@ public class RabbitKeyConstants {
public static final String ORDER_ON_EXCHANGE ="clx-order.order.on.exchange";
//更改订单状态为挂单中
public static final String ORDER_ON_DEAD_EXCHANGE ="clx-order.order.on.dead.exchange";
public static final String ORDER_ON_DEAD_QUEUE ="clx-order.order.on.dead.queue";
......
......@@ -111,7 +111,7 @@ public class GoodsOrderController {
epochMilli = sendLazyTime.minusMinutes(now.getMinute()).getMinute() * 60 * 1000;
log.info("执行订单状态更改,选择时间在当前时间之后,则设置延迟队列时间,时间为:{}", epochMilli);
//选择时间在当前时间之后,则设置延迟队列时间
}
if (epochMilli == 0L) {
log.info("执行订单状态更改,epochMilli时间为0,时间为:{}", epochMilli);
......@@ -121,7 +121,7 @@ public class GoodsOrderController {
);
} else {
log.info("执行订单状态更改,epochMilli时间不为0,时间为:{}", epochMilli);
rabbitTemplate.send(RabbitKeyConstants.ORDER_POSTED_EXCHANGE, RabbitKeyConstants.ORDER_POSTED_ROUTE_KEY, MessageBuilder.withBody(orderNo.toString().getBytes()).build());
rabbitTemplate.send(RabbitKeyConstants.ORDER_POSTED_EXCHANGE, RabbitKeyConstants.ORDER_POSTED_ROUTE_KEY, MessageBuilder.withBody(orderNo.getBytes()).build());
message.getMessageProperties().setExpiration(String.valueOf(epochMilli));
rabbitTemplate.send(
......
......@@ -82,7 +82,7 @@ public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
if (residueWeight.compareTo(childSum) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货单总吨数已超订单总吨数");
}
long beginOrderGoodsId = orderGoodsIdGenerate.getOrderGoodsId(OrderGoodsTypeEnum.Status.PLATFORM.getCode(), childParamsList.size());
long beginOrderGoodsId = orderGoodsIdGenerate.getOrderGoodsId(childParamsList.size());
Map<String, LocalDateTime> mqMap = new HashMap<>();
List<OrderGoods> orderGoodsList = new LinkedList<>();
......@@ -130,7 +130,10 @@ public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderGoods.setSeniorLogisticsManagerName(child.getSeniorLogisticsManagerName());
orderGoods.setOrderNo(orderNo);
orderGoods.setOrderGoodsNo(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
Integer pendingOrderWay = orderGoods.getPendingOrderWay();
String orderNoPrefix = PendingOrderWayStatusEnum.Status.GK.getCode().equals(pendingOrderWay) ? PendingOrderWayStatusEnum.Status.GK.getName() : PendingOrderWayStatusEnum.Status.DX.getName();
orderGoods.setOrderGoodsNo(orderNoPrefix + beginOrderGoodsId);
orderGoods.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CREATED.getCode());
orderGoods.setSendAddressId(orderInfo.getSendAddressId());
orderGoods.setSendAddressShorter(orderInfo.getSendAddressShorter());
......
......@@ -12,10 +12,7 @@ import com.clx.performance.component.OrderGoodsStatusLazyComponent;
import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.dao.OrderGoodsTruckBindDao;
import com.clx.performance.enums.OrderGoodsStatusEnum;
import com.clx.performance.enums.OrderGoodsTypeEnum;
import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.enums.TruckDemandEnum;
import com.clx.performance.enums.*;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.strategy.GoodsOrderStrategy;
......@@ -90,7 +87,7 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing
}
Map<String, LocalDateTime> mqMap = new HashMap<>();
long beginOrderGoodsId = orderGoodsIdGenerate.getOrderGoodsId(OrderGoodsTypeEnum.Status.PLATFORM.getCode(), childParamsList.size());
long beginOrderGoodsId = orderGoodsIdGenerate.getOrderGoodsId(childParamsList.size());
List<OrderGoods> orderGoodsList = new LinkedList<>();
for (OrderGoodsChildParams child : childParamsList) {
......@@ -132,7 +129,9 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing
orderGoods.setSeniorLogisticsManagerName(child.getSeniorLogisticsManagerName());
orderGoods.setOrderNo(orderNo);
orderGoods.setOrderGoodsNo(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
Integer pendingOrderWay = orderGoods.getPendingOrderWay();
String orderNoPrefix = PendingOrderWayStatusEnum.Status.GK.getCode().equals(pendingOrderWay) ? PendingOrderWayStatusEnum.Status.GK.getName() : PendingOrderWayStatusEnum.Status.DX.getName();
orderGoods.setOrderGoodsNo(orderNoPrefix + beginOrderGoodsId);
orderGoods.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CREATED.getCode());
orderGoods.setSendAddressId(orderInfo.getSendAddressId());
......
......@@ -92,7 +92,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
Map<String, LocalDateTime> mqMap = new HashMap<>();
List<OrderGoods> orderGoodsList = new LinkedList<>();
long beginOrderGoodsId = orderGoodsIdGenerate.getOrderGoodsId(OrderGoodsTypeEnum.Status.PLATFORM.getCode(), childParamsList.size());
long beginOrderGoodsId = orderGoodsIdGenerate.getOrderGoodsId(childParamsList.size());
for (OrderGoodsChildParams child : childParamsList) {
if (child.getPendingOrderWay().equals(2)) {
if (child.getNeedTruckNum() == null) {
......@@ -139,7 +139,9 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderGoods.setSeniorLogisticsManagerName(child.getSeniorLogisticsManagerName());
orderGoods.setOrderNo(orderNo);
orderGoods.setOrderGoodsNo(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
Integer pendingOrderWay = orderGoods.getPendingOrderWay();
String orderNoPrefix = PendingOrderWayStatusEnum.Status.GK.getCode().equals(pendingOrderWay) ? PendingOrderWayStatusEnum.Status.GK.getName() : PendingOrderWayStatusEnum.Status.DX.getName();
orderGoods.setOrderGoodsNo(orderNoPrefix + beginOrderGoodsId);
orderGoods.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CREATED.getCode());
orderGoods.setSendAddressId(orderInfo.getSendAddressId());
......
......@@ -2,7 +2,9 @@ package com.clx.performance;
import com.clx.order.feign.OrderFeign;
import com.clx.order.param.feign.UpdateOrderInfoResidueWeightParam;
import com.clx.performance.component.OrderGoodsStatusLazyComponent;
import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.constant.RedisConstants;
import com.clx.performance.mapper.OrderGoodsMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -11,9 +13,13 @@ import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.test.context.junit4.SpringRunner;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Set;
@SpringBootTest
@RunWith(SpringRunner.class)
......@@ -25,14 +31,22 @@ public class JobTest {
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private OrderGoodsStatusLazyComponent orderGoodsStatusLazyComponent;
@Test
public void test1() {
UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
param.setOrderId(150);
param.setUpdateType("1");
param.setResidueWeight(new BigDecimal(200));
orderFeign.updateOrderInfoResidueWeight(param);
orderGoodsStatusLazyComponent.consuming();
System.out.println();
// UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
// param.setOrderId(150);
// param.setUpdateType("1");
// param.setResidueWeight(new BigDecimal(200));
// orderFeign.updateOrderInfoResidueWeight(param);
// Message message = MessageBuilder.withBody("PT2023091900049".getBytes()).build();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论