From 84e27510eac3b86af8a98d7498eb451b876c5413 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期五, 20 三月 2026 09:11:30 +0800
Subject: [PATCH] 入库口强制入库确认后还会退回一次,才可入库修复
---
src/main/java/com/zy/core/plugin/NormalProcess.java | 135 +++++++++++++++++++++++++++++++++++++++++----
1 files changed, 123 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/zy/core/plugin/NormalProcess.java b/src/main/java/com/zy/core/plugin/NormalProcess.java
index 018cbfc..97f3ccb 100644
--- a/src/main/java/com/zy/core/plugin/NormalProcess.java
+++ b/src/main/java/com/zy/core/plugin/NormalProcess.java
@@ -5,8 +5,10 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.zy.asrs.domain.param.CreateInTaskParam;
+import com.zy.asrs.entity.BasCrnp;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.WrkMast;
+import com.zy.asrs.service.BasCrnpService;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.WrkMastService;
import com.zy.common.model.StartupDto;
@@ -15,15 +17,14 @@
import com.zy.core.News;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
-import com.zy.core.enums.RedisKeyType;
-import com.zy.core.enums.SlaveType;
-import com.zy.core.enums.StationCommandType;
-import com.zy.core.enums.WrkIoType;
+import com.zy.core.enums.*;
import com.zy.core.model.StationObjModel;
import com.zy.core.model.Task;
import com.zy.core.model.command.StationCommand;
+import com.zy.core.model.protocol.CrnProtocol;
import com.zy.core.model.protocol.StationProtocol;
import com.zy.core.plugin.api.MainProcessPluginApi;
+import com.zy.core.thread.CrnThread;
import com.zy.core.thread.StationThread;
import com.zy.core.utils.CrnOperateProcessUtils;
import com.zy.core.utils.StationOperateProcessUtils;
@@ -32,9 +33,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
@Slf4j
@Component
@@ -54,6 +53,8 @@
private RedisUtil redisUtil;
@Autowired
private WmsOperateUtils wmsOperateUtils;
+ @Autowired
+ private BasCrnpService basCrnpService;
@Override
public void run() {
@@ -77,6 +78,11 @@
//妫�娴嬭緭閫佺珯鐐规槸鍚﹁繍琛屽牭濉�
stationOperateProcessUtils.checkStationRunBlock();
+
+ //涓婃姤鍫嗗灈鏈篋B110鐘舵�佹暟鎹�
+ reportDb110();
+ //璺ㄥ尯鍏ュ簱浠诲姟涓嬪彂锛屼慨鏀圭珯鐐逛换鍔″彿涓哄叆搴撲换鍔″彿
+ taskToNewAreaInTaskStationSend();
}
/**
@@ -156,6 +162,10 @@
Integer stationIdVal = stationProtocol.getStationId();
+ String stationBackKey = RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + barcode + "_" + stationIdVal;
+ if (redisUtil.get(stationBackKey) != null) {
+ continue;
+ }
// 1. 棣栧厛鏌ヨ鏄惁鏈夊凡瀹屾垚鐨勫紓姝ュ搷搴�
String response = wmsOperateUtils.queryAsyncInTaskResponse(barcode, stationIdVal);
@@ -177,7 +187,9 @@
JSONObject jsonObject = JSON.parseObject(response);
if (jsonObject.getInteger("code").equals(200)) {
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
-
+ if (Cools.isEmpty(dto.getTaskNo())){
+ throw new Exception("TaskNo涓嶈兘涓虹┖");
+ }
CreateInTaskParam taskParam = new CreateInTaskParam();
taskParam.setTaskNo(String.valueOf(dto.getTaskNo()));
taskParam.setLocNo(dto.getLocNo());
@@ -194,6 +206,7 @@
News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
continue;
}
+ redisUtil.del(stationBackKey);
stationProtocol.setSystemWarning("");
MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
} else {
@@ -202,12 +215,13 @@
StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO,
9991, 1015, 1013, 0);
MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
- // 鎺ュ彛杩斿洖闈�200锛岄噸鏂板彂璧疯姹�
- News.error("WMS鍏ュ簱鎺ュ彛杩斿洖闈�200锛岄噸鏂板彂璧疯姹傦紝barcode={}锛宻tationId={}锛宺esponse={}", barcode,
+ redisUtil.set(stationBackKey, "lock", 15);
+ wmsOperateUtils.clearAsyncInTaskCache(barcode, stationIdVal);
+ // 鎺ュ彛杩斿洖闈�200锛屽厛閫�鍥烇紝绛夊緟涓嬫寰幆閲嶆柊璇锋眰
+ News.error("WMS鍏ュ簱鎺ュ彛杩斿洖闈�200锛屽厛閫�鍥炲悗绛夊緟閲嶈瘯锛宐arcode={}锛宻tationId={}锛宺esponse={}", barcode,
stationIdVal, response);
- wmsOperateUtils.applyInTaskAsync(barcode, stationIdVal,
- stationProtocol.getPalletHeight(),stationProtocol.getWeight());
redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 2);
+ continue;
}
} else {
// 3. 娌℃湁鍝嶅簲缁撴灉锛屾鏌ユ槸鍚︽湁璇锋眰姝e湪杩涜涓�
@@ -271,4 +285,101 @@
}
}
+ //涓婃姤鍫嗗灈鏈篋B110鐘舵�佹暟鎹�
+ public synchronized void reportDb110() {
+ List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
+ for (BasCrnp basCrnp : basCrnps) {
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo());
+ if(crnThread == null){
+ continue;
+ }
+
+ CrnProtocol crnProtocol = crnThread.getStatus();
+ if(crnProtocol == null){
+ continue;
+ }
+
+ // 涓婃姤鍫嗗灈鏈篋B110鐘舵�佹暟鎹�
+ short[] db110Data = crnProtocol.getDb110Data();
+ List<Integer> currentIndices = new ArrayList<>();
+ if (db110Data != null) {
+ for (int i = 0; i < db110Data.length; i++) {
+ if (db110Data[i] == 1) {
+ currentIndices.add(i);
+ }
+ }
+ }
+
+ if (currentIndices.isEmpty()) {
+ continue;
+ }
+
+ String reportLockKey = RedisKeyType.REPORT_CRN_DB110_STATUS_LIMIT.key + crnProtocol.getCrnNo();
+ if (redisUtil.get(reportLockKey) != null) {
+ continue;
+ }
+
+ long reportLockSeconds = Math.max(60L, currentIndices.size() * 35L);
+ redisUtil.set(reportLockKey, "lock", reportLockSeconds);
+ wmsOperateUtils.reportCrnDb110StatusAsync(crnProtocol.getCrnNo(), new ArrayList<>(currentIndices));
+ }
+ }
+
+ //璺ㄥ尯鍏ュ簱浠诲姟涓嬪彂锛屼慨鏀圭珯鐐逛换鍔″彿涓哄叆搴撲换鍔″彿
+ public synchronized void taskToNewAreaInTaskStationSend() {
+ Set<String> list = redisUtil.searchKeys(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK.key);
+ for (String key : list) {
+ Object dataStr = redisUtil.get(key);
+ if (dataStr == null) {
+ continue;
+ }
+
+ JSONObject data = JSON.parseObject(dataStr.toString());
+ Integer oldTaskNo = data.getInteger("oldTaskNo");
+ Integer newTaskNo = data.getInteger("newTaskNo");
+ StationCommand command = data.getObject("command", StationCommand.class);
+ Integer stationId = data.getInteger("stationId");
+ Integer deviceNo = data.getInteger("deviceNo");
+
+ Object lock = redisUtil.get(RedisKeyType.SEND_LIMIT_RECEIVE_IN_TASK_CHANGE_STATION_TASK.key + stationId);
+ if(lock != null){
+ continue;
+ }
+
+ StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, deviceNo);
+ if(stationThread == null){
+ continue;
+ }
+
+ Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
+ StationProtocol stationProtocol = statusMap.get(stationId);
+ if(stationProtocol == null){
+ continue;
+ }
+
+ if (!stationProtocol.isAutoing()) {
+ continue;
+ }
+
+ if (!stationProtocol.isLoading()) {
+ continue;
+ }
+
+ if (stationProtocol.getTaskNo() == 0) {
+ continue;
+ }
+
+ if (!stationProtocol.getTaskNo().equals(oldTaskNo)) {
+ //鍜岀紦瀛樺懡浠や笉鐩稿悓鍒犻櫎
+ redisUtil.del(key);
+ continue;
+ }
+
+ //缂撳瓨鍛戒护鐩稿悓锛屼笅鍙戝懡浠ゆ敼鍙樺叆搴撲换鍔″彿淇℃伅
+ MessageQueue.offer(SlaveType.Devp, deviceNo, new Task(2, command));
+ redisUtil.set(RedisKeyType.SEND_LIMIT_RECEIVE_IN_TASK_CHANGE_STATION_TASK.key + stationId, "lock", 5);
+ }
+
+ }
+
}
--
Gitblit v1.9.1