From 24393cdbdcc3f3e921050e733bd6a27208d4ea55 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 09 五月 2023 12:48:54 +0800
Subject: [PATCH] console.html fixed
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 318 +++++++++++++++++++++++++++++++---------------------
1 files changed, 189 insertions(+), 129 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 aad864d..f2b386c 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -68,6 +68,10 @@
@Autowired
private BasSteErrLogService basSteErrLogService;
@Autowired
+ private BasShuttleErrLogService basShuttleErrLogService;
+ @Autowired
+ private BasShuttleErrService basShuttleErrService;
+ @Autowired
private BasCrnErrorMapper basCrnErrorMapper;
@Autowired
private BasSteService basSteService;
@@ -602,115 +606,6 @@
}
}
-// /**
-// * 鍏ュ簱 ===>> 鍥涘悜绌挎杞﹀叆搴撲綔涓氫笅鍙�
-// */
-// public synchronized void shuttleIoInExecute() {
-// // 鏍规嵁杈撻�佺嚎plc閬嶅巻
-// for (DevpSlave devp : slaveProperties.getDevp()) {
-// // 閬嶅巻鍏ュ簱绔�
-// for (DevpSlave.StaRack rackInStn : devp.getRackInStn()) {
-// // 鑾峰彇鍏ュ簱绔欎俊鎭�
-// DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
-//
-// StaProtocol staProtocol = devpThread.getStation().get(rackInStn.getStaNo());
-// StaProtocol staProtocol105 = devpThread.getStation().get(105);
-// staProtocol105.setWorkNo((short) 752);
-// staProtocol105.setStaNo((short) 100);
-//
-// StaProtocol staProtocol106 = devpThread.getStation().get(106);
-// staProtocol106.setWorkNo((short) 753);
-// staProtocol106.setStaNo((short) 100);
-//
-// if (staProtocol == null) {
-// continue;
-// } else {
-// staProtocol = staProtocol.clone();
-// }
-// Short workNo = staProtocol.getWorkNo();
-//
-// // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
-// if (true || staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()) {
-// WrkMast wrkMast = wrkMastMapper.selectRackInStep48(workNo, staProtocol.getSiteId());
-// if (wrkMast != null) {
-// if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 8) {
-// ShuttleThread shuttleThread = null;
-// HashMap<String, Object> searchIdleShuttle = null;
-// if (wrkMast.getWrkSts() == 4) {
-// //瀵绘壘鏈�杩戜笖绌洪棽鐨勫洓鍚戠┛姊溅
-// searchIdleShuttle = this.searchIdleShuttle(wrkMast);
-// shuttleThread = (ShuttleThread) searchIdleShuttle.get("result");
-// }else {
-// //鐘舵��8锛屽洓鍚戠┛姊溅宸插湪鎻愬崌鏈哄彛锛岀瓑寰呭懡浠よ繘琛屽叆搴撴惉杩愬姩浣�
-// Integer shuttleNo = wrkMast.getShuttleNo();//鍥涘悜绌挎杞﹀彿
-// shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
-// }
-//
-// if (shuttleThread == null) {
-// continue;
-// }
-//
-// ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
-// if (!shuttleProtocol.isIdle()) {
-// continue;
-// }
-//
-// wrkMast.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());//缁欏伐浣滄。鍒嗛厤鍥涘悜绌挎杞﹀彿
-//
-// //鍒嗛厤浠诲姟鍙�
-// shuttleProtocol.setTaskNo(wrkMast.getWrkNo().shortValue());
-// //鍒嗛厤婧愬簱浣�
-// shuttleProtocol.setSourceLocNo(wrkMast.getSourceLocNo());
-//
-// ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
-// //鍥涘悜绌挎杞﹀彿
-// assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());
-// //浠诲姟鍙�
-// assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());
-// //鍏ュ嚭搴撴ā寮�
-// assignCommand.setTaskMode(ShuttleTaskModeType.PAK_IN.id.shortValue());
-// //婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
-// String currentLocNo = shuttleProtocol.getCurrentLocNo();
-// assignCommand.setSourceLocNo(currentLocNo);
-//
-// if (wrkMast.getWrkSts() == 8 || Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) {
-// //鍚屼竴灞�
-// //鍒嗛厤鐩爣搴撲綅
-// shuttleProtocol.setLocNo(wrkMast.getLocNo());
-// //鐩爣搴撲綅
-// assignCommand.setLocNo(wrkMast.getLocNo());
-// wrkMast.setWrkSts(9L);//灏忚溅鍏ュ簱涓�
-//
-// //鑾峰彇浠庡皬杞�
-// }else {
-// //涓嶅悓灞傦紝灏嗙洰鏍囧簱浣嶅垎閰嶆垚鎻愬崌鏈哄簱浣嶅彿
-//
-// //灏忚溅褰撳墠灞傞珮
-// Integer currentLev = Integer.parseInt(currentLocNo.substring(currentLocNo.length() - 2, currentLocNo.length()));
-//
-// //鑾峰彇鎻愬崌鏈�
-// LiftSlave liftSlave = slaveProperties.getLift().get(0);
-// //鎻愬崌鏈哄簱浣嶅彿
-// String liftLocNo = liftSlave.getLiftLocNo(currentLev);
-// shuttleProtocol.setLocNo(liftLocNo);
-// //鐩爣搴撲綅
-// assignCommand.setLocNo(liftLocNo);
-// wrkMast.setWrkSts(5L);//灏忚溅杩佺Щ鐘舵��
-// }
-//
-// if (wrkMastMapper.updateById(wrkMast) > 0) {
-// //涓嬪彂浠诲姟
-// MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
-// }
-// }
-//
-// }
-// }
-//
-// }
-// }
-//
-// }
/**
* 鍏ュ簱 ===>> 鍥涘悜绌挎杞﹀叆搴撲綔涓氫笅鍙�
@@ -793,6 +688,19 @@
//鍚屼竴灞傜洿鎺ュ彇璐ф棤闇�缁忚繃鎻愬崌鏈�
//鐩存帴璁$畻杞﹀埌鎻愬崌鏈哄彇璐у啀鍒板簱浣嶈矾寰勬寚浠�
List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, locNo);
+ if (wrkMast.getWrkSts() == 8) {
+ //姝ゆ椂杞﹀湪鎻愬崌鏈哄唴閮紝闇�瑕佸涓嬭揪涓�姝ユ寚浠よ杞︾Щ鍔ㄥ埌鎻愬崌鏈哄彛
+ BasDevp basDevp = basDevpService.selectById(109);//鑾峰彇鎻愬崌鏈轰俊鎭�
+ ShuttleCommand moveCommand = new ShuttleCommand();
+ moveCommand.setCommandWord((short) 1);
+ moveCommand.setStartCodeNum(Short.parseShort(basDevp.getQrCodeValue()));//鎻愬崌鏈哄唴閮ㄤ簩缁寸爜
+ moveCommand.setDistCodeNum(commands.get(0).getStartCodeNum());//鎻愬崌鏈哄彛浜岀淮鐮�
+ moveCommand.setStartToDistDistance(1300);
+ moveCommand.setMiddleToDistDistance(0);
+ moveCommand.setRunDirection(commands.get(0).getRunDirection());
+ moveCommand.setCommandEnd((short) 1);
+ commands.add(0, moveCommand);//灏嗚鎸囦护娣诲姞鍒伴槦澶�
+ }
assignCommand.setCommands(commands);
//鍒嗛厤鐩爣搴撲綅
shuttleProtocol.setLocNo(wrkMast.getLocNo());
@@ -847,17 +755,24 @@
ShuttleCommand command = new ShuttleCommand();
command.setCommandWord((short) 1);
- command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY()));
- command.setMiddleCodeNum((short) 0);
- command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY()));
+
+ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
+ Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ());
+ command.setStartCodeNum(startCodeNum);
+
+ command.setMiddleCodeNum((short) 1);
+
+ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
+ Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ());
+ command.setDistCodeNum(distCodeNum);
+
command.setStartToDistDistance(allDistance);
- command.setMiddleToDistDistance(1000);
+ command.setMiddleToDistDistance(0);
command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id);
command.setPalletLift((short) 1);
- command.setForceMoveDistance(1000);
+ command.setForceMoveDistance(0);
command.setChargeSwitch((short) 2);
command.setIOControl((short) 0);
- command.setRunSpeed((short) 1000);
command.setRadarTmp((short) 0);
command.setCommandEnd((short) 1);
commands.add(command);
@@ -886,17 +801,24 @@
ShuttleCommand command = new ShuttleCommand();
command.setCommandWord((short) 1);
- command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY()));
- command.setMiddleCodeNum((short) 0);
- command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY()));
+
+ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
+ Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ());
+ command.setStartCodeNum(startCodeNum);
+
+ command.setMiddleCodeNum((short) 1);
+
+ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
+ Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ());
+ command.setDistCodeNum(distCodeNum);
+
command.setStartToDistDistance(allDistance);
- command.setMiddleToDistDistance(1000);
+ command.setMiddleToDistDistance(0);
command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id);
command.setPalletLift((short) 1);
- command.setForceMoveDistance(1000);
+ command.setForceMoveDistance(0);
command.setChargeSwitch((short) 2);
command.setIOControl((short) 0);
- command.setRunSpeed((short) 1000);
command.setRadarTmp((short) 0);
command.setCommandEnd((short) 1);
commands.add(command);
@@ -926,17 +848,24 @@
command = new ShuttleCommand();
command.setCommandWord((short) 1);
- command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY()));
- command.setMiddleCodeNum((short) 0);
- command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY()));
+
+ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
+ Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ());
+ command.setStartCodeNum(startCodeNum);
+
+ command.setMiddleCodeNum((short) 1);
+
+ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
+ Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ());
+ command.setDistCodeNum(distCodeNum);
+
command.setStartToDistDistance(allDistance);
- command.setMiddleToDistDistance(1000);
+ command.setMiddleToDistDistance(0);
command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id);
command.setPalletLift((short) 1);
- command.setForceMoveDistance(1000);
+ command.setForceMoveDistance(0);
command.setChargeSwitch((short) 2);
command.setIOControl((short) 0);
- command.setRunSpeed((short) 1000);
command.setRadarTmp((short) 0);
command.setCommandEnd((short) 1);
commands.add(command);
@@ -1052,6 +981,18 @@
}
} else if (wrkMast.getWrkSts() == 25) {
List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo);
+ //姝ゆ椂杞﹀湪鎻愬崌鏈哄唴閮紝闇�瑕佸涓嬭揪涓�姝ユ寚浠よ杞︾Щ鍔ㄥ埌鎻愬崌鏈哄彛
+ BasDevp basDevp = basDevpService.selectById(109);//鑾峰彇鎻愬崌鏈轰俊鎭�
+ ShuttleCommand moveCommand = new ShuttleCommand();
+ moveCommand.setCommandWord((short) 1);//灏忚溅绉诲姩鎸囦护瀛�
+ moveCommand.setStartCodeNum(Short.parseShort(basDevp.getQrCodeValue()));//鎻愬崌鏈轰簩缁寸爜
+ moveCommand.setDistCodeNum(commands.get(0).getStartCodeNum());
+ moveCommand.setStartToDistDistance(1300);
+ moveCommand.setMiddleToDistDistance(0);
+ moveCommand.setRunDirection(commands.get(0).getRunDirection());
+ moveCommand.setCommandEnd((short) 1);
+ commands.add(0, moveCommand);//灏嗚鎸囦护娣诲姞鍒伴槦澶�
+
//鍒嗛厤鐩爣搴撲綅
shuttleProtocol.setLocNo(wrkMast.getSourceLocNo());
//鐩爣搴撲綅
@@ -2918,10 +2859,129 @@
*/
public void recErr() {
try {
+ this.recShuttleErr();
this.recCrnErr();
this.recSteErr();
} catch (Exception e) {
News.error("recErr fail", e);
+ }
+ }
+
+ /**
+ * 鍥涘悜绌挎杞﹀紓甯镐俊鎭褰�
+ */
+ private void recShuttleErr() {
+ Date now = new Date();
+ for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) {
+ // 鑾峰彇鍫嗗灈鏈轰俊鎭�
+ ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleSlave.getId());
+ if (shuttleThread == null) {
+ continue;
+ }
+ ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ if (shuttleProtocol == null) {
+ continue;
+ }
+
+ if (shuttleProtocol.getTaskNo() != 0) {
+ //鏈変换鍔�
+ BasShuttleErrLog latest = basShuttleErrLogService.findLatestByTaskNo(shuttleSlave.getId(), shuttleProtocol.getTaskNo().intValue());
+ // 鏈夊紓甯�
+ if (latest == null) {
+ if (shuttleProtocol.getStatusErrorCode() != null && shuttleProtocol.getStatusErrorCode() > 0) {
+ WrkMast wrkMast = wrkMastMapper.selectById(shuttleProtocol.getTaskNo());
+ if (wrkMast == null) {
+ continue;
+ }
+ BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(shuttleProtocol.getStatusErrorCode().intValue());
+ String errName = basShuttleErr==null? "鏈煡寮傚父":basShuttleErr.getErrName();
+ BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog(
+ null, // 缂栧彿
+ wrkMast.getWrkNo(), // 宸ヤ綔鍙�
+ now, // 鍙戠敓鏃堕棿
+ null, // 缁撴潫鏃堕棿
+ wrkMast.getWrkSts(), // 宸ヤ綔鐘舵��
+ wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨�
+ shuttleSlave.getId(), // 鍥涘悜绌挎杞�
+ null, // plc
+ wrkMast.getLocNo(), // 鐩爣搴撲綅
+ wrkMast.getStaNo(), // 鐩爣绔�
+ wrkMast.getSourceStaNo(), // 婧愮珯
+ wrkMast.getSourceLocNo(), // 婧愬簱浣�
+ wrkMast.getBarcode(), // 鏉$爜
+ (int) shuttleProtocol.getStatusErrorCode(), // 寮傚父鐮�
+ errName, // 寮傚父
+ 1, // 寮傚父鎯呭喌
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ "浠诲姟涓紓甯�" // 澶囨敞
+ );
+ if (!basShuttleErrLogService.insert(basShuttleErrLog)) {
+ News.error("鍥涘悜绌挎杞lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName);
+ }
+ }
+ } else {
+ // 寮傚父淇
+ if (shuttleProtocol.getStatusErrorCode() == null || shuttleProtocol.getStatusErrorCode() == 0) {
+ latest.setEndTime(now);
+ latest.setUpdateTime(now);
+ latest.setStatus(2);
+ if (!basShuttleErrLogService.updateById(latest)) {
+ News.error("鍥涘悜绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", shuttleSlave.getId(), latest.getId());
+ }
+ }
+ }
+ }else {
+ //鏃犱换鍔�
+ BasShuttleErrLog latest = basShuttleErrLogService.findLatest(shuttleSlave.getId());
+ // 鏈夊紓甯�
+ if (shuttleProtocol.getStatusErrorCode() != null && shuttleProtocol.getStatusErrorCode() > 0) {
+ // 璁板綍鏂板紓甯�
+ if (latest == null || (latest.getErrCode() != shuttleProtocol.getStatusErrorCode().intValue())) {
+ BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(shuttleProtocol.getStatusErrorCode().intValue());
+ String errName = basShuttleErr==null? "鏈煡寮傚父":basShuttleErr.getErrName();
+ BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog(
+ null, // 缂栧彿
+ null, // 宸ヤ綔鍙�
+ now, // 鍙戠敓鏃堕棿
+ null, // 缁撴潫鏃堕棿
+ null, // 宸ヤ綔鐘舵��
+ null, // 鍏ュ嚭搴撶被鍨�
+ shuttleSlave.getId(), // 鍥涘悜绌挎杞�
+ null, // plc
+ null, // 鐩爣搴撲綅
+ null, // 鐩爣绔�
+ null, // 婧愮珯
+ null, // 婧愬簱浣�
+ null, // 鏉$爜
+ (int)shuttleProtocol.getStatusErrorCode(), // 寮傚父鐮�
+ errName, // 寮傚父
+ 1, // 寮傚父鎯呭喌
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ "鏃犱换鍔″紓甯�" // 澶囨敞
+ );
+ if (!basShuttleErrLogService.insert(basShuttleErrLog)) {
+ News.error("鍥涘悜绌挎杞lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName);
+ }
+ }
+ // 鏃犲紓甯�
+ } else {
+ // 寮傚父淇
+ if (latest != null && latest.getStatus() == 1) {
+ latest.setEndTime(now);
+ latest.setUpdateTime(now);
+ latest.setStatus(2);
+ if (!basShuttleErrLogService.updateById(latest)) {
+ News.error("鍥涘悜绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", shuttleSlave.getId(), latest.getId());
+ }
+ }
+ }
+ }
}
}
@@ -3643,8 +3703,8 @@
} else if (wrkCharge.getWrkSts() == 56) {
//鍏呯數涓�
- //鍒ゆ柇灏忚溅鏄惁鍏呮弧鐢甸噺
- if (shuttleProtocol.getBatteryPower() == 1000) {
+ //鍒ゆ柇灏忚溅鏄惁鍏呮弧鐢甸噺锛屾弧鐢�1000鎴栫數鍘�54V浠ヤ笂
+ if (shuttleProtocol.getBatteryPower() >= 1000 || shuttleProtocol.getCurrentVoltage() >= 540) {
//鍏呮弧锛屾柇寮�鍏呯數
List<ShuttleCommand> commands = new ArrayList<>();
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
--
Gitblit v1.9.1