From 2f269a156fc820de8ee893475f0d89e0d77a732a Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期一, 11 十二月 2023 17:16:29 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/CrnController.java | 147 ++++++++++++++++++++++++++++++++++++-------------
1 files changed, 108 insertions(+), 39 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/CrnController.java b/src/main/java/com/zy/asrs/controller/CrnController.java
index 3690e3c..314a8fa 100644
--- a/src/main/java/com/zy/asrs/controller/CrnController.java
+++ b/src/main/java/com/zy/asrs/controller/CrnController.java
@@ -1,9 +1,7 @@
package com.zy.asrs.controller;
-import HslCommunication.Profinet.Siemens.SiemensS7Net;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
-import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.R;
@@ -21,6 +19,7 @@
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.service.impl.MainServiceImpl;
+import com.zy.asrs.utils.CommandUtils;
import com.zy.asrs.utils.VersionUtils;
import com.zy.core.CrnThread;
import com.zy.core.cache.MessageQueue;
@@ -37,8 +36,10 @@
import com.zy.core.properties.SystemProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -51,6 +52,11 @@
@Slf4j
@RestController
public class CrnController {
+
+ @Value("${wms.url}")
+ private String wmsUrl;
+ @Value("${wms.movePath}")
+ private String movePath;
@@ -125,8 +131,8 @@
vo.setLiftPos(crnProtocol.getLiftPosType().desc);
vo.setWalkPos(crnProtocol.getWalkPos()==1?"涓嶅湪瀹氫綅":"鍦ㄥ畾浣�");
vo.setWarnCode(String.valueOf(crnProtocol.getAlarm1()));
- if (crnProtocol.getAlarm1() > 0) {
- BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1());
+ if (crnProtocol.getAlarm() > 0) {
+ BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
vo.setAlarm(crnError==null?"鏈煡寮傚父":crnError.getErrName());
}
}
@@ -375,12 +381,13 @@
command.setTaskNo((short) 0); // 宸ヤ綔鍙�
command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
command.setTaskMode(CrnTaskModeType.PAKIN); // 浠诲姟妯″紡
- command.setSourcePosX(param.getSourceRow()); // 婧愬簱浣嶆帓
- command.setSourcePosY(param.getSourceBay()); // 婧愬簱浣嶅垪
- command.setSourcePosZ(param.getSourceLev()); // 婧愬簱浣嶅眰
- command.setDestinationPosX(param.getRow()); // 鐩爣搴撲綅鎺�
- command.setDestinationPosY(param.getBay()); // 鐩爣搴撲綅鍒�
- command.setDestinationPosZ(param.getLev()); // 鐩爣搴撲綅灞�
+ command.setSourcePosZ(param.getSourceRow()); // 婧愬簱浣嶆帓
+ command.setSourcePosX(param.getSourceBay()); // 婧愬簱浣嶅垪
+ command.setSourcePosY(param.getSourceLev()); // 婧愬簱浣嶅眰
+ command.setDestinationPosZ(param.getRow()); // 鐩爣搴撲綅鎺�
+ command.setDestinationPosX(param.getBay()); // 鐩爣搴撲綅鍒�
+ command.setDestinationPosY(param.getLev()); // 鐩爣搴撲綅灞�
+ command.setCommand((short)1);
return crnControl(command)?R.ok():R.error();
}
@@ -392,12 +399,12 @@
command.setTaskNo((short) 0); // 宸ヤ綔鍙�
command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
command.setTaskMode(CrnTaskModeType.PAKOUT); // 浠诲姟妯″紡
- command.setSourcePosX(param.getSourceRow()); // 婧愬簱浣嶆帓
- command.setSourcePosY(param.getSourceBay()); // 婧愬簱浣嶅垪
- command.setSourcePosZ(param.getSourceLev()); // 婧愬簱浣嶅眰
- command.setDestinationPosX(param.getRow()); // 鐩爣搴撲綅鎺�
- command.setDestinationPosY(param.getBay()); // 鐩爣搴撲綅鍒�
- command.setDestinationPosZ(param.getLev()); // 鐩爣搴撲綅灞�
+ command.setSourcePosZ(param.getSourceRow()); // 婧愬簱浣嶆帓
+ command.setSourcePosX(param.getSourceBay()); // 婧愬簱浣嶅垪
+ command.setSourcePosY(param.getSourceLev()); // 婧愬簱浣嶅眰
+ command.setDestinationPosZ(param.getRow()); // 鐩爣搴撲綅鎺�
+ command.setDestinationPosX(param.getBay()); // 鐩爣搴撲綅鍒�
+ command.setDestinationPosY(param.getLev()); // 鐩爣搴撲綅灞�
return crnControl(command)?R.ok():R.error();
}
@@ -409,12 +416,13 @@
command.setTaskNo((short) 0); // 宸ヤ綔鍙�
command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
command.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡
- command.setSourcePosX(param.getSourceRow()); // 婧愬簱浣嶆帓
- command.setSourcePosY(param.getSourceBay()); // 婧愬簱浣嶅垪
- command.setSourcePosZ(param.getSourceLev()); // 婧愬簱浣嶅眰
- command.setDestinationPosX(param.getRow()); // 鐩爣搴撲綅鎺�
- command.setDestinationPosY(param.getBay()); // 鐩爣搴撲綅鍒�
- command.setDestinationPosZ(param.getLev()); // 鐩爣搴撲綅灞�
+ command.setSourcePosZ(param.getSourceRow()); // 婧愬簱浣嶆帓
+ command.setSourcePosX(param.getSourceBay()); // 婧愬簱浣嶅垪
+ command.setSourcePosY(param.getSourceLev()); // 婧愬簱浣嶅眰
+ command.setDestinationPosZ(param.getRow()); // 鐩爣搴撲綅鎺�
+ command.setDestinationPosX(param.getBay()); // 鐩爣搴撲綅鍒�
+ command.setDestinationPosY(param.getLev()); // 鐩爣搴撲綅灞�
+ command.setCommand((short)1);
LocMast sourceLoc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("row1", command.getSourcePosX())
.eq("bay1", command.getSourcePosY()).eq("lev1", command.getSourcePosZ()));
LocMast loc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("row1", command.getDestinationPosX())
@@ -469,8 +477,8 @@
command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪
command.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰
command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺�
- command.setDestinationPosY((short) 34); // 鐩爣搴撲綅鍒�
- command.setDestinationPosZ((short) 5); // 鐩爣搴撲綅灞�
+ command.setDestinationPosY((short) 22); // 鐩爣搴撲綅鍒�
+ command.setDestinationPosZ((short) 1); // 鐩爣搴撲綅灞�
return crnControl(command)?R.ok():R.error();
}
@@ -566,7 +574,7 @@
crnCommand.setCommand((short) 0); // 浠诲姟瀹屾垚纭浣�
// 寤舵椂鍙戦��
Thread.sleep(1000L);
- if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(2, crnCommand))) {
+ if (CommandUtils.offer(SlaveType.Crn, crn.getId(), new Task(2, crnCommand), false)) {
return R.ok();
} else {
throw new CoolException("鍛戒护涓嬪彂澶辫触");
@@ -586,18 +594,79 @@
CrnCommand command = new CrnCommand();
command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
command.setTaskNo((short) 0); // 宸ヤ綔鍙�
-// command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
-// command.setTaskMode(CrnTaskModeType.PAKIN); // 浠诲姟妯″紡
-// command.setSourcePosX(param.getSourceRow()); // 婧愬簱浣嶆帓
-// command.setSourcePosY(param.getSourceBay()); // 婧愬簱浣嶅垪
-// command.setSourcePosZ(param.getSourceLev()); // 婧愬簱浣嶅眰
-// command.setDestinationPosX(param.getRow()); // 鐩爣搴撲綅鎺�
-// command.setDestinationPosY(param.getBay()); // 鐩爣搴撲綅鍒�
-// command.setDestinationPosZ(param.getLev()); // 鐩爣搴撲綅灞�
command.setAuto((short)1);
return crnControl2(command)?R.ok():R.error();
}
+ @ManagerAuth(memo = "鍒囨崲鍗婃墜鍔ㄦā寮�")
+ @PostMapping("/crn/operator/semiAutomatic")
+ public R crnsemiAutomatic(CrnOperatorParam param){
+ short[] array = new short[9];
+ CrnCommand command = new CrnCommand();
+ command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
+ command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+ command.setAuto((short)2);
+
+ return crnControl2(command)?R.ok():R.error();
+ }
+ @ManagerAuth(memo = "鍒囨崲鎵嬪姩妯″紡")
+ @PostMapping("/crn/operator/hand")
+ public R onlineWrk1(CrnOperatorParam param){
+ short[] array = new short[9];
+ CrnCommand command = new CrnCommand();
+ command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
+ command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+ command.setAuto((short)3);
+
+ return crnControl2(command)?R.ok():R.error();
+ }
+ @ManagerAuth(memo = "鐢宠瀹屾垚浠诲姟")
+ @PostMapping("/crn/operator/onlineWrk1")
+ public R onlineWrk2(CrnOperatorParam param){
+ short[] array = new short[9];
+ CrnCommand command = new CrnCommand();
+ command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
+ command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+ command.setOnlineWrk1((short)1);
+
+ return crnControl2(command)?R.ok():R.error();
+ }
+ @ManagerAuth(memo = "鐢宠鍙栨秷浠诲姟")
+ @PostMapping("/crn/operator/onlineWrk2")
+ public R onlineWrk3(CrnOperatorParam param){
+ short[] array = new short[9];
+ CrnCommand command = new CrnCommand();
+ command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
+ command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+ command.setOnlineWrk2((short)1);
+
+ return crnControl2(command)?R.ok():R.error();
+ }
+ @ManagerAuth(memo = "娓呴櫎鑱旀満浠诲姟")
+ @PostMapping("/crn/operator/onlineWrk3")
+ public R onlineWrk4(CrnOperatorParam param){
+ short[] array = new short[9];
+ CrnCommand command = new CrnCommand();
+ command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
+ command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+ command.setOnlineWrk3((short)1);
+
+ return crnControl2(command)?R.ok():R.error();
+ }
+ @ManagerAuth(memo = "鎭㈠鑱旀満浠诲姟")
+ @PostMapping("/crn/operator/onlineWrk4")
+ public R crnHand(CrnOperatorParam param){
+ short[] array = new short[9];
+ CrnCommand command = new CrnCommand();
+ command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
+ command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+ command.setOnlineWrk4((short)1);
+
+ return crnControl2(command)?R.ok():R.error();
+ }
+
+
+
private boolean crnControl2(CrnCommand command){
if (command.getCrnNo() == null) {
throw new CoolException("璇烽�夋嫨鍫嗗灈鏈�");
@@ -615,7 +684,7 @@
}
// 绌洪棽鍒ゆ柇
// if (crnProtocol.getStatusType().equals(com.zy.core.enums.CrnStatusType.IDLE) && crnProtocol.getTaskNo() == 0) {
- if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(4, command))) {
+ if (CommandUtils.offer(SlaveType.Crn, crn.getId(), new Task(4, command), false)) {
return true;
} else {
throw new CoolException("鍛戒护涓嬪彂澶辫触");
@@ -649,11 +718,11 @@
}
// 绌洪棽鍒ゆ柇
// if (crnProtocol.getStatusType().equals(com.zy.core.enums.CrnStatusType.IDLE) && crnProtocol.getTaskNo() == 0) {
- if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(2, command))) {
- return true;
- } else {
- throw new CoolException("鍛戒护涓嬪彂澶辫触");
- }
+ if (CommandUtils.offer(SlaveType.Crn, crn.getId(), new Task(2, command), false)) {
+ return true;
+ } else {
+ throw new CoolException("鍛戒护涓嬪彂澶辫触");
+ }
// } else {
// throw new CoolException("鍫嗗灈鏈轰笉鍦ㄧ┖闂茬姸鎬�");
// }
--
Gitblit v1.9.1