From 64da17c397d02f8b1d19b9c46134eb8469957c46 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期一, 26 九月 2022 11:23:45 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 226 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 143 insertions(+), 83 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index efa2107..201904d 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -43,10 +43,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -2222,21 +2219,82 @@ } + public List<String> crn1DemoLocs = new ArrayList<String>(); public String crn1LastLoc = ""; + public List<String> crn2DemoLocs = new ArrayList<String>(); public String crn2LastLoc = ""; + public List<String> crn3DemoLocs = new ArrayList<String>(); public String crn3LastLoc = ""; public synchronized void demo() { + if (Cools.isEmpty(crn1DemoLocs)) { + crn1DemoLocs = locMastService.getDemoNextLoc(1); + } + if (Cools.isEmpty(crn2DemoLocs)) { + crn2DemoLocs = locMastService.getDemoNextLoc(2); + } + if (Cools.isEmpty(crn3DemoLocs)) { + crn3DemoLocs = locMastService.getDemoNextLoc(3); + } for (CrnSlave crn : slaveProperties.getCrn()) { - // 鑾峰彇鍫嗗灈鏈轰俊鎭� - CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); - CrnProtocol crnProtocol = crnThread.getCrnProtocol(); - if (crnProtocol == null) { + if (!crn.getDemo()) { continue; - } - BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); - if (basCrnp == null) { - log.error("{}鍙峰爢鍨涙満灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", crn.getId()); - continue; + } // 蹇呴』涓烘紨绀虹姸鎬� + +// CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); +// CrnProtocol crnProtocol = crnThread.getCrnProtocol(); +// if (crnProtocol == null) { +// continue; +// } + + // 鍙湁褰撳爢鍨涙満绌洪棽 骞朵笖 鏃犱换鍔℃椂鎵嶇户缁墽琛� +// if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { + + String locNo = null; + Iterator<String> iterator = crn1DemoLocs.iterator(); + if (crn.getId() == 1) { + iterator = crn1DemoLocs.iterator(); + } else if (crn.getId() == 2) { + iterator = crn2DemoLocs.iterator(); + } else if (crn.getId() == 3) { + iterator = crn3DemoLocs.iterator(); + } + while (iterator.hasNext()) { + String next = iterator.next(); + String lastLoc = ""; + if (crn.getId() == 1) { + lastLoc = crn1LastLoc; + } else if (crn.getId() == 2) { + lastLoc = crn2LastLoc; + } else if (crn.getId() == 3) { + lastLoc = crn3LastLoc; + } + if (!Cools.isEmpty(lastLoc)) { + if (!lastLoc.substring(2, 7).equals(next.substring(2, 7)) || !Utils.getGroupRow(lastLoc).equals(Utils.getGroupRow(next))) { + locNo = next; + iterator.remove(); + break; + } else { + iterator.remove(); + } + } else { + locNo = next; + iterator.remove(); + break; + } + + } + if (!Cools.isEmpty(locNo)) { + if (crn.getId() == 1) { + crn1LastLoc = locNo; + } else if (crn.getId() == 2) { + crn2LastLoc = locNo; + } else if (crn.getId() == 3) { + crn3LastLoc = locNo; + } + } + + log.info("{}鍙峰爢鍨涙満瀵箋}搴撲綅杩涜婕旂ず", crn.getId(), locNo); + } - } +// } } /** @@ -2250,77 +2308,79 @@ CrnProtocol crnProtocol = crnThread.getCrnProtocol(); if (crnProtocol == null) { continue; } + log.info("{}鍙峰爢鍨涙満姝e湪婕旂ず", crn.getId()); + // 鍙湁褰撳爢鍨涙満绌洪棽 骞朵笖 鏃犱换鍔℃椂鎵嶇户缁墽琛� if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { - // 鑾峰彇绉诲簱宸ヤ綔妗d俊鎭� - WrkMast wrkMast = wrkMastMapper.selectLocMove(crn.getId()); - if (null != wrkMast) { continue; } - - LocMast sourceLoc = locMastService.queryDemoSourceLoc(crn.getId()); - LocMast loc = locMastService.queryDemoLoc(crn.getId()); - if (null == sourceLoc || null == loc) { continue; } - - String sourceLocNo = sourceLoc.getLocNo(); - String locNo = loc.getLocNo(); - - // 鑾峰彇宸ヤ綔鍙� - int workNo = commonService.getWorkNo(WorkNoType.PICK.type); - // 淇濆瓨宸ヤ綔妗� - wrkMast = new WrkMast(); - wrkMast.setWrkNo(workNo); - wrkMast.setIoTime(new Date()); - wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID - wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇 - wrkMast.setIoPri(13D); - wrkMast.setCrnNo(crn.getId()); - wrkMast.setSourceLocNo(sourceLocNo); // 婧愬簱浣� - wrkMast.setLocNo(locNo); // 鐩爣搴撲綅 - wrkMast.setFullPlt("N"); // 婊℃澘锛歒 - wrkMast.setPicking("N"); // 鎷f枡 - wrkMast.setExitMk("N"); // 閫�鍑� - wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 绌烘澘 - wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮� - wrkMast.setLinkMis("N"); - wrkMast.setAppeTime(new Date()); - wrkMast.setModiTime(new Date()); - int res = wrkMastMapper.insert(wrkMast); - if (res == 0) { - throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); - } - // 宸ヤ綔妗f槑缁嗕繚瀛� - List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); - for (LocDetl locDetl : locDetls) { - WrkDetl wrkDetl = new WrkDetl(); - wrkDetl.sync(locDetl); - wrkDetl.setWrkNo(workNo); - wrkDetl.setIoTime(new Date()); - wrkDetl.setAnfme(locDetl.getAnfme()); - wrkDetl.setAppeTime(new Date()); - wrkDetl.setModiTime(new Date()); - if (!wrkDetlService.insert(wrkDetl)) { - throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); - } - } - // 淇敼婧愬簱浣嶇姸鎬� - if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) { - sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害 - sourceLoc.setModiTime(new Date()); - if (!locMastService.updateById(sourceLoc)){ - throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); - } - } else { - throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�"); - } - // 淇敼鐩爣搴撲綅鐘舵�� - if (loc.getLocSts().equals("O")) { - loc.setLocSts("S"); // S.鍏ュ簱棰勭害 - loc.setModiTime(new Date()); - if (!locMastService.updateById(loc)) { - throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); - } - } else { - throw new CoolException("绉昏浆澶辫触"); - } +// // 鑾峰彇绉诲簱宸ヤ綔妗d俊鎭� +// WrkMast wrkMast = wrkMastMapper.selectLocMove(crn.getId()); +// if (null != wrkMast) { continue; } +// +// LocMast sourceLoc = locMastService.queryDemoSourceLoc(crn.getId()); +// LocMast loc = locMastService.queryDemoLoc(crn.getId()); +// if (null == sourceLoc || null == loc) { continue; } +// +// String sourceLocNo = sourceLoc.getLocNo(); +// String locNo = loc.getLocNo(); +// +// // 鑾峰彇宸ヤ綔鍙� +// int workNo = commonService.getWorkNo(WorkNoType.PICK.type); +// // 淇濆瓨宸ヤ綔妗� +// wrkMast = new WrkMast(); +// wrkMast.setWrkNo(workNo); +// wrkMast.setIoTime(new Date()); +// wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID +// wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇 +// wrkMast.setIoPri(13D); +// wrkMast.setCrnNo(crn.getId()); +// wrkMast.setSourceLocNo(sourceLocNo); // 婧愬簱浣� +// wrkMast.setLocNo(locNo); // 鐩爣搴撲綅 +// wrkMast.setFullPlt("N"); // 婊℃澘锛歒 +// wrkMast.setPicking("N"); // 鎷f枡 +// wrkMast.setExitMk("N"); // 閫�鍑� +// wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 绌烘澘 +// wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮� +// wrkMast.setLinkMis("N"); +// wrkMast.setAppeTime(new Date()); +// wrkMast.setModiTime(new Date()); +// int res = wrkMastMapper.insert(wrkMast); +// if (res == 0) { +// throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); +// } +// // 宸ヤ綔妗f槑缁嗕繚瀛� +// List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); +// for (LocDetl locDetl : locDetls) { +// WrkDetl wrkDetl = new WrkDetl(); +// wrkDetl.sync(locDetl); +// wrkDetl.setWrkNo(workNo); +// wrkDetl.setIoTime(new Date()); +// wrkDetl.setAnfme(locDetl.getAnfme()); +// wrkDetl.setAppeTime(new Date()); +// wrkDetl.setModiTime(new Date()); +// if (!wrkDetlService.insert(wrkDetl)) { +// throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); +// } +// } +// // 淇敼婧愬簱浣嶇姸鎬� +// if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) { +// sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害 +// sourceLoc.setModiTime(new Date()); +// if (!locMastService.updateById(sourceLoc)){ +// throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); +// } +// } else { +// throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�"); +// } +// // 淇敼鐩爣搴撲綅鐘舵�� +// if (loc.getLocSts().equals("O")) { +// loc.setLocSts("S"); // S.鍏ュ簱棰勭害 +// loc.setModiTime(new Date()); +// if (!locMastService.updateById(loc)) { +// throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); +// } +// } else { +// throw new CoolException("绉昏浆澶辫触"); +// } } -- Gitblit v1.9.1