Browse Source

修改盘点数据后增加到盘点明细中

ljx 1 year ago
parent
commit
963df5632f

+ 12 - 5
ruoyi-admin/src/main/java/com/ruoyi/inventory/service/impl/TbAssetInventoryServiceImpl.java

@@ -97,23 +97,23 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
         if (intersection.size()<rfidList.size()){
             //盘亏
             if (!orderNumber.isEmpty()){
-                return takeStock(orderNumber, intersection, 2L);
+                return takeStock(orderNumber, epcList, 2L);
             }else {
-                return takeStock2(location, 2L);
+                return takeStock2(location, 2L, epcList, orderNumber);
             }
         }else if (list.size()>intersection.size()){
             //盘盈
             if (!orderNumber.isEmpty()){
                 return takeStock(orderNumber, epcList, 1L);
             }else {
-                return takeStock2(location, 1L);
+                return takeStock2(location, 1L, epcList, orderNumber);
             }
         }else if (intersection.size()==rfidList.size()){
             //正常
             if (!orderNumber.isEmpty()){
                 return takeStock(orderNumber, epcList, 3L);
             }else {
-                return takeStock2(location, 3L);
+                return takeStock2(location, 3L, epcList, orderNumber);
             }
         }else {
             return 0;
@@ -205,7 +205,7 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
         }
     }
 
-    private int takeStock2(String location, Long result){
+    private int takeStock2(String location, Long result, List<String> list, String orderNumber){
         TbAssetInventory inventory = new TbAssetInventory();
         inventory.setInventoryStatus(2L);
         inventory.setInventoryResult(result);
@@ -213,6 +213,13 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
         inventory.setInventoryLocation(location);
         inventory.setInventoryDate(new Date());
         inventory.setName("线下自测");
+        //插入盘点明细
+        TbInventoryDetail detail = new TbInventoryDetail();
+        for (String number : list) {
+            detail.setOrderNumber(orderNumber);
+            detail.setInventoryMetadata(JSONUtil.toJsonStr(informationMapper.selectTbAssetInformationByAssetNumber(number)));
+            tbInventoryDetailMapper.insertTbInventoryDetail(detail);
+        }
         return insertTbAssetInventory(inventory);
     }
 }