From 73df1a92d6fd2696d4f359efa19e4b684317d732 Mon Sep 17 00:00:00 2001 From: LSH Date: 星期日, 17 九月 2023 18:46:13 +0800 Subject: [PATCH] # --- src/main/java/com/zy/common/service/CommonService.java | 173 +++++++++++++++++++++++++++++++-------------------------- 1 files changed, 93 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java index cd4b253..6b10fe2 100644 --- a/src/main/java/com/zy/common/service/CommonService.java +++ b/src/main/java/com/zy/common/service/CommonService.java @@ -7,6 +7,7 @@ import com.core.common.Cools; import com.core.exception.CoolException; import com.zy.asrs.entity.*; +import com.zy.asrs.entity.result.KeyValueVo; import com.zy.asrs.service.*; import com.zy.asrs.utils.Utils; import com.zy.asrs.utils.VersionUtils; @@ -50,7 +51,7 @@ /** * 鐢熸垚宸ヤ綔鍙� - * @param wrkMk 0:鍏ュ簱 1 - 3000 ; 1:鎷f枡/骞舵澘/鐩樼偣 3001 - 6000 ; 2: 鍑哄簱 6001 -9000 ; 3:鍏朵粬 9001 -9999 + * @param wrkMk * @return workNo(宸ヤ綔鍙�) */ public int getWorkNo(Integer wrkMk) { @@ -87,17 +88,33 @@ return workNo; } + //鎷嗙洏鏈哄绌烘澘鎵爜锛岄┍鍔ㄦ墭鐩樺悜鐮佸灈浣嶏紝涓嶅叆搴� + @Transactional + public StartupDto getScanBarcodeEmptyBoard(){ + StartupDto startupDto = new StartupDto(); + Integer staNo = 0; + if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 201).eq("staNo", 216))<2){ + staNo=216; + } + if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 201).eq("staNo", 220))<2){ + staNo=220; + } + + startupDto.setStaNo(staNo); + return startupDto; + } + /** * 妫�绱㈠簱浣嶅彿 * @param whsType 绫诲瀷 1:鍙屾繁寮忚揣鏋� * @param staDescId 璺緞宸ヤ綔绫诲瀷 * @param sourceStaNo 婧愮珯 - * @param matNos 鍟嗗搧缂栧彿闆嗗悎 + * @param list 鍟嗗搧缂栧彿闆嗗悎 * @return locNo 妫�绱㈠埌鐨勫簱浣嶅彿 */ @Transactional - public StartupDto getLocNo(Integer whsType, Integer staDescId, Integer sourceStaNo, List<String> matNos, LocTypeDto locTypeDto, int times) { - whsType = getWhsType(sourceStaNo, times); + public StartupDto getLocNo(Integer whsType, Integer staDescId, Integer sourceStaNo, List<KeyValueVo> list, LocTypeDto locTypeDto, int times) { + whsType = 1; StartupDto startupDto = new StartupDto(); // 鐢熸垚宸ヤ綔鍙� int workNo = getWorkNo(0); @@ -118,25 +135,44 @@ LocMast locMast = null; // 闈犺繎鎽嗘斁瑙勫垯 --- 鍚屽ぉ鍚岃鏍肩墿鏂� - if (!Cools.isEmpty(matNos)) { - List<String> locNos = locDetlService.getSameDetlToday(matNos.get(0), sRow, eRow); - for (String locNo : locNos) { - if (Utils.isShallowLoc(slaveProperties, locNo)) { - continue; + if (!Cools.isEmpty(list)) { + boolean sameMatnr = true; + String matnr = ""; + String batch = ""; + for (KeyValueVo vo : list) { + if (Cools.isEmpty(matnr)) { + matnr = vo.getName(); + } else { + if (!matnr.equals(vo.getName())) { + sameMatnr = false; + break; + } } - String shallowLocNo = Utils.getShallowLoc(slaveProperties, locNo); - // 妫�娴嬬洰鏍囧簱浣嶆槸鍚︿负绌哄簱浣� - LocMast shallowLoc = locMastService.selectById(shallowLocNo); - if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) { - if (VersionUtils.locMoveCheckLocType(shallowLoc, locTypeDto)) { - if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) { - locMast = shallowLoc; - crnNo = locMast.getCrnNo(); - break; + } + if (sameMatnr) { + List<String> locNos = locDetlService.getSameDetlToday(matnr, sRow, eRow); + for (String locNo : locNos) { + if (Utils.isShallowLoc(slaveProperties, locNo)) { + continue; + } + String shallowLocNo = Utils.getShallowLoc(slaveProperties, locNo); + // 妫�娴嬬洰鏍囧簱浣嶆槸鍚︿负绌哄簱浣� + LocMast shallowLoc = locMastService.selectById(shallowLocNo); + if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) { + if (VersionUtils.locMoveCheckLocType(shallowLoc, locTypeDto)) { + // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣� + if (locMastService.checkEmptyCount(shallowLoc)) { + if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) { + locMast = shallowLoc; + crnNo = locMast.getCrnNo(); + break; + } + } } } } } + } // 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭 @@ -151,10 +187,13 @@ // 妫�娴嬬洰鏍囧簱浣嶆槸鍚︿负绌哄簱浣� LocMast shallowLoc = locMastService.selectById(shallowLocNo); if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) { - if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) { - locMast = shallowLoc; - crnNo = locMast.getCrnNo(); - break; + // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣� + if (locMastService.checkEmptyCount(shallowLoc)) { + if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) { + locMast = shallowLoc; + crnNo = locMast.getCrnNo(); + break; + } } } } @@ -164,35 +203,15 @@ // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋� if (null == locMast) { Shelves shelves = new Shelves(rowCount, crn_qty); - if (whsType != 4) { - int divides = (int) Arith.divides(1, curRow - 1, 16); - curRow = (int) Arith.remainder(curRow, 16); - if (curRow == 0) { - curRow = 16; + for (int i = 0; i < shelves.group; i ++) { + curRow = shelves.start(curRow); + if (curRow < 0) { + throw new CoolException("妫�绱㈠簱浣嶅け璐ワ紝璇疯仈绯荤鐞嗗憳"); } - for (int i = 0; i < shelves.group; i ++) { - curRow = shelves.start(curRow); - if (curRow < 0) { - throw new CoolException("妫�绱㈠簱浣嶅け璐ワ紝璇疯仈绯荤鐞嗗憳"); - } - Integer crnNo1 = shelves.get(curRow); - crnNo1 = crnNo1 + divides*4; - if (basCrnpService.checkSiteError(crnNo1, true)) { - crnNo = crnNo1; - break; - } - } - } else { - for (int i = 0; i < shelves.group; i ++) { - curRow = shelves.start(curRow); - if (curRow < 0) { - throw new CoolException("妫�绱㈠簱浣嶅け璐ワ紝璇疯仈绯荤鐞嗗憳"); - } - Integer crnNo1 = shelves.get(curRow); - if (basCrnpService.checkSiteError(crnNo1, true)) { - crnNo = crnNo1; - break; - } + Integer crnNo1 = shelves.get(curRow); + if (basCrnpService.checkSiteError(crnNo1, true)) { + crnNo = crnNo1; + break; } } } @@ -211,8 +230,11 @@ throw new CoolException("鍏ュ簱璺緞涓嶅瓨鍦�"); } BasDevp staNo = basDevpService.selectById(staDesc.getCrnStn()); + boolean sign = true; if (!staNo.getAutoing().equals("Y")) { - throw new CoolException("鐩爣绔�"+staDesc.getCrnStn()+"涓嶅彲鐢�"); +// throw new CoolException("鐩爣绔�"+staDesc.getCrnStn()+"涓嶅彲鐢�"); + log.error("鐩爣绔�"+staDesc.getCrnStn()+"涓嶅彲鐢�"); + sign = false; } // 鏇存柊搴撲綅鎺掑彿 rowLastno.setCurrentRow(curRow); @@ -221,22 +243,24 @@ // 寮�濮嬫煡鎵惧簱浣� ==============================>> // 1.褰撴绱㈠簱鎺掍负娴呭簱浣嶆帓鏃讹紝浼樺厛瀵绘壘褰撳墠搴撴帓鐨勬繁搴撲綅鎺� - if (locMast == null) { + if (locMast == null && sign) { if (Utils.isShallowLoc(slaveProperties, curRow)) { Integer deepRow = Utils.getDeepRow(slaveProperties, curRow); locMast = locMastService.queryFreeLocMast(deepRow, locTypeDto.getLocType1()); // todo:luxiaotao 濡傛灉鐢ㄦ祬鎺掓壘鍒扮殑娣卞簱浣嶏紝閭d箞鍒欓渶瑕佸垽鏂繖涓繁搴撲綅瀵瑰簲鐨勬祬搴撲綅鏄惁鏈夎揣锛團銆乆銆丏锛� // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣� - if (!locMastService.checkEmptyCount(locMast)) { + if (locMast !=null && !locMastService.checkEmptyCount(locMast)) { locMast = null; } } + if (Cools.isEmpty(locMast)) { locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1()); // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣� if (!locMastService.checkEmptyCount(locMast)) { locMast = null; } + // 鐩爣搴撲綅 ===>> 娴呭簱浣嶏紝 鍒欐牎楠屽叾娣卞簱浣嶆槸鍚︿负 F D X if (null != locMast && Utils.isShallowLoc(slaveProperties, locMast.getLocNo())) { LocMast deepLoc = locMastService.selectById(Utils.getDeepLoc(slaveProperties, locMast.getLocNo())); @@ -259,13 +283,18 @@ // 褰撳墠宸烽亾鏃犵┖搴撲綅鏃讹紝閫掑綊璋冩暣鑷充笅涓�宸烽亾锛屾绱㈠叏閮ㄥ贩閬撴棤鏋滃悗锛岃烦鍑洪�掑綊 if (times < rowCount) { times = times + 1; - return getLocNo(1, staDescId, sourceStaNo, matNos, locTypeDto, times); + return getLocNo(1, staDescId, sourceStaNo, list, locTypeDto, times); + } else { + times = 0; } // 杞昏揣鐗╂壘杞诲簱浣嶄负绌烘椂锛屽彲浠ュ幓鎵鹃噸搴撲綅浠� if (locTypeDto.getLocType1() == 1) { locTypeDto.setLocType1((short) 2); - return getLocNo(1, staDescId, sourceStaNo, matNos, locTypeDto, times); + return getLocNo(1, staDescId, sourceStaNo, list, locTypeDto, times); + } + if (!sign){ + throw new CoolException("鐩爣绔�"+staDesc.getCrnStn()+"涓嶅彲鐢�"); } log.error("绯荤粺娌℃湁绌哄簱浣嶏紒锛侊紒 灏哄瑙勬牸锛� {}锛� 杞娆℃暟锛歿}", JSON.toJSONString(locTypeDto), times); throw new CoolException("娌℃湁绌哄簱浣�"); @@ -280,6 +309,7 @@ startupDto.setLocNo(locNo); return startupDto; } + public static String zerofill(String msg, Integer count) { @@ -299,31 +329,14 @@ /** * 鏍规嵁鍏ュ簱绔欒幏鍙栧簱浣嶆帓鍙峰垎閰� */ - private Integer getWhsType(Integer sourceStaNo, int times) { - if (times >= 16) { - return 4; + private Integer getCurRow(Integer curRow) { + if (Utils.isDeepLocLeft(slaveProperties,curRow)){ //鍒ゆ柇鏄惁涓哄乏娣卞簱浣� + curRow=curRow+3; + }else if (Utils.isDeepLocLeft(slaveProperties,curRow-1)){ + curRow=curRow+1; + }else { + curRow=curRow-2; } - switch (sourceStaNo) { - case 173: - case 176: - case 180: - case 185: - return 1; - case 189: - case 194: - case 198: - case 202: - return 2; - case 206: -// case 211: -// case 215: -// case 219: -// case 223: - case 227: - return 3; - default: - throw new CoolException("鏍规嵁鍏ュ簱绔欒幏鍙栧簱浣嶆帓鍙峰垎閰嶅け璐ワ紝鍏ュ簱绔欙細" + sourceStaNo); - } + return curRow; } - } -- Gitblit v1.9.1