#
vincentlu
10 小时以前 d58a5160d46bd0f83fdd73e9e49061b33e1d241b
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java
@@ -5,7 +5,7 @@
import com.zy.acs.manager.common.utils.CommonUtil;
import com.zy.acs.manager.core.domain.AgvCntDto;
import com.zy.acs.manager.core.domain.FilterLaneDto;
import com.zy.acs.manager.core.domain.Lane;
import com.zy.acs.manager.core.domain.LaneDto;
import com.zy.acs.manager.core.domain.TaskPosDto;
import com.zy.acs.manager.manager.entity.*;
import com.zy.acs.manager.manager.enums.*;
@@ -135,11 +135,11 @@
        }
        // record lane hash for later dispatch/traffic-control logic
        if (filterLaneDto.getOriginLane() != null) {
            task.setOriLaneHash(filterLaneDto.getOriginLane().getHashCode());
        if (filterLaneDto.getOriginLaneDto() != null) {
            task.setOriLaneHash(filterLaneDto.getOriginLaneDto().getHashCode());
        }
        if (filterLaneDto.getDestinationLane() != null) {
            task.setDestLaneHash(filterLaneDto.getDestinationLane().getHashCode());
        if (filterLaneDto.getDestinationLaneDto() != null) {
            task.setDestLaneHash(filterLaneDto.getDestinationLaneDto().getHashCode());
        }
        return agvNo;
@@ -167,8 +167,8 @@
        if (null == filterLaneDto) {
            return null;
        }
        Lane originLane = filterLaneDto.getOriginLane();
        Lane destinationLane = filterLaneDto.getDestinationLane();
        LaneDto originLaneDto = filterLaneDto.getOriginLaneDto();
        LaneDto destinationLaneDto = filterLaneDto.getDestinationLaneDto();
        List<String> actualAvailableAgvNos = filterLaneDto.getActualAvailableAgvNos();
        if (Cools.isEmpty(actualAvailableAgvNos)) {
            return null;
@@ -180,11 +180,11 @@
                calcAllocateWeight(o1, task)
        ));
        if (null != originLane) {
            task.setOriLaneHash(originLane.getHashCode());
        if (null != originLaneDto) {
            task.setOriLaneHash(originLaneDto.getHashCode());
        }
        if (null != destinationLane) {
            task.setDestLaneHash(destinationLane.getHashCode());
        if (null != destinationLaneDto) {
            task.setDestLaneHash(destinationLaneDto.getHashCode());
        }
        return actualAvailableAgvNos.get(0);
@@ -291,13 +291,13 @@
        Integer maxAgvCountInLane = configService.getVal("maxAgvCountInLane", Integer.class);
        // checkout lane
        Lane originLane = taskService.checkoutOriginLane(task);
        Lane destinationLane = taskService.checkoutDestinationLane(task);
        LaneDto originLaneDto = taskService.checkoutOriginLane(task);
        LaneDto destinationLaneDto = taskService.checkoutDestinationLane(task);
        // allocate about origin
        List<String> availableAgvNosByOriLane = new ArrayList<>(availableAgvNos);
        if (null != originLane) {
            List<String> agvNosByOriLane = findAgvNosByLane(originLane);    // the agv list that had tasks in this lane
        if (null != originLaneDto) {
            List<String> agvNosByOriLane = findAgvNosByLane(originLaneDto);    // the agv list that had tasks in this lane
            // if full lane
            if (agvNosByOriLane.size() >= maxAgvCountInLane) {
@@ -310,8 +310,8 @@
        // allocate about destination
        List<String> availableAgvNosByDestLane = new ArrayList<>(availableAgvNos);
        if (null != destinationLane) {
            List<String> agvNosByDestLane = findAgvNosByLane(destinationLane);
        if (null != destinationLaneDto) {
            List<String> agvNosByDestLane = findAgvNosByLane(destinationLaneDto);
            if (agvNosByDestLane.size() >= maxAgvCountInLane) {
                availableAgvNosByDestLane = Cools.getIntersection(agvNosByDestLane, availableAgvNos);
@@ -334,14 +334,14 @@
            return null;
        }
        return new FilterLaneDto(originLane, destinationLane, actualAvailableAgvNos);
        return new FilterLaneDto(originLaneDto, destinationLaneDto, actualAvailableAgvNos);
    }
    public List<String> findAgvNosByLane(Lane lane) {
        if (null == lane) {
    public List<String> findAgvNosByLane(LaneDto laneDto) {
        if (null == laneDto) {
            return new ArrayList<>();
        }
        List<Task> taskList = taskService.findRunningTasksByLaneHash(lane.getHashCode());
        List<Task> taskList = taskService.findRunningTasksByLaneHash(laneDto.getHashCode());
        if (Cools.isEmpty(taskList)) {
            return new ArrayList<>();
        }
@@ -412,11 +412,11 @@
    }
    public Boolean validCapacityOfLane(String agvNo, Code code) {
        Lane lane = laneBuilder.search(code.getData());
        if (null != lane) {
        LaneDto laneDto = laneBuilder.search(code.getData());
        if (null != laneDto) {
            Integer maxAgvCountInLane = configService.getVal("maxAgvCountInLane", Integer.class);
            List<String> agvNosByLane = this.findAgvNosByLane(lane);
            List<String> agvNosByLane = this.findAgvNosByLane(laneDto);
            agvNosByLane.remove(agvNo);
            if (agvNosByLane.size() >= maxAgvCountInLane) {
                return false;