充电自动移动到等待点

This commit is contained in:
cbs 2025-06-03 15:42:30 +08:00
parent 432eeba127
commit 4beceefef7
3 changed files with 17 additions and 6 deletions

View File

@ -129,11 +129,12 @@ public class AutoChargeServiceImpl implements AutoChargeService {
log.info("没有充电中的车辆");
return;
}
chargeIngRobots = getCanLeaveChargingRobots(chargeIngRobots, chargeConfig, robots.size());
if (ObjectUtil.isEmpty(chargeIngRobots)) {
List<RobotInformationDO> moveToWaitRobots = getCanLeaveChargingRobots(chargeIngRobots, chargeConfig, robots.size());
if (ObjectUtil.isEmpty(moveToWaitRobots)) {
log.info("充电中的车辆未充满电");
return;
}
robotPathPlanningService.moveRobotToWait(moveToWaitRobots);
return;
}
@ -192,6 +193,7 @@ public class AutoChargeServiceImpl implements AutoChargeService {
private List<RobotInformationDO> getCanLeaveChargingRobots(List<RobotInformationDO> robots, CommonConfigVO chargeConfig, int sum) {
List<RobotInformationDO> needChargeRobots = new ArrayList<>();
Map<String, Integer> map = new HashMap<>();
Map<String, RobotInformationDO> robotMap = new HashMap<>();
for (RobotInformationDO robot : robots) {
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS + robot.getMacAddress();
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robot.getMacAddress();
@ -215,6 +217,7 @@ public class AutoChargeServiceImpl implements AutoChargeService {
Object o = redisUtil.get(socKey);
Integer soc = ObjectUtil.isEmpty(o) ? 0 : Integer.parseInt(o.toString());
map.put(robot.getRobotNo(), soc);
robotMap.put(robot.getRobotNo(),robot);
}
}
@ -226,9 +229,14 @@ public class AutoChargeServiceImpl implements AutoChargeService {
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (x1, x2) -> x2, LinkedHashMap::new));
log.info("排序后的集合 :{}",JSON.toJSONString(map));
for (Map.Entry<String, Integer> item : map.entrySet()) {
if (needChargeRobots.size() > sum) {
break;
}
needChargeRobots.add(robotMap.get(item.getKey()));
}
log.info("充电达到阀值,可以移动到等待点的车辆 :{}",JSON.toJSONString(needChargeRobots));
return needChargeRobots;
}

View File

@ -17,4 +17,6 @@ public interface RobotPathPlanningService {
List<RobotInformationDO> robots);
List<TaskRobotNoLimittationAreaDTO> getRobotNoLimitationArea(List<RobotInformationDO> robots);
void moveRobotToWait(List<RobotInformationDO> robots);
}

View File

@ -181,7 +181,8 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
*
* @param robots
*/
private void moveRobotToWait(List<RobotInformationDO> robots) {
@Override
public void moveRobotToWait(List<RobotInformationDO> robots) {
List<RobotTaskDetailDO> detailDOS = robotTaskDetailMapper.selectAutoCreateCycleTask();