提交 ddd4635b 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
...@@ -20,4 +20,7 @@ public interface PerformanceFeign { ...@@ -20,4 +20,7 @@ public interface PerformanceFeign {
@GetMapping(value = {"clx-performance/feign/orderGoodsDriverTruck/getTrucksByOrderGoodsNo"}) @GetMapping(value = {"clx-performance/feign/orderGoodsDriverTruck/getTrucksByOrderGoodsNo"})
Result<List<Integer>> getTrucksByOrderGoodsNo(@RequestParam("orderGoodsNo") @NotBlank(message = "货单编号不可为空") String orderGoodsNo); Result<List<Integer>> getTrucksByOrderGoodsNo(@RequestParam("orderGoodsNo") @NotBlank(message = "货单编号不可为空") String orderGoodsNo);
@GetMapping(value = {"clx-performance/feign/orderChild/getOrderChildTotalByUserNo"})
Integer getOrderChildTotalByUserNo(@RequestParam("userNo") Long userNo);
} }
...@@ -91,4 +91,12 @@ public class RabbitBeanConfig { ...@@ -91,4 +91,12 @@ public class RabbitBeanConfig {
return BindingBuilder.bind(orderOnDeadQueue()).to(orderOnDeadExchange()).with(RabbitKeyConstants.ORDER_ON_ROUTE_KEY); return BindingBuilder.bind(orderOnDeadQueue()).to(orderOnDeadExchange()).with(RabbitKeyConstants.ORDER_ON_ROUTE_KEY);
} }
/* *//**
* 运单同步队列
*//*
@Bean
public Queue orderChildQueue() {
return new Queue(RabbitKeyConstants.CLX_PERFORMANCE_ORDER_CHILD_QUEUE, true);
}*/
} }
package com.clx.performance.controller.feign;
import com.clx.performance.service.OrderChildService;
import com.msl.common.result.Result;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
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 javax.validation.constraints.NotNull;
import java.util.List;
@RestController
@RequestMapping("/feign/orderChild")
@Validated
@Api(tags = "运单Feign")
@AllArgsConstructor
public class OrderChildController {
private final OrderChildService orderChildService;
@GetMapping({"/getOrderChildTotalByUserNo"})
Integer getTrucksByOrderGoodsNo(@RequestParam("userNo") @NotNull(message = "用户编号不可为空") Long userNo){
Integer totalByUserNo = orderChildService.getOrderChildTotalByUserNo(userNo);
return totalByUserNo;
}
}
...@@ -77,7 +77,6 @@ public class GoodsOrderController { ...@@ -77,7 +77,6 @@ public class GoodsOrderController {
String orderNo = orderGoodsParams.getOrderNo(); String orderNo = orderGoodsParams.getOrderNo();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
LocalDateTime sendLazyTime = null; LocalDateTime sendLazyTime = null;
//UserSessionData loginUserInfo = TokenUtil.getLoginUserInfo();
RLock rLock = null; RLock rLock = null;
try { try {
//1. 加分布式锁通过订单ID //1. 加分布式锁通过订单ID
...@@ -89,7 +88,7 @@ public class GoodsOrderController { ...@@ -89,7 +88,7 @@ public class GoodsOrderController {
FeignOrderVO orderInfo = orderFeign.getOrderInfoFeign(orderNo); FeignOrderVO orderInfo = orderFeign.getOrderInfoFeign(orderNo);
//1平台车辆 2部分平台车辆 3自有车辆 //1平台车辆 2部分平台车辆 3自有车辆
Integer truckDemand = orderInfo.getTruckDemand(); Integer truckDemand = orderInfo.getTruckDemand();
sendLazyTime = goodsOrderStrategyContext.strategyContext.get(truckDemand).goodsOrderProcess(orderGoodsParams,orderInfo); sendLazyTime = goodsOrderStrategyContext.strategyContext.get(truckDemand).goodsOrderProcess(orderGoodsParams, orderInfo);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
...@@ -107,14 +106,21 @@ public class GoodsOrderController { ...@@ -107,14 +106,21 @@ public class GoodsOrderController {
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.toString().getBytes()).build());
Message message = MessageBuilder.withBody(orderNo.getBytes()).build(); Message message = MessageBuilder.withBody(orderNo.getBytes()).build();
long epochMilli = 0L; long epochMilli = 0L;
if(sendLazyTime.isAfter(now)){ if (sendLazyTime.isAfter(now)) {
//选择时间在当前时间之后,则设置延迟队列时间 //选择时间在当前时间之后,则设置延迟队列时间
epochMilli = sendLazyTime.minusMinutes(now.getMinute()).getMinute() * 60 * 1000; epochMilli = sendLazyTime.minusMinutes(now.getMinute()).getMinute() * 60 * 1000;
} }
message.getMessageProperties().setExpiration(String.valueOf(epochMilli)); if (epochMilli == 0L) {
rabbitTemplate.send( rabbitTemplate.send(
RabbitKeyConstants.ORDER_ON_EXCHANGE, RabbitKeyConstants.ORDER_ON_ROUTE_KEY, message RabbitKeyConstants.ORDER_ON_DEAD_EXCHANGE, RabbitKeyConstants.ORDER_ON_ROUTE_KEY, message
); );
} else {
message.getMessageProperties().setExpiration(String.valueOf(epochMilli));
rabbitTemplate.send(
RabbitKeyConstants.ORDER_ON_EXCHANGE, RabbitKeyConstants.ORDER_ON_ROUTE_KEY, message
);
}
return Result.ok(); return Result.ok();
} }
......
...@@ -52,4 +52,5 @@ public interface OrderChildDao extends BaseDao<OrderChildMapper, OrderChild, Int ...@@ -52,4 +52,5 @@ public interface OrderChildDao extends BaseDao<OrderChildMapper, OrderChild, Int
int countValidByOrderGoodsNo(String orderGoodsNo); int countValidByOrderGoodsNo(String orderGoodsNo);
Integer getOrderChildTotalByUserNo(Long userNo);
} }
...@@ -179,4 +179,9 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -179,4 +179,9 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
return baseMapper.countValidByOrderGoodsNo(orderGoodsNo); return baseMapper.countValidByOrderGoodsNo(orderGoodsNo);
} }
@Override
public Integer getOrderChildTotalByUserNo(Long userNo) {
return baseMapper.getOrderChildTotalByUserNo(userNo);
}
} }
package com.clx.performance.listener; //package com.clx.performance.listener;
//
import com.alibaba.fastjson.JSON; //import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; //import com.alibaba.fastjson.JSONObject;
import com.clx.performance.constant.RabbitKeyConstants; //import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.data.OrderChildData; //import com.clx.performance.data.OrderChildData;
import com.msl.common.utils.DtsMapConvertUtil; //import com.msl.common.utils.DtsMapConvertUtil;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.*; //import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
//
@Slf4j //@Slf4j
@Component //@Component
@RabbitListener(queues = RabbitKeyConstants.CLX_PERFORMANCE_ORDER_CHILD_QUEUE) //@RabbitListener(queues = RabbitKeyConstants.CLX_PERFORMANCE_ORDER_CHILD_QUEUE)
public class OrderChildDtsListener { //public class OrderChildDtsListener {
//
//
@RabbitHandler // @RabbitHandler
public void dealMessage(byte[] message) { // public void dealMessage(byte[] message) {
try { // try {
String msg = new String(message); // String msg = new String(message);
log.info("DTS消息同步开始, database:order_service, msg:{}", msg); // log.info("DTS消息同步开始, database:order_service, msg:{}", msg);
//
JSONObject object = JSON.parseObject(msg); // JSONObject object = JSON.parseObject(msg);
//
JSONObject beforeMap = object.getJSONObject("beforeMap"); // JSONObject beforeMap = object.getJSONObject("beforeMap");
JSONObject afterMap = object.getJSONObject("afterMap"); // JSONObject afterMap = object.getJSONObject("afterMap");
OrderChildData before = DtsMapConvertUtil.convert(beforeMap, new OrderChildData()); // OrderChildData before = DtsMapConvertUtil.convert(beforeMap, new OrderChildData());
OrderChildData entity = DtsMapConvertUtil.convert(afterMap, new OrderChildData()); // OrderChildData entity = DtsMapConvertUtil.convert(afterMap, new OrderChildData());
//
//
} catch (Exception e) { // } catch (Exception e) {
log.info("DTS消息同步失败, database:order_service, error:{}", e.getMessage()); // log.info("DTS消息同步失败, database:order_service, error:{}", e.getMessage());
} // }
} // }
//
} //}
...@@ -46,4 +46,6 @@ public interface OrderChildMapper extends BaseMapper<OrderChild> { ...@@ -46,4 +46,6 @@ public interface OrderChildMapper extends BaseMapper<OrderChild> {
@Select("select count(1) from order_child where order_goods_no = #{orderGoodsNo} and status < 110") @Select("select count(1) from order_child where order_goods_no = #{orderGoodsNo} and status < 110")
int countValidByOrderGoodsNo(String orderGoodsNo); int countValidByOrderGoodsNo(String orderGoodsNo);
@Select("select count(1) from order_child where user_no = #{userNo} and status = 100")
Integer getOrderChildTotalByUserNo(Long userNo);
} }
\ No newline at end of file
...@@ -60,4 +60,5 @@ public interface OrderChildService { ...@@ -60,4 +60,5 @@ public interface OrderChildService {
GoingOrderChildVO getGoingLatestOrderChild(); GoingOrderChildVO getGoingLatestOrderChild();
Integer getOrderChildTotalByUserNo(Long userNo);
} }
...@@ -1133,4 +1133,9 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -1133,4 +1133,9 @@ public class OrderChildServiceImpl implements OrderChildService {
OrderChild orderChild = orderChildDao.getGoingLatestOrderChild(loginUserInfo.getUserNo()); OrderChild orderChild = orderChildDao.getGoingLatestOrderChild(loginUserInfo.getUserNo());
return orderChildStruct.convertGoingOrder(orderChild); return orderChildStruct.convertGoingOrder(orderChild);
} }
@Override
public Integer getOrderChildTotalByUserNo(Long userNo) {
return orderChildDao.getOrderChildTotalByUserNo(userNo);
}
} }
...@@ -17,6 +17,8 @@ import com.clx.performance.service.OrderGoodsService; ...@@ -17,6 +17,8 @@ import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.strategy.GoodsOrderStrategy; import com.clx.performance.strategy.GoodsOrderStrategy;
import com.msl.common.exception.ServiceSystemException; import com.msl.common.exception.ServiceSystemException;
import com.msl.common.utils.DateUtils; import com.msl.common.utils.DateUtils;
import com.msl.user.data.UserSessionData;
import com.msl.user.utils.TokenUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -50,6 +52,7 @@ public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -50,6 +52,7 @@ public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
@Override @Override
public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo) { public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo) {
String orderNo = orderGoodsParams.getOrderNo(); String orderNo = orderGoodsParams.getOrderNo();
UserSessionData loginUserInfo = TokenUtil.getLoginUserInfo();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
LocalDateTime sendLazyTime = null; LocalDateTime sendLazyTime = null;
...@@ -113,11 +116,13 @@ public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -113,11 +116,13 @@ public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderGoods.setReceiveLatitude(orderInfo.getReveiveLatitude()); orderGoods.setReceiveLatitude(orderInfo.getReveiveLatitude());
orderGoods.setReceiveLongitude(orderInfo.getReveiveLongitude()); orderGoods.setReceiveLongitude(orderInfo.getReveiveLongitude());
orderGoods.setReceiveAddressId(orderInfo.getReveiveAddressId()); orderGoods.setReceiveAddressId(orderInfo.getReveiveAddressId());
orderGoods.setReceiveAddressShorter(orderInfo.getReveiveAddressShorter());
orderGoods.setGoodsName(orderInfo.getGoodsName()); orderGoods.setGoodsName(orderInfo.getGoodsName());
orderGoods.setCreateTime(now); orderGoods.setCreateTime(now);
orderGoods.setModifiedTime(now); orderGoods.setModifiedTime(now);
orderGoods.setUserName("loginUserInfo.getUserName()"); orderGoods.setUserName(loginUserInfo.getUserName());
orderGoods.setUserNo(123L); orderGoods.setUserNo(loginUserInfo.getUserNo());
if (CollectionUtil.isNotEmpty(child.getTruckList())) { if (CollectionUtil.isNotEmpty(child.getTruckList())) {
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now); orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
} }
......
...@@ -17,6 +17,8 @@ import com.clx.performance.service.OrderGoodsService; ...@@ -17,6 +17,8 @@ import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.strategy.GoodsOrderStrategy; import com.clx.performance.strategy.GoodsOrderStrategy;
import com.msl.common.exception.ServiceSystemException; import com.msl.common.exception.ServiceSystemException;
import com.msl.common.utils.DateUtils; import com.msl.common.utils.DateUtils;
import com.msl.user.data.UserSessionData;
import com.msl.user.utils.TokenUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -52,6 +54,7 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing ...@@ -52,6 +54,7 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing
@Override @Override
public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo) { public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo) {
String orderNo = orderGoodsParams.getOrderNo(); String orderNo = orderGoodsParams.getOrderNo();
UserSessionData loginUserInfo = TokenUtil.getLoginUserInfo();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
LocalDateTime sendLazyTime = null; LocalDateTime sendLazyTime = null;
...@@ -113,8 +116,8 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing ...@@ -113,8 +116,8 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing
orderGoods.setGoodsName(orderInfo.getGoodsName()); orderGoods.setGoodsName(orderInfo.getGoodsName());
orderGoods.setCreateTime(now); orderGoods.setCreateTime(now);
orderGoods.setModifiedTime(now); orderGoods.setModifiedTime(now);
orderGoods.setUserName("loginUserInfo.getUserName()"); orderGoods.setUserName(loginUserInfo.getUserName());
orderGoods.setUserNo(123L); orderGoods.setUserNo(loginUserInfo.getUserNo());
if (CollectionUtil.isNotEmpty(child.getTruckList())) { if (CollectionUtil.isNotEmpty(child.getTruckList())) {
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now); orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
} }
......
...@@ -17,6 +17,8 @@ import com.clx.performance.service.OrderGoodsService; ...@@ -17,6 +17,8 @@ import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.strategy.GoodsOrderStrategy; import com.clx.performance.strategy.GoodsOrderStrategy;
import com.msl.common.exception.ServiceSystemException; import com.msl.common.exception.ServiceSystemException;
import com.msl.common.utils.DateUtils; import com.msl.common.utils.DateUtils;
import com.msl.user.data.UserSessionData;
import com.msl.user.utils.TokenUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -53,6 +55,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -53,6 +55,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
@Override @Override
public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo) { public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo) {
String orderNo = orderGoodsParams.getOrderNo(); String orderNo = orderGoodsParams.getOrderNo();
UserSessionData loginUserInfo = TokenUtil.getLoginUserInfo();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
LocalDateTime sendLazyTime = null; LocalDateTime sendLazyTime = null;
...@@ -119,8 +122,8 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -119,8 +122,8 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderGoods.setGoodsName(orderInfo.getGoodsName()); orderGoods.setGoodsName(orderInfo.getGoodsName());
orderGoods.setCreateTime(now); orderGoods.setCreateTime(now);
orderGoods.setModifiedTime(now); orderGoods.setModifiedTime(now);
orderGoods.setUserName("loginUserInfo.getUserName()"); orderGoods.setUserName(loginUserInfo.getUserName());
orderGoods.setUserNo(123L); orderGoods.setUserNo(loginUserInfo.getUserNo());
if (CollectionUtil.isNotEmpty(child.getTruckList())) { if (CollectionUtil.isNotEmpty(child.getTruckList())) {
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now); orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论