Sfoglia il codice sorgente

更新备货流程 --end (待测试)

k 1 anno fa
parent
commit
47261f75c4

+ 3 - 2
ruoyi-ui/src/views/wms/docOrder/index.vue

@@ -143,8 +143,9 @@
           <div v-if="scope.row.ediSendFlag === 'Y'">是</div>
         </template>
       </el-table-column>
-      <el-table-column label="客户单号2" align="center" prop="soReference2"/>
-      <el-table-column label="客户单号3" align="center" prop="soReference3"/>
+      <el-table-column label="更新备货记录" align="center" prop="hEdi08" show-overflow-tooltip = "true"/>
+      <!--      <el-table-column label="客户单号2" align="center" prop="soReference2"/>-->
+<!--      <el-table-column label="客户单号3" align="center" prop="soReference3"/>-->
       <el-table-column label="创建时间" align="center" prop="createTime"/>
       <el-table-column label="创建人" align="center" prop="createBy"/>
       <!--<el-table-column label="单据操作优先级" align="center" prop="priority" />-->

+ 16 - 8
warewms-ams/src/main/java/com/ruoyi/ams/inv/mapper/InvLotAttMapper.java

@@ -5,15 +5,15 @@ import com.ruoyi.ams.inv.domain.InvLotAtt;
 
 /**
  * 批次属性Mapper接口
- * 
+ *
  * @author andy
  * @date 2022-03-09
  */
-public interface InvLotAttMapper 
+public interface InvLotAttMapper
 {
     /**
      * 查询批次属性
-     * 
+     *
      * @param lotnum 批次属性主键
      * @return 批次属性
      */
@@ -21,7 +21,7 @@ public interface InvLotAttMapper
 
     /**
      * 查询批次属性列表
-     * 
+     *
      * @param invLotAtt 批次属性
      * @return 批次属性集合
      */
@@ -29,7 +29,7 @@ public interface InvLotAttMapper
 
     /**
      * 新增批次属性
-     * 
+     *
      * @param invLotAtt 批次属性
      * @return 结果
      */
@@ -37,15 +37,23 @@ public interface InvLotAttMapper
 
     /**
      * 修改批次属性
-     * 
+     *
      * @param invLotAtt 批次属性
      * @return 结果
      */
      int updateInvLotAtt(InvLotAtt invLotAtt);
 
+     /**
+     * 修改批次属性
+     *
+     * @param lotnum
+     * @return 结果
+     */
+     int updateInvLotAttLotatt14IsNull(String lotnum);
+
     /**
      * 删除批次属性
-     * 
+     *
      * @param lotnum 批次属性主键
      * @return 结果
      */
@@ -53,7 +61,7 @@ public interface InvLotAttMapper
 
     /**
      * 批量删除批次属性
-     * 
+     *
      * @param lotnums 需要删除的数据主键集合
      * @return 结果
      */

+ 16 - 7
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/IInvLotAttService.java

@@ -5,15 +5,15 @@ import com.ruoyi.ams.inv.domain.InvLotAtt;
 
 /**
  * 批次属性Service接口
- * 
+ *
  * @author andy
  * @date 2022-03-09
  */
-public interface IInvLotAttService 
+public interface IInvLotAttService
 {
     /**
      * 查询批次属性
-     * 
+     *
      * @param lotnum 批次属性主键
      * @return 批次属性
      */
@@ -21,7 +21,7 @@ public interface IInvLotAttService
 
     /**
      * 查询批次属性列表
-     * 
+     *
      * @param invLotAtt 批次属性
      * @return 批次属性集合
      */
@@ -37,15 +37,24 @@ public interface IInvLotAttService
 
     /**
      * 修改批次属性
-     * 
+     *
      * @param invLotAtt 批次属性
      * @return 结果
      */
      int updateInvLotAtt(InvLotAtt invLotAtt);
 
+
+    /**
+     * 设置批次号Lotatt14为空
+     *
+     * @param lotnum
+     * @return
+     */
+     int updateInvLotAttLotatt14IsNull(String lotnum);
+
     /**
      * 批量删除批次属性
-     * 
+     *
      * @param lotnums 需要删除的批次属性主键集合
      * @return 结果
      */
@@ -53,7 +62,7 @@ public interface IInvLotAttService
 
     /**
      * 删除批次属性信息
-     * 
+     *
      * @param lotnum 批次属性主键
      * @return 结果
      */

+ 5 - 0
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/impl/InvLotAttServiceImpl.java

@@ -70,6 +70,11 @@ public class InvLotAttServiceImpl implements IInvLotAttService {
         return invLotAttMapper.updateInvLotAtt(invLotAtt);
     }
 
+    @Override
+    public int updateInvLotAttLotatt14IsNull(String lotnum) {
+        return invLotAttMapper.updateInvLotAttLotatt14IsNull(lotnum);
+    }
+
     /**
      * 批量删除批次属性
      *

+ 35 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/mapper/WmsDocOrderDetailsMapper.java

@@ -72,6 +72,41 @@ public interface WmsDocOrderDetailsMapper {
      */
     int updateOrderDetailsStock(@Param("orderNo") String orderNo, @Param("orderLoneNo") Long orderLoneNo, @Param("qty") Double qty, @Param("status") String status);
 
+    /**
+     * 修改明细数量和状态
+     *
+     * @param orderNo
+     * @param orderLoneNo
+     * @param qty
+     * @param status
+     * @return
+     */
+    int updateOrderDetailsAddQtyAndSts(@Param("orderNo") String orderNo, @Param("orderLoneNo") Long orderLoneNo, @Param("qty") Double qty, @Param("status") String status);
+
+    /**
+     * 修改明细数量和状态
+     *
+     * @param orderNo
+     * @param orderLoneNo
+     * @param qty
+     * @param status
+     * @return
+     */
+    int updateOrderDetailsSubQtyAndSts(@Param("orderNo") String orderNo, @Param("orderLoneNo") Long orderLoneNo, @Param("qty") Double qty, @Param("status") String status);
+
+    /**
+     * 修改明细备货的数量和状态
+     *
+     * @param orderNo
+     * @param orderLoneNo
+     * @param qtyAll
+     * @param qtySoft
+     * @param status
+     * @return
+     */
+    int updateOrderDetailsSubStockQtyAndSts(@Param("orderNo") String orderNo, @Param("orderLoneNo") Long orderLoneNo
+            , @Param("qtyAll") Double qtyAll,@Param("qtySoft") Double qtySoft, @Param("status") String status);
+
     /**
      * 查询待出库记录
      *

+ 1 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/mapper/WmsDocOrderHeaderMapper.java

@@ -21,6 +21,7 @@ public interface WmsDocOrderHeaderMapper {
      * @return 出库单头
      */
     WmsDocOrderHeader selectWmsDocOrderHeaderByOrderNo(String orderNo);
+    WmsDocOrderHeader selectDocOrderHeaderByOrderNo(String orderNo);
 
     /**
      * 查询出库单头

+ 8 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/service/IWmsDocOrderHeaderService.java

@@ -29,6 +29,14 @@ public interface IWmsDocOrderHeaderService {
      */
     WmsDocOrderHeader selectWmsDocOrderHeaderByOrderNo(String orderNo);
 
+    /**
+     * 查询出库单头
+     *
+     * @param orderNo
+     * @return
+     */
+    WmsDocOrderHeader selectDocOrderHeaderByOrderNo(String orderNo);
+
     /**
      * 查询出库单头(根据ERP单号)
      *

+ 225 - 22
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/UpdateOrderStockingProcessImpl.java

@@ -1,11 +1,15 @@
 package com.ruoyi.ams.order.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.ruoyi.ams.erp.domain.ErpOrderList;
+import com.ruoyi.ams.inv.domain.InvLotLocId;
 import com.ruoyi.ams.inv.domain.form.InvLocIdSearchFrom;
 import com.ruoyi.ams.inv.domain.vo.InvLotLocIdLotattVO;
+import com.ruoyi.ams.inv.service.IInvLotAttService;
 import com.ruoyi.ams.inv.service.IInvLotLocIdService;
 import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
 import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
+import com.ruoyi.ams.order.mapper.WmsDocOrderDetailsMapper;
 import com.ruoyi.ams.order.service.IWmsDocOrderDetailsService;
 import com.ruoyi.ams.order.service.IWmsDocOrderHeaderService;
 import com.ruoyi.ams.order.service.UpdateOrderStockingProcess;
@@ -32,15 +36,19 @@ import java.util.stream.Collectors;
 public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProcess {
 
     @Autowired
-    private IWmsDocOrderHeaderService wmsDocOrderHeaderService;
+    public IWmsDocOrderHeaderService wmsDocOrderHeaderService;
     @Autowired
-    private IWmsDocOrderDetailsService iWmsDocOrderDetailsService;
+    public IWmsDocOrderDetailsService iWmsDocOrderDetailsService;
     @Autowired
-    private IInvLotLocIdService invLotLocIdService;
+    public WmsDocOrderDetailsMapper wmsDocOrderDetailsMapper;
     @Autowired
-    private IBaseLocationInfoService baseLocationInfoService;
+    public IInvLotLocIdService invLotLocIdService;
     @Autowired
-    private UpdateOrderStockingProcess updateOrderStockingProcess;
+    public IInvLotAttService invLotAttService;
+    @Autowired
+    public IBaseLocationInfoService baseLocationInfoService;
+    @Autowired
+    public UpdateOrderStockingProcess updateOrderStockingProcess;
 
     /**
      * 单据明细修改标记
@@ -119,7 +127,7 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
         updateQuantityAndStatusOfDocuments(markerListMap);
         // 更新库存
         updateInventory(markerListMap);
-        return null;
+        return AjaxResult.success();
     }
 
     /**
@@ -167,16 +175,16 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
             List<WmsDocOrderDetails> value = modify_markerListEntry.getValue();
             switch (key) {
                 case INSERT:
-                    detailsInsert(value);
+                    detailsInsertModifyInventory(value);
                     break;
                 case DELETE:
-                    detailsDelete(value);
+                    detailsDeleteModifyInventory(value);
                     break;
                 case ADD:
-                    detailsAdd(value);
+                    detailsAddModifyInventory(value);
                     break;
                 case DECREASE:
-                    detailsDecrease(value);
+                    detailsDecreaseModifyInventory(value);
                     break;
                 default:
                     break;
@@ -194,6 +202,18 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
      */
     @Transactional
     public AjaxResult documentVoided(String orderNo) {
+        List<WmsDocOrderDetails> details = iWmsDocOrderDetailsService.selectWmsDocOrderDetailsByOrderNo(orderNo);
+        for (WmsDocOrderDetails detail : details) {
+            detail.setQtyOrdered(detail.getQtyAllocated());
+        }
+        // 释放已经备货的库存
+        detailsDeleteModifyInventory(details);
+        // 更新出库单为取消
+        WmsDocOrderHeader headerUpdate = new WmsDocOrderHeader();
+        headerUpdate.setOrderNo(orderNo);
+        headerUpdate.setOrderStatus(Constant.ORDER_STS.STS90.getValue());
+        headerUpdate.setRemark("ERP将单据更新为失效!");
+        wmsDocOrderHeaderService.updateWmsDocOrderHeader(headerUpdate);
         return null;
     }
 
@@ -203,10 +223,18 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
      * @param value
      * @return
      */
-    private AjaxResult detailsInsert(List<WmsDocOrderDetails> value) {
+    @Transactional
+    public AjaxResult detailsInsert(List<WmsDocOrderDetails> value) {
+        String orderNo = value.get(0).getOrderNo();
         for (WmsDocOrderDetails details : value) {
-
+            wmsDocOrderHeaderService.insertWmsDocOrderDetails(details);
         }
+        WmsDocOrderHeader headerUpdate = new WmsDocOrderHeader();
+        headerUpdate.setOrderNo(orderNo);
+        headerUpdate.setOrderStatus(Constant.ORDER_STS.STS10.getValue());
+        headerUpdate.setRemark("已发生更新备货流程!");
+        wmsDocOrderHeaderService.updateWmsDocOrderHeader(headerUpdate);
+        recordChangeData(orderNo, "插入:" + JSON.toJSONString(value));
         return AjaxResult.success();
     }
 
@@ -216,7 +244,35 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
      * @param value
      * @return
      */
-    private AjaxResult detailsDelete(List<WmsDocOrderDetails> value) {
+    @Transactional
+    public AjaxResult detailsDelete(List<WmsDocOrderDetails> value) {
+        String orderNo = value.get(0).getOrderNo();
+        String orderStatus = Constant.ORDER_STS.STS23.getValue();
+        WmsDocOrderHeader wmsDocOrderHeader = wmsDocOrderHeaderService.selectDocOrderHeaderByOrderNo(orderNo);
+        for (WmsDocOrderDetails details : value) {
+            BigDecimal qtySoft = details.getQtySoftAllocated();
+            iWmsDocOrderDetailsService.deleteWmsDocOrderDetailsByOrderNo(details.getOrderNo(), details.getOrderLineNo().longValue());
+            // 更新需要减去的备货库存
+            details.setQtyOrdered(qtySoft);
+        }
+        // 主单为创建状态
+        if (wmsDocOrderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS00.getValue())) {
+            orderStatus = Constant.ORDER_STS.STS00.getValue();
+        } else {
+            List<WmsDocOrderDetails> details = iWmsDocOrderDetailsService.selectWmsDocOrderDetailsByOrderNo(orderNo);
+            for (WmsDocOrderDetails detail : details) {
+                if (detail.getQtyOrdered().compareTo(detail.getQtyAllocated()) != 0) {
+                    orderStatus = Constant.ORDER_STS.STS10.getValue();
+                    break;
+                }
+            }
+        }
+        WmsDocOrderHeader headerUpdate = new WmsDocOrderHeader();
+        headerUpdate.setOrderNo(orderNo);
+        headerUpdate.setOrderStatus(orderStatus);
+        headerUpdate.setRemark("已发生更新备货流程!");
+        wmsDocOrderHeaderService.updateWmsDocOrderHeader(headerUpdate);
+        recordChangeData(orderNo, "删除:" + JSON.toJSONString(value));
         return AjaxResult.success();
     }
 
@@ -226,7 +282,24 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
      * @param value
      * @return
      */
-    private AjaxResult detailsAdd(List<WmsDocOrderDetails> value) {
+    public AjaxResult detailsAdd(List<WmsDocOrderDetails> value) {
+        String orderNo = value.get(0).getOrderNo();
+        String orderStatus;
+        WmsDocOrderHeader wmsDocOrderHeader = wmsDocOrderHeaderService.selectDocOrderHeaderByOrderNo(orderNo);
+        orderStatus = wmsDocOrderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS00.getValue())
+                ? Constant.ORDER_STS.STS00.getValue() : Constant.ORDER_STS.STS10.getValue();
+        for (WmsDocOrderDetails details : value) {
+            // 拿到需要增加到数量
+            BigDecimal qtyOrdered = details.getQtyOrdered();
+            wmsDocOrderDetailsMapper.updateOrderDetailsAddQtyAndSts(orderNo, details.getOrderLineNo().longValue()
+                    , qtyOrdered.doubleValue(), orderStatus);
+        }
+        WmsDocOrderHeader headerUpdate = new WmsDocOrderHeader();
+        headerUpdate.setOrderNo(orderNo);
+        headerUpdate.setOrderStatus(orderStatus);
+        headerUpdate.setRemark("已发生更新备货流程!");
+        wmsDocOrderHeaderService.updateWmsDocOrderHeader(headerUpdate);
+        recordChangeData(orderNo, "增加:" + JSON.toJSONString(value));
         return AjaxResult.success();
     }
 
@@ -236,7 +309,51 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
      * @param value
      * @return
      */
-    private AjaxResult detailsDecrease(List<WmsDocOrderDetails> value) {
+    @Transactional
+    public AjaxResult detailsDecrease(List<WmsDocOrderDetails> value) {
+        String orderNo = value.get(0).getOrderNo();
+        String orderStatus = Constant.ORDER_STS.STS23.getValue();
+        WmsDocOrderHeader wmsDocOrderHeader = wmsDocOrderHeaderService.selectDocOrderHeaderByOrderNo(orderNo);
+        for (WmsDocOrderDetails details : value) {
+            WmsDocOrderDetails originalDetail = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByNoLineNo(orderNo, details.getOrderLineNo().longValue());
+            BigDecimal originalQtyOrdered = originalDetail.getQtyOrdered();
+            BigDecimal originalQtyAllocated = originalDetail.getQtyAllocated();
+            // 拿到需要减少数量
+            BigDecimal qtyOrdered = details.getQtyOrdered();
+            wmsDocOrderDetailsMapper.updateOrderDetailsSubQtyAndSts(orderNo, details.getOrderLineNo().longValue()
+                    , qtyOrdered.doubleValue(), Constant.ORDER_STS.STS10.getValue());
+            // 拿到减少已经备货数量
+            BigDecimal nowInvQty = originalQtyOrdered.subtract(qtyOrdered);
+            BigDecimal end = originalQtyAllocated.subtract(nowInvQty);
+            if (end.compareTo(BigDecimal.ZERO) != -1) {
+                // 更新出库明细分配和备货的数量
+                wmsDocOrderDetailsMapper.updateOrderDetailsSubStockQtyAndSts(orderNo, details.getOrderLineNo().longValue()
+                        , end.doubleValue(), end.doubleValue(), Constant.ORDER_STS.STS23.getValue());
+            }
+            if (end.compareTo(BigDecimal.ZERO) == -1) {
+                end = BigDecimal.ZERO;
+            }
+            // 更新需要减去的备货库存
+            details.setQtyOrdered(end);
+        }
+        // 主单为创建状态
+        if (wmsDocOrderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS00.getValue())) {
+            orderStatus = Constant.ORDER_STS.STS00.getValue();
+        } else {
+            List<WmsDocOrderDetails> details = iWmsDocOrderDetailsService.selectWmsDocOrderDetailsByOrderNo(orderNo);
+            for (WmsDocOrderDetails detail : details) {
+                if (detail.getQtyOrdered().compareTo(detail.getQtyAllocated()) != 0) {
+                    orderStatus = Constant.ORDER_STS.STS10.getValue();
+                    break;
+                }
+            }
+        }
+        WmsDocOrderHeader headerUpdate = new WmsDocOrderHeader();
+        headerUpdate.setOrderNo(orderNo);
+        headerUpdate.setOrderStatus(orderStatus);
+        headerUpdate.setRemark("已发生更新备货流程!");
+        wmsDocOrderHeaderService.updateWmsDocOrderHeader(headerUpdate);
+        recordChangeData(orderNo, "增加:" + JSON.toJSONString(value));
         return AjaxResult.success();
     }
 
@@ -246,8 +363,9 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
      * @param value
      * @return
      */
-    private AjaxResult detailsInsertModifyInventory(List<WmsDocOrderDetails> value) {
-        return AjaxResult.success();
+    @Transactional
+    public AjaxResult detailsInsertModifyInventory(List<WmsDocOrderDetails> value) {
+        return AjaxResult.success("新增不需要释放备货库存!");
     }
 
     /**
@@ -256,7 +374,61 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
      * @param value
      * @return
      */
-    private AjaxResult detailsDeleteModifyInventory(List<WmsDocOrderDetails> value) {
+    @Transactional
+    public AjaxResult detailsDeleteModifyInventory(List<WmsDocOrderDetails> value) {
+        Double qtyOrdered; // 需要减少的备货数量
+        String orderNo;  // 出库单号
+        for (WmsDocOrderDetails details : value) {
+            qtyOrdered = details.getQtyOrdered().doubleValue();
+            orderNo = details.getOrderNo();
+            if (qtyOrdered.compareTo(BigDecimal.ZERO.doubleValue()) == 0) {
+                continue;
+            }
+            // 释放存储区的备货库存
+            InvLocIdSearchFrom invLocIdSearchFrom = new InvLocIdSearchFrom();
+            invLocIdSearchFrom.setLotatt14(orderNo);
+            invLocIdSearchFrom.setSku(details.getSku());
+            invLocIdSearchFrom.setZoneId(Constant.ZONE_TYPE.ZONE_INV.toString());
+            // 查出仓储区
+            List<InvLotLocIdLotattVO> idLotattVOListInv = invLotLocIdService.selectInvLocIdLotattList(invLocIdSearchFrom);
+            invLocIdSearchFrom.setZoneId(Constant.ZONE_TYPE.ZONE_VIRTUAL.toString());
+            // 查出虚拟区
+            List<InvLotLocIdLotattVO> idLotattVOListVir = invLotLocIdService.selectInvLocIdLotattList(invLocIdSearchFrom);
+            if (idLotattVOListVir.size() > 0) {
+                idLotattVOListInv.addAll(idLotattVOListVir);
+            }
+            for (InvLotLocIdLotattVO invLotLocId : idLotattVOListInv) {
+                if (qtyOrdered.compareTo(BigDecimal.ZERO.doubleValue()) == 0) {
+                    break;
+                }
+                Double qty = invLotLocId.getQty();
+                Double qtyallocated = invLotLocId.getQtyallocated();
+                // 修改InvLotLocId
+                InvLotLocId lotLocIdUpdate = new InvLotLocId();
+                lotLocIdUpdate.setLocationId(invLotLocId.getLocationId().toString());
+                lotLocIdUpdate.setLotnum(invLotLocId.getLotnum());
+                lotLocIdUpdate.setCustomerId(invLotLocId.getCustomerId());
+                lotLocIdUpdate.setSku(invLotLocId.getSku());
+                if (qtyallocated.compareTo(qtyOrdered) == 0) {
+                    lotLocIdUpdate.setQtyallocated(BigDecimal.ZERO);
+                    // 修改lotatt14为空
+                    invLotAttService.updateInvLotAttLotatt14IsNull(invLotLocId.getLotnum());
+                    qtyOrdered = BigDecimal.ZERO.doubleValue();
+                } else if (qtyallocated.compareTo(qtyOrdered) == 1) {
+                    lotLocIdUpdate.setQtyallocated(new BigDecimal(qtyallocated).subtract(new BigDecimal(qtyOrdered)));
+                    qtyOrdered = BigDecimal.ZERO.doubleValue();
+
+                }else {
+                    lotLocIdUpdate.setQtyallocated(BigDecimal.ZERO);
+                    // 修改lotatt14为空
+                    invLotAttService.updateInvLotAttLotatt14IsNull(invLotLocId.getLotnum());
+                    qtyOrdered = new BigDecimal(qtyOrdered).subtract(new BigDecimal(qtyallocated)).doubleValue();
+
+                }
+                invLotLocIdService.updateInvLotLocId(lotLocIdUpdate);
+            }
+
+        }
         return AjaxResult.success();
     }
 
@@ -266,8 +438,9 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
      * @param value
      * @return
      */
-    private AjaxResult detailsAddModifyInventory(List<WmsDocOrderDetails> value) {
-        return AjaxResult.success();
+    @Transactional
+    public AjaxResult detailsAddModifyInventory(List<WmsDocOrderDetails> value) {
+        return AjaxResult.success("增加数量不需要释放备货库存!");
     }
 
     /**
@@ -276,8 +449,9 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
      * @param value
      * @return
      */
-    private AjaxResult detailsDecreaseModifyInventory(List<WmsDocOrderDetails> value) {
-        return AjaxResult.success();
+    @Transactional
+    public AjaxResult detailsDecreaseModifyInventory(List<WmsDocOrderDetails> value) {
+        return detailsDeleteModifyInventory(value);
     }
 
 
@@ -316,9 +490,15 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
         List<WmsDocOrderDetails> detailsAdd = detailsWms.stream().filter(a -> {
             String orderNo = a.getOrderNo();
             String edi07 = a.getdEdi07();
+            String sku = a.getSku();
             BigDecimal qtyWms = a.getQtyOrdered();
             for (WmsDocOrderDetails details : detailsErp) {
                 if (details.getOrderNo().equals(orderNo) && details.getdEdi07().equals(edi07)) {
+                    // 更新备货同样的项号,同样的项次号,品号不可不同
+                    if (!details.getSku().equals(sku)) {
+                        log.error("更新备货同样的项号,同样的项次号,品号不可不同:" + JSON.toJSONString(details));
+                        continue;
+                    }
                     BigDecimal qtyErp = details.getQtyOrdered();
                     if (qtyWms.compareTo(qtyErp) == -1) {
                         // 需要增加的数量
@@ -334,9 +514,15 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
         List<WmsDocOrderDetails> detailsDecrease = detailsWms.stream().filter(a -> {
             String orderNo = a.getOrderNo();
             String edi07 = a.getdEdi07();
+            String sku = a.getSku();
             BigDecimal qtyWms = a.getQtyOrdered();
             for (WmsDocOrderDetails details : detailsErp) {
                 if (details.getOrderNo().equals(orderNo) && details.getdEdi07().equals(edi07)) {
+                    // 更新备货同样的项号,同样的项次号,品号不可不同
+                    if (!details.getSku().equals(sku)) {
+                        log.error("更新备货同样的项号,同样的项次号,品号不可不同:" + JSON.toJSONString(details));
+                        continue;
+                    }
                     BigDecimal qtyErp = details.getQtyOrdered();
                     if (qtyWms.compareTo(qtyErp) == 1) {
                         BigDecimal qtyDec = qtyWms.subtract(qtyErp);
@@ -398,4 +584,21 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
         }
         return detailsArrayList;
     }
+
+    /**
+     * 记录变更数据到单头
+     *
+     * @param orderNo
+     */
+    public void recordChangeData(String orderNo, String data) {
+        String record = "";
+        WmsDocOrderHeader wmsDocOrderHeader = wmsDocOrderHeaderService.selectDocOrderHeaderByOrderNo(orderNo);
+        if (wmsDocOrderHeader.gethEdi08() != null) {
+            record = wmsDocOrderHeader.gethEdi08();
+        }
+        WmsDocOrderHeader headerUpdate = new WmsDocOrderHeader();
+        headerUpdate.setOrderNo(orderNo);
+        headerUpdate.sethEdi08(record + "--" + data);
+        wmsDocOrderHeaderService.updateWmsDocOrderHeader(headerUpdate);
+    }
 }

+ 42 - 1
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -123,6 +123,17 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         return wmsDocOrderHeaderMapper.selectWmsDocOrderHeaderByOrderNo(orderNo);
     }
 
+    /**
+     * 查询出库单头
+     *
+     * @param orderNo
+     * @return 出库单头
+     */
+    @Override
+    public WmsDocOrderHeader selectDocOrderHeaderByOrderNo(String orderNo) {
+        return wmsDocOrderHeaderMapper.selectDocOrderHeaderByOrderNo(orderNo);
+    }
+
     /**
      * 查询出库单头
      *
@@ -403,6 +414,12 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                 , Constant.CUSTOMER_ID, lotattDTO);
         // 筛选出没有被分配过的库存
         List<InvLotLocIdForm> invList = invListAll.stream().filter(v -> {
+            // 判断库位是否存在备货库存
+            boolean b = whetherStockStockExists(v.getLocationId());
+            if (b) {
+                return false;
+            }
+            // 库存是否已经分配或者备货
             if (StringUtils.isEmpty(v.getLotatt15()) || orderNo.equals(v.getLotatt15())) {
                 if (StringUtils.isEmpty(v.getLotatt14())) {
                     return true;
@@ -501,6 +518,21 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         return AjaxResult.success("库存数不足,部分分配", originalOrderQty.subtract(orderQty));
     }
 
+    /**
+     * 判断库位是否存在备货库存
+     *
+     * @param locationId
+     */
+    private boolean whetherStockStockExists(String locationId) {
+        List<InvLotLocIdLotattVO> invLotLocIdLotattVOList = invLotLocIdService.selectInvLocIdLotattByLocationId(Long.valueOf(locationId));
+        for (InvLotLocIdLotattVO invLotLocIdLotattVO : invLotLocIdLotattVOList) {
+            if (StringUtils.isNotEmpty(invLotLocIdLotattVO.getLotatt14())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * 每次分配只能进入一条线程
      *
@@ -523,6 +555,12 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                 , Constant.CUSTOMER_ID, lotattDTO);
         // 筛选出没有被分配过的库存
         List<InvLotLocIdForm> invList = invListAll.stream().filter(v -> {
+            // 判断库位是否存在备货库存
+            boolean b = whetherStockStockExists(v.getLocationId());
+            if (b) {
+                return false;
+            }
+            // 库存是否已经分配或者备货
             if (StringUtils.isEmpty(v.getLotatt15()) || orderNo.equals(v.getLotatt15())) {
                 if (StringUtils.isEmpty(v.getLotatt14())) {
                     return true;
@@ -1119,11 +1157,14 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
      * @return
      */
     private int judgmentOfGroupPlateType(InvLotLocIdLotattVO locIdLotattVO) {
-        // 为空说明是备货出库,但是已经更新备货了
+        // 为空说明是备货出库,但是被更新备货流程改变了分配数
         if (StringUtils.isEmpty(locIdLotattVO.getLotatt15())
                 &&StringUtils.isNotEmpty(locIdLotattVO.getLotatt14())) {
             return 3;
         }
+        if (StringUtils.isEmpty(locIdLotattVO.getLotatt15())) {
+            return 0;
+        }
         String lotatt15 = locIdLotattVO.getLotatt15();
         WmsDocOrderHeader wmsDocOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(lotatt15);
         if (wmsDocOrderHeader.getOrderType().equals(Constant.ORDER_TYP.BH.getValue())

+ 12 - 6
warewms-ams/src/main/resources/mapper/ams/InvLotAttMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.ams.inv.mapper.InvLotAttMapper">
-    
+
     <resultMap type="InvLotAtt" id="InvLotAttResult">
         <result property="lotnum"    column="lotnum"    />
         <result property="customerId"    column="customer_id"    />
@@ -39,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectInvLotAttList" parameterType="InvLotAtt" resultMap="InvLotAttResult">
         <include refid="selectInvLotAttVo"/>
-        <where>  
+        <where>
             <if test="customerId != null  and customerId != ''"> and customer_id = #{customerId}</if>
             <if test="sku != null  and sku != ''"> and sku = #{sku}</if>
             <if test="lotatt01 != null  and lotatt01 != ''"> and lotatt01 = #{lotatt01}</if>
@@ -62,12 +62,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="lotatt18 != null  and lotatt18 != ''"> and lotatt18 = #{lotatt18}</if>
         </where>
     </select>
-    
+
     <select id="selectInvLotAttByLotnum" parameterType="String" resultMap="InvLotAttResult">
         <include refid="selectInvLotAttVo"/>
         where lotnum = #{lotnum}
     </select>
-        
+
     <insert id="insertInvLotAtt" parameterType="InvLotAtt">
         insert into inv_lot_att
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -160,12 +160,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where lotnum = #{lotnum}
     </update>
 
+    <update id="updateInvLotAttLotatt14IsNull" parameterType="InvLotAtt">
+        update inv_lot_att
+        set lotatt14 = ''
+        where lotnum = #{lotnum}
+    </update>
+
     <delete id="deleteInvLotAttByLotnum" parameterType="String">
         delete from inv_lot_att where lotnum = #{lotnum}
     </delete>
 
     <delete id="deleteInvLotAttByLotnums" parameterType="String">
-        delete from inv_lot_att where lotnum in 
+        delete from inv_lot_att where lotnum in
         <foreach item="lotnum" collection="array" open="(" separator="," close=")">
             #{lotnum}
         </foreach>
@@ -176,4 +182,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         left join inv_lot_att t_att on t_asn_d.asn_no = t_att.lotatt08 and t_asn_d.sku = t_att.sku
         where t_asn_d.asn_no = #{asnNo} and t_att.lotatt02 is not null and t_att.lotatt02 <![CDATA[ <> ]]> ''
     </select>
-</mapper>
+</mapper>

+ 27 - 0
warewms-ams/src/main/resources/mapper/docOrder/WmsDocOrderDetailsMapper.xml

@@ -368,6 +368,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where order_no = #{orderNo} and order_line_no = #{orderLoneNo}
     </update>
 
+    <update id="updateOrderDetailsAddQtyAndSts">
+        update wms_doc_order_details
+        set qty_ordered = qty_ordered + #{qty}
+          ,qty_ordered_each = qty_ordered_each + #{qty}
+          ,line_status = #{status}
+        where order_no = #{orderNo} and order_line_no = #{orderLoneNo}
+    </update>
+
+    <update id="updateOrderDetailsSubQtyAndSts">
+        update wms_doc_order_details
+        set qty_ordered = qty_ordered - #{qty}
+          ,qty_ordered_each = qty_ordered_each - #{qty}
+          ,line_status = #{status}
+        where order_no = #{orderNo} and order_line_no = #{orderLoneNo}
+    </update>
+
+    <update id="updateOrderDetailsSubStockQtyAndSts">
+        update wms_doc_order_details
+        set
+           qty_allocated = qty_allocated - #{qtyAll}
+          ,qty_allocated_each = qty_allocated_each - #{qtyAll}
+          ,qty_soft_allocated = qty_soft_allocated - #{qtySoft}
+          ,qty_softallocated_each = qty_softallocated_each - #{qtySoft}
+          ,line_status = #{status}
+        where order_no = #{orderNo} and order_line_no = #{orderLoneNo}
+    </update>
+
     <select id="selectStockOrder" resultMap="StockOrderVOResult">
         select
             h.order_no,de.order_line_no,ad.allocation_id,de.sku,de.d_edi_02,ifnull(ad.pick_qty,0) pick_qty

+ 6 - 0
warewms-ams/src/main/resources/mapper/docOrder/WmsDocOrderHeaderMapper.xml

@@ -197,6 +197,12 @@
         where a.order_no = #{orderNo}
     </select>
 
+    <select id="selectDocOrderHeaderByOrderNo" parameterType="String" resultMap="WmsDocOrderHeaderResult">
+        select *
+        from wms_doc_order_header
+        where order_no = #{orderNo}
+    </select>
+
     <select id="selectWmsDocOrderHeaderByErpNo" parameterType="String" resultMap="WmsDocOrderHeaderResult">
         select *
         from wms_doc_order_header