From 6182cc11c3e93610df7fda87611d2ca807c6354c Mon Sep 17 00:00:00 2001
From: qlsxk <qlsxk@qq.com>
Date: 星期四, 16 十月 2025 14:28:30 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/utils/ForkLiftUtils.java | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 101 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/ForkLiftUtils.java b/src/main/java/com/zy/common/utils/ForkLiftUtils.java
index adc109d..fed6942 100644
--- a/src/main/java/com/zy/common/utils/ForkLiftUtils.java
+++ b/src/main/java/com/zy/common/utils/ForkLiftUtils.java
@@ -4,13 +4,13 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.SpringUtils;
+import com.zy.asrs.entity.DeviceConfig;
+import com.zy.asrs.service.DeviceConfigService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.NavigateNode;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
-import com.zy.core.model.ForkLiftSlave;
import com.zy.core.model.protocol.ForkLiftStaProtocol;
-import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.ForkLiftThread;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
@@ -24,17 +24,61 @@
*/
public class ForkLiftUtils {
+ //鑾峰彇鎻愬崌鏈烘墍鏈夌珯鐐�
+ public static List<Integer> getLiftAllStaNo(Integer liftNo) {
+ List<Integer> list = new ArrayList<>();
+ ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo);
+ if (forkLiftThread == null) {
+ return list;
+ }
+
+ for (ForkLiftStaProtocol forkLiftStaProtocol : forkLiftThread.getForkLiftStaProtocols()) {
+ list.add(forkLiftStaProtocol.getSiteId());
+ }
+
+ return list;
+ }
+
+ //鑾峰彇鎻愬崌鏈烘墍缁戝畾鐨勮緭閫佺嚎鎵�鏈夌珯鐐�
+ public static List<Integer> getConveyorBindLiftAllStaNo(Integer liftNo) {
+ List<Integer> list = new ArrayList<>();
+ ConfigService configService = SpringUtils.getBean(ConfigService.class);
+ if (configService == null) {
+ return list;
+ }
+
+ Config conveyorLiftBindConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "conveyorLiftBind"));
+ if(conveyorLiftBindConfig == null) {
+ return list;
+ }
+
+ List<JSONObject> val = JSON.parseArray(conveyorLiftBindConfig.getValue(), JSONObject.class);
+ if (val.isEmpty()) {
+ return list;
+ }
+
+ for (JSONObject data : val) {
+ if(data.getInteger("liftNo").equals(liftNo)) {
+ list.add(data.getInteger("staNo"));
+ }
+ }
+
+ return list;
+ }
+
//鑾峰彇鎻愬崌鏈虹珯鐐�
- public static ForkLiftStaProtocol getLiftStaByStaNo(Integer staNo) {
- SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class);
- for (ForkLiftSlave liftSlave : slaveProperties.getForkLift()) {
- ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftSlave.getId());
+ public static ForkLiftStaProtocol getLiftStaByStaNo(Integer siteId) {
+ DeviceConfigService deviceConfigService = SpringUtils.getBean(DeviceConfigService.class);
+ List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.ForkLift)));
+ for (DeviceConfig device : forkliftList) {
+ ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo());
if (forkLiftThread == null) {
return null;
}
for (ForkLiftStaProtocol forkLiftStaProtocol : forkLiftThread.getForkLiftStaProtocols()) {
- if (forkLiftStaProtocol.getStaNo().equals(staNo)) {
+ if (forkLiftStaProtocol.getSiteId().equals(siteId)) {
return forkLiftStaProtocol;
}
}
@@ -94,7 +138,7 @@
}
for (JSONObject data : list) {
- if(data.getInteger("staNo") == staNo) {
+ if(data.getInteger("staNo").equals(staNo)) {
return data.getInteger("liftNo");
}
}
@@ -149,4 +193,53 @@
return false;
}
+ //璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿叆搴�
+ //鏌ヨ鏄惁鏈夊叆搴撴潈闄�
+ public static boolean queryInMission(Integer sourceStaNo, Integer liftNo, String superTaskNo) {
+ ConfigService configService = SpringUtils.getBean(ConfigService.class);
+ if (configService == null) {
+ return false;
+ }
+
+ Config queryInMissionPathEnableConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "queryInMissionPathEnable"));
+ if (queryInMissionPathEnableConfig != null) {
+ String queryInMissionPathEnable = queryInMissionPathEnableConfig.getValue();
+ if (!queryInMissionPathEnable.equals("Y")) {
+ return true;//鍏抽棴鏌ヨ鍏ュ簱鏉冮檺鍔熻兘
+ }
+ }
+
+ Config superSystemUriConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "superSystemUri"));
+ if (superSystemUriConfig == null) {
+ return false;
+ }
+ String superSystemUri = superSystemUriConfig.getValue();
+
+ Config queryInMissionPathConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "queryInMissionPath"));
+ if (queryInMissionPathConfig == null) {
+ return false;
+ }
+ String missionPath = queryInMissionPathConfig.getValue();
+
+ try {
+ HashMap<String, Object> data = new HashMap<>();
+ data.put("staNo", sourceStaNo);
+ data.put("liftNo", liftNo);
+ data.put("superTaskNo", superTaskNo);
+
+ String response = new HttpHandler.Builder()
+ .setUri(superSystemUri)
+ .setPath(missionPath)
+ .setJson(JSON.toJSONString(data))
+ .build()
+ .doPost();
+ if (response.equals("ok")) {
+ return true;//鏈夊叆搴撴潈闄�
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
}
--
Gitblit v1.9.1