| | |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.AgvTaskAssignmentParam; |
| | | import com.zy.asrs.entity.param.ArmOrderAssignmentParam; |
| | | import com.zy.asrs.entity.param.ArmTaskAssignmentParam; |
| | | import com.zy.asrs.entity.param.CombParam; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.OrderDetlValueResultUtil; |
| | | import com.zy.asrs.mapper.*; |
| | | import com.zy.asrs.service.*; |
| | |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private BasDevpOptService basDevpOptService; |
| | | @Autowired |
| | | private MatService matService; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | |
| | | && staProtocol.isPakMk() |
| | | && staProtocol.getWorkNo() == 0 |
| | | ) { |
| | | |
| | | if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | // News.error(JSON.toJSONString(staProtocol)); |
| | | News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | log.error("输送线下发1:"+wrkNo+","+inSta.getBackSta()); |
| | | continue; |
| | | } |
| | | if(barcode.equals("0")){ |
| | | continue; |
| | | } |
| | | // if (staProtocol.getSiteId()!= 159){ |
| | |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | log.error("输送线下发2:"+dto.getWorkNo()+","+dto.getStaNo()); |
| | | |
| | | if(staProtocol.getSiteId() == 1036){ //1036 |
| | | BasAgvMast basAgvMast = basAgvMastService.selectOne(new EntityWrapper<BasAgvMast>().eq("sta_no", 1037)); |
| | | AgvBindCtnrAndBinParam agvBindCtnrAndBinParam = new AgvBindCtnrAndBinParam(basAgvMast); |
| | | agvBindCtnrAndBinParam.setCtnrCode(barcode); |
| | | ReturnT<String> resultBind = new PostMesDataUtils().postMesDataAgv("AGV容器绑定解绑", AgvConstant.AGV_URL, AgvConstant.AGV_CTNRANDBING, agvBindCtnrAndBinParam); |
| | | if (resultBind.getCode()!=200){ |
| | | agvTaskAssignmentCallApiLogSave(basAgvMast, "AGV容器绑定解绑", "任务号:"+basAgvMast.getTaskNo()+"任务信息下发失败!!!", false); |
| | | } |
| | | } |
| | | ledThread.errorReset(); |
| | | log.error("组托请求后LED错误清除"); |
| | | |
| | |
| | | for (Integer site:list){ |
| | | Integer emptyCount = wrkMastMapper.countPakOutEmpty(site); |
| | | StaProtocol staProtocol = null; |
| | | if(emptyCount >= 1 && site == 1108){ |
| | | if(emptyCount >= 2 && site == 1108){ |
| | | continue; |
| | | }else if(emptyCount == 1 && site == 2031){ |
| | | continue; |
| | |
| | | if(rgvProtocol.getStatusType1() == RgvStatusType.WORKING){ |
| | | rgvThread.setPaking(true); |
| | | } |
| | | if(rgvProtocol.getTaskNo1() == 0 && rgvProtocol.getTaskNo2() == 0 && rgvProtocol.getStatusType1() == RgvStatusType.IDLE){ |
| | | rgvThread.setPaking(true); |
| | | } |
| | | // if(rgvProtocol.getTaskNo1() == 0 && rgvProtocol.getTaskNo2() == 0 && rgvProtocol.getStatusType1() == RgvStatusType.IDLE){ |
| | | // rgvThread.setPaking(true); |
| | | // } |
| | | if(rgvProtocol.isLoaded1ing() && rgvProtocol.isLoaded2ing()){ |
| | | basRgv.setPakAll("1"); |
| | | basRgvService.updateById(basRgv); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /* |
| | | * arm任务完成自动组托 |
| | | * */ |
| | |
| | | log.error("机械臂抓取任务完成组托失败"+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * arm任务完成自动组托 |
| | | * */ |
| | | public synchronized void armMissionAccomplished2() { |
| | | try{ |
| | | List<BasArm> basArmList = basArmService.selectList(new EntityWrapper<BasArm>().gt("arm_no",4)); |
| | | for (BasArm basArm : basArmList) { |
| | | if (basArm.getStatus()!=1){ |
| | | continue; |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", basArm.getStaNoSou())); |
| | | if (Cools.isEmpty(locMast)){ |
| | | continue; |
| | | } |
| | | try{ |
| | | List<BasArmMast> basArmMastList = basArmMastService.selectList( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("arm_no", basArm.getArmNo()) |
| | | .eq("sorting_line", basArm.getSortingLineSou()) |
| | | .eq("status", 3) |
| | | ); |
| | | if (basArmMastList.isEmpty()){ |
| | | continue; |
| | | } |
| | | CombParam combParam = new CombParam(basArmMastList); |
| | | //arm任务完成自动组托 |
| | | ReturnT<String> result = new PostMesDataUtils().postMesData("arm任务完成自动组托",wmsUrl, wmsComb, combParam); |
| | | if (result.getCode()==200){ |
| | | basArmMastService.updateArmMastStatus(basArm.getArmNo(),basArm.getSortingLineSou(),3,5); |
| | | locMast.setLocSts("R"); |
| | | locMastService.updateById(locMast); |
| | | } else { |
| | | armTaskAssignmentCallApiLogSave(locMast, "自动组托失败", basArm.getStaNoSou()+"码垛位置,===》自动组托失败,等待重试", false); |
| | | // log.error("机械臂抓取任务完成:"+JSON.toJSON(basArmMastList)+"===》自动组托失败,等待重试"); |
| | | } |
| | | } catch (Exception e){ |
| | | armTaskAssignmentCallApiLogSave(locMast, "自动组托失败", basArm.getStaNoSou()+"码垛位置,===》自动组托失败,等待重试", false); |
| | | // log.error("arm编号:"+basArm.getArmNo()+"====》机械臂抓取任务完成"+e.getMessage()); |
| | | } |
| | | break; |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("机械臂抓取任务完成组托失败"+e.getMessage()); |
| | | } |
| | | } |
| | | public synchronized void armMissionAccomplishedScanToCheckIn() { |
| | | try{ |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | |
| | | * */ |
| | | public synchronized void armTaskAssignment() { |
| | | try{ |
| | | List<BasArm> basArmList = basArmService.selectList(new EntityWrapper<>()); |
| | | List<BasArm> basArmList = basArmService.selectList(new EntityWrapper<BasArm>().lt("arm_no",5)); |
| | | for (BasArm basArm : basArmList) { |
| | | if (basArm.getStatus()!=1){ |
| | | if (basArm.getStatus()!=1 || basArm.getArmNo()>4){ |
| | | continue; |
| | | } |
| | | try{ |
| | |
| | | if(!Cools.isEmpty(barcode)) { |
| | | if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | armTaskAssignmentCallApiLogSave(staProtocol, "托盘条码为空", staProtocol.getSiteId()+"码垛位置,===》托盘条码为空", false); |
| | | // log.error(staProtocol.getSiteId()+"码垛位置,===》托盘条码为空"); |
| | | continue; |
| | | } |
| | | } else { |
| | | armTaskAssignmentCallApiLogSave(staProtocol, "托盘条码为空", staProtocol.getSiteId()+"码垛位置,===》托盘条码为空", false); |
| | | |
| | | // log.error(staProtocol.getSiteId()+"码垛位置,===》托盘条码为空"); |
| | | continue; |
| | | } |
| | | |
| | | if(barcode.length()!=6){ |
| | | armTaskAssignmentCallApiLogSave(staProtocol, "条码长度不是6位", staProtocol.getSiteId()+"码垛位置,条码长度不是6位===>>" + barcode, false); |
| | | // log.error(staProtocol.getSiteId()+"码垛位置,条码长度不是6位===>>" + barcode); |
| | | continue; |
| | | // throw new CoolException(staProtocol.getSiteId()+"码垛位置,条码长度不是6位===>>" + barcode); |
| | | } |
| | | |
| | | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",barcode)); |
| | | int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",barcode)); |
| | | int countwait = waitPakinMapper.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",barcode)); |
| | | if (countLoc > 0 || countWrk > 0 || countwait > 0) { |
| | | // throw new CoolException("组托档/工作档/库存条码数据已存在===>>" + barcode); |
| | | armTaskAssignmentCallApiLogSave(staProtocol, "条码数据已存在", staProtocol.getSiteId()+"码垛位置,组托档/工作档/库存条码数据已存在===>>" + barcode, false); |
| | | |
| | | // log.error(staProtocol.getSiteId()+"码垛位置,组托档/工作档/库存条码数据已存在===>>" + barcode); |
| | | continue; |
| | | } |
| | | |
| | |
| | | ); |
| | | if (!basArmMastListError.isEmpty()){ |
| | | armTaskAssignmentCallApiLogSave(staProtocol, "存在异常机械臂任务", basArm.getArmNo()+"号机械臂存在异常数据需要维护!!!", false); |
| | | |
| | | // log.error(basArm.getArmNo()+"号机械臂存在异常数据需要维护!!!"); |
| | | continue; |
| | | } |
| | | List<BasArmMast> basArmMastListRuning = basArmMastService.selectList( |
| | |
| | | List<BasArmMast> basArmMastListRuning3 = basArmMastService.selectList( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("arm_no", basArm.getArmNo()) |
| | | .eq( |
| | | |
| | | "sorting_line", basArm.getSortingLineSou()) |
| | | .eq("sorting_line", basArm.getSortingLineSou()) |
| | | .eq("status", 3) |
| | | ); |
| | | if (basArmMastListRuning.isEmpty() && basArmMastListRuning3.isEmpty()){ |
| | |
| | | } |
| | | if (basArmMastList.size()>1){ |
| | | armTaskAssignmentCallApiLogSave(staProtocol, "任务待执行数量大于1,无法分辨待执行任务", "arm编号:"+basArm.getArmNo()+"====》拆码垛任务异常禁止下发!!!任务待执行数量大于1!!!", false); |
| | | |
| | | // log.error("arm编号:"+basArm.getArmNo()+"====》拆码垛任务异常禁止下发!!!任务待执行数量大于1!!!"); |
| | | continue; |
| | | } |
| | | BasArmMast basArmMast = basArmMastList.get(0); |
| | |
| | | if (basArmMastListOrder.size()==1){ |
| | | Thread.sleep(100); |
| | | |
| | | |
| | | List<BasArmMast> basArmMastListRuningBarCode2 = basArmMastService.selectList( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("barcode", barcode) |
| | | new EntityWrapper<BasArmMast>().eq("barcode", barcode) |
| | | ); |
| | | if (!basArmMastListRuningBarCode2.isEmpty()){ |
| | | int binding_tags = basArmMastService.selectCount( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("status", 2) |
| | | .eq("binding_tags", basArmMast.getBindingTags()) |
| | | ); |
| | | |
| | | .eq("binding_tags", basArmMast.getBindingTags())); |
| | | if (binding_tags<2){ |
| | | BasArmMast basArmMastOne = basArmMastService.selectOne( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("status", 2) |
| | | .eq("binding_tags", basArmMast.getBindingTags()) |
| | | ); |
| | | .eq("binding_tags", basArmMast.getBindingTags())); |
| | | Double anfmeSignOne = basArmMastService.selectBasArmMastSignValue(basArmMastOne.getOrderNo(), basArmMastOne.getMatnr(),basArmMastOne.getBindingTags()); |
| | | |
| | | if (anfmeSignOne>1D){ |
| | | armTaskAssignmentCallApiLogSave(staProtocol, "条码数据已存在!!!", staProtocol.getSiteId()+"码垛位置,条码数据正在自动组托===>>" + barcode, false); |
| | | continue; |
| | |
| | | ArmOrderAssignmentParam armOrderAssignmentParam = new ArmOrderAssignmentParam(basArmMast,orderDetlValueResultUtil); |
| | | // 订单下发(SKU+订单) |
| | | ReturnT<String> result = new PostMesDataUtils().postMesData("机械臂抓取订单(SKU)下发:",ArmConstant.getArmUrl(basArmMast.getArmNo()), ArmConstant.ARM_ADAPTOR, armOrderAssignmentParam); |
| | | if (result.getCode()==200){ |
| | | // basArmMast.setStatus(1); |
| | | // basArmMast.setBarcode(barcode); |
| | | // basArmMastService.updateById(basArmMast); |
| | | } else { |
| | | if (result.getCode()!=200){ |
| | | armTaskAssignmentCallApiLogSave(staProtocol, "机械臂抓取订单(SKU)下发", "arm编号:"+basArm.getArmNo()+"订单下发订单信息下发失败!!!", false); |
| | | |
| | | // log.error("arm编号:"+basArm.getArmNo()+"机械臂抓取订单(SKU)下发:"+JSON.toJSON(basArmMast)+"===》订单信息下发失败"); |
| | | continue; |
| | | } |
| | | } catch (Exception e){ |
| | | armTaskAssignmentCallApiLogSave(staProtocol, "机械臂抓取订单(SKU)下发", "arm编号:"+basArm.getArmNo()+"订单下发订单信息下发失败!!!", false); |
| | | // log.error("arm编号:"+basArm.getArmNo()+"机械臂抓取订单(SKU)下发:"+JSON.toJSON(basArmMast)+"===》订单下发订单信息下发失败"); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | basArmMastService.updateById(basArmMast); |
| | | } else { |
| | | armTaskAssignmentCallApiLogSave(staProtocol, "机械臂抓取任务信息下发失败", "arm编号:"+basArm.getArmNo()+"任务信息下发失败!!!", false); |
| | | // log.error("机械臂抓取任务:"+JSON.toJSON(basArmMast)+"===》任务信息下发失败"); |
| | | } |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("arm编号:"+basArm.getArmNo()+"====》拆码垛任务下发失败"+e.getMessage()); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("arm任务下发失败"+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * arm任务下发 |
| | | * */ |
| | | public synchronized void armTaskAssignment2() { |
| | | try{ |
| | | List<BasArm> basArmList = basArmService.selectList(new EntityWrapper<BasArm>().gt("arm_no",4)); |
| | | for (BasArm basArm : basArmList) { |
| | | if (basArm.getStatus()!=1 || basArm.getArmNo()<5){ |
| | | continue; |
| | | } |
| | | try{ |
| | | LocMast locMastEnd = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", basArm.getStaNoSou())); |
| | | if(!locMastEnd.getLocSts().equals("D")){ |
| | | continue; |
| | | } |
| | | |
| | | String barcode = locMastEnd.getBarcode(); |
| | | if(!Cools.isEmpty(barcode)) { |
| | | if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "0".equals(barcode)) { |
| | | armTaskAssignmentCallApiLogSave(locMastEnd, "托盘条码为空", basArm.getStaNoSou()+"码垛位置,===》托盘条码为空", false); |
| | | continue; |
| | | } |
| | | } else { |
| | | armTaskAssignmentCallApiLogSave(locMastEnd, "托盘条码为空", basArm.getStaNoSou()+"码垛位置,===》托盘条码为空", false); |
| | | continue; |
| | | } |
| | | |
| | | if(barcode.length()!=6){ |
| | | armTaskAssignmentCallApiLogSave(locMastEnd, "条码长度不是6位", basArm.getStaNoSou()+"码垛位置,条码长度不是6位===>>" + barcode, false); |
| | | continue; |
| | | } |
| | | |
| | | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",barcode)); |
| | | int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",barcode)); |
| | | int countwait = waitPakinMapper.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",barcode)); |
| | | if (countLoc > 0 || countWrk > 0 || countwait > 0) { |
| | | armTaskAssignmentCallApiLogSave(locMastEnd, "条码数据已存在", basArm.getStaNoSou()+"码垛位置,组托档/工作档/库存条码数据已存在===>>" + barcode, false); |
| | | continue; |
| | | } |
| | | |
| | | List<BasArmMast> basArmMastListRuningBarCode = basArmMastService.selectList( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("barcode", barcode) |
| | | .eq("status", 3) |
| | | ); |
| | | if (!basArmMastListRuningBarCode.isEmpty()){ |
| | | armTaskAssignmentCallApiLogSave(locMastEnd, "条码数据已存在,正在自动组托!!!", basArm.getStaNoSou()+"码垛位置,条码数据正在自动组托===>>" + barcode, false); |
| | | continue; |
| | | } |
| | | List<BasArmMast> basArmMastListError = basArmMastService.selectList( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("arm_no", basArm.getArmNo()) |
| | | .eq("sorting_line", basArm.getSortingLineSou()) |
| | | .eq("status", 9) |
| | | ); |
| | | if (!basArmMastListError.isEmpty()){ |
| | | armTaskAssignmentCallApiLogSave(locMastEnd, "存在异常机械臂任务", basArm.getArmNo()+"号机械臂存在异常数据需要维护!!!", false); |
| | | continue; |
| | | } |
| | | List<BasArmMast> basArmMastListRuning = basArmMastService.selectList( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("arm_no", basArm.getArmNo()) |
| | | .eq("sorting_line", basArm.getSortingLineSou()) |
| | | .eq("status", 1) |
| | | ); |
| | | List<BasArmMast> basArmMastListRuning3 = basArmMastService.selectList( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("arm_no", basArm.getArmNo()) |
| | | .eq("sorting_line", basArm.getSortingLineSou()) |
| | | .eq("status", 3) |
| | | ); |
| | | if (basArmMastListRuning.isEmpty() && basArmMastListRuning3.isEmpty()){ |
| | | List<BasArmMast> basArmMastList = basArmMastService.selectList( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("arm_no", basArm.getArmNo()) |
| | | .eq("sorting_line", basArm.getSortingLineSou()) |
| | | .eq("sta_no", basArm.getStaNoSou()) |
| | | .eq("status", 0) |
| | | ); |
| | | if (basArmMastList.isEmpty()){ |
| | | continue; |
| | | } |
| | | if (basArmMastList.size()>1){ |
| | | armTaskAssignmentCallApiLogSave(locMastEnd, "任务待执行数量大于1,无法分辨待执行任务", "arm编号:"+basArm.getArmNo()+"====》拆码垛任务异常禁止下发!!!任务待执行数量大于1!!!", false); |
| | | continue; |
| | | } |
| | | BasArmMast basArmMast = basArmMastList.get(0); |
| | | // List<BasArmMast> basArmMastListOrder = basArmMastService.selectList( |
| | | // new EntityWrapper<BasArmMast>() |
| | | // .eq("arm_no", basArm.getArmNo()) |
| | | // .eq("sorting_line", basArm.getSortingLineSou()) |
| | | // .eq("matnr", basArmMast.getMatnr()) |
| | | // .eq("order_no", basArmMast.getOrderNo()) |
| | | // .eq("binding_tags", basArmMast.getBindingTags()) |
| | | // ); |
| | | // if (basArmMastListOrder.size()==1){ |
| | | // OrderDetlValueResultUtil orderDetlValueResultUtil = basArmMastService.selectOrderDetlValue(basArmMast.getOrderNo(), basArmMast.getMatnr()); |
| | | // |
| | | // if (Cools.isEmpty(orderDetlValueResultUtil)){ |
| | | // continue; |
| | | // } |
| | | |
| | | OrderDetlValueResultUtil orderDetlValueResultUtil = new OrderDetlValueResultUtil(); |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", basArmMast.getMatnr())); |
| | | // Double anfmeSign = basArmMastService.selectBasArmMastSignValue(basArmMast.getOrderNo(), basArmMast.getMatnr(),basArmMast.getBindingTags()); |
| | | orderDetlValueResultUtil.setAnfme(1D); |
| | | orderDetlValueResultUtil.setHeight(mat.getHeight()); |
| | | orderDetlValueResultUtil.setWeight(mat.getWeight()); |
| | | orderDetlValueResultUtil.setLength(mat.getManLength()); |
| | | orderDetlValueResultUtil.setWidth(mat.getWidth()); |
| | | //订单下发 |
| | | try{ |
| | | ArmOrderAssignmentParam armOrderAssignmentParam = new ArmOrderAssignmentParam(basArmMast,orderDetlValueResultUtil); |
| | | // 订单下发(SKU+订单) |
| | | ReturnT<String> result = new PostMesDataUtils().postMesData("机械臂抓取订单(SKU)下发:",ArmConstant.getArmUrl(basArmMast.getArmNo()), ArmConstant.ARM_ADAPTOR, armOrderAssignmentParam); |
| | | if (result.getCode()!=200){ |
| | | armTaskAssignmentCallApiLogSave(locMastEnd, "机械臂抓取订单(SKU)下发", "arm编号:"+basArm.getArmNo()+"订单下发订单信息下发失败!!!", false); |
| | | continue; |
| | | } |
| | | } catch (Exception e){ |
| | | armTaskAssignmentCallApiLogSave(locMastEnd, "机械臂抓取订单(SKU)下发", "arm编号:"+basArm.getArmNo()+"订单下发订单信息下发失败!!!", false); |
| | | continue; |
| | | } |
| | | // } |
| | | ArmTaskAssignmentParam armTaskAssignmentParam = new ArmTaskAssignmentParam(basArm.getSortingLine()); |
| | | //设置工作空间就绪 |
| | | ReturnT<String> result = new PostMesDataUtils().postMesData("机械臂抓取任务下发:通知工作空间已就绪",ArmConstant.getArmUrl(basArmMast.getArmNo()), ArmConstant.ARM_WORKSPACE, armTaskAssignmentParam); |
| | | if (result.getCode()==200){ |
| | | basArmMast.setStatus(1); |
| | | basArmMast.setBarcode(barcode); |
| | | basArmMastService.updateById(basArmMast); |
| | | } else { |
| | | armTaskAssignmentCallApiLogSave(locMastEnd, "机械臂抓取任务信息下发失败", "arm编号:"+basArm.getArmNo()+"任务信息下发失败!!!", false); |
| | | } |
| | | } |
| | | } catch (Exception e){ |
| | |
| | | // 如果没有符合条件的记录,或者所有记录时间差大于 5 分钟,保存新的日志 |
| | | apiLogService.save("机械臂任务相关", tableName, "null", staProtocol.getBarcode(), |
| | | "站点号:" + staProtocol.getSiteId(), |
| | | response, bool); |
| | | } |
| | | |
| | | public void armTaskAssignmentCallApiLogSave(LocMast locMast, String tableName, String response, Boolean bool) { |
| | | // 查询符合条件的所有 ApiLog |
| | | List<ApiLog> apiLogs = apiLogService.selectList(new EntityWrapper<ApiLog>() |
| | | .eq("namespace", "机械臂任务相关") |
| | | .eq("request", "站点号:" + locMast.getLocNo()) |
| | | .eq("response", response) |
| | | .eq("url", tableName) |
| | | .eq("client_ip", locMast.getBarcode()) |
| | | .eq("result", 0) |
| | | .orderBy("create_time", false) |
| | | ); |
| | | |
| | | // 遍历结果集,检查时间戳差值是否小于 5 分钟 |
| | | for (ApiLog apiLog : apiLogs) { |
| | | long parseLong = Long.parseLong(apiLog.getTimestamp()); |
| | | if (new Date().getTime() - parseLong < 5 * 1000 * 60) { |
| | | // 如果找到符合条件的记录且时间差小于 5 分钟,则不保存新记录,直接返回 |
| | | return; |
| | | } |
| | | } |
| | | |
| | | // 如果没有符合条件的记录,或者所有记录时间差大于 5 分钟,保存新的日志 |
| | | apiLogService.save("机械臂任务相关", tableName, "null", locMast.getBarcode(), |
| | | "站点号:" + locMast.getLocNo(), |
| | | response, bool); |
| | | } |
| | | |
| | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | if(wrkMast.getStaNo()<2000){ |
| | | basAgvMast.setFloorNo(1); |
| | | }else if(wrkMast.getStaNo()<4000){ |
| | | basAgvMast.setFloorNo(2); |
| | | }else{ |
| | | basAgvMast.setFloorNo(3); |
| | | } |
| | | basAgvMast.setTaskNo(wrkMast.getWrkNo()); |
| | | basAgvMast.setSourceStaNo(outStaAgv.getStaNo()); |
| | | basAgvMast.setLocNo(dto.getLocNo()); |
| | |
| | | basAgvMast.setIoType(2); |
| | | |
| | | basAgvMastService.insert(basAgvMast); |
| | | |
| | | |
| | | |
| | | wrkMast.setTakeNone("2"); |
| | |
| | | |
| | | String barcode = staProtocol.getBarcode(); |
| | | if(!Cools.isEmpty(barcode)) { |
| | | if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | News.info("{}号站点扫描器检测条码信息:{}", outStaAgv.getStaNo(), barcode); |
| | | if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "0".equals(barcode)) { |
| | | // News.info("{}号站点扫描器检测条码信息:{}", outStaAgv.getStaNo(), barcode); |
| | | continue; |
| | | } |
| | | } else { |
| | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | basAgvMast.setTaskNo(outStaAgv.getStaNo()); |
| | | basAgvMast.setSourceStaNo(outStaAgv.getStaNo()); |
| | | basAgvMast.setLocNo(dto.getLocNo()); |
| | | basAgvMast.setDevpId(devp.getId()); |
| | | basAgvMast.setIoType(2); |
| | | basAgvMast.setFloorNo(2); |
| | | |
| | | basAgvMastService.insert(basAgvMast); |
| | | } else { |
| | |
| | | |
| | | BasAgvMast basAgvMast = new BasAgvMast(); |
| | | try { |
| | | List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "R") |
| | | .ge("row1", 23) |
| | | .le("row1", 32) |
| | | .orderBy("io_time",true) |
| | | ); |
| | | List<LocMast> locMastList = null; |
| | | Integer floorNo = 1; |
| | | if(inStaAgv.getStaNo() < 2000){ |
| | | locMastList = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "R") |
| | | .ge("row1", 21) |
| | | .le("row1", 26) |
| | | .orderBy("io_time",true) |
| | | ); |
| | | }else if(inStaAgv.getStaNo() < 4000){ |
| | | locMastList = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "R") |
| | | .ge("row1", 28) |
| | | .le("row1", 31) |
| | | .orderBy("io_time",true)); |
| | | floorNo = 2; |
| | | }else{ |
| | | locMastList = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "R") |
| | | .ge("row1", 32) |
| | | .le("row1", 38) |
| | | .orderBy("io_time",true)); |
| | | floorNo = 3; |
| | | } |
| | | |
| | | for (LocMast locMast : locMastList){ |
| | | basAgvMast.setTaskNo(inStaAgv.getStaNo()); |
| | | basAgvMast.setSourceLocNo(locMast.getLocNo()); |
| | | basAgvMast.setStaNo(inStaAgv.getStaNo()); |
| | | basAgvMast.setDevpId(devp.getId()); |
| | | basAgvMast.setFloorNo(floorNo); |
| | | basAgvMast.setIoType(0);//AGV库位==》输送线站点 0 |
| | | basAgvMastService.insert(basAgvMast); |
| | | break; |
| | |
| | | } |
| | | try{ |
| | | // 获取站点信息 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, basAgvMast.getDevpId()); |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, basAgvMast.getFloorNo() !=1?2:1); |
| | | StaProtocol staProtocol = devpThread.getStation().get(basAgvMast.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | |
| | | } |
| | | |
| | | if (staProtocol.isAutoing()){ |
| | | AgvBindCtnrAndBinParam agvBindCtnrAndBinParam = new AgvBindCtnrAndBinParam(basAgvMast); |
| | | agvBindCtnrAndBinParam.setCtnrCode(basAgvMast.getTimestamp().toString()); |
| | | ReturnT<String> resultBind = new PostMesDataUtils().postMesDataAgv("AGV容器绑定", AgvConstant.AGV_URL, AgvConstant.AGV_CTNRANDBING, agvBindCtnrAndBinParam); |
| | | if (resultBind.getCode()!=200){ |
| | | agvTaskAssignmentCallApiLogSave(basAgvMast, "AGV容器绑定", "任务号:"+basAgvMast.getTaskNo()+"任务信息下发失败!!!", false); |
| | | } |
| | | |
| | | AgvTaskAssignmentParam agvTaskAssignmentParam = new AgvTaskAssignmentParam(basAgvMast); |
| | | |
| | | //任务下发 |
| | | ReturnT<String> result = new PostMesDataUtils().postMesDataAgv("AGV任务下发", AgvConstant.AGV_URL, AgvConstant.AGV_ADAPTOR, agvTaskAssignmentParam); |
| | | if (result.getCode()==200){ |
| | |
| | | } |
| | | try{ |
| | | // 获取站点信息 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, basAgvMast.getDevpId()); |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, basAgvMast.getFloorNo() !=1?2:1); |
| | | StaProtocol staProtocol = devpThread.getStation().get(basAgvMast.getSourceStaNo()); |
| | | if (staProtocol == null || !staProtocol.isLoading()) { |
| | | continue; |
| | |
| | | (basAgvMast.getSourceStaNo().equals(2033))){ |
| | | |
| | | AgvTaskAssignmentParam agvTaskAssignmentParam = new AgvTaskAssignmentParam(basAgvMast); |
| | | |
| | | //任务下发 |
| | | ReturnT<String> result = new PostMesDataUtils().postMesDataAgv("AGV任务下发", AgvConstant.AGV_URL, AgvConstant.AGV_ADAPTOR, agvTaskAssignmentParam); |
| | | if (result.getCode()==200){ |
| | | basAgvMast.setStatus(1); |
| | | basAgvMastService.updateById(basAgvMast); |
| | | } else { |
| | | agvTaskAssignmentCallApiLogSave(basAgvMast, "AGV任务下发失败", "任务号:"+basAgvMast.getTaskNo()+"任务信息下发失败!!!", false); |
| | | if(basAgvMast.getFloorNo()==1 || basAgvMast.getStaNo().equals(2034)) { |
| | | WrkMast wrkMast = wrkMastService.selectByWrkNo(staProtocol.getWorkNo()); |
| | | AgvBindCtnrAndBinParam agvBindCtnrAndBinParam = new AgvBindCtnrAndBinParam(basAgvMast); |
| | | agvBindCtnrAndBinParam.setCtnrCode(wrkMast.getBarcode()); |
| | | agvBindCtnrAndBinParam.setCtnrTyp("1"); |
| | | ReturnT<String> resultBind = new PostMesDataUtils().postMesDataAgv("AGV容器绑定解绑", AgvConstant.AGV_URL, AgvConstant.AGV_CTNRANDBING, agvBindCtnrAndBinParam); |
| | | if (resultBind.getCode()==200){ |
| | | //任务下发 |
| | | ReturnT<String> result = new PostMesDataUtils().postMesDataAgv("AGV任务下发", AgvConstant.AGV_URL, AgvConstant.AGV_ADAPTOR, agvTaskAssignmentParam); |
| | | if (result.getCode()==200){ |
| | | basAgvMast.setStatus(1); |
| | | basAgvMastService.updateById(basAgvMast); |
| | | } else { |
| | | agvTaskAssignmentCallApiLogSave(basAgvMast, "AGV任务下发失败", "任务号:"+basAgvMast.getTaskNo()+"任务信息下发失败!!!", false); |
| | | } |
| | | } else { |
| | | agvTaskAssignmentCallApiLogSave(basAgvMast, "AGV容器绑定解绑", "任务号:"+basAgvMast.getTaskNo()+"任务信息下发失败!!!", false); |
| | | } |
| | | }else{ |
| | | //任务下发 |
| | | ReturnT<String> result = new PostMesDataUtils().postMesDataAgv("AGV任务下发", AgvConstant.AGV_URL, AgvConstant.AGV_ADAPTOR, agvTaskAssignmentParam); |
| | | if (result.getCode()==200){ |
| | | basAgvMast.setStatus(1); |
| | | basAgvMastService.updateById(basAgvMast); |
| | | } else { |
| | | agvTaskAssignmentCallApiLogSave(basAgvMast, "AGV任务下发失败", "任务号:"+basAgvMast.getTaskNo()+"任务信息下发失败!!!", false); |
| | | } |
| | | } |
| | | // |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("任务号:"+basAgvMast.getTaskNo()+"====》AGV任务下发失败"+e.getMessage()); |
| | |
| | | } |
| | | try{ |
| | | // 获取站点信息 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, basAgvMast.getDevpId()); |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, basAgvMast.getFloorNo() !=1?2:1); |
| | | StaProtocol staProtocol = devpThread.getStation().get(basAgvMast.getSourceStaNo()); |
| | | if (staProtocol == null || !staProtocol.isLoading()) { |
| | | continue; |
| | |
| | | if (!Cools.isEmpty(staProtocol.getWorkNo()) && staProtocol.getWorkNo().equals(basAgvMast.getTaskNo())){ |
| | | |
| | | AgvTaskAssignmentParam agvTaskAssignmentParam = new AgvTaskAssignmentParam(basAgvMast); |
| | | |
| | | // AgvBindCtnrAndBinParam agvBindCtnrAndBinParam = new AgvBindCtnrAndBinParam(basAgvMast); |
| | | // |
| | | // ReturnT<String> resultBind = new PostMesDataUtils().postMesDataAgv("AGV容器绑定解绑", AgvConstant.AGV_URL, AgvConstant.AGV_ADAPTOR, agvBindCtnrAndBinParam); |
| | | // if (resultBind.getCode()==200){ |
| | | // //任务下发 |
| | | // ReturnT<String> result = new PostMesDataUtils().postMesDataAgv("AGV任务下发", AgvConstant.AGV_URL, AgvConstant.AGV_ADAPTOR, agvTaskAssignmentParam); |
| | | // if (result.getCode()==200){ |
| | | // basAgvMast.setStatus(1); |
| | | // basAgvMastService.updateById(basAgvMast); |
| | | // } else { |
| | | // agvTaskAssignmentCallApiLogSave(basAgvMast, "AGV任务下发失败", "任务号:"+basAgvMast.getTaskNo()+"任务信息下发失败!!!", false); |
| | | // } |
| | | // } else { |
| | | // agvTaskAssignmentCallApiLogSave(basAgvMast, "AGV容器绑定解绑", "任务号:"+basAgvMast.getTaskNo()+"任务信息下发失败!!!", false); |
| | | // } |
| | | //任务下发 |
| | | ReturnT<String> result = new PostMesDataUtils().postMesDataAgv("AGV任务下发", AgvConstant.AGV_URL, AgvConstant.AGV_ADAPTOR, agvTaskAssignmentParam); |
| | | if (result.getCode()==200){ |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public void agvTaskAssignmentCallApiLogSave(BasAgvMast basAgvMast ,String tableName, String response, Boolean bool) { |
| | | ApiLog apiLog = apiLogService.selectOne(new EntityWrapper<ApiLog>() |
| | | .eq("namespace", "Agv任务下发") |