| | |
| | | import com.zy.acs.manager.manager.service.AgvService; |
| | | import com.zy.acs.manager.manager.service.SegmentService; |
| | | import com.zy.acs.manager.manager.service.TaskService; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | private SegmentService segmentService; |
| | | |
| | | private final AgvService agvService; |
| | | private final AgvDetailService agvDetailService; |
| | | private final TaskService taskService; |
| | | private final MainLockWrapService mainLockWrapService; |
| | | |
| | | public GuaranteeRuntimeService(AgvService agvService, |
| | | AgvDetailService agvDetailService, |
| | | TaskService taskService, |
| | | MainLockWrapService mainLockWrapService) { |
| | | this.agvService = agvService; |
| | | this.agvDetailService = agvDetailService; |
| | | this.taskService = taskService; |
| | | this.mainLockWrapService = mainLockWrapService; |
| | | } |
| | | @Autowired |
| | | private AgvService agvService; |
| | | @Autowired |
| | | private AgvDetailService agvDetailService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private MainLockWrapService mainLockWrapService; |
| | | |
| | | public void prepare(Guarantee plan, LocalDateTime targetTime) { |
| | | int requiredCount = plan.getRequiredCount() == null ? 0 : plan.getRequiredCount(); |
| | |
| | | // log.debug("Guarantee[{}] already has {} vehicles >= {}% SOC for {}", plan.getName(), available, minSoc, targetTime); |
| | | return; |
| | | } |
| | | int shortage = requiredCount - available; |
| | | int shortage = requiredCount - available; // 还差多少辆 |
| | | candidates.sort(Comparator.comparingInt(ChargeCandidate::getSoc)); |
| | | int scheduled = 0; |
| | | int scheduled = 0; // 已经安排充电的AGV数量 |
| | | for (ChargeCandidate candidate : candidates) { |
| | | if (scheduled >= shortage) { |
| | | break; |
| | |
| | | return agvService.list(wrapper); |
| | | } |
| | | |
| | | @Data |
| | | private static class ChargeCandidate { |
| | | private final Agv agv; |
| | | private final int soc; |
| | |
| | | this.soc = soc; |
| | | } |
| | | |
| | | public Agv getAgv() { |
| | | return agv; |
| | | } |
| | | |
| | | public int getSoc() { |
| | | return soc; |
| | | } |
| | | } |
| | | } |