From 7f5ecaf7dbd07e218fbda575e45d8264a560a1e6 Mon Sep 17 00:00:00 2001 From: jiazx0107@163.com <jiazx0107@163.com> Date: 星期一, 05 六月 2023 13:50:59 +0800 Subject: [PATCH] 出入库优化-称重页面逻辑优化完成 --- igds-web/src/main/resources/templates/admin/inout/in-weight.html | 49 +-- igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java | 163 ++++++++++--- igds-web/src/main/resources/static/admin/inout/in-weight.js | 102 +++----- igds-databoard/src/main/java/com/ld/igds/databoard/controller/DataboardController.java | 30 ++ igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java | 151 +++--------- igds-inout/src/main/java/com/ld/igds/inout/controller/InoutReportController.java | 6 igds-inout/src/main/java/com/ld/igds/inout/manager/InoutDeviceManager.java | 18 + igds-web/src/main/resources/static/admin/inout/inout-print.js | 34 +- igds-inout/src/main/java/com/ld/igds/inout/manager/InoutCommonManager.java | 8 igds-inout/src/main/java/com/ld/igds/inout/service/InoutService.java | 37 +-- igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java | 31 ++ igds-core/src/main/java/com/ld/igds/check/dto/CheckUpdateResult.java | 19 igds-core/src/main/java/com/ld/igds/check/CheckStandardManager.java | 21 + 13 files changed, 347 insertions(+), 322 deletions(-) diff --git a/igds-core/src/main/java/com/ld/igds/check/CheckStandardManager.java b/igds-core/src/main/java/com/ld/igds/check/CheckStandardManager.java index c39d885..2b2c5cd 100644 --- a/igds-core/src/main/java/com/ld/igds/check/CheckStandardManager.java +++ b/igds-core/src/main/java/com/ld/igds/check/CheckStandardManager.java @@ -3,7 +3,6 @@ import com.ld.igds.check.dto.CheckItemData; import com.ld.igds.check.dto.CheckUpdateResult; import com.ld.igds.check.service.CoreCheckStandardService; -import com.ld.igds.inout.InoutConstant; import com.ld.igds.util.ContextUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -65,14 +64,22 @@ item.setUpperLimit(0.0); } - //姘村垎淇℃伅鍥炲~ - if (InoutConstant.CHECK_ITEM_C01.equals(item.getStandardId()) || InoutConstant.CHECK_ITEM_C020101.equals(item.getStandardId())) { - if(null != item.getValue()) result.setWet(Double.valueOf(item.getValue())); + + if (item.getDeNum() > 0) { + result.setDeSum(result.getDeSum() + item.getDeNum()); } - //鏉傝川淇℃伅鍥炲~ - if (InoutConstant.CHECK_ITEM_C02.equals(item.getStandardId()) || InoutConstant.CHECK_ITEM_C01010301.equals(item.getStandardId())) { - if(null != item.getValue()) result.setImpurity(Double.valueOf(item.getValue())); + if (item.getAddNum() > 0) { + result.setAddSum(result.getAddSum() + item.getAddNum()); } + + if (item.getAddPrice() > 0) { + result.setAddPriceSum(result.getAddPriceSum() + item.getAddPrice()); + } + + if (item.getDePrice() > 0) { + result.setDePriceSum(result.getDePriceSum() + item.getDePrice()); + } + //鍏堟洿鏂帮紝鏇存柊澶辫触鍒欐柊澧� int i = checkStandardService.updateCheckItem(item); if (i < 1) { diff --git a/igds-core/src/main/java/com/ld/igds/check/dto/CheckUpdateResult.java b/igds-core/src/main/java/com/ld/igds/check/dto/CheckUpdateResult.java index 68e8b42..dce9cf7 100644 --- a/igds-core/src/main/java/com/ld/igds/check/dto/CheckUpdateResult.java +++ b/igds-core/src/main/java/com/ld/igds/check/dto/CheckUpdateResult.java @@ -11,17 +11,14 @@ @Data public class CheckUpdateResult { - /** - * 姘村垎姣斾緥 - */ - private double wet; - /** - * 鏉傝川姣斾緥 - */ - private double impurity; - + //鎵i噸鍚堣 + private double deSum = 0.0; + //澧為噸鍚堣 + private double addSum = 0.0; + //鎵d环鍚堣 + private double dePriceSum = 0.0; + //澧炰环鍚堣 + private double addPriceSum = 0.0; private String msg; - - } diff --git a/igds-databoard/src/main/java/com/ld/igds/databoard/controller/DataboardController.java b/igds-databoard/src/main/java/com/ld/igds/databoard/controller/DataboardController.java index 4c5e2f3..2ef17de 100644 --- a/igds-databoard/src/main/java/com/ld/igds/databoard/controller/DataboardController.java +++ b/igds-databoard/src/main/java/com/ld/igds/databoard/controller/DataboardController.java @@ -292,7 +292,19 @@ @RequestMapping("/init-inout-data") @ResponseBody public PageResponse<String> initInoutData(@RequestBody BaseParam param) { - inoutCommonManager.initInoutScreen(param.getDeptId()); + + if (null == param.getCompanyId()) { + IUser user = ContextUtil.getLoginUser(); + + param.setCompanyId(user.getCompanyId()); + + if (null == param.getDeptId()) { + param.setDeptId(ContextUtil.subDeptId(user)); + } + } + + inoutCommonManager.initInoutScreen(param.getCompanyId(),param.getDeptId()); + return new PageResponse<String>(RespCodeEnum.CODE_0000.getCode(), "鎴愬姛锛�"); } @@ -373,7 +385,21 @@ @RequestMapping("/init-check-data") @ResponseBody public PageResponse<String> initCheckData(@RequestBody BaseParam param) { - inoutCommonManager.initInoutScreen(param.getCompanyId()); + + if (null == param.getCompanyId()) { + IUser user = ContextUtil.getLoginUser(); + + param.setCompanyId(user.getCompanyId()); + + if (null == param.getDeptId()) { + param.setDeptId(ContextUtil.subDeptId(user)); + } + } + + + inoutCommonManager.initInoutScreen(param.getCompanyId(),param.getDeptId()); + + return new PageResponse<String>(RespCodeEnum.CODE_0000.getCode(), "鎴愬姛锛�"); } diff --git a/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java b/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java index 72a7b16..c5d050f 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java @@ -1,6 +1,5 @@ package com.ld.igds.inout.controller; -import ch.qos.logback.classic.pattern.ClassNameOnlyAbbreviator; import com.bstek.bdf2.core.business.IUser; import com.bstek.bdf2.core.model.DefaultDept; import com.ld.igds.check.dto.CheckItemData; @@ -322,6 +321,7 @@ /** * 鍑哄簱鐧昏 + * * @param sort 琛ㄧず浣跨敤鐨勫嚭鍏ュ簱璁惧閰嶅鍙凤紝涓嶄紶閫掗粯璁や负1 * @return */ @@ -449,7 +449,7 @@ view.addObject("type", InoutConstant.TYPE_OUT); // 浠撳簱鍒楄〃鍋氫笅鎷夋浣跨敤 - List<SimpleDepot> listDepot = commonManager.getCacheDeptOut(user.getCompanyId(),deptId); + List<SimpleDepot> listDepot = commonManager.getCacheDeptOut(user.getCompanyId(), deptId); view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot); //鍑哄簱娴佺▼ @@ -486,15 +486,15 @@ IUser user = ContextUtil.getLoginUser(); - String deptId = ContextUtil.subDeptId(user); + String deptId = ContextUtil.subDeptId(user); view.addObject(Constant.MODEL_KEY_LOGIN_USER, user); view.addObject("bizType", BizType.INOUT_OUT.getCode()); - view.addObject("deptId",deptId); + view.addObject("deptId", deptId); view.addObject("type", InoutConstant.TYPE_OUT); // 浠撳簱鍒楄〃鍋氫笅鎷夋浣跨敤 - List<SimpleDepot> listDepot = commonManager.getCacheDeptOut(user.getCompanyId(),deptId); + List<SimpleDepot> listDepot = commonManager.getCacheDeptOut(user.getCompanyId(), deptId); view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot); @@ -528,7 +528,7 @@ */ @RequestMapping("/inout-query") public PageResponse<InoutData> inoutQuery(@RequestBody InoutParam param) { - if(null == param.getCompanyId()) param.setCompanyId(ContextUtil.getCompanyId()); + if (null == param.getCompanyId()) param.setCompanyId(ContextUtil.getCompanyId()); return inoutManager.inoutQuery(param); } @@ -604,6 +604,25 @@ } /** + * 鍑哄叆搴撶О閲嶇幆鑺傛彁浜� + * + * @param data + * @return + */ + @RequestMapping("/submit-weight") + @Transactional + public PageResponse<InoutData> submitWeight(@RequestBody InoutData data) throws Exception { + + if(null == data.getJjlx()) data.setJjlx("0"); + + if (InoutConstant.TYPE_IN.equals(data.getType())) { + return inoutManager.submitWeightIn(data); + } else { + return inoutManager.submitWeightOut(data); + } + } + + /** * 鍗″洖鏀堕〉闈㈡彁浜わ紝濡傛灉鏄甯告祦绋嬪崱鍥炴敹鍒欒蛋姝e父瀹屾垚娴佺▼锛屽惁鍒欐墽琛屽垹闄ら�昏緫骞跺洖鏀跺崱 * * @param data diff --git a/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutReportController.java b/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutReportController.java index 33e6d42..6531a9f 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutReportController.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/controller/InoutReportController.java @@ -18,7 +18,7 @@ */ @Slf4j @RestController -@RequestMapping("basic/inout-report") +@RequestMapping("basic/inout/report") public class InoutReportController { @Autowired @@ -31,7 +31,7 @@ * @param data * @return */ - @RequestMapping("/inout-bill-weight") + @RequestMapping("/bill-weight") public PageResponse<String> inoutWeightBill(@RequestBody InoutData data) { try { String html; @@ -45,7 +45,7 @@ return new PageResponse<>(RespCodeEnum.CODE_0000, html); } catch (Exception e) { log.error("鍚庡彴寮傚父:{}", e); - return new PageResponse<String>(RespCodeEnum.CODE_1111.getCode(), + return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "鍚庡彴寮傚父锛�" + e.getMessage()); } } diff --git a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutCommonManager.java b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutCommonManager.java index da03cd4..3bba0c7 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutCommonManager.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutCommonManager.java @@ -159,10 +159,10 @@ * * @param deptId */ - public void initInoutScreen(String deptId) { - if (StringUtils.isEmpty(deptId)) - deptId = ContextUtil.subDeptId(null); - inoutService.initInoutScreen(deptId); + public void initInoutScreen(String companyId, String deptId) { + if (StringUtils.isEmpty(companyId)) return; + if (StringUtils.isEmpty(deptId)) return; + inoutService.notifyToScreen(companyId, deptId, null); } public List<InoutData> getListInoutCache(String deptId) { diff --git a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutDeviceManager.java b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutDeviceManager.java index 2d36582..81ce32e 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutDeviceManager.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutDeviceManager.java @@ -144,7 +144,7 @@ ApiInoutService inoutApiService = apiInoutManager.getApiService(conf.getProtocol()); - // return inoutApiService.noticeWeightDone(apiData); TODO + // return inoutApiService.noticeWeightDone(apiData); TODO return null; } @@ -246,7 +246,7 @@ for (InoutConf conf : list) { apiData = new ApiInoutData(conf); apiData.setPlateNum(imgDto.getPlateNum()); - // inoutApiService.addWhitePlate(apiData); + // inoutApiService.addWhitePlate(apiData); } } @@ -265,7 +265,7 @@ apiData = new ApiInoutData(conf); apiData.setPlateNum(data.getPlateNum()); - // inoutApiService.delWhitePlate(apiData); TODO + // inoutApiService.delWhitePlate(apiData); TODO } } @@ -427,4 +427,16 @@ } + /** + * 鏍规嵁鍑哄叆搴撲俊鎭紝鎺у埗鍑哄叆搴撴帶鍒跺櫒 + * + * @param data + * @param curProgress + * @param nextProgress + */ + public void controlWeight(InoutData data, String curProgress, String nextProgress) { + + //TODO + + } } 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 a0e1cad..ac4dce1 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 @@ -397,14 +397,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); @@ -858,7 +864,6 @@ // 鏇存柊鏁版嵁 inoutService.updateData(data); - // this.autoCheckByUpdate(data, record); return null; } @@ -972,9 +977,6 @@ if (StringUtils.isEmpty(data.getDepotId())) { return "璇峰~鍐欎粨搴撲俊鎭紒"; } -// if (StringUtils.isEmpty(data.getCustomerId())) { -// return "璇峰~鍐欏線鏉ュ崟浣嶄俊鎭紒"; -// } if (StringUtils.isEmpty(data.getFoodYear())) { return "璇峰~鍐欑伯椋熷勾浠戒俊鎭紒"; } @@ -997,28 +999,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); } /** @@ -1074,6 +1054,116 @@ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data); } + public PageResponse<InoutData> submitWeightIn(InoutData data) throws Exception { + //鑾峰彇绯荤粺鍙傛暟閰嶇疆 + InoutSysConf inoutSysConf = inoutManagerService.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); + + if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(curProgress)) { + data.setEmptyWeightTime(new Date()); + data.setEmptyWeightUser(ContextUtil.getLoginUserCName()); + data.setProgress(nextProgress); + + } + if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(nextProgress)) { + data.setFullWeightTime(new Date()); + data.setFullWeightUser(ContextUtil.getLoginUserCName()); + data.setProgress(nextProgress); + } + + + //濡傛灉涓嬩竴涓暟鎹姸鎬�=娴佺▼缁撴潫 + if (InoutConstant.PROGRESS_RECORD.equals(nextProgress)) { + data.setCompleteTime(DateUtils.addMinutes(new Date(), 2)); + data.setCompleteUser(ContextUtil.getLoginUserCName()); + data.setProgress(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 = inoutManagerService.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); + + if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(curProgress)) { + data.setEmptyWeightTime(new Date()); + data.setEmptyWeightUser(ContextUtil.getLoginUserCName()); + data.setProgress(nextProgress); + + } + if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(nextProgress)) { + data.setFullWeightTime(new Date()); + data.setFullWeightUser(ContextUtil.getLoginUserCName()); + data.setProgress(nextProgress); + } + + + //濡傛灉涓嬩竴涓暟鎹姸鎬�=娴佺▼缁撴潫 + if (InoutConstant.PROGRESS_RECORD.equals(nextProgress)) { + data.setCompleteTime(DateUtils.addMinutes(new Date(), 2)); + data.setCompleteUser(ContextUtil.getLoginUserCName()); + data.setProgress(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); + } + /** * 鏍规嵁鏉′欢鑾峰彇鎵︽牱鏁版嵁 @@ -1107,7 +1197,7 @@ } @Transactional(rollbackFor = Exception.class) - public PageResponse<InoutCheckData> updateSampleData(InoutCheckData data){ + public PageResponse<InoutCheckData> updateSampleData(InoutCheckData data) { try { // 鑾峰彇涓氬姟鏁版嵁淇℃伅 @@ -1125,10 +1215,10 @@ } //鎵︽牱鏃堕棿鍜屾墻鏍蜂汉 - if(StringUtils.isEmpty(data.getSampleUser())){ + if (StringUtils.isEmpty(data.getSampleUser())) { data.setSampleUser(ContextUtil.getLoginUserCName()); } - if(null == data.getSampleTime()){ + if (null == data.getSampleTime()) { data.setSampleTime(new Date()); } String msg = inoutService.updateSampleData(data); @@ -1192,7 +1282,7 @@ } @Transactional(rollbackFor = Exception.class) - public PageResponse<InoutCheckData> updateCheckData(InoutCheckData data){ + public PageResponse<InoutCheckData> updateCheckData(InoutCheckData data) { try { // 鑾峰彇涓氬姟鏁版嵁淇℃伅 @@ -1221,10 +1311,10 @@ data.setCheckStatus(curData.getCheckStatus()); //鍖栭獙浜恒�佸寲楠屾椂闂� - if(StringUtils.isEmpty(data.getCheckUser())){ + if (StringUtils.isEmpty(data.getCheckUser())) { data.setCheckUser(ContextUtil.getLoginUserCName()); } - if(null == data.getCheckTime()){ + if (null == data.getCheckTime()) { data.setCheckTime(new Date()); } @@ -1243,4 +1333,5 @@ } + } \ No newline at end of file diff --git a/igds-inout/src/main/java/com/ld/igds/inout/service/InoutService.java b/igds-inout/src/main/java/com/ld/igds/inout/service/InoutService.java index b35779e..539d8e4 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/service/InoutService.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/service/InoutService.java @@ -101,28 +101,12 @@ String toComplete(InoutParam param) throws Exception; /** - * 灏嗗嚭鍏ュ簱淇℃伅瀛樻斁鍒颁复鏃剁紦瀛樹腑锛岃繖涓紦瀛橀粯璁ゅ彧淇濈暀2澶╂椂闂� - * - * @param data - */ - void addInoutCache(InoutData data); - - /** - * 鏇存柊鍑哄叆搴撶紦瀛樹俊鎭� + * 灏嗗嚭鍏ュ簱娴佹按淇℃伅鏀惧埌缂撳瓨涓紝鍖呮嫭杩涜涓殑鍜屽凡缁忓畬鎴愮殑 * * @param data */ void updateInoutCache(InoutData data); - /** - * 浠庣紦瀛樹腑鍒犻櫎鍑哄叆搴撶紦瀛� - * - * @param deptId - * @param type - * @param id - * @param addToComplete - */ - void delInoutFromCache(String deptId, String type, String id, boolean addToComplete); /** * 鑾峰彇鍑哄叆搴撳垪琛ㄤ俊鎭紝缂撳瓨鏃堕棿鏄�48灏忔椂 @@ -140,13 +124,6 @@ */ InoutData getFromInoutCache(InoutParam param); - /** - * 鍒濆鍖栧嚭鍏ュ簱澶у睆鏁版嵁锛屼粎浠呭彂閫� - * - * @param deptId - */ - void initInoutScreen(String deptId); - /** * 鏍规嵁鏁版嵁杩涜鎺ㄩ�� @@ -154,6 +131,16 @@ * @param result */ void notifyWeb(InoutData result); + + + /** + * 鎺ㄩ�佸ぇ灞� + * + * @param companyId + * @param deptId + * @param progress 鍙互涓虹┖ + */ + void notifyToScreen(String companyId, String deptId, String progress); /** * 蹇�熷畬鎴愭祦绋嬩腑鐨勮鍗� @@ -255,6 +242,7 @@ /** * 鏇存柊鎵︽牱淇℃伅 + * * @param data * @return * @throws Exception @@ -271,6 +259,7 @@ /** * 鏇存柊鍖栭獙淇℃伅 + * * @param data * @return * @throws Exception diff --git a/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java b/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java index b7eb6ed..460f565 100644 --- a/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java +++ b/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java @@ -5,6 +5,7 @@ import com.ld.igds.common.CoreCommonService; import com.ld.igds.constant.BizType; import com.ld.igds.constant.Constant; +import com.ld.igds.constant.FoodType; import com.ld.igds.constant.RedisConst; import com.ld.igds.data.CommonData; import com.ld.igds.data.Page; @@ -100,10 +101,9 @@ return "娌℃湁鑾峰彇鍒拌鍒犻櫎鏁版嵁鐨処D锛屾棤娉曞垹闄わ紒"; } - // 缂撳瓨涓垹闄� - this.delInoutFromCache(param.getDeptId(), param.getType(), param.getId(), false); - inoutMapper.deleteData(param); + + delInoutFromCache(param.getDeptId(), param.getType(), param.getId()); return null; } @@ -113,8 +113,9 @@ if (StringUtils.isEmpty(param.getCompanyId())) { param.setCompanyId(ContextUtil.getCompanyId()); } + // 缂撳瓨涓垹闄� - this.delInoutFromCache(param.getDeptId(), param.getType(), param.getId(), false); + delInoutFromCache(param.getDeptId(), param.getType(), param.getId()); param.setProgress(InoutConstant.PROGRESS_RECORD); param.setRecordStatus(InoutConstant.RECORD_STATUS_ERROR); @@ -157,7 +158,7 @@ inoutMapper.insertData(data); - this.addInoutCache(data); + updateInoutCache(data); } catch (Exception e) { log.error("------------鍑哄叆搴撴墽琛屼繚瀛樺嚭閿�---{}", e); @@ -183,17 +184,8 @@ inoutMapper.updateData(newData); - //濡傛灉鏄畬鎴愮姸鎬佷笉鍦ㄨ繘琛屽悗鏈熷鐞嗭紝鍗曠嫭璧癱omplete鏂规硶 - if (InoutConstant.PROGRESS_RECORD.equals(newData.getProgress())) { - return null; - } - - // 鏇存柊绶╁瓨 - if (InoutConstant.PROGRESS_RECORD.equals(newData.getProgress())) { - this.delInoutFromCache(newData.getDeptId(), newData.getType(), newData.getId(), true); - } else { - this.updateInoutCache(newData); - } + //鏇存柊缂撳瓨 + updateInoutCache(newData); return null; } @@ -249,16 +241,6 @@ return records; } -// @Override -// public InoutData getLastRecord(InoutParam param) { -// return inoutMapper.getLastRecord(param); -// } - -// @Override -// public int updateCuStorage(InoutParam param) { -// return inoutMapper.updateCuStorage(param); -// } - @Override public String validate(String intelCard, String plateNum) { InoutParam param = new InoutParam(); @@ -281,16 +263,11 @@ param.setCompanyId(ContextUtil.getCompanyId()); } - if (null == param.getFoodType()) { - // 鏍规嵁浠撳簱淇℃伅鑾峰彇缂撳瓨 - Depot depot = commonService.getCacheDepot(param.getCompanyId(), param.getDepotId()); - param.setFoodType(depot.getFoodType()); - } - // 娓呴櫎缂撳瓨 - this.delInoutFromCache(param.getDeptId(), param.getType(), param.getId(), true); + this.delInoutFromCache(param.getDeptId(), param.getType(), param.getId()); inoutMapper.toComplete(param); + return null; } @@ -344,43 +321,34 @@ data.setFoodType(depot.getFoodType()); } - // 娓呴櫎缂撳瓨 - this.delInoutFromCache(data.getDeptId(), data.getType(), data.getId(), false); - inoutMapper.updateData(data); + + updateInoutCache(data); return null; } @Override - public void addInoutCache(InoutData data) { - data.setFiles(null); - data.setCheckItems(null); - - this.setInoutCache(data.getDeptId(), data); - - // 鎺ㄩ�佸埌澶у睆 - List<InoutData> list = this.getListInoutCache(data.getDeptId()); - - this.notifyToScreen(data.getDeptId(), list, null); - } - - @Override public void updateInoutCache(InoutData data) { + data.setFiles(null); data.setCheckItems(null); - this.setInoutCache(data.getDeptId(), data); + if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { - // 鎺ㄩ�佸埌澶у睆 - List<InoutData> list = this.getListInoutCache(data.getDeptId()); - List<InoutData> completeList = this.getCompleteListInoutCache(data.getDeptId()); + delInoutFromCache(data.getDeptId(), data.getType(), data.getId()); - this.notifyToScreen(data.getCompanyId(), list, completeList); + setCompleteInoutCache(data.getDeptId(), data); + + } else { + setInoutCache(data.getDeptId(), data); + } + //鎺ㄩ�佸ぇ灞� + notifyToScreen(data.getCompanyId(), data.getDeptId(), data.getProgress()); } - @Override - public void delInoutFromCache(String deptId, String type, String id, boolean addToComplete) { + + public void delInoutFromCache(String deptId, String type, String id) { if (StringUtils.isEmpty(deptId)) { return; } @@ -390,44 +358,14 @@ if (StringUtils.isEmpty(id)) { return; } - //鍒犻櫎鏈畬鎴愭祦绋嬬殑缂撳瓨 + //浠庢湭瀹屾垚鍒楄〃涓垹闄� String key = this.buildInoutKey(deptId, InoutConstant.KEY_INOUT_LIST, type, id); - InoutData inoutData = (InoutData) redisUtil.get(key); redisUtil.del(key); - List<InoutData> list = this.getListInoutCache(deptId); - - //鍒犻櫎宸插畬鎴愭祦绋嬬殑缂撳瓨 - key = this.buildInoutKey(deptId, InoutConstant.KEY_INOUT_COMPLETE_LIST, type, id); - redisUtil.del(key); - List<InoutData> completeList = this.getCompleteListInoutCache(deptId); - - if (addToComplete) { - addInoutCompleteCache(inoutData); - completeList = this.getCompleteListInoutCache(deptId); - } - - // 閫氱煡鍒板ぇ灞� - notifyToScreen(deptId, list, completeList); - } - - /** - * 娣诲姞鍒板凡缁忓畬鎴愮殑闃熷垪涓� - * - * @param data - */ - public void addInoutCompleteCache(InoutData data) { - - if (null == data.getCompleteTime()) { - data.setCompleteTime(new Date()); - } - if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { - data.setProgress(InoutConstant.PROGRESS_RECORD); - } - this.setCompleteInoutCache(data.getDeptId(), data); } @Override public List<InoutData> getListInoutCache(String deptId) { + String pattern = RedisConst.buildKey(deptId, InoutConstant.KEY_INOUT_LIST); Set<String> keys = redisUtil.keys(pattern); if (null == keys || keys.isEmpty()) { @@ -484,19 +422,6 @@ } } return null; - } - - @Override - public void initInoutScreen(String deptId) { - if (null == deptId) { - deptId = ContextUtil.subDeptId(null); - } - - List<InoutData> curList = this.getListInoutCache(deptId); - List<InoutData> complateList = this.getCompleteListInoutCache(deptId); - - notifyToScreen(deptId, curList, complateList); - } @Override @@ -695,7 +620,6 @@ */ private void setCompleteInoutCache(String deptId, InoutData data) { String key = this.buildInoutKey(deptId, InoutConstant.KEY_INOUT_COMPLETE_LIST, data.getType(), data.getId()); - //璁剧疆缂撳瓨鍒扮浜屽ぉ鍑屾櫒(璁$畻褰撳墠鏃堕棿鍒扮浜屽ぉ鍑屾櫒鐨勬椂闂村樊绉掓暟) redisUtil.set(key, data, DateUtil.getNowToNextDaySeconds()); } @@ -703,12 +627,17 @@ /** * 鎺ㄩ�佸埌澶у睆锛屽垽鏂彧鏈夊綋澶у睆鍦ㄧ嚎鏃跺�欐墠澶勭悊褰撳墠閫昏緫锛岄伩鍏嶉〉闈㈠崱椤匡紝璋冪敤瀛愪换鍔″畬鎴愭帹閫� * - * @param deptId - * @param curList 鏈畬鎴愭祦绋嬩釜鏁� - * @param completeList 宸茬粡瀹屾垚娴佺▼涓暟 + * @param companyId 缁勭粐缂栧彿 + * @param deptId 鍒嗗簱缂栧彿 + * @param progress 娴佽浆鑺傜偣 */ - private void notifyToScreen(String deptId, List<InoutData> curList, - List<InoutData> completeList) { + public void notifyToScreen(String companyId, String deptId, String progress) { + + // 鎺ㄩ�佸埌澶у睆 + List<InoutData> curList = this.getListInoutCache(deptId); + + List<InoutData> completeList = this.getCompleteListInoutCache(deptId); + if (null == WebSocketServer.contextOnLineMap.get(BizType.SCREEN .getCode())) { @@ -732,13 +661,11 @@ || WebSocketServer.contextOnLineMap.get(BizType.SCREEN_CHECK .getCode())) { - if (null == completeList) { - completeList = this.getCompleteListInoutCache(deptId); - } + // 鍒涘缓涓�涓瓙浠诲姟杩涜鎺ㄩ�佷俊鎭� - FutureTask<String> futureTask = new FutureTask<>( - new NotifyScreenTask(curList, completeList, deptId)); + FutureTask<String> futureTask = new FutureTask<>(new NotifyScreenTask(curList, completeList, deptId)); + ExecutorService executorService = Executors.newCachedThreadPool(); executorService.submit(futureTask); executorService.shutdown(); diff --git a/igds-web/src/main/resources/static/admin/inout/in-weight.js b/igds-web/src/main/resources/static/admin/inout/in-weight.js index 86e82ee..b2cf50b 100644 --- a/igds-web/src/main/resources/static/admin/inout/in-weight.js +++ b/igds-web/src/main/resources/static/admin/inout/in-weight.js @@ -285,7 +285,7 @@ // 鐐瑰嚮鎵撳嵃锛岀郴缁熷垽鏂槸鍚﹀凡缁忔墽琛屽畬鎴愶紝濡傛灉宸茬粡瀹屾垚锛岀洿鎺ユ墦鍗帮紝濡傛灉鏈畬鎴愬垯鍏堟墽琛屽畬鎴� function printBill() { if (!recordData) { - layer.alert("娌℃湁鑾峰彇鍒颁笟鍔℃暟鎹紝涓嶆敮鎸佹墦鍗帮紒"); + alertError("娌℃湁鑾峰彇鍒颁笟鍔℃暟鎹紝鎵撳嵃琚嫆缁濓紒"); return; } // 浠庡悗鍙拌幏鍙栨ā鐗堝苟鎵撳嵃 @@ -293,34 +293,25 @@ // 鍚堝苟鏇存柊鐣跺墠缂栬緫鏁版嵁 Object.assign(recordData, data); - printBillStep2(); -} - -// 鐐瑰嚮鎵撳嵃锛屽厛鎵ц绯荤粺榛樿鎵ц瀹屾垚鍗″洖鏀� -function printBillStep2() { var index = layer.load(); $.ajax({ type: "POST", - url: "../../basic/inout-report/inout-bill-weight", + url: "../../basic/inout/report/bill-weight", dataType: "json", contentType: "application/json;charset=UTF-8", data: JSON.stringify(recordData), success: function (result) { layer.close(index); if (result.code != "0000") { - layer.msg(result.msg); + alertError(result.msg); } else { layer.msg("寮�濮嬫覆鏌撴墦鍗板崟鈥︹��"); - if (companyId && companyId == "5016") { - print5016Weight(result.data); - } else { - printWeight(result.data); - } + printWeight(result.data); } }, error: function () { layer.close(index); - layer.msg("鑾峰彇鎵撳嵃妯$増澶辫触锛岃鑱旂郴绠$悊鍛樻煡鐪嬪師鍥狅紒锛�"); + alertError("鑾峰彇鎵撳嵃妯$増澶辫触锛岃鑱旂郴绠$悊鍛樻煡鐪嬪師鍥�"); } }); } @@ -331,19 +322,13 @@ form.render(); recordData = null; weightDto.weight = 0.0; - $("#weightValue").text("0.0"); $("#img_scale_statule").attr("src", "../../static/images/icon-red.png"); - - //绉伴噸鍙互澶嶇敤 - $("#btn-weight").removeClass("layui-btn-disabled"); - $("#btn-weight").attr("disabled", false); } function flushPage() { layer.confirm('纭畾瑕佸埛鏂伴〉闈㈠悧锛�', {icon: 3, title: '鎻愮ず'}, function (index) { resetForm(); - layer.msg("椤甸潰閲嶇疆瀹屾垚锛岃閲嶆柊鎿嶄綔鈥︹��"); layer.close(index); }); } @@ -424,41 +409,49 @@ // 褰撳墠瀹屾垚 function submit() { - if (null == recordData) { - notify("娌℃湁鏁版嵁鍙互鎻愪氦", null); + if (!recordData) { + alertError("娌℃湁涓氬姟鏁版嵁淇℃伅锛屾墽琛岃鎷掔粷"); return; } var data = form.val("form-data"); if (!data.depotId) { - notify("瑁呭嵏浠撳簱蹇呴』濉啓", null); + alertError("鎻愮ず锛氳鍗镐粨搴撳繀濉�"); return; } + if (!data.customerName) { + alertError("鎻愮ず锛氬鎴峰悕绉板繀濉�"); + return; + } + // 鏍¢獙-鍏ュ簱婊¤溅绉伴噸 if (InoutProgress.WEIGHT_FULL == recordData.progress) { if (data.fullWeight <= 0.0) { - notify("婊¤溅绉伴噸淇℃伅蹇呭~锛侊紒", null); - return; - } - if (!data.customerName) { - notify("瀹㈡埛鍚嶇О蹇呭~锛侊紒", null); - return; - } - } else { - if (data.emptyWeight <= 0.0) { - notify("绌鸿溅绉伴噸淇℃伅蹇呭~锛侊紒", null); - return; - } - if (!data.foodVariety) { - notify("绮鍝佺蹇呭~锛侊紒", null); - return; - } - if (!data.settleWeight || data.settleWeight <= 0.0) { - notify("缁撶畻閲嶉噺鍚堣锛岃鏍稿锛侊紒", null); + alertError("鎻愮ず锛氭弧杞︾О閲嶄俊鎭繀濉�"); return; } } - // 鍚堝苟鏇存柊鐣跺墠缂栬緫鏁版嵁 + if (InoutProgress.WEIGHT_EMPTY == recordData.progress) { + if (data.emptyWeight <= 0.0) { + alertError("鎻愮ず锛氱┖杞︾О閲嶄俊鎭繀濉�"); + return; + } + if (!data.foodVariety) { + alertError("鎻愮ず锛氱伯椋熷搧绉嶅繀濉�"); + return; + } + + if (!data.settleWeight || data.settleWeight <= 0.0) { + alertError("缁撶畻閲嶉噺涓嶅悎瑙勶紝璇锋牳瀵�"); + return; + } + if (!data.recordWeight || data.recordWeight <= 0.0) { + alertError("鍏ュ簱閲嶉噺涓嶅悎瑙勶紝璇锋牳瀵�"); + return; + } + } + + //鍚堝苟鏁版嵁 Object.assign(recordData, data); // 鑾峰彇鐓х墖 @@ -474,7 +467,7 @@ var index = layer.load(); $.ajax({ type: "POST", - url: "../../basic/inout/inout-next-step", + url: "../../basic/inout/submit-weight", dataType: "json", contentType: "application/json;charset=UTF-8", data: JSON.stringify(recordData), @@ -488,29 +481,8 @@ }, error: function () { layer.close(index); - notify("鎻愪氦澶辫触锛岃閲嶆柊灏濊瘯", null); + alertError("鎻愪氦澶辫触锛岃閲嶆柊灏濊瘯"); } - }); - - //浠ヤ笅閫昏緫涓哄鍔犱竴涓闊抽�氱煡鐨勮皟鐢ㄦ柟娉曪紝涓嶈�冭檻杩斿洖缁撴灉--鍚庡彴璋冪敤 - var curWeight = recordData.fullWeight; - if (InoutProgress.WEIGHT_EMPTY == recordData.progress) { - curWeight = recordData.emptyWeight; - } - var param = { - sort: $("#scaleName").val(), - weight: curWeight, - inoutProgress: recordData.progress, - deptId: recordData.deptId, - companyId: recordData.companyId, - plateNum: recordData.plateNum - }; - $.ajax({ - type: "POST", - url: "../../inout/api/notice-weight-done", - dataType: "json", - contentType: "application/json;charset=UTF-8", - data: JSON.stringify(param) }); } diff --git a/igds-web/src/main/resources/static/admin/inout/inout-print.js b/igds-web/src/main/resources/static/admin/inout/inout-print.js index f2b56c2..8855dc5 100644 --- a/igds-web/src/main/resources/static/admin/inout/inout-print.js +++ b/igds-web/src/main/resources/static/admin/inout/inout-print.js @@ -1,23 +1,21 @@ - /** * 鎵撳嵃杩囩鍗� */ -printWeight = function(htmlStr) { - var LODOP = CLODOP; - LODOP.PRINT_INIT("杩囩鍗�"); - //LODOP.SET_PRINT_PAGESIZE(1, 0, '90mm', "A4"); - LODOP.SET_PRINT_PAGESIZE(1,2100,1400, "A4"); - //LODOP.SET_PRINT_PAGESIZE(3, 2100, '45', "A4"); - LODOP.ADD_PRINT_HTM(0, 0, "100%", "100%", htmlStr); - LODOP.PREVIEW(); - //LODOP.PRINT_DESIGN(); -}; - -print5016Weight = function(htmlStr) { - var LODOP = CLODOP; - LODOP.PRINT_INIT("绉伴噸鍗�"); - LODOP.SET_PRINT_PAGESIZE(1, 1050, 1400, ""); - LODOP.ADD_PRINT_HTM(0, 0, "100%", "100%", htmlStr); - LODOP.PREVIEW(); +printWeight = function (htmlStr) { + var LODOP = CLODOP; + if ("5016" == companyId) { + LODOP.PRINT_INIT("绉伴噸鍗�"); + LODOP.SET_PRINT_PAGESIZE(1, 1050, 1400, ""); + LODOP.ADD_PRINT_HTM(0, 0, "100%", "100%", htmlStr); + LODOP.PREVIEW(); + } else { + LODOP.PRINT_INIT("杩囩鍗�"); + //LODOP.SET_PRINT_PAGESIZE(1, 0, '90mm', "A4"); + LODOP.SET_PRINT_PAGESIZE(1, 2100, 1400, "A4"); + //LODOP.SET_PRINT_PAGESIZE(3, 2100, '45', "A4"); + LODOP.ADD_PRINT_HTM(0, 0, "100%", "100%", htmlStr); + LODOP.PREVIEW(); + //LODOP.PRINT_DESIGN(); + } }; diff --git a/igds-web/src/main/resources/templates/admin/inout/in-weight.html b/igds-web/src/main/resources/templates/admin/inout/in-weight.html index 01d2c2c..7350385 100644 --- a/igds-web/src/main/resources/templates/admin/inout/in-weight.html +++ b/igds-web/src/main/resources/templates/admin/inout/in-weight.html @@ -138,22 +138,20 @@ <div class="qyzj-btnbox layui-clear"> <div class="rkbk-quick fl"> - <button class="rkbk-quick-btn layui-btn" onclick="showCheck()"> - <i><img th:src="@{../../static/images/icon-hyd.png}"/></i>璐ㄦ淇℃伅 - </button> <button id="btn-weight" class="rkbk-quick-btn layui-btn btn-blue" onclick="weight()"> - <i><img th:src="@{../../static/images/icon-chengzhong.png}"/></i>绉伴噸纭 + <i><img th:src="@{../../static/images/icon-chengzhong.png}"/></i>姝ラ1锛氱О閲嶇‘璁� </button> <button id="btn-submit" - class="rkbk-quick-btn layui-btn btn-green" - disabled=true onclick="submit()"> - <i><img th:src="@{../../static/images/icon-ok.png}"/></i>瀹屾垚绉伴噸 + class="rkbk-quick-btn layui-btn btn-green" onclick="submit()"> + <i><img th:src="@{../../static/images/icon-ok.png}"/></i>姝ラ2锛氬畬鎴愮О閲� </button> <button id="btn-printBill" - class="rkbk-quick-btn layui-btn btn-blue" - disabled=true onclick="printBill()"> - <i><img th:src="@{../../static/images/icon-dayin.png}"/></i>鎵撳嵃杩囩鍗� + class="rkbk-quick-btn layui-btn btn-blue" onclick="printBill()"> + <i><img th:src="@{../../static/images/icon-dayin.png}"/></i>姝ラ3锛氭墦鍗拌繃纾呭崟 + </button> + <button class="rkbk-quick-btn layui-btn" onclick="showCheck()"> + <i><img th:src="@{../../static/images/icon-hyd.png}"/></i>璐ㄦ璇︾粏 </button> <button class="rkbk-quick-btn layui-btn btn-violet" onclick="flushPage()"> @@ -520,16 +518,6 @@ <!-- 琛ュ厖瀛楁榛樿闅愯棌 --> <div class="layui-col-xs4"> <div class="layui-form-item"> - <label class="layui-form-label">妫�鏂ょ被鍨�</label> - <div class="layui-input-block"> - <input type="radio" name="jjlx" value="0" title="绉伴噸鍏ュ簱" checked> - <input type="radio" name="jjlx" value="1" title="鏍囧噯鍖呭叆搴�"> - </div> - </div> - </div> - - <div class="layui-col-xs4"> - <div class="layui-form-item"> <label class="layui-form-label">鍖呰鐗�</label> <div class="layui-input-block"> <input type="radio" name="bzw" value="1" title="楹昏"> @@ -548,6 +536,16 @@ <input type="text" name="dePackage" autocomplete="off" placeholder="璇疯緭鍏�" class="layui-input weight"> <em class="kccz-data-dw">KG</em> + </div> + </div> + </div> + + <div class="layui-col-xs4"> + <div class="layui-form-item"> + <label class="layui-form-label">鍗曚环</label> + <div class="layui-input-block"> + <input type="text" name="price" placeholder="璇疯緭鍏�" + class="layui-input"> <em class="kccz-data-dw">鍏�/鍏枻</em> </div> </div> </div> @@ -573,17 +571,6 @@ </div> </div> </div> - - <div class="layui-col-xs4"> - <div class="layui-form-item"> - <label class="layui-form-label">鍗曚环</label> - <div class="layui-input-block"> - <input type="text" name="price" placeholder="璇疯緭鍏�" - class="layui-input"> <em class="kccz-data-dw">鍏�/鍏枻</em> - </div> - </div> - </div> - </form> </div> -- Gitblit v1.9.3