From 8dc960dd9fda130ff19faaafed6b1234e622610b Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期五, 19 十二月 2025 15:23:05 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/plugin/FakeProcess.java | 145 +++++++++++++++++++++++------------------------
1 files changed, 71 insertions(+), 74 deletions(-)
diff --git a/src/main/java/com/zy/core/plugin/FakeProcess.java b/src/main/java/com/zy/core/plugin/FakeProcess.java
index f6ff3a2..53193ef 100644
--- a/src/main/java/com/zy/core/plugin/FakeProcess.java
+++ b/src/main/java/com/zy/core/plugin/FakeProcess.java
@@ -3,14 +3,13 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.common.Cools;
import com.zy.asrs.domain.param.CreateInTaskParam;
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;
@@ -26,6 +25,7 @@
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;
@@ -41,6 +41,8 @@
private static Map<Integer,Long> stationStayTimeMap = new HashMap<>();
private static String enableFake = "N";
private static String fakeRealTaskRequestWms = "N";
+ private static String fakeGenerateInTask = "Y";
+ private static String fakeGenerateOutTask = "Y";
@Autowired
private WrkMastService wrkMastService;
@@ -61,7 +63,7 @@
@Autowired
private StationOperateProcessUtils stationOperateProcessUtils;
@Autowired
- private HttpRequestLogService httpRequestLogService;
+ private WmsOperateUtils wmsOperateUtils;
@Override
public void run() {
@@ -73,6 +75,16 @@
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();
}
//妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
@@ -100,11 +112,17 @@
stationOperateProcessUtils.stationOutExecute();
//妫�娴嬭緭閫佺珯鐐瑰嚭搴撲换鍔℃墽琛屽畬鎴�
stationOperateProcessUtils.stationOutExecuteFinish();
+ //妫�娴嬭緭閫佺珯鐐规槸鍚﹁繍琛屽牭濉�
+ stationOperateProcessUtils.checkStationRunBlock();
}
//妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
private synchronized void checkInStationHasTask() {
if (!enableFake.equals("Y")) {
+ return;
+ }
+
+ if (!fakeGenerateInTask.equals("Y")) {
return;
}
@@ -129,8 +147,8 @@
continue;
}
- Object object = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId);
- if (object != null) {
+ Object lock = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId);
+ if(lock != null){
continue;
}
@@ -139,9 +157,9 @@
&& !stationProtocol.isLoading()
&& stationProtocol.getTaskNo() == 0
) {
- StationCommand command = stationThread.getMoveCommand(9999, stationId, 0, 0);
+ StationCommand command = stationThread.getMoveCommand(commonService.getWorkNo(WrkIoType.FAKE_TASK_NO.id), stationId, entity.getBarcodeStation().getStationId(), 0);
MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
- redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 10);
+ redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 5);
}
}
}
@@ -157,6 +175,10 @@
return;
}
+ if (!fakeGenerateInTask.equals("Y")) {
+ return;
+ }
+
List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
for (BasDevp basDevp : basDevps) {
StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
@@ -166,7 +188,7 @@
Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
- List<StationObjModel> list = basDevp.getInStationList$();
+ List<StationObjModel> list = basDevp.getBarcodeStationList$();
for (StationObjModel model : list) {
Integer stationId = model.getStationId();
if(!stationMap.containsKey(stationId)){
@@ -183,11 +205,15 @@
return;
}
- //婊¤冻鑷姩銆佹湁鐗┿�佸伐浣滃彿9999锛岀敓鎴愬叆搴撴暟鎹�
+ //婊¤冻鑷姩銆佹湁鐗┿�佹湁宸ヤ綔鍙凤紝鐢熸垚鍏ュ簱鏁版嵁
if (stationProtocol.isAutoing()
&& stationProtocol.isLoading()
- && stationProtocol.getTaskNo() == 9999
+ && stationProtocol.getTaskNo() > 0
) {
+ if (Cools.isEmpty(stationProtocol.getBarcode())) {
+ continue;
+ }
+
//妫�娴嬩换鍔℃槸鍚︾敓鎴�
List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
if (!wrkMasts.isEmpty()) {
@@ -218,8 +244,14 @@
taskParam.setStaNo(targetStationId);
taskParam.setLocNo(locMast.getLocNo());
taskParam.setBarcode(stationProtocol.getBarcode());
- boolean result = commonService.createInTask(taskParam);
+ 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));
redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_TASK_LIMIT.key + stationId, "lock", 5);
}
}
@@ -233,6 +265,10 @@
}
if (fakeRealTaskRequestWms.equals("Y")) {
+ return;
+ }
+
+ if (!fakeGenerateOutTask.equals("Y")) {
return;
}
@@ -284,7 +320,7 @@
taskParam.setStaNo(stationId);
taskParam.setLocNo(locMast.getLocNo());
boolean result = commonService.createOutTask(taskParam);
- redisUtil.set(RedisKeyType.GENERATE_FAKE_OUT_TASK_LIMIT.key + stationId, "lock", 15);
+ redisUtil.set(RedisKeyType.GENERATE_FAKE_OUT_TASK_LIMIT.key + stationId, "lock", 10);
}
}
}
@@ -308,7 +344,7 @@
Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
- List<StationObjModel> list = basDevp.getInStationList$();
+ List<StationObjModel> list = basDevp.getBarcodeStationList$();
for (StationObjModel entity : list) {
Integer stationId = entity.getStationId();
if(!stationMap.containsKey(stationId)){
@@ -320,84 +356,45 @@
continue;
}
- //婊¤冻鑷姩銆佹湁鐗┿�佸伐浣滃彿9999锛岀敓鎴愬叆搴撴暟鎹�
+ //婊¤冻鑷姩銆佹湁鐗┿�佹湁宸ヤ綔鍙凤紝鐢熸垚鍏ュ簱鏁版嵁
if (stationProtocol.isAutoing()
&& stationProtocol.isLoading()
- && stationProtocol.getTaskNo() == 9999
+ && stationProtocol.getTaskNo() > 0
) {
+ if (Cools.isEmpty(stationProtocol.getBarcode())) {
+ continue;
+ }
+
//妫�娴嬩换鍔℃槸鍚︾敓鎴�
List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
if (!wrkMasts.isEmpty()) {
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", 5);
- redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 15);
+ String response = wmsOperateUtils.applyInTask(stationProtocol.getBarcode(), stationProtocol.getStationId(), stationProtocol.getPalletHeight());
+ 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());
- boolean result = commonService.createInTask(taskParam);
-
- 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));
}
}
}
--
Gitblit v1.9.1