From 46054fc49e33fe4f1aba8da23b74b8f14664bdfe Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期日, 28 四月 2024 09:06:42 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/FlowExecute.java | 82 ++++++++++++++++++++++++++
zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerLift.jsx | 47 +++++++++++++--
2 files changed, 119 insertions(+), 10 deletions(-)
diff --git a/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerLift.jsx b/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerLift.jsx
index 042d9dc..a62d7a0 100644
--- a/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerLift.jsx
+++ b/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerLift.jsx
@@ -38,14 +38,33 @@
},
];
- const sourceLevChange = (e) => {
- setSourceLev(e.target.value);
- nodeData.data.liftType.sourceLev = e.target.value;
+ const liftOptions2 = [
+ {
+ label: '鏃�',
+ value: 'none'
+ },
+ {
+ label: '绌挎杞﹀眰',
+ value: 'shuttleLev'
+ },
+ {
+ label: '宸ヤ綔妗f簮搴撲綅灞�',
+ value: 'originLev'
+ },
+ {
+ label: '宸ヤ綔妗g洰鏍囧簱浣嶅眰',
+ value: 'targetLev'
+ },
+ ];
+
+ const sourceLevChange = (event) => {
+ setSourceLev(event);
+ nodeData.data.liftType.sourceLev = event;
}
- const targetLevChange = (e) => {
- setTargetLev(e.target.value);
- nodeData.data.liftType.targetLev = e.target.value;
+ const targetLevChange = (event) => {
+ setTargetLev(event);
+ nodeData.data.liftType.targetLev = event;
}
const liftOptionsChange = (event) => {
@@ -137,10 +156,22 @@
<div>缁勪欢鍚嶏細<Input defaultValue={nodeData.label} onChange={nodeDataInputChange} /></div>
<div>鏍硅妭鐐癸細<Switch checkedChildren="鏄�" unCheckedChildren="鍚�" checked={nodeData.data.root} /></div>
<div>
- 婧愬眰锛�<Input defaultValue={sourceLev} onChange={sourceLevChange} />
+ 婧愬眰锛�
+ <Select
+ style={{ width: 240 }}
+ options={liftOptions2}
+ value={sourceLev}
+ onChange={sourceLevChange}
+ />
</div>
<div>
- 鐩爣灞傦細<Input defaultValue={targetLev} onChange={targetLevChange} />
+ 鐩爣灞傦細
+ <Select
+ style={{ width: 240 }}
+ options={liftOptions2}
+ value={targetLev}
+ onChange={targetLevChange}
+ />
</div>
<div>
鎿嶄綔鏂规硶锛�
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/FlowExecute.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/FlowExecute.java
index 5ba60e1..4efdbd0 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/FlowExecute.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/FlowExecute.java
@@ -7,7 +7,10 @@
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.asrs.entity.param.FlowLogicCodeParam;
+import com.zy.asrs.wcs.core.domain.dto.MotionDto;
+import com.zy.asrs.wcs.core.entity.Motion;
import com.zy.asrs.wcs.core.entity.Task;
+import com.zy.asrs.wcs.core.kernel.KernelService;
import com.zy.asrs.wcs.core.service.TaskService;
import com.zy.asrs.wcs.core.utils.RedisUtil;
import com.zy.asrs.wcs.core.utils.ShuttleDispatcher;
@@ -15,12 +18,14 @@
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.model.protocol.ShuttleProtocol;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.digest.Md5Crypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -33,6 +38,8 @@
private TaskService taskService;
@Autowired
private ShuttleDispatcher shuttleDispatcher;
+ @Autowired
+ private KernelService kernelService;
//鎵ц娴佺▼鍥�
public boolean execute(List<JSONObject> list) {
@@ -48,6 +55,7 @@
for (Task task : tasks) {
String redisKey = DigestUtils.md5Hex(JSON.toJSONString(list));
+ redisSet(redisKey, "motionList", new ArrayList<Motion>());
while (currentId != null) {
//鑾峰彇娴佺▼鍥�
JSONObject flow = findFLow(list, currentId);
@@ -160,15 +168,85 @@
}
private boolean executeLiftFlow(Task task, JSONObject data, String redisKey) {
+ Object object = redisGet(redisKey, "motionList");
+ List<Motion> motionList = JSON.parseArray(JSON.toJSONString(object), Motion.class);
+
+ Object liftDeviceObj = redisGet(redisKey, "liftDevice");
+ if (liftDeviceObj == null) {
+ throw new CoolException("鎻愬崌鏈虹紦瀛樹负绌�");
+ }
+
+ Device device = JSON.parseObject(String.valueOf(liftDeviceObj), Device.class);
+ if (device == null) {
+ throw new CoolException("鎻愬崌鏈鸿澶囦笉瀛樺湪");
+ }
+
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue());
+ if (liftThread == null) {
+ throw new CoolException("鎻愬崌鏈轰笉瀛樺湪");
+ }
+
+ LiftProtocol liftProtocol = liftThread.getStatus();
+ if (liftProtocol == null) {
+ throw new CoolException("鎻愬崌鏈轰笉瀛樺湪");
+ }
+
JSONObject liftType = data.getJSONObject("liftType");
- String oper = liftType.getString("liftOper");
- if (oper.equals("move")) {
+ String opera = liftType.getString("liftOper");
+ if (opera.equals("move")) {
//鎻愬崌鏈哄崌闄�
+ String sourceLevStr = liftType.getString("sourceLev");
+ String targetLevStr = liftType.getString("targetLev");
+ Integer sourceLev = getLiftOperaLev(sourceLevStr, task, redisKey);
+ Integer targetLev = getLiftOperaLev(targetLevStr, task, redisKey);
+
+ motionList.addAll(kernelService.liftMove(
+ MotionDto.build((dto -> {
+ dto.setLiftNo(device.getId().intValue());
+ dto.setLev(sourceLev);
+ }))
+ , MotionDto.build((dto -> {
+ dto.setLiftNo(device.getId().intValue());
+ dto.setLev(targetLev);
+ }))
+ ));
}
return true;
}
+ private Integer getLiftOperaLev(String opera, Task task, String redisKey) {
+ if (opera.equals("sourceLev")) {
+ return Utils.getLev(task.getOriginLoc());
+ } else if (opera.equals("targetLev")) {
+ return Utils.getLev(task.getDestLoc());
+ } else if (opera.equals("shuttleLev")) {
+ //鍙栧嚭缂撳瓨灏忚溅
+ Object shuttleDeviceObj = redisGet(redisKey, "shuttleDevice");
+ if (shuttleDeviceObj == null) {
+ throw new CoolException("绌挎杞︾紦瀛樹负绌�");
+ }
+ Device device = JSON.parseObject(String.valueOf(shuttleDeviceObj), Device.class);
+ if (device == null) {
+ throw new CoolException("绌挎杞﹁澶囦笉瀛樺湪");
+ }
+
+ ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
+ if (shuttleThread == null) {
+ throw new CoolException("绌挎杞︿笉瀛樺湪");
+ }
+
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+ if (shuttleProtocol == null) {
+ throw new CoolException("绌挎杞︿笉瀛樺湪");
+ }
+
+ return Utils.getLev(shuttleProtocol.getCurrentLocNo());
+ }
+
+ throw new CoolException("绫诲瀷寮傚父");
+ }
+
private boolean redisSet(String redisKey, String key, Object data) {
if (redisUtil.hasKey(redisKey)) {
Object obj = redisUtil.get(redisKey);
--
Gitblit v1.9.1