From 8280c9eee52dd9fa3501305dfd4d1cab1564a73b Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期六, 20 十二月 2025 15:01:20 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/plugin/FakeProcess.java | 235 ++++++++++++++++++++++++++++++++--------------------------
1 files changed, 128 insertions(+), 107 deletions(-)
diff --git a/src/main/java/com/zy/core/plugin/FakeProcess.java b/src/main/java/com/zy/core/plugin/FakeProcess.java
index da22a9a..f202acc 100644
--- a/src/main/java/com/zy/core/plugin/FakeProcess.java
+++ b/src/main/java/com/zy/core/plugin/FakeProcess.java
@@ -8,10 +8,8 @@
import com.zy.asrs.domain.param.CreateOutTaskParam;
import com.zy.asrs.entity.*;
import com.zy.asrs.service.*;
-import com.zy.asrs.utils.Utils;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
-import com.zy.common.utils.HttpHandler;
import com.zy.common.utils.RedisUtil;
import com.zy.core.News;
import com.zy.core.cache.MessageQueue;
@@ -23,10 +21,12 @@
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.properties.SystemProperties;
import com.zy.core.thread.CrnThread;
import com.zy.core.thread.StationThread;
import com.zy.core.utils.CrnOperateProcessUtils;
import com.zy.core.utils.StationOperateProcessUtils;
+import com.zy.core.utils.WmsOperateUtils;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
@@ -44,6 +44,9 @@
private static String fakeRealTaskRequestWms = "N";
private static String fakeGenerateInTask = "Y";
private static String fakeGenerateOutTask = "Y";
+
+ private Thread asyncRunThread = null;
+ private Thread asyncFakeRunThread = null;
@Autowired
private WrkMastService wrkMastService;
@@ -64,45 +67,13 @@
@Autowired
private StationOperateProcessUtils stationOperateProcessUtils;
@Autowired
- private HttpRequestLogService httpRequestLogService;
+ private WmsOperateUtils wmsOperateUtils;
@Override
public void run() {
- Config enableFakeConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
- if (enableFakeConfig != null) {
- enableFake = enableFakeConfig.getValue();
- }
+ asyncRun();
+ asyncFakeRun();
- Config fakeRealTaskRequestWmsConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "fakeRealTaskRequestWms"));
- if (fakeRealTaskRequestWmsConfig != null) {
- fakeRealTaskRequestWms = fakeRealTaskRequestWmsConfig.getValue();
- }
-
- Config fakeGenerateInTaskConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "fakeGenerateInTask"));
- if (fakeGenerateInTaskConfig != null) {
- fakeGenerateInTask = fakeGenerateInTaskConfig.getValue();
- }
-
- Config fakeGenerateOutTaskConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "fakeGenerateOutTask"));
- if (fakeGenerateOutTaskConfig != null) {
- fakeGenerateOutTask = fakeGenerateOutTaskConfig.getValue();
- }
-
- //妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
- checkInStationHasTask();
- //鐢熸垚浠跨湡妯℃嫙鍏ュ簱浠诲姟
- generateFakeInTask();
- //鐢熸垚浠跨湡妯℃嫙鍑哄簱浠诲姟
- generateFakeOutTask();
- //璁$畻鎵�鏈夌珯鐐瑰仠鐣欐椂闂�
- calcAllStationStayTime();
- //妫�娴嬪嚭搴撶珯鐐瑰仠鐣欐槸鍚﹁秴鏃�
- checkOutStationStayTimeOut();
- //妫�娴嬪叆搴撶珯鐐瑰爢鍨涙満鏄惁鍙栬蛋璐х墿
- checkInStationCrnTake();
-
- //璇锋眰鐢熸垚鍏ュ簱浠诲姟
- generateStoreWrkFile();
//鎵ц鍫嗗灈鏈轰换鍔�
crnOperateUtils.crnIoExecute();
//鍫嗗灈鏈轰换鍔℃墽琛屽畬鎴�-鍏峰浠跨湡鑳藉姏
@@ -113,6 +84,101 @@
stationOperateProcessUtils.stationOutExecute();
//妫�娴嬭緭閫佺珯鐐瑰嚭搴撲换鍔℃墽琛屽畬鎴�
stationOperateProcessUtils.stationOutExecuteFinish();
+ }
+
+ public void asyncRun() {
+ if (asyncRunThread != null) {
+ return;
+ }
+
+ asyncRunThread = new Thread(() -> {
+ while (!Thread.currentThread().isInterrupted()) {
+ try {
+ // 绯荤粺杩愯鐘舵�佸垽鏂�
+ if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
+ continue;
+ }
+
+ //璇锋眰鐢熸垚鍏ュ簱浠诲姟
+ generateStoreWrkFile();
+
+ // 闂撮殧
+ Thread.sleep(50);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ break;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ asyncRunThread.setName("asyncRunProcess");
+ asyncRunThread.setDaemon(true);
+ asyncRunThread.start();
+ }
+
+ public void asyncFakeRun() {
+ if (asyncFakeRunThread != null) {
+ return;
+ }
+
+ asyncFakeRunThread = new Thread(() -> {
+ while (!Thread.currentThread().isInterrupted()) {
+ try {
+ Config enableFakeConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
+ if (enableFakeConfig != null) {
+ enableFake = enableFakeConfig.getValue();
+ }
+
+ Config fakeRealTaskRequestWmsConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "fakeRealTaskRequestWms"));
+ if (fakeRealTaskRequestWmsConfig != null) {
+ fakeRealTaskRequestWms = fakeRealTaskRequestWmsConfig.getValue();
+ }
+
+ Config fakeGenerateInTaskConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "fakeGenerateInTask"));
+ if (fakeGenerateInTaskConfig != null) {
+ fakeGenerateInTask = fakeGenerateInTaskConfig.getValue();
+ }
+
+ Config fakeGenerateOutTaskConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "fakeGenerateOutTask"));
+ if (fakeGenerateOutTaskConfig != null) {
+ fakeGenerateOutTask = fakeGenerateOutTaskConfig.getValue();
+ }
+
+ // 绯荤粺杩愯鐘舵�佸垽鏂�
+ if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
+ continue;
+ }
+
+ //妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
+ checkInStationHasTask();
+ //鐢熸垚浠跨湡妯℃嫙鍏ュ簱浠诲姟
+ generateFakeInTask();
+ //鐢熸垚浠跨湡妯℃嫙鍑哄簱浠诲姟
+ generateFakeOutTask();
+ //璁$畻鎵�鏈夌珯鐐瑰仠鐣欐椂闂�
+ calcAllStationStayTime();
+ //妫�娴嬪嚭搴撶珯鐐瑰仠鐣欐槸鍚﹁秴鏃�
+ checkOutStationStayTimeOut();
+ //妫�娴嬪叆搴撶珯鐐瑰爢鍨涙満鏄惁鍙栬蛋璐х墿
+ checkInStationCrnTake();
+
+ //妫�娴嬭緭閫佺珯鐐规槸鍚﹁繍琛屽牭濉�
+ stationOperateProcessUtils.checkStationRunBlock();
+
+ // 闂撮殧
+ Thread.sleep(50);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ break;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ asyncFakeRunThread.setName("asyncFakeRunProcess");
+ asyncFakeRunThread.setDaemon(true);
+ asyncFakeRunThread.start();
}
//妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
@@ -201,7 +267,7 @@
Object object = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_TASK_LIMIT.key + stationId);
if (object != null) {
- return;
+ continue;
}
//婊¤冻鑷姩銆佹湁鐗┿�佹湁宸ヤ綔鍙凤紝鐢熸垚鍏ュ簱鏁版嵁
@@ -370,79 +436,34 @@
continue;
}
- String wmsUrl = null;
- Config wmsSystemUriConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemUri"));
- if (wmsSystemUriConfig != null) {
- wmsUrl = wmsSystemUriConfig.getValue();
- }
-
- if(wmsUrl == null){
- News.error("鏈厤缃甒MS绯荤粺URI锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemUri");
- return;
- }
-
- String wmsSystemInUrl = null;
- Config wmsSystemInUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemInUrl"));
- if (wmsSystemInUrlConfig != null) {
- wmsSystemInUrl = wmsSystemInUrlConfig.getValue();
- }
-
- if(wmsSystemInUrlConfig == null){
- News.error("鏈厤缃甒MS鍏ュ簱鎺ュ彛鍦板潃锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemInUrl");
- return;
- }
-
Object lock = redisUtil.get(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId);
if (lock != null) {
continue;
}
+ redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 2);
- redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 5);
+ String response = wmsOperateUtils.applyInTask(stationProtocol.getBarcode(), stationProtocol.getStationId(), stationProtocol.getPalletHeight());
+ if (response == null) {
+ News.error("璇锋眰WMS鍏ュ簱鎺ュ彛澶辫触锛屾帴鍙f湭鍝嶅簲锛侊紒锛乺esponse锛歿}", response);
+ continue;
+ }
+ JSONObject jsonObject = JSON.parseObject(response);
+ if (jsonObject.getInteger("code").equals(200)) {
+ StartupDto dto = jsonObject.getObject("data", StartupDto.class);
- HashMap<String, Object> requestParam = new HashMap<>();
- String response = null;
- try {
- requestParam.put("barcode", stationProtocol.getBarcode());
- requestParam.put("sourceStaNo", stationProtocol.getStationId());
- requestParam.put("locType1", stationProtocol.getPalletHeight());
- requestParam.put("row", Utils.getInTaskEnableRow());
+ CreateInTaskParam taskParam = new CreateInTaskParam();
+ taskParam.setTaskNo(dto.getTaskNo());
+ taskParam.setLocNo(dto.getLocNo());
+ taskParam.setTaskPri(dto.getTaskPri());
+ taskParam.setBarcode(stationProtocol.getBarcode());
+ WrkMast wrkMast = commonService.createInTask(taskParam);
- response = new HttpHandler.Builder()
- .setUri(wmsUrl)
- .setPath(wmsSystemInUrl)
- .setJson(JSON.toJSONString(requestParam))
- .build()
- .doPost();
- JSONObject jsonObject = JSON.parseObject(response);
- if (jsonObject.getInteger("code").equals(200)) {
- StartupDto dto = jsonObject.getObject("data", StartupDto.class);
-
- CreateInTaskParam taskParam = new CreateInTaskParam();
- taskParam.setTaskNo(String.valueOf(dto.getTaskNo()));
- taskParam.setLocNo(dto.getLocNo());
- taskParam.setTaskPri(dto.getTaskPri());
- taskParam.setBarcode(stationProtocol.getBarcode());
- WrkMast wrkMast = commonService.createInTask(taskParam);
-
- StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationId, stationId, 0);
- if(command == null){
- News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
- continue;
- }
- MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
- News.info("璇锋眰WMS鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response);
- } else {
- News.error("璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response);
+ StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationId, stationId, 0);
+ if(command == null){
+ News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+ continue;
}
- } catch (Exception e) {
- News.error("璇锋眰WMS鎺ュ彛寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response, e);
- } finally {
- HttpRequestLog httpRequestLog = new HttpRequestLog();
- httpRequestLog.setName(wmsUrl + wmsSystemInUrl);
- httpRequestLog.setRequest(JSON.toJSONString(requestParam));
- httpRequestLog.setResponse(response);
- httpRequestLog.setCreateTime(new Date());
- httpRequestLogService.insert(httpRequestLog);
+ MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
}
}
}
@@ -505,7 +526,7 @@
MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
redisUtil.set(RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10);
- News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(), JSON.toJSONString(command));
+ News.info("杈撻�佺珯鐐瑰嚭搴撻噸缃懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(), JSON.toJSONString(command));
}
}
}
@@ -548,7 +569,7 @@
if (wrkMast == null) {
MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10);
- News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(), JSON.toJSONString(command));
+ News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔�(task_over)锛岀珯鐐瑰彿={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(), JSON.toJSONString(command));
}else {
if (wrkMast.getWrkSts() != WrkStsType.NEW_INBOUND.sts && wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
Integer crnNo = wrkMast.getCrnNo();
@@ -557,13 +578,13 @@
continue;
}
CrnProtocol crnProtocol = crnThread.getStatus();
- if (crnProtocol.getStatusType().equals(CrnStatusType.FETCH_MOVING) || crnProtocol.getStatusType().equals(CrnStatusType.FETCHING)) {
+ if (!crnProtocol.getStatusType().equals(CrnStatusType.PUT_MOVING) && !crnProtocol.getStatusType().equals(CrnStatusType.PUTTING)) {
continue;
}
MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10);
- News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(), JSON.toJSONString(command));
+ News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔�(crn_fetch)锛岀珯鐐瑰彿={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(), JSON.toJSONString(command));
}
}
}
--
Gitblit v1.9.1