From de7203bde97e80ec0b845f29c158c4b30d876caf Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 15 二月 2023 09:12:19 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java | 353 +++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 226 insertions(+), 127 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
index 25c72b6..457bd8b 100644
--- a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -1,5 +1,6 @@
package com.zy.asrs.service.impl;
+import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.common.BaseRes;
@@ -19,6 +20,7 @@
import com.zy.common.model.enums.WorkNoType;
import com.zy.common.properties.SlaveProperties;
import com.zy.common.service.CommonService;
+import com.zy.common.web.BaseController;
import com.zy.common.web.WcsController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -98,7 +100,9 @@
wrkMast.setIoTime(new Date());
wrkMast.setWrkSts(1L); // 宸ヤ綔鐘舵�侊細鐢熸垚鍏ュ簱ID
wrkMast.setIoType(1); // 鍏ュ嚭搴撶姸鎬侊細1.鍏ュ簱
- wrkMast.setIoPri(13D); // 浼樺厛绾э細13
+ Double ioPri = wrkMastService.getIoPri(1, dto.getLocNo());
+ wrkMast.setIoPri(ioPri); // 浼樺厛绾э細13
+ wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), true)?1:0);;
wrkMast.setCrnNo(dto.getCrnNo());
wrkMast.setSourceStaNo(dto.getSourceStaNo());
wrkMast.setStaNo(dto.getStaNo());
@@ -195,8 +199,17 @@
}
}
Integer ioType = null;
+ List<String> excludeLocNos = dtos.stream().map(OutLocDto::getLocNo).distinct().collect(Collectors.toList());
// 鐢熸垚宸ヤ綔妗�
for (OutLocDto dto : dtos) {
+ // 濡傛灉涓烘繁搴撲綅锛屼笖瀵瑰簲娴呭簱浣嶄负X.绂佺敤锛屽垯鐣ヨ繃姝ゅ簱浣�
+ if (Utils.isDeepLoc(slaveProperties, dto.getLocNo())) {
+ String shallowLoc = Utils.getShallowLoc(slaveProperties, dto.getLocNo());
+ if (locMastService.selectById(shallowLoc).getLocSts().equals("X")) {
+ continue;
+ }
+ }
+
// 鍒ゆ柇鍏ュ嚭搴撶被鍨嬶細101.鍏ㄦ澘鍑哄簱 or 103.鎷f枡鍑哄簱
if (ioWorkType == null) {
ioType = dto.isAll() ? 101 : 103;
@@ -207,7 +220,9 @@
// 鑾峰彇搴撲綅
LocMast locMast = locMastService.selectById(dto.getLocNo());
// 鑾峰彇璺緞
- StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), staNo.getDevNo());
+ Boolean outMost = locMastService.isOutMost(dto.getLocNo(), false);
+ Integer outCrnNo = locMastService.getOutCrnNo(locMast);
+ StaDesc staDesc = staDescService.queryCrnStn(ioType, outCrnNo, staNo.getDevNo());
// 鐢熸垚宸ヤ綔鍙�
int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType));
// 鐢熸垚宸ヤ綔妗�
@@ -216,8 +231,10 @@
wrkMast.setIoTime(now);
wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬�
- wrkMast.setIoPri(13D); // 浼樺厛绾э細13
- wrkMast.setCrnNo(locMast.getCrnNo());
+ Double ioPri = wrkMastService.getIoPri(ioType, dto.getLocNo());
+ wrkMast.setIoPri(ioPri); // 浼樺厛绾э細13
+ wrkMast.setOutMost(outMost?1:0);;
+ wrkMast.setCrnNo(outMost?outCrnNo:locMast.getCrnNo());
wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
wrkMast.setSourceLocNo(dto.getLocNo()); // 婧愬簱浣�
@@ -264,6 +281,7 @@
} else {
throw new CoolException(dto.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��");
}
+ locMastService.breakUp(dto.getLocNo(), excludeLocNos);
}
}
@@ -281,7 +299,9 @@
LocMast locMast = locMastService.selectById(taskDto.getLocNo());
// 鑾峰彇璺緞
int ioType = taskDto.isAll() ? 101 : 103;
- StaDesc staDesc = staDescService.queryCrnStnAuto(ioType, locMast.getCrnNo(), staNo.getDevNo());
+ Boolean outMost = locMastService.isOutMost(taskDto.getLocNo(), false);
+ Integer outCrnNo = locMastService.getOutCrnNo(locMast);
+ StaDesc staDesc = staDescService.queryCrnStnAuto(ioType, outCrnNo, staNo.getDevNo());
// 鐢熸垚宸ヤ綔鍙�
int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType));
// 鐢熸垚宸ヤ綔妗�
@@ -290,8 +310,10 @@
wrkMast.setIoTime(now);
wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬�
- wrkMast.setIoPri(13D); // 浼樺厛绾э細13
- wrkMast.setCrnNo(locMast.getCrnNo());
+ Double ioPri = wrkMastService.getIoPri(ioType, taskDto.getLocNo());
+ wrkMast.setIoPri(ioPri); // 浼樺厛绾э細13
+ wrkMast.setOutMost(outMost?1:0);;
+ wrkMast.setCrnNo(outMost?outCrnNo:locMast.getCrnNo());
wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
wrkMast.setSourceLocNo(taskDto.getLocNo()); // 婧愬簱浣�
@@ -311,12 +333,14 @@
// 鐢熸垚宸ヤ綔妗f槑缁�
for (LocDto locDto : taskDto.getLocDtos()) {
if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; }
- OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch());
- if (orderDetl == null) {
- orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null);
+ LocDetl locDetl = locDetlService.selectItem(locDto.getLocNo(), locDto.getMatnr(), locDto.getBatch());
+ if (locDetl == null || locDetl.getAnfme() < locDto.getAnfme()) {
+ throw new CoolException(locDto.getLocNo() + "搴撲綅涓�" + locDto.getMatnr() + "鍟嗗搧搴撳瓨涓嶈冻锛�");
}
+ Mat mat = matService.selectByMatnr(locDto.getMatnr());
+ assert mat != null;
WrkDetl wrkDetl = new WrkDetl();
- wrkDetl.sync(orderDetl);
+ wrkDetl.sync(mat);
wrkDetl.setZpallet(wrkMast.getBarcode());
wrkDetl.setIoTime(now);
wrkDetl.setWrkNo(workNo);
@@ -331,10 +355,29 @@
throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
}
// 淇敼璁㈠崟鏄庣粏
- if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) {
- throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触");
+ if (!BaseController.isJSON(locDto.getOrderNo())) {
+ OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch());
+ if (orderDetl == null) {
+ orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null);
+ }
+ if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) {
+ throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触");
+ }
+ orderService.updateSettle(orderDetl.getOrderId(), 2L, userId);
+ } else {
+ // 璁㈠崟鍚堝苟鍑哄簱
+ List<OrderDto> orderDtoList = JSON.parseArray(locDto.getOrderNo(), OrderDto.class);
+ for (OrderDto orderDto : orderDtoList) {
+ OrderDetl orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch());
+ if (orderDetl == null) {
+ orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), null);
+ }
+ if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDto.getAnfme())) {
+ throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触");
+ }
+ orderService.updateSettle(orderDetl.getOrderId(), 2L, userId);
+ }
}
- orderService.updateSettle(orderDetl.getOrderId(), 2L, userId);
}
// 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓�
locMast = locMastService.selectById(taskDto.getLocNo());
@@ -365,7 +408,9 @@
wrkMast.setIoTime(new Date());
wrkMast.setWrkSts(1L); // 宸ヤ綔鐘舵�侊細鐢熸垚鍏ュ簱ID
wrkMast.setIoType(10); // 鍏ュ嚭搴撶姸鎬侊細10.绌烘澘鍏ュ簱
- wrkMast.setIoPri(10D); // 浼樺厛绾э細10
+ Double ioPri = wrkMastService.getIoPri(10, dto.getLocNo());
+ wrkMast.setIoPri(ioPri); // 浼樺厛绾э細10
+ wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), true)?1:0);;
wrkMast.setCrnNo(dto.getCrnNo());
wrkMast.setSourceStaNo(dto.getSourceStaNo());
wrkMast.setStaNo(dto.getStaNo());
@@ -414,6 +459,13 @@
throw new CoolException("绔欑偣涓嶅瓨鍦�");
}
for (String locNo : param.getLocNos()) {
+ // 濡傛灉涓烘繁搴撲綅锛屼笖瀵瑰簲娴呭簱浣嶄负X.绂佺敤锛屽垯鐣ヨ繃姝ゅ簱浣�
+ if (Utils.isDeepLoc(slaveProperties, locNo)) {
+ String shallowLoc = Utils.getShallowLoc(slaveProperties, locNo);
+ if (locMastService.selectById(shallowLoc).getLocSts().equals("X")) {
+ continue;
+ }
+ }
// 鑾峰彇宸ヤ綔鍙�
int workNo = commonService.getWorkNo(WorkNoType.PAKOUT.type);
// 鑾峰彇搴撲綅
@@ -421,12 +473,17 @@
if (Cools.isEmpty(locMast)) {
throw new CoolException(locNo+"搴撲綅涓嶅瓨鍦�");
}
+ Boolean outMost = locMastService.isOutMost(locNo, false);
+ Integer outCrnNo = locMastService.getOutCrnNo(locMast);
// 鑾峰彇婧愮珯
Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
.eq("type_no", 110)
.eq("stn_no", param.getOutSite())
- .eq("crn_no", locMast.getCrnNo());
+ .eq("crn_no", outCrnNo);
StaDesc staDesc = staDescService.selectOne(wrapper);
+ if (Cools.isEmpty(staDesc)) {
+ throw new CoolException("闈炴硶璺緞锛�");
+ }
Integer sourceStaNo = staDesc.getCrnStn();
if (Cools.isEmpty(sourceStaNo)) {
throw new CoolException("妫�绱㈡簮绔欏け璐�");
@@ -437,10 +494,12 @@
wrkMast.setIoTime(new Date());
wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
wrkMast.setIoType(110); // 鍏ュ嚭搴撶姸鎬侊細 110.绌烘澘鍑哄簱
- wrkMast.setIoPri(10D);
+ Double ioPri = wrkMastService.getIoPri(110, locNo);
+ wrkMast.setIoPri(ioPri);
wrkMast.setSourceStaNo(sourceStaNo); // 婧愮珯
wrkMast.setStaNo(param.getOutSite()); // 鐩爣绔�
- wrkMast.setCrnNo(locMast.getCrnNo());
+ wrkMast.setOutMost(outMost?1:0);;
+ wrkMast.setCrnNo(outMost?outCrnNo:locMast.getCrnNo());
wrkMast.setSourceLocNo(locNo); // 婧愬簱浣�
wrkMast.setFullPlt("N"); // 婊℃澘锛歒
wrkMast.setPicking("N"); // 鎷f枡
@@ -501,17 +560,19 @@
throw new CoolException("鏈壘鍒板簱浣�");
}
if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) {
- throw new CoolException("绉昏浆搴撲綅灞炰簬涓嶅悓鍫嗗灈鏈�");
+// throw new CoolException("绉昏浆搴撲綅灞炰簬涓嶅悓鍫嗗灈鏈�"); todo:luxiaotao
}
+ Date now = new Date();
// 鑾峰彇宸ヤ綔鍙�
int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
// 淇濆瓨宸ヤ綔妗�
WrkMast wrkMast = new WrkMast();
wrkMast.setWrkNo(workNo);
- wrkMast.setIoTime(new Date());
+ wrkMast.setIoTime(now);
wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
wrkMast.setIoPri(10D);
+ wrkMast.setOutMost(locMastService.isOutMost(locNo, false)?1:0);;
wrkMast.setCrnNo(sourceLoc.getCrnNo());
wrkMast.setSourceLocNo(sourceLocNo); // 婧愬簱浣�
wrkMast.setLocNo(locNo); // 鐩爣搴撲綅
@@ -522,9 +583,9 @@
wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮�
wrkMast.setLinkMis("N");
wrkMast.setAppeUser(userId);
- wrkMast.setAppeTime(new Date());
+ wrkMast.setAppeTime(now);
wrkMast.setModiUser(userId);
- wrkMast.setModiTime(new Date());
+ wrkMast.setModiTime(now);
boolean res = wrkMastService.insert(wrkMast);
if (!res) {
throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
@@ -534,11 +595,11 @@
WrkDetl wrkDetl = new WrkDetl();
wrkDetl.sync(locDetl);
wrkDetl.setWrkNo(workNo);
- wrkDetl.setIoTime(new Date());
+ wrkDetl.setIoTime(now);
wrkDetl.setAnfme(locDetl.getAnfme());
- wrkDetl.setAppeTime(new Date());
+ wrkDetl.setAppeTime(now);
wrkDetl.setAppeUser(userId);
- wrkDetl.setModiTime(new Date());
+ wrkDetl.setModiTime(now);
wrkDetl.setModiUser(userId);
if (!wrkDetlService.insert(wrkDetl)) {
throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
@@ -548,17 +609,17 @@
if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) {
sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害
sourceLoc.setModiUser(userId);
- sourceLoc.setModiTime(new Date());
+ sourceLoc.setModiTime(now);
if (!locMastService.updateById(sourceLoc)){
throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
}
} else {
- throw new CoolException("婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細"+sourceLoc.getLocSts$());
+ throw new CoolException(sourceLoc.getLocNo() + "婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細"+sourceLoc.getLocSts$());
}
// 淇敼鐩爣搴撲綅鐘舵��
if (loc.getLocSts().equals("O")) {
loc.setLocSts("S"); // S.鍏ュ簱棰勭害
- loc.setModiTime(new Date());
+ loc.setModiTime(now);
loc.setModiUser(userId);
if (!locMastService.updateById(loc)) {
throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
@@ -575,15 +636,15 @@
if (Cools.isEmpty(wrkMast)){
throw new CoolException(workNo+"宸ヤ綔妗d笉瀛樺湪");
}
- if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 14) {
+ if (wrkMast.getWrkSts() == 9 || wrkMast.getWrkSts() == 17) {
throw new CoolException("褰撳墠宸ヤ綔妗e凡瀹屾垚");
}
// 鍏ュ簱 + 搴撲綅杞Щ
- if (wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()==11)) {
- wrkMast.setWrkSts(4L);
- // 鍑哄簱
+ if (wrkMast.getWrkSts() < 9 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()==11)) {
+ wrkMast.setWrkSts(9L);
+ // 鍑哄簱
} else if (wrkMast.getWrkSts() > 10) {
- wrkMast.setWrkSts(14L);
+ wrkMast.setWrkSts(17L);
}
Date now = new Date();
wrkMast.setCrnStrTime(DateUtils.calculate(now, 1L, TimeUnit.SECONDS, true));
@@ -728,14 +789,11 @@
String locNo = ""; // 寰呬慨鏀圭洰鏍囧簱浣�
String locSts = ""; // 寰呬慨鏀圭洰鏍囧簱浣嶇姸鎬�
// 鍏ュ簱鍙栨秷锛堜慨鏀圭洰鏍囧簱浣嶏級
- if (wrkMast.getWrkSts() < 4) {
+ if (wrkMast.getWrkSts() < 9) {
locNo = wrkMast.getLocNo();
locSts = "O";
- /**
- * 搴撲綅杞Щ
- * 鍙栨秷鍚� 婧愬簱浣� ==>> F.鍦ㄥ簱
- * 鐩爣搴撲綅 ===>> O.绌哄簱浣�
- **/
+
+ // 搴撲綅杞Щ
if (wrkMast.getIoType() == 11) {
// 搴撲綅杞Щ锛氭簮搴撲綅
LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());
@@ -748,7 +806,7 @@
locMastService.updateById(locMast);
}
// 鍑哄簱鍙栨秷锛堜慨鏀规簮搴撲綅锛�
- } else if (wrkMast.getWrkSts() > 10 && wrkMast.getWrkSts() != 14) {
+ } else if (wrkMast.getWrkSts() > 10 && wrkMast.getWrkSts() != 19) {
locNo = wrkMast.getSourceLocNo();
// 鍑哄簱 ===>> F.鍦ㄥ簱
if (wrkMast.getIoType() > 100 && wrkMast.getIoType() != 110) {
@@ -776,11 +834,19 @@
List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo());
for (WrkDetl wrkDetl : wrkDetls) {
if (!Cools.isEmpty(wrkDetl.getOrderNo())) {
- if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) {
- throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触");
+ if (!BaseController.isJSON(wrkDetl.getOrderNo())) {
+ if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) {
+ throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触");
+ }
+ } else {
+ // 璁㈠崟鍚堝苟鍑哄簱
+ List<OrderDto> orderDtoList = JSON.parseArray(wrkDetl.getOrderNo(), OrderDto.class);
+ for (OrderDto orderDto : orderDtoList) {
+ if (!orderDetlService.decrease(orderDto.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), orderDto.getAnfme())) {
+ throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触");
+ }
+ }
}
- // 鐢熸垚鏂扮殑鍑哄簱浣滀笟
-// stockOutRe(wrkMast, wrkDetls);
}
}
// 鍙栨秷鎿嶄綔浜哄憳璁板綍
@@ -878,107 +944,140 @@
@Override
public StartupDto createWaitPainWrkMastStart(List<WaitPakin> list, Long userId) {
- if (Cools.isEmpty(list)) {
- throw new CoolException("鍏ュ簱閫氱煡妗d笉鑳戒负绌�");
- }
- LocTypeDto locTypeDto = new LocTypeDto();
- locTypeDto.setLocType1((short) 1);
- return wcsController.startupFullPutStore(301, list.get(0).getZpallet(), locTypeDto, list);
+ return null;
}
@Override
@Transactional
public String dealPreHaveStart(Integer wrkNo, Long userId) {
- WrkMast wrkMast = wrkMastService.selectById(wrkNo);
- if (wrkMast == null) {
- throw new CoolException("浠诲姟宸插け鏁�");
+ if (true) {
+ throw new CoolException("鍔熻兘鍋滅敤");
}
- String locNo = wrkMast.getLocNo();
- LocMast locMast = locMastService.selectById(locNo);
- assert locMast != null;
- RowLastno rowLastno = rowLastnoService.findBySection(locMast.getRow1());
- assert rowLastno != null;
+ return "";
+ }
- // 鐩爣搴撲綅
- LocMast targetLoc = null;
+ @Override
+ @Transactional
+ public void shuttleTransfer(List<String> locNos) {
+ if (Cools.isEmpty(locNos)) {
+ return;
+ }
+ if (true && !Cools.isEmpty(locNos)) {
+ throw new CoolException("鏆備笉鏀寔绉诲簱浠诲姟"); // todo:luxiaotao 绉诲簱寮�鍏�
+ }
+ LocMast one = locMastService.selectById(locNos.get(0));
+ List<Integer> rows = Utils.getGroupLoc(Integer.parseInt(locNos.get(0).substring(0, 2)));
+ List<LocMast> locMasts = locMastService.queryFreeLocMast(rows, rows.size(), one.getLocType1());
+ if (Cools.isEmpty(locMasts)) {
+ throw new CoolException("搴撲綅绉昏浆澶辫触锛屽凡鏃犵┖搴撲綅");
+ }
+ // 鍏ュ簱鎺掑簭 娣卞簱浣� ==> 娴呭簱浣�
+ switch (locMasts.get(0).getRow1()) {
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 12:
+ case 13:
+ case 14:
+ case 19:
+ case 20:
+ case 21:
+ Collections.reverse(locMasts);
+ break;
+ default:
+ break;
+ }
+ if (locNos.size() > locMasts.size()) {
+ throw new CoolException("鏈嶅姟鍣ㄩ敊璇�");
+ }
+ Date now = new Date();
+ // 鐢熸垚绉诲簱宸ヤ綔妗�
+ Iterator<LocMast> iterator = locMasts.iterator();
+ for (String sourceLocNo : locNos) {
- for (int curRow = rowLastno.getsRow(); curRow<=rowLastno.geteRow(); curRow++) {
-
- if (Utils.isShallowLoc(slaveProperties, curRow)) {
- Integer deepRow = Utils.getDeepRow(slaveProperties, curRow);
- targetLoc = locMastService.queryFreeLocMast(deepRow, locMast.getLocType1());
- // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣�
- if (!locMastService.checkEmptyCount(targetLoc)) {
- continue;
+ while (iterator.hasNext()) {
+ LocMast sourceLoc = locMastService.selectById(sourceLocNo);
+ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo));
+ if (Cools.isEmpty(sourceLoc)){
+ throw new CoolException("鏈壘鍒板簱浣�");
}
- }
- if (Cools.isEmpty(targetLoc)) {
- targetLoc = locMastService.queryFreeLocMast(curRow, locMast.getLocType1());
- // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣�
- if (!locMastService.checkEmptyCount(targetLoc)) {
- continue;
+ LocMast loc = iterator.next();
+ if (Cools.isEmpty(loc)){
+ throw new CoolException("鏈壘鍒板簱浣�");
}
- // 鐩爣搴撲綅 ===>> 娴呭簱浣嶏紝 鍒欐牎楠屽叾娣卞簱浣嶆槸鍚︿负 F D X
- if (null != targetLoc && Utils.isShallowLoc(slaveProperties, targetLoc.getLocNo())) {
- LocMast deepLoc = locMastService.selectById(Utils.getDeepLoc(slaveProperties, targetLoc.getLocNo()));
- if (!deepLoc.getLocSts().equals("F") && !deepLoc.getLocSts().equals("D") && !deepLoc.getLocSts().equals("X")) {
- continue;
+ if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) {
+// throw new CoolException("绉昏浆搴撲綅灞炰簬涓嶅悓鍫嗗灈鏈�"); todo:luxiaotao
+ }
+ // 鑾峰彇宸ヤ綔鍙�
+ int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+ // 淇濆瓨宸ヤ綔妗�
+ WrkMast wrkMast = new WrkMast();
+ wrkMast.setWrkNo(workNo);
+ wrkMast.setIoTime(now);
+ wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+ wrkMast.setIoPri(15D);
+ wrkMast.setOutMost(locMastService.isOutMost(loc.getLocNo(), false)?1:0);;
+ wrkMast.setCrnNo(sourceLoc.getCrnNo());
+ wrkMast.setSourceLocNo(sourceLocNo); // 婧愬簱浣�
+ wrkMast.setLocNo(loc.getLocNo()); // 鐩爣搴撲綅
+ wrkMast.setFullPlt(Cools.isEmpty(locDetls)?"N":"Y"); // 婊℃澘锛歒
+ wrkMast.setPicking("N"); // 鎷f枡
+ wrkMast.setExitMk("N"); // 閫�鍑�
+ wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 绌烘澘
+ wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮�
+ wrkMast.setLinkMis("N");
+ wrkMast.setAppeUser(9527L);
+ wrkMast.setAppeTime(now);
+ wrkMast.setModiUser(9527L);
+ wrkMast.setModiTime(now);
+ boolean res = wrkMastService.insert(wrkMast);
+ if (!res) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ }
+ // 宸ヤ綔妗f槑缁嗕繚瀛�
+ for (LocDetl locDetl : locDetls) {
+ WrkDetl wrkDetl = new WrkDetl();
+ wrkDetl.sync(locDetl);
+ wrkDetl.setWrkNo(workNo);
+ wrkDetl.setIoTime(now);
+ wrkDetl.setAnfme(locDetl.getAnfme());
+ wrkDetl.setAppeTime(now);
+ wrkDetl.setAppeUser(9527L);
+ wrkDetl.setModiTime(now);
+ wrkDetl.setModiUser(9527L);
+ if (!wrkDetlService.insert(wrkDetl)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
}
}
- // 鐩爣搴撲綅 ===>> 娣卞簱浣嶏紝 鍒欐牎楠屽叾娴呭簱浣嶆槸鍚︿负 O
- if (null != targetLoc && Utils.isDeepLoc(slaveProperties, targetLoc.getLocNo())) {
- LocMast shallowLoc = locMastService.selectById(Utils.getShallowLoc(slaveProperties, targetLoc.getLocNo()));
- if (!shallowLoc.getLocSts().equals("O")) {
- continue;
+ // 淇敼婧愬簱浣嶇姸鎬�
+ if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) {
+ sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害
+ sourceLoc.setModiUser(9527L);
+ sourceLoc.setModiTime(now);
+ if (!locMastService.updateById(sourceLoc)){
+ throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
}
+ } else {
+ throw new CoolException(sourceLoc.getLocNo() + "婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細"+sourceLoc.getLocSts$());
}
- }
+ // 淇敼鐩爣搴撲綅鐘舵��
+ if (loc.getLocSts().equals("O")) {
+ loc.setLocSts("S"); // S.鍏ュ簱棰勭害
+ loc.setModiTime(now);
+ loc.setModiUser(9527L);
+ if (!locMastService.updateById(loc)) {
+ throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+ }
+ } else {
+ throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細"+loc.getLocSts$());
+ }
- if (!Cools.isEmpty(targetLoc)) {
+ iterator.remove();
break;
}
-
}
-
- if (targetLoc == null) {
- throw new CoolException("鎿嶄綔澶辫触锛屽綋鍓嶄粨搴撴壘涓嶅埌绌哄簱浣�");
- }
-
- Date now = new Date();
- // 淇敼宸ヤ綔妗�
- StaDesc staDesc = staDescService.queryCrnStn(targetLoc.getCrnNo());
- if (Cools.isEmpty(staDesc)) {
- throw new CoolException("鍏ュ簱璺緞涓嶅瓨鍦�");
- }
- wrkMast.setWrkSts(2L);
- wrkMast.setLocNo(targetLoc.getLocNo());
- wrkMast.setStaNo(staDesc.getCrnStn());
- wrkMast.setCrnNo(targetLoc.getCrnNo());
- wrkMast.setModiTime(now);
- wrkMast.setModiUser(userId);
- wrkMast.setPreHave("N");
- if (!wrkMastService.updateById(wrkMast)) {
- throw new CoolException("淇敼宸ヤ綔妗eけ璐�");
- }
- // 淇敼搴撲綅鐘舵�� O ===>>> S
- if (targetLoc.getLocSts().equals("O")){
- targetLoc.setLocSts("S"); // S.鍏ュ簱棰勭害
- targetLoc.setModiUser(userId);
- targetLoc.setModiTime(now);
- if (!locMastService.updateById(targetLoc)){
- throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�");
- }
- } else {
- throw new CoolException(targetLoc.getLocNo()+"鐩爣搴撲綅宸茶鍗犵敤");
- }
- // 绂佺敤寮傚父搴撲綅
-// locMast.setLocSts("X"); // X.绂佺敤
-// locMast.setModiUser(userId);
-// locMast.setModiTime(now);
-// if (!locMastService.updateById(locMast)){
-// throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�");
-// }
- return targetLoc.getLocNo();
}
}
--
Gitblit v1.9.1