|
|
@@ -454,37 +454,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
//endregion
|
|
|
|
|
|
//region 销售订单
|
|
|
- if (outboundVO.getFromId() != null) {
|
|
|
- //赋值 (这里重写了更新方法,数量在更新方法中有数据库原始数量+本次数量)
|
|
|
- Order order = new Order();
|
|
|
- order.setOrderId(outboundVO.getFromId());
|
|
|
- //根据id查询
|
|
|
- OrderResponse orderResponse = orderMapper.selectById(outboundVO.getFromId());
|
|
|
- //已出库
|
|
|
- if (Constant.OutStatus.YICHUKU.getName().equals(outboundVO.getOutStatus())) {
|
|
|
- order.setOutingQty(BigDecimal.ZERO);
|
|
|
- order.setOutingAmt(BigDecimal.ZERO);
|
|
|
- order.setOutQty(outboundVO.getOutQty());
|
|
|
- order.setOutAmt(outboundVO.getOutAmt());
|
|
|
- }
|
|
|
- //出库中
|
|
|
- else {
|
|
|
- order.setOutingQty(outboundVO.getOutingQty());
|
|
|
- order.setOutingAmt(outboundVO.getOutingAmt());
|
|
|
- order.setOutQty(BigDecimal.ZERO);
|
|
|
- order.setOutAmt(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- //入库状态
|
|
|
- String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
|
|
|
- orderResponse.getOutQty().add(order.getOutQty()), orderResponse.getSumQuantity());
|
|
|
- order.setOutStatus(outStatus);
|
|
|
- //修改
|
|
|
- int countRow = orderMapper.updateById(order);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
+ //新建销售出库修改销售订单信息
|
|
|
+ this.insertOrderMessageByEdit(outboundVO,outboundVO.getItemList());
|
|
|
//endregion
|
|
|
|
|
|
BigDecimal factAmt = BigDecimal.ZERO; //总单的实际金额
|
|
|
@@ -498,6 +469,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
|
|
|
for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
|
|
|
outboundItemVO.setItemId(null);
|
|
|
+
|
|
|
//region 将库存需要的参数赋值
|
|
|
outboundItemVO.setInventoryType(Constant.InventoryType.OUTBOUND.getName());
|
|
|
outboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.SALE_ORDER.getValue());
|
|
|
@@ -614,6 +586,58 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @desc : 新建销售出库修改销售订单信息
|
|
|
+ * @date : 2024/6/27 9:27
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public void insertOrderMessageByEdit(OutboundVO outboundVO , List<OutboundItemVO> itemList){
|
|
|
+ //出库明细汇总
|
|
|
+ Map<String, List<OutboundItemVO>> orderOutItemVOListMap = itemList.stream().collect(Collectors.groupingBy(OutboundItemVO::getFromId));
|
|
|
+ //出库明细汇总循环
|
|
|
+ for (String fromId : orderOutItemVOListMap.keySet()) {
|
|
|
+
|
|
|
+ //region 提取新建分组后的明细
|
|
|
+ List<OutboundItemVO> orderOutItemVOListGroup = orderOutItemVOListMap.get(fromId);
|
|
|
+ //分组后的明细 出库数量和金额总和
|
|
|
+ BigDecimal orderSumQty = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal orderSumAmt = orderOutItemVOListGroup.stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 反写订单数据
|
|
|
+ //根据id查询
|
|
|
+ OrderResponse orderResponse = orderMapper.selectById(fromId);
|
|
|
+ Order order = new Order();
|
|
|
+ order.setOrderId(fromId);
|
|
|
+ //已出库
|
|
|
+ if (Constant.OutStatus.YICHUKU.getName().equals(outboundVO.getOutStatus())) {
|
|
|
+ order.setOutingQty(BigDecimal.ZERO);
|
|
|
+ order.setOutingAmt(BigDecimal.ZERO);
|
|
|
+ order.setOutQty(orderSumQty);
|
|
|
+ order.setOutAmt(orderSumAmt);
|
|
|
+ }
|
|
|
+ //出库中
|
|
|
+ else {
|
|
|
+ order.setOutingQty(orderSumQty);
|
|
|
+ order.setOutingAmt(orderSumQty);
|
|
|
+ order.setOutQty(BigDecimal.ZERO);
|
|
|
+ order.setOutAmt(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ //出库状态
|
|
|
+ String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
|
|
|
+ orderResponse.getOutQty().add(order.getOutQty()), orderResponse.getSumQuantity());
|
|
|
+ order.setOutStatus(outStatus);
|
|
|
+ //修改
|
|
|
+ int countRow = orderMapper.updateById(order);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED_OUTBOUND.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* @desc : 销售出库编辑
|
|
|
* @date : 2024/3/25 16:25
|
|
|
* @author : 寇珊珊
|
|
|
@@ -1899,8 +1923,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
public String setOutStatus(BigDecimal intoingQty, BigDecimal intoQty, BigDecimal sumQty) {
|
|
|
//出库状态
|
|
|
String outStatus = null;
|
|
|
- //出库中+已出库小于总数 并且 出库中+已出库大于0
|
|
|
- if(intoingQty.add(intoQty).compareTo(sumQty) < 0 && intoingQty.add(intoQty).compareTo(BigDecimal.ZERO) > 0 ){
|
|
|
+ //出库中小于等于总数,已出库小于总数,并且出库中+已出库大于0
|
|
|
+ if(intoingQty.compareTo(sumQty)<=0 && intoQty.compareTo(sumQty) < 0 && intoingQty.add(intoQty).compareTo(BigDecimal.ZERO) > 0 ){
|
|
|
//出库中
|
|
|
outStatus = Constant.OutStatus.CHUKUZHONG.getName();
|
|
|
}
|