From 785ce007ce4b7b2119a99aacc95cefe9da09e32e Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期二, 04 七月 2023 16:49:09 +0800
Subject: [PATCH] 优化出入库逻辑,调整节点事件

---
 igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java |  147 ++++++++++++++++++++++++++----------------------
 1 files changed, 79 insertions(+), 68 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 9373ae5..bed9209 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
@@ -3,7 +3,6 @@
 import com.ld.igds.check.CheckStandardManager;
 import com.ld.igds.check.dto.CheckItemData;
 import com.ld.igds.check.dto.CheckUpdateResult;
-import com.ld.igds.common.CoreCommonService;
 import com.ld.igds.constant.RespCodeEnum;
 import com.ld.igds.data.Page;
 import com.ld.igds.data.PageResponse;
@@ -20,9 +19,7 @@
 import com.ld.igds.models.InoutSysConf;
 import com.ld.igds.util.ContextUtil;
 import com.ld.igds.util.DateUtil;
-
 import lombok.extern.slf4j.Slf4j;
-
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.apache.commons.lang3.time.DateUtils;
@@ -30,7 +27,6 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -49,13 +45,11 @@
     @Resource
     private CoreFileService fileService;
     @Resource
-    private CoreCommonService commonService;
-    @Resource
     private InoutCommonService inoutCommonService;
     @Resource
     private CheckStandardManager checkStandardManager;
     @Resource
-    private InoutDeviceManager inoutDeviceManager;
+    private InoutEventControlManager inoutEventControl;
 
     /**
      * 鐩存帴浠庢暟鎹簱鏌ヨ锛屼笉鑰冭檻淇℃伅鐘舵��
@@ -296,46 +290,6 @@
         return data;
     }
 
-    public PageResponse<InoutData> submitComplete(InoutData data)
-            throws Exception {
-
-        if (StringUtils.isEmpty(data.getId())
-                || StringUtils.isEmpty(data.getType())
-                || StringUtils.isEmpty(data.getProgress())) {
-
-            return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
-                    "娌℃湁鑾峰彇鍒拌溅杈嗕俊鎭��", data);
-        }
-
-        data.setUpdateTime(new Date());
-        if (null == data.getCompleteTime()) {
-            data.setCompleteTime(DateUtil.getNewByMinute(new Date(), 2));
-        }
-        if (null == data.getCompleteUser()) {
-            data.setCompleteUser(ContextUtil.getLoginUserCName());
-        }
-
-        // 璁剧疆娴佺▼鑺傜偣鐩存帴瀹屾垚
-        InoutParam param = new InoutParam();
-        param.setCompanyId(data.getCompanyId());
-        param.setId(data.getId());
-        param.setType(data.getType());
-        param.setDeptId(data.getDeptId());
-        param.setIntelCard(data.getIntelCard());
-        param.setUserId(data.getCompleteUser());
-        param.setDepotId(data.getDepotId());
-        param.setCompleteTime(new Date());
-        param.setProgress(InoutConstant.PROGRESS_RECORD);
-
-        String msg = inoutService.toComplete(param);
-
-        if (null != msg) {
-            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
-        }
-
-        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data);
-    }
-
     /**
      * 鍗″洖鏀堕�昏緫澶勭悊
      *
@@ -374,6 +328,51 @@
 
         return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
                 data);
+    }
+
+
+    public PageResponse<InoutData> submitComplete(InoutData data)
+            throws Exception {
+
+        if (StringUtils.isEmpty(data.getId())
+                || StringUtils.isEmpty(data.getType())
+                || StringUtils.isEmpty(data.getProgress())) {
+
+            return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
+                    "娌℃湁鑾峰彇鍒拌溅杈嗕俊鎭��", data);
+        }
+
+        data.setUpdateTime(new Date());
+        if (null == data.getCompleteTime()) {
+            data.setCompleteTime(DateUtil.getNewByMinute(new Date(), 2));
+        }
+        if (null == data.getCompleteUser()) {
+            data.setCompleteUser(ContextUtil.getLoginUserCName());
+        }
+
+        // 璁剧疆娴佺▼鑺傜偣鐩存帴瀹屾垚
+        InoutParam param = new InoutParam();
+        param.setCompanyId(data.getCompanyId());
+        param.setId(data.getId());
+        param.setType(data.getType());
+        param.setDeptId(data.getDeptId());
+        param.setIntelCard(data.getIntelCard());
+        param.setUserId(data.getCompleteUser());
+        param.setDepotId(data.getDepotId());
+        param.setCompleteTime(new Date());
+        param.setProgress(InoutConstant.PROGRESS_RECORD);
+
+        String msg = inoutService.toComplete(param);
+
+        if (null != msg) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
+        }
+
+
+        // 娴佺▼瀹屾垚鏀朵簨浠�
+        inoutEventControl.onInoutComplete(data);
+
+        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data);
     }
 
     /**
@@ -556,8 +555,13 @@
         return msg;
     }
 
-    public void initLpr(InoutConf conf) {
-        inoutDeviceManager.initLpr(conf);
+    /**
+     * 鍑哄叆搴撶櫥璁板垵濮嬪寲
+     *
+     * @param conf 杞︾墝璇嗗埆閰嶇疆淇℃伅
+     */
+    public void initInoutRegister(InoutConf conf) {
+        inoutEventControl.initInoutRegister(conf);
     }
 
     /**
@@ -567,8 +571,7 @@
      * @return
      * @throws Exception
      */
-    public PageResponse<InoutData> submitRegisterInout(InoutData data)
-            throws Exception {
+    public PageResponse<InoutData> submitRegisterInout(InoutData data) throws Exception {
 
         // 棣栧厛鍒ゆ柇娴佺▼涓槸鍚︽湁宸茬粡瀛樺湪鐨勮溅杈嗕俊鎭湭鎵ц瀹屾垚锛岀洿鎺ヤ粠鏁版嵁搴撲腑鏌ヨ
         InoutParam param = new InoutParam();
@@ -602,20 +605,20 @@
         String msg = inoutService.insertData(data);
 
         if (null != msg) {
-            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg,
-                    data);
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
         }
 
         // 鎵ц闄勪欢淇℃伅
-        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
-                data.getId(), curProgress);
+        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
+
+        //鐧昏瀹屾垚浜嬩欢
+        inoutEventControl.onInoutRegister(data);
 
         return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
                 data);
     }
 
-    public PageResponse<InoutData> submitWeightIn(InoutData data)
-            throws Exception {
+    public PageResponse<InoutData> submitWeightIn(InoutData data) throws Exception {
         // 鑾峰彇绯荤粺鍙傛暟閰嶇疆
         InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
                 data.getCompanyId(), data.getDeptId());
@@ -642,14 +645,12 @@
         }
 
         // 鎵ц闄勪欢淇℃伅
-        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
-                data.getId(), curProgress);
+        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
 
-        // 绉伴噸瀹屾垚锛岃皟鐢ㄥ嚭鍏ュ簱鎺у埗閫昏緫澶勭悊
-        inoutDeviceManager.controlWeight(data, curProgress, nextProgress);
+        // 绉伴噸瀹屾垚浜嬩欢
+        inoutEventControl.onInoutWeight(data, curProgress, nextProgress);
 
-        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
-                data);
+        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
     }
 
     public PageResponse<InoutData> submitWeightOut(InoutData data)
@@ -680,11 +681,11 @@
         fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
                 data.getId(), curProgress);
 
-        // 绉伴噸鍚庢牴鎹綋鍓嶆祦绋嬬姸鎬佸拰涓嬩竴涓姸鎬侊紝閫氱煡绉伴噸鎺у埗鍣�
-        inoutDeviceManager.controlWeight(data, curProgress, nextProgress);
 
-        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
-                data);
+        // 绉伴噸瀹屾垚浜嬩欢
+        inoutEventControl.onInoutWeight(data, curProgress, nextProgress);
+
+        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
     }
 
     public PageResponse<InoutData> submitHandle(InoutData data)
@@ -715,6 +716,9 @@
 
         // 鎵ц闄勪欢淇℃伅
         fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
+
+        // 鍊间粨瀹屾垚瑙﹀彂浜嬩欢
+        inoutEventControl.onInoutHandle(data, curProgress, nextProgress);
 
         return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
     }
@@ -784,6 +788,9 @@
         if (null != msg) {
             return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
         }
+
+        // 鎵︽牱瀹屾垚瑙﹀彂浜嬩欢
+        inoutEventControl.onInSimple(data);
 
         return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
     }
@@ -867,6 +874,10 @@
             return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
         }
 
+
+        // 璐ㄦ瀹屾垚瑙﹀彂浜嬩欢
+        inoutEventControl.onInCheck(data,curProgress,nextProgress);
+
         return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
     }
 
@@ -908,7 +919,7 @@
 
         try {
             List<CheckItemData> result = checkStandardManager.listCheckItem(
-                     param.getCompanyId(),param.getCheckId(),
+                    param.getCompanyId(), param.getCheckId(),
                     param.getFoodVariety());
 
             return new PageResponse<>(RespCodeEnum.CODE_0000, result);

--
Gitblit v1.9.3