充电自动移动到等待点
This commit is contained in:
parent
432eeba127
commit
4beceefef7
@ -129,11 +129,12 @@ public class AutoChargeServiceImpl implements AutoChargeService {
|
|||||||
log.info("没有充电中的车辆");
|
log.info("没有充电中的车辆");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chargeIngRobots = getCanLeaveChargingRobots(chargeIngRobots, chargeConfig, robots.size());
|
List<RobotInformationDO> moveToWaitRobots = getCanLeaveChargingRobots(chargeIngRobots, chargeConfig, robots.size());
|
||||||
if (ObjectUtil.isEmpty(chargeIngRobots)) {
|
if (ObjectUtil.isEmpty(moveToWaitRobots)) {
|
||||||
log.info("充电中的车辆未充满电");
|
log.info("充电中的车辆未充满电");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
robotPathPlanningService.moveRobotToWait(moveToWaitRobots);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,6 +193,7 @@ public class AutoChargeServiceImpl implements AutoChargeService {
|
|||||||
private List<RobotInformationDO> getCanLeaveChargingRobots(List<RobotInformationDO> robots, CommonConfigVO chargeConfig, int sum) {
|
private List<RobotInformationDO> getCanLeaveChargingRobots(List<RobotInformationDO> robots, CommonConfigVO chargeConfig, int sum) {
|
||||||
List<RobotInformationDO> needChargeRobots = new ArrayList<>();
|
List<RobotInformationDO> needChargeRobots = new ArrayList<>();
|
||||||
Map<String, Integer> map = new HashMap<>();
|
Map<String, Integer> map = new HashMap<>();
|
||||||
|
Map<String, RobotInformationDO> robotMap = new HashMap<>();
|
||||||
for (RobotInformationDO robot : robots) {
|
for (RobotInformationDO robot : robots) {
|
||||||
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS + robot.getMacAddress();
|
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS + robot.getMacAddress();
|
||||||
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robot.getMacAddress();
|
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robot.getMacAddress();
|
||||||
@ -215,6 +217,7 @@ public class AutoChargeServiceImpl implements AutoChargeService {
|
|||||||
Object o = redisUtil.get(socKey);
|
Object o = redisUtil.get(socKey);
|
||||||
Integer soc = ObjectUtil.isEmpty(o) ? 0 : Integer.parseInt(o.toString());
|
Integer soc = ObjectUtil.isEmpty(o) ? 0 : Integer.parseInt(o.toString());
|
||||||
map.put(robot.getRobotNo(), soc);
|
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()))
|
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
|
||||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (x1, x2) -> x2, LinkedHashMap::new));
|
.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;
|
return needChargeRobots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,4 +17,6 @@ public interface RobotPathPlanningService {
|
|||||||
List<RobotInformationDO> robots);
|
List<RobotInformationDO> robots);
|
||||||
|
|
||||||
List<TaskRobotNoLimittationAreaDTO> getRobotNoLimitationArea(List<RobotInformationDO> robots);
|
List<TaskRobotNoLimittationAreaDTO> getRobotNoLimitationArea(List<RobotInformationDO> robots);
|
||||||
|
|
||||||
|
void moveRobotToWait(List<RobotInformationDO> robots);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,8 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
|||||||
*
|
*
|
||||||
* @param robots
|
* @param robots
|
||||||
*/
|
*/
|
||||||
private void moveRobotToWait(List<RobotInformationDO> robots) {
|
@Override
|
||||||
|
public void moveRobotToWait(List<RobotInformationDO> robots) {
|
||||||
|
|
||||||
List<RobotTaskDetailDO> detailDOS = robotTaskDetailMapper.selectAutoCreateCycleTask();
|
List<RobotTaskDetailDO> detailDOS = robotTaskDetailMapper.selectAutoCreateCycleTask();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user