From d35dd49decd2207b80b8c9410427d4ff25d3e3d0 Mon Sep 17 00:00:00 2001 From: LSH Date: 星期六, 11 二月 2023 13:12:46 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java | 218 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 190 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java index e70dae6..8d37d41 100644 --- a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java @@ -20,6 +20,8 @@ import com.zy.asrs.utils.MatUtils; import com.zy.common.constant.MesConstant; import com.zy.common.model.DetlDto; +import com.zy.common.model.enums.WorkNoType; +import com.zy.common.service.CommonService; import com.zy.common.utils.HttpHandler; import com.zy.common.utils.NodeUtils; import lombok.extern.slf4j.Slf4j; @@ -65,9 +67,12 @@ private TestMastService testMastService; @Autowired private LocMastService locMastService; - + @Autowired + private CommonService commonService; @Autowired private ApiLogService apiLogService; + @Autowired + private WrkMastService wrkMastService; @Value("${mes.url}") private String mesUrl; @@ -574,6 +579,15 @@ @Override @Transactional public void combPACK(CombParam param) { + if (Cools.isEmpty(param.getPackNo())){ + throw new CoolException("缂哄皯鍙傛暟锛歱ackNo"); + }else if (Cools.isEmpty(param.getPackName())){ + throw new CoolException("缂哄皯鍙傛暟锛歱ackName"); + }else if (Cools.isEmpty(param.getSettingTimes())){ + throw new CoolException("缂哄皯鍙傛暟锛歴ettingTimes"); + }else if (Cools.isEmpty(param.getRequestTime())){ + throw new CoolException("缂哄皯鍙傛暟锛歳equestTime"); + } if (Cools.isEmpty(param.getPackNo())) { throw new CoolException(BaseRes.PARAM); } @@ -621,10 +635,112 @@ throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); } } + @Override + @Transactional + public void combPackOut(CombParam param) { + if (Cools.isEmpty(param.getPackNo())){ + throw new CoolException("缂哄皯鍙傛暟锛歱ackNo"); + }else if (Cools.isEmpty(param.getPackName())){ + throw new CoolException("缂哄皯鍙傛暟锛歱ackName"); + }else if (Cools.isEmpty(param.getSettingTimes())){ + throw new CoolException("缂哄皯鍙傛暟锛歴ettingTimes"); + }else if (Cools.isEmpty(param.getRequestTime())){ + throw new CoolException("缂哄皯鍙傛暟锛歳equestTime"); + } + if (Cools.isEmpty(param.getPackNo())) { + throw new CoolException(BaseRes.PARAM); + } + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() +// .eq("fire_status", 0) +// .eq("loc_sts", "F") + .eq("barcode", param.getPackNo())); + if (Cools.isEmpty(locMast)){ + throw new CoolException("鏈煡璇㈠埌PACK鐮佷负锛�"+param.getPackNo()+"鐨勮揣鐗�"); + }else if (!locMast.getLocSts().equals("F")){ + throw new CoolException("PACK鐮佷负锛�"+param.getPackNo()+"鐨勮揣鐗╁簱浣嶇姸鎬佷笉鏄�淔鈥�"); + }else if (locMast.getFireStatus()!=0){ + throw new CoolException("璀﹀憡锛侊紒锛丳ACK鐮佷负锛�"+param.getPackNo()+"鐨勫簱浣嶏細"+locMast.getLocNo()+"娑堥槻鐘舵�佸紓甯革紒锛侊紒"); +// }else if (locMast.getFireStatus()!=0){ +// throw new CoolException("璀﹀憡锛侊紒锛丳ACK鐮佷负锛�"+param.getPackNo()+"鐨勫簱浣嶏細"+locMast.getLocNo()+"娑堥槻鐘舵�佸紓甯革紒锛侊紒"); +// }else if (locMast.getFireStatus()!=0){ +// throw new CoolException("璀﹀憡锛侊紒锛丳ACK鐮佷负锛�"+param.getPackNo()+"鐨勫簱浣嶏細"+locMast.getLocNo()+"娑堥槻鐘舵�佸紓甯革紒锛侊紒"); +// }else if (locMast.getFireStatus()!=0){ +// throw new CoolException("璀﹀憡锛侊紒锛丳ACK鐮佷负锛�"+param.getPackNo()+"鐨勫簱浣嶏細"+locMast.getLocNo()+"娑堥槻鐘舵�佸紓甯革紒锛侊紒"); + }else { + Date now = new Date(); + Integer ioType = 101; //鍏ュ嚭搴撶被鍨� + LocDetl locDetl=locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no",locMast.getLocNo())); + if (Cools.isEmpty(locDetl)){ + log.error("搴撲綅:"+locMast.getLocNo()+"娌℃湁鏄庣粏"); +// } else if (Cools.isEmpty(locDetl.getDeadWarn())){ +// log.error("搴撲綅:"+locMast.getLocNo()+"娌℃湁闈欑疆鏃堕棿"); +// } else if (Cools.isEmpty(locMast.getModiTime())){ +// log.error("搴撲綅:"+locMast.getLocNo()+"modiTime涓虹┖"); + } else if (Cools.isEmpty(locMast.getBarcode())){ + log.error("搴撲綅:"+locMast.getLocNo()+"Pack鐮佷负绌�"); + } else { + // 鐢熸垚宸ヤ綔鍙� + int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); + // 鐢熸垚宸ヤ綔妗� + WrkMast wrkMast = new WrkMast(); + wrkMast.setWrkNo(workNo); + wrkMast.setIoTime(now); + wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID + wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬� + wrkMast.setIoPri(13D); // 浼樺厛绾э細13 + wrkMast.setCrnNo(1); + wrkMast.setSourceStaNo(107); // 婧愮珯 + wrkMast.setStaNo(104); // 鐩爣绔� + wrkMast.setSourceLocNo(locMast.getLocNo()); // 婧愬簱浣� + wrkMast.setFullPlt("Y"); // 婊℃澘锛歒 + wrkMast.setPicking("N"); // 鎷f枡 + wrkMast.setExitMk("N"); // 閫�鍑� + wrkMast.setEmptyMk("N"); // 绌烘澘 + wrkMast.setLinkMis("N"); + wrkMast.setBarcode(locMast.getBarcode()); + wrkMast.setAppeTime(now); + wrkMast.setModiTime(now); + if (!wrkMastService.insert(wrkMast)) { + throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細"+locMast.getLocNo()); + } + // 鐢熸垚宸ヤ綔妗f槑缁� + WrkDetl wrkDetl = new WrkDetl(); + wrkDetl.sync(locDetl); + wrkDetl.setWrkNo(workNo); + wrkDetl.setIoTime(now); + wrkDetl.setAnfme(1.0); // 鏁伴噺 + wrkDetl.setAppeTime(now); + wrkDetl.setModiTime(now); + if (!wrkDetlService.insert(wrkDetl)) { + throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); + } + // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害 + if (locMast.getLocSts().equals("F")) { + locMast.setLocSts("R"); + locMast.setModiTime(now); + locMast.setPackStatus(6); //6:闈欑疆瀹屾垚 + CombParam combParam = new CombParam(); + combParam.setPackNo(locMast.getBarcode()); + combParam.setLocNo(locMast.getLocNo()); + combParam.setPackSts(7); + combParam.setRequestTime(DateUtils.convert(new Date())); + postMesData(inpath,combParam); + + if (!locMastService.updateById(locMast)) { + throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細"+locMast.getLocNo()); + } + } else { + throw new CoolException(locMast.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��"); + } + } + } + + + } @Override @Transactional - public void infoReview(Review review) { + public TestMast infoReview(Review review) { LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo())); if (!review.getBarcode().equals(locMast.getBarcode())){ throw new CoolException("pack鐮佷笉鍚�"); @@ -633,13 +749,22 @@ .eq("loc_no", review.getLocNo()) .eq("barcode", review.getBarcode()) .eq("user_Id", review.getUserId()); - if (null == locMast ||locMast.getPackStatus()!=1) { - throw new CoolException("浜у搧鐘舵�佷笉鏄� 1:寰呮祴璇�"); - } TestMast testMast = testMastService.selectOne(wrapper); + if (null == locMast) { + throw new CoolException("浜у搧鐘舵�佷负绌�"); + }else if (locMast.getPackStatus()==2){ + if (!Cools.isEmpty(testMast)){ + if (testMast.getStatus()==2 || testMast.getStatus()==3){ + return testMast; + } + } + }else if (locMast.getPackStatus()!=1){ + throw new CoolException("浜у搧鐘舵�佷笉鏄�1寰呮祴璇�"); + } + if(null != testMast){ if (testMast.getStatus()==1){ - testMast.setStatus(3); + testMast.setStatus(2); testMast.setModiTime(new Date()); if (!testMastService.update(testMast,wrapper)){ throw new CoolException("鏇存柊娴嬭瘯鐘舵�佸け璐�"); @@ -647,14 +772,14 @@ locMast.setPackStatus(2); CombParam combParam = new CombParam(); combParam.setPackNo(locMast.getBarcode()); - combParam.setLocno(locMast.getLocNo()); + combParam.setLocNo(locMast.getLocNo()); combParam.setPackSts(2); combParam.setRequestTime(DateUtils.convert(new Date())); postMesData(inpath,combParam); if (!locMastService.update(locMast,new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo()))){ throw new CoolException("鏇存柊浜у搧鐘舵�佸け璐�"); } - }else if (Cools.isEmpty(testMast.getStatus())){ + } else if (Cools.isEmpty(testMast.getStatus())){ throw new CoolException("鐘舵�佸紓甯�"); }else { throw new CoolException("鐘舵�佷笉鏄� 1:鐢宠涓�"); @@ -662,6 +787,7 @@ } else { throw new CoolException("娴嬭瘯鐢宠澶嶆牳澶辫触"); } + return testMast; } @@ -683,17 +809,52 @@ if(null != testMast){ if (testMast.getStatus()==3){ Date date = new Date(); - testMast.setStatus(4); - testMast.setModiTime(date); - if (!testMastService.update(testMast,wrapper)){ - throw new CoolException("鏇存敼娴嬭瘯鐘舵�佸け璐�"); - } locMast.setPackStatus(3); - testMast.setModiTime(date); + locMast.setModiTime(date); CombParam combParam = new CombParam(); combParam.setPackNo(locMast.getBarcode()); - combParam.setLocno(locMast.getLocNo()); + combParam.setLocNo(locMast.getLocNo()); combParam.setPackSts(3); + combParam.setRequestTime(DateUtils.convert(new Date())); + postMesData(inpath,combParam); + if (!locMastService.update(locMast, new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo()))){ + throw new CoolException("鏇存敼浜у搧鐘舵�佸け璐�"); + } + }else if (Cools.isEmpty(testMast.getStatus())){ + throw new CoolException("鐘舵�佸紓甯�"); + }else { + throw new CoolException("娴嬭瘯鐘舵�佷笉鏄� 3:娴嬭瘯涓�"); + } + } else { + throw new CoolException("鐘舵�佸紓甯�"); + } + return success; + } + + @Override + @Transactional + public Boolean testNG(Review review) { + Boolean success=true; + Wrapper wrapper = new EntityWrapper<TestMast>() + .eq("loc_no", review.getLocNo()) + .eq("barcode", review.getBarcode()) + .eq("user_Id", review.getUserId()); + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo())); + if (null == locMast ||locMast.getPackStatus()!=2){ + throw new CoolException("浜у搧鐘舵�佷笉鏄� 2:娴嬭瘯涓�"); + }else if (!review.getBarcode().equals(locMast.getBarcode())){ + throw new CoolException("pack鐮佷笉鍚�"); + } + TestMast testMast = testMastService.selectOne(wrapper); + if(null != testMast){ + if (testMast.getStatus()==3){ + Date date = new Date(); + locMast.setPackStatus(4); + locMast.setModiTime(date); + CombParam combParam = new CombParam(); + combParam.setPackNo(locMast.getBarcode()); + combParam.setLocNo(locMast.getLocNo()); + combParam.setPackSts(4); combParam.setRequestTime(DateUtils.convert(new Date())); postMesData(inpath,combParam); if (!locMastService.update(locMast, new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo()))){ @@ -715,9 +876,10 @@ String response = ""; boolean success = false; try { - Map<String, Object> map = new HashMap<>(); - map.put("appkey","ea1f0459efc02a79f046f982767939ae"); - response = new HttpHandler.Builder().setHeaders(map) +// Map<String, Object> map = new HashMap<>(); +// map.put("appkey","ea1f0459efc02a79f046f982767939ae"); + response = new HttpHandler.Builder() +// .setHeaders(map) .setUri(mesUrl) .setPath(mesPath) .setJson(JSON.toJSONString(combParam)) @@ -725,16 +887,16 @@ .doPost(); JSONObject jsonObject = JSON.parseObject(response); if (jsonObject.getInteger("code").equals(200)) { - if (jsonObject.getDate("isComplete").equals(true)){ +// if (jsonObject.getDate("isComplete").equals(true)){ success = true; - }else if (jsonObject.getDate("isComplete").equals(false)){ - success = false; - }else { - log.error("杩斿洖鍊煎嚭閿�!!!url锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL+MesConstant.PAKIN_URL, JSON.toJSONString(combParam), response); - throw new CoolException("杩斿洖鍊煎嚭閿�"); - } +// }else if (jsonObject.getDate("isComplete").equals(false)){ +// success = false; +// }else { +// log.error("杩斿洖鍊煎嚭閿�!!!url锛歿}锛況equest锛歿}锛況esponse锛歿}", mesUrl+"/"+mesPath, JSON.toJSONString(combParam), response); +// throw new CoolException("杩斿洖鍊煎嚭閿�"); +// } } else { - log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL+MesConstant.PAKIN_URL, JSON.toJSONString(combParam), response); + log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", mesUrl+"/"+mesPath, JSON.toJSONString(combParam), response); throw new CoolException("涓婃姤mes绯荤粺澶辫触"); } } catch (Exception e) { @@ -745,8 +907,8 @@ try { // 淇濆瓨鎺ュ彛鏃ュ織 apiLogService.save( - "鎴愬搧搴撳叆搴撲笂鎶�", - MesConstant.URL + MesConstant.PAKIN_URL, + "涓婃姤mes绯荤粺", + mesUrl +"/"+ mesPath, null, "127.0.0.1", JSON.toJSONString(combParam), -- Gitblit v1.9.1