From a3457fec2098d42166adba326c1d7f197cb59b16 Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期日, 27 四月 2025 08:28:00 +0800
Subject: [PATCH] 米多泉州rgv调度程序完成
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 93 ++++++++++++++++++++++++++++++++++++----------
1 files changed, 72 insertions(+), 21 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index 8353ed6..143e3a4 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -3,28 +3,38 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
-import com.zy.asrs.entity.*;
+import com.zy.asrs.entity.BasCircularShuttle;
+import com.zy.asrs.entity.BasDevpPosition;
+import com.zy.asrs.entity.BasRgv;
+import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.BasCircularShuttleService;
import com.zy.asrs.service.BasDevpPositionService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.SortTheExecutionOfTheCarUtil;
import com.zy.asrs.utils.TimeCalculatorUtils;
+import com.zy.common.service.CommonService;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
-import com.zy.core.enums.*;
+import com.zy.core.enums.RgvModeType;
+import com.zy.core.enums.RgvStatusType;
+import com.zy.core.enums.RgvTaskModeType;
+import com.zy.core.enums.SlaveType;
import com.zy.core.model.RgvSlave;
import com.zy.core.model.Task;
import com.zy.core.model.command.RgvCommand;
import com.zy.core.model.protocol.RgvProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.RgvThread;
+import com.zy.system.entity.license.LicenseVerify;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
/**
* 绔嬩綋浠撳簱WCS绯荤粺涓绘祦绋嬩笟鍔�
@@ -45,6 +55,8 @@
private BasCircularShuttleService basCircularShuttleService;
@Autowired
private WrkMastService wrkMastService;
+ @Autowired
+ private CommonService commonService;
@Value("${constant-parameters.perimeter}")
private Long perimeter;
@@ -56,13 +68,37 @@
private Long rgvCount;
@Value("${constant-parameters.rgvDate}")
private Double rgvDate;
+ @Value("${wms.url}")
+ private String wmsUrl;
+ @Value("${wms.reportOutPath}")
+ private String wmsOutPath;
+ @Value("${wms.reportSwitch}")
+ private boolean reportSwitch;
+ @Value("${wms.reportSwitchAuto}")
+ private boolean reportSwitchAuto;
+
+ /*
+ * 楠岃瘉璁稿彲璇佹槸鍚︽湁鏁�
+ * */
+ public synchronized boolean licenseVerify() {
+ try{
+// if (true) {
+// return true;
+// }
+ return new LicenseVerify().verify();
+ } catch (Exception e){
+ log.info("璁稿彲璇侀獙璇佸け璐ワ紒锛佸紓甯革細{}",e.getMessage());
+ }
+ return false;
+ }
+
/**
* 绔欑偣浠诲姟妫�娴� 鏇存柊灏忚溅浣嶇疆淇℃伅
*/
public synchronized void updateStePositionNearby() {
try {
- List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 1L));
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 2L));
if (wrkMasts.isEmpty()) {
return;
}
@@ -101,7 +137,7 @@
log.info("鏇存柊灏忚溅鎺掑簭淇℃伅寮傚父={}", rgvNo);
return;
}
- List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().orderBy("rgv_id", true));
+ List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().eq("status", 0).orderBy("rgv_id", true));
if (basCircularShuttleList.get(0).getRgvNo().equals(rgvNo)) {
return;
}
@@ -141,6 +177,10 @@
Integer rgvNo = 0;
List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().orderBy("rgv_id", true));
for (BasCircularShuttle basCircularShuttle : basCircularShuttleList) {
+ if (basCircularShuttle.getStatus() != 0){
+ sign = true;
+ continue;
+ }
RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo());
RgvProtocol rgvProtocol = rgvThread.getRgvProtocol();
if (rgvProtocol == null) {
@@ -185,7 +225,7 @@
*/
public synchronized void DevpTaskNoRun() {
try {
- List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 1L).orderBy("modi_time", true));
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("rgv_no", 0).orderBy("modi_time", true));
if (wrkMasts.isEmpty()) {
return;
}
@@ -219,7 +259,7 @@
List<WrkMast> wrkMastlistA = new ArrayList<>();
List<WrkMast> wrkMastlistB = new ArrayList<>();
for (BasDevpPosition basDevpPosition : basDevpPositionsListUN) {
- List<WrkMast> wrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("sta_no", basDevpPosition.getDevNo()).eq("wrk_sts", 1L).orderBy("modi_time", true));
+ List<WrkMast> wrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("sta_no", basDevpPosition.getDevNo()).eq("rgv_no", 0).orderBy("modi_time", true));
for (WrkMast wrkMast : wrkMastList) {
if (!Cools.isEmpty(wrkMast)) {
if (SortTheExecutionOfTheCarUtil.devpNoSortbj(basDevpPositionsListUN, wrkMast.getSourceStaNo(), wrkMast.getStaNo())) {
@@ -251,18 +291,20 @@
break runRgv;
}
BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", rgvId));
+ if (basCircularShuttle.getStatus() != 0){
+ continue ;
+ }
RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo());
RgvProtocol rgvProtocol = rgvThread.getRgvProtocol();
if (rgvProtocol == null) {
continue;
}
- List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("rgv_no", rgvProtocol.getRgvNo()).eq("wrk_sts", 2L));
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("rgv_no", rgvProtocol.getRgvNo()));
if (!wrkMasts.isEmpty()) {
continue;
}
- if (rgvProtocol != null
- && rgvProtocol.modeType == RgvModeType.AUTO
+ if (rgvProtocol.modeType == RgvModeType.AUTO
&& (rgvProtocol.getStatusType() == RgvStatusType.IDLE || rgvProtocol.getStatusType() == RgvStatusType.ROAM)
&& rgvProtocol.getTaskNo1() == 0
&& rgvProtocol.getAlarm() == 0) {
@@ -270,8 +312,17 @@
double finalVelocity = 0.0; // 鏈�缁堥�熷害 (m/s)
double distance = (Math.pow(finalVelocity, 2) - Math.pow(rgvProtocol.instantaneousSpeed / 60, 2)) / (2 * acceleration);
BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("dev_no", wrkMast.getSourceStaNo()));
- if (distance * proportion > ((SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPosition.getPlcPosition(), rgvProtocol.getRgvPos(), perimeter) + (rgvProtocol.instantaneousSpeed / 60) * proportion * rgvDate))) {
- continue;
+ if ((distance * proportion + (rgvProtocol.instantaneousSpeed / 60) * proportion * rgvDate) > (SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPosition.getPlcPosition(), rgvProtocol.getRgvPos(), perimeter) )) {
+// List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position", true));
+// if (basDevpPositions.isEmpty()) {
+// log.error("鑾峰彇鎵�鏈夌珯鐐逛俊鎭紓甯�,RGV浠诲姟涓嬪彂澶辫触锛岃鑱旂郴绠$悊鍛橈紒锛侊紒");
+// break runRgv;
+// }
+// List<Integer> devpList = SortTheExecutionOfTheCarUtil.BasDevpPositionExtractSites(basDevpPositions);
+//
+// if (!SortTheExecutionOfTheCarUtil.calculateShortestDistanceDirection(devpList,rgvProtocol.getEndStaM(),wrkMast.getSourceStaNo())){
+ continue;
+// }
}
}
RgvCommand rgvCommand = new RgvCommand();
@@ -279,8 +330,8 @@
rgvCommand.setAckFinish1((short) 0); // 宸ヤ綅1浠诲姟瀹屾垚纭浣�
rgvCommand.setTaskNo1(wrkMast.getWrkNo().shortValue());
rgvCommand.setTaskMode1(RgvTaskModeType.FETCH_PUT); // 宸ヤ綅1浠诲姟妯″紡: 鍙栨斁璐�
- rgvCommand.setSourceStaNo1(wrkMast.getSourceStaNo().shortValue()); //宸ヤ綅1璧风偣
- rgvCommand.setDestinationStaNo1(wrkMast.getStaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣
+ rgvCommand.setSourceStaNo1(wrkMast.getRgvSstaNo().shortValue()); //宸ヤ綅1璧风偣
+ rgvCommand.setDestinationStaNo1(wrkMast.getRgvDstaNo().shortValue()); //宸ヤ綅1鐩爣绔欑偣
rgvCommand.setCommand((short) 1); //宸ヤ綅1浠诲姟纭
if (!MessageQueue.offer(SlaveType.Rgv, rgvProtocol.getRgvNo(), new Task(2, rgvCommand))) {
//
@@ -289,7 +340,6 @@
}
log.info("RGV鍛戒护涓嬪彂鎴愬姛锛孯GV鍙�={}锛屼换鍔℃暟鎹�={}", rgvId, JSON.toJSON(rgvCommand));
- wrkMast.setWrkSts(2L);
wrkMast.setRgvNo(rgvProtocol.getRgvNo());
wrkMast.setAppeTime(new Date());
try {
@@ -308,7 +358,7 @@
}
//浠诲姟瀹屾垚
- public synchronized void rgvCompleteWrkMastSta() {
+ public synchronized void rgvCompleteWrkMastSta(int[] autoZ) {
try {
for (RgvSlave rgvSlave : slaveProperties.getRgv()) {
RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvSlave.getId());
@@ -329,10 +379,10 @@
&& rgvProtocol.getModeType() == RgvModeType.AUTO
&& rgvProtocol.getTaskNo1() != 0
) {
-// log.info("{}鍙峰皬杞︾瓑寰厀cs纭锛岀姸鎬亄}锛屽弬鏁皗}",rgvProtocol.getRgvNo(),rgvProtocol.getStatusType(),rgvProtocol);
+ log.info("{}鍙峰皬杞︾瓑寰厀cs纭锛岀姸鎬亄}锛屽弬鏁皗}",rgvProtocol.getRgvNo(),rgvProtocol.getStatusType(),rgvProtocol);
WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", rgvProtocol.getTaskNo1().longValue()));
- if (Cools.isEmpty(wrkMast) || !wrkMast.getWrkSts().equals(2L)) {
- log.error("鏈煡鍒板皬杞︽墽琛屼换鍔℃垨鑰呮墽琛屼换鍔$姸鎬佷笉绗﹀悎锛�" + wrkMast);
+ if (Cools.isEmpty(wrkMast) && (wrkMast.getWrkSts() == 2 || wrkMast.getWrkSts() == 15) && (wrkMast.getRgvNo() == 0 || wrkMast.getRgvNo() > 10)) {
+ log.error("鏈煡鍒板皬杞︽墽琛屼换鍔℃垨鑰呮墽琛屼换鍔$姸鎬佷笉绗﹀悎锛�" + rgvProtocol.getTaskNo1());
continue;
}
boolean rgvComplete = rgvComplete(rgvProtocol.getRgvNo());
@@ -340,8 +390,9 @@
log.error("灏忚溅澶嶄綅澶辫触锛屽皬杞﹀彿{}锛�", rgvProtocol.getRgvNo());
break;
}
- wrkMast.setWrkSts(3L);
- wrkMast.setAppeTime(new Date());
+ wrkMast.setRgvNo(10+rgvProtocol.getRgvNo());
+ Date now = new Date();
+ wrkMast.setModiTime(now);
wrkMastService.updateById(wrkMast);
}
}
--
Gitblit v1.9.1