| | |
| | | @Autowired |
| | | private BasErrLogService basErrLogService; |
| | | @Autowired |
| | | private BasSteErrLogService basSteErrLogService; |
| | | @Autowired |
| | | private BasCrnErrorMapper basCrnErrorMapper; |
| | | @Autowired |
| | | private BasSteService basSteService; |
| | | @Autowired |
| | | private WrkChargeService wrkChargeService; |
| | | @Autowired |
| | | private BasSteErrService basSteErrService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | |
| | | |
| | | try { |
| | | // 保存工作明细档历史档 |
| | | if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作明细档历史档失败"); |
| | | } |
| | | // if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | // throw new CoolException("保存工作明细档历史档失败"); |
| | | // } |
| | | // 保存工作主档历史档 |
| | | if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | |
| | | continue; |
| | | } |
| | | |
| | | // 过滤 |
| | | if (null != wrkMastMapper.selectPakout(slave.getId(), null)) { |
| | | log.error("{}入库任务无法作业,因存在出库中任务!", wrkMast.getWrkNo()); |
| | | continue; |
| | | } |
| | | |
| | | // 置顶任务 |
| | | wrkMast.setIoPri((double) 9999); |
| | | wrkMastMapper.updateById(wrkMast); |
| | |
| | | // 目标库位 ===>> 最外层库位 |
| | | if (locMastService.isOutMost(wrkMast.getLocNo())) { |
| | | // 判断小车是否在最外层库位,如果是则搬走,如果不是,则直接堆垛机入库 |
| | | Integer steNo = this.hasCarOfIdle(wrkMast.getLocNo()); |
| | | Integer steNo = this.hasCar(wrkMast.getLocNo()); |
| | | // 有小车 |
| | | if (steNo != null) { |
| | | // 小车行走到堆垛机待搬移点 |
| | | if (wrkMast.getWrkSts() == 2L && wrkMast.getSteNo() == null) { |
| | | // if (null != wrkMastMapper.selectPakin(slave.getId(), steNo)) { |
| | | // continue; |
| | | // } |
| | | this.letCarBeReady(wrkMast, steNo, wrkMast.getLocNo()); |
| | | } |
| | | // 小车搬走 |
| | |
| | | |
| | | // 堆垛机控制过滤 |
| | | if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { |
| | | continue; |
| | | } |
| | | |
| | | // 过滤 |
| | | if (null != wrkMastMapper.selectPakin(slave.getId(), null)) { |
| | | log.error("{}出库任务无法作业,因存在入库中任务!", wrkMast.getWrkNo()); |
| | | continue; |
| | | } |
| | | |
| | |
| | | if (locMastService.isOutMost(wrkMast.getSourceLocNo())) { |
| | | // 目标库位 ===>> 最外层库位 |
| | | if (locMastService.isOutMost(wrkMast.getLocNo())) { |
| | | // todo:luxiaotao 判断目标库位是否存在小车,如果存在,则搬走小车 |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 当前库位组是否存在空闲小车 |
| | | */ |
| | | public Integer hasCar(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 (Utils.getGroupRow(locNo).equals(Utils.getGroupRow(steProtocol.getRow().intValue())) && steProtocol.getBay() == Utils.getBay(locNo) && steProtocol.getLev() == Utils.getLev(locNo)) { |
| | | return steProtocol.getSteNo().intValue(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | continue; |
| | | } |
| | | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); |
| | | String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName(); |
| | | String errName = crnError==null? "未知异常":crnError.getErrName(); |
| | | BasErrLog basErrLog = new BasErrLog( |
| | | null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | |
| | | // 记录新异常 |
| | | if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) { |
| | | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); |
| | | String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName(); |
| | | String errName = crnError==null? "未知异常":crnError.getErrName(); |
| | | BasErrLog basErrLog = new BasErrLog( |
| | | null, // 编号 |
| | | null, // 工作号 |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 穿梭车异常信息记录 |
| | | */ |
| | | @Async |
| | | public void recSteErr(){ |
| | | Date now = new Date(); |
| | | for (SteSlave ste : slaveProperties.getSte()) { |
| | | // 获取堆垛机信息 |
| | | SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId()); |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | if (steProtocol == null) { |
| | | continue; |
| | | } |
| | | // 有任务 |
| | | if (steProtocol.getTaskNo() != 0) { |
| | | BasSteErrLog latest = basSteErrLogService.findLatestByTaskNo(ste.getId(), steProtocol.getTaskNo().intValue()); |
| | | // 有异常 |
| | | if (latest == null) { |
| | | if (steProtocol.getAlarm() != null && steProtocol.isAlarm()) { |
| | | WrkMast wrkMast = wrkMastMapper.selectById(steProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | continue; |
| | | } |
| | | BasSteErr steErr = basSteErrService.selectById(steProtocol.getAlarm()); |
| | | String errName = steErr==null? "未知异常":steErr.getErrName(); |
| | | BasSteErrLog basSteErrLog = new BasSteErrLog( |
| | | null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | | wrkMast.getWrkSts(), // 工作状态 |
| | | wrkMast.getIoType(), // 入出库类型 |
| | | ste.getId(), // 堆垛机 |
| | | null, // plc |
| | | wrkMast.getLocNo(), // 目标库位 |
| | | wrkMast.getStaNo(), // 目标站 |
| | | wrkMast.getSourceStaNo(), // 源站 |
| | | wrkMast.getSourceLocNo(), // 源库位 |
| | | wrkMast.getBarcode(), // 条码 |
| | | (int) steProtocol.getAlarm(), // 异常码 |
| | | errName, // 异常 |
| | | 1, // 异常情况 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | "任务中异常" // 备注 |
| | | ); |
| | | if (!basSteErrLogService.insert(basSteErrLog)) { |
| | | log.error("穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", ste.getId(), errName); |
| | | } |
| | | } |
| | | } else { |
| | | // 异常修复 |
| | | if (steProtocol.getAlarm() == null || !steProtocol.isAlarm()) { |
| | | latest.setEndTime(now); |
| | | latest.setUpdateTime(now); |
| | | latest.setStatus(2); |
| | | if (!basSteErrLogService.updateById(latest)) { |
| | | log.error("穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", ste.getId(), latest.getId()); |
| | | } |
| | | } |
| | | } |
| | | // 无任务 |
| | | } else { |
| | | BasSteErrLog latest = basSteErrLogService.findLatest(ste.getId()); |
| | | // 有异常 |
| | | if (steProtocol.getAlarm() != null && steProtocol.isAlarm()) { |
| | | // 记录新异常 |
| | | if (latest == null || (latest.getErrCode() != steProtocol.getAlarm().intValue())) { |
| | | BasSteErr steErr = basSteErrService.selectById(steProtocol.getAlarm()); |
| | | String errName = steErr==null? "未知异常":steErr.getErrName(); |
| | | BasSteErrLog basSteErrLog = new BasSteErrLog( |
| | | null, // 编号 |
| | | null, // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | | null, // 工作状态 |
| | | null, // 入出库类型 |
| | | ste.getId(), // 堆垛机 |
| | | null, // plc |
| | | null, // 目标库位 |
| | | null, // 目标站 |
| | | null, // 源站 |
| | | null, // 源库位 |
| | | null, // 条码 |
| | | (int)steProtocol.getAlarm(), // 异常码 |
| | | errName, // 异常 |
| | | 1, // 异常情况 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | "无任务异常" // 备注 |
| | | ); |
| | | if (!basSteErrLogService.insert(basSteErrLog)) { |
| | | log.error("穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", ste.getId(), errName); |
| | | } |
| | | } |
| | | // 无异常 |
| | | } else { |
| | | // 异常修复 |
| | | if (latest != null && latest.getStatus() == 1) { |
| | | latest.setEndTime(now); |
| | | latest.setUpdateTime(now); |
| | | latest.setStatus(2); |
| | | if (!basSteErrLogService.updateById(latest)) { |
| | | log.error("穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", ste.getId(), latest.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // ------------------------------------------------------------------------------- |
| | | |