From e222fba1a5aab1c9877667560629ae643133cb7d Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期五, 19 四月 2024 14:25:08 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java | 39 ++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java | 24 ++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/ShuttleServiceImpl.java | 4
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java | 14 +
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java | 18 +
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java | 5
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/param/LiftOperatorParam.java | 20 ++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/ws/LiftWebSocket.java | 171 +++++++++++++++++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/LiftServiceImpl.java | 41 ++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasLiftController.java | 128 +++++++++++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java | 4
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java | 4
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/LiftService.java | 11 +
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/ws/ShuttleWebSocket.java | 1
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java | 2
15 files changed, 466 insertions(+), 20 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
index b5aed07..49dbbc6 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
@@ -41,7 +41,7 @@
redisCommand.setAssignCommand(assignCommand);//鍛戒护
//浠诲姟鏁版嵁淇濆瓨鍒皉edis
if (redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand))) {
- liftProtocol.setTaskNo(assignCommand.getTaskNo());
+ liftThread.setSyncTaskNo(assignCommand.getTaskNo());
return true;
}
return false;
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasLiftController.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasLiftController.java
index 64a5424..6d52e63 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasLiftController.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasLiftController.java
@@ -1,25 +1,44 @@
-package com.zy.asrs.wcs.system.controller;
+package com.zy.asrs.wcs.core.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
+import com.zy.asrs.framework.common.SnowflakeIdWorker;
import com.zy.asrs.wcs.common.annotation.OperationLog;
import com.zy.asrs.wcs.common.domain.BaseParam;
import com.zy.asrs.wcs.common.domain.KeyValVo;
import com.zy.asrs.wcs.common.domain.PageParam;
+import com.zy.asrs.wcs.core.domain.param.LiftOperatorParam;
import com.zy.asrs.wcs.core.entity.BasLift;
+import com.zy.asrs.wcs.core.entity.Motion;
+import com.zy.asrs.wcs.core.entity.Task;
+import com.zy.asrs.wcs.core.entity.TaskCtg;
+import com.zy.asrs.wcs.core.kernel.AnalyzeService;
+import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
+import com.zy.asrs.wcs.core.model.enums.TaskStsType;
import com.zy.asrs.wcs.core.service.BasLiftService;
+import com.zy.asrs.wcs.core.service.MotionService;
+import com.zy.asrs.wcs.core.service.TaskCtgService;
+import com.zy.asrs.wcs.core.service.TaskService;
+import com.zy.asrs.wcs.core.utils.Utils;
+import com.zy.asrs.wcs.rcs.News;
+import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
+import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
+import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
+import com.zy.asrs.wcs.rcs.service.DeviceService;
+import com.zy.asrs.wcs.rcs.thread.LiftThread;
+import com.zy.asrs.wcs.system.controller.BaseController;
+import com.zy.asrs.wcs.system.entity.Dict;
+import com.zy.asrs.wcs.system.service.DictService;
import com.zy.asrs.wcs.utils.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
@RestController
@RequestMapping("/api")
@@ -27,6 +46,20 @@
@Autowired
private BasLiftService basLiftService;
+ @Autowired
+ private TaskCtgService taskCtgService;
+ @Autowired
+ private DeviceService deviceService;
+ @Autowired
+ private SnowflakeIdWorker snowflakeIdWorker;
+ @Autowired
+ private TaskService taskService;
+ @Autowired
+ private AnalyzeService analyzeService;
+ @Autowired
+ private MotionService motionService;
+ @Autowired
+ private DictService dictService;
@PreAuthorize("hasAuthority('core:basLift:list')")
@PostMapping("/basLift/page")
@@ -98,4 +131,89 @@
ExcelUtil.build(ExcelUtil.create(basLiftService.list(), BasLift.class), response);
}
+ //鑾峰彇妤煎眰
+ @PreAuthorize("hasAuthority('core:basLift:list')")
+ @PostMapping("/basLift/getMapLev")
+ public R getMapLev() {
+ List<Dict> dicts = dictService.list(new LambdaQueryWrapper<Dict>()
+ .like(Dict::getFlag, "map")
+ .eq(Dict::getStatus, 1));
+ return R.ok().add(dicts.size());
+ }
+
+ @PreAuthorize("hasAuthority('core:basLift:operator')")
+ @PostMapping("/basLift/operator/lift")
+ public R liftOperator(@RequestBody LiftOperatorParam param) {
+ if (Cools.isEmpty(param.getLiftNo())) {
+ return R.error("鍙傛暟涓虹┖");
+ }
+
+ Integer liftNo = param.getLiftNo();
+
+ //鑾峰彇鎵嬪姩浠诲姟绫诲瀷
+ TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
+ .eq(TaskCtg::getFlag, "MANUAL")
+ .eq(TaskCtg::getStatus, 1));
+ if (taskCtg == null) {
+ return R.error();
+ }
+
+ Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
+ .eq(Device::getDeviceType, DeviceCtgType.LIFT.val())
+ .eq(Device::getStatus, 1)
+ .eq(Device::getDeviceNo, liftNo));
+ if (device == null) {
+ return R.error("璁惧涓嶅瓨鍦�");
+ }
+
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue());
+ if (liftThread == null) {
+ return R.error("璁惧绂荤嚎");
+ }
+
+ if (param.getLiftTaskMode().equals("reset")) {
+ //鎻愬崌鏈哄浣�
+ liftThread.setSyncTaskNo(0);
+ liftThread.setProtocolStatus(LiftProtocolStatusType.IDLE);
+ return R.ok("澶嶄綅鎴愬姛");
+ }
+
+ Task task = new Task();
+ task.setUuid(String.valueOf(snowflakeIdWorker.nextId()));
+ task.setTaskNo(String.valueOf(Utils.getTaskNo("MANUAL")));
+ task.setTaskSts(TaskStsType.NEW_MANUAL.sts);
+ task.setTaskCtg(taskCtg.getId());
+ task.setPriority(10);
+ task.setOriginSite(null);
+ task.setOriginLoc(param.getSourceStaNo());
+ task.setDestSite(param.getLiftTaskMode());
+ task.setDestLoc(param.getStaNo());
+ task.setIoTime(new Date());
+ task.setStartTime(new Date());
+ task.setStatus(1);
+ task.setMemo("manual");
+ task.setLiftNo(liftNo);
+ boolean result = taskService.save(task);
+ if (!result) {
+ return R.error();
+ }
+
+ task = taskService.getById(task.getId());
+
+ // generate motion list
+ List<Motion> motionList = analyzeService.generateLiftManualMotion(task);
+ if (Cools.isEmpty(motionList)) {
+ News.error("淇濆瓨{}鎻愬崌鏈烘墜鍔ㄤ换鍔″け璐�!!!", liftNo);
+ return R.error();
+ }
+ motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()));
+
+ task.setTaskSts(TaskStsType.ANALYZE_MANUAL.sts);
+ if (!taskService.updateById(task)) {
+ News.error("淇濆瓨{}鎻愬崌鏈烘墜鍔ㄤ换鍔″け璐�!!!", liftNo);
+ return R.error();
+ }
+ return R.ok();
+ }
+
}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java
index 8255384..e9a34f5 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java
@@ -2,7 +2,6 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.zy.asrs.framework.common.BaseRes;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.framework.common.SnowflakeIdWorker;
@@ -27,7 +26,6 @@
import com.zy.asrs.wcs.rcs.News;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.rcs.entity.Device;
-import com.zy.asrs.wcs.rcs.entity.DeviceType;
import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
import com.zy.asrs.wcs.rcs.service.DeviceService;
@@ -142,7 +140,7 @@
Integer shuttleNo = param.getShuttleNo();
- //鑾峰彇杩佺Щ浠诲姟绫诲瀷
+ //鑾峰彇鎵嬪姩浠诲姟绫诲瀷
TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
.eq(TaskCtg::getFlag, "MANUAL")
.eq(TaskCtg::getStatus, 1));
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/param/LiftOperatorParam.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/param/LiftOperatorParam.java
new file mode 100644
index 0000000..b2b3dcf
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/param/LiftOperatorParam.java
@@ -0,0 +1,20 @@
+package com.zy.asrs.wcs.core.domain.param;
+
+import lombok.Data;
+
+@Data
+public class LiftOperatorParam {
+
+ // 鎻愬崌鏈哄彿
+ private Integer liftNo;
+
+ //鎿嶄綔妯″紡
+ private String liftTaskMode;
+
+ //婧愮珯
+ private String sourceStaNo;
+
+ //鐩爣绔�
+ private String staNo;
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
index c596e27..ed5431c 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.framework.common.R;
import com.zy.asrs.wcs.core.domain.dto.MotionDto;
import com.zy.asrs.wcs.core.entity.ShuttleStandby;
import com.zy.asrs.wcs.core.entity.Task;
@@ -18,6 +19,7 @@
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.core.entity.Motion;
import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
@@ -1146,4 +1148,41 @@
return motionList;
}
+ /**
+ * 鐢熸垚鎻愬崌鏈烘墜鍔ㄥ姩浣�
+ */
+ public List<Motion> generateLiftManualMotion(Task task) {
+ List<Motion> motionList = new ArrayList<>();
+ if (task.getTaskSts() != TaskStsType.NEW_MANUAL.sts) {
+ return motionList;
+ }
+
+ Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
+ .eq(Device::getDeviceNo, task.getLiftNo())
+ .eq(Device::getDeviceType, DeviceCtgType.LIFT.val())
+ .eq(Device::getHostId, task.getHostId())
+ .eq(Device::getStatus, 1));
+ if (device == null) {
+ return motionList;
+ }
+
+ if (task.getDestSite().equals("move")) {
+ //鎻愬崌鏈哄崌闄嶆ゼ灞�
+
+ // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰
+ motionList.addAll(kernelService.liftMove(
+ null
+ , MotionDto.build((dto -> {
+ dto.setLiftNo(device.getId().intValue());
+ dto.setLev(Integer.parseInt(task.getDestLoc()));
+ }))
+ ));
+
+ } else if (task.getDestSite().equals("movePallet")) {
+ //绉诲姩鎵樼洏
+ }
+
+ return motionList;
+ }
+
}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java
index 9f876c1..4fb2d5f 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java
@@ -70,7 +70,7 @@
case LIFT_MOVE:
// 濡傛灉宸茬粡鍦ㄧ洰鏍囧眰锛岄偅杈瑰眰杩囨护
if (liftProtocol.getLev().equals(Integer.valueOf(motion.getTarget()))) {
- liftProtocol.setTaskNo(motion.getTaskNo());
+ liftThread.setSyncTaskNo(motion.getTaskNo());
break;
}
@@ -338,7 +338,7 @@
return false;
}
- liftProtocol.setTaskNo(0);//娓呴浂宸ヤ綔鍙�
+ liftThread.setSyncTaskNo(0);//娓呴浂宸ヤ綔鍙�
return true;
}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java
index d47627f..24c4169 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java
@@ -144,6 +144,30 @@
*/
private Object extend;
+ public String getRun$() {
+ if (this.run == null) {
+ return "鏈煡";
+ }
+
+ return this.run ? "杩愯涓�" : "绌洪棽";
+ }
+
+ public String getReady$() {
+ if (this.ready == null) {
+ return "鏈煡";
+ }
+
+ return this.ready ? "灏辩华" : "鏈氨缁�";
+ }
+
+ public String getModel$() {
+ if (this.model == null) {
+ return "鏈煡";
+ }
+
+ return this.model ? "鑷姩" : "鎵嬪姩";
+ }
+
/**
* 璁剧疆鎻愬崌鏈虹姸鎬�
*/
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/LiftService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/LiftService.java
new file mode 100644
index 0000000..10ba6e5
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/LiftService.java
@@ -0,0 +1,11 @@
+package com.zy.asrs.wcs.rcs.service;
+
+import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
+
+import java.util.List;
+
+public interface LiftService {
+
+ List<LiftProtocol> getLiftStatusList(Long hostId);
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/LiftServiceImpl.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/LiftServiceImpl.java
new file mode 100644
index 0000000..8563c3d
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/LiftServiceImpl.java
@@ -0,0 +1,41 @@
+package com.zy.asrs.wcs.rcs.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
+import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
+import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
+import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
+import com.zy.asrs.wcs.rcs.service.DeviceService;
+import com.zy.asrs.wcs.rcs.service.LiftService;
+import com.zy.asrs.wcs.rcs.thread.LiftThread;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service("LiftService")
+public class LiftServiceImpl implements LiftService {
+
+ @Autowired
+ private DeviceService deviceService;
+
+ @Override
+ public List<LiftProtocol> getLiftStatusList(Long hostId) {
+ ArrayList<LiftProtocol> data = new ArrayList<>();
+ List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>()
+ .eq(Device::getHostId, hostId)
+ .eq(Device::getStatus, 1)
+ .eq(Device::getDeviceType, DeviceCtgType.LIFT.val()));
+ for (Device device : list) {
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue());
+ if (liftThread == null) {
+ continue;
+ }
+ LiftProtocol status = liftThread.getStatus();
+ data.add(status);
+ }
+ return data;
+ }
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/ShuttleServiceImpl.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/ShuttleServiceImpl.java
index 50bac03..d15f663 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/ShuttleServiceImpl.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/ShuttleServiceImpl.java
@@ -26,7 +26,6 @@
@Override
public List<ShuttleProtocol> getShuttleStatusList(Long hostId) {
-
ArrayList<ShuttleProtocol> data = new ArrayList<>();
List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>()
.eq(Device::getHostId, hostId)
@@ -34,6 +33,9 @@
.eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()));
for (Device device : list) {
ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
+ if (shuttleThread == null) {
+ continue;
+ }
ShuttleProtocol status = shuttleThread.getStatus();
data.add(status);
}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
index 8dc9155..72e48c4 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
@@ -3,6 +3,7 @@
import com.zy.asrs.wcs.common.ExecuteSupport;
import com.zy.asrs.wcs.core.model.command.LiftCommand;
import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
public interface LiftThread extends ThreadHandler{
@@ -25,6 +26,10 @@
boolean isIdle(ExecuteSupport support);//鏄惁绌洪棽
+ boolean setProtocolStatus(LiftProtocolStatusType status);//璁剧疆宸ヤ綔鐘舵��
+
+ boolean setSyncTaskNo(Integer taskNo);//璁剧疆宸ヤ綔鍙�
+
//***************鑾峰彇鍛戒护*****************
LiftCommand getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, Integer mode);//鎻愬崌鏈虹Щ鍔�
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java
index 1f91941..90ddd55 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java
@@ -21,7 +21,6 @@
import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.entity.DeviceDataLog;
import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
-import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
import com.zy.asrs.wcs.rcs.service.DeviceDataLogService;
import com.zy.asrs.wcs.rcs.thread.LiftThread;
@@ -29,7 +28,6 @@
import lombok.extern.slf4j.Slf4j;
import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
import java.util.*;
@Slf4j
@@ -302,6 +300,18 @@
}
@Override
+ public synchronized boolean setProtocolStatus(LiftProtocolStatusType status) {
+ this.liftProtocol.setProtocolStatus(status);
+ return true;
+ }
+
+ @Override
+ public synchronized boolean setSyncTaskNo(Integer taskNo) {
+ this.liftProtocol.setTaskNo(taskNo);
+ return true;
+ }
+
+ @Override
public LiftCommand getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, Integer mode) {
/**
* 浠诲姟绫诲瀷
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
index d4f8011..fcdf4fd 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
@@ -2,18 +2,13 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.common.utils.HttpHandler;
import com.zy.asrs.framework.common.DateUtils;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.common.ExecuteSupport;
-import com.zy.asrs.wcs.core.entity.Loc;
import com.zy.asrs.wcs.core.model.command.LiftCommand;
-import com.zy.asrs.wcs.core.model.command.ShuttleCommand;
import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType;
-import com.zy.asrs.wcs.core.model.enums.ShuttleCommandModeType;
-import com.zy.asrs.wcs.core.service.LocService;
import com.zy.asrs.wcs.rcs.News;
import com.zy.asrs.wcs.rcs.cache.OutputQueue;
import com.zy.asrs.wcs.rcs.entity.DeviceDataLog;
@@ -28,7 +23,6 @@
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
-import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
@@ -333,6 +327,18 @@
return false;
}
+ @Override
+ public boolean setProtocolStatus(LiftProtocolStatusType status) {
+ this.liftProtocol.setProtocolStatus(status);
+ return true;
+ }
+
+ @Override
+ public boolean setSyncTaskNo(Integer taskNo) {
+ this.liftProtocol.setTaskNo(taskNo);
+ return true;
+ }
+
//***************璁惧灞傞�氳-涓嶅悓鍘傚晢璁惧閫氳鏂规涓嶄竴鑷�***************
//璇锋眰鐧诲綍
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/ws/LiftWebSocket.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/ws/LiftWebSocket.java
new file mode 100644
index 0000000..e0e6b97
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/ws/LiftWebSocket.java
@@ -0,0 +1,171 @@
+package com.zy.asrs.wcs.rcs.ws;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.zy.asrs.framework.common.R;
+import com.zy.asrs.framework.common.SpringUtils;
+import com.zy.asrs.wcs.common.config.ConfigProperties;
+import com.zy.asrs.wcs.common.security.JwtSubject;
+import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
+import com.zy.asrs.wcs.rcs.service.LiftService;
+import com.zy.asrs.wcs.rcs.ws.model.WebSocketMessage;
+import com.zy.asrs.wcs.utils.JwtUtil;
+import io.jsonwebtoken.Claims;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.websocket.*;
+import javax.websocket.server.ServerEndpoint;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+@Component
+@Slf4j
+@Service
+@ServerEndpoint("/ws/lift/websocket")
+@Data
+public class LiftWebSocket {
+
+ //瀹㈡埛绔湪绾夸汉鏁�
+ private static int onlineClient = 0;
+
+ //瀹㈡埛绔睜
+ private static CopyOnWriteArraySet<LiftWebSocket> webSocketServers = new CopyOnWriteArraySet<>();
+
+ private Session session;
+
+ private String username;
+
+ private Long hostId;
+
+ //绠¢亾ID
+ private String sessionId;
+
+ @OnOpen
+ public void onOpen(Session session) {
+ this.session = session;
+ this.sessionId = session.getId();
+
+ //灏唚ebsocket瀵硅薄杩涜淇濆瓨
+ webSocketServers.add(this);
+ //娣诲姞鍦ㄧ嚎浜烘暟
+ addOnlineClient();
+ log.info("鏈夋柊绐楀彛寮�濮嬬洃鍚�:" + session.getId() + ",褰撳墠鍦ㄧ嚎浜烘暟涓�:" + getOnlineClient());
+ }
+
+ /**
+ * 杩炴帴鍏抽棴璋冪敤鐨勬柟娉�
+ */
+ @OnClose
+ public void onClose() {
+ webSocketServers.remove(this); //浠巗et涓垹闄�
+ subOnlineClient(); //鍦ㄧ嚎鏁板噺1
+ log.info("鍏抽棴鐨勮繛鎺ワ細" + sessionId);
+ log.info("鏈変竴杩炴帴鍏抽棴锛佸綋鍓嶅湪绾夸汉鏁颁负" + getOnlineClient());
+ }
+
+ /**
+ * 鏀跺埌瀹㈡埛绔秷鎭悗璋冪敤鐨勬柟娉�
+ * @ Param message 瀹㈡埛绔彂閫佽繃鏉ョ殑娑堟伅
+ */
+ @OnMessage
+ public void onMessage(String message, Session session) throws IOException {
+ LiftService liftService = SpringUtils.getBean(LiftService.class);
+ WebSocketMessage socketMessage = JSON.parseObject(message, WebSocketMessage.class);
+ if (socketMessage.getUrl().equals("login")) {
+ try {
+ // 瑙f瀽token
+ ConfigProperties configProperties = SpringUtils.getBean(ConfigProperties.class);
+ JSONObject data = JSON.parseObject(socketMessage.getData());
+ Claims claims = JwtUtil.parseToken(data.getString("token"), configProperties.getTokenKey());
+ JwtSubject jwtSubject = JwtUtil.getJwtSubject(claims);
+ this.username = jwtSubject.getUsername();
+ this.hostId = jwtSubject.getHostId();
+ socketMessage.setData(JSON.toJSONString(R.ok("auth success")));
+ } catch (Exception e) {
+ e.printStackTrace();
+ socketMessage.setData(JSON.toJSONString(R.error("auth fail")));
+ }
+ this.sendMessage(JSON.toJSONString(socketMessage));
+ } else if (socketMessage.getUrl().equals("/lift/status/list")) {
+ if (this.hostId != null) {
+ List<LiftProtocol> data = liftService.getLiftStatusList(this.hostId);
+ socketMessage.setData(JSON.toJSONString(data));
+ this.sendMessage(JSON.toJSONString(socketMessage));
+ }
+ }
+// log.info("鏀跺埌鏉ヨ嚜杩炴帴锛�" + sessionId + "鐨勪俊鎭�:" + message);
+ }
+
+ /**
+ * @ Param session
+ * @ Param error
+ */
+ @OnError
+ public void onError(Session session, Throwable error) {
+ log.error("鍙戠敓閿欒");
+ error.printStackTrace();
+ }
+
+ /**
+ * 瀹炵幇鏈嶅姟鍣ㄤ富鍔ㄦ帹閫�
+ */
+ public void sendMessage(String message) throws IOException {
+ this.session.getBasicRemote().sendText(message);
+ }
+
+ /**
+ * 鏈嶅姟鍣ㄤ富鍔ㄦ帹閫佺粰鎸囧畾鐢ㄦ埛
+ */
+ public void sendMessage(String message, String account) throws IOException {
+ for (LiftWebSocket item : webSocketServers) {
+ item.sendMessage(message);
+ }
+ }
+
+ public void sendMessage(String message, int userId) throws IOException {
+ for (LiftWebSocket item : webSocketServers) {
+ item.sendMessage(message);
+ }
+ }
+
+ /**
+ * 鏈嶅姟鍣ㄤ富鍔ㄦ帹閫佺粰鎸囧畾鐢ㄦ埛
+ */
+ public static boolean sendMessageGlobal(String message, String account) throws IOException {
+ boolean tag = false;
+ for (LiftWebSocket item : webSocketServers) {
+ tag = true;
+ item.sendMessage(message);
+ }
+ return tag;
+ }
+
+ public static boolean sendMessageGlobal(String message, int userId) throws IOException {
+ boolean tag = false;
+ for (LiftWebSocket item : webSocketServers) {
+ tag = true;
+ item.sendMessage(message);
+ }
+ return tag;
+ }
+
+ public static synchronized int getOnlineClient() {
+ return onlineClient;
+ }
+
+ public static synchronized void addOnlineClient() {
+ LiftWebSocket.onlineClient++;
+ }
+
+ public static synchronized void subOnlineClient() {
+ if (LiftWebSocket.onlineClient > 0) {
+ LiftWebSocket.onlineClient--;
+ }
+ }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/ws/ShuttleWebSocket.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/ws/ShuttleWebSocket.java
index b17a131..354eaa4 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/ws/ShuttleWebSocket.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/ws/ShuttleWebSocket.java
@@ -13,6 +13,7 @@
import io.jsonwebtoken.Claims;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
--
Gitblit v1.9.1