Commit 61fa3ac1 authored by huyf's avatar huyf

提货箱数、提货率、提货状态回填

parent f5ee152b
...@@ -538,7 +538,7 @@ public class OrderDO extends BaseDO { ...@@ -538,7 +538,7 @@ public class OrderDO extends BaseDO {
private Integer pickState; private Integer pickState;
@ApiModelProperty(value = "'提货率'") @ApiModelProperty(value = "'提货率'")
private String pickRatio; private BigDecimal pickRatio;
@ApiModelProperty(value = "'提货箱数'") @ApiModelProperty(value = "'提货箱数'")
private Integer pickNum; private Integer pickNum;
......
...@@ -534,7 +534,7 @@ public class OrderBackInfoDto { ...@@ -534,7 +534,7 @@ public class OrderBackInfoDto {
private Integer pickState; private Integer pickState;
@ApiModelProperty(value = "'提货率'") @ApiModelProperty(value = "'提货率'")
private Integer pickRatio; private BigDecimal pickRatio;
@ApiModelProperty(value = "'提货箱数'") @ApiModelProperty(value = "'提货箱数'")
private Integer pickNum; private Integer pickNum;
......
package cn.iocoder.yudao.module.order.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum PickStateEnum {
unpick(0,"待提货"),
picking(1,"提货中"),
partPick(2,"部分提货"),
picked(3,"已提货");
private Integer pickState;
private String pickStateStr;
}
...@@ -29,6 +29,7 @@ import cn.iocoder.yudao.module.order.vo.orderPickup.*; ...@@ -29,6 +29,7 @@ import cn.iocoder.yudao.module.order.vo.orderPickup.*;
import cn.iocoder.yudao.module.order.vo.orderTime.OrderTimeQueryVO; import cn.iocoder.yudao.module.order.vo.orderTime.OrderTimeQueryVO;
import cn.iocoder.yudao.module.system.service.user.AdminUserService; import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -38,6 +39,7 @@ import org.springframework.validation.annotation.Validated; ...@@ -38,6 +39,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -188,6 +190,7 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O ...@@ -188,6 +190,7 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O
} }
} }
} }
dealDeliveryRate(createReqVO.getOrderId(),createReqVO.getPickNum(),orderDO.getSumNum(),PickStateEnum.picked.getPickState());
// 返回 // 返回
return orderPickup.getId(); return orderPickup.getId();
} }
...@@ -204,6 +207,20 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O ...@@ -204,6 +207,20 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O
return orderDO.getSumNum() - allPickNum; return orderDO.getSumNum() - allPickNum;
} }
private void dealDeliveryRate(String orderNo,Integer pickNum,Integer sumNum,Integer pickState) {
List<OrderPickupDO> orderPickupDOS = orderPickupMapper.selectList(OrderPickupDO::getOrderId, orderNo);
int pickedSum = orderPickupDOS.stream().mapToInt(OrderPickupDO::getPickNum).sum();
int allPickNum = pickedSum + pickNum;
BigDecimal pickRatio = new BigDecimal(allPickNum / sumNum);
pickRatio.setScale(2, RoundingMode.HALF_UP);
orderService.update(new LambdaUpdateWrapper<OrderDO>()
.set(OrderDO::getPickNum, allPickNum)
.set(OrderDO::getPickRatio, pickRatio)
.set(OrderDO::getPickState,pickState)
.eq(OrderDO::getOrderNo,orderNo)
);
}
private void deleteCustomLevelAndCreditLevelLog(OrderPickupDO orderPickupDO) { private void deleteCustomLevelAndCreditLevelLog(OrderPickupDO orderPickupDO) {
OrderBackInfoDto info = orderQueryService.info(orderService.selectOne(OrderDO::getOrderNo, orderPickupDO.getOrderId()).getOrderId()); OrderBackInfoDto info = orderQueryService.info(orderService.selectOne(OrderDO::getOrderNo, orderPickupDO.getOrderId()).getOrderId());
if (info.getSumNum() != 0) { if (info.getSumNum() != 0) {
...@@ -318,11 +335,13 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O ...@@ -318,11 +335,13 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O
List<OrderPickupDO> pickupDOList = orderPickupMapper.selectList(new LambdaQueryWrapper<OrderPickupDO>().eq(OrderPickupDO::getOrderId, orderPickupDO.getOrderId()).orderByDesc(OrderPickupDO::getPickTime)); List<OrderPickupDO> pickupDOList = orderPickupMapper.selectList(new LambdaQueryWrapper<OrderPickupDO>().eq(OrderPickupDO::getOrderId, orderPickupDO.getOrderId()).orderByDesc(OrderPickupDO::getPickTime));
if (CollectionUtil.isNotEmpty(pickupDOList) && pickupDOList.size() > 0) { if (CollectionUtil.isNotEmpty(pickupDOList) && pickupDOList.size() > 0) {
orderService.updateStatus(one.getOrderId(), null, OrderStatusEnum.PART_PICKED_UP.getValue(), null, null, null, null, null); orderService.updateStatus(one.getOrderId(), null, OrderStatusEnum.PART_PICKED_UP.getValue(), null, null, null, null, null);
dealDeliveryRate(one.getOrderNo(),-orderPickupDO.getPickNum(),one.getSumNum(),PickStateEnum.partPick.getPickState());
} else { } else {
// 找到已删除 订单状态大于0的数据来恢复订单状态 // 找到已删除 订单状态大于0的数据来恢复订单状态
OrderPickupDO delOrderPickupDO = orderPickupMapper.selectDeletedPickup(orderPickupDO.getOrderId()); OrderPickupDO delOrderPickupDO = orderPickupMapper.selectDeletedPickup(orderPickupDO.getOrderId());
// 这里需要考虑到老数据的空指针异常 // 这里需要考虑到老数据的空指针异常
orderService.updateStatus(one.getOrderId(), null, Objects.nonNull(delOrderPickupDO) ? delOrderPickupDO.getOrderStatus() : 16, null, null, null, null, null); orderService.updateStatus(one.getOrderId(), null, Objects.nonNull(delOrderPickupDO) ? delOrderPickupDO.getOrderStatus() : 16, null, null, null, null, null);
dealDeliveryRate(one.getOrderNo(),-orderPickupDO.getPickNum(),one.getSumNum(),PickStateEnum.picked.getPickState());
} }
if (Objects.equals(one.getTransportId(), TransportTypeShortEnum.AIR_FREIGHT_LINE.getValue())) { if (Objects.equals(one.getTransportId(), TransportTypeShortEnum.AIR_FREIGHT_LINE.getValue())) {
...@@ -516,6 +535,7 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O ...@@ -516,6 +535,7 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O
} }
} }
} }
dealDeliveryRate(createReqVO.getOrderId(),createReqVO.getPickNum(),orderDO.getSumNum(),PickStateEnum.picked.getPickState());
} }
} }
} }
...@@ -638,6 +658,7 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O ...@@ -638,6 +658,7 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O
OrderDO orderDO1 = new OrderDO(); OrderDO orderDO1 = new OrderDO();
BeanUtils.copyProperties(orderDO, orderDO1); BeanUtils.copyProperties(orderDO, orderDO1);
insertCustomLevelAndCreditLevelLog(orderPickup, orderDO1, false); insertCustomLevelAndCreditLevelLog(orderPickup, orderDO1, false);
dealDeliveryRate(createReqVO.getOrderId(),createReqVO.getPickNum(),orderDO.getSumNum(),PickStateEnum.partPick.getPickState());
} else if (num < 0) { } else if (num < 0) {
//如果分批提的数量加上已分批提的数量超过了总量 则重新计算成剩余的量 //如果分批提的数量加上已分批提的数量超过了总量 则重新计算成剩余的量
throw exception(PICK_UP_TOO_MORE); throw exception(PICK_UP_TOO_MORE);
...@@ -662,6 +683,7 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O ...@@ -662,6 +683,7 @@ public class OrderPickupServiceImpl extends AbstractService<OrderPickupMapper, O
BeanUtils.copyProperties(orderDO, orderDO1); BeanUtils.copyProperties(orderDO, orderDO1);
insertCustomLevelAndCreditLevelLog(orderPickup, orderDO1, true); insertCustomLevelAndCreditLevelLog(orderPickup, orderDO1, true);
updateCustomerLevelUp(orderDO1); updateCustomerLevelUp(orderDO1);
dealDeliveryRate(createReqVO.getOrderId(),createReqVO.getPickNum(),orderDO.getSumNum(),PickStateEnum.picked.getPickState());
} }
orderBusinessService.addOrderOperateLog(orderDO.getOrderId(), "", "分批提货", ""); orderBusinessService.addOrderOperateLog(orderDO.getOrderId(), "", "分批提货", "");
if (Objects.equals(orderDO.getTransportId(), TransportTypeShortEnum.AIR_FREIGHT_LINE.getValue())) { if (Objects.equals(orderDO.getTransportId(), TransportTypeShortEnum.AIR_FREIGHT_LINE.getValue())) {
......
...@@ -375,7 +375,7 @@ public class OrderBackPageVO { ...@@ -375,7 +375,7 @@ public class OrderBackPageVO {
private Integer pickState; private Integer pickState;
@ApiModelProperty(value = "'提货率'") @ApiModelProperty(value = "'提货率'")
private Integer pickRatio; private BigDecimal pickRatio;
@ApiModelProperty(value = "'提货箱数'") @ApiModelProperty(value = "'提货箱数'")
private Integer pickNum; private Integer pickNum;
......
...@@ -631,7 +631,7 @@ public class OrderBackVO { ...@@ -631,7 +631,7 @@ public class OrderBackVO {
private Integer pickState; private Integer pickState;
@ApiModelProperty(value = "'提货率'") @ApiModelProperty(value = "'提货率'")
private Integer pickRatio; private BigDecimal pickRatio;
@ApiModelProperty(value = "'提货箱数'") @ApiModelProperty(value = "'提货箱数'")
private Integer pickNum; private Integer pickNum;
......
...@@ -359,7 +359,7 @@ public class OrderBaseVO { ...@@ -359,7 +359,7 @@ public class OrderBaseVO {
private Integer pickState; private Integer pickState;
@ApiModelProperty(value = "'提货率'") @ApiModelProperty(value = "'提货率'")
private Integer pickRatio; private BigDecimal pickRatio;
@ApiModelProperty(value = "'提货箱数'") @ApiModelProperty(value = "'提货箱数'")
private Integer pickNum; private Integer pickNum;
......
...@@ -542,16 +542,16 @@ public class OrderQueryVO { ...@@ -542,16 +542,16 @@ public class OrderQueryVO {
private Integer pickState; private Integer pickState;
@ApiModelProperty(value = "'提货率'") @ApiModelProperty(value = "'提货率'")
private Integer pickRatio; private BigDecimal pickRatio;
@ApiModelProperty(value = "小于等于提货率") @ApiModelProperty(value = "小于等于提货率")
private String lePickRatio; private BigDecimal lePickRatio;
@ApiModelProperty(value = "等于提货率") @ApiModelProperty(value = "等于提货率")
private String eqPickRatio; private BigDecimal eqPickRatio;
@ApiModelProperty(value = "大于等于提货率") @ApiModelProperty(value = "大于等于提货率")
private String gePickRatio; private BigDecimal gePickRatio;
@ApiModelProperty(value = "'提货箱数'") @ApiModelProperty(value = "'提货箱数'")
private Integer pickNum; private Integer pickNum;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment