From 25f276990df41cc8bc03a9427874f70776b04bea Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 08 一月 2025 16:18:48 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvDetailServiceImpl.java | 2
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/AgvModelController.java | 13 ++++
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java | 2
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/AgvController.java | 2
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 53 +++++++++--------
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java | 2
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java | 4 +
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java | 4
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MaintainScheduler.java | 4
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvModelServiceImpl.java | 48 ++++++++++++++++
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MapDataWsScheduler.java | 2
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/AgvModelService.java | 4 +
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AvoidWaveCalculator.java | 4
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvServiceImpl.java | 25 ++++----
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java | 7 -
15 files changed, 123 insertions(+), 53 deletions(-)
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MaintainScheduler.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MaintainScheduler.java
index 59dae6c..8927b6d 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MaintainScheduler.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MaintainScheduler.java
@@ -53,7 +53,7 @@
List<Agv> agvList = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val));
for (Agv agv : agvList) {
AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ AgvModel agvModel = agvModelService.getByAgvId(agv.getId());
if (null == agvDetail || null == agvDetail.getVol() || null == agvDetail.getAgvStatus()) {
continue;
}
@@ -95,7 +95,7 @@
List<Agv> agvList = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val));
for (Agv agv : agvList) {
AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ AgvModel agvModel = agvModelService.getByAgvId(agv.getId());
if (null == agvDetail || null == agvDetail.getVol() || null == agvDetail.getAgvStatus() || null == agvDetail.getRecentCode()) {
continue;
}
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MapDataWsScheduler.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MapDataWsScheduler.java
index 4285a02..560bc73 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MapDataWsScheduler.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MapDataWsScheduler.java
@@ -80,7 +80,7 @@
for (Agv agv : agvList) {
AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ AgvModel agvModel = agvModelService.getByAgvId(agv.getId());
if (null == agvDetail) { continue; }
Long recentCode = agvDetail.getRecentCode();
if (null == recentCode) { continue; }
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java
index b389fe9..6434f28 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java
@@ -178,7 +178,7 @@
}
return agvNoList.stream().filter(agvNo -> {
Agv agv = agvService.selectByUuid(agvNo);
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ AgvModel agvModel = agvModelService.getByAgvNo(agvNo);
List<Task> transportTasks = taskService.findTransportTasksByAgv(agv.getId());
return transportTasks.size() < agvModel.getBackpack();
}).collect(Collectors.toList());
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AvoidWaveCalculator.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AvoidWaveCalculator.java
index 142e857..927e1a9 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AvoidWaveCalculator.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AvoidWaveCalculator.java
@@ -115,7 +115,7 @@
}
stopWatch.stop();
- if (stopWatch.getTime() > 100) {
+ if (stopWatch.getTime() > 0) {
log.info("婊ゆ尝鍑芥暟鑺辫垂鏃堕棿涓猴細{}姣......", stopWatch.getTime());
}
}
@@ -241,7 +241,7 @@
}
Agv agv = agvService.selectByUuid(agvNo);
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ AgvModel agvModel = agvModelService.getByAgvNo(agvNo);
Double avoidDistance = MapDataUtils.getVehicleWaveSafeDistance(agvModel.getDiameter(), MapDataConstant.MAX_DISTANCE_BETWEEN_ADJACENT_AGV_FACTOR);
String[][] waveMatrix = mapDataDispatcher.getWaveMatrix(lev);
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
index a71e6f0..3046cc6 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -1,7 +1,6 @@
package com.zy.acs.manager.core.service;
import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.acs.common.domain.AgvAction;
import com.zy.acs.common.domain.AgvActionItem;
@@ -646,28 +645,31 @@
try {
if (Cools.isEmpty(agvId, segmentList)) { return; }
Date now = new Date();
- JSONObject storeDirection = configService.getVal("storeDirection", JSONObject.class);
- Agv agv = agvService.getById(agvId);
- if (!agvService.judgeEnable(agv.getId())) {
- throw new CoolException("AGV[" + agv.getUuid() + "]褰撳墠涓嶅彲鐢�...");
+ long actionPrepareSts = ActionStsType.PREPARE.val();
+// JSONObject storeDirection = configService.getVal("storeDirection", JSONObject.class);
+ int angleOffsetVal = configService.getVal("mapAngleOffsetVal", Integer.class);
+ String agvNo = agvService.getAgvNo(agvId);
+ if (!agvService.judgeEnable(agvId)) {
+ throw new CoolException("AGV[" + agvNo + "]褰撳墠涓嶅彲鐢�...");
}
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ AgvModel agvModel = agvModelService.getByAgvId(agvId);
Double workDirection = agvModel.getWorkDirection();
AgvSpeedType agvSpeedType = AgvSpeedType.query(agvModel.getTravelSpeed());
assert agvSpeedType != null;
- AgvDetail agvDetail = agvDetailService.selectByAgvId(agvId);
+ AgvDetail agvDetail = agvDetailService.selectMajorByAgvId(agvId);
List<Action> actionList = new ArrayList<>();
// start node
Code lastCode = codeService.getById(agvDetail.getRecentCode());
Double lastDirection = agvDetail.getAgvAngle();
if (!lastCode.getData().equals(pathList.get(0))) {
- throw new CoolException("AGV[" + agv.getUuid() + "]瀹氫綅鍋忕Щ...");
+ throw new CoolException("AGV[" + agvNo + "]瀹氫綅鍋忕Щ...");
}
boolean first = true;
+ long startTime = System.currentTimeMillis();
for (Segment segment : segmentList) {
// 鍒嗘鎵�灞炵殑Task
@@ -689,7 +691,7 @@
String next = pathListPart.get(i);
Code nextCode = codeService.selectByData(next);
- Double nextDirection = mapService.calculateDirection(lastCode, nextCode);
+ Double nextDirection = mapService.calculateDirection(lastCode, nextCode, angleOffsetVal);
boolean reverse = false;
if (nextDirection.equals((workDirection + 180) % 360)) {
@@ -709,7 +711,7 @@
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -735,7 +737,7 @@
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(gap.getDistance()), // 鍔ㄤ綔鍙傛暟
actionType.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -761,7 +763,7 @@
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(workDirection), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -792,7 +794,7 @@
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(workDirection), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -801,7 +803,7 @@
// 璐ф灦鍙栬揣
Loc oriLoc = locService.getById(task.getOriLoc());
// 璁$畻宸﹀彸鏂瑰悜
- agvDirectionType = mapService.calculateAgvWorkDirection(storeDirection, oriLoc, lastCode);
+ agvDirectionType = mapService.calculateAgvWorkDirection(oriLoc, lastCode);
actionList.add(new Action(
null, // 缂栧彿
task.getBusId(), // 鎬荤嚎
@@ -813,7 +815,7 @@
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(oriLoc.getOffset()), // 鍔ㄤ綔鍙傛暟
ActionTypeType.ReadyTakeFromShelvesLoc.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -829,7 +831,7 @@
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(backpackType.height), // 鍔ㄤ綔鍙傛暟
ActionTypeType.ReadyReleaseToAgvSite.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -850,7 +852,7 @@
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(workDirection), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -868,7 +870,7 @@
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(backpackType.height), // 鍔ㄤ綔鍙傛暟
ActionTypeType.ReadyTakeFromAgvSite.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -876,7 +878,7 @@
// 璐ф灦鏀捐揣
Loc destLoc = locService.getById(task.getDestLoc());
// 璁$畻宸﹀彸鏂瑰悜
- agvDirectionType = mapService.calculateAgvWorkDirection(storeDirection, destLoc, lastCode);
+ agvDirectionType = mapService.calculateAgvWorkDirection(destLoc, lastCode);
actionList.add(new Action(
null, // 缂栧彿
task.getBusId(), // 鎬荤嚎
@@ -888,7 +890,7 @@
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(destLoc.getOffset()), // 鍔ㄤ綔鍙傛暟
ActionTypeType.ReadyReleaseToShelvesLoc.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -913,7 +915,7 @@
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(chargeDirection), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -932,7 +934,7 @@
lastCode.getData(), // 鍦伴潰鐮�
null, // 鍔ㄤ綔鍙傛暟
ActionTypeType.DockingCharge.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -952,7 +954,7 @@
// lastCode.getData(), // 鍦伴潰鐮�
// String.valueOf(standByDirection), // 鍔ㄤ綔鍙傛暟
// ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
-// ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+// actionPrepareSts, // 鍔ㄤ綔杩涘害
// agvId, // AGV
// now // 宸ヤ綔鏃堕棿
// ));
@@ -966,6 +968,7 @@
}
}
+ System.out.println("save data: " + (System.currentTimeMillis() - startTime));
// finish
actionList.add(new Action(
@@ -979,7 +982,7 @@
lastCode.getData(), // 鍦伴潰鐮�
null, // 鍔ㄤ綔鍙傛暟
ActionTypeType.FinishPath.val(), // 鍔ㄤ綔绫诲瀷
- ActionStsType.PREPARE.val(), // 鍔ㄤ綔杩涘害
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
@@ -1018,7 +1021,7 @@
}
}
- log.info(agv.getUuid() + "鍙稟gv鍔ㄤ綔缁勮瀹屾垚锛屾寚浠ゆ暟閲忥細" + newActionList.size());
+ log.info(agvNo + "鍙稟gv鍔ㄤ綔缁勮瀹屾垚锛屾寚浠ゆ暟閲忥細" + newActionList.size());
} catch (Exception e) {
log.error("mainService.generateAction", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java
index 2be706d..4ad4904 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java
@@ -1,6 +1,5 @@
package com.zy.acs.manager.core.service;
-import com.alibaba.fastjson.JSONObject;
import com.zy.acs.common.enums.AgvDirectionType;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.manager.common.utils.MapDataUtils;
@@ -125,7 +124,7 @@
// 瑙掑害璁$畻
- public Double calculateDirection(Code startCode, Code endCode) {
+ public Double calculateDirection(Code startCode, Code endCode, int angleOffsetVal) {
Double x0 = startCode.getX();
Double y0 = startCode.getY();
@@ -135,7 +134,6 @@
double deltaX = x1 - x0;
double deltaY = y1 - y0;
double angle = -Math.atan2(deltaX, deltaY);
- int angleOffsetVal = configService.getVal("mapAngleOffsetVal", Integer.class);
angle = Math.toDegrees(angle) + angleOffsetVal;
angle = (angle + 360) % 360; // 灏嗚搴﹁浆鎹负姝e��
@@ -143,8 +141,7 @@
}
// 鍧愭爣璐ф灦闃堝�� todo:luxiaotao
- public AgvDirectionType calculateAgvWorkDirection(JSONObject storeDirection, Loc loc, Code code) {
- storeDirection.getString("key");
+ public AgvDirectionType calculateAgvWorkDirection(Loc loc, Code code) {
Integer compDirect = loc.getCompDirect();
AgvDirectionType agvDirectionType = null;
if (compDirect == 0) {
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java
index e13cd31..db2d907 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/RetreatNavigateService.java
@@ -67,7 +67,7 @@
String breakPoint = avoidPathList.stream().findFirst().orElse(null);
List<String> blackList = Utils.singletonList(sponsor);
- Double avoidDistance = MapDataUtils.getVehicleWaveSafeDistance(agvModelService.getById(agvService.selectByUuid(sponsor).getAgvModel()).getDiameter()
+ Double avoidDistance = MapDataUtils.getVehicleWaveSafeDistance(agvModelService.getByAgvNo(sponsor).getDiameter()
, MapDataConstant.MAX_DISTANCE_BETWEEN_ADJACENT_AGV_FACTOR);
List<String> avoidPathListWave = mapService.getWaveScopeByCodeList(lev, avoidPathList, avoidDistance);
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java
index de7319e..6a08094 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java
@@ -135,7 +135,9 @@
// checkout path
Code startCode = codeService.getById(agvDetail.getRecentCode());
Code endCode = codeService.getById(endNode);
+ long startTime = System.currentTimeMillis();
List<String> pathList = this.checkoutPath(agv, startCode, endCode, segment);
+ System.out.println("checkoutPath: " + (System.currentTimeMillis() - startTime));
if (Cools.isEmpty(pathList)) {
return;
}
@@ -200,7 +202,9 @@
mapService.lockPath(null, pathList, agv.getUuid());
+ startTime = System.currentTimeMillis();
mainService.generateAction(segment.getAgvId(), segmentList, pathList, now);
+ System.out.println("generateAction: " + (System.currentTimeMillis() - startTime));
} catch (Exception e) {
log.error("TrafficService.trigger", e);
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/AgvController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/AgvController.java
index 3defd6e..6947650 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/AgvController.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/AgvController.java
@@ -92,7 +92,7 @@
if (null != agvDetail) {
agv.setAgvDetail(agvDetail);
}
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ AgvModel agvModel = agvModelService.getByAgvId(agv.getId());
if (null != agvModel) {
agv.setAgvModelData(agvModel);
}
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/AgvModelController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/AgvModelController.java
index cde3cc3..2380ef6 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/AgvModelController.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/AgvModelController.java
@@ -12,6 +12,7 @@
import com.zy.acs.manager.common.utils.ExcelUtil;
import com.zy.acs.manager.manager.entity.AgvModel;
import com.zy.acs.manager.manager.service.AgvModelService;
+import com.zy.acs.manager.manager.service.impl.AgvModelServiceImpl;
import com.zy.acs.manager.system.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -101,6 +102,18 @@
agvModel.setUpdateTime(new Date());
if (!agvModelService.updateById(agvModel)) {
return R.error("Update Fail");
+ } else {
+ // update cache
+ for (Map.Entry<Long, AgvModel> entry : AgvModelServiceImpl.AGV_ID_MODEL_CACHE.entrySet()) {
+ if (entry.getValue().getId().equals(agvModel.getId())) {
+ entry.setValue(agvModel);
+ }
+ }
+ for (Map.Entry<String, AgvModel> entry : AgvModelServiceImpl.AGV_NO_MODEL_CACHE.entrySet()) {
+ if (entry.getValue().getId().equals(agvModel.getId())) {
+ entry.setValue(agvModel);
+ }
+ }
}
return R.ok("Update Success").add(agvModel);
}
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/AgvModelService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/AgvModelService.java
index e70b4fe..f6e683c 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/AgvModelService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/AgvModelService.java
@@ -7,4 +7,8 @@
AgvModel selectByType(String type);
+ AgvModel getByAgvId(Long agvId);
+
+ AgvModel getByAgvNo(String agvNo);
+
}
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvDetailServiceImpl.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvDetailServiceImpl.java
index df6f396..fbb348a 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvDetailServiceImpl.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvDetailServiceImpl.java
@@ -66,7 +66,7 @@
agvDetail = this.selectByAgvId(agv.getId());
}
if (null == agvModel) {
- agvModel = agvModelService.getById(agv.getAgvModel());
+ agvModel = agvModelService.getByAgvId(agv.getId());
}
if (null == agv.getChargeLine()) {
return agvDetail.getVol() < agvModel.getLowBattery();
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvModelServiceImpl.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvModelServiceImpl.java
index 86dc58b..bce4b2d 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvModelServiceImpl.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvModelServiceImpl.java
@@ -2,17 +2,65 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zy.acs.manager.manager.entity.Agv;
import com.zy.acs.manager.manager.entity.AgvModel;
import com.zy.acs.manager.manager.mapper.AgvModelMapper;
import com.zy.acs.manager.manager.service.AgvModelService;
+import com.zy.acs.manager.manager.service.AgvService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.util.HashMap;
+import java.util.Map;
@Service("agvModelService")
public class AgvModelServiceImpl extends ServiceImpl<AgvModelMapper, AgvModel> implements AgvModelService {
+ public static final Map<Long, AgvModel> AGV_ID_MODEL_CACHE = new HashMap<>();
+ public static final Map<String, AgvModel> AGV_NO_MODEL_CACHE = new HashMap<>();
+
+ @Autowired
+ private AgvService agvService;
+
+ @PostConstruct
+ public void init() {
+ for (Agv agv : agvService.list()) {
+ AgvModel agvModel = this.getById(agv.getAgvModel());
+ AGV_ID_MODEL_CACHE.put(agv.getId(), agvModel);
+ AGV_NO_MODEL_CACHE.put(agv.getUuid(), agvModel);
+ }
+ }
+
@Override
public AgvModel selectByType(String type) {
return this.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, type));
}
+ @Override
+ public AgvModel getByAgvId(Long agvId) {
+ AgvModel agvModel = AGV_ID_MODEL_CACHE.get(agvId);
+ if (agvModel == null) {
+ Agv agv = agvService.getById(agvId);
+ agvModel = this.getById(agv.getAgvModel());
+ if(agvModel != null) {
+ AGV_ID_MODEL_CACHE.put(agv.getId(), agvModel);
+ }
+ }
+ return agvModel;
+ }
+
+ @Override
+ public AgvModel getByAgvNo(String agvNo) {
+ AgvModel agvModel = AGV_NO_MODEL_CACHE.get(agvNo);
+ if (agvModel == null) {
+ Agv agv = agvService.selectByUuid(agvNo);
+ agvModel = this.getById(agv.getAgvModel());
+ if(agvModel != null) {
+ AGV_NO_MODEL_CACHE.put(agvNo, agvModel);
+ }
+ }
+ return agvModel;
+ }
+
}
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvServiceImpl.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvServiceImpl.java
index d30882b..95f8cbf 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvServiceImpl.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/AgvServiceImpl.java
@@ -100,29 +100,29 @@
@Override
public Boolean judgeEnable(Long agvId, Boolean isLowBattery) {
- Agv agv = this.getById(agvId);
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ String agvNo = this.getAgvNo(agvId);
+ AgvModel agvModel = agvModelService.getByAgvId(agvId);
if (0 < segmentService.count(new LambdaQueryWrapper<Segment>()
.eq(Segment::getAgvId, agvId)
.eq(Segment::getState, SegmentStateType.RUNNING.toString())
)) {
- log.warn("[{}]鍙稟gv姝e湪蹇欑 - segment......", agv.getUuid());
+ log.warn("[{}]鍙稟gv姝e湪蹇欑 - segment......", agvNo);
return false;
}
- if (!this.judgeOnline(agv.getId())) {
- log.warn("[{}]鍙稟gv涓嶆槸鍦ㄧ嚎鐘舵��......", agv.getUuid());
+ if (!this.judgeOnline(agvId)) {
+ log.warn("[{}]鍙稟gv涓嶆槸鍦ㄧ嚎鐘舵��......", agvNo);
return false;
}
- AgvDetail agvDetail = agvDetailService.selectMajorByAgvId(agv.getId());
+ AgvDetail agvDetail = agvDetailService.selectMajorByAgvId(agvId);
if (null == agvDetail) {
- log.warn("[{}]鍙稟gv鏈敹鍒扮姸鎬佸寘......", agv.getUuid());
+ log.warn("[{}]鍙稟gv鏈敹鍒扮姸鎬佸寘......", agvNo);
return false;
}
if (agvDetail.getVol() == 0) {
return false;
}
if (!agvDetail.getAgvStatus().equals(AgvStatusType.IDLE) && !agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) {
- log.warn("[{}]鍙稟gv涓嶆槸绌洪棽鐘舵��......", agv.getUuid());
+ log.warn("[{}]鍙稟gv涓嶆槸绌洪棽鐘舵��......", agvNo);
return false;
}
if (agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) {
@@ -132,18 +132,19 @@
}
if (!agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) {
if (agvDetail.getPos() != 1) {
- log.warn("[{}]鍙稟gv褰撳墠涓嶅湪瀹氫綅......", agv.getUuid());
+ log.warn("[{}]鍙稟gv褰撳墠涓嶅湪瀹氫綅......", agvNo);
return false;
}
if (null == agvDetail.getRecentCode()) {
- log.warn("[{}]鍙稟gv褰撳墠涓嶅湪瀹氫綅......", agv.getUuid());
+ log.warn("[{}]鍙稟gv褰撳墠涓嶅湪瀹氫綅......", agvNo);
return false;
}
}
// with battery
if (isLowBattery) {
+ Agv agv = this.getById(agvId);
if (agvDetailService.isPowerLoss(agv, agvDetail, agvModel)) {
- log.warn("[{}]鍙稟gv鐢甸噺涓嶈冻......", agv.getUuid());
+ log.warn("[{}]鍙稟gv鐢甸噺涓嶈冻......", agvNo);
return false;
}
}
@@ -181,7 +182,7 @@
// if (null != agv.getStage()) {
// return agv.getStage();
// }
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ AgvModel agvModel = agvModelService.getByAgvId(agv.getId());
assert null != agvModel;
return agvModel.getBackpack();
}
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
index e9307d8..1542f2f 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
@@ -74,7 +74,7 @@
if (funcSta.getType().equals(FuncStaType.CHARGE.toString())) {
// if the type of this funSta is charge and the existing agv is in charge status, then that means this funSta is occupied
if (null != agv && !agv.getId().equals(agvId)) {
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ AgvModel agvModel = agvModelService.getByAgvId(agv.getId());
AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
if (agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) {
if (agvDetail.getVol() < agvModel.getQuaBattery()) {
@@ -189,7 +189,7 @@
agv = agvService.findByPosition(funcSta.getCode());
if (null != agv) {
- AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
+ AgvModel agvModel = agvModelService.getByAgvId(agv.getId());
AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
if (agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) {
return false;
--
Gitblit v1.9.1