From 7a546480f6ddfaee1366f280981a002a08412c11 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 17 十二月 2025 15:11:07 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/plugin/FakeProcess.java | 158 +++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 118 insertions(+), 40 deletions(-)
diff --git a/src/main/java/com/zy/core/plugin/FakeProcess.java b/src/main/java/com/zy/core/plugin/FakeProcess.java
index c6c7532..da22a9a 100644
--- a/src/main/java/com/zy/core/plugin/FakeProcess.java
+++ b/src/main/java/com/zy/core/plugin/FakeProcess.java
@@ -6,14 +6,9 @@
import com.core.common.Cools;
import com.zy.asrs.domain.param.CreateInTaskParam;
import com.zy.asrs.domain.param.CreateOutTaskParam;
-import com.zy.asrs.entity.BasCrnp;
-import com.zy.asrs.entity.BasDevp;
-import com.zy.asrs.entity.LocMast;
-import com.zy.asrs.entity.WrkMast;
-import com.zy.asrs.service.BasCrnpService;
-import com.zy.asrs.service.BasDevpService;
-import com.zy.asrs.service.LocMastService;
-import com.zy.asrs.service.WrkMastService;
+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;
@@ -46,6 +41,9 @@
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;
@@ -65,12 +63,29 @@
private CrnOperateProcessUtils crnOperateUtils;
@Autowired
private StationOperateProcessUtils stationOperateProcessUtils;
+ @Autowired
+ private HttpRequestLogService httpRequestLogService;
@Override
public void run() {
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();
}
//妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
@@ -106,6 +121,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());
@@ -127,8 +146,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;
}
@@ -137,9 +156,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);
}
}
}
@@ -148,6 +167,14 @@
//鐢熸垚浠跨湡妯℃嫙鍏ュ簱浠诲姟
private synchronized void generateFakeInTask() {
if (!enableFake.equals("Y")) {
+ return;
+ }
+
+ if (fakeRealTaskRequestWms.equals("Y")) {
+ return;
+ }
+
+ if (!fakeGenerateInTask.equals("Y")) {
return;
}
@@ -160,7 +187,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)){
@@ -177,11 +204,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()) {
@@ -212,8 +243,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);
}
}
@@ -223,6 +260,14 @@
//鐢熸垚浠跨湡妯℃嫙鍑哄簱浠诲姟
private synchronized void generateFakeOutTask() {
if (!enableFake.equals("Y")) {
+ return;
+ }
+
+ if (fakeRealTaskRequestWms.equals("Y")) {
+ return;
+ }
+
+ if (!fakeGenerateOutTask.equals("Y")) {
return;
}
@@ -269,19 +314,12 @@
continue;
}
- Integer sourceStationId = commonService.findOutStationId(crnNo, stationId);
- if (sourceStationId == null) {
- continue;
- }
-
CreateOutTaskParam taskParam = new CreateOutTaskParam();
taskParam.setTaskNo(String.valueOf(commonService.getWorkNo(WrkIoType.OUT.id)));
- taskParam.setSourceStaNo(sourceStationId);
taskParam.setStaNo(stationId);
- taskParam.setSourceLocNo(locMast.getLocNo());
- taskParam.setBarcode(locMast.getBarcode());
+ 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);
}
}
}
@@ -292,6 +330,10 @@
* 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗�
*/
public synchronized void generateStoreWrkFile() {
+ if (fakeRealTaskRequestWms.equals("N")) {
+ return;
+ }
+
List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
for (BasDevp basDevp : basDevps) {
StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
@@ -301,7 +343,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)){
@@ -313,11 +355,15 @@
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()) {
@@ -346,17 +392,25 @@
return;
}
- try {
- HashMap<String, Object> param = new HashMap<>();
- param.put("barcode", stationProtocol.getBarcode());
- param.put("ioType", 1);
- param.put("sourceStaNo", stationProtocol.getStationId());
- param.put("locType1", stationProtocol.getPalletHeight());
+ Object lock = redisUtil.get(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId);
+ if (lock != null) {
+ continue;
+ }
- String response = new HttpHandler.Builder()
+ redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 5);
+
+ 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());
+
+ response = new HttpHandler.Builder()
.setUri(wmsUrl)
.setPath(wmsSystemInUrl)
- .setJson(JSON.toJSONString(param))
+ .setJson(JSON.toJSONString(requestParam))
.build()
.doPost();
JSONObject jsonObject = JSON.parseObject(response);
@@ -364,15 +418,31 @@
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
CreateInTaskParam taskParam = new CreateInTaskParam();
- taskParam.setTaskNo(String.valueOf(dto.getWorkNo()));
+ taskParam.setTaskNo(String.valueOf(dto.getTaskNo()));
taskParam.setLocNo(dto.getLocNo());
taskParam.setTaskPri(dto.getTaskPri());
- boolean result = commonService.createInTask(taskParam);
+ 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 + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+ News.error("璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response);
}
} catch (Exception e) {
- e.printStackTrace();
+ 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);
}
}
}
@@ -519,6 +589,10 @@
&& crnProtocol.getTaskNo() > 0
&& crnProtocol.getStatus() == CrnStatusType.WAITING.id
) {
+ Object lock = redisUtil.get(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo());
+ if(lock != null){
+ continue;
+ }
// 鑾峰彇寰呯‘璁ゅ伐浣滄。
WrkMast wrkMast = wrkMastService.selectByWorkNo(crnProtocol.getTaskNo());
@@ -553,6 +627,8 @@
StationCommand command = stationThread.getMoveCommand(9998, wrkMast.getSourceStaNo(), 0, 0);
MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
}
+ }else if(wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts){
+ updateWrkSts = WrkStsType.COMPLETE_LOC_MOVE.sts;
}else{
News.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗗伐浣滅姸鎬佸紓甯搞�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
continue;
@@ -566,6 +642,8 @@
MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, resetCommand));
News.info("鍫嗗灈鏈轰换鍔$姸鎬佹洿鏂版垚鍔燂紝鍫嗗灈鏈哄彿={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
}
+
+ redisUtil.set(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo(), "lock",10);
}
}
}
--
Gitblit v1.9.1