| | |
| | | private BasCrnErrorMapper basCrnErrorMapper; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | |
| | | public short wrkNo = 9999; |
| | | /** |
| | | * 组托 |
| | | * 入库站,根据条码扫描生成入库工作档,工作状态 2 |
| | | */ |
| | | public synchronized void generateStoreWrkFile(Integer mark) { |
| | | public synchronized void generateStoreWrkFile(Integer mark) throws InterruptedException { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { //遍历输送线 |
| | | // 遍历入库口 |
| | |
| | | // 获取入库站信息 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | |
| | | //LED |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); |
| | | // 入出库模式判断 |
| | | // if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; } |
| | | // if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { |
| | | // continue; |
| | | // } |
| | | /* |
| | | 无条码 |
| | | 没有可入信号 |
| | | 有空板信号 |
| | | 不是满托盘 |
| | | 是2号输送线9995拣料任务 |
| | | */ |
| | | String barcode = barcodeThread.getBarcode(); |
| | | |
| | | // 判断是否满足入库条件 |
| | | if (!staProtocol.isLoading()){ |
| | | continue; |
| | | |
| | | // 尺寸检测异常 |
| | | boolean back = false; |
| | | String errMsg = ""; |
| | | if (staProtocol.isFrontErr()) { |
| | | errMsg = "前超限"; |
| | | back = true; |
| | | } |
| | | // String barcode11 = barcodeThread.getBarcode(); |
| | | // if (Cools.isEmpty(barcode11)){ |
| | | // if (staProtocol.isAutoing()&& !staProtocol.isEmptyMk() && staProtocol.getWorkNo() == 9999 && staProtocol.isPakMk() && staProtocol.getStamp()>=2){ |
| | | // staProtocol.setStamp(0); |
| | | // News.info(""+mark+" - 7"+" - 扫码失败2 ===>> {}号条码扫描器检测条码信息:{},站点:{}", inSta.getBarcode(), barcode11, inSta.getStaNo()); |
| | | // staProtocol.setWorkNo((short) 9989); |
| | | // staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | // MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // // led 异常显示 |
| | | // if (ledThread != null) { |
| | | // String errorMsg = "扫码失败,请重试"; |
| | | // MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); |
| | | // } |
| | | // continue; |
| | | if (!back && staProtocol.isBackErr()) { |
| | | errMsg = "后超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isHighErr()) { |
| | | errMsg = "高超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isLeftErr()) { |
| | | errMsg = "左超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isRightErr()) { |
| | | errMsg = "右超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isWeightErr()) { |
| | | errMsg = "超重"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isBarcodeErr()) { |
| | | errMsg = "扫码失败"; |
| | | back = true; |
| | | } |
| | | |
| | | // if (!back && devp.getId() == 2) { |
| | | // if(staProtocol.getWorkNo() == 9907 && '5' != barcode.charAt(0)){ |
| | | // errMsg = "条码5只能入7排"; |
| | | // back = true; |
| | | // } |
| | | // if(staProtocol.getWorkNo() == 9906 && '5' == barcode.charAt(0)){ |
| | | // errMsg = "条码5不能入6排"; |
| | | // back = true; |
| | | // } |
| | | // } |
| | | if (staProtocol.isAutoing() && staProtocol.isInEnable() |
| | | && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() > 9990) |
| | | && staProtocol.isPakMk()) { //&& staProtocol.getStamp()>=2) {// && !Cools.isEmpty(barcode)) { |
| | | News.warnNoLog(""+mark+" - 0"+" - 开始执行"); |
| | | // try { |
| | | // Thread.sleep(300); |
| | | // }catch (Exception e){} |
| | | |
| | | //String barcode = barcodeThread.getBarcode(); |
| | | String barcode = "20000005"; |
| | | if(!Cools.isEmpty(barcode)) { |
| | | News.info(""+mark+" - 1"+" - {}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | // 退回 |
| | | if (back && devp.getId() == 2) { |
| | | // News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); |
| | | // if(!staProtocol.isOutEnable()){ |
| | | // continue; |
| | | // } |
| | | |
| | | if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | News.info(""+mark+" - 2"+" - 扫码失败1 ===>> {}号条码扫描器检测条码信息:{},站点:{}", inSta.getBarcode(), barcode, inSta.getStaNo()); |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = "扫码失败,请重试"; |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); |
| | | } |
| | | continue; |
| | | } |
| | | } else { |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | News.info(""+mark+" - 3"+" - 扫码失败2 ===>> {}号条码扫描器检测条码信息:{},站点:{}", inSta.getBarcode(), barcode, inSta.getStaNo()); |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = "扫码失败,请重试"; |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); |
| | | } |
| | | if (!staProtocol.isLoading()){ |
| | | continue; |
| | | } |
| | | if (!staProtocol.isPakMk()) { |
| | | continue; |
| | | } |
| | | staProtocol.setWorkNo(wrkNo); |
| | | News.warn("{}入库回退:{},任务号:{}", inSta.getStaNo(), errMsg,wrkNo); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errMsg)); |
| | | Thread.sleep(500); |
| | | } |
| | | |
| | | if (Cools.isEmpty(barcode) || !staProtocol.isInEnable() || staProtocol.isEmptyMk() |
| | | || !staProtocol.isFullPlt() || (staProtocol.getWorkNo() <= 9000 && devp.getId() == 2)) { |
| | | continue; |
| | | } |
| | | |
| | | if (staProtocol.isAutoing() && staProtocol.isInEnable() |
| | | && !staProtocol.isEmptyMk() && staProtocol.getWorkNo() > 9000 |
| | | && staProtocol.isPakMk() &&!Cools.isEmpty(barcode) && !back) { |
| | | // 判断重复工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); |
| | | //过滤判断,防止拣料再入库货物,经过入库站再入库时,被退回到退库站 |
| | | WrkMast wrkMast1 = wrkMastMapper.selectPakInStepBarcode(barcode); |
| | | if (wrkMast1 !=null){ |
| | | if (wrkMast1.getIoType()==103 || wrkMast1.getIoType()==107 || wrkMast1.getIoType()==104){ |
| | | if (wrkMast1.getIoType()==103 || wrkMast1.getIoType() == 53 || wrkMast1.getIoType()==107 || wrkMast1.getIoType()==104){ |
| | | continue; |
| | | } |
| | | } |
| | | if (wrkMast != null) { |
| | | News.error(""+mark+" - 4"+" - 工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo()); |
| | | staProtocol.setWorkNo((short)9999); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | News.warn(""+mark+" - 4"+" - 满托盘入库工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo()); |
| | | if (devp.getId() == 2) { |
| | | // staProtocol.setWorkNo((short)9999); |
| | | // staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } |
| | | |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = "工作档已存在该条码号===>>" + barcode; |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); |
| | | // MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); |
| | | } |
| | | continue; |
| | | } |
| | |
| | | ledCommand.setTitle("全板入库"); |
| | | ledCommand.setLocNo(dto.getLocNo()); |
| | | ledCommand.setStaNo(dto.getStaNo()); |
| | | ArrayList<MatDto> matDtos = new ArrayList<>(); |
| | | MatDto matDto = new MatDto(); |
| | | matDto.setLocNo(dto.getLocNo()); |
| | | matDtos.add(matDto); |
| | | ledCommand.setMatDtos(matDtos); |
| | | ledCommand.setBarcode(barcode); |
| | | commands.add(ledCommand); |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands)); |
| | | if (devp.getId() == 1) { |
| | | // if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(1, commands))){ |
| | | // ledThread.setLedMk(false); |
| | | // } |
| | | } else { |
| | | if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands))){ |
| | | ledThread.setLedMk(false); |
| | | } |
| | | } |
| | | // ledThread.errorReset(); |
| | | } |
| | | } else { |
| | | News.error(""+mark+" - 5"+" - 请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | staProtocol.setWorkNo((short)9999); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | News.error(""+mark+" - 5"+" - 满板入库请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | if(devp.getId() == 2) { |
| | | staProtocol.setWorkNo((short)9999); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } |
| | | |
| | | // led 异常显示 |
| | |
| | | } |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if(!Cools.isEmpty(barcode)) { |
| | | News.info(""+mark+" - 1"+" - {}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode); |
| | | // News.info(""+mark+" - 1"+" - {}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode); |
| | | if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | |
| | | // 拣、盘、并 作业站转换 |
| | | // int stnNo = 0; |
| | | // if (wrkMast.getStaNo() == 109) { |
| | | // stnNo = 127; |
| | | // } else if (wrkMast.getStaNo() == 113) { |
| | | // stnNo = 128; |
| | | // } else { |
| | | // log.error("{}号任务数据异常!", wrkMast.getWrkNo()); |
| | | // } |
| | | int stnNo = 0; |
| | | if (wrkMast.getIoType() == 103) { // 拣料出库 |
| | | if(wrkMast.getCrnNo() == 1) { |
| | | stnNo = 104; |
| | | }else if(wrkMast.getCrnNo() == 2) { |
| | | stnNo =204; |
| | | }else if(wrkMast.getCrnNo() == 3) { |
| | | stnNo = 304; |
| | | } |
| | | } else if(wrkMast.getIoType() == 107){ //盘点出库 |
| | | if(wrkMast.getCrnNo() == 1) { |
| | | stnNo = 101; |
| | | }else if(wrkMast.getCrnNo() == 2) { |
| | | stnNo =201; |
| | | }else if(wrkMast.getCrnNo() == 3) { |
| | | stnNo = 301; |
| | | } |
| | | } |
| | | if (stnNo == 0) { |
| | | log.error("{}号任务数据异常!", wrkMast.getWrkNo()); |
| | | continue; |
| | | } |
| | | // 获取目标站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", wrkMast.getIoType() - 50) |
| | | .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站 |
| | | .eq("stn_no", stnNo) // 作业站点 = 拣料出库的目标站 |
| | | .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号 |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | //LED |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | News.error(""+mark+" - 2"+" - 入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo()); |
| | | staProtocol.setWorkNo((short) 9989); |
| | | staProtocol.setStaNo(pickSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | //LED |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); |
| | | if (devp.getId() == 2) { |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo(pickSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = "此为拣料、并板、盘点再入库.请放在"+pickSta.getBackSta().shortValue()+"站点"; |
| | |
| | | Integer staNo = staDesc.getCrnStn(); |
| | | // 更新工作档数据状态 |
| | | wrkMast.setIoTime(now); |
| | | //盘点入库时,有组托数据,盘点转并板入库 |
| | | List<WaitPakin> waitPakins=waitPakinMapper.selectList(new EntityWrapper<WaitPakin>() |
| | | .eq("barcode",barcode)); |
| | | if(!Cools.isEmpty(waitPakins)){ |
| | | wrkMast.setIoType(54); |
| | | }else{ |
| | | wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | } |
| | | wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 |
| | | wrkMast.setSourceStaNo(100); // 源站 |
| | | wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 源站 |
| | | wrkMast.setStaNo(staNo); // 目标站 |
| | | wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 目标库位 = 出库时的源库位 |
| | | wrkMast.setSourceLocNo(""); // 源库位清空 |
| | |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException("更新工作档数据状态失败"); |
| | | } |
| | | |
| | | |
| | | |
| | | // 更新明细档io_time (历史档关联使用) |
| | | wrkDetlService.updateIoTime(wrkMast.getWrkNo(), now); |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | continue; |
| | | } |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | LedCommand ledCommand = new LedCommand(); |
| | | ledCommand.setWorkNo(wrkMast.getWrkNo()); |
| | | ledCommand.setIoType(wrkMast.getIoType()); |
| | | ledCommand.setTitle(wrkMast.getIoType() == 53 ? "拣料再入库" : "盘点再入库"); |
| | | ledCommand.setLocNo(wrkMast.getLocNo()); |
| | | ledCommand.setStaNo(wrkMast.getStaNo()); |
| | | ledCommand.setBarcode(barcode); |
| | | ArrayList<MatDto> matDtos = new ArrayList<>(); |
| | | MatDto matDto = new MatDto(); |
| | | matDto.setLocNo(wrkMast.getLocNo()); |
| | | matDtos.add(matDto); |
| | | ledCommand.setMatDtos(matDtos); |
| | | commands.add(ledCommand); |
| | | if (devp.getId() == 1) { |
| | | // if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(1, commands))) { |
| | | // ledThread.setLedMk(false); |
| | | // } |
| | | } else { |
| | | if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, commands))){ |
| | | ledThread.setLedMk(false); |
| | | } |
| | | } |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | |
| | | //mark - 3 - .... |
| | | this.locToLoc(crn, crnProtocol,mark); |
| | | |
| | | if (!Cools.isEmpty(basCrnp.getMoveOrigin()) && basCrnp.getMoveOrigin().equals("Y")){ |
| | | if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO |
| | | && crnThread.isCmdFlag()) { |
| | | this.crnMoveIntXY(crn, crnProtocol, crnThread); |
| | | this.crnMoveOutXY(crn, crnProtocol, crnThread); |
| | | } |
| | | } |
| | | // if (!Cools.isEmpty(basCrnp.getMoveOrigin()) && basCrnp.getMoveOrigin().equals("Y")){ |
| | | // if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO |
| | | // && crnThread.isCmdFlag()) { |
| | | // this.crnMoveIntXY(crn, crnProtocol, crnThread); |
| | | // this.crnMoveOutXY(crn, crnProtocol, crnThread); |
| | | // } |
| | | // } |
| | | // this.crnRebackHp(crnProtocol, crnThread); |
| | | |
| | | } |
| | |
| | | News.error(""+mark+" - 1"+" - 2"+" - 入库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo()); |
| | | continue; |
| | | } |
| | | // 获取工作状态为2(设备上走)的入库工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo()); |
| | | if (null == wrkMast) { |
| | | News.infoNoLog(""+mark+" - 1"+" - 4"+" - 查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | | // log.error("查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | | continue; |
| | | } |
| | | |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable() |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && |
| | | (staProtocol.getWorkNo() <= 9000 || (slave.getId() == 1 && (wrkMast.getIoType() == 53 || wrkMast.getIoType() == 57))) |
| | | && staProtocol.isInEnable() |
| | | && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) { |
| | | flag = true; |
| | | } |
| | |
| | | +"能入信号(wms设置).equals(\"Y\")"+staDetl.getCanining()); |
| | | continue; |
| | | } |
| | | // 获取工作状态为2(设备上走)的入库工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo()); |
| | | if (null == wrkMast) { |
| | | News.infoNoLog(""+mark+" - 1"+" - 4"+" - 查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | | // log.error("查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | | continue; |
| | | } |
| | | |
| | | // 获取库位信息 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (locMast == null) { |
| | |
| | | crnCommand.setDestinationPosX(locMast.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 目标库位层 |
| | | crnCommand.setCommand((short) 1); |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | News.error(""+mark+" - 1"+" - 16"+" - 堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | |
| | | crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 目标库位层 |
| | | crnCommand.setCommand((short) 1); |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | News.error(""+mark+" - 2"+" - 13"+" - 堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | |
| | | crnCommand.setDestinationPosX(sta.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(sta.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(sta.getLev1().shortValue()); // 目标库位层 |
| | | crnCommand.setCommand((short) 1); |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | News.error(""+mark+" - 3"+" - 4"+" - 堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | |
| | | crnThread.setResetFlag(true); |
| | | } else { |
| | | // 获取入库待确认工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue()); |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep3(Integer.valueOf(crnProtocol.getTaskNo())); |
| | | if (wrkMast == null) { |
| | | News.error(""+mark+" - 1"+" - 堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo()); |
| | | continue; |
| | |
| | | ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); |
| | | } |
| | | |
| | | if (!staProtocol.isLoading()){ |
| | | continue; |
| | | } |
| | | // 站点条件判断 |
| | | if (staProtocol.isAutoing() |
| | | && staProtocol.isInEnable() |
| | | && staProtocol.isEmptyMk() |
| | | && (staProtocol.getWorkNo() > 9990 && staProtocol.getWorkNo() <= 9999) |
| | | && staProtocol.isPakMk() ) { |
| | | && staProtocol.getWorkNo() > 9000 |
| | | && staProtocol.isPakMk() |
| | | && staProtocol.isLoading() |
| | | ) { |
| | | News.warnNoLog(""+mark+" - 0"+" - 开始执行:空栈板初始化入库,叉车入库站放货"); |
| | | |
| | | // 判断上一个空托入库写入后,线程还读取到,造成重复请求 |
| | | List<WrkMast> wrkMastList = wrkMastMapper.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts",2) |
| | | .eq("io_type",10).eq("source_sta_no",emptyInSta.getStaNo())); |
| | | if(!wrkMastList.isEmpty()) { |
| | | log.warn("查询到一个在设备上走任务:{}",wrkMastList.get(0).getWrkNo()); |
| | | continue; |
| | | } |
| | | try { |
| | | LocTypeDto locTypeDto = new LocTypeDto(staProtocol); |
| | | |
| | |
| | | News.errorNoLog(""+mark+" - 1"+" - 更新plc站点信息失败"); |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | |
| | | if (ledThread != null) { |
| | | // 命令集合 |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | // 组装命令 |
| | | LedCommand ledCommand = new LedCommand(); |
| | | ledCommand.setWorkNo(dto.getWorkNo()); |
| | | ledCommand.setIoType(1); |
| | | ledCommand.setTitle("全板入库"); |
| | | ledCommand.setIoType(10); |
| | | ledCommand.setTitle("空板入库"); |
| | | ledCommand.setLocNo(dto.getLocNo()); |
| | | ledCommand.setStaNo(dto.getStaNo()); |
| | | ledCommand.setBarcode(""); |
| | | ArrayList<MatDto> matDtos = new ArrayList<>(); |
| | | MatDto matDto = new MatDto(); |
| | | matDto.setLocNo(dto.getLocNo()); |
| | | matDtos.add(matDto); |
| | | ledCommand.setMatDtos(matDtos); |
| | | commands.add(ledCommand); |
| | | MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, commands)); |
| | | if (devp.getId() == 1) { |
| | | // MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(1, commands)); |
| | | } else { |
| | | MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, commands)); |
| | | } |
| | | // ledThread.errorReset(); |
| | | } |
| | | Thread.sleep(1000); |
| | | } else { |
| | | staProtocol.setWorkNo((short)9991); |
| | | staProtocol.setStaNo((short)100); |
| | | staProtocol.setStaNo(emptyInSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | |
| | | MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); |
| | | } |
| | | } |
| | | News.error(""+mark+" - 3"+" - 请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | News.error(""+mark+" - 3"+" - 空板入库请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | // 工作档集合 |
| | | List<WrkMast> wrkMasts = new ArrayList<>(); |
| | | for (Integer staNo : led.getStaArr()) { |
| | | if (staNo == 104 || staNo == 204 || staNo == 304) { |
| | | continue; |
| | | } |
| | | // 获取叉车站点 |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { |
| | |
| | | ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); |
| | | ledCommand.setLocNo(wrkMast.getLocNo()); |
| | | ledCommand.setStaNo(wrkMast.getStaNo()); |
| | | ledCommand.setBarcode(wrkMast.getBarcode()); |
| | | // ledCommand.setSourceStaNo(wrkMast.getSourceStaNo()); |
| | | if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); |
| | | wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getSpecs()))); |
| | | wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getSpecs(),wrkDetl.getBatch(),wrkDetl.getMemo()))); |
| | | } |
| | | commands.add(ledCommand); |
| | | } |
| | |
| | | continue; |
| | | } |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | // if (!commands.isEmpty()) { |
| | | // if (led.getId() < 7) { |
| | | // if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | // News.error(""+mark+" - 2"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // continue; |
| | | // } else { |
| | | // ledThread.setLedMk(false); |
| | | // } |
| | | // } else { |
| | | // if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { |
| | | // News.error(""+mark+" - 3"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // continue; |
| | | // } else { |
| | | // ledThread.setLedMk(false); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | if (!commands.isEmpty()) { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | }else { |
| | | ledThread.setLedMk(false); |
| | | if (led.getId() == 3) { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | News.error(""+mark+" - 2"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | } else { |
| | | ledThread.setLedMk(false); |
| | | } |
| | | } else if(led.getId() == 1 || led.getId() == 2){ |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { |
| | | News.error(""+mark+" - 3"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | } else { |
| | | ledThread.setLedMk(false); |
| | | } |
| | | } |
| | | |
| | | } |
| | | // // 命令下发 ------------------------------------------------------------------------------- |
| | | // if (!commands.isEmpty()) { |
| | | // if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | // News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // continue; |
| | | // }else { |
| | | // ledThread.setLedMk(false); |
| | | // } |
| | | // } |
| | | |
| | | try { |
| | | // 修改主档led标记 |
| | |
| | | // led显示默认内容 |
| | | if (reset && !ledThread.isLedMk()) { |
| | | ledThread.setLedMk(true); |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { |
| | | News.error(""+mark+" - 1"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | } else { |
| | | if (led.getId() <=2 ) { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { |
| | | News.error(""+mark+" - 1"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | } else { |
| | | |
| | | } |
| | | } else { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { |
| | | News.error(""+mark+" - 1"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | } else { |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | News.infoNoLog(""+mark+" - 0"+" - 执行完成:其他 ===>> LED显示器复位,显示默认信息"); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 接收超宽超高没扫到条码报警 |
| | | * @param mark |
| | | */ |
| | | public synchronized void DevpCallThePolice(Integer mark){ |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { //遍历输送线 |
| | | // 遍历入库口 |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { // 遍历入库口 |
| | | // 获取入库站信息 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | | if(null != devpThread){ |
| | | boolean fig=false; |
| | | for (int i=0;i<8;i++){ |
| | | switch (i){ |
| | | case 0: if(devpThread.startSignal[i]){ |
| | | log.error("前超报警"); |
| | | fig=true; |
| | | }; |
| | | case 1: if(devpThread.startSignal[i]){ |
| | | log.error("后超报警"); |
| | | fig=true; |
| | | }; |
| | | case 2: if(devpThread.startSignal[i]){ |
| | | log.error("高超报警"); |
| | | fig=true; |
| | | }; |
| | | case 3: if(devpThread.startSignal[i]){ |
| | | log.error("左超报警"); |
| | | fig=true; |
| | | }; |
| | | case 4: if(devpThread.startSignal[i]){ |
| | | log.error("右超报警"); |
| | | fig=true; |
| | | }; |
| | | case 5: if(devpThread.startSignal[i]){ |
| | | log.error("超重报警"); |
| | | fig=true; |
| | | }; |
| | | case 6: if(devpThread.startSignal[i]){ |
| | | log.error("未扫到码报警"); |
| | | fig=true; |
| | | }; |
| | | |
| | | } |
| | | } |
| | | //发生报警,退回入库口 |
| | | if(fig){ |
| | | staProtocol.setWorkNo((short)9991); |
| | | staProtocol.setStaNo((short)100); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void resetOneLed() { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { //遍历输送线 |
| | | if (devp.getId() == 1) { |
| | | // 遍历入库口 |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { // 遍历入库口 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |