| | |
| | | import com.zy.common.model.SearchLocParam; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.CollectionUtils; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.News; |
| | | import com.zy.core.CrnThread; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | |
| | | public short wrkNo = 11000; |
| | | |
| | | /** |
| | | * 组托 |
| | | * 入库站,根据条码扫描生成入库工作档,工作状态 2 |
| | |
| | | if (barcodeThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | String barcode = barcodeThread.getBarcode(); |
| | | //9998退回,9996空板 |
| | | if (!Cools.isEmpty(barcode) && (staProtocol.getWorkNo() != 9998 || staProtocol.getWorkNo() != 9996)) { |
| | | log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | staProtocol.setWorkNo((short) 9998); |
| | | staProtocol.setStaNo((short) 14); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = "扫码失败,请重试"; |
| | | News.error(methodName + ":扫码失败,请重试"); |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | continue; |
| | | } |
| | | } else { |
| | | continue; |
| | | // 尺寸检测异常 |
| | | boolean back = false; |
| | | String errMsg = ""; |
| | | if (staProtocol.isFrontErr()) { |
| | | errMsg = "前超限"; |
| | | back = true; |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | // 获取入库站信息 |
| | | // SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | |
| | | |
| | | // 入出库模式判断 |
| | | // if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; } |
| | | // if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { |
| | | // continue; |
| | | // } |
| | | // 退回 |
| | | if (back) { |
| | | // News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); |
| | | if(!staProtocol.isOutEnable()){ |
| | | continue; |
| | | } |
| | | |
| | | if (!staProtocol.isLoading()){ |
| | | continue; |
| | | } |
| | | if (!staProtocol.isPakMk()) { |
| | | continue; |
| | | } |
| | | staProtocol.setWorkNo(wrkNo); |
| | | News.info("{}入库回退:{},任务号:{}", inSta.getStaNo(), errMsg,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, errMsg)); |
| | | } |
| | | //拣料、盘点任务,不进入新板入库方法,直接跳出 |
| | | if(staProtocol.getWorkNo()>=3001 && staProtocol.getWorkNo()<=6000){ |
| | | continue; |
| | | } |
| | | // 判断是否满足入库条件 |
| | | if (staProtocol.isAutoing() |
| | | && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | | && !staProtocol.isEmptyMk() |
| | | && (staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9997 || staProtocol.getWorkNo() == 9995) |
| | | && staProtocol.isPakMk()) {// && !Cools.isEmpty(barcode)) { |
| | | && staProtocol.isPakMk() && !back) {// && !Cools.isEmpty(barcode)) { |
| | | |
| | | // if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | // News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | // //条码为空或者不符合,退库到172站点 |
| | | // staProtocol.setWorkNo((short)9999); |
| | | // staProtocol.setStaNo((short)172); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | // boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // if (!result) { |
| | | // throw new CoolException("更新plc站点信息失败"); |
| | | if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) { |
| | | News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | //条码为空或者不符合,退库到172站点 |
| | | staProtocol.setWorkNo(wrkNo); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | wrkNo++; |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | continue; |
| | | } |
| | | // //判断101和104是否是拣料、并板、盘点再入库 设备暂不支持101、104站盘点/拣料入库 |
| | | // WrkMast wrkMast1=wrkMastMapper.selectpj(inSta.getStaNo(),barcode); |
| | | // if(!Cools.isEmpty(wrkMast1)){ |
| | | // if (wrkMast1.getIoType()!=1){ |
| | | // continue; |
| | | // } |
| | | // } |
| | | // if( !Cools.isEmpty(barcode)&&!Cools.isEmpty(wrkMast1)){ |
| | | // log.error("101或104拣料、并板、盘点再入库", wrkMast1.getWrkNo()); |
| | | // continue; |
| | | // } |
| | | |
| | | // 判断重复工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); |
| | | if (wrkMast != null) { |
| | | News.error(methodName + ":工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo()); |
| | | if (ledThread != null) { |
| | | News.error(methodName + ":扫码失败,请重试"); |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, "工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={" + wrkMast.getWrkNo() + "}, 请手动取消已存在工作档")); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("barcode", barcode) |
| | | .eq("io_type", 103)); |
| | | .in("io_type", 107,103,104,57,53)); |
| | | if (!Cools.isEmpty(checkPick)) { |
| | | continue; |
| | | } else { |
| | | News.info("新板入库条码===>>" + barcode); |
| | | } |
| | | // WrkMast checkPick2 = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | // .eq("barcode", barcode) |
| | | // .in("io_type", 57,53)); |
| | | // if (!Cools.isEmpty(checkPick2)) { |
| | | // continue; |
| | | // } |
| | | |
| | | try { |
| | | |
| | |
| | | param.setLocType1(locTypeDto.getLocType1()); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setTimeout(30, TimeUnit.SECONDS) |
| | | .setPath("/rpc/pakin/loc/v1") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | News.error(methodName + ":更新plc站点信息失败"); |
| | | News.error(methodName + ":更新plc站点信息失败"); |
| | | |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | }else { |
| | | ledThread.errorReset(); |
| | | } |
| | | |
| | | if (ledThread != null) { |
| | | String successMsg = "入库工作档--工作号:" + dto.getWorkNo() + " 目标库位:" + dto.getLocNo(); |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, successMsg)); |
| | | } |
| | | |
| | | } else { |
| | | staProtocol.setWorkNo((short) 9998); |
| | | staProtocol.setStaNo((short) 14); |
| | | staProtocol.setWorkNo(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); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // // 入出库模式判断 |
| | | if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { |
| | | continue; |
| | | } |
| | | // if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { |
| | | // continue; |
| | | // } |
| | | |
| | | // 判断是否满足入库条件 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() |
| | |
| | | News.error(methodName + ":更新工作档失败!!! [工作号:{}]", wrkMast.getWrkNo()); |
| | | } |
| | | } else { |
| | | News.error(methodName +":发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | News.error(methodName + ":发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | String barcode = barcodeThread.getBarcode(); |
| | | |
| | | if (!Cools.isEmpty(barcode) && (staProtocol.getWorkNo() != 9998 || staProtocol.getWorkNo() != 9996)) { |
| | | log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode); |
| | | if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | staProtocol.setWorkNo((short) 9998); |
| | | staProtocol.setStaNo((short) 14); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = "扫码失败,请重试"; |
| | | News.error(methodName + ":扫码失败,请重试"); |
| | | MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); |
| | | WrkMast wrkMast1 = wrkMastMapper.selectPickStep1(staProtocol.getWorkNo().intValue()); |
| | | |
| | | //任务号如果在工作档中存在,就不用去判断条码 |
| | | if(Cools.isEmpty(wrkMast1)) { |
| | | // WrkMast mast = wrkMastMapper.selectPickStep(barcode); |
| | | // if (Cools.isEmpty(mast)) { |
| | | // break; |
| | | // } |
| | | |
| | | if (!Cools.isEmpty(barcode)) { |
| | | |
| | | |
| | | // log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode); |
| | | if ("NG".endsWith(barcode) || "NoRead".equals(barcode) && staProtocol.isPakMk()) { |
| | | if (!staProtocol.isLoading()) { |
| | | continue; |
| | | } |
| | | if (!staProtocol.isPakMk()) { |
| | | continue; |
| | | } |
| | | if (staProtocol.getWorkNo() != 0) { |
| | | continue; |
| | | } |
| | | |
| | | staProtocol.setWorkNo(wrkNo); |
| | | wrkNo++; |
| | | 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 = "扫码失败,请重试"; |
| | | News.error(methodName + ":扫码失败,请重试"); |
| | | MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | continue; |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | |
| | | |
| | |
| | | && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | | && !staProtocol.isEmptyMk() |
| | | && (staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9997 || staProtocol.getWorkNo() == 9995) |
| | | // && (staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9997 || staProtocol.getWorkNo() == 9995) |
| | | && staProtocol.isPakMk()) { |
| | | |
| | | WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); |
| | | WrkMast wrkMast = null; |
| | | //优先查询任务号对应的工作档有没有,如果有的话就不用查条码号 |
| | | wrkMast = wrkMastMapper.selectPickStep1(staProtocol.getWorkNo().intValue()); |
| | | if(Cools.isEmpty(wrkMast)) { |
| | | wrkMast = wrkMastMapper.selectPickStep(barcode); |
| | | } |
| | | // WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue()); |
| | | if (wrkMast == null) { |
| | | // 无拣料数据 |
| | |
| | | || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { |
| | | continue; |
| | | } |
| | | LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", wrkMast.getSourceLocNo())); |
| | | |
| | | |
| | | |
| | | // 拣、盘、并 作业站转换 |
| | | // int stnNo = 0; |
| | |
| | | // 获取目标站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", wrkMast.getIoType() - 50) |
| | | //速腾特有捡料, 11站是出库站, 然后手动走到15站进行再入库 |
| | | .eq("stn_no", 15) // 作业站点 = 拣料出库的目标站 |
| | | .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站 |
| | | .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号 |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)) { |
| | |
| | | locMast.setLocSts("Q"); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)) { |
| | | News.error(methodName+ ":修改库位状态失败"); |
| | | News.error(methodName + ":修改库位状态失败"); |
| | | |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | continue; |
| | | } |
| | | |
| | | if (ledThread != null) { |
| | | ledThread.errorReset(); |
| | | } |
| | | // 更新站点信息 且 下发plc命令 |
| | | 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) { |
| | | News.error(methodName + ":发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | |
| | |
| | | wrkMast.setCrnEndTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) != 0) { |
| | | // 复位堆垛机 |
| | | News.info("crnStnToOutStn堆垛机复位时工作号===>>" + crnProtocol.getTaskNo()); |
| | | crnThread.setResetFlag(true); |
| | | } else { |
| | | News.error(methodName + ":更新工作档的工作状态为14失败!!! [工作号:{}]", wrkMast.getWrkNo()); |
| | |
| | | |
| | | /** |
| | | * 入库 ===>> 堆垛机站到库位 |
| | | * 根据入库时间进行排序入库,同一堆垛机先查询所有工作档任务号,再根据优先级、时间排序,确保先进先出 |
| | | */ |
| | | public synchronized void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol) { |
| | | for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) { |
| | | boolean flag = false; |
| | | // 获取堆垛机入库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | // 查询站点详细信息 |
| | | BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); |
| | | if (staDetl == null) { |
| | | log.error("入库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo()); |
| | | continue; |
| | | } |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable() |
| | | && staDetl.getCanining()!=null && staDetl.getCanining().equals("Y")) { |
| | | flag = true; |
| | | } |
| | | if (!flag) { |
| | | continue; |
| | | } |
| | | // 获取工作状态为2(设备上走)的入库工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(),crnStn.getStaNo()); |
| | | if(null == wrkMast) { |
| | | log.error("查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | | continue; |
| | | } |
| | | // 获取库位信息 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (locMast == null) { |
| | | log.error("查询库存无数据--库位号{}", wrkMast.getLocNo()); |
| | | continue; |
| | | } |
| | | if (!locMast.getLocSts().equals("S") && !locMast.getLocSts().equals("Q")) { |
| | | log.error("入库操作库位状态不符合--状态, 库位号={},库位状态={}", wrkMast.getLocNo(), locMast.getLocSts()); |
| | | continue; |
| | | } |
| | | CrnThread crnThreadNow = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo()); |
| | | CrnProtocol crnProtocolNow = crnThreadNow.getCrnProtocol(); |
| | | |
| | | // 堆垛机控制过滤 |
| | | if (!crnProtocolNow.getStatusType().equals(CrnStatusType.IDLE) || crnProtocolNow.getTaskNo() != 0) { |
| | | continue; |
| | | } |
| | | |
| | | // 已经存在吊车执行任务时,则过滤 |
| | | if (wrkMastMapper.selectWorking(slave.getId()) != null) { |
| | | break; |
| | | // return; |
| | | } |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | | crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.PAKIN); // 任务模式: 库位移转 |
| | | crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY(crnStn.getBay().shortValue()); // 源库位列 |
| | | crnCommand.setSourcePosZ(crnStn.getLev().shortValue()); // 源库位层 |
| | | crnCommand.setDestinationPosX(locMast.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 目标库位层 |
| | | log.error("1"+crnCommand+crnProtocol); |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | System.err.println("入库到库位命令下发"); |
| | | // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(3L); |
| | | wrkMast.setCrnStrTime(now); |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 入库 ===>> 堆垛机站到库位 |
| | | * 根据入库时间进行排序入库 |
| | | */ |
| | | public synchronized void crnStnToLoc2(CrnSlave slave, CrnProtocol crnProtocol) { |
| | | String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); |
| | | List<WrkMast> wrkMasts= new ArrayList<>(); |
| | | //指针 |
| | | int count=-1; |
| | | int i=0; |
| | | |
| | | WrkMast wrkMast=null; |
| | | CrnSlave.CrnStn crnStn1=null; |
| | | for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) { |
| | | boolean flag = false; |
| | | // 获取堆垛机入库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | // 查询站点详细信息 |
| | | BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); |
| | | if (staDetl == null) { |
| | | News.error(methodName + ":入库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo()); |
| | | continue; |
| | | } |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable() |
| | | && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) { |
| | | flag = true; |
| | | // 获取工作状态为2(设备上走)的入库工作档 |
| | | wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo()); |
| | | if (null == wrkMast) { |
| | | // News.error("查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | | continue; |
| | | } |
| | | //打擂台 |
| | | wrkMasts.add(wrkMast); |
| | | count++; |
| | | if(count==0) continue; |
| | | if(wrkMast.getWrkDate().getTime()<wrkMasts.get(i).getWrkDate().getTime() && wrkMast.getIoPri()>=wrkMasts.get(i).getIoPri()) |
| | | i=count; |
| | | crnStn1=crnStn; |
| | | } |
| | | if (!flag) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | |
| | | if(!Cools.isEmpty(wrkMasts)){ |
| | | wrkMast=wrkMasts.get(i); |
| | | // 获取库位信息 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (locMast != null) { |
| | | if (locMast.getLocSts().equals("S") && locMast.getLocSts().equals("Q")) { |
| | | // 堆垛机控制过滤 |
| | | if (crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() == 0) { |
| | | // 已经存在吊车执行任务时,则过滤 |
| | | if (wrkMastMapper.selectWorking(slave.getId()) == null) { |
| | | // 双深库位且浅库位有货,则需先对浅库位进行库位移转 |
| | | // if (Utils.isDeepLoc(slaveProperties, wrkMast.getLocNo())) { |
| | | // String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getLocNo()); |
| | | // LocMast shallowLoc = locMastService.selectById(shallowLocNo); |
| | | // // O.空库位、Q.拣料/盘点/并板再入库、S.入库预约、X.禁用 直接搬! |
| | | // if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) { |
| | | // WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); |
| | | // if (null == waitWrkMast) { |
| | | // News.error(methodName + ":{}库位异常,未检索到相应工作档!", shallowLocNo); |
| | | // } else { |
| | | // waitWrkMast.setIoPri(15D); |
| | | // waitWrkMast.setModiTime(new Date()); |
| | | // if (wrkMastMapper.updateById(waitWrkMast) == 0) { |
| | | // News.error(methodName + ":调整工作档优先级失败!工作号={}", waitWrkMast.getWrkNo()); |
| | | // } |
| | | // continue; |
| | | // } |
| | | // |
| | | // } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { |
| | | // // 此标记避免多次执行移库任务 |
| | | // if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) { |
| | | // wrkMast.setUpdMk("Y"); |
| | | // wrkMast.setIoPri(14D); |
| | | // wrkMastMapper.updateById(wrkMast); |
| | | // // 生成工作档,将浅库位移转到新的库位中 |
| | | // moveLocForDeepLoc(slave, shallowLoc); |
| | | // // 生成工作档、改变浅库位的源库/目标库 库位状态、下发堆垛机命令(立马执行) |
| | | //// moveLocForDeepLocPakin(slave, shallowLoc, wrkMast); |
| | | // } |
| | | // continue; |
| | | // } else if (shallowLoc.getLocSts().equals("Q")) { |
| | | // WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); |
| | | // if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) { |
| | | // continue; |
| | | // } |
| | | // } |
| | | // } |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | | crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转 |
| | | crnCommand.setSourcePosX(crnStn1.getRow().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY(crnStn1.getBay().shortValue()); // 源库位列 |
| | | crnCommand.setSourcePosZ(crnStn1.getLev().shortValue()); // 源库位层 |
| | | crnCommand.setDestinationPosX(locMast.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 目标库位层 |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | News.error(methodName + ":堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | |
| | | // long startTime = System.currentTimeMillis(); |
| | | // while ((System.currentTimeMillis() - startTime) < COMMAND_TIMEOUT) { |
| | | // |
| | | // if (true) { |
| | | // break; |
| | | // } |
| | | // |
| | | // try{ |
| | | // Thread.sleep(500); |
| | | // }catch(Exception ignore){} |
| | | // } |
| | | |
| | | // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(3L); |
| | | wrkMast.setCrnStrTime(now); |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | News.error(methodName + ":修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }else News.error(methodName + ":入库操作库位状态不符合--状态, 库位号={},库位状态={}", wrkMast.getLocNo(), locMast.getLocSts()); |
| | | }else News.error(methodName + ":查询库存无数据--库位号{}", wrkMast.getLocNo()); |
| | | } |
| | | } |
| | | |
| | | public synchronized void crnStnToLoc1(CrnSlave slave, CrnProtocol crnProtocol) { |
| | | String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); |
| | | |
| | | for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) { |
| | |
| | | */ |
| | | public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol) { |
| | | String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); |
| | | |
| | | for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) { |
| | | // 获取工作状态为11(生成出库ID)的出库工作档 |
| | | // WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo()); |
| | | List<WrkMast> wrkMasts = wrkMastMapper.selectPakOutStep11(slave.getId(), crnStn.getStaNo()); |
| | | //按照工作档出库 |
| | | List<WrkMast> wrkMasts = wrkMastService.selectWrkIoType(slave.getId()); |
| | | if (!Cools.isEmpty(wrkMasts)) { |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | if (wrkMast == null) { |
| | | CrnSlave.CrnStn crnStn = null; |
| | | for (CrnSlave.CrnStn crnStn1 : slave.getCrnOutStn()) { |
| | | if (wrkMast.getSourceStaNo().equals(crnStn1.getStaNo())) { |
| | | crnStn = crnStn1; |
| | | break; |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | if (Cools.isEmpty(crnStn)) { |
| | | continue; |
| | | } |
| | | // 工作档状态判断 |
| | | if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null) { |
| | | News.error(methodName + ":查询工作档数据不符合条件--入出类型/站点, 工作号={},源库位={},入出类型={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType()); |
| | | if (wrkMast.getSourceStaNo() == null) { |
| | | log.error("查询工作档数据不符合条件--入出类型/站点, 工作号={},源库位={},入出类型={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType()); |
| | | continue; |
| | | } |
| | | |
| | | // 获取源库位信息 |
| | | LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) { |
| | |
| | | |
| | | // // 入出库模式判断 |
| | | // if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; } |
| | | if (wrkMast.getStaNo() == 204 && devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { |
| | | continue; |
| | | } |
| | | // if (wrkMast.getStaNo() == 204 && devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { |
| | | // continue; |
| | | // } |
| | | |
| | | // 查询站点详细信息 |
| | | BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); |
| | |
| | | // continue; |
| | | } |
| | | // 判断堆垛机出库站状态 |
| | | |
| | | if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") |
| | | && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | // 获取目标库位信息 |
| | | LocMast sta = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (null == sta) { |
| | | News.error(methodName + ":工作档库位移转失败,原因:检索目标库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getLocNo()); |
| | | News.error(methodName + ":工作档库位移转失败,原因:检索目标库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getLocNo()); |
| | | return; |
| | | } |
| | | // 获取堆垛机信息 并 判断是否可入出 |
| | |
| | | } |
| | | // 入库 + 库位转移 ==> 4.入库完成 |
| | | if (wrkMast.getWrkSts() == 3 || (wrkMast.getWrkSts() == 12 && wrkMast.getIoType() == 11)) { |
| | | log.error("入库完成堆垛机任务=========》"+JSON.toJSONString(wrkMast)); |
| | | wrkMast.setWrkSts(4L); |
| | | } else { |
| | | continue; |
| | |
| | | // 修改成功后复位堆垛机 |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | // 堆垛机复位 |
| | | News.info("storeFinished堆垛机复位时工作号===>>" + crnProtocol.getTaskNo()); |
| | | crnThread.setResetFlag(true); |
| | | } |
| | | } |
| | |
| | | && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | | && staProtocol.isEmptyMk() |
| | | && (staProtocol.getWorkNo() == 9996) |
| | | && staProtocol.isPakMk()) { |
| | | |
| | | try { |
| | |
| | | param.setLocType1(locTypeDto.getLocType1()); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setTimeout(30, TimeUnit.SECONDS) |
| | | .setPath("/rpc/pakin/loc/v1") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | |
| | | * 出库 ===>> 工作档信息写入led显示器 |
| | | */ |
| | | public synchronized void ledExecute() { |
| | | String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); |
| | | |
| | | for (LedSlave led : slaveProperties.getLed()) { |
| | | // 获取输送线plc线程 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | |
| | | } |
| | | // 获取工作档数据 |
| | | WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); |
| | | // if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; } |
| | | if (null == wrkMast) { |
| | | continue; |
| | | } |
| | | if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; } |
| | | wrkMasts.add(wrkMast); |
| | | // 组装命令 |
| | | LedCommand ledCommand = new LedCommand(); |
| | |
| | | ledCommand.setIoType(wrkMast.getIoType()); |
| | | // 出库模式 |
| | | switch (wrkMast.getIoType()) { |
| | | case -1: |
| | | ledCommand.setTitle("全板入库"); |
| | | break; |
| | | case 10: |
| | | ledCommand.setTitle("空板入库"); |
| | | break; |
| | | case 10-1: |
| | | case 101: |
| | | ledCommand.setTitle("全板出库"); |
| | | break; |
| | | case 103: |
| | |
| | | ledCommand.setEmptyMk(true); |
| | | break; |
| | | default: |
| | | News.error(methodName + ":任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); |
| | | News.error("任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); |
| | | break; |
| | | } |
| | | ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); |
| | | ledCommand.setLocNo(wrkMast.getLocNo()); |
| | | ledCommand.setStaNo(wrkMast.getStaNo()); |
| | | // ledCommand.setSourceStaNo(wrkMast.getSourceStaNo()); |
| | | if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { |
| | | ledCommand.setBarcode(wrkMast.getBarcode()); |
| | | if (wrkMast.getIoType() != 110) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); |
| | | wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme()))); |
| | | |
| | | wrkDetls.forEach(wrkDetl -> { |
| | | Double total = 0.0; |
| | | EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); |
| | | LocDetl locDetl = locDetlService.selectOne(wrapper.eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr())); |
| | | if (!Cools.isEmpty(locDetl)) { |
| | | total = locDetl.getAnfme(); |
| | | } |
| | | if (wrkMast.getIoType() == 101) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | if (wrkMast.getIoType() == 103 && (null == wrkDetl.getInspect() || 0 == wrkDetl.getInspect())) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | if (wrkMast.getIoType() == 107) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | }); |
| | | } |
| | | commands.add(ledCommand); |
| | | } |
| | |
| | | // 获取LED线程 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // 相同工作号集合则过滤 |
| | | // if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { |
| | | // continue; |
| | | // } |
| | | if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { |
| | | continue; |
| | | } |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | if (!commands.isEmpty()) { |
| | | String errMsg = ""; |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | News.error(methodName + ":{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { |
| | | News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | } else { |
| | | ledThread.setLedMk(false); |
| | | // News.info("{}号LED命令下发成功!!![ip:{}] [port:{}] [port:{}]", led.getId(), led.getIp(), led.getPort(),commands); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | try { |
| | |
| | | * 其他 ===>> LED显示器复位,显示默认信息 |
| | | */ |
| | | public synchronized void ledReset() { |
| | | // for (LedSlave led : slaveProperties.getLed()) { |
| | | // // 获取输送线plc线程 |
| | | // DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | | // // 命令集合 |
| | | // boolean reset = true; |
| | | // for (Integer staNo : led.getStaArr()) { |
| | | // // 获取叉车站点 |
| | | // StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | // if (staProtocol == null) { |
| | | // continue; |
| | | // } else { |
| | | // staProtocol = staProtocol.clone(); |
| | | // } |
| | | // if (staProtocol.getWorkNo() != 0) { |
| | | // reset = false; |
| | | // break; |
| | | // } |
| | | // } |
| | | // // 获取led线程 |
| | | // LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId()); |
| | | // // led显示默认内容 |
| | | // if (reset) { |
| | | // if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { |
| | | // News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // } |
| | | // } |
| | | // } |
| | | for (LedSlave led : slaveProperties.getLed()) { |
| | | // 获取输送线plc线程 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | |
| | | for (Integer staNo : led.getStaArr()) { |
| | | // 获取叉车站点 |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } |
| | | if (staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) { |
| | | StaProtocol staProtocol1 = devpThread.getStation().get(staNo+1); |
| | | if (staProtocol == null) { continue; } |
| | | if (staProtocol1 == null) { continue; } |
| | | if (staProtocol.getWorkNo() != 0 || staProtocol.isLoading()) { |
| | | reset = false; |
| | | break; |
| | | } |
| | | if (staProtocol1.isLoading() || staProtocol1.getWorkNo() != 0) { |
| | | reset = false; |
| | | break; |
| | | } |
| | | if (!staProtocol.isLoading() && staProtocol.getWorkNo() == 0 && !staProtocol1.isLoading() && staProtocol1.getWorkNo() == 0){ |
| | | // News.error("{}号LED入库口2个站点都没有数据,准备reset复位显示器!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | } |
| | | } |
| | | // // 获取led线程 |
| | | // LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // // led显示默认内容 |
| | | // if (reset && !ledThread.isLedMk()) { |
| | | // if (led.getId() == 7) { |
| | | // ledThread.setLedMk(true); |
| | | // if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { |
| | | // News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // } else { |
| | | // |
| | | // } |
| | | // } else { |
| | | // ledThread.setLedMk(true); |
| | | // if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { |
| | | // News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // } else { |
| | | // |
| | | // } |
| | | // } |
| | | // } |
| | | // 获取led线程 |
| | | // LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId()); |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // led显示默认内容 |
| | | if (reset) { |
| | | //News.info("{}号LED命令重置!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | if (ledThread == null) { |
| | | continue; |
| | | } |
| | | ledThread.errorReset(); |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { |
| | | News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * 入出库模式切换函数 |
| | | */ |
| | | public synchronized void ioConvert() { |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | if (inSta.getStaNo() == 2) { |
| | | continue; |
| | | } |
| | | WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getStaNo()); |
| | | switch (inSta.getStaNo()) { |
| | | case 203://1F |
| | | if (pakout != null) { |
| | | if (devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { |
| | | // 出库切换中 |
| | | devpThread.ioModeOf2F = IoModeType.PAKOUT_BOOTING; |
| | | WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo()); |
| | | if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading() |
| | | && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading() |
| | | && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) { |
| | | // 出库模式 |
| | | devpThread.ioModeOf2F = IoModeType.PAKOUT_MODE; |
| | | } |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf2F = IoModeType.PAKIN_MODE; |
| | | } |
| | | break; |
| | | case 401://1F |
| | | if (pakout != null) { |
| | | if (devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) { |
| | | // 出库切换中 |
| | | devpThread.ioModeOf4F = IoModeType.PAKOUT_BOOTING; |
| | | WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo()); |
| | | if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading() |
| | | && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading() |
| | | && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) { |
| | | // 出库模式 |
| | | devpThread.ioModeOf4F = IoModeType.PAKOUT_MODE; |
| | | } |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf4F = IoModeType.PAKIN_MODE; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | // public synchronized void ioConvert() { |
| | | // try { |
| | | // // 根据输送线plc遍历 |
| | | // for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | // |
| | | // for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | // if (inSta.getStaNo() == 2) { |
| | | // continue; |
| | | // } |
| | | // WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getStaNo()); |
| | | // switch (inSta.getStaNo()) { |
| | | // case 203://1F |
| | | // if (pakout != null) { |
| | | // if (devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { |
| | | // // 出库切换中 |
| | | // devpThread.ioModeOf2F = IoModeType.PAKOUT_BOOTING; |
| | | // WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo()); |
| | | // if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading() |
| | | // && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading() |
| | | // && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) { |
| | | // // 出库模式 |
| | | // devpThread.ioModeOf2F = IoModeType.PAKOUT_MODE; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // // 入库模式 |
| | | // devpThread.ioModeOf2F = IoModeType.PAKIN_MODE; |
| | | // } |
| | | // break; |
| | | // case 401://1F |
| | | // if (pakout != null) { |
| | | // if (devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) { |
| | | // // 出库切换中 |
| | | // devpThread.ioModeOf4F = IoModeType.PAKOUT_BOOTING; |
| | | // WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo()); |
| | | // if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading() |
| | | // && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading() |
| | | // && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) { |
| | | // // 出库模式 |
| | | // devpThread.ioModeOf4F = IoModeType.PAKOUT_MODE; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // // 入库模式 |
| | | // devpThread.ioModeOf4F = IoModeType.PAKIN_MODE; |
| | | // } |
| | | // break; |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // |
| | | // |
| | | // } |
| | | public synchronized void outOfDevp() { |
| | | List<WrkMast> wrkMasts = wrkMastMapper.selectPick(); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | |
| | | try { |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setTimeout(30, TimeUnit.SECONDS) |
| | | .setPath("/rpc/auto/emptyOut/v1") |
| | | .build() |
| | | .doPost(); |
| | |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setTimeout(30, TimeUnit.SECONDS) |
| | | .setPath("/rpc/auto/emptyIn/v1") |
| | | .setJson(JSON.toJSONString(locTypeDto)) |
| | | .build() |