From 7ad4b3cb3848a8a3ee18f117f453060b9530bfba Mon Sep 17 00:00:00 2001
From: CZT <czt18638530771@163.com>
Date: 星期一, 31 七月 2023 09:46:24 +0800
Subject: [PATCH] 新增贝博粮情协议--整体框架提交

---
 igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java |  102 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 99 insertions(+), 3 deletions(-)

diff --git a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java
index bed9209..c62bd2b 100644
--- a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java
+++ b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java
@@ -7,6 +7,7 @@
 import com.ld.igds.data.Page;
 import com.ld.igds.data.PageResponse;
 import com.ld.igds.file.CoreFileService;
+import com.ld.igds.file.dto.FileData;
 import com.ld.igds.inout.InoutConstant;
 import com.ld.igds.inout.dto.InoutCheckData;
 import com.ld.igds.inout.dto.InoutCheckParam;
@@ -50,6 +51,8 @@
     private CheckStandardManager checkStandardManager;
     @Resource
     private InoutEventControlManager inoutEventControl;
+    @Resource
+    private CoreFileService coreFileService;
 
     /**
      * 鐩存帴浠庢暟鎹簱鏌ヨ锛屼笉鑰冭檻淇℃伅鐘舵��
@@ -213,6 +216,22 @@
         return data;
     }
 
+    private InoutData updateFiles(InoutData data) throws Exception {
+        List<FileData> files = data.getFiles();
+        if (null == files) {
+            return data;
+        }
+
+        for (FileData fileData : files) {
+            fileData.setFileId(ContextUtil.getUUID());
+            fileData.setCompanyId(data.getCompanyId());
+            fileData.setBizId(data.getId());
+            fileData.setCreateTime(new Date());
+            coreFileService.addRecord(fileData);
+        }
+
+        return data;
+    }
 
     /**
      * 浠庣紦瀛樹腑鑾峰彇涓嬩竴娴佺▼
@@ -367,8 +386,9 @@
         if (null != msg) {
             return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
         }
-
-
+        data.setCompleteTime(param.getCompleteTime());
+        data.setProgress(InoutConstant.PROGRESS_RECORD);
+        inoutService.updateInoutCache(data);
         // 娴佺▼瀹屾垚鏀朵簨浠�
         inoutEventControl.onInoutComplete(data);
 
@@ -443,6 +463,7 @@
         if (InoutConstant.TYPE_IN.equals(data.getType())) {
             this.updateCheckItems(data, true);
         }
+        this.updateFiles(data);
 
         return null;
     }
@@ -841,6 +862,7 @@
             data.setCheckTime(new Date());
         }
         curData.setCheckStatus(data.getCheckStatus());
+        curData.setFoodYear(data.getFoodYear());
 
 
         // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
@@ -860,6 +882,8 @@
         curData.setPrice(data.getPrice());
         curData.setRemarks(data.getRemarks());
         curData.setCheckItems(data.getCheckItems());
+        curData.setCheckTime(data.getCheckTime());
+        curData.setDepotId(data.getDepotId());
 
         if (StringUtils.isEmpty(data.getCheckUser())) {
             curData.setCheckUser(ContextUtil.getLoginUserCName());
@@ -876,9 +900,50 @@
 
 
         // 璐ㄦ瀹屾垚瑙﹀彂浜嬩欢
-        inoutEventControl.onInCheck(data,curProgress,nextProgress);
+        inoutEventControl.onInCheck(data, curProgress, nextProgress);
 
         return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
+    }
+
+    public PageResponse<InoutCheckData> submitCheckData(InoutCheckData data) throws Exception {
+
+
+        // 鑾峰彇涓氬姟鏁版嵁淇℃伅
+        InoutParam param = new InoutParam();
+        param.setCompanyId(data.getCompanyId());
+        param.setId(data.getId());
+        InoutData curData = inoutService.inoutProgressQuery(param);
+
+        if (null == curData) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+                    "娌℃湁鑾峰彇鍒板叆搴撲笟鍔℃暟鎹俊鎭紝鏇存柊澶辫触", data);
+        }
+
+        if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+                    "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼");
+        }
+
+        // 鏇存柊鍖栭獙椤逛俊鎭�
+        CheckUpdateResult checkResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems());
+        if (StringUtils.isNotEmpty(checkResult.getMsg())) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+                    "鍚庡彴鎵ц寮傚父锛�" + checkResult.getMsg(), data);
+        }
+
+        curData.setType(curData.getType());
+        curData.setFoodLevel(data.getFoodLevel());
+        curData.setFoodVariety(data.getFoodVariety());
+        curData.setPrice(data.getPrice());
+        curData.setDepotId(data.getDepotId());
+        curData.setCheckItems(data.getCheckItems());
+
+        String msg = inoutService.updateCheckData(curData);
+        if (null != msg) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
+        }
+
+        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "淇濆瓨鎴愬姛");
     }
 
     /**
@@ -952,4 +1017,35 @@
         }
     }
 
+    /**
+     * @param param
+     * @return
+     */
+    public PageResponse<InoutCheckData> inoutDataByCheckId(InoutCheckParam param) {
+        if (StringUtils.isEmpty(param.getCheckId())) {
+            return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
+                    "鏌ヨ鍙傛暟涓嶅畬鏁达紝鏌ヨ澶辫触锛�");
+        }
+
+        InoutCheckData result;
+        try {
+            param.setProgress(InoutConstant.PROGRESS_CHECK);
+            result = inoutService.inoutDataByCheckId(param);
+            if (null == result) {
+                return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+                        "绯荤粺鏈煡璇㈠埌鎵ц涓殑杞﹁締淇℃伅", null);
+            }
+
+            return new PageResponse<>(RespCodeEnum.CODE_0000, result);
+
+        } catch (Exception e) {
+            return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+                    e.getMessage());
+        }
+    }
+
+    public void initInoutWeight(List<InoutConf> listInoutConf, String sort) {
+        inoutEventControl.initInoutWeight(listInoutConf, sort);
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.3