From 1b60f1df51e1824154018a5b6a7159b09b44c8b1 Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期一, 12 六月 2023 14:23:26 +0800
Subject: [PATCH] 化验页面--数据提交更新

---
 igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java |  595 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 357 insertions(+), 238 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 a3e5e3d..dd68d6f 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
@@ -23,7 +23,6 @@
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
@@ -48,8 +47,8 @@
     private CoreFileService fileService;
     @Autowired
     private CoreCommonService commonService;
-    @Autowired
-    private InoutCommonService inoutManagerService;
+    @Resource
+    private InoutCommonService inoutCommonService;
     @Autowired
     private CheckStandardManager checkStandardManager;
     @Resource
@@ -143,14 +142,14 @@
         List<FileData> files = data.getFiles();
 
         // 鏇存柊涓嬩竴涓姸鎬佸拰鍩烘湰淇℃伅
-        InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(
+        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
                 data.getCompanyId(), data.getDeptId());
         if (null == inoutSysConf
                 || StringUtils.isEmpty(inoutSysConf.getProgressIn())) {
             return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                     "褰撳墠搴撳尯鏈厤缃嚭搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳閰嶇疆銆�", data);
         }
-        data = updateOutBasicInfo(data, inoutSysConf);
+        data = updateBasicInfo(data, inoutSysConf);
 
         // 濡傛灉褰撳墠鑺傜偣鏄敞鍐岋紝鍒欓渶瑕侀獙璇佷笅锛屾槸鍚︽湁涓哄畬鎴愮殑娴佺▼鍦ㄦ墽琛屼腑
         if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) {
@@ -211,7 +210,7 @@
         }
 
         // 鏇存柊涓嬩竴涓姸鎬佸拰鍩烘湰淇℃伅
-        InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
+        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
 
         if (null == inoutSysConf
                 || StringUtils.isEmpty(inoutSysConf.getProgressIn())) {
@@ -219,7 +218,7 @@
                     "褰撳墠搴撳尯鏈厤缃叆搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳閰嶇疆銆�", data);
         }
 
-        data = updateInBasicInfo(data, inoutSysConf);
+        data = updateBasicInfo(data, inoutSysConf);
 
         // 濡傛灉褰撳墠鑺傜偣鏄敞鍐岋紝鍒欓渶瑕侀獙璇佷笅锛屾槸鍚︽湁涓哄畬鎴愮殑娴佺▼鍦ㄦ墽琛屼腑
         if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) {
@@ -284,96 +283,84 @@
         return inoutService.inoutProgressQuery(param);
     }
 
-    @Transactional(rollbackFor = Exception.class)
-    public PageResponse<InoutData> updateCheck(InoutData data) throws Exception {
-
-        if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
-            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
-                    "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼", data);
-        }
-
-        CheckUpdateResult checkResult = this.updateCheckItems(data);
-        String tag = checkResult.getMsg();
-
-        if (null != tag) {
-            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
-                    "鍚庡彴鎵ц寮傚父锛�" + tag, data);
-        }
-
-        // 鑾峰彇涓氬姟鏁版嵁淇℃伅
-        InoutParam param = new InoutParam();
-        param.setCompanyId(data.getCompanyId());
-        param.setId(data.getId());
-        InoutData progressData = inoutService.inoutProgressQuery(param);
-        if (null == progressData) {
-            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
-                    "娌℃湁鑾峰彇鍒板嚭鍏ュ簱涓氬姟鏁版嵁淇℃伅锛屾洿鏂板け璐�", data);
-        }
-        if (InoutConstant.PROGRESS_RECORD.equals(progressData.getProgress())) {
-            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
-                    "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼");
-        }
-        progressData.setCheckStatus(data.getCheckStatus());
-
-        // 鏇存柊涓嬩竴涓姸鎬佸拰鍩烘湰淇℃伅
-        if (InoutConstant.PROGRESS_CHECK.equals(progressData.getProgress())) {
-            progressData = updateInBasicInfo(progressData, null);
-            // 鑻ュ寲楠岀粨鏋滀笉鍚堟牸锛屽垽鏂厤缃悗缁祦绋�
-            if (InoutConstant.STATUS_UNPASS.equals(progressData
-                    .getCheckStatus())) {
-                progressData = checkNoPass(progressData);
-            }
-        }
-        progressData.setCheckUser(ContextUtil.getLoginUserCName());
-//		if (StringUtils.isNotEmpty(data.getCustomerName())) {
-//			progressData.setCustomerId(data.getCustomerId());
-//			progressData.setCustomerName(data.getCustomerName());
-//		}
-        if (StringUtils.isNotEmpty(data.getDepotId())) {
-            progressData.setDepotId(data.getDepotId());
-        }
-        if (StringUtils.isNotEmpty(data.getFoodVariety())) {
-            progressData.setFoodVariety(data.getFoodVariety());
-        }
-        if (StringUtils.isNotEmpty(data.getFoodLevel())) {
-            progressData.setFoodLevel(data.getFoodLevel());
-        }
-        if (StringUtils.isNotEmpty(data.getFoodLocation())) {
-            progressData.setFoodLocation(data.getFoodLocation());
-        }
-        if (StringUtils.isNotEmpty(data.getFoodYear())) {
-            progressData.setFoodYear(data.getFoodYear());
-        }
-        if (null != data.getPrice()) {
-            progressData.setPrice(data.getPrice());
-        }
-        if (StringUtils.isNotEmpty(data.getRemarks())) {
-            progressData.setRemarks(data.getRemarks());
-        }
-        if (StringUtils.isNotEmpty(data.getNoticeId())) {
-            progressData.setNoticeId(data.getNoticeId());
-        }
-
-//		// 鍥炲~姘村垎鍜屾潅璐�
-//		if (checkResult.getWet() > 0) {
-//			progressData.setWet(checkResult.getWet());
-//		}
+//    @Transactional(rollbackFor = Exception.class)
+//    public PageResponse<InoutData> updateCheck(InoutData data) throws Exception {
 //
-//		if (checkResult.getImpurity() > 0) {
-//			progressData.setImpurity(checkResult.getImpurity());
-//		}
-
-        String msg = inoutService.updateData(progressData);
-
-        if (null != msg) {
-            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
-        }
-        if (InoutConstant.PROGRESS_RECORD.equals(progressData.getProgress())) {
-
-            inoutComplete(progressData);
-        }
-        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
-    }
+//        if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
+//            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+//                    "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼", data);
+//        }
+//
+//        CheckUpdateResult checkResult = this.updateCheckItems(data);
+//        String tag = checkResult.getMsg();
+//
+//        if (null != tag) {
+//            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+//                    "鍚庡彴鎵ц寮傚父锛�" + tag, data);
+//        }
+//
+//        // 鑾峰彇涓氬姟鏁版嵁淇℃伅
+//        InoutParam param = new InoutParam();
+//        param.setCompanyId(data.getCompanyId());
+//        param.setId(data.getId());
+//        InoutData progressData = inoutService.inoutProgressQuery(param);
+//        if (null == progressData) {
+//            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+//                    "娌℃湁鑾峰彇鍒板嚭鍏ュ簱涓氬姟鏁版嵁淇℃伅锛屾洿鏂板け璐�", data);
+//        }
+//        if (InoutConstant.PROGRESS_RECORD.equals(progressData.getProgress())) {
+//            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+//                    "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼");
+//        }
+//        progressData.setCheckStatus(data.getCheckStatus());
+//
+//        // 鏇存柊涓嬩竴涓姸鎬佸拰鍩烘湰淇℃伅
+//        if (InoutConstant.PROGRESS_CHECK.equals(progressData.getProgress())) {
+//            progressData = updateBasicInfo(progressData, null);
+//            // 鑻ュ寲楠岀粨鏋滀笉鍚堟牸锛屽垽鏂厤缃悗缁祦绋�
+//            if (InoutConstant.STATUS_UNPASS.equals(progressData
+//                    .getCheckStatus())) {
+//                progressData = checkNoPass(progressData);
+//            }
+//        }
+//        progressData.setCheckUser(ContextUtil.getLoginUserCName());
+//
+//        if (StringUtils.isNotEmpty(data.getDepotId())) {
+//            progressData.setDepotId(data.getDepotId());
+//        }
+//        if (StringUtils.isNotEmpty(data.getFoodVariety())) {
+//            progressData.setFoodVariety(data.getFoodVariety());
+//        }
+//        if (StringUtils.isNotEmpty(data.getFoodLevel())) {
+//            progressData.setFoodLevel(data.getFoodLevel());
+//        }
+//        if (StringUtils.isNotEmpty(data.getFoodLocation())) {
+//            progressData.setFoodLocation(data.getFoodLocation());
+//        }
+//        if (StringUtils.isNotEmpty(data.getFoodYear())) {
+//            progressData.setFoodYear(data.getFoodYear());
+//        }
+//        if (null != data.getPrice()) {
+//            progressData.setPrice(data.getPrice());
+//        }
+//        if (StringUtils.isNotEmpty(data.getRemarks())) {
+//            progressData.setRemarks(data.getRemarks());
+//        }
+//        if (StringUtils.isNotEmpty(data.getNoticeId())) {
+//            progressData.setNoticeId(data.getNoticeId());
+//        }
+//
+//        String msg = inoutService.updateData(progressData);
+//
+//        if (null != msg) {
+//            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
+//        }
+//        if (InoutConstant.PROGRESS_RECORD.equals(progressData.getProgress())) {
+//
+//            inoutComplete(progressData);
+//        }
+//        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
+//    }
 
     /**
      * 鍖栭獙缁撴灉涓嶉�氳繃鏃舵牎楠岄厤缃俊鎭�
@@ -382,7 +369,7 @@
      * @return
      */
     private InoutData checkNoPass(InoutData data) {
-        InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(
+        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
                 data.getCompanyId(), data.getDeptId());
 
         if (inoutSysConf.getNoPassNext().equals(InoutConstant.CHECK_NOPASS_RECORD)) {
@@ -397,14 +384,20 @@
         return data;
     }
 
+
+    /**
+     * 鏇存柊璐ㄦ淇℃伅
+     *
+     * @param data
+     * @return
+     */
     private CheckUpdateResult updateCheckItems(InoutData data) {
         CheckUpdateResult result = new CheckUpdateResult();
-        if (null == data.getCheckItems())
-            return result;
+        if (null == data.getCheckItems()) return result;
+
         try {
             // 鏇存柊妫�楠岄」鏁版嵁
-            result = checkStandardManager.updateCheckItems(data.getCheckId(),
-                    data.getCompanyId(), data.getCheckItems());
+            result = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems());
 
             // 灏嗗寲楠屾暟鎹瓨鍏ョ紦瀛樹腑
             inoutService.setCheckCache(data);
@@ -444,82 +437,59 @@
     }
 
     /**
-     * 鏍规嵁闇�瑕佷繚瀛樼殑鏁版嵁锛岃皟鏁翠笅涓�涓祦绋嬬姸鎬� 涓嶅悓鐨勪粨搴撶粍缁囨祦绋嬪彲鑳戒笉涓�鏍凤紝闇�瑕佹牴鎹疄闄呰皟鏁�
+     * 鏍规嵁鏁版嵁褰撳墠鐘舵�佸拰涓嬩竴涓姸鎬侊紝鏇存柊鍩虹淇℃伅
      *
      * @param data
      * @return
      */
-    private InoutData updateInBasicInfo(InoutData data, InoutSysConf sysConf) {
-        if (null == sysConf) {
-            sysConf = inoutManagerService.getCacheInoutSysConf(
-                    data.getCompanyId(), data.getDeptId());
-        }
+    private InoutData updateBasicInfo(InoutData data, String curProgress, String nextProgress) {
 
-        if (InoutConstant.PROGRESS_REGISTER.equals(data.getProgress())) {
+        if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) {
             data.setRegisterTime(new Date());
             data.setRegisterUser(ContextUtil.getLoginUserCName());
-            data.setProgress(getNextProgress(data.getProgress(),
-                    data.getType(), sysConf));
-
-            return data;
+            data.setProgress(nextProgress);
         }
 
-        if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(data.getProgress())) {
-            data.setFullWeightTime(new Date());
-            data.setFullWeightUser(ContextUtil.getLoginUserCName());
-            data.setProgress(getNextProgress(data.getProgress(),
-                    data.getType(), sysConf));
-            return data;
-        }
-        if (InoutConstant.PROGRESS_CHECK.equals(data.getProgress())) {
-            data.setCheckUser(ContextUtil.getLoginUserCName());
-            data.setProgress(getNextProgress(data.getProgress(),
-                    data.getType(), sysConf));
-            return data;
-        }
-
-        if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(data.getProgress())) {
+        if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(curProgress)) {
             data.setEmptyWeightTime(new Date());
             data.setEmptyWeightUser(ContextUtil.getLoginUserCName());
+            data.setProgress(nextProgress);
 
-            data.setProgress(getNextProgress(data.getProgress(),
-                    data.getType(), sysConf));
+        }
+        if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(curProgress)) {
+            data.setFullWeightTime(new Date());
+            data.setFullWeightUser(ContextUtil.getLoginUserCName());
+            data.setProgress(nextProgress);
+        }
 
-            if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
-                data.setCompleteTime(DateUtils.addMinutes(new Date(), 2));
-                data.setCompleteUser(ContextUtil.getLoginUserCName());
+        if (InoutConstant.PROGRESS_HANDLE.equals(curProgress)) {
+            if (null == data.getHandleUser()) {
+                data.setHandleUser(ContextUtil.getLoginUserCName());
             }
-            return data;
+            data.setProgress(nextProgress);
         }
 
-        if (InoutConstant.PROGRESS_HANDLE.equals(data.getProgress())) {
 
-            // 鏌ヨ缂撳瓨涓粨搴撲俊鎭紝鏍规嵁浠撳簱id璁剧疆鍊间粨浜轰负浠撳簱淇濈鍛�
-            Depot depot = commonService.getCacheDepot(data.getCompanyId(),
-                    data.getDepotId());
-            data.setHandleUser(depot == null ? "" : depot.getStoreKeeperName());
-            data.setProgress(getNextProgress(data.getProgress(),
-                    data.getType(), sysConf));
-            return data;
-        }
-
-        if (InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) {
-            data.setCompleteTime(new Date());
+        //濡傛灉涓嬩竴涓暟鎹姸鎬�=娴佺▼缁撴潫锛岀洿鎺ヨˉ鍏呭畬鏁翠俊鎭�
+        if (InoutConstant.PROGRESS_RECORD.equals(nextProgress)) {
+            data.setCompleteTime(DateUtils.addMinutes(new Date(), 2));
             data.setCompleteUser(ContextUtil.getLoginUserCName());
-            data.setProgress(getNextProgress(data.getProgress(),
-                    data.getType(), sysConf));
-            return data;
+            data.setProgress(nextProgress);
         }
+
+
         return data;
     }
 
     /**
+     * 褰撳墠鏂规硶闇�瑕佸垹闄�
+     * <p>
      * 鏍规嵁闇�瑕佷繚瀛樼殑鏁版嵁锛岃皟鏁翠笅涓�涓祦绋嬬姸鎬� 涓嶅悓鐨勪粨搴撶粍缁囨祦绋嬪彲鑳戒笉涓�鏍凤紝闇�瑕佹牴鎹疄闄呰皟鏁�
      *
      * @param data
      * @return
      */
-    private InoutData updateOutBasicInfo(InoutData data, InoutSysConf sysConf) {
+    private InoutData updateBasicInfo(InoutData data, InoutSysConf sysConf) {
         if (InoutConstant.PROGRESS_REGISTER.equals(data.getProgress())) {
             data.setRegisterTime(new Date());
             data.setRegisterUser(ContextUtil.getLoginUserCName());
@@ -570,36 +540,6 @@
         }
 
         return data;
-    }
-
-    public PageResponse<Page<InoutData>> pageRecordData(InoutParam param) {
-
-        log.debug("鍒嗛〉淇℃伅--page={},limit={},cuur={}", param.getPage(),
-                param.getLimit(), param.getCurr());
-
-        Page<InoutData> result = inoutService.pageRecordData(param);
-
-        if (null == result.getRecords() || result.getRecords().isEmpty()) {
-            return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
-                    "鑾峰彇鍒版暟鎹俊鎭负绌�");
-        }
-
-        return new PageResponse<>(RespCodeEnum.CODE_0000, result);
-    }
-
-    /**
-     * @param param
-     * @return
-     */
-    public PageResponse<Page<InoutData>> pageCheckData(InoutParam param) {
-        // 濡傛灉鏄凡鍖栭獙锛屽垯灏嗘祦绋嬬姸鎬佺疆绌猴紝濡傛灉鏄湭鍖栭獙锛屽垯娴佺▼鐘舵�佷笉澶勭悊锛屼粛鏄疌HECK鐘舵��
-        if (!"NONE".equals(param.getCheckStatus())) {
-            param.setProgress(null);
-        }
-        // 璁剧疆鍒嗗簱Id
-        String deptId = ContextUtil.subDeptId(null);
-        param.setDeptId(deptId);
-        return pageRecordData(param);
     }
 
 
@@ -642,20 +582,20 @@
         return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data);
     }
 
-    /**
-     * 鎵︽牱鍖栭獙椤甸潰鑾峰彇妫�楠岄」鏉$洰淇℃伅
-     *
-     * @param data
-     * @return
-     */
-    public PageResponse<List<CheckItemData>> getCheckItem(InoutData data) {
-
-        List<CheckItemData> result = checkStandardManager.listCheckItem(
-                data.getCheckId(), data.getCompanyId(), data.getDeptId(),
-                data.getFoodVariety());
-
-        return new PageResponse<>(RespCodeEnum.CODE_0000, result);
-    }
+//    /**
+//     * 鎵︽牱鍖栭獙椤甸潰鑾峰彇妫�楠岄」鏉$洰淇℃伅
+//     *
+//     * @param data
+//     * @return
+//     */
+//    public PageResponse<List<CheckItemData>> getCheckItem(InoutData data) {
+//
+//        List<CheckItemData> result = checkStandardManager.listCheckItem(
+//                data.getCheckId(), data.getCompanyId(), data.getDeptId(),
+//                data.getFoodVariety());
+//
+//        return new PageResponse<>(RespCodeEnum.CODE_0000, result);
+//    }
 
     /**
      * 鍒犻櫎骞跺畬鎴�
@@ -768,9 +708,6 @@
             if (null == data.getFullWeightTime()) {
                 data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -50));
             }
-            if (null == data.getHandleEnd()) {
-                data.setHandleEnd(DateUtil.getNewByMinute(new Date(), -40));
-            }
             if (null == data.getEmptyWeightTime()) {
                 data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -10));
             }
@@ -784,9 +721,6 @@
         } else {
             if (null == data.getEmptyWeightTime()) {
                 data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -50));
-            }
-            if (null == data.getHandleEnd()) {
-                data.setHandleEnd(DateUtil.getNewByMinute(new Date(), -40));
             }
             if (null == data.getFullWeightTime()) {
                 data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -10));
@@ -858,7 +792,6 @@
 
         // 鏇存柊鏁版嵁
         inoutService.updateData(data);
-        // this.autoCheckByUpdate(data, record);
         return null;
     }
 
@@ -972,9 +905,6 @@
         if (StringUtils.isEmpty(data.getDepotId())) {
             return "璇峰~鍐欎粨搴撲俊鎭紒";
         }
-//		if (StringUtils.isEmpty(data.getCustomerId())) {
-//			return "璇峰~鍐欏線鏉ュ崟浣嶄俊鎭紒";
-//		}
         if (StringUtils.isEmpty(data.getFoodYear())) {
             return "璇峰~鍐欑伯椋熷勾浠戒俊鎭紒";
         }
@@ -997,28 +927,6 @@
 
     public void initLpr(InoutConf conf) {
         inoutDeviceManager.initLpr(conf);
-    }
-
-    /**
-     * 鑾峰彇鍑哄叆搴撹澶囬厤缃俊鎭�
-     *
-     * @param companyId
-     * @param deptId
-     * @return
-     */
-    public List<InoutConf> getListInoutConf(String companyId, String deptId) {
-        return inoutManagerService.getCacheInoutConf(companyId, deptId);
-    }
-
-    /**
-     * 鎿嶄綔閬撻椄璁惧
-     *
-     * @param param
-     * @return
-     */
-    public PageResponse<List<CheckItemData>> gateCtrl(InoutGateDto param) {
-
-        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "", null);
     }
 
     /**
@@ -1046,19 +954,19 @@
 
 
         //鑾峰彇绯荤粺鍙傛暟閰嶇疆
-        InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
+        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
         if (null == inoutSysConf) {
             return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                     "鎻愮ず锛氬綋鍓嶅簱鍖烘湭閰嶇疆鍑哄叆搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳", data);
         }
 
-        String curProgress = data.getProgress();
 
         //鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
+        String curProgress = data.getProgress();
         String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf);
-        data.setRegisterTime(new Date());
-        data.setRegisterUser(ContextUtil.getLoginUserCName());
-        data.setProgress(nextProgress);
+
+
+        data = updateBasicInfo(data, curProgress, nextProgress);
 
         String msg = inoutService.insertData(data);
 
@@ -1070,6 +978,104 @@
         // 鎵ц闄勪欢淇℃伅
         fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
 
+
+        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
+    }
+
+    public PageResponse<InoutData> submitWeightIn(InoutData data) throws Exception {
+        //鑾峰彇绯荤粺鍙傛暟閰嶇疆
+        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
+        if (null == inoutSysConf) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+                    "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data);
+        }
+
+
+        //鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
+        String curProgress = data.getProgress();
+        String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf);
+        data = updateBasicInfo(data, curProgress, nextProgress);
+
+
+        //鍏ュ簱绉伴噸鍙兘璋冩暣璐ㄦ鍗�
+        CheckUpdateResult checkUpdateResult = updateCheckItems(data);
+        if (data.getDeCheck() == 0) {
+            data.setDeCheck(checkUpdateResult.getDeSum());
+        }
+        if (data.getAddCheck() == 0) {
+            data.setAddCheck(checkUpdateResult.getAddSum());
+        }
+
+        //鎵ц鏁版嵁鏇存柊
+        String msg = inoutService.updateData(data);
+
+        if (null != msg) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
+        }
+
+        // 鎵ц闄勪欢淇℃伅
+        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
+
+        //绉伴噸瀹屾垚锛岃皟鐢ㄥ嚭鍏ュ簱鎺у埗閫昏緫澶勭悊
+        inoutDeviceManager.controlWeight(data, curProgress, nextProgress);
+
+        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
+    }
+
+
+    public PageResponse<InoutData> submitWeightOut(InoutData data) throws Exception {
+        //鑾峰彇绯荤粺鍙傛暟閰嶇疆
+        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
+        if (null == inoutSysConf) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+                    "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data);
+        }
+
+
+        //鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
+        String curProgress = data.getProgress();
+        String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf);
+        data = updateBasicInfo(data, curProgress, nextProgress);
+
+        //鎵ц鏁版嵁鏇存柊
+        String msg = inoutService.updateData(data);
+
+        if (null != msg) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
+        }
+
+        // 鎵ц闄勪欢淇℃伅
+        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
+
+        //绉伴噸鍚庢牴鎹綋鍓嶆祦绋嬬姸鎬佸拰涓嬩竴涓姸鎬侊紝閫氱煡绉伴噸鎺у埗鍣�
+        inoutDeviceManager.controlWeight(data, curProgress, nextProgress);
+
+        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
+    }
+
+    public PageResponse<InoutData> submitHandle(InoutData data) throws Exception {
+        //鑾峰彇绯荤粺鍙傛暟閰嶇疆
+        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
+        if (null == inoutSysConf) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+                    "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data);
+        }
+
+        //鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
+        String curProgress = data.getProgress();
+        String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf);
+        data = updateBasicInfo(data, curProgress, nextProgress);
+
+
+        //鎵ц鏁版嵁鏇存柊
+        String msg = inoutService.updateDataByHandle(data);
+
+        if (null != msg) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
+        }
+
+        // 鎵ц闄勪欢淇℃伅
+        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
 
         return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
     }
@@ -1091,7 +1097,7 @@
         }
 
         //鑻ユ煡璇㈡潯浠朵负宸叉墻鏍凤紝鍒欐祦绋嬬疆绌猴紱鑻ユ湭鎵︽牱锛屽垯娴佺▼涓嶅鐞嗭紝浠嶄负鎵︽牱鍖栭獙娴佺▼(CHECK)
-        if ("SAMPLE".equals(param.getSampleStatus())) {
+        if (!"NONE".equals(param.getSampleStatus())) {
             param.setProgress(null);
         }
 
@@ -1107,7 +1113,7 @@
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public PageResponse<InoutCheckData> updateSampleData(InoutCheckData data){
+    public PageResponse<InoutCheckData> updateSampleData(InoutCheckData data) {
 
         try {
             // 鑾峰彇涓氬姟鏁版嵁淇℃伅
@@ -1124,12 +1130,14 @@
                         "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼");
             }
 
-            //鎵︽牱淇℃伅
-            curData.setSampleTime(data.getSampleTime());
-            curData.setSampleType(data.getSampleType());
-            curData.setSampleUser(data.getSampleUser());
-
-            String msg = inoutService.updateSampleData(curData);
+            //鎵︽牱鏃堕棿鍜屾墻鏍蜂汉
+            if (StringUtils.isEmpty(data.getSampleUser())) {
+                data.setSampleUser(ContextUtil.getLoginUserCName());
+            }
+            if (null == data.getSampleTime()) {
+                data.setSampleTime(new Date());
+            }
+            String msg = inoutService.updateSampleData(data);
 
             if (null != msg) {
                 return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
@@ -1143,4 +1151,115 @@
         }
     }
 
+    /**
+     * @param param
+     * @return
+     */
+    public PageResponse<Page<InoutCheckData>> pageCheckData(InoutCheckParam param) {
+
+        if (StringUtils.isEmpty(param.getCompanyId())) {
+            param.setCompanyId(ContextUtil.getCompanyId());
+        }
+        if (StringUtils.isEmpty(param.getDeptId())) {
+            param.setDeptId(ContextUtil.subDeptId(null));
+        }
+        // 濡傛灉鏄凡鍖栭獙锛屽垯灏嗘祦绋嬬姸鎬佺疆绌猴紝濡傛灉鏄湭鍖栭獙锛屽垯娴佺▼鐘舵�佷笉澶勭悊锛屼粛鏄疌HECK鐘舵��
+        if (!"NONE".equals(param.getCheckStatus())) {
+            param.setProgress(null);
+        }
+
+        Page<InoutCheckData> checkList = inoutService.pageCheckData(param);
+
+
+        if (null == checkList.getRecords() || checkList.getRecords().isEmpty()) {
+            return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+                    "鑾峰彇鍒版暟鎹俊鎭负绌�");
+        }
+        return new PageResponse<>(RespCodeEnum.CODE_0000, checkList);
+    }
+
+    /**
+     * 鑾峰彇鍖栭獙椤逛俊鎭�
+     *
+     * @param param
+     * @return
+     */
+    public PageResponse<List<CheckItemData>> getCheckItemData(InoutCheckParam param) {
+
+        try {
+            List<CheckItemData> result = checkStandardManager.listCheckItem(param.getCheckId(),
+                    param.getCompanyId(), param.getFoodVariety());
+
+            return new PageResponse<>(RespCodeEnum.CODE_0000, result);
+        } catch (Exception e) {
+            return new PageResponse<>(
+                    RespCodeEnum.CODE_1111.getCode(), "鍚庡彴寮傚父锛�" + e.getMessage(), null);
+        }
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public PageResponse<InoutCheckData> updateCheckData(InoutCheckData data) {
+        try {
+
+            // 鑾峰彇涓氬姟鏁版嵁淇℃伅
+            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 (null == checkResult || null != checkResult.getMsg()) {
+                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+                        "鍚庡彴鎵ц寮傚父锛�" + checkResult.getMsg(), data);
+            }
+
+            //璁剧疆鍖栭獙淇℃伅
+            if (checkResult.getDeSum() > 0) {
+                data.setDeCheck(checkResult.getDeSum());
+            }
+            if (checkResult.getAddSum() > 0) {
+                data.setAddCheck(checkResult.getAddSum());
+            }
+            if (null == data.getCheckTime()) {
+                data.setCheckTime(new Date());
+            }
+            curData.setCheckStatus(data.getCheckStatus());
+            //鏇存柊涓嬩竴娴佺▼鐘舵��
+            if (InoutConstant.PROGRESS_CHECK.equals(curData.getProgress())) {
+                curData = updateBasicInfo(curData, null);
+                // 鑻ュ寲楠岀粨鏋滀笉鍚堟牸锛屽垽鏂厤缃悗缁祦绋�
+                if (InoutConstant.STATUS_UNPASS.equals(curData.getCheckStatus())) {
+                    curData = checkNoPass(curData);
+                }
+            }
+
+            data.setCheckStatus(curData.getCheckStatus());
+            //鍖栭獙浜恒�佸寲楠屾椂闂�
+            if (StringUtils.isEmpty(data.getCheckUser())) {
+                data.setCheckUser(ContextUtil.getLoginUserCName());
+            }
+            if (null == data.getCheckTime()) {
+                data.setCheckTime(new Date());
+            }
+
+            String msg = inoutService.updateCheckData(data);
+            if (null != msg) {
+                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
+            }
+
+            return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
+        } catch (Exception e) {
+            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+                    "鍚庡彴寮傚父锛�" + e.getMessage(), null);
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3