#
vincentlu
3 小时以前 d58a5160d46bd0f83fdd73e9e49061b33e1d241b
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
@@ -5,11 +5,9 @@
import com.zy.acs.common.enums.AgvStatusType;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.manager.common.utils.CommonUtil;
import com.zy.acs.manager.core.service.AgvAreaDispatcher;
import com.zy.acs.manager.manager.entity.*;
import com.zy.acs.manager.manager.enums.FuncStaType;
import com.zy.acs.manager.manager.enums.StatusType;
import com.zy.acs.manager.manager.enums.TaskStsType;
import com.zy.acs.manager.manager.enums.TaskTypeType;
import com.zy.acs.manager.manager.enums.*;
import com.zy.acs.manager.manager.mapper.FuncStaMapper;
import com.zy.acs.manager.manager.service.*;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,6 +29,8 @@
    private AgvModelService agvModelService;
    @Autowired
    private TaskService taskService;
    @Autowired
    private AgvAreaDispatcher agvAreaDispatcher;
    @Override
    public FuncSta getByCodeAndType(Long codeId, String type) {
@@ -53,14 +53,31 @@
    @Override
    public List<FuncSta> findInIdleStatus(FuncStaType type, Long agvId) {
        LambdaQueryWrapper<FuncSta> wrapper = new LambdaQueryWrapper<FuncSta>()
                .eq(FuncSta::getType, type).eq(FuncSta::getStatus, StatusType.ENABLE.val);
                .eq(FuncSta::getType, type).eq(FuncSta::getStatus, StatusType.ENABLE.val).eq(FuncSta::getState, FuncStaStateType.IDLE.toString());
        List<FuncSta> funcStaList = this.list(wrapper);
        if (Cools.isEmpty(funcStaList)) {
            return new ArrayList<>();
        }
        Collections.shuffle(funcStaList);
        // area limit
        if (agvAreaDispatcher.isAgvExistsInAnyArea(agvId)) {
            List<String> areaCodeList = agvAreaDispatcher.getCodesByAgvId(agvId);
            if (Cools.isEmpty(areaCodeList)) {
                funcStaList.clear();
            } else {
                funcStaList.removeIf(funcSta -> {
                    Code code = codeService.getCacheById(funcSta.getCode());
                    if (Cools.isEmpty(code, code.getData())) { return true; }
                    return !areaCodeList.contains(code.getData());
                });
            }
        }
        if (!Cools.isEmpty(funcStaList)) {
            Collections.shuffle(funcStaList);
        }
        // filter idle
        funcStaList = funcStaList.stream().filter(funcSta -> {
@@ -77,7 +94,7 @@
                    AgvModel agvModel = agvModelService.getByAgvId(agv.getId());
                    AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
                    if (agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) {
                        if (agvDetail.getVol() < agvModel.getQuaBattery()) {
                        if (agvDetail.getSoc() < agvModel.getQuaBattery()) {
                            return false;
                        }
                    } else {