| | |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.CrnSlave; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.LedSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.*; |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.model.command.LedCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import com.zy.core.model.protocol.SteProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.BarcodeThread; |
| | | import com.zy.core.thread.LedThread; |
| | | import com.zy.core.thread.SteThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | private BasErrLogService basErrLogService; |
| | | @Autowired |
| | | private BasCrnErrorMapper basCrnErrorMapper; |
| | | @Autowired |
| | | private BasSteService basSteService; |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | |
| | |
| | | if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { |
| | | continue; |
| | | } |
| | | // todo:小车迁入出 |
| | | // 最外层库位 |
| | | if (locMastService.isOutMost(wrkMast.getLocNo())) { |
| | | // 判断小车是否在最外层库位,如果是则搬走,如果不是,则直接堆垛机入库 |
| | | Integer steNo = this.hasCarOfIdle(wrkMast.getLocNo()); |
| | | if (steNo != null) { |
| | | // 小车搬走 |
| | | |
| | | |
| | | |
| | | } else { |
| | | // 堆垛机入库 |
| | | } |
| | | |
| | | // 非最外层库位 |
| | | } else { |
| | | // 判断小车是否在当前组库位,如果是则堆垛机将货物放置小车上,如果不是,则直接堆垛机搬移小车至当前组的最外层库位 |
| | | |
| | | } |
| | | |
| | | |
| | | this.carMoveIn(wrkMast); |
| | | |
| | | |
| | | // 已经存在吊车执行任务时,则过滤 |
| | | if (wrkMastMapper.selectWorking(slave.getId()) != null) { |
| | |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | |
| | | // long startTime = System.currentTimeMillis(); |
| | | // while ((System.currentTimeMillis() - startTime) < COMMAND_TIMEOUT) { |
| | | // |
| | | // if (true) { |
| | | // break; |
| | | // } |
| | | // |
| | | // try{ |
| | | // Thread.sleep(500); |
| | | // }catch(Exception ignore){} |
| | | // } |
| | | |
| | | // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(3L); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 当前库位组是否存在空闲小车 |
| | | * @param locNo |
| | | * @return |
| | | */ |
| | | public Integer hasCarOfIdle(String locNo) { |
| | | for (SteSlave ste : slaveProperties.getSte()) { |
| | | // 获取堆垛机信息 |
| | | SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId()); |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | if (steProtocol == null) { continue; } |
| | | if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) { |
| | | if (steProtocol.getRow() == Utils.getRow(locNo) && steProtocol.getBay() == Utils.getBay(locNo) && steProtocol.getLev() == Utils.getLev(locNo)) { |
| | | return steProtocol.getSteNo().intValue(); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 入库 ===>> 堆垛机搬入小车 |
| | | */ |
| | | public void carMoveIn(WrkMast wrkMast) { |
| | | for (SteSlave ste : slaveProperties.getSte()) { |
| | | // 获取堆垛机信息 |
| | | SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId()); |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | if (steProtocol == null) { continue; } |
| | | if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) { |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 入库 ===>> 堆垛机搬出小车 |
| | | */ |
| | | public void carMoveOut(WrkMast wrkMast) { |
| | | for (SteSlave ste : slaveProperties.getSte()) { |
| | | // 获取堆垛机信息 |
| | | SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId()); |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | if (steProtocol == null) { continue; } |
| | | if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) { |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 出库 ===>> 库位到堆垛机站 |
| | | */ |
| | | public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){ |