| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.asrs.domain.enums.NotifyMsgType; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.mapper.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.NotifyUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.*; |
| | | import com.zy.common.model.enums.NavigationMapType; |
| | |
| | | private ShuttleAction shuttleAction; |
| | | @Autowired |
| | | private ForkLiftAction forkLiftAction; |
| | | @Autowired |
| | | private NotifyUtils notifyUtils; |
| | | |
| | | |
| | | // /** |
| | |
| | | //310.小车移动中 ==> 311.小车移动完成 |
| | | wrkMast.setWrkSts(WrkStsType.COMPLETE_MOVE.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_MOVE_COMPLETE);//触发通知 |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.CHARGE_SHUTTLE_WORKING.sts) { |
| | | //204.小车充电中 ==> 205.小车充电完成 |
| | | wrkMast.setWrkSts(WrkStsType.CHARGE_SHUTTLE_COMPLETE.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//触发通知 |
| | | }else { |
| | | continue; |
| | | } |
| | |
| | | // } |
| | | |
| | | /** |
| | | * 出库 ===>> 工作档信息写入led显示器 |
| | | */ |
| | | public void ledExecute() { |
| | | // try { |
| | | // for (LedSlave led : slaveProperties.getLed()) { |
| | | // // 获取输送线plc线程 |
| | | // DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | | // // 命令集合 |
| | | // List<LedCommand> commands = new ArrayList<>(); |
| | | // // 工作档集合 |
| | | // List<WrkMast> wrkMasts = new ArrayList<>(); |
| | | // List<WrkMastLog> wrkMastLogs = new ArrayList<>(); |
| | | // for (Integer staNo : led.getStaArr()) { |
| | | // // 获取叉车站点 |
| | | // StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | // if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { |
| | | // continue; |
| | | // } else { |
| | | // staProtocol = staProtocol.clone(); |
| | | // } |
| | | // // 获取工作档数据 |
| | | // WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); |
| | | // Integer wrkNo = staProtocol.getWorkNo().intValue(); |
| | | // Integer ioType = null; |
| | | // String sourceLocNo = null; |
| | | // String locNo = null; |
| | | // Integer wrkStaNo = null; |
| | | // String barcode = null; |
| | | // if (wrkMast == null) { |
| | | // //查询历史档 |
| | | // WrkMastLog wrkMastLog = wrkMastLogMapper.selectLatestByWorkNo(staProtocol.getWorkNo().intValue()); |
| | | // if (wrkMastLog == null) { |
| | | // continue; |
| | | // } |
| | | // ioType = wrkMastLog.getIoType(); |
| | | // sourceLocNo = wrkMastLog.getSourceLocNo(); |
| | | // locNo = wrkMastLog.getLocNo(); |
| | | // wrkStaNo = wrkMastLog.getStaNo(); |
| | | // barcode = wrkMastLog.getBarcode(); |
| | | // wrkMastLogs.add(wrkMastLog); |
| | | // }else { |
| | | // if (wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { |
| | | // continue; |
| | | // } |
| | | // ioType = wrkMast.getIoType(); |
| | | // sourceLocNo = wrkMast.getSourceLocNo(); |
| | | // locNo = wrkMast.getLocNo(); |
| | | // wrkStaNo = wrkMast.getStaNo(); |
| | | // barcode = wrkMast.getBarcode(); |
| | | // wrkMasts.add(wrkMast); |
| | | // } |
| | | // // 组装命令 |
| | | // LedCommand ledCommand = new LedCommand(); |
| | | // ledCommand.setWorkNo(wrkNo); |
| | | // ledCommand.setIoType(ioType); |
| | | // // 出库模式 |
| | | // switch (ioType) { |
| | | // case 101: |
| | | // ledCommand.setTitle("全板出库"); |
| | | // break; |
| | | // case 103: |
| | | // ledCommand.setTitle("拣料出库"); |
| | | // break; |
| | | // case 104: |
| | | // ledCommand.setTitle("并板出库"); |
| | | // break; |
| | | // case 107: |
| | | // ledCommand.setTitle("盘点出库"); |
| | | // break; |
| | | // case 110: |
| | | // ledCommand.setTitle("空板出库"); |
| | | // ledCommand.setEmptyMk(true); |
| | | // break; |
| | | // default: |
| | | // News.error("任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkNo, ioType); |
| | | // break; |
| | | // } |
| | | // ledCommand.setSourceLocNo(sourceLocNo); |
| | | // ledCommand.setLocNo(locNo); |
| | | // ledCommand.setStaNo(wrkStaNo); |
| | | // ledCommand.setBarcode(barcode); |
| | | // if (ioType != 110 && ioType != 10) { |
| | | // List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo)); |
| | | // if (!wrkDetls.isEmpty()) { |
| | | // wrkDetls.forEach(wrkDetl -> { |
| | | // double remainNum = wrkDetl.getStock() - wrkDetl.getAnfme();//剩余数量 |
| | | // if (remainNum < 0) { |
| | | // remainNum = 0; |
| | | // } |
| | | // String matnr = wrkDetl.getMatnr(); |
| | | // Mat mat = matService.selectByMatnr(wrkDetl.getMatnr()); |
| | | // if (mat != null) { |
| | | // if (!mat.getMatnr().equals(mat.getMatnr2())) { |
| | | // matnr += " - " + mat.getMatnr2(); |
| | | // } |
| | | // } |
| | | // ledCommand.getMatDtos().add(new MatDto(matnr, wrkDetl.getMaktx(), wrkDetl.getAnfme(), remainNum, wrkDetl.getSpecs(), wrkDetl.getSuppCode(), wrkDetl.getOrderNo())); |
| | | // }); |
| | | // }else { |
| | | // List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectLatestByWorkNo(wrkNo, barcode); |
| | | // for (WrkDetlLog wrkDetlLog : wrkDetlLogs) { |
| | | // double remainNum = wrkDetlLog.getStock() - wrkDetlLog.getAnfme();//剩余数量 |
| | | // if (remainNum < 0) { |
| | | // remainNum = 0; |
| | | // } |
| | | // String matnr = wrkDetlLog.getMatnr(); |
| | | // Mat mat = matService.selectByMatnr(wrkDetlLog.getMatnr()); |
| | | // if (mat != null) { |
| | | // if (!mat.getMatnr().equals(mat.getMatnr2())) { |
| | | // matnr += " - " + mat.getMatnr2(); |
| | | // } |
| | | // } |
| | | // ledCommand.getMatDtos().add(new MatDto(matnr, wrkDetlLog.getMaktx(), wrkDetlLog.getAnfme(), remainNum, wrkDetlLog.getSpecs(), wrkDetlLog.getSuppCode())); |
| | | // } |
| | | // } |
| | | // commands.add(ledCommand); |
| | | // } |
| | | // Set<Integer> workNos = null; |
| | | // if (!wrkMasts.isEmpty()) { |
| | | // workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); |
| | | // }else { |
| | | // workNos = wrkMastLogs.stream().map(WrkMastLog::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))) { |
| | | // log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // continue; |
| | | // } else { |
| | | // ledThread.setLedMk(false); |
| | | // } |
| | | // } |
| | | // |
| | | // 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(); |
| | | // } |
| | | // |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | | * 其他 ===>> LED显示器复位,显示默认信息 |
| | | */ |
| | | public void ledReset() { |
| | | // try { |
| | | // for (LedSlave led : slaveProperties.getLed()) { |
| | | // // 获取输送线plc线程 |
| | | // DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | | // // 命令集合 |
| | | // boolean reset = true; |
| | | // for (Integer staNo : led.getStaArr()) { |
| | | // // 获取叉车站点 |
| | | // StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | // if (staProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // if (staProtocol.isLoading()) { |
| | | // reset = false; |
| | | // break; |
| | | // } |
| | | // } |
| | | // // 获取led线程 |
| | | // LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // // led显示默认内容 |
| | | // if (reset) { |
| | | // ledThread.setLedMk(true); |
| | | // if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { |
| | | // log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // } |
| | | // } |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | | * 四向穿梭车电量检测 ===>> 发起充电 |
| | | */ |
| | | public synchronized void loopShuttleCharge() { |
| | |
| | | |
| | | //下发任务 |
| | | shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); |
| | | |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_POWER_START);//触发通知 |
| | | return false; |
| | | } |
| | | return true; |
| | |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | //下发任务 |
| | | shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); |
| | | //触发通知 |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_MOVING); |
| | | return false; |
| | | } |
| | | return false; |
| | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | // //扫描设备PakMk标记是否超时 |
| | | // public synchronized void scanDevicePakMk() { |
| | | // try { |
| | | // //扫描小车 |
| | | // for (ShuttleSlave slave : slaveProperties.getShuttle()) { |
| | | // NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); |
| | | // NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | // if (shuttleProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // if ((System.currentTimeMillis() - shuttleProtocol.getSendTime() > (1000 * 60 * 5)) && shuttleProtocol.getPakMk()) { |
| | | // //设备超过5分钟还没复位标记 |
| | | // shuttleProtocol.setPakMk(false);//复位标记 |
| | | // } |
| | | // } |
| | | // |
| | | // //扫描提升机 |
| | | // for (LiftSlave slave : slaveProperties.getLift()) { |
| | | // LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); |
| | | // LiftProtocol liftProtocol = liftThread.getLiftProtocol(); |
| | | // if (liftProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // if ((System.currentTimeMillis() - liftProtocol.getSendTime() > (1000 * 60 * 5)) && liftProtocol.getPakMk()) { |
| | | // //设备超过5分钟还没复位标记 |
| | | // liftProtocol.setPakMk(false);//复位标记 |
| | | // } |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | } |