From d9cea3d7757a8d580bb0574d419ba6dd9c2478e7 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 13 十二月 2024 15:11:50 +0800
Subject: [PATCH] #search shuttle
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java | 117 ++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 89 insertions(+), 28 deletions(-)
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 8869609..7e5b117 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
@@ -14,6 +14,7 @@
import com.zy.asrs.wcs.core.entity.BasLift;
import com.zy.asrs.wcs.core.model.command.LiftCommand;
import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType;
+import com.zy.asrs.wcs.core.model.enums.MotionCtgType;
import com.zy.asrs.wcs.core.service.BasLiftService;
import com.zy.asrs.wcs.core.utils.RedisUtil;
import com.zy.asrs.wcs.core.utils.Utils;
@@ -21,6 +22,7 @@
import com.zy.asrs.wcs.rcs.cache.OutputQueue;
import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.entity.DeviceDataLog;
+import com.zy.asrs.wcs.rcs.model.CommandResponse;
import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
import com.zy.asrs.wcs.rcs.service.DeviceDataLogService;
@@ -81,9 +83,9 @@
try {
readStatus();
- //鎻愬崌鏈哄浜庤繍琛岀姸鎬侊紝灏嗘爣璁扮疆涓篺alse
+ //鎻愬崌鏈哄浜庤繍琛岀姸鎬侊紝灏嗘爣璁扮疆涓簍rue
if (liftProtocol.getRun()) {
- liftProtocol.setPakMk(false);
+ liftProtocol.setPakMk(true);
}
} catch (Exception e) {
OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆戣鍙栨彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort()));
@@ -141,7 +143,7 @@
liftProtocol.setLev((int) lev);
//************琛ュ厖鎵╁睍瀛楁*************
- InnerLiftExtend liftExtend = JSON.parseObject(JSON.toJSONString(liftProtocol.getExtend()), InnerLiftExtend.class);
+ InnerLiftExtend liftExtend = (InnerLiftExtend) liftProtocol.getExtend();
//浠诲姟鍙�
liftExtend.setLiftTaskNo(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result1.Content, 2)));
liftProtocol.setExtend(liftExtend);
@@ -210,6 +212,31 @@
liftProtocol.setDeviceDataLog(System.currentTimeMillis());
}
+ //灏嗘彁鍗囨満鐘舵�佷繚瀛樿嚦鏁版嵁搴�
+ BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class);
+ BasLift basLift = basLiftService.getOne(new LambdaQueryWrapper<BasLift>()
+ .eq(BasLift::getLiftNo, device.getDeviceNo())
+ .eq(BasLift::getHostId, device.getHostId()));
+ if (basLift == null) {
+ basLift = new BasLift();
+ //鎻愬崌鏈哄彿
+ basLift.setLiftNo(Integer.valueOf(device.getDeviceNo()));
+ basLift.setStatus(1);
+ basLift.setDeleted(0);
+ basLift.setHostId(device.getHostId());
+ basLift.setDeviceId(device.getId());
+ basLiftService.save(basLift);
+ }
+ //浠诲姟鍙�
+ basLift.setTaskNo(liftProtocol.getTaskNo().intValue());
+ //淇敼鏃堕棿
+ basLift.setUpdateTime(new Date());
+ //璁惧鐘舵��
+ basLift.setProtocol(JSON.toJSONString(liftProtocol));
+ if (basLiftService.updateById(basLift)) {
+ OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), device.getDeviceNo()));
+ }
+
} catch (Exception e) {
OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆戣鍙栨彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort()));
}
@@ -226,19 +253,21 @@
}
@Override
- public boolean move(LiftCommand command) {
+ public CommandResponse move(LiftCommand command) {
return write(command);
}
@Override
- public boolean palletInOut(LiftCommand command) {
+ public CommandResponse palletInOut(LiftCommand command) {
return write(command);
}
- private boolean write(LiftCommand command) {
+ private CommandResponse write(LiftCommand command) {
+ CommandResponse response = new CommandResponse(false);
if (null == command) {
News.error("鎻愬崌鏈哄啓鍏ュ懡浠や负绌�");
- return false;
+ response.setMessage("鎻愬崌鏈哄啓鍏ュ懡浠や负绌�");
+ return response;
}
List<Short> shorts = JSON.parseArray(command.getBody(), Short.class);
@@ -252,27 +281,30 @@
liftProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
News.info("鎻愬崌鏈哄懡浠や笅鍙慬id:{}] >>>>> {}", device.getId(), JSON.toJSON(command));
OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), device.getId(), JSON.toJSON(command)));
- return true;
+ response.setMessage(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), device.getId(), JSON.toJSON(command)));
+ response.setResult(true);
+ return response;
} else {
OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆戝啓鍏ユ彁鍗囨満plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}],娆℃暟锛歿}", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort()));
News.error("鍐欏叆鎻愬崌鏈簆lc鏁版嵁澶辫触 ===>> [id:{}] [ip:{}] [port:{}]", device.getId(), device.getIp(), device.getPort());
- return false;
+ response.setMessage(MessageFormat.format("銆恵0}銆戝啓鍏ユ彁鍗囨満plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}],娆℃暟锛歿}", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort()));
+ return response;
}
}
@Override
- public boolean lock(LiftCommand command) {
- return true;
+ public CommandResponse lock(LiftCommand command) {
+ return new CommandResponse(true);
}
@Override
- public boolean unlock(LiftCommand command) {
- return true;
+ public CommandResponse unlock(LiftCommand command) {
+ return new CommandResponse(true);
}
@Override
- public boolean reset(LiftCommand command) {
- return false;
+ public CommandResponse reset(LiftCommand command) {
+ return new CommandResponse(false);
}
@Override
@@ -281,19 +313,40 @@
}
@Override
- public boolean isIdle(ExecuteSupport support) {
- if (null != support) {
- if (!support.judgement()) {
- return false;
- }
- }
+ public boolean isIdle(MotionCtgType flag) {
// 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佸氨缁�佺┖闂�
if (this.liftProtocol.getModel()
&& !this.liftProtocol.getRun()
&& this.liftProtocol.getReady()
&& this.liftProtocol.getPakMk()
&& this.liftProtocol.getErrorCode().equals("0")
- && this.liftProtocol.getProtocolStatus().equals(LiftProtocolStatusType.IDLE)
+ && (this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE)
+ || this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.WAITING))
+ ) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isDeviceIdle() {
+ return isDeviceIdle(null);
+ }
+
+ @Override
+ public boolean isDeviceIdle(ExecuteSupport support) {
+ if (null != support) {
+ Boolean judgement = support.judgement();
+ if (judgement != null && !judgement) {
+ return true;
+ }
+ }
+
+ // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佸氨缁�佺┖闂�
+ if (this.liftProtocol.getModel()
+ && !this.liftProtocol.getRun()
+ && this.liftProtocol.getReady()
+ && this.liftProtocol.getErrorCode().equals("0")
) {
return true;
}
@@ -321,7 +374,12 @@
}
@Override
- public LiftCommand getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) {
+ public int generateDeviceTaskNo(int taskNo, MotionCtgType motionCtgType) {
+ return taskNo;
+ }
+
+ @Override
+ public List<LiftCommand> getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) {
/**
* 浠诲姟绫诲瀷
* 1=绉绘墭鐩橈紱鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囩珯鍙�
@@ -349,26 +407,29 @@
command.setMode(LiftCommandModeType.MOVE.id);
command.setOriginLev(sourceLev);
command.setTargetLev(targetLev);
- return command;
+
+ ArrayList<LiftCommand> list = new ArrayList<>();
+ list.add(command);
+ return list;
}
@Override
- public LiftCommand getMoveWithShuttleCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) {
+ public List<LiftCommand> getMoveWithShuttleCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) {
return getMoveCommand(taskNo, sourceLev, targetLev, mode);
}
@Override
- public LiftCommand getPalletInOutCommand(Integer taskNo, Integer sourceLev, Integer targetLev, Integer originSta, Integer targetSta, LiftCommandModeType mode) {
+ public List<LiftCommand> getPalletInOutCommand(Integer taskNo, Integer sourceLev, Integer targetLev, Integer originSta, Integer targetSta, LiftCommandModeType mode) {
return getMoveCommand(taskNo, sourceLev, targetLev, mode);
}
@Override
- public LiftCommand getLockCommand(Integer taskNo, Boolean lock) {
+ public List<LiftCommand> getLockCommand(Integer taskNo, Boolean lock) {
return null;
}
@Override
- public LiftCommand getShuttleSignalCommand(Integer taskNo, Boolean signal) {
+ public List<LiftCommand> getShuttleSignalCommand(Integer taskNo, Boolean signal) {
return null;
}
--
Gitblit v1.9.1