提交 4c2954ec 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
...@@ -102,7 +102,8 @@ public enum OrderChildEnum { ...@@ -102,7 +102,8 @@ public enum OrderChildEnum {
// 取消 // 取消
public static final List<Integer> CANCEL_lIST = Arrays.asList( public static final List<Integer> CANCEL_lIST = Arrays.asList(
Status.DRIVER_CANCEL.getCode(), Status.DRIVER_CANCEL.getCode(),
Status.PLATFORM_CANCEL.getCode() Status.PLATFORM_CANCEL.getCode(),
Status.OWNER_CANCEL.getCode()
); );
......
...@@ -44,15 +44,19 @@ public enum PerformanceResultEnum implements ResultEnum { ...@@ -44,15 +44,19 @@ public enum PerformanceResultEnum implements ResultEnum {
ORDER_CHILD_COMPLETE(1304, "运单状态已完成"), ORDER_CHILD_COMPLETE(1304, "运单状态已完成"),
ORDER_CHILD_LOAD_TIMEOUT(1305, "超过装货截止时间"), ORDER_CHILD_LOAD_TIMEOUT(1305, "超过装货截止时间"),
ORDER_CHILD_CANCEL_FORBID(1306, "运单无法取消"), ORDER_CHILD_CANCEL_FORBID(1306, "运单无法取消"),
ORDER_CHILD_CANCEL_FORBID_COUNT(1307, "超出最大取消数量"), ORDER_CHILD_CANCEL_FORBID_COUNT(1307, "今日取消运单次数超过上限,暂时无法取消"),
ORDER_CHILD_POUND_AUDIT(1308, "磅单审核中"), ORDER_CHILD_POUND_AUDIT(1308, "磅单审核中"),
ORDER_CHILD_DIRECT_ORDER_TRUCK_ERROR(1309, "请选择定向车辆"), ORDER_CHILD_POUND_REJECT(1309, "磅单审核驳回,请重新提交信息"),
ORDER_CHILD_DIRECT_ORDER_TRUCK_ERROR1(1310, "请选择非定向车辆"), ORDER_CHILD_DIRECT_ORDER_TRUCK_ERROR(1310, "请选择定向车辆"),
ORDER_CHILD_DIRECT_REJECT_TRUCK_ERROR(1311, "非定向车辆无法取消"), ORDER_CHILD_DIRECT_ORDER_TRUCK_ERROR1(1311, "请选择非定向车辆"),
ORDER_CHILD_DIRECT_REJECT_TRUCK_ERROR(1312, "非定向车辆无法取消"),
ORDER_CHILD_LOAD_WEIGHT_ERROR(1312, "装货净重超过载重的1.5倍"), ORDER_CHILD_LOAD_WEIGHT_ERROR(1312, "装货净重超过载重的1.5倍"),
ORDER_CHILD_UNLOAD_WEIGHT_ERROR(1313, "卸货净重超过载重的1.5倍"), ORDER_CHILD_UNLOAD_WEIGHT_ERROR(1313, "卸货净重超过载重的1.5倍"),
ORDER_CHILD_LOAD_TIME_ERROR(1314, "非装车时间段"),
ORDER_CHILD_UNLOAD_TIME_ERROR(1315, "非卸车时间段"),
ORDER_CHILD_ARRIVE_SEND_ADDRESS_DISTANCE_ERROR(1316, "没有到达货源地"),
ORDER_CHILD_ARRIVE_RECEIVE_ADDRESS_DISTANCE_ERROR(1317, "没有到达目的地"),
; ;
private final int code; private final int code;
......
...@@ -21,7 +21,7 @@ import java.math.BigDecimal; ...@@ -21,7 +21,7 @@ import java.math.BigDecimal;
public class PoundAuditParam { public class PoundAuditParam {
@NotBlank(message = "运单编号不能为空") @NotBlank(message = "运单编号不能为空")
@ApiModelProperty(value="运单编号",example = "201457878") @ApiModelProperty(value="运单编号",example = "CYD201457878")
private String childNo; private String childNo;
@ApiModelProperty(value="审核驳回类型:1装车 2卸车 3装车+卸车",example = "1") @ApiModelProperty(value="审核驳回类型:1装车 2卸车 3装车+卸车",example = "1")
......
package com.clx.performance.vo.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@ApiModel(description = "运单表")
@Getter
@Setter
@ToString
@NoArgsConstructor
public class GoingOrderChildVO {
@ApiModelProperty(value = "运单编号", example = "100000000")
private String childNo;
@ApiModelProperty(value = "发货地址", example = "朝阳")
private String sendAddress;
@ApiModelProperty(value = "收货地址", example = "西城")
private String receiveAddress;
@ApiModelProperty(value = "最晚装货时间", example = "")
private String loadDeadline;
@ApiModelProperty(value = "车牌号", example = "京A12345")
private String truckNo;
}
\ No newline at end of file
package com.clx.performance.component;
import com.clx.performance.strategy.GoodsOrderStrategy;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class GoodsOrderStrategyContext {
public final Map<Integer, GoodsOrderStrategy> strategyContext = new HashMap<>();
}
...@@ -3,6 +3,7 @@ package com.clx.performance.component; ...@@ -3,6 +3,7 @@ package com.clx.performance.component;
import com.clx.performance.constant.RedisConstants; import com.clx.performance.constant.RedisConstants;
import com.clx.performance.dao.OrderGoodsDao; import com.clx.performance.dao.OrderGoodsDao;
import com.msl.common.utils.DateUtils; import com.msl.common.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
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.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -23,7 +24,12 @@ public class OrderGoodsIdGenerate { ...@@ -23,7 +24,12 @@ public class OrderGoodsIdGenerate {
long baseStart = Long.parseLong(DateUtils.formatDate(LocalDate.now(), "yyyyMMdd").get() + "00001"); long baseStart = Long.parseLong(DateUtils.formatDate(LocalDate.now(), "yyyyMMdd").get() + "00001");
Object o = redisTemplate.opsForHash().get(RedisConstants.ORDER_GOODS_ID, type); Object o = redisTemplate.opsForHash().get(RedisConstants.ORDER_GOODS_ID, type);
if (o == null) { if (o == null) {
Long maxOrderGoodsId = Long.valueOf(orderGoodsDao.getMaxOrderGoodsId(type).substring(2)); Long maxOrderGoodsId = null;
String maxID = orderGoodsDao.getMaxOrderGoodsId(type);
if (StringUtils.isNotBlank(maxID)) {
maxOrderGoodsId = Long.valueOf(maxID.substring(0, 2));
}
if (maxOrderGoodsId == null) { if (maxOrderGoodsId == null) {
maxOrderGoodsId = 0L; maxOrderGoodsId = 0L;
} }
......
...@@ -21,4 +21,14 @@ public class RabbitKeyConstants { ...@@ -21,4 +21,14 @@ public class RabbitKeyConstants {
public static final String ORDER_GOODS_SYNC_TRUCK_DRIVER_INFO_QUEUE = "clx-performance.order.goods.sync.truck.driver.info.queue"; public static final String ORDER_GOODS_SYNC_TRUCK_DRIVER_INFO_QUEUE = "clx-performance.order.goods.sync.truck.driver.info.queue";
// 司机出车状态更新
public static final String DRIVER_EXCHANGE = "clx-user.driver.exchange";
public static final String DRIVER_ORDER_STATUS_UPDATE_KEY = "clx-user.driver.orderStatus.update.key";
// 车辆出车状态更新
public static final String TRUCK_EXCHANGE = "clx-user.truck.exchange";
public static final String TRUCK_ORDER_STATUS_UPDATE_KEY = "clx-user.truck.orderStatus.update.key";
} }
...@@ -165,4 +165,12 @@ public class AppDriverOrderChildController { ...@@ -165,4 +165,12 @@ public class AppDriverOrderChildController {
return Result.ok(orderChildService.getOrderChildFreightInfo(childNo)); return Result.ok(orderChildService.getOrderChildFreightInfo(childNo));
} }
@ApiOperation(value = "查询正在进行中的最新运单", notes = "<br>By:李瑞新")
@GetMapping("/getGoingLatestOrderChild")
public Result<GoingOrderChildVO> getGoingLatestOrderChild() {
return Result.ok(orderChildService.getGoingLatestOrderChild());
}
} }
...@@ -75,7 +75,7 @@ public class CarrierOrderChildController { ...@@ -75,7 +75,7 @@ public class CarrierOrderChildController {
@ApiOperation(value = "取消运单", notes = "<br>By:艾庆国") @ApiOperation(value = "取消运单", notes = "<br>By:艾庆国")
@PostMapping("/updateCancel") @PostMapping("/updateCancel")
public Result<Void> updateCarrierCancel(@RequestBody @Validated OrderChildCarrierCancelParam param) { public Result<Void> updateCarrierCancel(@RequestBody @Validated OrderChildCarrierCancelParam param) {
orderChildPoundAuditService.updateCarrierCancel(param); orderChildService.updateCarrierCancel(param);
return Result.ok(); return Result.ok();
} }
......
...@@ -25,11 +25,15 @@ import java.util.List; ...@@ -25,11 +25,15 @@ import java.util.List;
public interface OrderChildDao extends BaseDao<OrderChildMapper, OrderChild, Integer> { public interface OrderChildDao extends BaseDao<OrderChildMapper, OrderChild, Integer> {
boolean updateStatus(OrderChild item); boolean updateStatus(OrderChild item);
boolean updateCancel(OrderChild item);
boolean updateLoad(OrderChild item); boolean updateLoad(OrderChild item);
boolean updateUnload(OrderChild item); boolean updateUnload(OrderChild item);
boolean updateLoadAndUnload(OrderChild item); boolean updateLoadAndUnload(OrderChild item);
boolean updatePoundAuditStatus(OrderChild item);
boolean updateDriverConfirm(OrderChild item);
boolean updateCancel(OrderChild item);
Optional<OrderChild> getByChildNo(String childNo); Optional<OrderChild> getByChildNo(String childNo);
...@@ -42,8 +46,10 @@ public interface OrderChildDao extends BaseDao<OrderChildMapper, OrderChild, Int ...@@ -42,8 +46,10 @@ public interface OrderChildDao extends BaseDao<OrderChildMapper, OrderChild, Int
IPage<PageCarrierOrderChildVO> pageCarrierOrderChildList(PageCarrierOrderChildParam param); IPage<PageCarrierOrderChildVO> pageCarrierOrderChildList(PageCarrierOrderChildParam param);
Optional<List<OrderChild>> getOrderChildInfoByOrderGoodsNo(String childNo);
boolean updatePoundAuditStatus(OrderChild item); OrderChild getGoingLatestOrderChild(Long driverUserNo);
int countValidByOrderGoodsNo(String orderGoodsNo);
Optional<List<OrderChild>> getOrderChildInfoByOrderGoodsNo(String childNo);
} }
...@@ -33,7 +33,7 @@ public interface OrderGoodsDao extends BaseDao<OrderGoodsMapper, OrderGoods, Int ...@@ -33,7 +33,7 @@ public interface OrderGoodsDao extends BaseDao<OrderGoodsMapper, OrderGoods, Int
IPage<OrderGoodsVO> pageOrderGoodsList(PageOrderGoodsListParam param); IPage<OrderGoodsVO> pageOrderGoodsList(PageOrderGoodsListParam param);
void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight); void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight, Integer orderGoodsStatus);
IPage<OrderGoodsAPPVO> openOrderPageGoodsList(OrderGoodsListPageParam orderGoodsListPageParam); IPage<OrderGoodsAPPVO> openOrderPageGoodsList(OrderGoodsListPageParam orderGoodsListPageParam);
......
...@@ -32,18 +32,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -32,18 +32,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
@Override @Override
public boolean updateStatus(OrderChild item) { public boolean updateStatus(OrderChild item) {
return update(lUdWrapper() return update(lUdWrapper()
.eq(OrderChild::getChildNo, item.getChildNo()) .eq(OrderChild::getId, item.getId())
.set(OrderChild::getStatus, item.getStatus())
);
}
@Override
public boolean updateCancel(OrderChild item) {
return update(lUdWrapper()
.eq(OrderChild::getChildNo, item.getChildNo())
.set(OrderChild::getCancelRemark, item.getCancelRemark())
.set(OrderChild::getCancelTime, item.getCancelTime())
.set(OrderChild::getFinishTime, item.getFinishTime())
.set(OrderChild::getStatus, item.getStatus()) .set(OrderChild::getStatus, item.getStatus())
); );
} }
...@@ -51,13 +40,14 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -51,13 +40,14 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
@Override @Override
public boolean updateLoad(OrderChild item) { public boolean updateLoad(OrderChild item) {
return update(lUdWrapper() return update(lUdWrapper()
.eq(OrderChild::getChildNo, item.getChildNo()) .eq(OrderChild::getId, item.getId())
.set(OrderChild::getLoadRough, item.getLoadRough()) .set(OrderChild::getLoadRough, item.getLoadRough())
.set(OrderChild::getLoadTare, item.getLoadTare()) .set(OrderChild::getLoadTare, item.getLoadTare())
.set(OrderChild::getLoadNet, item.getLoadNet()) .set(OrderChild::getLoadNet, item.getLoadNet())
.set(OrderChild::getLoadTime, item.getLoadTime()) .set(OrderChild::getLoadTime, item.getLoadTime())
.set(OrderChild::getWeight, item.getWeight()) .set(OrderChild::getWeight, item.getWeight())
.set(OrderChild::getFreight, item.getFreight())
.set(OrderChild::getStatus, item.getStatus()) .set(OrderChild::getStatus, item.getStatus())
); );
} }
...@@ -65,7 +55,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -65,7 +55,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
@Override @Override
public boolean updateUnload(OrderChild item) { public boolean updateUnload(OrderChild item) {
return update(lUdWrapper() return update(lUdWrapper()
.eq(OrderChild::getChildNo, item.getChildNo()) .eq(OrderChild::getId, item.getId())
.set(OrderChild::getUnloadPoundNo, item.getUnloadPoundNo()) .set(OrderChild::getUnloadPoundNo, item.getUnloadPoundNo())
.set(OrderChild::getUnloadRough, item.getUnloadRough()) .set(OrderChild::getUnloadRough, item.getUnloadRough())
.set(OrderChild::getUnloadTare, item.getUnloadTare()) .set(OrderChild::getUnloadTare, item.getUnloadTare())
...@@ -73,6 +63,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -73,6 +63,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
.set(OrderChild::getUnloadTime, item.getUnloadTime()) .set(OrderChild::getUnloadTime, item.getUnloadTime())
.set(OrderChild::getPoundStatus, item.getPoundStatus()) .set(OrderChild::getPoundStatus, item.getPoundStatus())
.set(OrderChild::getFreight, item.getFreight())
.set(OrderChild::getStatus, item.getStatus()) .set(OrderChild::getStatus, item.getStatus())
); );
} }
...@@ -80,7 +71,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -80,7 +71,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
@Override @Override
public boolean updateLoadAndUnload(OrderChild item) { public boolean updateLoadAndUnload(OrderChild item) {
return update(lUdWrapper() return update(lUdWrapper()
.eq(OrderChild::getChildNo, item.getChildNo()) .eq(OrderChild::getId, item.getId())
.set(OrderChild::getUnloadPoundNo, item.getUnloadPoundNo()) .set(OrderChild::getUnloadPoundNo, item.getUnloadPoundNo())
.set(OrderChild::getLoadRough, item.getLoadRough()) .set(OrderChild::getLoadRough, item.getLoadRough())
...@@ -91,7 +82,38 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -91,7 +82,38 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
.set(OrderChild::getUnloadTare, item.getUnloadTare()) .set(OrderChild::getUnloadTare, item.getUnloadTare())
.set(OrderChild::getUnloadNet, item.getUnloadNet()) .set(OrderChild::getUnloadNet, item.getUnloadNet())
.set(OrderChild::getWeight, item.getWeight())
.set(OrderChild::getFreight, item.getFreight())
.set(OrderChild::getPoundStatus, item.getPoundStatus())
);
}
@Override
public boolean updatePoundAuditStatus(OrderChild item) {
return update(lUdWrapper()
.eq(OrderChild::getId, item.getId())
.set(OrderChild::getPoundStatus, item.getPoundStatus()) .set(OrderChild::getPoundStatus, item.getPoundStatus())
.set(OrderChild::getLoadNet, item.getLoadNet())
.set(OrderChild::getUnloadNet, item.getUnloadNet())
);
}
@Override
public boolean updateDriverConfirm(OrderChild item) {
return update(lUdWrapper()
.eq(OrderChild::getId, item.getId())
.set(OrderChild::getStatus, item.getStatus())
);
}
@Override
public boolean updateCancel(OrderChild item) {
return update(lUdWrapper()
.eq(OrderChild::getId, item.getId())
.set(OrderChild::getCancelRemark, item.getCancelRemark())
.set(OrderChild::getCancelTime, item.getCancelTime())
.set(OrderChild::getFinishTime, item.getFinishTime())
.set(OrderChild::getStatus, item.getStatus())
); );
} }
...@@ -107,7 +129,6 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -107,7 +129,6 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
@Override @Override
public long countOfCancel(Long userNo, LocalDateTime startTime, LocalDateTime endTime) { public long countOfCancel(Long userNo, LocalDateTime startTime, LocalDateTime endTime) {
return count(lQrWrapper() return count(lQrWrapper()
.eq(OrderChild::getChildNo, userNo) .eq(OrderChild::getChildNo, userNo)
.eq(OrderChild::getStatus, OrderChildEnum.Status.DRIVER_CANCEL.getCode()) .eq(OrderChild::getStatus, OrderChildEnum.Status.DRIVER_CANCEL.getCode())
...@@ -141,17 +162,21 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -141,17 +162,21 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
} }
@Override @Override
public boolean updatePoundAuditStatus(OrderChild item) { public Optional<List<OrderChild>> getOrderChildInfoByOrderGoodsNo(String orderGoodsNo) {
return update(lUdWrapper() return Optional.of(list(lQrWrapper().eq(OrderChild::getOrderGoodsNo, orderGoodsNo)));
.eq(OrderChild::getChildNo, item.getChildNo())
.set(OrderChild::getPoundStatus, item.getPoundStatus())
.set(OrderChild::getLoadNet, item.getLoadNet())
.set(OrderChild::getUnloadNet, item.getUnloadNet())
);
} }
@Override @Override
public Optional<List<OrderChild>> getOrderChildInfoByOrderGoodsNo(String orderGoodsNo) { public OrderChild getGoingLatestOrderChild(Long driverUserNo) {
return Optional.of(list(lQrWrapper().eq(OrderChild::getOrderGoodsNo, orderGoodsNo))); return getOne(lQrWrapper().eq(OrderChild::getDriverUserNo,driverUserNo)
.le(OrderChild::getStatus,OrderChildEnum.Status.UNLOAD.getCode())
.orderByDesc(OrderChild::getId)
.last("limit 1"));
}
@Override
public int countValidByOrderGoodsNo(String orderGoodsNo) {
return baseMapper.countValidByOrderGoodsNo(orderGoodsNo);
} }
} }
...@@ -70,8 +70,8 @@ public class OrderGoodsDaoImpl extends BaseDaoImpl<OrderGoodsMapper, OrderGoods, ...@@ -70,8 +70,8 @@ public class OrderGoodsDaoImpl extends BaseDaoImpl<OrderGoodsMapper, OrderGoods,
} }
@Override @Override
public void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight) { public void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight, Integer orderGoodsStatus) {
baseMapper.updateOrderGoodsWeightAndStatus(id, orderChildWeight, OrderGoodsStatusEnum.Status.GO_TO_SEND.getCode()); baseMapper.updateOrderGoodsWeightAndStatus(id, orderChildWeight, orderGoodsStatus);
} }
@Override @Override
......
...@@ -7,4 +7,7 @@ public interface DriverService { ...@@ -7,4 +7,7 @@ public interface DriverService {
Optional<DriverTruckInfoFeignVo> getUserDetailInfo(Long driverUserNo, Integer truckId); Optional<DriverTruckInfoFeignVo> getUserDetailInfo(Long driverUserNo, Integer truckId);
void updateOrderStatus(Long driverUserNo, Integer driverOrderStatus, Integer truckId, Integer truckOrderStatus);
} }
package com.clx.performance.extranal.user;
import com.clx.order.vo.feign.FeignOrderInfoVO;
import com.msl.common.base.Optional;
import org.springframework.web.bind.annotation.RequestParam;
public interface OrderService {
Optional<FeignOrderInfoVO> getOrderInfo(@RequestParam String orderNo);
}
...@@ -4,11 +4,15 @@ import com.clx.performance.extranal.user.DriverService; ...@@ -4,11 +4,15 @@ import com.clx.performance.extranal.user.DriverService;
import com.clx.user.feign.DriverFeign; import com.clx.user.feign.DriverFeign;
import com.clx.user.vo.feign.DriverTruckInfoFeignVo; import com.clx.user.vo.feign.DriverTruckInfoFeignVo;
import com.msl.common.base.Optional; import com.msl.common.base.Optional;
import com.msl.common.enums.ResultCodeEnum;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.result.Result; import com.msl.common.result.Result;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Objects;
@Slf4j @Slf4j
@Service @Service
@AllArgsConstructor @AllArgsConstructor
...@@ -18,11 +22,19 @@ public class DriverServiceImpl implements DriverService { ...@@ -18,11 +22,19 @@ public class DriverServiceImpl implements DriverService {
@Override @Override
public Optional<DriverTruckInfoFeignVo> getUserDetailInfo(Long driverUserNo, Integer truckId) { public Optional<DriverTruckInfoFeignVo> getUserDetailInfo(Long driverUserNo, Integer truckId) {
Optional<DriverTruckInfoFeignVo> map = Optional.ofNullable(driverFeign.getDriverTruckInfo(driverUserNo, truckId)) Result<DriverTruckInfoFeignVo> result = Optional.ofNullable(driverFeign.getDriverTruckInfo(driverUserNo, truckId)).orElseThrow(ResultCodeEnum.FAIL);
.filter(Result::succeed)
.map(Result::getData);
return map; if (!Objects.equals(result.getCode(), 0)){
throw new ServiceSystemException(ResultCodeEnum.FAIL, result.getMsg());
}
return Optional.ofNullable(result.getData());
} }
@Override
public void updateOrderStatus(Long driverUserNo, Integer driverOrderStatus, Integer truckId, Integer truckOrderStatus){
Optional.ofNullable(driverFeign.updateOrderStatus(driverUserNo, driverOrderStatus, truckId, truckOrderStatus))
.filter(Result::succeed).orElseThrow(ResultCodeEnum.FAIL);
}
} }
package com.clx.performance.extranal.user.impl;
import com.clx.order.feign.OrderFeign;
import com.clx.order.vo.feign.FeignOrderInfoVO;
import com.clx.performance.extranal.user.OrderService;
import com.msl.common.base.Optional;
import com.msl.common.result.Result;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
@AllArgsConstructor
public class OrderServiceImpl implements OrderService {
private final OrderFeign orderFeign;
@Override
public Optional<FeignOrderInfoVO> getOrderInfo(String orderNo) {
return Optional.ofNullable(orderFeign.getOrderInfo(orderNo))
.filter(Result::succeed)
.map(Result::getData);
}
}
...@@ -14,6 +14,7 @@ import com.clx.performance.vo.pc.PageCarrierOrderChildVO; ...@@ -14,6 +14,7 @@ import com.clx.performance.vo.pc.PageCarrierOrderChildVO;
import com.clx.performance.vo.pc.PageOrderChildPoundAuditVO; import com.clx.performance.vo.pc.PageOrderChildPoundAuditVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider; import org.apache.ibatis.annotations.SelectProvider;
...@@ -42,4 +43,7 @@ public interface OrderChildMapper extends BaseMapper<OrderChild> { ...@@ -42,4 +43,7 @@ public interface OrderChildMapper extends BaseMapper<OrderChild> {
@SelectProvider(type = OrderChildSqlProvider.class, method = "pageCarrierOrderChildList") @SelectProvider(type = OrderChildSqlProvider.class, method = "pageCarrierOrderChildList")
IPage<PageCarrierOrderChildVO> pageCarrierOrderChildList(@Param("page") Page<PageCarrierOrderChildVO> page, @Param("param") PageCarrierOrderChildParam param); IPage<PageCarrierOrderChildVO> pageCarrierOrderChildList(@Param("page") Page<PageCarrierOrderChildVO> page, @Param("param") PageCarrierOrderChildParam param);
@Select("select count(1) from order_child where order_goods_no = #{orderGoodsNo} and status < 110")
int countValidByOrderGoodsNo(String orderGoodsNo);
} }
\ No newline at end of file
...@@ -34,9 +34,9 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> { ...@@ -34,9 +34,9 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
IPage<OrderGoodsVO> pageOrderGoodsList(Page<OrderGoodsVO> page, PageOrderGoodsListParam param); IPage<OrderGoodsVO> pageOrderGoodsList(Page<OrderGoodsVO> page, PageOrderGoodsListParam param);
@Update(" update order_goods set " + @Update(" update order_goods set " +
" residue_transport_weight = residue_transport_weight-#{weight}," + " residue_transport_weight = if (residue_transport_weight>#{weight}, residue_transport_weight-#{weight}, 0)," +
" already_transport_weight = already_transport_weight+#{weight}," + " already_transport_weight = already_transport_weight+#{weight}," +
"order_goods_status = #{orderGoodsStatus}" + "order_goods_status = if (residue_transport_weight>#{weight}, #{orderGoodsStatus}, 40) " +
" where id = #{id}") " where id = #{id}")
void updateOrderGoodsWeightAndStatus(@Param("id") Integer id, @Param("weight") BigDecimal orderChildWeight, @Param("orderGoodsStatus") Integer orderGoodsStatus); void updateOrderGoodsWeightAndStatus(@Param("id") Integer id, @Param("weight") BigDecimal orderChildWeight, @Param("orderGoodsStatus") Integer orderGoodsStatus);
......
...@@ -50,7 +50,7 @@ public class OrderGoodsTruckBind implements HasKey<Integer> { ...@@ -50,7 +50,7 @@ public class OrderGoodsTruckBind implements HasKey<Integer> {
@TableField("modified_time") @TableField("modified_time")
@ApiModelProperty("修改时间") @ApiModelProperty("修改时间")
private LocalDateTime updateTime; private LocalDateTime modifiedTime;
@Override @Override
......
package com.clx.performance.service; package com.clx.performance.service;
import com.clx.performance.param.pc.OrderChildCarrierCancelParam;
import com.clx.performance.param.pc.PoundAuditParam; import com.clx.performance.param.pc.PoundAuditParam;
import com.clx.performance.vo.pc.OrderChildPoundAuditDetailVO; import com.clx.performance.vo.pc.OrderChildPoundAuditDetailVO;
...@@ -17,6 +16,5 @@ public interface OrderChildPoundAuditService { ...@@ -17,6 +16,5 @@ public interface OrderChildPoundAuditService {
void updatePoundAudit(PoundAuditParam param); void updatePoundAudit(PoundAuditParam param);
void updateCarrierCancel(OrderChildCarrierCancelParam param);
} }
...@@ -2,6 +2,7 @@ package com.clx.performance.service; ...@@ -2,6 +2,7 @@ package com.clx.performance.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.param.app.*; import com.clx.performance.param.app.*;
import com.clx.performance.param.pc.OrderChildCarrierCancelParam;
import com.clx.performance.param.pc.PageCarrierOrderChildParam; import com.clx.performance.param.pc.PageCarrierOrderChildParam;
import com.clx.performance.param.pc.PagePoundAuditParam; import com.clx.performance.param.pc.PagePoundAuditParam;
import com.clx.performance.vo.app.*; import com.clx.performance.vo.app.*;
...@@ -38,6 +39,8 @@ public interface OrderChildService { ...@@ -38,6 +39,8 @@ public interface OrderChildService {
void updateDriverConfirm(OrderChildDriverConfirmParam param); void updateDriverConfirm(OrderChildDriverConfirmParam param);
void updateDriverCancel(OrderChildDriverCancelParam param); void updateDriverCancel(OrderChildDriverCancelParam param);
void updateCarrierCancel(OrderChildCarrierCancelParam param);
OrderChildVO getOrderChildInfo(String childNo); OrderChildVO getOrderChildInfo(String childNo);
IPage<OrderChildVO> pageOrderChild(PageOrderChildOfDriverParam param); IPage<OrderChildVO> pageOrderChild(PageOrderChildOfDriverParam param);
...@@ -55,4 +58,6 @@ public interface OrderChildService { ...@@ -55,4 +58,6 @@ public interface OrderChildService {
CarrierOrderChildDetailVO getCarrierOrderChildDetail(String childNo); CarrierOrderChildDetailVO getCarrierOrderChildDetail(String childNo);
GoingOrderChildVO getGoingLatestOrderChild();
} }
...@@ -21,7 +21,7 @@ public interface OrderGoodsService { ...@@ -21,7 +21,7 @@ public interface OrderGoodsService {
IPage<OrderGoodsVO> pageOrderGoodsList(PageOrderGoodsListParam param); IPage<OrderGoodsVO> pageOrderGoodsList(PageOrderGoodsListParam param);
void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight); void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight, Integer orderGoodsStatus);
IPage<OrderGoodsAPPVO> indexOrderGoodsList(OrderGoodsListPageParam orderGoodsListParam); IPage<OrderGoodsAPPVO> indexOrderGoodsList(OrderGoodsListPageParam orderGoodsListParam);
} }
...@@ -68,10 +68,15 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer ...@@ -68,10 +68,15 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updatePoundAudit(PoundAuditParam param) { public void updatePoundAudit(PoundAuditParam param) {
//运单详情
OrderChild orderChild = orderChildDao.getByChildNo(param.getChildNo()).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND); OrderChild orderChild = orderChildDao.getByChildNo(param.getChildNo()).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND);
//待审核磅单
OrderChildPoundAudit poundAuditDetail = orderChildPoundAuditDao.getPoundAuditDetail(param.getChildNo()).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND); OrderChildPoundAudit poundAuditDetail = orderChildPoundAuditDao.getPoundAuditDetail(param.getChildNo()).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND);
if(!Objects.equals(poundAuditDetail.getStatus(),OrderChildPoundAuditEnum.Status.AUDIT.getCode())){
throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_STATUS_CHANGED);
}
poundAuditDetail.setStatus(param.getStatus()); poundAuditDetail.setStatus(param.getStatus());
poundAuditDetail.setRejectType(param.getRejectType()); poundAuditDetail.setRejectType(param.getRejectType());
poundAuditDetail.setRemark(param.getRemark()); poundAuditDetail.setRemark(param.getRemark());
...@@ -119,85 +124,4 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer ...@@ -119,85 +124,4 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
} }
@Override
public void updateCarrierCancel(OrderChildCarrierCancelParam param) {
UserSessionData loginUserInfo = TokenUtil.getLoginUserInfo();
Long userNo = loginUserInfo.getUserNo();
String childNo = param.getChildNo();
LocalDateTime now = LocalDateTime.now();
OrderChild orderChild = orderChildDao.getByChildNo(childNo).orElseThrow(PerformanceResultEnum.ORDER_CHILD_NO_FOUND);
if (OrderChildEnum.CANCEL_lIST.contains(orderChild.getStatus())){
return;
}
// 禁止取消 (卸车前取消)
if (orderChild.getStatus()>OrderChildEnum.Status.UNLOAD.getCode()) {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_CANCEL_FORBID);
}
OrderGoods orderGoods = orderGoodsDao.getByOrderGoodsNo(orderChild.getOrderGoodsNo()).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND);
// 定向
OrderGoodsTruckBind orderGoodsTruckBind = null;
if (Objects.equals(orderGoods.getPendingOrderWay(), OrderGoodsPendingOrderWayStatusEnum.Status.EXCLUSIVE.getCode())){
orderGoodsTruckBind = orderGoodsTruckBindDao.getByOrderGoodsNoAndTruckNo(orderGoods.getOrderGoodsNo(), orderChild.getTruckNo())
.orElseThrow(PerformanceResultEnum.DATA_NOT_FIND);
}
orderChild.setCancelRemark(param.getRemark());
orderChild.setCancelTime(now);
orderChild.setFinishTime(now);
orderChild.setStatus(OrderChildEnum.Status.PLATFORM_CANCEL.getCode());
orderChildDao.updateCancel(orderChild);
// 返回吨数
updateOrderGoodsAmountReturn(orderChild, orderGoods);
// 取消定向
updateOrderGoodsDirectCancel(orderGoodsTruckBind);
// 释放司机、车辆
releaseDriver(orderChild.getDriverUserNo());
releaseTruck(orderChild.getTruckId());
// 日志
orderChildLogService.saveCarrierOrderChildLog(childNo, OrderChildLogEnum.Type.PLATFORM_CANCEL.getCode(), OrderChildLogEnum.Type.PLATFORM_CANCEL.getMsg(),
loginUserInfo.getUserNo(), loginUserInfo.getUserName());
}
/**
* 取消返吨数
*/
private void updateOrderGoodsAmountReturn(OrderChild orderChild, OrderGoods orderGoods){
orderGoodsDao.updateOrderGoodsReduceWeightAndStatus(orderGoods.getId(), orderChild.getWeight().negate());
}
/**
* 更新定向派单状态 (取消)
*/
private void updateOrderGoodsDirectCancel(OrderGoodsTruckBind orderGoodsTruckBind){
if (orderGoodsTruckBind == null) {return;}
orderGoodsTruckBind.setStatus(OrderGoodsTruckBind.Status.CANCEL.getCode());
orderGoodsTruckBindDao.updateStatus(orderGoodsTruckBind);
}
/**
* 释放司机
*/
private void releaseDriver(Long driverNo){
}
/**
* 释放车辆
*/
private void releaseTruck(Integer truckId){
}
} }
...@@ -75,8 +75,8 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { ...@@ -75,8 +75,8 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
} }
@Override @Override
public void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight) { public void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight, Integer orderGoodsStatus) {
orderGoodsDao.updateOrderGoodsReduceWeightAndStatus(id, orderChildWeight); orderGoodsDao.updateOrderGoodsReduceWeightAndStatus(id, orderChildWeight, orderGoodsStatus);
} }
@Override @Override
......
...@@ -120,7 +120,7 @@ public class OrderGoodsSqlProvider { ...@@ -120,7 +120,7 @@ public class OrderGoodsSqlProvider {
"a.extract_way,a.need_truck_num,a.senior_logistics_manager_id,a.senior_logistics_manager_name," + "a.extract_way,a.need_truck_num,a.senior_logistics_manager_id,a.senior_logistics_manager_name," +
"a.pending_order_freight,a.user_no,a.user_name from order_goods a where a.last_arrive_send_time >= now() and (a.order_goods_status = 20 or a.order_goods_status = 30)" + "a.pending_order_freight,a.user_no,a.user_name from order_goods a where a.last_arrive_send_time >= now() and (a.order_goods_status = 20 or a.order_goods_status = 30)" +
"and a.residue_transport_weight > 0" + "and a.residue_transport_weight > 0" +
" and a.pending_order_way = 1 and a.order_goods_no in ("); " and a.pending_order_way = 2 and a.order_goods_no in (");
if (!param.isEmpty()) { if (!param.isEmpty()) {
for (int i = 0; i < param.size(); i++) { for (int i = 0; i < param.size(); i++) {
......
package com.clx.performance.strategy;
import com.clx.order.params.OrderGoodsParams;
import com.clx.order.vo.feign.FeignOrderVO;
import java.time.LocalDateTime;
public interface GoodsOrderStrategy {
LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo);
}
package com.clx.performance.strategy.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.clx.order.feign.OrderFeign;
import com.clx.order.params.OrderGoodsChildParams;
import com.clx.order.params.OrderGoodsParams;
import com.clx.order.vo.feign.FeignOrderVO;
import com.clx.performance.component.GoodsOrderStrategyContext;
import com.clx.performance.component.OrderGoodsIdGenerate;
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.mapper.OrderGoodsMapper;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.strategy.GoodsOrderStrategy;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Component("OneGoodsOrderStrategy")
@Slf4j
public class OneGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBean {
@Autowired
private OrderGoodsIdGenerate orderGoodsIdGenerate;
@Autowired
private OrderGoodsTruckBindDao orderGoodsTruckBindDao;
@Autowired
private OrderFeign orderFeign;
@Autowired
OrderGoodsService orderGoodsService;
@Autowired
OrderGoodsMapper orderGoodsMapper;
@Autowired
private GoodsOrderStrategyContext goodsOrderStrategyContext;
@Override
public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo) {
String orderNo = orderGoodsParams.getOrderNo();
LocalDateTime now = LocalDateTime.now();
LocalDateTime sendLazyTime = null;
List<OrderGoodsChildParams> childParamsList = orderGoodsParams.getOrderGoodsChildParams();
BigDecimal childSum = childParamsList.stream().map(OrderGoodsChildParams::getExtractWeight).reduce(
BigDecimal.ZERO, BigDecimal::add);
if (orderInfo.getResidueWeight().compareTo(childSum) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货单总吨数已超订单总吨数");
}
long beginOrderGoodsId = orderGoodsIdGenerate.getOrderGoodsId(OrderGoodsTypeEnum.Status.PLATFORM.getCode(), childParamsList.size());
for (OrderGoodsChildParams child : childParamsList) {
if (child.getPendingOrderWay().equals(2)) {
if (child.getNeedTruckNum() == null) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "定向派单必须选择车辆");
}
if (child.getNeedTruckNum() != child.getTruckList().size()) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "定向派单需要车数与已选车辆数量不一致");
}
}
OrderGoods orderGoods = new OrderGoods();
//提取吨数
orderGoods.setExtractWeight(child.getExtractWeight());
orderGoods.setResidueTransportWeight(child.getExtractWeight());
orderGoods.setLossPrice(orderInfo.getLossPrice());
//提取方式 1提取全部 2提取部分
Integer extractWay = child.getExtractWay();
orderGoods.setExtractWay(extractWay);
//需要车辆
orderGoods.setNeedTruckNum(child.getNeedTruckNum());
//挂单方式
orderGoods.setPendingOrderWay(child.getPendingOrderWay());
//挂单时间
LocalDateTime postedTime = DateUtils.parseDateTime(child.getPendingOrderTime()).get();
if (sendLazyTime == null) {
sendLazyTime = postedTime;
} else if (sendLazyTime.isAfter(postedTime)) {
sendLazyTime = postedTime;
}
orderGoods.setPendingOrderTime(postedTime);
orderGoods.setPendingOrderFreight(child.getPendingOrderFreight());
orderGoods.setLastArriveSendTime(DateUtils.parseDateTime(child.getLastArriveSendTime()).get());
//定向运单失效时间
// orderGoods.setDirectionalExpireTime(DateUtils.parseDateTime(child.getDirectionalExpireTime()).get());
// orderGoods.setSeniorLogisticsManagerId(child.getSeniorLogisticsManagerId());
// orderGoods.setSeniorLogisticsManagerName(child.getSeniorLogisticsManagerName());
orderGoods.setOrderNo(orderNo);
orderGoods.setOrderGoodsNo(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
orderGoods.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CREATED.getCode());
orderGoods.setSendAddressId(orderInfo.getSendAddressId());
orderGoods.setSendAddressShorter(orderInfo.getSendAddressShorter());
//收发货经纬度
orderGoods.setSendLongitude(orderInfo.getSendLongitude());
orderGoods.setSendLatitude(orderInfo.getSendLatitude());
orderGoods.setReceiveLatitude(orderInfo.getReveiveLatitude());
orderGoods.setReceiveLongitude(orderInfo.getReveiveLongitude());
orderGoods.setReceiveAddressId(orderInfo.getReveiveAddressId());
orderGoods.setGoodsName(orderInfo.getGoodsName());
orderGoods.setCreateTime(now);
orderGoods.setModifiedTime(now);
orderGoods.setUserName("loginUserInfo.getUserName()");
orderGoods.setUserNo(123L);
if (CollectionUtil.isNotEmpty(child.getTruckList())) {
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
}
beginOrderGoodsId = beginOrderGoodsId + 1;
orderGoodsMapper.insert(orderGoods);
}
orderFeign.updateOrderInfoResidueWeight(orderInfo.getId(),orderInfo.getResidueWeight().subtract(childSum));
return sendLazyTime;
}
@Override
public void afterPropertiesSet() throws Exception {
goodsOrderStrategyContext.strategyContext.put(1,this);
}
}
package com.clx.performance.strategy.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.clx.order.feign.OrderFeign;
import com.clx.order.params.OrderGoodsChildParams;
import com.clx.order.params.OrderGoodsParams;
import com.clx.order.vo.feign.FeignOrderVO;
import com.clx.performance.component.GoodsOrderStrategyContext;
import com.clx.performance.component.OrderGoodsIdGenerate;
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.mapper.OrderGoodsMapper;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.strategy.GoodsOrderStrategy;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Component("ThreeGoodsOrderStrategy")
@Slf4j
public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBean {
@Autowired
private OrderGoodsIdGenerate orderGoodsIdGenerate;
@Autowired
private OrderGoodsTruckBindDao orderGoodsTruckBindDao;
@Autowired
OrderGoodsService orderGoodsService;
@Autowired
OrderGoodsMapper orderGoodsMapper;
@Autowired
private GoodsOrderStrategyContext goodsOrderStrategyContext;
@Autowired
private OrderFeign orderFeign;
@Override
public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo) {
String orderNo = orderGoodsParams.getOrderNo();
LocalDateTime now = LocalDateTime.now();
LocalDateTime sendLazyTime = null;
List<OrderGoodsChildParams> childParamsList = orderGoodsParams.getOrderGoodsChildParams();
BigDecimal childSum = childParamsList.stream().map(OrderGoodsChildParams::getExtractWeight).reduce(
BigDecimal.ZERO, BigDecimal::add);
if (orderInfo.getResidueWeight().compareTo(childSum) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货单总吨数已超订单总吨数");
}
if (childParamsList.size() > 1) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "全部自有车辆只能全部提取");
}
long beginOrderGoodsId = orderGoodsIdGenerate.getOrderGoodsId(OrderGoodsTypeEnum.Status.PLATFORM.getCode(), childParamsList.size());
for (OrderGoodsChildParams child : childParamsList) {
OrderGoods orderGoods = new OrderGoods();
//提取吨数
orderGoods.setExtractWeight(child.getExtractWeight());
orderGoods.setResidueTransportWeight(child.getExtractWeight());
orderGoods.setLossPrice(orderInfo.getLossPrice());
//提取方式 1提取全部 2提取部分
Integer extractWay = child.getExtractWay();
if (extractWay.equals(2)) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "全部自有车辆只能全部提取");
}
orderGoods.setExtractWay(extractWay);
//需要车辆
orderGoods.setNeedTruckNum(child.getNeedTruckNum());
//挂单方式
orderGoods.setPendingOrderWay(child.getPendingOrderWay());
//挂单时间
LocalDateTime postedTime = DateUtils.parseDateTime(child.getPendingOrderTime()).get();
if (sendLazyTime == null) {
sendLazyTime = postedTime;
} else if (sendLazyTime.isAfter(postedTime)) {
sendLazyTime = postedTime;
}
orderGoods.setPendingOrderTime(postedTime);
orderGoods.setPendingOrderFreight(child.getPendingOrderFreight());
orderGoods.setLastArriveSendTime(DateUtils.parseDateTime(child.getLastArriveSendTime()).get());
//定向运单失效时间
// orderGoods.setDirectionalExpireTime(DateUtils.parseDateTime(child.getDirectionalExpireTime()).get());
// orderGoods.setSeniorLogisticsManagerId(child.getSeniorLogisticsManagerId());
// orderGoods.setSeniorLogisticsManagerName(child.getSeniorLogisticsManagerName());
orderGoods.setOrderNo(orderNo);
orderGoods.setOrderGoodsNo(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
orderGoods.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CREATED.getCode());
orderGoods.setSendAddressId(orderInfo.getSendAddressId());
orderGoods.setSendAddressShorter(orderInfo.getSendAddressShorter());
//收发货经纬度
orderGoods.setSendLongitude(orderInfo.getSendLongitude());
orderGoods.setSendLatitude(orderInfo.getSendLatitude());
orderGoods.setReceiveLatitude(orderInfo.getReveiveLatitude());
orderGoods.setReceiveLongitude(orderInfo.getReveiveLongitude());
orderGoods.setReceiveAddressId(orderInfo.getReveiveAddressId());
orderGoods.setGoodsName(orderInfo.getGoodsName());
orderGoods.setCreateTime(now);
orderGoods.setModifiedTime(now);
orderGoods.setUserName("loginUserInfo.getUserName()");
orderGoods.setUserNo(123L);
if (CollectionUtil.isNotEmpty(child.getTruckList())) {
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
}
beginOrderGoodsId = beginOrderGoodsId + 1;
orderGoodsMapper.insert(orderGoods);
}
orderFeign.updateOrderInfoResidueWeight(orderInfo.getId(),orderInfo.getResidueWeight().subtract(childSum));
return sendLazyTime;
}
@Override
public void afterPropertiesSet() throws Exception {
goodsOrderStrategyContext.strategyContext.put(3,this);
}
}
package com.clx.performance.strategy.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.clx.order.feign.OrderFeign;
import com.clx.order.params.OrderGoodsChildParams;
import com.clx.order.params.OrderGoodsParams;
import com.clx.order.vo.feign.FeignOrderVO;
import com.clx.performance.component.GoodsOrderStrategyContext;
import com.clx.performance.component.OrderGoodsIdGenerate;
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.mapper.OrderGoodsMapper;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.strategy.GoodsOrderStrategy;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Component("TwoGoodsOrderStrategy")
@Slf4j
public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBean {
@Autowired
private OrderGoodsIdGenerate orderGoodsIdGenerate;
@Autowired
private OrderGoodsTruckBindDao orderGoodsTruckBindDao;
@Autowired
OrderGoodsService orderGoodsService;
@Autowired
OrderGoodsMapper orderGoodsMapper;
@Autowired
private OrderFeign orderFeign;
@Autowired
private GoodsOrderStrategyContext goodsOrderStrategyContext;
@Override
public LocalDateTime goodsOrderProcess(OrderGoodsParams orderGoodsParams, FeignOrderVO orderInfo) {
String orderNo = orderGoodsParams.getOrderNo();
LocalDateTime now = LocalDateTime.now();
LocalDateTime sendLazyTime = null;
List<OrderGoodsChildParams> childParamsList = orderGoodsParams.getOrderGoodsChildParams();
BigDecimal childSum = childParamsList.stream().map(OrderGoodsChildParams::getExtractWeight).reduce(
BigDecimal.ZERO, BigDecimal::add);
if (orderInfo.getResidueWeight().compareTo(childSum) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货单总吨数已超订单总吨数");
}
long beginOrderGoodsId = orderGoodsIdGenerate.getOrderGoodsId(OrderGoodsTypeEnum.Status.PLATFORM.getCode(), childParamsList.size());
for (OrderGoodsChildParams child : childParamsList) {
if (child.getPendingOrderWay().equals(2)) {
if (child.getNeedTruckNum() == null) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "定向派单必须选择车辆");
}
if (child.getNeedTruckNum() != child.getTruckList().size()) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "定向派单需要车数与已选车辆数量不一致");
}
}
OrderGoods orderGoods = new OrderGoods();
//提取吨数
orderGoods.setExtractWeight(child.getExtractWeight());
orderGoods.setResidueTransportWeight(child.getExtractWeight());
orderGoods.setLossPrice(orderInfo.getLossPrice());
//提取方式 1提取全部 2提取部分
Integer extractWay = child.getExtractWay();
orderGoods.setExtractWay(extractWay);
//需要车辆
orderGoods.setNeedTruckNum(child.getNeedTruckNum());
//挂单方式
orderGoods.setPendingOrderWay(child.getPendingOrderWay());
//挂单时间
LocalDateTime postedTime = DateUtils.parseDateTime(child.getPendingOrderTime()).get();
if (sendLazyTime == null) {
sendLazyTime = postedTime;
} else if (sendLazyTime.isAfter(postedTime)) {
sendLazyTime = postedTime;
}
orderGoods.setPendingOrderTime(postedTime);
orderGoods.setPendingOrderFreight(child.getPendingOrderFreight());
orderGoods.setLastArriveSendTime(DateUtils.parseDateTime(child.getLastArriveSendTime()).get());
//定向运单失效时间
// orderGoods.setDirectionalExpireTime(DateUtils.parseDateTime(child.getDirectionalExpireTime()).get());
// orderGoods.setSeniorLogisticsManagerId(child.getSeniorLogisticsManagerId());
// orderGoods.setSeniorLogisticsManagerName(child.getSeniorLogisticsManagerName());
orderGoods.setOrderNo(orderNo);
orderGoods.setOrderGoodsNo(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
orderGoods.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CREATED.getCode());
orderGoods.setSendAddressId(orderInfo.getSendAddressId());
orderGoods.setSendAddressShorter(orderInfo.getSendAddressShorter());
//收发货经纬度
orderGoods.setSendLongitude(orderInfo.getSendLongitude());
orderGoods.setSendLatitude(orderInfo.getSendLatitude());
orderGoods.setReceiveLatitude(orderInfo.getReveiveLatitude());
orderGoods.setReceiveLongitude(orderInfo.getReveiveLongitude());
orderGoods.setReceiveAddressId(orderInfo.getReveiveAddressId());
orderGoods.setGoodsName(orderInfo.getGoodsName());
orderGoods.setCreateTime(now);
orderGoods.setModifiedTime(now);
orderGoods.setUserName("loginUserInfo.getUserName()");
orderGoods.setUserNo(123L);
if (CollectionUtil.isNotEmpty(child.getTruckList())) {
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
}
beginOrderGoodsId = beginOrderGoodsId + 1;
orderGoodsMapper.insert(orderGoods);
}
orderFeign.updateOrderInfoResidueWeight(orderInfo.getId(),orderInfo.getResidueWeight().subtract(childSum));
return sendLazyTime;
}
@Override
public void afterPropertiesSet() throws Exception {
goodsOrderStrategyContext.strategyContext.put(2,this);
}
}
package com.clx.performance.struct; package com.clx.performance.struct;
import com.clx.performance.model.OrderChild; import com.clx.performance.model.OrderChild;
import com.clx.performance.vo.app.GoingOrderChildVO;
import com.clx.performance.vo.app.OrderChildVO; import com.clx.performance.vo.app.OrderChildVO;
import com.clx.performance.vo.pc.CarrierOrderChildDetailVO; import com.clx.performance.vo.pc.CarrierOrderChildDetailVO;
import com.clx.performance.vo.pc.OrderChildPCVO; import com.clx.performance.vo.pc.OrderChildPCVO;
...@@ -19,4 +20,8 @@ public interface OrderChildStruct { ...@@ -19,4 +20,8 @@ public interface OrderChildStruct {
CarrierOrderChildDetailVO carrierConvert(OrderChild item); CarrierOrderChildDetailVO carrierConvert(OrderChild item);
GoingOrderChildVO convertGoingOrder(OrderChild item);
} }
package com.clx.performance; package com.clx.performance;
import com.clx.order.feign.OrderFeign;
import com.clx.performance.mapper.OrderGoodsMapper; import com.clx.performance.mapper.OrderGoodsMapper;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -14,10 +15,10 @@ import java.math.BigDecimal; ...@@ -14,10 +15,10 @@ import java.math.BigDecimal;
public class JobTest { public class JobTest {
@Autowired @Autowired
private OrderGoodsMapper oderGoodsMapper; private OrderFeign orderFeign;
@Test @Test
public void test1() { public void test1() {
oderGoodsMapper.updateOrderGoodsWeightAndStatus(94,new BigDecimal("23.32"),11); orderFeign.updateOrderInfoResidueWeight(5,new BigDecimal(32));
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论