From 50b1b07bfa382c3f19c6b23f1cff4dfa50294f07 Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期四, 30 十一月 2023 10:58:38 +0800
Subject: [PATCH] feat: 库存管理 增加加载状态

---
 consum-base/src/main/java/com/consum/base/service/LWhFormInventoryServiceImpl.java |   53 ++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/service/LWhFormInventoryServiceImpl.java b/consum-base/src/main/java/com/consum/base/service/LWhFormInventoryServiceImpl.java
index 45982fd..79c9669 100644
--- a/consum-base/src/main/java/com/consum/base/service/LWhFormInventoryServiceImpl.java
+++ b/consum-base/src/main/java/com/consum/base/service/LWhFormInventoryServiceImpl.java
@@ -16,6 +16,7 @@
 import com.consum.model.po.FinSysTenant;
 import com.consum.model.po.FinSysTenantUser;
 import com.consum.model.po.LWhFormInventory;
+import com.iplatform.model.po.S_user_core;
 import com.walker.db.page.GenericPager;
 import com.walker.infrastructure.utils.DateUtils;
 import com.walker.infrastructure.utils.StringUtils;
@@ -27,7 +28,9 @@
 import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 /**
@@ -44,15 +47,14 @@
     @Autowired
     private BaseWarehouseServiceImpl baseWarehouseService;
     @Autowired
-    private FinSysTenantUserServiceImpl finSysTenantUserService;
-    @Autowired
     private LWhFormInventoryGoodsServiceImpl inventoryGoodsService;
-    @Autowired
-    private BaseGoodsTemplateServiceImpl baseGoodsTemplateService;
     @Autowired
     private LWhGoodsService lWhGoodsService;
     @Autowired
     private FinSysTenantServiceImpl finSysTenantService;
+    @Autowired
+    @Lazy
+    private LWhFormInventoryCoreService lWhFormInventoryCoreService;
 
 
     private static final String QUERY_LIST = "select * from l_wh_form_inventory where 1=1 ";
@@ -155,7 +157,7 @@
     }
 
 
-    public void saveInventory(FormInventoryVO dto, Long id) {
+    public List<FormInventoryGoodsVO> saveInventory(FormInventoryVO dto, Long id) {
         //1.鏍规嵁鐩樼偣鍗昳d鏌ヨ鐩樼偣鍗�
         LWhFormInventory lWhFormInventory = this.get(new LWhFormInventory(id));
         if (lWhFormInventory == null) {
@@ -173,12 +175,11 @@
         if (CollectionUtils.isEmpty(formInventoryGoodsList)) {
             log.error("鐩樼偣鍗曠墿鍝佷负绌�");
         }
-        int num = inventoryGoodsService.add(formInventoryGoodsList, id);
-        if (num != formInventoryGoodsList.size()) {
-            log.error("鏇存柊鐩樼偣鍗曠墿鍝佸け璐�");
-        }
+        List<FormInventoryGoodsVO> result = inventoryGoodsService.add(formInventoryGoodsList, id);
 
+        return result;
     }
+
 
     /**
      * 淇濆瓨鐩樼偣淇℃伅
@@ -186,14 +187,33 @@
      * @author 鍗㈠簡闃�
      * @date 2023/10/31
      */
-    public int updateInventoryInfo(LWhFormInventoryParam dto, Integer state) {
+    @Transactional(rollbackFor = Exception.class)
+    public int updateInventoryInfo(LWhFormInventoryParam dto, Integer state, S_user_core currentUser, FinSysTenantUser sysInfo) {
         //1.鏍规嵁鐩樼偣鍗昳d鏌ヨ鐩樼偣鍗�
         LWhFormInventory lWhFormInventory = this.get(new LWhFormInventory(dto.getId()));
         if (lWhFormInventory == null) {
             log.error("鏍规嵁鐩樼偣鍗昳d鏌ヨ鐩樼偣鍗曞け璐�");
             return 0;
         }
-        //2.淇敼鐩樼偣鍗�
+        //娣诲姞鐩樼偣鍗曠墿鍝�
+        List<FormInventoryGoodsVO> inventoryGoodsList = dto.getInventoryGoodsList();
+        if (CollectionUtils.isEmpty(inventoryGoodsList)) {
+            log.error("鐩樼偣鍗曠墿鍝佷负绌�");
+            return 0;
+        }
+        this.inventoryGoodsService.updateInventoryGoods(inventoryGoodsList);
+        //淇敼鐩樼偣鍗�
+        if (state == 2) {
+            //瀹屾垚鐩樼偣鏃惰缃畬鎴愮洏鐐规椂闂�
+            lWhFormInventory.setStopTime(DateUtils.getDateTimeNumber(System.currentTimeMillis()));
+
+            //瀹屾垚鐩樼偣鏃惰缃畬鎴愮洏鐐规椂闂�
+            String inOutFormByInventoryId = lWhFormInventoryCoreService.createInOutFormByInventoryId(dto.getId(), currentUser, sysInfo);
+            if (!StringUtils.isEmpty(inOutFormByInventoryId)) {
+                log.error(inOutFormByInventoryId);
+                return 0;
+            }
+        }
         lWhFormInventory.setStates(state);
         lWhFormInventory.setInventoryDate(DateUtils.getDateTimeNumber(System.currentTimeMillis()));
         int flag1 = this.update(lWhFormInventory);
@@ -201,13 +221,7 @@
             log.error("淇敼鐩樼偣鍗曞け璐�");
             return 0;
         }
-        //3.娣诲姞鐩樼偣鍗曠墿鍝�
-        List<FormInventoryGoodsVO> inventoryGoodsList = dto.getInventoryGoodsList();
-        if (CollectionUtils.isEmpty(inventoryGoodsList)) {
-            log.error("鐩樼偣鍗曠墿鍝佷负绌�");
-            return 0;
-        }
-        this.inventoryGoodsService.updateInventoryGoods(inventoryGoodsList);
+
         return 1;
     }
 
@@ -326,6 +340,7 @@
                 formInventoryDetailVO.getInventoryResult() == null ? null : (formInventoryDetailVO.getInventoryResult() == 2 ? "鐩樼泩" : "鐩樹簭"));
             formInventoryDetailVO.setInventoryType(
                 formInventoryDetailVO.getInventoryResult() == null ? null : (formInventoryDetailVO.getInventoryResult() == 2 ? "鐩樼泩鍏ュ簱" : "鐩樹簭鍑哄簱"));
+            formInventoryDetailVO.setWarehouseFormCode(formInventoryDetailVO.getWarehouseFormCode());
             result.add(formInventoryDetailVO);
         });
         pageUtil.setDatas(result);
@@ -366,7 +381,7 @@
         formInventoryVO.setWarehouseName(inventory.getWarehouseName());
 
         String sql =
-            "select bgm.id,bgt.id baseGoodsTemplateId,bgt.GOODS_NAME goodsTemplateName,bgm.MODEL_NAME baseGoodsModelsName,bgt.CLASSIFICATION type,bgm.UNIT "
+            "select bgt.id baseGoodsTemplateId,bgt.GOODS_NAME goodsTemplateName,bgm.MODEL_NAME baseGoodsModelsName,bgt.CLASSIFICATION type,bgm.UNIT "
                 + "from base_goods_models bgm left join base_goods_template bgt on bgm.GOODS_TEMPLATES_ID = bgt.id "
                 + "where bgt.AGENCY_ID = :agencyId";
         HashMap<String, Object> param = new HashMap<>();

--
Gitblit v1.9.1