提交 cf1381df authored 作者: huyufan's avatar huyufan

增加货单失效逻辑处理

上级 47c95e8f
...@@ -18,8 +18,9 @@ public enum OrderGoodsStatusEnum { ...@@ -18,8 +18,9 @@ public enum OrderGoodsStatusEnum {
PAYING(20, "挂单中"), PAYING(20, "挂单中"),
GO_TO_SEND(30, "运输中"), GO_TO_SEND(30, "运输中"),
ARRIVE_SEND(40, "已完成"), SUCCESS(40, "已完成"),
CANCEL(50, "已取消"), CANCEL(50, "已取消"),
COMPLETED(60, "已完结")
; ;
private final Integer code; private final Integer code;
......
package com.clx.performance.feign; package com.clx.performance.feign;
import com.clx.performance.vo.feign.OrderGoodsFeignVO;
import com.msl.common.result.Result; import com.msl.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -23,4 +24,7 @@ public interface PerformanceFeign { ...@@ -23,4 +24,7 @@ public interface PerformanceFeign {
@GetMapping(value = {"clx-performance/feign/orderChild/getOrderChildTotalByUserNo"}) @GetMapping(value = {"clx-performance/feign/orderChild/getOrderChildTotalByUserNo"})
Integer getOrderChildTotalByUserNo(@RequestParam("userNo") Long userNo); Integer getOrderChildTotalByUserNo(@RequestParam("userNo") Long userNo);
@GetMapping(value = {"clx-performance/feign/orderGoods/getOrderGoodsListByOrderNo"})
List<OrderGoodsFeignVO> getOrderGoodsListByOrderNo(@RequestParam String orderNo);
} }
package com.clx.performance.vo.feign;
import com.msl.common.convertor.type.MoneyOutConvert;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.math.BigDecimal;
@Getter
@Setter
@NoArgsConstructor
public class OrderGoodsFeignVO {
@ApiModelProperty("订单编号")
private String orderNo;
@ApiModelProperty("货单编号")
private String orderGoodsNo;
@ApiModelProperty("货单状态")
private Integer orderGoodsStatus;
@ApiModelProperty("提取吨数")
private BigDecimal extractWeight;
@ApiModelProperty("剩余拉运吨数")
private BigDecimal residueTransportWeight;
@ApiModelProperty("已拉运吨数")
private BigDecimal alreadyTransportWeight;
@ApiModelProperty("发货地址ID")
private Integer sendAddressId;
@ApiModelProperty(value = "发货地址全称")
private String sendAddressAll;
@ApiModelProperty("发货地址简称")
private String sendAddressShorter;
@ApiModelProperty("发货地址经度")
private BigDecimal sendLongitude;
@ApiModelProperty("发货地址纬度")
private BigDecimal sendLatitude;
@ApiModelProperty("收货地址ID")
private Integer receiveAddressId;
@ApiModelProperty(value="收货地址全称")
private String reveiveAddressAll;
@ApiModelProperty("收货地址简称")
private String receiveAddressShorter;
@ApiModelProperty("收货地址经度")
private BigDecimal receiveLongitude;
@ApiModelProperty("收货地址纬度")
private BigDecimal receiveLatitude;
@ApiModelProperty("货物ID")
private Integer goodsId;
@ApiModelProperty("货物名称")
private String goodsName;
@ApiModelProperty("挂单方式 1公开派单 2定向派单")
private Integer pendingOrderWay;
@ApiModelProperty("定向运单失效时间")
private String directionalExpireTime;
@ApiModelProperty("最晚到达货源地时间/运单的最晚装货时间")
private String lastArriveSendTime;
@ApiModelProperty("挂单时间")
private String pendingOrderTime;
@ApiModelProperty("提取方式 1提取全部 2提取部分")
private Integer extractWay;
@ApiModelProperty("需要车辆/辆")
private Integer needTruckNum;
@ApiModelProperty("高级物流经理id")
private Integer seniorLogisticsManagerId;
@ApiModelProperty("高级物流经理姓名")
private String seniorLogisticsManagerName;
@ApiModelProperty("挂单运费")
@MoneyOutConvert
private BigDecimal pendingOrderFreight;
@ApiModelProperty("创建人用户编号")
private Long userNo;
@ApiModelProperty("创建人姓名")
private String userName;
@ApiModelProperty("创建时间")
private String createTime;
}
\ No newline at end of file
package com.clx.performance.component;
import cn.hutool.core.collection.CollectionUtil;
import com.clx.order.feign.OrderFeign;
import com.clx.order.param.feign.UpdateOrderInfoParam;
import com.clx.order.vo.feign.FeignOrderVO;
import com.clx.performance.constant.RedisConstants;
import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.enums.OrderGoodsStatusEnum;
import com.clx.performance.model.OrderGoods;
import com.msl.common.base.Optional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
import java.util.List;
import java.util.Set;
@Component
@Slf4j
public class OrderGoodsStatusLazyComponent implements InitializingBean {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private OrderGoodsDao orderGoodsDao;
@Autowired
private OrderFeign orderFeign;
public void expireProduce(LocalDateTime localDateTime, String orderGoodsNo) {
stringRedisTemplate.opsForZSet().add(RedisConstants.ORDER_GOODS_STATUS_LAZY, orderGoodsNo, localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli());
}
public void consuming() {
long nowTimeMillis = System.currentTimeMillis();
LocalDateTime nowDateTime = new Date(nowTimeMillis).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime();
Set<ZSetOperations.TypedTuple<String>> orderGoodsIds = stringRedisTemplate.opsForZSet().rangeByScoreWithScores(
RedisConstants.ORDER_GOODS_STATUS_LAZY,
0, nowTimeMillis //延时任务score最小值
//延时任务score最大值(当前时间)
);
if (!CollectionUtil.isEmpty(orderGoodsIds)) {
for (ZSetOperations.TypedTuple<String> orderGoodsId : orderGoodsIds) {
log.info("货单" + orderGoodsId + "过了最晚拉运时间");
String orderGoodsNo = orderGoodsId.getValue();
OrderGoods orderGoods = orderGoodsDao.getByOrderGoodsNo(orderGoodsNo).get();
FeignOrderVO orderInfoFeign = orderFeign.getOrderInfoFeign(orderGoods.getOrderNo());
if (!OrderGoodsStatusEnum.Status.COMPLETED.getCode().equals(orderInfoFeign.getOrderStatus()) && OrderGoodsStatusEnum.Status.SUCCESS.getCode().equals(orderGoods.getOrderGoodsStatus())) {
//如果当前货单已完成,则判断之前所有货单是否等于订单总吨数,等于则更新订单为已完成
List<OrderGoods> list = orderGoodsDao.getOrderGoodsListByOrderNoAndLastArriveSendTime(orderGoods.getOrderNo(), nowDateTime);
BigDecimal childSum = list.stream().map(OrderGoods::getExtractWeight).reduce(BigDecimal.ZERO, BigDecimal::add);
if (childSum.compareTo(new BigDecimal(orderInfoFeign.getTransportWeight())) == 0) {
//补充更新订单状态 已完成
UpdateOrderInfoParam updateOrderInfoParam = new UpdateOrderInfoParam();
updateOrderInfoParam.setOrderId(orderInfoFeign.getId());
updateOrderInfoParam.setOrderStatus(OrderGoodsStatusEnum.Status.SUCCESS.getCode());
orderFeign.updateOrderInfo(updateOrderInfoParam);
}
} else {
//更新货单已完结,并返还货单吨数
orderGoodsDao.updateOrderGoodsStatusByOrderGoodsNo(orderGoodsNo, OrderGoodsStatusEnum.Status.COMPLETED.getCode());
BigDecimal residueTransportWeight = orderGoods.getResidueTransportWeight();
UpdateOrderInfoParam updateOrderInfoParam = new UpdateOrderInfoParam();
updateOrderInfoParam.setOrderId(orderInfoFeign.getId());
updateOrderInfoParam.setResidueWeight(residueTransportWeight);
//返还订单剩余吨数
orderFeign.updateOrderInfo(updateOrderInfoParam);
}
stringRedisTemplate.opsForZSet().remove(RedisConstants.ORDER_GOODS_STATUS_LAZY, orderGoodsId.getValue());
}
}
}
@Override
public void afterPropertiesSet() throws Exception {
Optional<List<OrderGoods>> optional = orderGoodsDao.getOrderGoodsList();
if (optional.isPresent()) {
for (OrderGoods orderGoods : optional.get()) {
stringRedisTemplate.opsForZSet().add(RedisConstants.ORDER_GOODS_STATUS_LAZY, orderGoods.getOrderGoodsNo(), orderGoods.getLastArriveSendTime().toInstant(ZoneOffset.of("+8")).toEpochMilli());
}
}
}
}
...@@ -18,4 +18,6 @@ public class RedisConstants { ...@@ -18,4 +18,6 @@ public class RedisConstants {
public static final String CARRIER_ORDER_NUM_POOL_KEY = "carrier:order:orderNumPool:{date}"; public static final String CARRIER_ORDER_NUM_POOL_KEY = "carrier:order:orderNumPool:{date}";
public static final String ORDER_GOODS_STATUS_LAZY = "clx:order:goods:status:lazy:";
} }
package com.clx.performance.controller.feign; package com.clx.performance.controller.feign;
import com.clx.performance.service.OrderChildService; import com.clx.performance.service.OrderChildService;
import com.msl.common.result.Result;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -11,14 +10,13 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -11,14 +10,13 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
@RestController @RestController
@RequestMapping("/feign/orderChild") @RequestMapping("/feign/orderChild")
@Validated @Validated
@Api(tags = "运单Feign") @Api(tags = "运单Feign")
@AllArgsConstructor @AllArgsConstructor
public class OrderChildController { public class OrderChildFeignController {
private final OrderChildService orderChildService; private final OrderChildService orderChildService;
......
package com.clx.performance.controller.feign;
import com.clx.performance.service.OrderChildService;
import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.vo.feign.OrderGoodsFeignVO;
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/orderGoods")
@Validated
@Api(tags = "货单Feign")
@AllArgsConstructor
public class OrderGoodsFeignController {
private final OrderGoodsService orderGoodsService;
@GetMapping({"/getOrderGoodsListByOrderNo"})
List<OrderGoodsFeignVO> getOrderGoodsListByOrderNo(@RequestParam("userNo") @NotNull(message = "订单编号不可为空") String orderNo) {
return orderGoodsService.getOrderGoodsListByOrderNo(orderNo);
}
}
...@@ -6,12 +6,14 @@ import com.clx.performance.mapper.OrderGoodsMapper; ...@@ -6,12 +6,14 @@ import com.clx.performance.mapper.OrderGoodsMapper;
import com.clx.performance.model.OrderGoods; import com.clx.performance.model.OrderGoods;
import com.clx.performance.param.app.OrderGoodsListPageParam; import com.clx.performance.param.app.OrderGoodsListPageParam;
import com.clx.performance.vo.app.OrderGoodsAPPVO; import com.clx.performance.vo.app.OrderGoodsAPPVO;
import com.clx.performance.vo.feign.OrderGoodsFeignVO;
import com.clx.performance.vo.pc.OrderGoodsVO; import com.clx.performance.vo.pc.OrderGoodsVO;
import com.msl.common.base.Optional; import com.msl.common.base.Optional;
import com.msl.common.dao.BaseDao; import com.msl.common.dao.BaseDao;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
...@@ -42,4 +44,10 @@ public interface OrderGoodsDao extends BaseDao<OrderGoodsMapper, OrderGoods, Int ...@@ -42,4 +44,10 @@ public interface OrderGoodsDao extends BaseDao<OrderGoodsMapper, OrderGoods, Int
void updateOrderGoodsStatusByOrderGoodsNo(String orderGoodsNo, Integer code); void updateOrderGoodsStatusByOrderGoodsNo(String orderGoodsNo, Integer code);
void saveBatchEntity(List<OrderGoods> orderGoodsList); void saveBatchEntity(List<OrderGoods> orderGoodsList);
List<OrderGoods> getOrderGoodsListByOrderNo(String orderNo);
List<OrderGoods> getOrderGoodsListByOrderNoAndLastArriveSendTime(String orderNo, LocalDateTime lastArriveSendTime);
Optional<List<OrderGoods>> getOrderGoodsList();
} }
...@@ -2,6 +2,7 @@ package com.clx.performance.dao.impl; ...@@ -2,6 +2,7 @@ package com.clx.performance.dao.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.order.enums.OrderEnum;
import com.clx.order.params.PageOrderGoodsListParam; import com.clx.order.params.PageOrderGoodsListParam;
import com.clx.performance.dao.OrderGoodsDao; import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.enums.OrderGoodsStatusEnum; import com.clx.performance.enums.OrderGoodsStatusEnum;
...@@ -9,6 +10,7 @@ import com.clx.performance.mapper.OrderGoodsMapper; ...@@ -9,6 +10,7 @@ import com.clx.performance.mapper.OrderGoodsMapper;
import com.clx.performance.model.OrderGoods; import com.clx.performance.model.OrderGoods;
import com.clx.performance.param.app.OrderGoodsListPageParam; import com.clx.performance.param.app.OrderGoodsListPageParam;
import com.clx.performance.vo.app.OrderGoodsAPPVO; import com.clx.performance.vo.app.OrderGoodsAPPVO;
import com.clx.performance.vo.feign.OrderGoodsFeignVO;
import com.clx.performance.vo.pc.OrderGoodsVO; import com.clx.performance.vo.pc.OrderGoodsVO;
import com.msl.common.base.Optional; import com.msl.common.base.Optional;
import com.msl.common.dao.impl.BaseDaoImpl; import com.msl.common.dao.impl.BaseDaoImpl;
...@@ -16,6 +18,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -16,6 +18,7 @@ import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
...@@ -97,5 +100,28 @@ public class OrderGoodsDaoImpl extends BaseDaoImpl<OrderGoodsMapper, OrderGoods, ...@@ -97,5 +100,28 @@ public class OrderGoodsDaoImpl extends BaseDaoImpl<OrderGoodsMapper, OrderGoods,
baseMapper.saveBatchEntity(orderGoodsList); baseMapper.saveBatchEntity(orderGoodsList);
} }
@Override
public List<OrderGoods> getOrderGoodsListByOrderNo(String orderNo) {
return baseMapper.selectList(lQrWrapper().eq(OrderGoods::getOrderNo, orderNo));
}
@Override
public List<OrderGoods> getOrderGoodsListByOrderNoAndLastArriveSendTime(String orderNo, LocalDateTime lastArriveSendTime) {
return baseMapper.selectList(lQrWrapper().eq(OrderGoods::getOrderNo, orderNo)
.le(OrderGoods::getLastArriveSendTime, lastArriveSendTime)
);
}
@Override
public Optional<List<OrderGoods>> getOrderGoodsList() {
return Optional.ofEmpty(list(lQrWrapper()
.eq(OrderGoods::getOrderGoodsStatus, OrderGoodsStatusEnum.Status.CREATED.getCode())
.eq(OrderGoods::getOrderGoodsStatus, OrderGoodsStatusEnum.Status.PAYING.getCode())
.eq(OrderGoods::getOrderGoodsStatus, OrderGoodsStatusEnum.Status.GO_TO_SEND.getCode())
.eq(OrderGoods::getOrderGoodsStatus, OrderGoodsStatusEnum.Status.SUCCESS.getCode())
));
}
} }
...@@ -3,11 +3,15 @@ package com.clx.performance.service; ...@@ -3,11 +3,15 @@ package com.clx.performance.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.order.params.PageOrderGoodsListParam; import com.clx.order.params.PageOrderGoodsListParam;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.param.app.OrderGoodsListPageParam; import com.clx.performance.param.app.OrderGoodsListPageParam;
import com.clx.performance.vo.app.OrderGoodsAPPVO; import com.clx.performance.vo.app.OrderGoodsAPPVO;
import com.clx.performance.vo.feign.OrderGoodsFeignVO;
import com.clx.performance.vo.pc.OrderGoodsVO; import com.clx.performance.vo.pc.OrderGoodsVO;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/** /**
* @author kavin * @author kavin
...@@ -24,4 +28,8 @@ public interface OrderGoodsService { ...@@ -24,4 +28,8 @@ public interface OrderGoodsService {
void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight, Integer orderGoodsStatus); void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight, Integer orderGoodsStatus);
IPage<OrderGoodsAPPVO> indexOrderGoodsList(OrderGoodsListPageParam orderGoodsListParam); IPage<OrderGoodsAPPVO> indexOrderGoodsList(OrderGoodsListPageParam orderGoodsListParam);
List<OrderGoodsFeignVO> getOrderGoodsListByOrderNo(String orderNo);
List<OrderGoods> getOrderGoodsList(String orderNo, LocalDateTime lastArriveSendTime);
} }
...@@ -8,12 +8,14 @@ import com.clx.performance.dao.OrderGoodsDao; ...@@ -8,12 +8,14 @@ import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.dao.OrderGoodsDriverTruckDao; import com.clx.performance.dao.OrderGoodsDriverTruckDao;
import com.clx.performance.dao.OrderGoodsTruckBindDao; import com.clx.performance.dao.OrderGoodsTruckBindDao;
import com.clx.performance.enums.PerformanceResultEnum; import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.model.OrderGoodsDriverTruck; import com.clx.performance.model.OrderGoodsDriverTruck;
import com.clx.performance.model.OrderGoodsTruckBind; import com.clx.performance.model.OrderGoodsTruckBind;
import com.clx.performance.param.app.OrderGoodsListPageParam; import com.clx.performance.param.app.OrderGoodsListPageParam;
import com.clx.performance.service.OrderGoodsService; import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.struct.OrderGoodsStruct; import com.clx.performance.struct.OrderGoodsStruct;
import com.clx.performance.vo.app.OrderGoodsAPPVO; import com.clx.performance.vo.app.OrderGoodsAPPVO;
import com.clx.performance.vo.feign.OrderGoodsFeignVO;
import com.clx.performance.vo.pc.OrderGoodsVO; import com.clx.performance.vo.pc.OrderGoodsVO;
import com.msl.common.base.Optional; import com.msl.common.base.Optional;
import com.msl.common.exception.ServiceSystemException; import com.msl.common.exception.ServiceSystemException;
...@@ -22,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -22,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -102,4 +105,16 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { ...@@ -102,4 +105,16 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
} }
} }
@Override
public List<OrderGoodsFeignVO> getOrderGoodsListByOrderNo(String orderNo) {
List<OrderGoods> list = orderGoodsDao.getOrderGoodsListByOrderNo(orderNo);
return orderGoodsStruct.convertList(list);
}
@Override
public List<OrderGoods> getOrderGoodsList(String orderNo, LocalDateTime lastArriveSendTime) {
return orderGoodsDao.getOrderGoodsListByOrderNoAndLastArriveSendTime(orderNo, lastArriveSendTime);
}
} }
...@@ -8,6 +8,7 @@ import com.clx.order.params.OrderGoodsParams; ...@@ -8,6 +8,7 @@ import com.clx.order.params.OrderGoodsParams;
import com.clx.order.vo.feign.FeignOrderVO; import com.clx.order.vo.feign.FeignOrderVO;
import com.clx.performance.component.GoodsOrderStrategyContext; import com.clx.performance.component.GoodsOrderStrategyContext;
import com.clx.performance.component.OrderGoodsIdGenerate; import com.clx.performance.component.OrderGoodsIdGenerate;
import com.clx.performance.component.OrderGoodsStatusLazyComponent;
import com.clx.performance.constant.RabbitKeyConstants; import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.dao.OrderGoodsDao; import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.dao.OrderGoodsTruckBindDao; import com.clx.performance.dao.OrderGoodsTruckBindDao;
...@@ -58,6 +59,9 @@ public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -58,6 +59,9 @@ public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
@Autowired @Autowired
OrderGoodsDao orderGoodsDao; OrderGoodsDao orderGoodsDao;
@Autowired
private OrderGoodsStatusLazyComponent orderGoodsStatusLazyComponent;
@Autowired @Autowired
private GoodsOrderStrategyContext goodsOrderStrategyContext; private GoodsOrderStrategyContext goodsOrderStrategyContext;
...@@ -148,6 +152,8 @@ public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -148,6 +152,8 @@ public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now); orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
} }
mqMap.put(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, postedTime); mqMap.put(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, postedTime);
orderGoodsStatusLazyComponent.expireProduce(orderGoods.getLastArriveSendTime(),OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
beginOrderGoodsId = beginOrderGoodsId + 1; beginOrderGoodsId = beginOrderGoodsId + 1;
orderGoodsList.add(orderGoods); orderGoodsList.add(orderGoods);
} }
......
...@@ -8,6 +8,7 @@ import com.clx.order.params.OrderGoodsParams; ...@@ -8,6 +8,7 @@ import com.clx.order.params.OrderGoodsParams;
import com.clx.order.vo.feign.FeignOrderVO; import com.clx.order.vo.feign.FeignOrderVO;
import com.clx.performance.component.GoodsOrderStrategyContext; import com.clx.performance.component.GoodsOrderStrategyContext;
import com.clx.performance.component.OrderGoodsIdGenerate; import com.clx.performance.component.OrderGoodsIdGenerate;
import com.clx.performance.component.OrderGoodsStatusLazyComponent;
import com.clx.performance.constant.RabbitKeyConstants; import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.dao.OrderGoodsDao; import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.dao.OrderGoodsTruckBindDao; import com.clx.performance.dao.OrderGoodsTruckBindDao;
...@@ -65,6 +66,9 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing ...@@ -65,6 +66,9 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing
@Autowired @Autowired
private RabbitTemplate rabbitTemplate; private RabbitTemplate rabbitTemplate;
@Autowired
private OrderGoodsStatusLazyComponent orderGoodsStatusLazyComponent;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo, LocalDateTime now) { public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo, LocalDateTime now) {
...@@ -149,6 +153,7 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing ...@@ -149,6 +153,7 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now); orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
} }
mqMap.put(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, postedTime); mqMap.put(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, postedTime);
orderGoodsStatusLazyComponent.expireProduce(orderGoods.getLastArriveSendTime(),OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
beginOrderGoodsId = beginOrderGoodsId + 1; beginOrderGoodsId = beginOrderGoodsId + 1;
......
...@@ -8,6 +8,7 @@ import com.clx.order.params.OrderGoodsParams; ...@@ -8,6 +8,7 @@ import com.clx.order.params.OrderGoodsParams;
import com.clx.order.vo.feign.FeignOrderVO; import com.clx.order.vo.feign.FeignOrderVO;
import com.clx.performance.component.GoodsOrderStrategyContext; import com.clx.performance.component.GoodsOrderStrategyContext;
import com.clx.performance.component.OrderGoodsIdGenerate; import com.clx.performance.component.OrderGoodsIdGenerate;
import com.clx.performance.component.OrderGoodsStatusLazyComponent;
import com.clx.performance.constant.RabbitKeyConstants; import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.dao.OrderGoodsDao; import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.dao.OrderGoodsTruckBindDao; import com.clx.performance.dao.OrderGoodsTruckBindDao;
...@@ -59,6 +60,8 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -59,6 +60,8 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
@Autowired @Autowired
private OrderFeign orderFeign; private OrderFeign orderFeign;
@Autowired
private OrderGoodsStatusLazyComponent orderGoodsStatusLazyComponent;
@Autowired @Autowired
private GoodsOrderStrategyContext goodsOrderStrategyContext; private GoodsOrderStrategyContext goodsOrderStrategyContext;
...@@ -70,7 +73,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -70,7 +73,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo, LocalDateTime now) { public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo, LocalDateTime now) {
String orderNo = orderGoodsParams.getOrderNo(); String orderNo = orderGoodsParams.getOrderNo();
UserSessionData loginUserInfo = TokenUtil.getLoginUserInfo(); //UserSessionData loginUserInfo = TokenUtil.getLoginUserInfo();
LocalDateTime sendLazyTime = null; LocalDateTime sendLazyTime = null;
List<OrderGoodsChildParams> childParamsList = orderGoodsParams.getOrderGoodsChildParams(); List<OrderGoodsChildParams> childParamsList = orderGoodsParams.getOrderGoodsChildParams();
...@@ -153,19 +156,20 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -153,19 +156,20 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderGoods.setCreateTime(now); orderGoods.setCreateTime(now);
orderGoods.setModifiedTime(now); orderGoods.setModifiedTime(now);
orderGoods.setUserName(loginUserInfo.getUserName()); orderGoods.setUserName("loginUserInfo.getUserName()");
orderGoods.setUserNo(loginUserInfo.getUserNo()); orderGoods.setUserNo(1L);
if (StringUtils.equals(child.getVehicleUsage(), OrderGoodsPendingVehicleUsageEnum.Status.OWN_TRUCK.getCode()) && CollectionUtil.isNotEmpty(child.getTruckList())) { if (StringUtils.equals(child.getVehicleUsage(), OrderGoodsPendingVehicleUsageEnum.Status.OWN_TRUCK.getCode()) && 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);
} }
mqMap.put(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, postedTime); mqMap.put(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, postedTime);
orderGoodsStatusLazyComponent.expireProduce(orderGoods.getLastArriveSendTime(),OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
beginOrderGoodsId = beginOrderGoodsId + 1; beginOrderGoodsId = beginOrderGoodsId + 1;
orderGoodsList.add(orderGoods); orderGoodsList.add(orderGoods);
} }
orderGoodsDao.saveBatchEntity(orderGoodsList); orderGoodsDao.saveBatchEntity(orderGoodsList);
BigDecimal residueWeight = new BigDecimal(orderInfo.getResidueWeight()); BigDecimal residueWeight = new BigDecimal(orderInfo.getResidueWeight());
if (platSum != null && ownSum != null) { if (platSum.compareTo(BigDecimal.ZERO) != 0 && ownSum.compareTo(BigDecimal.ZERO) != 0) {
UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam(); UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
param.setOrderId(orderInfo.getId()); param.setOrderId(orderInfo.getId());
param.setUpdateType("4"); param.setUpdateType("4");
...@@ -173,14 +177,14 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -173,14 +177,14 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
param.setOwnWeight(ownSum); param.setOwnWeight(ownSum);
param.setPlatWeight(platSum); param.setPlatWeight(platSum);
orderFeign.updateOrderInfoResidueWeight(param); orderFeign.updateOrderInfoResidueWeight(param);
} else if (platSum != null && ownSum == null) { } else if (platSum.compareTo(BigDecimal.ZERO) != 0 && ownSum.compareTo(BigDecimal.ZERO) == 0) {
UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam(); UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
param.setOrderId(orderInfo.getId()); param.setOrderId(orderInfo.getId());
param.setUpdateType("2"); param.setUpdateType("2");
param.setResidueWeight(residueWeight.subtract(platSum)); param.setResidueWeight(residueWeight.subtract(platSum));
param.setPlatWeight(platSum); param.setPlatWeight(platSum);
orderFeign.updateOrderInfoResidueWeight(param); orderFeign.updateOrderInfoResidueWeight(param);
} else if (platSum != null && ownSum == null) { } else if (platSum.compareTo(BigDecimal.ZERO) == 0 && ownSum.compareTo(BigDecimal.ZERO) != 0) {
UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam(); UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
param.setOrderId(orderInfo.getId()); param.setOrderId(orderInfo.getId());
param.setUpdateType("3"); param.setUpdateType("3");
...@@ -189,6 +193,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -189,6 +193,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderFeign.updateOrderInfoResidueWeight(param); orderFeign.updateOrderInfoResidueWeight(param);
} }
sendMq(mqMap, now); sendMq(mqMap, now);
return sendLazyTime; return sendLazyTime;
} }
...@@ -206,9 +211,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -206,9 +211,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
long epochMilli = 0L; long epochMilli = 0L;
if (entry.getValue().isAfter(now)) { if (entry.getValue().isAfter(now)) {
epochMilli = entry.getValue().minusMinutes(now.getMinute()).getMinute() * 60 * 1000; epochMilli = entry.getValue().minusMinutes(now.getMinute()).getMinute() * 60 * 1000;
log.info("货单更改挂单中,选择时间在当前时间之后,则设置延迟队列时间,时间为:{}", epochMilli); log.info("货单更改挂单中,选择时间在当前时间之后,则设置延迟队列时间,时间为:{}", epochMilli);
} }
if (epochMilli == 0L) { if (epochMilli == 0L) {
log.info("货单更改挂单中,epochMilli时间为0,时间为:{}", epochMilli); log.info("货单更改挂单中,epochMilli时间为0,时间为:{}", epochMilli);
......
package com.clx.performance.struct; package com.clx.performance.struct;
import com.clx.performance.model.OrderGoods; import com.clx.performance.model.OrderGoods;
import com.clx.performance.vo.feign.OrderGoodsFeignVO;
import com.clx.performance.vo.pc.OrderGoodsVO; import com.clx.performance.vo.pc.OrderGoodsVO;
import com.msl.common.utils.DateStructUtil; import com.msl.common.utils.DateStructUtil;
import com.msl.common.utils.DateUtils; import com.msl.common.utils.DateUtils;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import java.util.List;
@Mapper(componentModel = "spring", uses = DateStructUtil.class, imports = {DateUtils.class}) @Mapper(componentModel = "spring", uses = DateStructUtil.class, imports = {DateUtils.class})
public interface OrderGoodsStruct { public interface OrderGoodsStruct {
OrderGoodsVO convert(OrderGoods orderGoods); OrderGoodsVO convert(OrderGoods orderGoods);
List<OrderGoodsFeignVO> convertList(List<OrderGoods> orderGoods);
} }
package com.clx.performance; package com.clx.performance;
import com.clx.order.feign.OrderFeign; import com.clx.order.feign.OrderFeign;
import com.clx.order.param.feign.UpdateOrderInfoResidueWeightParam;
import com.clx.performance.constant.RabbitKeyConstants; import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.mapper.OrderGoodsMapper; import com.clx.performance.mapper.OrderGoodsMapper;
import org.junit.Test; import org.junit.Test;
...@@ -26,10 +27,18 @@ public class JobTest { ...@@ -26,10 +27,18 @@ public class JobTest {
@Test @Test
public void test1() { public void test1() {
Message message = MessageBuilder.withBody("PT2023091900049".getBytes()).build();
message.getMessageProperties().setExpiration("10000"); UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
rabbitTemplate.send( param.setOrderId(150);
RabbitKeyConstants.ORDER_GOODS_ON_EXCHANGE, RabbitKeyConstants.ORDER_GOODS_ON_ROUTE_KEY, message param.setUpdateType("1");
); param.setResidueWeight(new BigDecimal(200));
orderFeign.updateOrderInfoResidueWeight(param);
// Message message = MessageBuilder.withBody("PT2023091900049".getBytes()).build();
// message.getMessageProperties().setExpiration("10000");
// rabbitTemplate.send(
// RabbitKeyConstants.ORDER_GOODS_ON_EXCHANGE, RabbitKeyConstants.ORDER_GOODS_ON_ROUTE_KEY, message
// );
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论