| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.dto.LedDTO; |
| | | import com.zy.asrs.domain.param.ForwardAGVTaskParam; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.mapper.*; |
| | |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private BasStationService basStationService; |
| | | @Autowired |
| | | private BasStationDetlService basStationDetlService; |
| | | |
| | | @Resource |
| | | private ApiLogService apiLogService; |
| | |
| | | ) { |
| | | News.warnNoLog(""+mark+" - 0"+" - 开始执行:空栈板初始化入库,叉车入库站放货"); |
| | | |
| | | String barcode = staProtocol.getBarcode(); |
| | | |
| | | try { |
| | | LocTypeDto locTypeDto = new LocTypeDto(staProtocol); |
| | | |
| | |
| | | param.setIoType(10); |
| | | param.setSourceStaNo(emptyInSta.getStaNo()); |
| | | param.setLocType1((short) 0); |
| | | param.setBarcode(barcode); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/pakin/loc/v1") |
| | |
| | | for (LedSlave led : slaveProperties.getLed()) { |
| | | // 获取输送线plc线程 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | | LedDTO ledDTO = new LedDTO(); |
| | | if (!led.getStaArr().isEmpty()) { |
| | | ledDTO = getstaCommands(led.getStaArr(), devpThread); |
| | | }else { |
| | | ledDTO = getAgvStaCommands(led.getAgvStaArr()); |
| | | } |
| | | // 命令集合 |
| | | List<LedCommand> commands = ledDTO.getCommands(); |
| | | // 工作档集合 |
| | | List<WrkMast> wrkMasts = ledDTO.getWrkMasts(); |
| | | Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); |
| | | // 获取LED线程 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // 相同工作号集合则过滤 |
| | | // if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { |
| | | // continue; |
| | | // } |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | if (!commands.isEmpty()) { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { |
| | | News.error("{}号LED显示内容命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | try { |
| | | // 修改主档led标记 |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | wrkMast.setOveMk("Y"); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | } |
| | | |
| | | // 更新线程当前工作号集合 |
| | | ledThread.setWorkNos(workNos); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | public LedDTO getstaCommands(List<Integer> staArr, DevpThread devpThread ) { |
| | | LedDTO ledDTO = new LedDTO(); |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | // 工作档集合 |
| | | List<WrkMast> wrkMasts = new ArrayList<>(); |
| | | for (Integer staNo : led.getStaArr()) { |
| | | for (Integer staNo : staArr) { |
| | | // 获取叉车站点 |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || staProtocol.workType == DevpWorkType.IDLE) { |
| | |
| | | } |
| | | commands.add(ledCommand); |
| | | } |
| | | Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); |
| | | // 获取LED线程 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // 相同工作号集合则过滤 |
| | | if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { |
| | | continue; |
| | | } |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | if (!commands.isEmpty()) { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { |
| | | News.error("{}号LED显示内容命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | } |
| | | ledDTO.setCommands(commands); |
| | | ledDTO.setWrkMasts(wrkMasts); |
| | | return ledDTO; |
| | | } |
| | | |
| | | try { |
| | | // 修改主档led标记 |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | wrkMast.setOveMk("Y"); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | } |
| | | public LedDTO getAgvStaCommands(List<String> agvStaArr ) { |
| | | LedDTO ledDTO = new LedDTO(); |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | // 工作档集合 |
| | | List<BasStation> basStations = new ArrayList<>(); |
| | | for (String staNo : agvStaArr) { |
| | | // 获取工作档数据 |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", staNo)); |
| | | if (null == station || !station.getLocSts().equals("F")) { continue; } |
| | | basStations.add(station); |
| | | // 组装命令 |
| | | LedCommand ledCommand = new LedCommand(); |
| | | ledCommand.setTitle("在站信息"); |
| | | ledCommand.setSourceLocNo(station.getDevNo()); |
| | | ledCommand.setBarcode(station.getBarcode()); |
| | | |
| | | // 更新线程当前工作号集合 |
| | | ledThread.setWorkNos(workNos); |
| | | List<BasStationDetl> basStationDetls = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>().eq("dev_no", station.getDevNo())); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | basStationDetls.forEach(basStationDetl -> { |
| | | Double total = 0.0; |
| | | total = basStationDetl.getAnfme(); |
| | | |
| | | ledCommand.getMatDtos().add(new MatDto(basStationDetl.getMatnr(), basStationDetl.getMaktx(), basStationDetl.getBatch(), basStationDetl.getSpecs(), basStationDetl.getManu(), basStationDetl.getMemo(), basStationDetl.getAnfme(),total,basStationDetl.getStandby1(),null)); |
| | | |
| | | |
| | | |
| | | |
| | | }); |
| | | |
| | | commands.add(ledCommand); |
| | | } |
| | | ledDTO.setCommands(commands); |
| | | return ledDTO; |
| | | } |
| | | |
| | | /** |
| | |
| | | for (LedSlave led : slaveProperties.getLed()) { |
| | | // 获取输送线plc线程 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | | if (!led.getStaArr().isEmpty()){ |
| | | // 命令集合 |
| | | boolean reset = true; |
| | | for (Integer staNo : led.getStaArr()) { |
| | |
| | | News.error("{}号LED显示默认命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | } |
| | | } |
| | | }else { |
| | | // 命令集合 |
| | | boolean reset = false; |
| | | for (String staNo : led.getAgvStaArr()) { |
| | | // 获取叉车站点 |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", staNo)); |
| | | if (null == station) { continue; } |
| | | if (station.getLocSts().equals("O")) { |
| | | reset = true; |
| | | break; |
| | | } |
| | | } |
| | | // 获取led线程 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // led显示默认内容 |
| | | if (reset) { |
| | | if (ledThread == null) { |
| | | continue; |
| | | } |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { |
| | | News.error("{}号LED显示默认命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |