From f5ec605bdab7ade01d58f4c162d34d2a521d6ed2 Mon Sep 17 00:00:00 2001
From: 杨凯 <398860375@qq.com>
Date: 星期六, 21 十月 2023 11:15:14 +0800
Subject: [PATCH] 新增mapper

---
 consum-base/src/main/java/com/consum/base/core/WarehouseBusinessService.java |  302 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 294 insertions(+), 8 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/core/WarehouseBusinessService.java b/consum-base/src/main/java/com/consum/base/core/WarehouseBusinessService.java
index 6d07897..669e63e 100644
--- a/consum-base/src/main/java/com/consum/base/core/WarehouseBusinessService.java
+++ b/consum-base/src/main/java/com/consum/base/core/WarehouseBusinessService.java
@@ -1,12 +1,14 @@
 package com.consum.base.core;
 
+import com.consum.base.core.param.BaseWarehouseParam;
+import com.consum.base.core.param.DepBackWarehouseParam;
 import com.consum.base.core.tools.SqlParameter;
 import com.consum.base.core.tools.SuperMap;
 import com.consum.base.core.util.DateUtil;
 import com.consum.model.po.*;
-import com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer;
 import com.walker.infrastructure.utils.NumberGenerator;
 import com.walker.jdbc.service.BaseServiceImpl;
+import org.bouncycastle.jcajce.provider.asymmetric.GOST;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -44,7 +46,7 @@
         List<WhFormProcureModel>  modelList = this.select(sql,new SqlParameter().put("PROCURE_ID",procure.getId()),new WhFormProcureModel());
 
         for (WhFormProcureModel model : modelList){
-            CheckWarehouseParam param = new CheckWarehouseParam();
+            BaseWarehouseParam param = new BaseWarehouseParam();
             param.setIsCheckIn(true);
             param.setWarehouseId(procure.getId());
             param.setCount(model.getCounts());
@@ -92,9 +94,10 @@
                 .put("OUTPUT_ID",output.getId()),new WhFormOutputGoods());
 
         for (WhFormOutputGoods goods : goodsList){
-            CheckWarehouseParam param = new CheckWarehouseParam();
+            BaseWarehouseParam param = new BaseWarehouseParam();
             param.setIsCheckIn(false);
             param.setWarehouseId(output.getWarehouseId());
+            param.setModelId(goods.getBaseGoodsModelsId());
             param.setCount(goods.getCounts());
 
             List<CheckWarehouseResult> results =  coreService.unifyCheck(param);
@@ -149,7 +152,7 @@
                 .put("TRANSFER_ID",transfer.getId()),new WhFormTransferGoods());
 
         for (WhFormTransferGoods goods : goodsList){
-            CheckWarehouseParam param = new CheckWarehouseParam();
+            BaseWarehouseParam param = new BaseWarehouseParam();
             param.setIsCheckIn(false);
             param.setWarehouseId(transfer.getOutWarehouseId());
             param.setCount(goods.getCounts());
@@ -205,7 +208,7 @@
                                     .put("TRANSFER_ID",transfer.getId()),new WhFormTransferModel());
 
         for (WhFormTransferModel model : modelsList) {
-            CheckWarehouseParam param = new CheckWarehouseParam();
+            BaseWarehouseParam param = new BaseWarehouseParam();
             param.setIsCheckIn(true);
             param.setWarehouseId(transfer.getInWarehouseId());
             param.setCount(model.getCounts());
@@ -250,7 +253,7 @@
                 .put("SCRAPPED_ID",scrapped.getId()),new WhFormScrappedGoods());
 
         for (WhFormScrappedGoods goods : goodsList){
-            CheckWarehouseParam param = new CheckWarehouseParam();
+            BaseWarehouseParam param = new BaseWarehouseParam();
             param.setIsCheckIn(false);
             param.setWarehouseId(scrapped.getWarehouseId());
             param.setCount(goods.getCounts());
@@ -363,7 +366,7 @@
                 .put("INVENTORY_ID",inventory.getId()),new WhFormInventoryGoods());
 
         for (WhFormInventoryGoods goods : goodsList){
-            CheckWarehouseParam param = new CheckWarehouseParam();
+            BaseWarehouseParam param = new BaseWarehouseParam();
             param.setIsCheckIn(false);
             param.setWarehouseId(inventory.getWarehouseId());
             param.setCount(goods.getErrorCounts());
@@ -421,7 +424,7 @@
                 .put("INVENTORY_ID",inventory.getId()),new WhFormInventoryGoods());
 
         for (WhFormInventoryGoods goods : goodsList){
-            CheckWarehouseParam param = new CheckWarehouseParam();
+            BaseWarehouseParam param = new BaseWarehouseParam();
             param.setIsCheckIn(true);
             param.setWarehouseId(inventory.getWarehouseId());
             param.setCount(goods.getErrorCounts());
@@ -565,4 +568,287 @@
 
         insertBatch(warningList);
     }
+
+    public void doDepBack(String depFormBackId){
+
+        DepFormBack back = get(new DepFormBack(),"ID=?",new Object[]{depFormBackId});
+
+        String sql = "SELECT\n" +
+                "	B.*,\n" +
+                "	A.BACK_COUNTS, \n" +
+                "	A.ID AS DEP_FORM_BACK_GOODS_ID \n" +
+                "FROM\n" +
+                "	DEP_FORM_BACK_GOODS A\n" +
+                "	LEFT JOIN DEP_FORM_LENDING_GOODS B ON A.DEP_FORM_LENDING_GOODS_ID = B.ID \n" +
+                "WHERE\n" +
+                "	A.DEP_FORM_BACK_ID = :DEP_FORM_BACK_ID \n" +
+                "	AND A.WAREHOUSE_ID = B.WAREHOUSE_ID \n" +
+                "	AND A.WAREHOUSE_ID = :WAREHOUSE_ID";
+
+        List<Map> list = select(sql,new SqlParameter("DEP_FORM_BACK_ID",back.getId()).add("WAREHOUSE_ID",back.getWarehouseId()));
+
+        for (Map myMap : list) {
+            SuperMap map = new SuperMap(myMap);
+
+            CheckUsingParam param = new CheckUsingParam();
+            param.setIsCheckIn(false);
+            param.setLending_id(map.getLong("DEP_FORM_LENDING_ID"));
+            param.setModel_id(map.getLong("BASE_GOODS_MODELS_ID"));
+            param.setUser_name(map.getString("GOODS_USER_NAME"));
+
+            List<CheckUsingResult> resultList = coreService.unifyUsingCheck(param);
+            for (CheckUsingResult result : resultList) {
+                BaseWarehouseParam param1 = new DepBackWarehouseParam();
+                param1.setIsCheckIn(true);
+                param1.setWarehouseId(result.getLendingModel().getWarehouseId());
+                param1.setModelId(result.getLendingModel().getBaseGoodsModelsId());
+                param1.setCount(result.getEnd_count() - result.getInitial_count());
+                param1.setFirst_input_type(4);
+
+                //鍏ュ簱骞跺瓨鍏ユ祦姘�
+                CheckWarehouseResult result1  = coreService.unifyCheck(param1).get(0);
+                WhGoodsDetails details = new WhGoodsDetails();
+                details.setId(result1.getWhGoods().getFirstInputHisId());
+                details.setBusinessFormId(back.getId());
+                details.setBusinessFormCode(back.getBusinessFormCode());
+                details.setBusinessFormName(back.getWarehouseName() + "杩斿簱鍏ュ簱鍗�:" + details.getBusinessFormCode());
+                details.setInitialCount(result.getInitial_count());
+                details.setThisType(1);
+                details.setEndCount(result.getEnd_count());
+                details.setWarehouseId(back.getWarehouseId());
+                details.setWarehouseName(back.getWarehouseName());
+                details.setClassification(1);
+                details.setOperatorId(back.getOperatorId());
+                details.setOperatorName(back.getOperatorName());
+                details.setDealTime(back.getDealTime());
+                details.setWhGoodsId(result1.getWhGoods().getId());
+
+                this.insert(details);
+
+
+                //瀛樺叆鍦ㄧ敤娴佹按
+                UsingGoodsHis his  = new UsingGoodsHis();
+                his.setId(NumberGenerator.getLongSequenceNumber());
+                his.setBusinessFormId(back.getId());
+                his.setBusinessFormCode(back.getBusinessFormCode());
+                his.setBusinessFormName("杩斿簱鍗曪細" + back.getBusinessFormCode());
+                his.setClassification(3);
+                his.setOperatorId(back.getOperatorId());
+                his.setOperatorName(back.getOperatorName());
+                his.setDealTime(back.getDealTime());
+                his.setDepFormLendingModelId(result.getLendingModel().getId());
+                his.setDepFormLendingGoodsId(result.getLendingModel().getDepFormLendingGoodsId());
+                his.setDepFormLendingId(result.getLendingModel().getDepFormLendingId());
+                his.setWhGoodsId(result.getLendingModel().getWhGoodsId());
+                his.setInitialCount(result.getInitial_count());
+                his.setEndCount(result.getEnd_count());
+                his.setWarehouseId(back.getWarehouseId());
+                his.setWarehouseName(back.getWarehouseName());
+                his.setDepartmentId(back.getDepartmentId());
+                his.setDepartmentName(back.getDepartmentName());
+                insert(his);
+
+                DepFormBackModel model = new DepFormBackModel();
+                model.setId(NumberGenerator.getLongSequenceNumber());
+                model.setDepFormBackGoodsId(map.getLong("DEP_FORM_BACK_GOODS_ID"));
+                model.setDepFormBackId(back.getId());
+                model.setWhGoodsDetailsId(result1.getWh_goods_detail_id());
+                model.setUsingGoodsHisId(his.getId());
+                model.setWhGoodsId(his.getWhGoodsId());
+                model.setCounts(his.getThisCount());
+                model.setDepFormLendingModelId(his.getDepFormLendingModelId());
+                model.setDepFormLendingGoodsId(his.getDepFormLendingGoodsId());
+                model.setDepFormLendingId(his.getDepFormLendingId());
+                model.setWhGoodsId(his.getWhGoodsId());
+                insert(model);
+            }
+
+        }
+
+
+    }
+
+
+    /**
+     * 閮ㄩ棬鐗╁搧鍒嗗彂
+     */
+    public void doDepLending(DepFormLending lending){
+        String sql = "SELECT\n" +
+                "	* \n" +
+                "FROM\n" +
+                "	DEP_FORM_LENDING_GOODS A \n" +
+                "WHERE\n" +
+                "	A.DEP_FORM_LENDING_ID = :LENDING_ID";
+
+        List<DepFormLendingGoods>  goodsList = this.select(sql,new SqlParameter()
+                .put("LENDING_ID",lending.getId()),new DepFormLendingGoods());
+
+        for (DepFormLendingGoods goods : goodsList){
+            BaseWarehouseParam param = new BaseWarehouseParam();
+            param.setIsCheckIn(false);
+            param.setWarehouseId(lending.getWarehouseId());
+            param.setModelId(goods.getBaseGoodsModelsId());
+            param.setCount(goods.getCounts());
+
+            //棣栧厛浠庢満鏋勪粨搴撳嚭搴�
+            List<CheckWarehouseResult> results =  coreService.unifyCheck(param);
+            for (CheckWarehouseResult result : results){
+                WhGoodsDetails details = new WhGoodsDetails();
+                details.setId(NumberGenerator.getLongSequenceNumber());
+                details.setBusinessFormId(lending.getId());
+                details.setBusinessFormCode(lending.getBusinessFormCode());
+                details.setBusinessFormName("鍒嗗彂鍗曪細" + lending.getBusinessFormCode());
+                details.setInitialCount(result.getInitial_count());
+                details.setThisType(2);
+                details.setThisCount(result.getInitial_count() - result.getEnd_count());
+                details.setEndCount(result.getEnd_count());
+                details.setWarehouseId(result.getWhGoods().getWarehouseId());
+                details.setWarehouseName(result.getWhGoods().getWarehouseName());
+                details.setClassification(11);
+                details.setOperatorId(lending.getOperatorId());
+                details.setOperatorName(lending.getOperatorName());
+                details.setDealTime(lending.getDealTime());
+                details.setWhGoodsId(result.getWhGoods().getId());
+                this.insert(details);
+
+                //鍥炲~鍑哄簱娴佹按ID锛岀敤浜庡垎鍙戞椂浣跨敤
+                result.setWh_goods_detail_id(details.getId());
+            }
+
+            CheckUsingParam usingParam = new CheckUsingParam();
+            usingParam.setIsCheckIn(true);
+            usingParam.setInput_type(1);
+            usingParam.setOutputList(results);
+
+            List<CheckUsingResult> usingResults = coreService.unifyUsingCheck(usingParam);
+            for (CheckUsingResult usingResult : usingResults) {
+                UsingGoodsHis his  = new UsingGoodsHis();
+                his.setId(NumberGenerator.getLongSequenceNumber());
+                his.setBusinessFormId(lending.getId());
+                his.setBusinessFormCode(lending.getBusinessFormCode());
+                his.setBusinessFormName("鍒嗗彂鍗曪細" + lending.getBusinessFormCode());
+                his.setClassification(1);
+                his.setOperatorId(lending.getOperatorId());
+                his.setOperatorName(lending.getOperatorName());
+                his.setDealTime(lending.getDealTime());
+                his.setDepFormLendingModelId(usingResult.getLendingModel().getId());
+                his.setDepFormLendingGoodsId(usingResult.getLendingModel().getDepFormLendingGoodsId());
+                his.setDepFormLendingId(lending.getId());
+                his.setWhGoodsId(usingResult.getLendingModel().getWhGoodsId());
+                his.setInitialCount(usingResult.getInitial_count());
+                his.setEndCount(usingResult.getEnd_count());
+                his.setWarehouseId(lending.getWarehouseId());
+                his.setWarehouseName(lending.getWarehouseName());
+                his.setDepartmentId(lending.getDepartmentId());
+                his.setDepartmentName(lending.getDepartmentName());
+                insert(his);
+            }
+        }
+    }
+
+    public void doDepScrapped(String dep_form_scrapped_id){
+
+        DepFormScrapped scrapped = get(new DepFormScrapped(),"ID=?",new Object[]{dep_form_scrapped_id});
+
+        String sql = "SELECT\n" +
+                "	B.*,\n" +
+                "	A.SCRAPPED_COUNTS, \n" +
+                "	A.ID AS DEP_FORM_SCRAPPED_GOODS_ID \n" +
+                "FROM\n" +
+                "	DEP_FORM_SCRAPPED_GOODS A\n" +
+                "	LEFT JOIN DEP_FORM_LENDING_GOODS B ON A.DEP_FORM_LENDING_GOODS_ID = B.ID \n" +
+                "WHERE\n" +
+                "	A.DEP_FORM_SCRAPPED_ID = :DEP_FORM_SCRAPPED_ID \n" +
+                "	AND A.WAREHOUSE_ID = B.WAREHOUSE_ID \n" +
+                "	AND A.WAREHOUSE_ID = :WAREHOUSE_ID";
+
+        List<Map> list = select(sql,new SqlParameter("DEP_FORM_SCRAPPED_ID",scrapped.getId()).add("WAREHOUSE_ID",scrapped.getWarehouseId()));
+        for (Map _map : list) {
+            SuperMap map = new SuperMap(_map);
+
+            CheckUsingParam param = new CheckUsingParam();
+            param.setIsCheckIn(false);
+            param.setOutputCount(map.getInteger("SCRAPPED_COUNTS"));
+            param.setLending_id(map.getLong("DEP_FORM_LENDING_ID"));
+            param.setModel_id(map.getLong("BASE_GOODS_MODELS_ID"));
+            param.setUser_name(map.getString("GOODS_USER_NAME"));
+
+            List<CheckUsingResult> resultList = coreService.unifyUsingCheck(param);
+
+            for (CheckUsingResult result : resultList) {
+
+                //瀛樺叆鍦ㄧ敤娴佹按
+                UsingGoodsHis his  = new UsingGoodsHis();
+                his.setId(NumberGenerator.getLongSequenceNumber());
+                his.setBusinessFormId(scrapped.getId());
+                his.setBusinessFormCode(scrapped.getBusinessFormCode());
+                his.setBusinessFormName("閮ㄩ棬鎶ュ簾鍗曪細" + scrapped.getBusinessFormCode());
+                his.setClassification(4);
+                his.setOperatorId(scrapped.getOperatorId());
+                his.setOperatorName(scrapped.getOperatorName());
+                his.setDealTime(scrapped.getDealTime());
+                his.setDepFormLendingModelId(result.getLendingModel().getId());
+                his.setDepFormLendingGoodsId(result.getLendingModel().getDepFormLendingGoodsId());
+                his.setDepFormLendingId(result.getLendingModel().getDepFormLendingId());
+                his.setWhGoodsId(result.getLendingModel().getWhGoodsId());
+                his.setInitialCount(result.getInitial_count());
+                his.setEndCount(result.getEnd_count());
+                his.setWarehouseId(scrapped.getWarehouseId());
+                his.setWarehouseName(scrapped.getWarehouseName());
+                his.setDepartmentId(scrapped.getDepartmentId());
+                his.setDepartmentName(scrapped.getDepartmentName());
+                insert(his);
+
+
+                DepFormScrappedModel model = new DepFormScrappedModel();
+                model.setId(NumberGenerator.getLongSequenceNumber());
+                model.setDepFormScrappedGoodsId(map.getLong("DEP_FORM_SCRAPPED_GOODS_ID"));
+                model.setScrappedCode(map.getString("SCRAPPED_CODE"));
+                model.setScrappedName(map.getString("SCRAPPED_NAME"));
+                model.setUsingGoodsHisId(his.getId());
+                model.setDepFormScrappedId(scrapped.getId());
+                model.setWhGoodsId(his.getWhGoodsId());
+                model.setScrappedCounts(his.getThisCount());
+                model.setInitCount(his.getInitialCount());
+                model.setDepFormLendingModelId(his.getDepFormLendingModelId());
+                model.setDepFormLendingGoodsId(his.getDepFormLendingGoodsId());
+                model.setDepFormLendingId(his.getDepFormLendingId());
+                insert(model);
+            }
+        }
+    }
+
+    /**
+     * 鐢ㄤ簬鍙樻洿鐗╁搧浣跨敤浜哄悗锛屾洿鏂板簱瀛樼墿鍝佷娇鐢ㄤ汉淇℃伅銆�
+     * @param dep_form_lending_goods_user_id
+     */
+    public void changeUser(Long dep_form_lending_goods_user_id){
+        DepFormLendingGoodsUser user = get(new DepFormLendingGoodsUser(),"ID=?",new Object[]{dep_form_lending_goods_user_id});
+        DepFormLendingGoods goods = get(new DepFormLendingGoods(),"ID=?",new Object[]{user.getDepFormLendingGoodsId()});
+
+
+        String sql =
+                "UPDATE DEP_FORM_LENDING_MODEL \n" +
+                        "SET NOW_USER_NAME =:NOW_USER_NAME,\n" +
+                        "NOW_USER_PHONE =:NOW_USER_PHONE \n" +
+                        "WHERE\n" +
+                        "	DEP_FORM_LENDING_GOODS_ID =:DEP_FORM_LENDING_GOODS_ID \n" +
+                        "	AND BASE_GOODS_MODELS_ID =:BASE_GOODS_MODELS_ID \n" +
+                        "	AND NOW_USER_NAME =:OLD_USER_NAME\n" +
+                        "	AND USING_COUNT > 0";
+
+        List<SqlParameter> parameterList = new ArrayList<>();
+        List<DepFormLendingModel> modelList = select(new DepFormLendingModel(),"DEP_FORM_LENDING_GOODS_ID=?",new Object[]{goods.getId()});
+        for (DepFormLendingModel model : modelList) {
+            if (model.getUsingCount() == 0) continue;
+            SqlParameter parameter = new SqlParameter();
+            parameter.add("NOW_USER_NAME",user.getNowUserName())
+                    .add("NOW_USER_PHONE",user.getNowUserPhone())
+                    .add("DEP_FORM_LENDING_GOODS_ID",goods.getId())
+                    .add("BASE_GOODS_MODELS_ID",goods.getBaseGoodsModelsId())
+                    .add("OLD_USER_NAME",goods.getGoodsUserName());
+            parameterList.add(parameter);
+        }
+        execBatchUpdate(sql,parameterList);
+    }
 }

--
Gitblit v1.9.1