From 7e1e714c49a20468fcc7c7c37d4f65142abb2528 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期二, 20 五月 2025 11:19:12 +0800
Subject: [PATCH] #电视机增加批号
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 97 +++++++++++++++++++++++++++++++-----------------
1 files changed, 63 insertions(+), 34 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 641d493..89cd345 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -49,6 +49,7 @@
import java.io.IOException;
import java.util.*;
+import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static com.zy.common.utils.RandomValidateCodeUtil.code;
@@ -105,6 +106,8 @@
private String wmsUrl;
public int workNo = 9900;
+
+ public int workNoMax = 12000;
/**
* 缁勬墭
@@ -237,6 +240,7 @@
param.setSourceStaNo(inSta.getStaNo());
param.setLocType1(locTypeDto.getLocType1());
String response = new HttpHandler.Builder()
+ .setTimeout(30, TimeUnit.SECONDS)
.setUri(wmsUrl)
.setPath("/rpc/pakin/loc/v1")
.setJson(JSON.toJSONString(param))
@@ -275,6 +279,11 @@
}
} else {
log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+ ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ if (ledThread != null) {
+ String errorMsg = barcode + jsonObject.get("msg");
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ }
}
} catch (Exception e) {
@@ -481,6 +490,7 @@
param.setSourceStaNo(inSta.getStaNo());
param.setLocType1(locTypeDto.getLocType1());
String response = new HttpHandler.Builder()
+ .setTimeout(30,TimeUnit.SECONDS)
.setUri(wmsUrl)
.setPath("/rpc/pakin/loc/v1")
.setJson(JSON.toJSONString(param))
@@ -518,6 +528,11 @@
MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
}
} else {
+ ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ if (ledThread != null) {
+ String errorMsg = jsonObject.getString("msg");
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ }
log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
}
@@ -1015,11 +1030,12 @@
} else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) {
// 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔�
if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) {
- wrkMast.setUpdMk("Y");
- wrkMast.setIoPri(14D);
- wrkMastMapper.updateById(wrkMast);
+ if (moveLocForDeepLoc(slave, shallowLoc)){
+ wrkMast.setUpdMk("Y");
+ wrkMast.setIoPri(14D);
+ wrkMastMapper.updateById(wrkMast);
+ }
// 鐢熸垚宸ヤ綔妗�,灏嗘祬搴撲綅绉昏浆鍒版柊鐨勫簱浣嶄腑
- moveLocForDeepLoc(slave, shallowLoc);
// 鐢熸垚宸ヤ綔妗c�佹敼鍙樻祬搴撲綅鐨勬簮搴�/鐩爣搴� 搴撲綅鐘舵�併�佷笅鍙戝爢鍨涙満鍛戒护锛堢珛椹墽琛�)
// moveLocForDeepLocPakin(slave, shallowLoc, wrkMast);
}
@@ -1159,10 +1175,12 @@
// if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())
// || Cools.isEmpty(waitWrkMast)) {
if (Cools.isEmpty(waitWrkMast)) {
- wrkMast.setUpdMk("Y");
- wrkMastMapper.updateById(wrkMast);
+ if ( moveLocForDeepLoc(slave, shallowLoc)){
+ wrkMast.setUpdMk("Y");
+ wrkMastMapper.updateById(wrkMast);
+ }
// 鐢熸垚宸ヤ綔妗�,灏嗘祬搴撲綅绉昏浆鍒版柊鐨勫簱浣嶄腑
- moveLocForDeepLoc(slave, shallowLoc);
+
}
log.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛佹祬搴撲綅鍙�:{}", wrkMast.getWrkNo(), shallowLocNo);
continue;
@@ -1618,6 +1636,11 @@
throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
} else {
+ ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed());
+ if (ledThread != null) {
+ String errorMsg = jsonObject.getString("msg");
+ MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, errorMsg));
+ }
log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
}
} catch (Exception e) {
@@ -1688,13 +1711,13 @@
List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
wrkDetls.forEach(wrkDetl -> {
if (wrkMast.getIoType() == 101) {
- ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme()));
+ ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getBatch()));
}
if (wrkMast.getIoType() == 103 && (null == wrkDetl.getInspect() || 0 == wrkDetl.getInspect())) {
- ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme()));
+ ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getBatch()));
}
if (wrkMast.getIoType() == 107) {
- ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme()));
+ ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getBatch()));
}
});
}
@@ -1845,7 +1868,8 @@
* 鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堢珛鍗虫墽琛岀増)
* tip锛氬悓姝�
*/
- private synchronized void moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc) {
+ @Transactional
+ public synchronized Boolean moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc) {
try {
List<Integer> rows = locMastService.queryDistinctRow(crn.getId());
LocMast loc = null;
@@ -1889,7 +1913,7 @@
if (null == loc) {
log.error("鍙屾繁搴撲綅 --- 娴呭簱浣嶉樆濉炲紓甯革紒 寰呯Щ杞祬搴撲綅锛�" + shallowLoc.getLocNo());
- throw new CoolException("鍙屾繁搴撲綅 --- 娴呭簱浣嶉樆濉炲紓甯革紒 寰呯Щ杞祬搴撲綅锛�" + shallowLoc.getLocNo());
+ return false;
}
List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo()));
// 鑾峰彇宸ヤ綔鍙�
@@ -1937,10 +1961,11 @@
shallowLoc.setLocSts("R"); // R.鍑哄簱棰勭害
shallowLoc.setModiTime(new Date());
if (!locMastService.updateById(shallowLoc)) {
- throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
+// throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
}
} else {
- throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�");
+ return false;
+// throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�");
}
// 淇敼鐩爣搴撲綅鐘舵��
if (loc.getLocSts().equals("O")) {
@@ -1950,13 +1975,13 @@
throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
}
} else {
- throw new CoolException("绉昏浆澶辫触");
+ return false;
+// throw new CoolException("绉昏浆澶辫触");
}
} catch (Exception e) {
log.error("鍙屾繁搴撲綅闃诲锛屽娴呭簱浣嶈繘琛岀Щ杞け璐�", e);
- e.printStackTrace();
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
+ return true;
}
/**
@@ -2842,6 +2867,7 @@
if (rgvSlave.getId() != 2 ){
continue;
}
+ if (workNo >= workNoMax){ workNo = 9900;}
workNo1 = workNo++;
souSta1 = Utils.getRgvStaNo(rgvSlave.getId(),inStn.getSourceStaNo());
if (inStn.getSourceStaNo() == 4007 && staProtocol.getTongType() == 1){
@@ -2968,6 +2994,7 @@
if (rgvSlave.getId() != 2 ){
continue;
}
+ if (workNo >= workNoMax){ workNo = 9900;}
workNo2 = workNo++;
souSta2 = Utils.getRgvStaNo(rgvSlave.getId(),inStn.getSourceStaNo());
if (inStn.getSourceStaNo() == 4007 && staProtocol.getTongType() == 1){
@@ -3085,26 +3112,10 @@
command.setWeight2(weight2);
if (workNo1 == 0 && workNo2 !=0){
- if("0".equals(matnr2) || "".equals(batch2) ){
- log.error("婧愮珯"+souSta2+"宸ヤ綅涓�浠诲姟缂哄皯淇℃伅锛岀墿鏂欎唬鐮�:"+matnr+",batch:"+batch);
- continue;
- }
command.setTaskMode(RgvTaskModeType.FETCH_PUT2); // 浠诲姟妯″紡: 2鍙栨斁璐�
} else if (workNo1 != 0 && workNo2 ==0) {
- if("0".equals(matnr) || "".equals(batch) ){
- log.error("婧愮珯"+souSta1+"宸ヤ綅浜屼换鍔$己灏戜俊鎭紝鐗╂枡浠g爜:"+matnr+",batch:"+batch);
- continue;
- }
command.setTaskMode(RgvTaskModeType.FETCH_PUT1); // 浠诲姟妯″紡: 1鍙栨斁璐�
}else {
- if("0".equals(matnr) || "".equals(batch) ){
- log.error("婧愮珯"+souSta1+"宸ヤ綅涓�浠诲姟缂哄皯淇℃伅锛岀墿鏂欎唬鐮�:"+matnr+",batch:"+batch);
- continue;
- }
- if("0".equals(matnr2) || "".equals(batch2) ){
- log.error("婧愮珯"+souSta2+"宸ヤ綅浜屼换鍔$己灏戜俊鎭紝鐗╂枡浠g爜:"+matnr+",batch:"+batch);
- continue;
- }
command.setTaskMode(RgvTaskModeType.FETCH_PUT_ALL); // 浠诲姟妯″紡: all鍙栨斁璐�
}
command.setCommand(false);
@@ -3653,6 +3664,7 @@
param.setSourceStaNo(inSta.getStaNo());
param.setLocType1(locTypeDto.getLocType1());
String response = new HttpHandler.Builder()
+ .setTimeout(30,TimeUnit.SECONDS)
.setUri(wmsUrl)
.setPath("/rpc/process/in/loc/v1")
.setJson(JSON.toJSONString(param))
@@ -3681,6 +3693,11 @@
MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
}
} else {
+ ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ if (ledThread != null) {
+ String errorMsg = jsonObject.getString("msg");
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ }
log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/process/in/loc/v1", JSON.toJSONString(param), response);
}
@@ -3720,7 +3737,7 @@
LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
if (jsonObject.getInteger("code").equals(200)) {
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
-
+ log.error(barcode + "鐢熸垚浠诲姟鎴愬姛锛�"+dto);
barcodeThread.setBarcode("");
staProtocol.setWorkNo(dto.getWorkNo().shortValue());
staProtocol.setStaNo(dto.getStaNo().shortValue());
@@ -3739,6 +3756,11 @@
MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
}
} else {
+ ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ if (ledThread != null) {
+ String errorMsg = jsonObject.getString("msg");
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ }
log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
}
@@ -3837,6 +3859,13 @@
// MatnrCode matnrCode = matnrCodeService.selectByCode(code);
Mat mat = matService.selectByCode(code);
if (Cools.isEmpty(mat)){
+ //zc 娣诲姞鏄剧ず灞忎俊鎭紝杈撳嚭鐗╂枡鏃犳硶鎴栧埆绛夋儏鍐�
+ // led 寮傚父鏄剧ず
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ if (ledThread != null) {
+ String errorMsg = code + "鏈壘鍒板搴旂殑鐗╂枡淇℃伅锛�";
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ }
throw new CoolException("鏈壘鍒板搴旂殑鐗╂枡淇℃伅");
}
CombParam combParam = new CombParam();
--
Gitblit v1.9.1