From 46d68076bfa7b706549e0420dfe09314024e3696 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 22 十一月 2024 21:02:39 +0800
Subject: [PATCH] #读取地图文件优化
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 628 ++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 403 insertions(+), 225 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 31c8325..292b860 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -44,7 +44,6 @@
*/
@Slf4j
@Service("mainService")
-@Transactional
public class MainServiceImpl {
@Value("${wms.url}")
@@ -113,6 +112,10 @@
private NavigateMapUtils navigateMapUtils;
@Autowired
private WrkDetlLogService wrkDetlLogService;
+ @Autowired
+ private MatService matService;
+ @Autowired
+ private NavigateMapData navigateMapData;
/**
@@ -120,89 +123,90 @@
* 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 2
*/
public void generateStoreWrkFile() {
- // 鏍规嵁杈撻�佺嚎plc閬嶅巻
- for (DevpSlave devp : slaveProperties.getDevp()) {
- // 閬嶅巻鍏ュ簱鍙�
- for (DevpSlave.Sta inSta : devp.getInSta()) {
- // 鑾峰彇鍏ュ簱绔欎俊鎭�
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
- StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
- if (staProtocol == null) {
- continue;
- } else {
- staProtocol = staProtocol.clone();
- }
- Short workNo = staProtocol.getWorkNo();
- // 灏哄妫�娴嬪紓甯�
- boolean back = false;
- String errMsg = "寮傚父锛�";
- if (staProtocol.isFrontErr()) {
- errMsg = errMsg+"鍓嶈秴闄愶紱";
- back = true;
- }
- if (staProtocol.isBackErr()) {
- errMsg = errMsg+"鍚庤秴闄�";
- back = true;
- }
- if (staProtocol.isHighErr()) {
- errMsg = errMsg+"楂樿秴闄�";
- back = true;
- }
- if (staProtocol.isLeftErr()) {
- errMsg = errMsg+"宸﹁秴闄�";
- back = true;
- }
- if (staProtocol.isRightErr()) {
- errMsg = errMsg+"鍙宠秴闄�";
- back = true;
- }
- if (staProtocol.isWeightErr()) {
- errMsg = errMsg+"瓒呴噸";
- back = true;
- }
- if (staProtocol.isBarcodeErr()) {
- errMsg = errMsg+"鎵爜澶辫触";
- back = true;
- }
- // 閫�鍥�
- if (back) {
- // led 寮傚父鏄剧ず
- LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
- if (ledThread != null) {
- MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
+ try {
+ // 鏍规嵁杈撻�佺嚎plc閬嶅巻
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ // 閬嶅巻鍏ュ簱鍙�
+ for (DevpSlave.Sta inSta : devp.getInSta()) {
+ // 鑾峰彇鍏ュ簱绔欎俊鎭�
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
+ if (staProtocol == null) {
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
}
- continue;
- }
-
- // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
- if (staProtocol.isAutoing() && staProtocol.isLoading()
- && staProtocol.isInEnable()
- && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999))
- ) {
-
- // 鑾峰彇鏉$爜鎵弿浠俊鎭�
- BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
- if (barcodeThread == null) {
+ Short workNo = staProtocol.getWorkNo();
+ // 灏哄妫�娴嬪紓甯�
+ boolean back = false;
+ String errMsg = "寮傚父锛�";
+ if (staProtocol.isFrontErr()) {
+ errMsg = errMsg + "鍓嶈秴闄愶紱";
+ back = true;
+ }
+ if (staProtocol.isBackErr()) {
+ errMsg = errMsg + "鍚庤秴闄�";
+ back = true;
+ }
+ if (staProtocol.isHighErr()) {
+ errMsg = errMsg + "楂樿秴闄�";
+ back = true;
+ }
+ if (staProtocol.isLeftErr()) {
+ errMsg = errMsg + "宸﹁秴闄�";
+ back = true;
+ }
+ if (staProtocol.isRightErr()) {
+ errMsg = errMsg + "鍙宠秴闄�";
+ back = true;
+ }
+ if (staProtocol.isWeightErr()) {
+ errMsg = errMsg + "瓒呴噸";
+ back = true;
+ }
+ if (staProtocol.isBarcodeErr()) {
+ errMsg = errMsg + "鎵爜澶辫触";
+ back = true;
+ }
+ // 閫�鍥�
+ if (back) {
+ // led 寮傚父鏄剧ず
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ if (ledThread != null) {
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
+ }
continue;
}
- String barcode = barcodeThread.getBarcode();
- if(!Cools.isEmpty(barcode)) {
+
+ // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
+ if (staProtocol.isAutoing() && staProtocol.isLoading()
+ && staProtocol.isInEnable()
+ && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999))
+ ) {
+
+ // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+ BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
+ if (barcodeThread == null) {
+ continue;
+ }
+ String barcode = barcodeThread.getBarcode();
+ if (!Cools.isEmpty(barcode)) {
// News.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
- if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)|| "00000000".equals(barcode)) {
+ if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode) || "00000000".equals(barcode)) {
// staProtocol.setWorkNo((short) 32002);
// 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));
+ // 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;
}
- continue;
- }
- } else {
+ } else {
// staProtocol.setWorkNo((short) 32002);
// staProtocol.setStaNo(inSta.getBackSta().shortValue());
// devpThread.setPakMk(staProtocol.getSiteId(), false);
@@ -214,42 +218,42 @@
// String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
// MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
// }
- continue;
- }
+ continue;
+ }
- // 杩囨护鐩樼偣/鎷f枡/骞舵澘浠诲姟
- WrkMast wrkMast1 = wrkMastMapper.selectPickStepByBarcode(barcode);
- if (null != wrkMast1) {
- continue;
- }
+ // 杩囨护鐩樼偣/鎷f枡/骞舵澘浠诲姟
+ WrkMast wrkMast1 = wrkMastMapper.selectPickStepByBarcode(barcode);
+ if (null != wrkMast1) {
+ continue;
+ }
- // 鍒ゆ柇閲嶅宸ヤ綔妗�
- WrkMast wrkMast2 = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
- if (wrkMast2 != null) {
- News.error("宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast2.getWrkNo());
- continue;
- }
+ // 鍒ゆ柇閲嶅宸ヤ綔妗�
+ WrkMast wrkMast2 = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
+ if (wrkMast2 != null) {
+ News.error("宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast2.getWrkNo());
+ continue;
+ }
- try {
- LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
- SearchLocParam param = new SearchLocParam();
- param.setBarcode(barcode);
- param.setIoType(1);
- param.setSourceStaNo(inSta.getStaNo());
- param.setLocType1(locTypeDto.getLocType1());
- String response = new HttpHandler.Builder()
- .setUri(wmsUrl)
- .setPath("/rpc/pakin/loc/v2")
- .setJson(JSON.toJSONString(param))
- .build()
- .doPost();
- JSONObject jsonObject = JSON.parseObject(response);
- 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("");
+ try {
+ LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
+ SearchLocParam param = new SearchLocParam();
+ param.setBarcode(barcode);
+ param.setIoType(1);
+ param.setSourceStaNo(inSta.getStaNo());
+ param.setLocType1(locTypeDto.getLocType1());
+ String response = new HttpHandler.Builder()
+ .setUri(wmsUrl)
+ .setPath("/rpc/pakin/loc/v2")
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ 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);
@@ -259,45 +263,50 @@
// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
// }
- // 鍒ゆ柇閲嶅宸ヤ綔妗�
- WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo());
- if (wrkMast == null) { continue; }
-
- // 鏇存柊宸ヤ綔涓绘。
- wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋
- wrkMast.setModiTime(new Date());
- if (wrkMastMapper.updateById(wrkMast) == 0) {
- News.error("鏇存柊宸ヤ綔妗eけ璐ワ紒锛侊紒 [宸ヤ綔鍙凤細{}]", wrkMast.getWrkNo());
- }
-
- } 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));
- ledThread.setLedMk(false);
+ // 鍒ゆ柇閲嶅宸ヤ綔妗�
+ WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo());
+ if (wrkMast == null) {
+ continue;
}
- }
- News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response);
- } else if (code == 700) {
+
+ // 鏇存柊宸ヤ綔涓绘。
+ wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋
+ wrkMast.setModiTime(new Date());
+ if (wrkMastMapper.updateById(wrkMast) == 0) {
+ News.error("鏇存柊宸ヤ綔妗eけ璐ワ紒锛侊紒 [宸ヤ綔鍙凤細{}]", wrkMast.getWrkNo());
+ }
+
+ } 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));
+ ledThread.setLedMk(false);
+ }
+ }
+ News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response);
+ } else if (code == 700) {
// staProtocol.setWorkNo((short) 32002);
// staProtocol.setRollback102(1);//102绔欏洖閫�淇″彿
// devpThread.setPakMk(staProtocol.getSiteId(), false);
// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(5, staProtocol));
- // led 寮傚父鏄剧ず
- if (ledThread != null) {
- String errorMsg = barcode + "鎵樼洏璇嗗埆寮傚父锛岃鍏堣繘琛岀粍鎵橈紒";
- MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
- ledThread.setLedMk(false);
+ // led 寮傚父鏄剧ず
+ if (ledThread != null) {
+ String errorMsg = barcode + "鎵樼洏璇嗗埆寮傚父锛岃鍏堣繘琛岀粍鎵橈紒";
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ ledThread.setLedMk(false);
+ }
}
+ } catch (Exception e) {
+ e.printStackTrace();
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
- } catch (Exception e) {
- e.printStackTrace();
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
}
}
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
@@ -931,8 +940,8 @@
if (basMap == null) {
//鏁版嵁搴撲腑涔熶笉瀛樺湪鍦板浘鏁版嵁锛屼粠鍦板浘鏂囦欢涓幏鍙�
//杞藉叆鍦板浘
- NavigateMapData mapData = new NavigateMapData(i);
- List<List<MapNode>> lists = mapData.getJsonData(-1, null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱)
+ navigateMapData.setLev(i);
+ List<List<MapNode>> lists = navigateMapData.getJsonData(-1, null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱)
//瀛樺叆鏁版嵁搴�
basMap = new BasMap();
@@ -2508,7 +2517,7 @@
/**
* AGV琛ヨ揣 => 鐢熸垚鍏ュ簱閫氱煡妗�
*/
- public void robotGenerateAgvTask() {
+ public synchronized void robotGenerateAgvTask() {
try {
//妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿
for (DevpSlave devp : slaveProperties.getDevp()) {
@@ -2534,10 +2543,13 @@
//鍒ゆ柇鏈烘鑷傛嫞鏂欑珯鏄惁绌洪棽
StaProtocol staProtocol303 = devpThread.getStation().get(303);
StaProtocol staProtocol317 = devpThread.getStation().get(317);
- if (staProtocol303.isAutoing() && !staProtocol303.isLoading()) {
+
+ List<WrkMast> wrkMasts303 = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 25).eq("sta_no", 303));
+ List<WrkMast> wrkMasts317 = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 25).eq("sta_no", 317));
+ if (staProtocol303.isAutoing() && !staProtocol303.isLoading() && wrkMasts303.isEmpty()) {
//鑷姩銆佹棤鐗�
targetSta = (short) 303;
- } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading()) {
+ } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading() && wrkMasts317.isEmpty()) {
//鑷姩銆佹棤鐗�
targetSta = (short) 317;
} else {
@@ -2576,7 +2588,7 @@
}
}
} catch (Exception e) {
- e.printStackTrace();
+// e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
@@ -2601,14 +2613,14 @@
}
}
} catch (Exception e) {
- e.printStackTrace();
+// e.printStackTrace();
}
}
/**
* AGV琛ヨ揣 => 鏈烘鑷傛嫞鏂�
*/
- public void agvRestockByRobot() {
+ public synchronized void agvRestockByRobot() {
try {
//妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿
for (DevpSlave devp : slaveProperties.getDevp()) {
@@ -2633,9 +2645,10 @@
}
if (wrkMast.getInvWh() == null) {
- wrkMast.setInvWh("Y");//鏍囪宸茬粡涓嬪彂鏈烘鑷備换鍔�
- if (wrkMastMapper.updateById(wrkMast) > 0) {
- RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetls.size(), "303");
+ boolean result = RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetls.size(), "303");
+ if (result) {
+ wrkMast.setInvWh("Y");//鏍囪宸茬粡涓嬪彂鏈烘鑷備换鍔�
+ wrkMastMapper.updateById(wrkMast);
}
}
}
@@ -2652,9 +2665,10 @@
continue;
}
if (wrkMast.getInvWh() == null) {
- wrkMast.setInvWh("Y");//鏍囪宸茬粡涓嬪彂鏈烘鑷備换鍔�
- if (wrkMastMapper.updateById(wrkMast) > 0) {
- RobotUtils.sendTask(staProtocol317.getWorkNo().toString(), wrkDetls.size(), "317");
+ boolean result = RobotUtils.sendTask(staProtocol317.getWorkNo().toString(), wrkDetls.size(), "317");
+ if (result) {
+ wrkMast.setInvWh("Y");//鏍囪宸茬粡涓嬪彂鏈烘鑷備换鍔�
+ wrkMastMapper.updateById(wrkMast);
}
}
}
@@ -2667,7 +2681,7 @@
/**
* AGV琛ヨ揣(閫氱煡AGV鍙栬揣)
*/
- public void agvRestockInto() {
+ public synchronized void agvRestockInto() {
try {
//妫�娴�309鍜�312绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗�
for (DevpSlave devp : slaveProperties.getDevp()) {
@@ -2688,8 +2702,11 @@
String barcode = barcodeThread.getBarcode();
if (!Cools.isEmpty(barcode)) {
//閫氱煡AGV鍙栬揣
- agvRestockCall("301-1", barcode);
- log.info("閫氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode);
+ boolean result = agvRestockCall("301-1", barcode);
+ log.info("鏈烘鑷傞�氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode);
+ if (result) {
+ barcodeThread.setBarcode("");
+ }
}
}
@@ -2702,8 +2719,11 @@
String barcode = barcodeThread.getBarcode();
if (!Cools.isEmpty(barcode)) {
//閫氱煡AGV鍙栬揣
- agvRestockCall("302-1", barcode);
- log.info("閫氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode);
+ boolean result = agvRestockCall("302-1", barcode);
+ log.info("鏈烘鑷傞�氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode);
+ if (result) {
+ barcodeThread.setBarcode("");
+ }
}
}
}
@@ -2737,13 +2757,38 @@
return false;
}
+ //閫氱煡WMS褰撳墠鎷f枡绔欑偣淇℃伅
+ private boolean agvCureentCall(String staNo, String barcode) {
+ try {
+ HashMap<String, Object> param = new HashMap<>();
+ param.put("devNo", staNo);
+ param.put("containerCode", barcode);
+ String response = new HttpHandler.Builder()
+ .setUri(wmsUrl)
+ .setPath("/rpc/current/containerCode")
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ News.info("鎮寕绾匡紝WMS杩斿洖缁撴灉锛�" + jsonObject);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {//鍛煎彨AGV
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ }
+ return false;
+ }
+
/**
* AGV琛ヨ揣(鎮寕绾块�氱煡AGV鍙栬揣)
*/
- public void agvRestockIntoByHangingWire() {
+ public synchronized void agvRestockIntoByHangingWire() {
try {
//妫�娴�350鍜�351鎵爜鍣�
- int[] barcodeStaNo = {11, 12};//11 => 350绔欐壂鐮佸櫒,12 => 351绔欐壂鐮佸櫒
+ int[] barcodeStaNo = {11, 12,14,16,18,20};//11 => 350绔欐壂鐮佸櫒,12 => 351绔欐壂鐮佸櫒
for (int staNo : barcodeStaNo) {
// 鑾峰彇鏉$爜鎵弿浠俊鎭�
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo);
@@ -2759,11 +2804,61 @@
String agvStaNo = null;
if (staNo == 11) {
agvStaNo = "303-1";
- } else {
+ } else if(staNo == 12){
agvStaNo = "304-1";
+ } else if(staNo == 14){
+ agvStaNo = "311-1";
+ } else if(staNo == 16){
+ agvStaNo = "313-1";
+ } else if(staNo == 18){
+ agvStaNo = "315-1";
+ } else if(staNo == 20){
+ agvStaNo = "317-1";
}
//閫氱煡AGV鍙栬揣
boolean result = agvRestockCall(agvStaNo, barcode);
+ if (result) {
+ barcodeThread.setBarcode("");
+ }
+ log.info(barcodeThread.getSlave().getId() + "鍙锋壂鐮佸櫒锛岄�氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * AGV鎷f枡绔欑偣淇℃伅
+ */
+ public synchronized void agvCurrentContainerCodeInfoWire() {
+ try {
+ //妫�娴�350鍜�351鎵爜鍣�
+ int[] barcodeStaNo = {13, 15,17,19};//11 => 350绔欐壂鐮佸櫒,12 => 351绔欐壂鐮佸櫒
+ for (int staNo : barcodeStaNo) {
+ // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+ BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo);
+ if (barcodeThread == null) {
+ continue;
+ }
+ String barcode = barcodeThread.getBarcode();
+ if (!Cools.isEmpty(barcode)) {
+ if (barcode.contains("NoRead")) {
+ continue;
+ }
+
+ String agvStaNo = null;
+ if (staNo == 13) {
+ agvStaNo = "CS-310";
+ } else if(staNo == 15){
+ agvStaNo = "CS-311";
+ } else if(staNo == 17){
+ agvStaNo = "CS-312";
+ } else if(staNo == 19){
+ agvStaNo = "CS-313";
+ }
+ //閫氱煡WMS褰撳墠瀹瑰櫒鐮�
+ boolean result = agvCureentCall(agvStaNo, barcode);
if (result) {
barcodeThread.setBarcode("");
}
@@ -2785,7 +2880,10 @@
StaProtocol staProtocol = devpThread.getStation().get(300);
if (staProtocol == null) {
continue;
+ }else {
+ staProtocol = staProtocol.clone();
}
+
if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) {
//鏌ヨ鏄惁鏈夊伐浣滄。
WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue());
@@ -2906,56 +3004,132 @@
ledCommand.setStaNo(wrkStaNo);
ledCommand.setBarcode(barcode);
if (ioType != 110 && ioType != 10) {
- List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo));
- locDetls.forEach(locDetl -> {
- Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no", wrkNo);
- Utils.wapperSetCondition(wrapper, "batch", locDetl.getBatch());
- Utils.wapperSetCondition(wrapper, "three_code", locDetl.getThreeCode());
- Utils.wapperSetCondition(wrapper, "dead_time", locDetl.getDeadTime());
- Utils.wapperSetCondition(wrapper, "supp_code", locDetl.getSuppCode());//鏂欑鐮�
- List<WrkDetl> detl = wrkDetlService.selectList(wrapper);
- if (Cools.isEmpty(detl)) {
- String suppCode = "";
- if (locDetl.getSuppCode() != null) {
- suppCode = locDetl.getSuppCode();
- }
- ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode));
- } else {
- //鍑哄簱鏁伴噺绱
- Double conut = 0.0;
- for (WrkDetl wrkDetl : detl) {
- conut = conut + wrkDetl.getAnfme();
- }
-
- for (WrkDetl wrkDetl : detl) {
- String suppCode = "";
- if (wrkDetl.getSuppCode() != null) {
- suppCode = wrkDetl.getSuppCode();
- }
- ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), (locDetl.getAnfme() - conut), wrkDetl.getSpecs(), suppCode, wrkDetl.getOrderNo()));
- }
- }
-
- });
-
- if (ioType == 107) {
- locDetls = new ArrayList<>();
- ledCommand.setMatDtos(new ArrayList<>());
- }
-
- if (locDetls.isEmpty()) {
- List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo));
+ List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo));
+ if (!wrkDetls.isEmpty()) {
wrkDetls.forEach(wrkDetl -> {
- ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getAnfme(), wrkDetl.getSpecs(), wrkDetl.getSuppCode()));
- });
-
- if (wrkDetls.isEmpty()) {//浠庡巻鍙叉。鏌ヨ
- List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectLatestByWorkNo(wrkNo, barcode);
- for (WrkDetlLog wrkDetlLog : wrkDetlLogs) {
- ledCommand.getMatDtos().add(new MatDto(wrkDetlLog.getMatnr(), wrkDetlLog.getMaktx(), wrkDetlLog.getAnfme(), wrkDetlLog.getAnfme(), wrkDetlLog.getSpecs(), wrkDetlLog.getSuppCode()));
+ double remainNum = wrkDetl.getStock() - wrkDetl.getAnfme();//鍓╀綑鏁伴噺
+ if (remainNum < 0) {
+ remainNum = 0;
}
+ String matnr = wrkDetl.getMatnr();
+ Mat mat = matService.selectByMatnr(wrkDetl.getMatnr());
+ if (mat != null) {
+ if (!mat.getMatnr().equals(mat.getMatnr2())) {
+ matnr += " - " + mat.getMatnr2();
+ }
+ }
+ ledCommand.getMatDtos().add(new MatDto(matnr, wrkDetl.getMaktx(), wrkDetl.getAnfme(), remainNum, wrkDetl.getSpecs(), wrkDetl.getSuppCode(), wrkDetl.getOrderNo()));
+ });
+ }else {
+ List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectLatestByWorkNo(wrkNo, barcode);
+ for (WrkDetlLog wrkDetlLog : wrkDetlLogs) {
+ double remainNum = wrkDetlLog.getStock() - wrkDetlLog.getAnfme();//鍓╀綑鏁伴噺
+ if (remainNum < 0) {
+ remainNum = 0;
+ }
+ String matnr = wrkDetlLog.getMatnr();
+ Mat mat = matService.selectByMatnr(wrkDetlLog.getMatnr());
+ if (mat != null) {
+ if (!mat.getMatnr().equals(mat.getMatnr2())) {
+ matnr += " - " + mat.getMatnr2();
+ }
+ }
+ ledCommand.getMatDtos().add(new MatDto(matnr, wrkDetlLog.getMaktx(), wrkDetlLog.getAnfme(), remainNum, wrkDetlLog.getSpecs(), wrkDetlLog.getSuppCode()));
}
}
+
+// List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo));
+// if (ioType == 101) {
+// List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo));
+// wrkDetls.forEach(wrkDetl -> {
+// ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), 0D, wrkDetl.getSpecs(), wrkDetl.getSuppCode()));
+// });
+//// locDetls.forEach(locDetl -> {
+//// Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no", wrkNo);
+//// Utils.wapperSetCondition(wrapper, "batch", locDetl.getBatch());
+//// Utils.wapperSetCondition(wrapper, "three_code", locDetl.getThreeCode());
+//// Utils.wapperSetCondition(wrapper, "dead_time", locDetl.getDeadTime());
+//// Utils.wapperSetCondition(wrapper, "supp_code", locDetl.getSuppCode());//鏂欑鐮�
+//// List<WrkDetl> detl = wrkDetlService.selectList(wrapper);
+//// if (Cools.isEmpty(detl)) {
+//// String suppCode = "";
+//// if (locDetl.getSuppCode() != null) {
+//// suppCode = locDetl.getSuppCode();
+//// }
+//// ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode));
+//// } else {
+//// //鍑哄簱鏁伴噺绱
+//// Double conut = 0.0;
+//// for (WrkDetl wrkDetl : detl) {
+//// conut = conut + wrkDetl.getAnfme();
+//// }
+////
+//// for (WrkDetl wrkDetl : detl) {
+//// String suppCode = "";
+//// if (wrkDetl.getSuppCode() != null) {
+//// suppCode = wrkDetl.getSuppCode();
+//// }
+//// ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), (locDetl.getAnfme() - conut), wrkDetl.getSpecs(), suppCode, wrkDetl.getOrderNo()));
+//// }
+//// }
+////
+//// });
+// } else {
+// locDetls.forEach(locDetl -> {
+// Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no", wrkNo);
+// Utils.wapperSetCondition(wrapper, "batch", locDetl.getBatch());
+// Utils.wapperSetCondition(wrapper, "three_code", locDetl.getThreeCode());
+// Utils.wapperSetCondition(wrapper, "dead_time", locDetl.getDeadTime());
+// Utils.wapperSetCondition(wrapper, "supp_code", locDetl.getSuppCode());//鏂欑鐮�
+// List<WrkDetl> detl = wrkDetlService.selectList(wrapper);
+// if (Cools.isEmpty(detl)) {
+// String suppCode = "";
+// if (locDetl.getSuppCode() != null) {
+// suppCode = locDetl.getSuppCode();
+// }
+// ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode));
+// } else {
+// //鍑哄簱鏁伴噺绱
+// Double conut = 0.0;
+// for (WrkDetl wrkDetl : detl) {
+// conut = conut + wrkDetl.getAnfme();
+// }
+//
+// for (WrkDetl wrkDetl : detl) {
+// String suppCode = "";
+// if (wrkDetl.getSuppCode() != null) {
+// suppCode = wrkDetl.getSuppCode();
+// }
+// ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), (wrkDetl.getStock() - conut), wrkDetl.getSpecs(), suppCode, wrkDetl.getOrderNo()));
+// }
+// }
+//
+// });
+// }
+//
+//
+// if (ioType == 107) {
+// locDetls = new ArrayList<>();
+// ledCommand.setMatDtos(new ArrayList<>());
+// }
+//
+// if (locDetls.isEmpty() && ioType != 101) {
+// List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo));
+// wrkDetls.forEach(wrkDetl -> {
+// if (wrkDetl.getAnfme() > 0D) {
+// ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getAnfme(), wrkDetl.getSpecs(), wrkDetl.getSuppCode()));
+// }
+// });
+//
+// if (wrkDetls.isEmpty()) {//浠庡巻鍙叉。鏌ヨ
+// List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectLatestByWorkNo(wrkNo, barcode);
+// for (WrkDetlLog wrkDetlLog : wrkDetlLogs) {
+// if (wrkDetlLog.getAnfme() > 0D) {
+// ledCommand.getMatDtos().add(new MatDto(wrkDetlLog.getMatnr(), wrkDetlLog.getMaktx(), wrkDetlLog.getAnfme(), wrkDetlLog.getAnfme(), wrkDetlLog.getSpecs(), wrkDetlLog.getSuppCode()));
+// }
+// }
+// }
+// }
}
commands.add(ledCommand);
@@ -3977,32 +4151,36 @@
//鎵弿璁惧PakMk鏍囪鏄惁瓒呮椂
public synchronized void scanDevicePakMk() {
- //鎵弿灏忚溅
- for (ShuttleSlave slave : slaveProperties.getShuttle()) {
- NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
- NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
- if (shuttleProtocol == null) {
- continue;
+ try {
+ //鎵弿灏忚溅
+ for (ShuttleSlave slave : slaveProperties.getShuttle()) {
+ NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
+ NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ if (shuttleProtocol == null) {
+ continue;
+ }
+
+ if ((System.currentTimeMillis() - shuttleProtocol.getSendTime() > (1000 * 60 * 5)) && shuttleProtocol.getPakMk()) {
+ //璁惧瓒呰繃5鍒嗛挓杩樻病澶嶄綅鏍囪
+ shuttleProtocol.setPakMk(false);//澶嶄綅鏍囪
+ }
}
- if ((System.currentTimeMillis() - shuttleProtocol.getSendTime() > (1000*60*5)) && shuttleProtocol.getPakMk()) {
- //璁惧瓒呰繃5鍒嗛挓杩樻病澶嶄綅鏍囪
- shuttleProtocol.setPakMk(false);//澶嶄綅鏍囪
- }
- }
+ //鎵弿鎻愬崌鏈�
+ for (LiftSlave slave : slaveProperties.getLift()) {
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId());
+ LiftProtocol liftProtocol = liftThread.getLiftProtocol();
+ if (liftProtocol == null) {
+ continue;
+ }
- //鎵弿鎻愬崌鏈�
- for (LiftSlave slave : slaveProperties.getLift()) {
- LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId());
- LiftProtocol liftProtocol = liftThread.getLiftProtocol();
- if (liftProtocol == null) {
- continue;
+ if ((System.currentTimeMillis() - liftProtocol.getSendTime() > (1000 * 60 * 5)) && liftProtocol.getPakMk()) {
+ //璁惧瓒呰繃5鍒嗛挓杩樻病澶嶄綅鏍囪
+ liftProtocol.setPakMk(false);//澶嶄綅鏍囪
+ }
}
-
- if ((System.currentTimeMillis() - liftProtocol.getSendTime() > (1000*60*5)) && liftProtocol.getPakMk()) {
- //璁惧瓒呰繃5鍒嗛挓杩樻病澶嶄綅鏍囪
- liftProtocol.setPakMk(false);//澶嶄綅鏍囪
- }
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
--
Gitblit v1.9.1