From 77db84d63aa23dfa63bdc667f73ee6507369fd9a Mon Sep 17 00:00:00 2001 From: LSH Date: 星期四, 03 十一月 2022 10:57:40 +0800 Subject: [PATCH] #pda同步优化 根据用户编号查询用户码 --- src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 251 insertions(+), 29 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 50f8bb7..8d37d41 100644 --- a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java @@ -1,5 +1,7 @@ package com.zy.asrs.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.core.common.BaseRes; @@ -13,29 +15,31 @@ import com.zy.asrs.entity.result.StockVo; import com.zy.asrs.mapper.TagMapper; import com.zy.asrs.service.*; +import com.zy.asrs.task.AbstractHandler; +import com.zy.asrs.task.core.ReturnT; 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; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.expression.spel.ast.NullLiteral; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.tools.JavaCompiler; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; /** * Created by vincent on 2022/4/9 */ @Slf4j @Service -public class OpenServiceImpl implements OpenService { +public class OpenServiceImpl extends AbstractHandler<String> implements OpenService { @Autowired private OrderService orderService; @@ -64,7 +68,17 @@ @Autowired private LocMastService locMastService; @Autowired - private WorkService workService; + private CommonService commonService; + @Autowired + private ApiLogService apiLogService; + @Autowired + private WrkMastService wrkMastService; + + @Value("${mes.url}") + private String mesUrl; + + @Value("${mes.inPath}") + private String inpath; @Override @Transactional @@ -565,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); } @@ -612,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鐮佷笉鍚�"); @@ -624,22 +749,37 @@ .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("鏇存柊娴嬭瘯鐘舵�佸け璐�"); } locMast.setPackStatus(2); + CombParam combParam = new CombParam(); + combParam.setPackNo(locMast.getBarcode()); + 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:鐢宠涓�"); @@ -647,6 +787,7 @@ } else { throw new CoolException("娴嬭瘯鐢宠澶嶆牳澶辫触"); } + return testMast; } @@ -667,37 +808,118 @@ TestMast testMast = testMastService.selectOne(wrapper); if(null != testMast){ if (testMast.getStatus()==3){ - testMast.setStatus(4); - testMast.setModiTime(new Date()); - if (!testMastService.update(testMast,wrapper)){ - throw new CoolException("鏇存敼娴嬭瘯鐘舵�佸け璐�"); - } + Date date = new Date(); locMast.setPackStatus(3); + locMast.setModiTime(date); + CombParam combParam = new CombParam(); + combParam.setPackNo(locMast.getBarcode()); + 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("鐘舵�佷笉鏄� 2:娴嬭瘯涓�"); + throw new CoolException("娴嬭瘯鐘舵�佷笉鏄� 3:娴嬭瘯涓�"); } } else { throw new CoolException("鐘舵�佸紓甯�"); } - //绉诲簱寮�濮嬶紝鏌ヨ鐩爣搴撲綅 - LocMast targetLocNo = locMastService.selectOne(new EntityWrapper<LocMast>() - .eq("row1",2) - .eq("loc_sts","O") - .eq("fire_status", 0) - .eq("pack_status",0)); - if (targetLocNo != null){ - workService.locMove(review.getLocNo(),targetLocNo.getLocNo(),(long)Integer.parseInt(review.getUserId())); - }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()))){ + throw new CoolException("鏇存敼浜у搧鐘舵�佸け璐�"); + } + }else if (Cools.isEmpty(testMast.getStatus())){ + throw new CoolException("鐘舵�佸紓甯�"); + }else { + throw new CoolException("鐘舵�佷笉鏄� 3:娴嬭瘯涓�"); + } + } else { + throw new CoolException("鐘舵�佸紓甯�"); } return success; } + private ReturnT<String> postMesData(String mesPath, Object combParam){ + if(combParam != null){ + String response = ""; + boolean success = false; + try { +// Map<String, Object> map = new HashMap<>(); +// map.put("appkey","ea1f0459efc02a79f046f982767939ae"); + response = new HttpHandler.Builder() +// .setHeaders(map) + .setUri(mesUrl) + .setPath(mesPath) + .setJson(JSON.toJSONString(combParam)) + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + if (jsonObject.getInteger("code").equals(200)) { +// if (jsonObject.getDate("isComplete").equals(true)){ + success = true; +// }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锛歿}", mesUrl+"/"+mesPath, JSON.toJSONString(combParam), response); + throw new CoolException("涓婃姤mes绯荤粺澶辫触"); + } + } catch (Exception e) { + log.error("fail", e); +// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return FAIL.setMsg(e.getMessage()); + } finally { + try { + // 淇濆瓨鎺ュ彛鏃ュ織 + apiLogService.save( + "涓婃姤mes绯荤粺", + mesUrl +"/"+ mesPath, + null, + "127.0.0.1", + JSON.toJSONString(combParam), + response, + success + ); + } catch (Exception e) { log.error("", e); } + } + } + return SUCCESS; + } /*...........................璧e窞鏂板..............浠ヤ笂.............璧e窞鏂板...........................*/ } -- Gitblit v1.9.1