| | |
| | | package com.zy.core.dispatcher; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.ShuttleGatherResult; |
| | | import com.zy.asrs.domain.param.ShuttleGatherParam; |
| | | import com.zy.asrs.entity.BasShuttle; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | |
| | | /** |
| | | * 调度车辆-调度指定穿梭车 |
| | | */ |
| | | public boolean dispatchShuttle(Integer wrkNo, String locNo, Integer shuttleNo) { |
| | | public synchronized boolean dispatchShuttle(Integer wrkNo, String locNo, Integer shuttleNo) { |
| | | return shuttleMoveGenerate(wrkNo, locNo, shuttleNo); |
| | | } |
| | | |
| | | /** |
| | | * 调度车辆 |
| | | */ |
| | | public boolean dispatchShuttle(Integer wrkNo, String locNo) { |
| | | public synchronized boolean dispatchShuttle(Integer wrkNo, String locNo) { |
| | | ArrayList<ShuttleThread> sameLev = new ArrayList<>();//相同楼层的穿梭车 |
| | | ArrayList<ShuttleThread> diffLev = new ArrayList<>();//不同楼层的穿梭车 |
| | | |
| | |
| | | //当前穿梭车库位号 |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | int currentLev = Utils.getLev(currentLocNo); |
| | | List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//判断当前穿梭车楼层是否有待分配车辆的任务,如果有则不分配这辆车 |
| | | //判断当前楼层是否有任务,如果有则不分配这辆车 |
| | | List<WrkMast> wrkMasts1 = wrkMastService.selectWrkByLev(currentLev); |
| | | int shuttleCount = this.getShuttleCountByLev(currentLev);//获取穿梭车楼层车辆数量 |
| | | if (!wrkMasts1.isEmpty() && shuttleCount <= 1) { |
| | | //存在其他任务且可用小车数量小于等于1,跳过这辆车 |
| | |
| | | * 小车迁移任务生成 |
| | | */ |
| | | @Transactional |
| | | public boolean shuttleMoveGenerate(Integer wrkNo, String locNo, Integer shuttleNo) { |
| | | public synchronized boolean shuttleMoveGenerate(Integer wrkNo, String locNo, Integer shuttleNo) { |
| | | Date now = new Date(); |
| | | //获取四向穿梭车线程 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); |
| | |
| | | News.info("{}号小车,存在其他工作档任务,等待执行完成再生成新的任务", shuttleNo); |
| | | return false; |
| | | }else { |
| | | if (!mainWrkMast.getShuttleNo().equals(shuttleNo)) { |
| | | if (!shuttleNo.equals(mainWrkMast.getShuttleNo())) { |
| | | News.info("{}号小车,存在其他工作档任务,等待执行完成再生成新的任务", shuttleNo); |
| | | return false; |
| | | } |
| | |
| | | /** |
| | | * 小车集合 |
| | | */ |
| | | public List<ShuttleGatherResult> shuttleGather() { |
| | | List<BasShuttle> basShuttles = basShuttleService.selectList(new EntityWrapper<BasShuttle>().eq("status", 1)); |
| | | public List<ShuttleGatherResult> shuttleGather(ShuttleGatherParam param) { |
| | | Wrapper<BasShuttle> wrapper = new EntityWrapper<BasShuttle>().eq("status", 1); |
| | | if (param != null) { |
| | | if (!param.getShuttleNos().isEmpty()) { |
| | | wrapper.in("shuttle_no", param.getShuttleNos()); |
| | | } |
| | | } |
| | | |
| | | List<BasShuttle> basShuttles = basShuttleService.selectList(wrapper); |
| | | List<ShuttleGatherResult> list = new ArrayList<>(); |
| | | for (BasShuttle basShuttle : basShuttles) { |
| | | String idleLoc = basShuttle.getIdleLoc(); |