#
luxiaotao1123
2022-10-26 e356cb699f91ff4359ef0e835fd311436489b9d8
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
@@ -898,7 +899,7 @@
                                }
                            }
                        }
                        // 没有小车
                    // 没有小车
                    } else {
                        if (wrkMast.getWrkSts() == 2L && wrkMast.getSteNo() == null) {
                            // 寻找当前堆垛机对应的小车
@@ -1290,17 +1291,32 @@
     * 查找当前库位最适合的穿梭车来作业
     */
    public SteThread queryIdleCar(WrkMast wrkMast) {
        Integer crnNo = wrkMast.getCrnNo();
        BasSte basSte = basSteService.findByCrnNo(crnNo);
        // 获取穿梭车信息
        SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, basSte.getSteNo());
        SteProtocol steProtocol = steThread.getSteProtocol();
        if (steProtocol != null) {
            if (steProtocol.isIdle()) {
                return steThread;
        List<BasSte> basStes = basSteService.selectList(new EntityWrapper<>());
        int val = 0;
        SteThread result = null;
        for (BasSte basSte : basStes) {
            // 获取穿梭车信息
            SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, basSte.getSteNo());
            SteProtocol steProtocol = steThread.getSteProtocol();
            if (steProtocol == null) { continue; }
            if (!steProtocol.isIdle()) { continue; }
            String locNo = wrkMast.getWrkSts() < 10 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo();
            LocMast locMast = locMastService.selectById(locNo);
            int lev = locMast.getLev1();
            int bay = locMast.getBay1();
            int levAbs = Math.abs(lev - steProtocol.getLev());
            int bayAbs = Math.abs(bay - steProtocol.getBay());
            if (val == 0) {
                val = levAbs + bayAbs;
                result = steThread;
            } else {
                if ((levAbs + bayAbs) < val) {
                    val = levAbs + bayAbs;
                    result = steThread;
                }
            }
        }
        return null;
        return result;
    }
    /**