| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.zy.acs.common.utils.News; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | |
| | | public void prepare(Guarantee plan, LocalDateTime targetTime) { |
| | | int requiredCount = plan.getRequiredCount() == null ? 0 : plan.getRequiredCount(); |
| | | if (requiredCount <= 0) { |
| | | log.warn("Guarantee[{}] requiredCount is not configured, skip", plan.getName()); |
| | | News.warn("Guarantee[{}] requiredCount is not configured, skip", plan.getName()); |
| | | return; |
| | | } |
| | | int minSoc = plan.getMinSoc(); |
| | |
| | | } |
| | | } |
| | | if (available >= requiredCount) { |
| | | // log.debug("Guarantee[{}] already has {} vehicles >= {}% SOC for {}", plan.getName(), available, minSoc, targetTime); |
| | | return; |
| | | } |
| | | int shortage = requiredCount - available; // 还差多少辆 |
| | |
| | | if (scheduled >= shortage) { |
| | | break; |
| | | } |
| | | log.info("Guarantee[{}] schedule AGV {} charging (soc={}%) for target {}", |
| | | News.info("Guarantee[{}] schedule AGV {} charging (soc={}%) for target {}", |
| | | plan.getName(), candidate.getAgv().getName(), candidate.getSoc(), targetTime); |
| | | mainLockWrapService.buildMinorTask(candidate.getAgv().getId(), TaskTypeType.TO_CHARGE, null, null); |
| | | scheduled++; |
| | | } |
| | | if (scheduled < shortage) { |
| | | log.warn("Guarantee[{}] still short of {} vehicles for {} (only {} idle low-soc AGVs)", |
| | | News.warn("Guarantee[{}] still short of {} vehicles for {} (only {} idle low-soc AGVs)", |
| | | plan.getName(), shortage - scheduled, targetTime, candidates.size()); |
| | | } |
| | | } |
| | |
| | | try { |
| | | wrapper.eq(Agv::getAgvModel, Long.valueOf(plan.getScopeValue())); |
| | | } catch (NumberFormatException ignore) { |
| | | log.warn("Guarantee[{}] invalid scopeValue {}", plan.getName(), plan.getScopeValue()); |
| | | News.warn("Guarantee[{}] invalid scopeValue {}", plan.getName(), plan.getScopeValue()); |
| | | } |
| | | } |
| | | return agvService.list(wrapper); |