From 1da5c464f48dca0be85647b1d4f284d92c9b3eba Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 10 十月 2022 10:52:27 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 284 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 255 insertions(+), 29 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 c19564c..1a9d2c7 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -74,11 +74,15 @@
@Autowired
private BasErrLogService basErrLogService;
@Autowired
+ private BasSteErrLogService basSteErrLogService;
+ @Autowired
private BasCrnErrorMapper basCrnErrorMapper;
@Autowired
private BasSteService basSteService;
@Autowired
private WrkChargeService wrkChargeService;
+ @Autowired
+ private BasSteErrService basSteErrService;
@Autowired
private CommonService commonService;
@@ -114,11 +118,33 @@
}
String barcode = barcodeThread.getBarcode();
if(!Cools.isEmpty(barcode)) {
- log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
- if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
+ if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
+ staProtocol.setWorkNo((short) 9995);
+ staProtocol.setStaNo(inSta.getBackSta().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+
+ // led 寮傚父鏄剧ず
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ if (ledThread != null) {
+ String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ }
continue;
}
} else {
+ staProtocol.setWorkNo((short) 9995);
+ staProtocol.setStaNo(inSta.getBackSta().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+
+ // led 寮傚父鏄剧ず
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ if (ledThread != null) {
+ String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ }
continue;
}
@@ -143,19 +169,39 @@
.build()
.doPost();
JSONObject jsonObject = JSON.parseObject(response);
- if (jsonObject.getInteger("code").equals(200)) {
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
// plc 澶勭悊
barcodeThread.setBarcode("");
staProtocol.setWorkNo(dto.getWorkNo().shortValue());
staProtocol.setStaNo(dto.getStaNo().shortValue());
devpThread.setPakMk(staProtocol.getSiteId(), false);
+
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
if (!result) {
throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
- } else {
- log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+ } else if (code == 500){
+ if (ledThread != null) {
+ String errorMsg = jsonObject.getString("msg");
+ if (!Cools.isEmpty(errorMsg)) {
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ }
+ }
+ log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+ } else if (code == 700) {
+ staProtocol.setWorkNo((short) 9995);
+ staProtocol.setStaNo(inSta.getBackSta().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+
+ // led 寮傚父鏄剧ず
+ if (ledThread != null) {
+ String errorMsg = barcode + "鎵樼洏璇嗗埆寮傚父锛岃鍏堣繘琛岀粍鎵橈紒";
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ }
}
} catch (Exception e) {
e.printStackTrace();
@@ -235,21 +281,21 @@
if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()){
// 鑾峰彇鏉$爜鎵弿浠俊鎭�
- BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
- if (barcodeThread == null) {
- continue;
- }
- String barcode = barcodeThread.getBarcode();
- if(!Cools.isEmpty(barcode)) {
- log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode);
- if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
- continue;
- }
- } else {
- continue;
- }
+// BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
+// if (barcodeThread == null) {
+// continue;
+// }
+// String barcode = barcodeThread.getBarcode();
+// if(!Cools.isEmpty(barcode)) {
+// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode);
+// if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+// continue;
+// }
+// } else {
+// continue;
+// }
- WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
+ WrkMast wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo());
if (wrkMast == null) {
// 鏃犳嫞鏂欐暟鎹�
continue;
@@ -272,9 +318,9 @@
try {
// 淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。
- if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) {
- throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。澶辫触");
- }
+// if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) {
+// throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。澶辫触");
+// }
// 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
throw new CoolException("淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�");
@@ -292,6 +338,9 @@
wrkMast.setModiTime(new Date());
if (wrkMastMapper.updateById(wrkMast) == 0) {
throw new CoolException("鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+ }
+ if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
+// throw new CoolException("鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
}
// 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴�
LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
@@ -482,6 +531,12 @@
continue;
}
+ // 杩囨护
+ if (null != wrkMastMapper.selectPakout(slave.getId(), null)) {
+ log.error("{}鍏ュ簱浠诲姟鏃犳硶浣滀笟锛屽洜瀛樺湪鍑哄簱涓换鍔�!", wrkMast.getWrkNo());
+ continue;
+ }
+
// 缃《浠诲姟
wrkMast.setIoPri((double) 9999);
wrkMastMapper.updateById(wrkMast);
@@ -489,11 +544,14 @@
// 鐩爣搴撲綅 ===>> 鏈�澶栧眰搴撲綅
if (locMastService.isOutMost(wrkMast.getLocNo())) {
// 鍒ゆ柇灏忚溅鏄惁鍦ㄦ渶澶栧眰搴撲綅锛屽鏋滄槸鍒欐惉璧帮紝濡傛灉涓嶆槸锛屽垯鐩存帴鍫嗗灈鏈哄叆搴�
- Integer steNo = this.hasCarOfIdle(wrkMast.getLocNo());
+ Integer steNo = this.hasCar(wrkMast.getLocNo());
// 鏈夊皬杞�
if (steNo != null) {
// 灏忚溅琛岃蛋鍒板爢鍨涙満寰呮惉绉荤偣
if (wrkMast.getWrkSts() == 2L && wrkMast.getSteNo() == null) {
+// if (null != wrkMastMapper.selectPakin(slave.getId(), steNo)) {
+// continue;
+// }
this.letCarBeReady(wrkMast, steNo, wrkMast.getLocNo());
}
// 灏忚溅鎼蛋
@@ -654,6 +712,12 @@
// 鍫嗗灈鏈烘帶鍒惰繃婊�
if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
+ continue;
+ }
+
+ // 杩囨护
+ if (null != wrkMastMapper.selectPakin(slave.getId(), null)) {
+ log.error("{}鍑哄簱浠诲姟鏃犳硶浣滀笟锛屽洜瀛樺湪鍏ュ簱涓换鍔�!", wrkMast.getWrkNo());
continue;
}
@@ -836,6 +900,8 @@
if (locMastService.isOutMost(wrkMast.getSourceLocNo())) {
// 鐩爣搴撲綅 ===>> 鏈�澶栧眰搴撲綅
if (locMastService.isOutMost(wrkMast.getLocNo())) {
+ // todo:luxiaotao 鍒ゆ柇鐩爣搴撲綅鏄惁瀛樺湪灏忚溅锛屽鏋滃瓨鍦紝鍒欐惉璧板皬杞�
+
// 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
CrnCommand crnCommand = new CrnCommand();
crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
@@ -1075,6 +1141,22 @@
}
}
}
+ }
+
+ /**
+ * 褰撳墠搴撲綅缁勬槸鍚﹀瓨鍦ㄧ┖闂插皬杞�
+ */
+ public Integer hasCar(String locNo) {
+ for (SteSlave ste : slaveProperties.getSte()) {
+ // 鑾峰彇鍫嗗灈鏈轰俊鎭�
+ SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId());
+ SteProtocol steProtocol = steThread.getSteProtocol();
+ if (steProtocol == null) { continue; }
+ if (Utils.getGroupRow(locNo).equals(Utils.getGroupRow(steProtocol.getRow().intValue())) && steProtocol.getBay() == Utils.getBay(locNo) && steProtocol.getLev() == Utils.getLev(locNo)) {
+ return steProtocol.getSteNo().intValue();
+ }
+ }
+ return null;
}
/**
@@ -1793,7 +1875,7 @@
continue;
}
BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
- String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName();
+ String errName = crnError==null? "鏈煡寮傚父":crnError.getErrName();
BasErrLog basErrLog = new BasErrLog(
null, // 缂栧彿
wrkMast.getWrkNo(), // 宸ヤ綔鍙�
@@ -1840,7 +1922,7 @@
// 璁板綍鏂板紓甯�
if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) {
BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
- String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName();
+ String errName = crnError==null? "鏈煡寮傚父":crnError.getErrName();
BasErrLog basErrLog = new BasErrLog(
null, // 缂栧彿
null, // 宸ヤ綔鍙�
@@ -1886,6 +1968,121 @@
}
}
+ /**
+ * 绌挎杞﹀紓甯镐俊鎭褰�
+ */
+ @Async
+ public void recSteErr(){
+ Date now = new Date();
+ for (SteSlave ste : slaveProperties.getSte()) {
+ // 鑾峰彇鍫嗗灈鏈轰俊鎭�
+ SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId());
+ SteProtocol steProtocol = steThread.getSteProtocol();
+ if (steProtocol == null) {
+ continue;
+ }
+ // 鏈変换鍔�
+ if (steProtocol.getTaskNo() != 0) {
+ BasSteErrLog latest = basSteErrLogService.findLatestByTaskNo(ste.getId(), steProtocol.getTaskNo().intValue());
+ // 鏈夊紓甯�
+ if (latest == null) {
+ if (steProtocol.getAlarm() != null && steProtocol.isAlarm()) {
+ WrkMast wrkMast = wrkMastMapper.selectById(steProtocol.getTaskNo());
+ if (wrkMast == null) {
+ continue;
+ }
+ BasSteErr steErr = basSteErrService.selectById(steProtocol.getAlarm());
+ String errName = steErr==null? "鏈煡寮傚父":steErr.getErrName();
+ BasSteErrLog basSteErrLog = new BasSteErrLog(
+ null, // 缂栧彿
+ wrkMast.getWrkNo(), // 宸ヤ綔鍙�
+ now, // 鍙戠敓鏃堕棿
+ null, // 缁撴潫鏃堕棿
+ wrkMast.getWrkSts(), // 宸ヤ綔鐘舵��
+ wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨�
+ ste.getId(), // 鍫嗗灈鏈�
+ null, // plc
+ wrkMast.getLocNo(), // 鐩爣搴撲綅
+ wrkMast.getStaNo(), // 鐩爣绔�
+ wrkMast.getSourceStaNo(), // 婧愮珯
+ wrkMast.getSourceLocNo(), // 婧愬簱浣�
+ wrkMast.getBarcode(), // 鏉$爜
+ (int) steProtocol.getAlarm(), // 寮傚父鐮�
+ errName, // 寮傚父
+ 1, // 寮傚父鎯呭喌
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ "浠诲姟涓紓甯�" // 澶囨敞
+ );
+ if (!basSteErrLogService.insert(basSteErrLog)) {
+ log.error("绌挎杞lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", ste.getId(), errName);
+ }
+ }
+ } else {
+ // 寮傚父淇
+ if (steProtocol.getAlarm() == null || !steProtocol.isAlarm()) {
+ latest.setEndTime(now);
+ latest.setUpdateTime(now);
+ latest.setStatus(2);
+ if (!basSteErrLogService.updateById(latest)) {
+ log.error("绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", ste.getId(), latest.getId());
+ }
+ }
+ }
+ // 鏃犱换鍔�
+ } else {
+ BasSteErrLog latest = basSteErrLogService.findLatest(ste.getId());
+ // 鏈夊紓甯�
+ if (steProtocol.getAlarm() != null && steProtocol.isAlarm()) {
+ // 璁板綍鏂板紓甯�
+ if (latest == null || (latest.getErrCode() != steProtocol.getAlarm().intValue())) {
+ BasSteErr steErr = basSteErrService.selectById(steProtocol.getAlarm());
+ String errName = steErr==null? "鏈煡寮傚父":steErr.getErrName();
+ BasSteErrLog basSteErrLog = new BasSteErrLog(
+ null, // 缂栧彿
+ null, // 宸ヤ綔鍙�
+ now, // 鍙戠敓鏃堕棿
+ null, // 缁撴潫鏃堕棿
+ null, // 宸ヤ綔鐘舵��
+ null, // 鍏ュ嚭搴撶被鍨�
+ ste.getId(), // 鍫嗗灈鏈�
+ null, // plc
+ null, // 鐩爣搴撲綅
+ null, // 鐩爣绔�
+ null, // 婧愮珯
+ null, // 婧愬簱浣�
+ null, // 鏉$爜
+ (int)steProtocol.getAlarm(), // 寮傚父鐮�
+ errName, // 寮傚父
+ 1, // 寮傚父鎯呭喌
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ "鏃犱换鍔″紓甯�" // 澶囨敞
+ );
+ if (!basSteErrLogService.insert(basSteErrLog)) {
+ log.error("绌挎杞lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", ste.getId(), errName);
+ }
+ }
+ // 鏃犲紓甯�
+ } else {
+ // 寮傚父淇
+ if (latest != null && latest.getStatus() == 1) {
+ latest.setEndTime(now);
+ latest.setUpdateTime(now);
+ latest.setStatus(2);
+ if (!basSteErrLogService.updateById(latest)) {
+ log.error("绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", ste.getId(), latest.getId());
+ }
+ }
+ }
+ }
+ }
+ }
+
// -------------------------------------------------------------------------------
@@ -1906,14 +2103,36 @@
staProtocol = staProtocol.clone();
}
// 绔欑偣鏉′欢鍒ゆ柇
- if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
- && staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 && staProtocol.getWorkNo() <= 9999) || staProtocol.getWorkNo() == 9997) && staProtocol.isPakMk()) {
+ if (staProtocol.isAutoing()
+ && staProtocol.isLoading()
+ && staProtocol.isInEnable()
+ && staProtocol.isEmptyMk()
+ && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 || staProtocol.getWorkNo() <= 9999))
+ && staProtocol.isPakMk()) {
+
+ // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+ String barcode = null;
+ BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode());
+ if (barcodeThread != null) {
+ String barcode0 = barcodeThread.getBarcode();
+ if(!Cools.isEmpty(barcode0)) {
+// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", emptyInSta.getBarcode(), barcode0);
+ if(!"NG".endsWith(barcode0) && !"NoRead".equals(barcode0) && !"empty".equals(barcode0)) {
+ barcode = barcode0;
+ }
+ }
+ }
+
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed());
try {
LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
SearchLocParam param = new SearchLocParam();
param.setIoType(10);
+ if (!Cools.isEmpty(barcode)) {
+ param.setBarcode(barcode);
+ }
param.setSourceStaNo(emptyInSta.getStaNo());
param.setLocType1(locTypeDto.getLocType1());
String response = new HttpHandler.Builder()
@@ -1923,7 +2142,8 @@
.build()
.doPost();
JSONObject jsonObject = JSON.parseObject(response);
- if (jsonObject.getInteger("code").equals(200)) {
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
// 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
@@ -1935,7 +2155,13 @@
throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
} else {
- log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+ if (ledThread != null) {
+ String errorMsg = jsonObject.getString("msg");
+ if (!Cools.isEmpty(errorMsg)) {
+ 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) {
e.printStackTrace();
--
Gitblit v1.9.1