zh 3 сар өмнө
parent
commit
181a6d4211

+ 57 - 49
src/views/robot/merge/index.vue

@@ -58,7 +58,7 @@
         <div class="cell label label-small">属性仓</div>
         <div class="cell value value-large">{{ productInfo.warehouseType }}</div>
         <div class="cell label label-small">批号</div>
-        <div class="cell value value-small"></div>
+        <div class="cell value value-small">{{ productInfo.lotNumber }}</div>
       </div>
       <div class="table-row">
         <div class="cell label">生产日期</div>
@@ -408,11 +408,11 @@ const onBarcodeEnter = async () => {
       productInfo.barcode = inventoryData.barcode || inventoryData.barcode2
       productInfo.qualityStatus = inventoryData.lotAtt08
       productInfo.warehouseType = inventoryData.lotAtt05
-      productInfo.batchNo = inventoryData.lotNumber
+      productInfo.lotNumber = inventoryData.lotAtt04 || ''
       productInfo.productionDate = inventoryData.lotAtt01
       productInfo.expiryDate = inventoryData.lotAtt02
       // 可移库数量
-      const availableQty = inventoryData.quantityAvailable || 0
+      const availableQty = inventoryData.quantityAvailable + inventoryData.quantityVirtual
       productInfo.moveQty = availableQty
       // 计算推荐移库数量:取可移库数量和任务推荐数量的最小值
       const taskRecommendQty = getTaskRecommendQty(sourceLocation.value)
@@ -472,7 +472,7 @@ const resetProductInfo = () => {
   productInfo.barcode = ''
   productInfo.qualityStatus = ''
   productInfo.warehouseType = ''
-  productInfo.batchNo = ''
+  productInfo.lotNumber = ''
   productInfo.productionDate = ''
   productInfo.expiryDate = ''
   productInfo.moveQty = ''
@@ -549,54 +549,61 @@ const mergeDataList = ref<BoxRelatedMergeDetailsVO[]>([])
 const buildClickableLocationsMap = (boxDetailsList: BoxRelatedMergeDetailsVO[]) => {
   const map = new Map<string, ClickableLocationInfo>()
 
+  // 先对所有移库任务去重,避免同一条任务被处理多次导致数量翻倍
+  const uniqueTaskMap = new Map<string, LocationMergeDetails>()
   boxDetailsList.forEach(boxDetail => {
     boxDetail.mergeDetails?.forEach((detail: LocationMergeDetails) => {
-      const sourceLocation = detail.sourceLocation
-      const targetLocation = detail.targetLocation
-      const moveQty = detail.moveQty || 0
-
-      // 处理源库位(推荐清空库位)
-      if (sourceLocation) {
-        if (!map.has(sourceLocation)) {
-          map.set(sourceLocation, {
-            recommendType: 'clear',
-            relatedLocations: [],
-            sku: detail.sku || ''
-          })
-        }
-        const sourceInfo = map.get(sourceLocation)!
-        // 添加对应的保留库位
-        if (targetLocation) {
-          const existingIdx = sourceInfo.relatedLocations.findIndex(r => r.location === targetLocation)
-          if (existingIdx === -1) {
-            sourceInfo.relatedLocations.push({ location: targetLocation, quantity: moveQty })
-          } else {
-            sourceInfo.relatedLocations[existingIdx].quantity += moveQty
-          }
-        }
+      // 使用 sourceLocation + targetLocation + sku 作为唯一键
+      const key = `${detail.sourceLocation || ''}_${detail.targetLocation || ''}_${detail.sku || ''}_${detail.lotNum || ''}`
+      if (!uniqueTaskMap.has(key)) {
+        uniqueTaskMap.set(key, detail)
       }
+    })
+  })
 
-      // 处理目标库位(推荐保留库位)
+  // 遍历去重后的任务
+  uniqueTaskMap.forEach((detail) => {
+    const sourceLocation = detail.sourceLocation
+    const targetLocation = detail.targetLocation
+    const moveQty = detail.moveQty || 0
+
+    // 处理源库位(推荐清空库位)
+    if (sourceLocation) {
+      if (!map.has(sourceLocation)) {
+        map.set(sourceLocation, {
+          recommendType: 'clear',
+          relatedLocations: [],
+          sku: detail.sku || ''
+        })
+      }
+      const sourceInfo = map.get(sourceLocation)!
+      // 添加对应的保留库位
       if (targetLocation) {
-        if (!map.has(targetLocation)) {
-          map.set(targetLocation, {
-            recommendType: 'keep',
-            relatedLocations: [],
-            sku: detail.sku || ''
-          })
+        const existingIdx = sourceInfo.relatedLocations.findIndex(r => r.location === targetLocation)
+        if (existingIdx === -1) {
+          sourceInfo.relatedLocations.push({ location: targetLocation, quantity: moveQty })
         }
-        const targetInfo = map.get(targetLocation)!
-        // 添加对应的清空库位
-        if (sourceLocation) {
-          const existingIdx = targetInfo.relatedLocations.findIndex(r => r.location === sourceLocation)
-          if (existingIdx === -1) {
-            targetInfo.relatedLocations.push({ location: sourceLocation, quantity: moveQty })
-          } else {
-            targetInfo.relatedLocations[existingIdx].quantity += moveQty
-          }
+      }
+    }
+
+    // 处理目标库位(推荐保留库位)
+    if (targetLocation) {
+      if (!map.has(targetLocation)) {
+        map.set(targetLocation, {
+          recommendType: 'keep',
+          relatedLocations: [],
+          sku: detail.sku || ''
+        })
+      }
+      const targetInfo = map.get(targetLocation)!
+      // 添加对应的清空库位
+      if (sourceLocation) {
+        const existingIdx = targetInfo.relatedLocations.findIndex(r => r.location === sourceLocation)
+        if (existingIdx === -1) {
+          targetInfo.relatedLocations.push({ location: sourceLocation, quantity: moveQty })
         }
       }
-    })
+    }
   })
 
   clickableLocationsMap.value = map
@@ -610,7 +617,7 @@ const productInfo = reactive({
   barcode: '',
   qualityStatus: '',
   warehouseType: '',
-  batchNo: '',
+  lotNumber: '', // 批号,取lotAtt04
   productionDate: '',
   expiryDate: '',
   moveQty: '', // 可移库数量(库存可用数量)
@@ -1028,11 +1035,11 @@ const queryInventoryBySku = async (sku: string, location: string) => {
       productInfo.barcode = inventoryData.barcode || inventoryData.barcode2
       productInfo.qualityStatus = inventoryData.lotAtt08
       productInfo.warehouseType = inventoryData.lotAtt05
-      productInfo.batchNo = inventoryData.lotNumber
+      productInfo.lotNumber = inventoryData.lotAtt04 || ''
       productInfo.productionDate = inventoryData.lotAtt01
       productInfo.expiryDate = inventoryData.lotAtt02
       // 可移库数量
-      const availableQty = inventoryData.quantityAvailable || 0
+      const availableQty = inventoryData.quantityAvailable + inventoryData.quantityVirtual
       productInfo.moveQty = availableQty
       // 计算推荐移库数量:取可移库数量和任务推荐数量的最小值
       const taskRecommendQty = getTaskRecommendQty(location)
@@ -1136,13 +1143,14 @@ const submitMove = () => {
     message: `${productInfo.barcode}从"${sourceLocation.value}"移动至"${productInfo.targetLocationNew}"共:${productInfo.actualMoveQty}件`
   })
     .then(() => {
-      const { traceId, lotNum, lotNumber, ownerCode, owner, sku } = currentInventoryData.value || {}
+      const { traceId, lotNumber, ownerCode, owner, sku } = currentInventoryData.value || {}
+      console.log(currentInventoryData.value)
       const data = {
         fmLocation: sourceLocation.value,
         fmContainer: traceId || boxCode.value,
         owner: ownerCode || owner || '',
         sku: sku || productInfo.barcode,
-        lotNum: lotNum || lotNumber || productInfo.batchNo || '',
+        lotNum: lotNumber,
         warehouse,
         quantity: Number(productInfo.actualMoveQty),
         toLocation: productInfo.targetLocationNew