From 36c6d6b39e2b76080480c5bc90a412d711b76144 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 19 六月 2024 15:54:24 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/Four-Way-Rack' into Four-Way-Rack
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java | 85 +++++++++++++++++++++++++++++++++---------
1 files changed, 66 insertions(+), 19 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
index 6773aea..41fe225 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
@@ -9,7 +9,6 @@
import com.zy.asrs.common.utils.HttpHandler;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SnowflakeIdWorker;
-import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.core.domain.dto.MatDto;
import com.zy.asrs.wcs.core.domain.dto.RedisMapDto;
import com.zy.asrs.wcs.core.domain.dto.StaDto;
@@ -82,6 +81,8 @@
private BasConveyorService basConveyorService;
@Autowired
private BasConveyorStaService basConveyorStaService;
+ @Autowired
+ private BasConveyorPathService basConveyorPathService;
@Autowired
private BasLedService basLedService;
@@ -220,10 +221,19 @@
Integer code = jsonObject.getInteger("code");
if (code.equals(200)) {
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
- devpThread.writeWorkSta(staProtocol.getSiteId(), dto.getWorkNo().shortValue(), dto.getStaNo().shortValue());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- } else if (code == 500) {
+ //鑾峰彇杈撻�佽矾寰�
+ BasConveyorPath conveyorPath = basConveyorPathService.getOne(new LambdaQueryWrapper<BasConveyorPath>()
+ .eq(BasConveyorPath::getTypeNo, TaskCtgType.IN.val())
+ .eq(BasConveyorPath::getDeviceId, devp.getId())
+ .eq(BasConveyorPath::getStnNo, staProtocol.getSiteId()));
+ if (conveyorPath == null) {
+ News.error("杈撻�佽矾寰勪笉瀛樺湪");
+ }else {
+ devpThread.writeWorkSta(staProtocol.getSiteId(), dto.getWorkNo().shortValue(), conveyorPath.getDeviceStn().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ }
+ }else {
if (ledThread != null) {
String errorMsg = jsonObject.getString("msg");
if (!Cools.isEmpty(errorMsg)) {
@@ -232,18 +242,6 @@
}
}
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 + "鎵樼洏璇嗗埆寮傚父锛岃鍏堣繘琛岀粍鎵橈紒";
- ledThread.error(errorMsg);
- ledThread.setLedMk(false);
- }
}
} catch (Exception e) {
e.printStackTrace();
@@ -423,6 +421,23 @@
// 瑙f瀽鍏ュ簱宸ヤ綔妗�
public synchronized void analyzeInBoundTask() {
for (Task task : taskService.selectWaitAnalyzeInBoundTask()) {
+ if (Cools.isEmpty(task.getShuttleNo())) {
+ //鍒嗛厤灏忚溅
+ //鎼滅储绌洪棽杞�
+ ShuttleThread shuttleThread = shuttleDispatcher.searchIdleShuttle(task);
+ if (shuttleThread == null) {
+ News.info("{}浠诲姟鏈壘鍒扮┖闂茬┛姊溅", task.getTaskNo());
+ continue;
+ }
+
+ task.setShuttleNo(Integer.valueOf(shuttleThread.getDevice().getDeviceNo()));//淇濆瓨绌挎杞﹀彿
+ task.setUpdateTime(new Date());
+ if (!taskService.updateById(task)) {
+ News.info("{}浠诲姟鏇存柊绌挎杞﹀彿澶辫触", task.getTaskNo());
+ }
+ continue;
+ }
+
// generate motion list
List<Motion> motionList = analyzeService.generateMotion(task);
if (motionList.isEmpty()) {
@@ -517,6 +532,23 @@
// 瑙f瀽灏忚溅绉诲姩宸ヤ綔妗�
public synchronized void analyzeMoveTask() {
for (Task task : taskService.selectWaitAnalyzeMoveTask()) {
+ if (Cools.isEmpty(task.getShuttleNo())) {
+ //鍒嗛厤灏忚溅
+ //鎼滅储绌洪棽杞�
+ ShuttleThread shuttleThread = shuttleDispatcher.searchIdleShuttle(task);
+ if (shuttleThread == null) {
+ News.info("{}浠诲姟鏈壘鍒扮┖闂茬┛姊溅", task.getTaskNo());
+ continue;
+ }
+
+ task.setShuttleNo(Integer.valueOf(shuttleThread.getDevice().getDeviceNo()));//淇濆瓨绌挎杞﹀彿
+ task.setUpdateTime(new Date());
+ if (!taskService.updateById(task)) {
+ News.info("{}浠诲姟鏇存柊绌挎杞﹀彿澶辫触", task.getTaskNo());
+ }
+ continue;
+ }
+
// generate motion list
List<Motion> motionList = analyzeService.generateMotion(task);
if (motionList.isEmpty()) {
@@ -789,8 +821,13 @@
.eq(BasLed::getDeviceId, ledDevice.getId()));
List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class);
+ BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId().intValue());
+ if (basConveyor == null) {
+ continue;
+ }
+
// 鑾峰彇杈撻�佺嚎plc绾跨▼
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, led.getConveyorId().intValue());
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue());
// 鍛戒护闆嗗悎
List<LedCommand> commands = new ArrayList<>();
// 宸ヤ綔妗i泦鍚�
@@ -870,8 +907,13 @@
.eq(BasLed::getDeviceId, ledDevice.getId()));
List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class);
+ BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId().intValue());
+ if (basConveyor == null) {
+ continue;
+ }
+
// 鑾峰彇杈撻�佺嚎plc绾跨▼
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, led.getConveyorId().intValue());
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue());
// 鍛戒护闆嗗悎
boolean reset = true;
for (Integer staNo : staArr) {
@@ -900,8 +942,13 @@
.eq(BasLed::getDeviceId, ledDevice.getId()));
List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class);
+ BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId());
+ if (basConveyor == null) {
+ continue;
+ }
+
// 鑾峰彇杈撻�佺嚎plc绾跨▼
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, led.getConveyorId().intValue());
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue());
// 鍛戒护闆嗗悎
boolean reset = true;
for (Integer staNo : staArr) {
--
Gitblit v1.9.1