| | |
| | | && staProtocol.isInEnable() |
| | | && !staProtocol.isEmptyMk() |
| | | && staProtocol.getWorkNo() >9990 |
| | | && staProtocol.isEmptyOutType() |
| | | && (staProtocol.isEmptyOutType() || staProtocol.getSiteId() == 301 || staProtocol.getSiteId() == 304) |
| | | && staProtocol.isPakMk()) { |
| | | News.warnNoLog("" + mark + " - 0" + " - 开始执行"); |
| | | Short wrkNo = 9981; |
| | |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if (!Cools.isEmpty(barcode)) { |
| | | News.info("" + mark + " - 1" + " - {}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)|| "00000000".equals(barcode)) { |
| | | if (" ERROR".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode) || "00000000".equals(barcode)) { |
| | | // staProtocol.setWorkNo((short) 9992); |
| | | // staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | |
| | | try { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历拣料入库口 |
| | | for (DevpSlave.Sta pickSta : devp.getPickSta()) { |
| | | for (DevpSlave.Sta insta : devp.getInSta()) { |
| | | // 获取拣料入库站信息 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(insta.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | |
| | | if (staProtocol.isAutoing() |
| | | && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | | && staProtocol.getWorkNo() > 0 |
| | | && staProtocol.getWorkNo() > 9990 |
| | | && staProtocol.isPakMk()) { |
| | | News.warnNoLog("" + mark + " - 0" + " - 开始执行"); |
| | | |
| | | // // 获取条码扫描仪信息 |
| | | // BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); |
| | | // if (barcodeThread == null) { |
| | | // continue; |
| | | // } |
| | | // String barcode = barcodeThread.getBarcode(); |
| | | // if(!Cools.isEmpty(barcode)) { |
| | | // News.info(""+mark+" - 1"+" - {}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode); |
| | | // if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | // continue; |
| | | // } |
| | | // } else { |
| | | // continue; |
| | | // } |
| | | // 获取条码扫描仪信息 |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, insta.getBarcode()); |
| | | if (barcodeThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | // WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue()); |
| | | String barcode = barcodeThread.getBarcode(); |
| | | |
| | | if (!Cools.isEmpty(barcode)) { |
| | | News.info("" + mark + " - 1" + " - {}号条码扫描器检测条码信息:{}", insta.getBarcode(), barcode); |
| | | if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | continue; |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); |
| | | if (wrkMast == null) { |
| | | // 无拣料数据 |
| | | continue; |
| | | } |
| | | |
| | | if (wrkMast.getIoType() == 53 || wrkMast.getIoType() == 57) { |
| | | if (wrkMast.getWrkSts() != 2) { |
| | | News.error("" + mark + " - 3" + " - 拣选盘点回库工作档状态异常!!! [plc编号:{}]", devp.getId()); |
| | | continue; |
| | | } |
| | | |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | // staProtocol.setPalletSize(locMast.getLocType2()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | News.error("" + mark + " - 3" + " - 发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) |
| | | || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { |
| | | continue; |
| | | } |
| | | |
| | | // 拣、盘、并 作业站转换 |
| | | // int stnNo = 0; |
| | | // if (wrkMast.getStaNo() == 109) { |
| | | // stnNo = 127; |
| | | // } else if (wrkMast.getStaNo() == 113) { |
| | | // stnNo = 128; |
| | | // } else { |
| | | // log.error("{}号任务数据异常!", wrkMast.getWrkNo()); |
| | | // } |
| | | // 获取目标站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", wrkMast.getIoType() - 50) |
| | | .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站 |
| | | .eq("stn_no", insta.getStaNo()) // 作业站点 = 拣料出库的目标站 |
| | | .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号 |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)) { |
| | |
| | | // 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()); |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, insta.getLed()); |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = "此为拣料、并板、盘点再入库.请放在" + pickSta.getBackSta().shortValue() + "站点"; |
| | | MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(5, errorMsg)); |
| | | String errorMsg = "此为拣料、并板、盘点再入库.请放在" + insta.getBackSta().shortValue() + "站点"; |
| | | MessageQueue.offer(SlaveType.Led, insta.getLed(), new Task(5, errorMsg)); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | try { |
| | | LocTypeDto locTypeDto = new LocTypeDto(staProtocol); |
| | | // 保存工作明细档历史档 |
| | | if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作明细档历史档失败"); |
| | | } |
| | | // 保存工作主档历史档 |
| | | |
| | | SearchLocParam param = new SearchLocParam(); |
| | | param.setBarcode(wrkMast.getBarcode()); |
| | | param.setSourceStaNo(pickSta.getStaNo()); |
| | | param.setLocType1(locTypeDto.getLocType1()); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/pakin/pick/loc/v1") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | WrkMast newWrkMast = wrkMastMapper.selectPakInStepBarcode(wrkMast.getBarcode()); |
| | | if (newWrkMast == null) { |
| | | // 无拣料数据 |
| | | News.error("" + mark + " - 3" + " - 拣选盘点回库获取工作档失败!!! [plc编号:{}]", devp.getId()); |
| | | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | // 堆垛机站点(目标站) |
| | | Integer staNo = staDesc.getCrnStn(); |
| | | // 更新工作档数据状态 |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 |
| | | wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 源站 |
| | | wrkMast.setStaNo(staNo); // 目标站 |
| | | wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 目标库位 = 出库时的源库位 |
| | | wrkMast.setSourceLocNo(""); // 源库位清空 |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setUpdMk("");//允许再次移库 |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException("更新工作档数据状态失败"); |
| | | } |
| | | // 更新明细档io_time (历史档关联使用) |
| | | wrkDetlService.updateIoTime(wrkMast.getWrkNo(), now); |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | locMast.setLocSts("Q"); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | continue; |
| | | } |
| | | |
| | | if(newWrkMast.getWrkSts() != 53 && newWrkMast.getWrkSts() != 57) { |
| | | News.error("" + mark + " - 3" + " - 拣选盘点回库工作档类型异常!!! [plc编号:{}]", devp.getId()); |
| | | continue; |
| | | } |
| | | |
| | | if (wrkMast.getWrkSts() != 2) { |
| | | News.error("" + mark + " - 3" + " - 拣选盘点回库工作档状态异常!!! [plc编号:{}]", devp.getId()); |
| | | continue; |
| | | } |
| | | |
| | | LocMast locMast = locMastService.selectById(newWrkMast.getLocNo()); |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo(newWrkMast.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(newWrkMast.getStaNo().shortValue()); |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | staProtocol.setPalletSize(locMast.getLocType2()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | News.error("" + mark + " - 3" + " - 发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | } |
| | | } else { |
| | | News.error("" + mark + " - 5" + " - 请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/pick/loc/v1", JSON.toJSONString(param), response); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } else { |
| | | News.errorNoLog("" + mark + " - 6" + " - 站点信息不符合入库条件!!!" + " 自动信号:" + staProtocol.isLoading() + "、可入信号:" + staProtocol.isInEnable() |
| | | + "、空板信号:" + staProtocol.isEmptyMk()); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | list.add(newName); |
| | | //入库前抓拍 |
| | | try { |
| | | hikUtils.startPic(ip, newName + ".jpg"); |
| | | hikUtils.startPic(ip, newName); |
| | | } catch (Exception e) { |
| | | log.error("入库前抓拍"); |
| | | } |
| | |
| | | continue; |
| | | } |
| | | //堆垛机接驳站点没有空料架 |
| | | if(!staProtocol.isEmptyOutType()&&(Cools.isEmpty(wrkMast.getCtnType())||wrkMast.getCtnType()==0)){ |
| | | if (staProtocol.getSiteId() != 301 && staProtocol.getSiteId() != 304 && !staProtocol.isEmptyOutType() && (Cools.isEmpty(wrkMast.getCtnType()) || wrkMast.getCtnType() == 0)) { |
| | | //请求wms下发agv搬运空料架到堆垛机接驳站点任务 |
| | | try { |
| | | HashMap<String,Object> hashMap=new HashMap<>(); |
| | |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | Boolean boo1 = false; |
| | | Boolean boo2 = false; |
| | | if (staProtocol.isEmptyOutType() || staProtocol.getSiteId() == 301 || staProtocol.getSiteId() == 304) { |
| | | boo1 = true; |
| | | } |
| | | if ((staProtocol.getSiteId() == 301 || staProtocol.getSiteId() == 304) && staProtocol.isOutEnable()) { |
| | | boo2 = true; |
| | | } |
| | | |
| | | // 判断堆垛机出库站状态&& staProtocol.isOutEnable() |
| | | if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") |
| | | && staProtocol.isEmptyOutType()) { |
| | | && boo1 && boo2) { |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | //判断是否有正在执行中的AGV任务 |
| | |
| | | } |
| | | break; |
| | | } |
| | | } else if (staProtocol.getSiteId() == 301 && staProtocol.isAutoing() && staProtocol.isLoading() && !staProtocol.isOutEnable()) { |
| | | StaProtocol staProtocol1 = devpThread.getStation().get(304); |
| | | if (staProtocol1 == null) { |
| | | break; |
| | | } else { |
| | | staProtocol1 = staProtocol1.clone(); |
| | | } |
| | | |
| | | if (staProtocol1.isAutoing() && !staProtocol1.isLoading() && staProtocol1.isOutEnable()) { |
| | | wrkMast.setSourceStaNo(304); |
| | | wrkMast.setStaNo(306); |
| | | Date now = new Date(); |
| | | wrkMast.setModiTime(now); |
| | | wrkMastMapper.updateById(wrkMast); |
| | | } |
| | | } else if (staProtocol.getSiteId() == 304 && staProtocol.isAutoing() && staProtocol.isLoading() && !staProtocol.isOutEnable()){ |
| | | StaProtocol staProtocol1 = devpThread.getStation().get(301); |
| | | if (staProtocol1 == null) { |
| | | break; |
| | | } else { |
| | | staProtocol1 = staProtocol1.clone(); |
| | | } |
| | | if (staProtocol1.isAutoing() && !staProtocol1.isLoading() && staProtocol1.isOutEnable()) { |
| | | wrkMast.setSourceStaNo(301); |
| | | wrkMast.setStaNo(303); |
| | | Date now = new Date(); |
| | | wrkMast.setModiTime(now); |
| | | wrkMastMapper.updateById(wrkMast); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | if (staProtocol.isAutoing() |
| | | && staProtocol.isInEnable() |
| | | && staProtocol.isPakMk() |
| | | && staProtocol.getWorkNo() > 9990 |
| | | ) { |
| | | News.warnNoLog("" + mark + " - 0" + " - 开始执行:空栈板初始化入库,叉车入库站放货"); |
| | | |
| | |
| | | continue; |
| | | } |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", barcode)); |
| | | WaitPakin waitPakin = waitPakinMapper.selectOne(new EntityWrapper<WaitPakin>().eq("zpallet", barcode).getEntity()); |
| | | if (waitPakin != null || wrkMast != null) { |
| | | WaitPakin waitPakin = waitPakinMapper.selectByBarcode(barcode); |
| | | LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("barcode", barcode)); |
| | | if (waitPakin != null || wrkMast != null || locMast1 != null) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | // 获取工作档数据 |
| | | WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no",staProtocol.getWorkNo())); |
| | | // if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; } |
| | | if (null == wrkMast) { |
| | | continue; |
| | |
| | | ledCommand.setIoType(wrkMast.getIoType()); |
| | | // 出库模式 |
| | | switch (wrkMast.getIoType()) { |
| | | case 1: |
| | | ledCommand.setTitle("全板入库"); |
| | | break; |
| | | case 10: |
| | | ledCommand.setTitle("空板入库"); |
| | | break; |
| | | // case 1: |
| | | // ledCommand.setTitle("全板入库"); |
| | | // break; |
| | | // case 10: |
| | | // ledCommand.setTitle("空板入库"); |
| | | // break; |
| | | case 101: |
| | | ledCommand.setTitle("全板出库"); |
| | | break; |
| | |
| | | ledCommand.setTitle("空板出库"); |
| | | ledCommand.setEmptyMk(true); |
| | | break; |
| | | case 53: |
| | | ledCommand.setTitle("拣料入库"); |
| | | break; |
| | | case 57: |
| | | ledCommand.setTitle("盘点入库"); |
| | | break; |
| | | case 54: |
| | | ledCommand.setTitle("并板入库"); |
| | | break; |
| | | // case 53: |
| | | // ledCommand.setTitle("拣料入库"); |
| | | // break; |
| | | // case 57: |
| | | // ledCommand.setTitle("盘点入库"); |
| | | // break; |
| | | // case 54: |
| | | // ledCommand.setTitle("并板入库"); |
| | | // break; |
| | | default: |
| | | News.error(""+mark+" - 1"+" - 任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); |
| | | break; |
| | |
| | | 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()); |
| | |
| | | if (wrkMast.getIoType()>100){ |
| | | for (WrkDetl wrkDetl : wrkDetls){ |
| | | LocDetl locDetl = locDetlService.selectMatnrSpecs(wrkDetl.getMatnr(), wrkDetl.getSpecs(), wrkMast.getSourceLocNo()); |
| | | if (Cools.isEmpty(locDetl)) { |
| | | wrkDetl.setWeight(0.0); |
| | | }else { |
| | | wrkDetl.setWeight(locDetl.getAnfme()); |
| | | } |
| | | } |
| | | }else { |
| | | for (WrkDetl wrkDetl : wrkDetls){ |
| | |
| | | }catch (Exception e){ |
| | | log.error("工作档案明细输入电视机失败1:异常信息==》"+e); |
| | | } |
| | | wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getWeight(),wrkDetl.getSpecs(),wrkDetl.getSku()))); |
| | | wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getWeight(), wrkDetl.getSpecs(), wrkDetl.getSku(),wrkDetl.getZpallet()))); |
| | | } |
| | | commands.add(ledCommand); |
| | | } |
| | |
| | | if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { |
| | | 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))) { |