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-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java | 151 +++++++++++++------------------------------------- 1 files changed, 39 insertions(+), 112 deletions(-) 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(); -- Gitblit v1.9.3