From 08cea428e888b6fdd2a3c3783e87e4f828385783 Mon Sep 17 00:00:00 2001 From: jiazx0107@163.com <jiazx0107@163.com> Date: 星期四, 08 六月 2023 08:55:47 +0800 Subject: [PATCH] 出入库优化-提交优化 --- igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java | 541 ++++++++++++++++++++++++++++++++++------------------- 1 files changed, 342 insertions(+), 199 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 b933596..621ad16 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 @@ -11,9 +11,7 @@ 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.InoutData; -import com.ld.igds.inout.dto.InoutGateDto; -import com.ld.igds.inout.dto.InoutParam; +import com.ld.igds.inout.dto.*; import com.ld.igds.inout.service.InoutService; import com.ld.igds.m.service.InoutCommonService; import com.ld.igds.models.Depot; @@ -49,15 +47,15 @@ private CoreFileService fileService; @Autowired private CoreCommonService commonService; - @Autowired - private InoutCommonService inoutManagerService; + @Resource + private InoutCommonService inoutCommonService; @Autowired private CheckStandardManager checkStandardManager; @Resource private InoutDeviceManager inoutDeviceManager; /** - * 褰撳墠鍏堜粠褰撴棩缂撳瓨涓幏鍙栨暟鎹紝濡傛灉缂撳瓨涓病鏈夊啀浠庢暟鎹簱鑾峰彇 + * 棣栧厛浠庣紦瀛樹腑鑾峰彇锛岀紦瀛樹腑锛屼粠鏁版嵁搴撲腑鑾峰彇 * * @param param * @return @@ -68,22 +66,17 @@ && StringUtils.isEmpty(param.getUserId())) { return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), - "鍙傛暟涓嶅畬鏁达紝鏃犳硶鑾峰彇淇℃伅锛�"); - } - - if (StringUtils.isEmpty(param.getCompanyId())) { - param.setCompanyId(ContextUtil.getCompanyId()); + "鏌ヨ鍙傛暟涓嶅畬鏁达紝鏌ヨ澶辫触锛�"); } InoutData result; String progress = param.getProgress(); try { param.setProgress(null); - result = inoutService.inoutProgressQuery(param); if (null == result) { return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), - "鏈壘鍒版祦绋嬩腑鐨勮溅杈嗭紒", null); + "绯荤粺涓烘煡璇㈠埌鎵ц涓殑杞﹁締淇℃伅", null); } // 濡傛灉娌℃湁娴佺▼鏉′欢璇存槑涓嶉渶瑕佸仛鍒ゆ柇锛岀洿鎺ヨ繑鍥� @@ -91,17 +84,16 @@ return new PageResponse<>(RespCodeEnum.CODE_0000, result); } + + //娴佺▼绫诲瀷楠岃瘉 if (!result.getType().equals(param.getType())) { - if (InoutConstant.TYPE_IN.equals(result.getType())) { - return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), - "绯荤粺锛氬綋鍓嶈溅杈嗕笟鍔′负銆愬叆搴撱��", result); - } else { - return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), - "绯荤粺锛氬綋鍓嶈溅杈嗕笟鍔′负銆愬嚭搴撱��", result); - } + String msg = "娴佺▼閿欒锛氬綋鍓嶈溅杈嗘祦绋嬩负銆愬叆搴撱��"; + if (InoutConstant.TYPE_OUT.equals(result.getType())) msg = "娴佺▼閿欒锛氬綋鍓嶈溅杈嗘祦绋嬩负銆愬嚭搴撱��"; + return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), msg, result); } - // 褰撳墠鏍囩鏍囩ず鏃㈠彲浠ユ槸绌鸿溅绉伴噸涔熷彲浠ユ槸婊¤溅 + + //娴佺▼鐜妭楠岃瘉 if (progress.equals(InoutConstant.PROGRESS_WEIGHT_TAG)) { if (result.getProgress().equals( InoutConstant.PROGRESS_WEIGHT_EMPTY) @@ -110,7 +102,7 @@ // 琛ㄧず褰撳墠娴佺▼姝e父 } else { return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), - "闈炲綋鍓嶆祦绋嬶紝璇峰埌" + "鎻愮ず锛氶潪褰撳墠鐜妭锛岃鍒�" + InoutConstant.getProcessName( param.getType(), result.getProgress()), result); @@ -118,33 +110,10 @@ } else { if (!result.getProgress().equals(progress)) { return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), - "闈炲綋鍓嶆祦绋嬶紝璇峰埌" + "鎻愮ず锛氶潪褰撳墠鐜妭锛岃鍒�" + InoutConstant.getProcessName( param.getType(), result.getProgress()), result); - } - } - - // 鏍规嵁褰撳墠鏁版嵁鍒ゆ柇鏄惁鎺ㄩ�� - inoutService.notifyWeb(result); - - //涓哄綋鍓嶆暟鎹坊鍔犲寲楠岄」鐩拰姘村垎鍜屾潅璐ㄧ殑鍖栭獙缁撴灉,鐢ㄤ簬鍑哄叆搴撳鎵i噸璁$畻 - if (InoutConstant.TYPE_IN.equals(result.getType())) { - List<CheckItemData> checkItemDataList = inoutService.getCheckCache(result.getCompanyId(), result.getCheckId()); - result.setCheckItems(checkItemDataList); - if (null != checkItemDataList && checkItemDataList.size() > 0) { - for (CheckItemData checkItem : checkItemDataList) { - if (StringUtils.isEmpty(checkItem.getValue())) { - continue; - } - -// if (InoutConstant.CHECK_ITEM_C01.equals(checkItem.getStandardId())) { -// result.setWet(Double.valueOf(checkItem.getValue())); -// } -// if (InoutConstant.CHECK_ITEM_C02.equals(checkItem.getStandardId())) { -// result.setImpurity(Double.valueOf(checkItem.getValue())); -// } - } } } @@ -173,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)) { @@ -241,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())) { @@ -249,7 +218,7 @@ "褰撳墠搴撳尯鏈厤缃叆搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳閰嶇疆銆�", data); } - data = updateInBasicInfo(data, inoutSysConf); + data = updateBasicInfo(data, inoutSysConf); // 濡傛灉褰撳墠鑺傜偣鏄敞鍐岋紝鍒欓渶瑕侀獙璇佷笅锛屾槸鍚︽湁涓哄畬鎴愮殑娴佺▼鍦ㄦ墽琛屼腑 if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) { @@ -347,7 +316,7 @@ // 鏇存柊涓嬩竴涓姸鎬佸拰鍩烘湰淇℃伅 if (InoutConstant.PROGRESS_CHECK.equals(progressData.getProgress())) { - progressData = updateInBasicInfo(progressData, null); + progressData = updateBasicInfo(progressData, null); // 鑻ュ寲楠岀粨鏋滀笉鍚堟牸锛屽垽鏂厤缃悗缁祦绋� if (InoutConstant.STATUS_UNPASS.equals(progressData .getCheckStatus())) { @@ -355,10 +324,7 @@ } } 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()); } @@ -384,15 +350,6 @@ progressData.setNoticeId(data.getNoticeId()); } -// // 鍥炲~姘村垎鍜屾潅璐� -// if (checkResult.getWet() > 0) { -// progressData.setWet(checkResult.getWet()); -// } -// -// if (checkResult.getImpurity() > 0) { -// progressData.setImpurity(checkResult.getImpurity()); -// } - String msg = inoutService.updateData(progressData); if (null != msg) { @@ -412,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)) { @@ -427,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); @@ -474,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()); @@ -600,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); } @@ -672,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); +// } /** * 鍒犻櫎骞跺畬鎴� @@ -798,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)); } @@ -814,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)); @@ -888,7 +792,6 @@ // 鏇存柊鏁版嵁 inoutService.updateData(data); - // this.autoCheckByUpdate(data, record); return null; } @@ -1002,9 +905,6 @@ if (StringUtils.isEmpty(data.getDepotId())) { return "璇峰~鍐欎粨搴撲俊鎭紒"; } -// if (StringUtils.isEmpty(data.getCustomerId())) { -// return "璇峰~鍐欏線鏉ュ崟浣嶄俊鎭紒"; -// } if (StringUtils.isEmpty(data.getFoodYear())) { return "璇峰~鍐欑伯椋熷勾浠戒俊鎭紒"; } @@ -1027,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); } /** @@ -1076,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); @@ -1104,4 +982,269 @@ 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); + } + + + /** + * 鏍规嵁鏉′欢鑾峰彇鎵︽牱鏁版嵁 + * + * @param param + * @return + */ + public PageResponse<Page<InoutCheckData>> pageSampleData(InoutCheckParam param) { + + if (StringUtils.isEmpty(param.getCompanyId())) { + param.setCompanyId(ContextUtil.getCompanyId()); + } + if (StringUtils.isEmpty(param.getDeptId())) { + param.setDeptId(ContextUtil.subDeptId(null)); + } + + //鑻ユ煡璇㈡潯浠朵负宸叉墻鏍凤紝鍒欐祦绋嬬疆绌猴紱鑻ユ湭鎵︽牱锛屽垯娴佺▼涓嶅鐞嗭紝浠嶄负鎵︽牱鍖栭獙娴佺▼(CHECK) + if (!"NONE".equals(param.getSampleStatus())) { + param.setProgress(null); + } + + //鑾峰彇鎵︽牱鏁版嵁 + Page<InoutCheckData> sampleList = inoutService.pageSampleData(param); + + + if (null == sampleList.getRecords() || sampleList.getRecords().isEmpty()) { + return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), + "鑾峰彇鍒版暟鎹俊鎭负绌�"); + } + return new PageResponse<>(RespCodeEnum.CODE_0000, sampleList); + } + + @Transactional(rollbackFor = Exception.class) + public PageResponse<InoutCheckData> updateSampleData(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(), + "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼"); + } + + //鎵︽牱鏃堕棿鍜屾墻鏍蜂汉 + 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); + } + + return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛"); + } catch (Exception e) { + log.error("鍚庡彴寮傚父:{}", e); + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), + "鍚庡彴寮傚父锛�" + e.getMessage(), null); + } + } + + /** + * @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(), + "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼"); + } + 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); + } + //TODO 鏇存柊鍖栭獙椤逛俊鎭� + + 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