| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private BasRgvMapService basRgvMapService; |
| | | @Autowired |
| | | private BasCrnOptService crnOptService; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | |
| | | errMsg = "右超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.getWeight() > 1000) { |
| | | if (!back && staProtocol.getWeight() > 15000) { |
| | | errMsg = "超重或未读取"; |
| | | back = true; |
| | | } |
| | |
| | | if (!staProtocol.isPakMk()) { |
| | | continue; |
| | | } |
| | | staProtocol.setWorkNo(wrkNo); |
| | | staProtocol.setWorkNo(wrkNo);//退回 工作号:10000 |
| | | News.info("{}PLC入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); |
| | | wrkNo++; |
| | | // wrkNo++; |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | log.error("输送线下发1:" + wrkNo + "," + inSta.getBackSta()); |
| | | break;//超限托盘退回不生成工作档 |
| | | } |
| | | |
| | | // 判断是否满足入库条件 |
| | |
| | | |
| | | staProtocol.setWorkNo(wrkNo); |
| | | News.info("{}barcode入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); |
| | | wrkNo++; |
| | | // wrkNo++; |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | |
| | | // } |
| | | News.error(barcode + "条码已存在状态为( 2.设备上走 )的数据,请查看WCS输送线界面,工作号={}", wrkMast.getWrkNo()); |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, barcode + "条码已存在状态为( 2.设备上走 )的任务,工作号=" + wrkMast.getWrkNo())); |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo()); |
| | | 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站点信息失败"); |
| | | } |
| | | continue; |
| | | // barcodeThread.setBarcode(""); |
| | | // staProtocol.setWorkNo(wrkMast.getWrkNo()); |
| | |
| | | continue; |
| | | } |
| | | staProtocol.setWorkNo(wrkNo); |
| | | wrkNo++; |
| | | // 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(3, errorMsg)); |
| | | } |
| | | // } |
| | | // News.error(methodName + ":请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | News.error(methodName + ":请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | } |
| | | // News.infoNoLog(""+mark+" - 0"+" - 组托 ===》执行完成"); |
| | | News.infoNoLog(""+mark+" - 0"+" - 组托 ===》执行完成"); |
| | | |
| | | } |
| | | |
| | |
| | | // 退回 |
| | | // if (back) { |
| | | // log.info("errmsg: " + errMsg); |
| | | //// News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); |
| | | // News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); |
| | | // MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(5, errMsg)); |
| | | // if (!staProtocol.isLoading()) { |
| | | // continue; |
| | |
| | | // |
| | | // |
| | | // 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; |
| | | // } |
| | |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | |
| | | // // 入出库模式判断 |
| | | // 入出库模式判断 |
| | | // if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; } |
| | | |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()) { |
| | |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | StaProtocol staProtocol1 = devpThread.getStation().get(crnStn.getStaNo() - 1); |
| | | StaProtocol staProtocol1 = staProtocol.getSiteId()==101?devpThread.getStation().get(crnStn.getStaNo() + 1):devpThread.getStation().get(crnStn.getStaNo() - 1); |
| | | // StaProtocol staProtocol1 = devpThread.getStation().get(crnStn.getStaNo() - 1); |
| | | // StaProtocol staProtocol1 = devpThread.getStation().get(crnStn.getStaNo() + 1); |
| | | if (staProtocol1 == null) { |
| | | News.infoNoLog("" + mark + " - 2" + " - 3" + " - 堆垛机出库站信息(staProtocol!=null继续执行,否则循环终止):staProtocol=" + staProtocol); |
| | | break; |
| | | } else { |
| | | staProtocol1 = staProtocol1.clone(); |
| | | } |
| | | StaProtocol staProtocol2 = devpThread.getStation().get(crnStn.getStaNo() - 2); |
| | | StaProtocol staProtocol2 = staProtocol.getSiteId()==101?devpThread.getStation().get(crnStn.getStaNo() + 2):devpThread.getStation().get(crnStn.getStaNo()); |
| | | // StaProtocol staProtocol2 = devpThread.getStation().get(crnStn.getStaNo() - 2); |
| | | // StaProtocol staProtocol2 = devpThread.getStation().get(crnStn.getStaNo() + 2); |
| | | if (staProtocol2 == null) { |
| | | News.infoNoLog("" + mark + " - 2" + " - 3" + " - 堆垛机出库站信息(staProtocol!=null继续执行,否则循环终止):staProtocol=" + staProtocol); |
| | | break; |
| | |
| | | staProtocol2 = staProtocol2.clone(); |
| | | } |
| | | //出入口输送线只允许存在一个托盘 |
| | | if(staProtocol.isLoading() || staProtocol1.isLoading() || staProtocol2.isLoading() ) { |
| | | if(staProtocol.isLoading() || staProtocol1.isLoading() || staProtocol2.isLoading() || staProtocol.getWorkNo() != 0 || staProtocol1.getWorkNo() != 0 || staProtocol2.getWorkNo() != 0) { |
| | | break; |
| | | } |
| | | |
| | |
| | | // 状态:等待确认 并且 任务完成位 = 1 |
| | | if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) { |
| | | News.warnNoLog("" + mark + " - 0" + " - 开始执行对工作档的完成操作,任务号:" + crnProtocol.getTaskNo()); |
| | | |
| | | if (crnProtocol.getTaskNo() == 9999){ |
| | | crnThread.setResetFlag(true); |
| | | continue; |
| | | } |
| | | // 获取入库待确认工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue()); |
| | | if (wrkMast == null) { |
| | |
| | | LedCommand ledCommand = new LedCommand(); |
| | | ledCommand.setWorkNo(dto.getWorkNo()); |
| | | ledCommand.setIoType(1); |
| | | ledCommand.setTitle("全板入库"); |
| | | ledCommand.setTitle("空板入库"); |
| | | ledCommand.setLocNo(dto.getLocNo()); |
| | | ledCommand.setStaNo(dto.getStaNo()); |
| | | commands.add(ledCommand); |
| | |
| | | } |
| | | } |
| | | } |
| | | // News.infoNoLog(""+mark+" - 0"+" - 空栈板初始化入库,叉车入库站放货执行完成"); |
| | | News.infoNoLog(""+mark+" - 0"+" - 空栈板初始化入库,叉车入库站放货执行完成"); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | public synchronized void crnMove() { |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // 获取堆垛机信息 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { |
| | | continue; |
| | | } |
| | | BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); |
| | | if (basCrnp == null) { |
| | | log.error("{}号堆垛机尚未在数据库进行维护!", crn.getId()); |
| | | continue; |
| | | } |
| | | |
| | | if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { |
| | | if (crnProtocol.getCrnNo()==1 && crnProtocol.getBay()==1 && crnProtocol.getLevel() == 1) { |
| | | continue; |
| | | } |
| | | Page<BasCrnOpt> basCrnOptPage = crnOptService.selectPage(new Page<>(1, 1), new EntityWrapper<BasCrnOpt>().eq("crn_no", crn.getId()).orderBy("send_time", false)); |
| | | if (basCrnOptPage != null && basCrnOptPage.getRecords() != null && basCrnOptPage.getRecords().size() > 0) { |
| | | if (System.currentTimeMillis() - basCrnOptPage.getRecords().get(0).getSendTime().getTime() < 1000 * 60 * 3) { |
| | | continue; |
| | | } |
| | | } else { |
| | | if (System.currentTimeMillis() - crnProtocol.getLastCommandTime() < 1000 * 60 * 2) { |
| | | continue; |
| | | } |
| | | } |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .eq("crn_no", crn.getId()) |
| | | .notIn("wrk_sts", 5, 14, 15) |
| | | ); |
| | | if (!wrkMasts.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | CrnSlave.CrnStn crnStn = crn.getCrnInStn().get(0); |
| | | |
| | | News.info("堆垛机无任务自动回入库口待机==>>" + crnProtocol.getCrnNo() + "号堆垛机"); |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 堆垛机编号 |
| | | crnCommand.setTaskNo((short) 9999); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | // crnCommand.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 任务模式: 堆垛机移动 |
| | | crnCommand.setTaskMode(CrnTaskModeType.X_MOVE);//余姚锐麒回原点任务模式: 站位转移 |
| | | crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY((short) 1); // 源库位列 |
| | | crnCommand.setSourcePosZ((short) 1); // 源库位层 |
| | | crnCommand.setDestinationPosX((short) 0); // 目标库位排 |
| | | crnCommand.setDestinationPosY((short) 0); // 目标库位列 |
| | | crnCommand.setDestinationPosZ((short) 0); // 目标库位层 |
| | | crnCommand.setCommand((short) 1);//任务确认位 |
| | | if (!MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, crnCommand))) { |
| | | News.error("堆垛机移动命令下发失败,堆垛机号={},任务数据={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | | crnThread.setBackHpFlag(true); |
| | | try { |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |