| | |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.mapper.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.CommandUtils; |
| | | import com.zy.asrs.utils.RouteUtils; |
| | | import com.zy.asrs.utils.TrackRangeUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.asrs.utils.*; |
| | | import com.zy.common.model.MatDto; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.CollectionUtils; |
| | |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if (!Cools.isEmpty(barcode) && !barcode.equals("99999999")) { |
| | | // 请求wms接口,获取工作号和目标库位 |
| | | ToWmsDTO toWmsDTO = new ToWmsDTO(barcode, staProtocol.getSiteId(), 0); |
| | | ToWmsDTO toWmsDTO = new ToWmsDTO(staProtocol.getSiteId(),staProtocol.getGrossWt(),barcode, 0); |
| | | TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode)); |
| | | if (!Cools.isEmpty(taskWrk1)) { |
| | | log.info("托盘码:" + barcode + "任务档存在"); |
| | |
| | | |
| | | // 判断是否满足入库条件 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() && (workNo == 0 || (workNo>9000 && workNo<10000)) |
| | | // && staProtocol.isInEnable() |
| | | && (workNo == 0 || (workNo>9000 && workNo<10000)) |
| | | && staProtocol.isPakMkWalk() |
| | | ) { |
| | | if (inSta.isBarcodeSign()){ |
| | |
| | | } else { |
| | | staProtocol.setWorkNo(taskWrk1.getWrkNo()); |
| | | staProtocol.setStaNo(staDesc.getCrnStn()); |
| | | devpThread.setPakMkWalk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } else { |
| | | TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>()); |
| | | TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("IO_TYPE",1).eq("WRK_STS",1).eq("START_POINT",staProtocol.getSiteId().toString())); |
| | | |
| | | if (!Cools.isEmpty(taskWrk1)) { |
| | | if (taskWrk1.getIoType() == 1 && taskWrk1.getStartPoint().equals(staProtocol.getSiteId().toString())) { |
| | |
| | | return; |
| | | } else { |
| | | staProtocol.setWorkNo(taskWrk1.getWrkNo()); |
| | | staProtocol.setStaNo(staDesc.getCrnStn()); |
| | | staProtocol.setStaNo(BarcodeUtils.getStaNo(staProtocol.getSiteId())); |
| | | devpThread.setPakMkWalk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | Date now = new Date(); |
| | | // taskWrk1.setStatus(TaskStatusType.DISTRIBUTE.id);//派发状态 |
| | | // taskWrk.setAssignTime(now);//派发时间 |
| | | taskWrk1.setExecuteTime(now); |
| | | taskWrk1.setWrkSts(2);//工作状态 3.吊车入库 |
| | | taskWrk1.setCrnNo(staDesc.getCrnNo());//堆垛机号 |
| | | taskWrk1.setModiTime(now); |
| | | taskWrk1.setModiUser(9988L); |
| | | taskWrkService.updateById(taskWrk1); |
| | | |
| | | |
| | | } |
| | | } |
| | | return; |
| | |
| | | log.info("下发输送线任务:taskWrk:" + JSON.toJSONString(taskWrk)); |
| | | // R r = siteController.siteDetlUpdate(Integer.valueOf(taskWrk.getTargetPoint()), taskWrk.getWrkNo().shortValue(), (short) 0, "Y", false, false); |
| | | staProtocol.setWorkNo(taskWrk.getWrkNo()); |
| | | staProtocol.setStaNo(staDesc.getCrnStn()); |
| | | staProtocol.setStaNo(BarcodeUtils.getStaNo(staProtocol.getSiteId())); |
| | | boolean offer = false; |
| | | try { |
| | | offer = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | |
| | | if (offer) { |
| | | log.info("下发输送线任务成功:taskWrk:" + JSON.toJSONString(taskWrk)); |
| | | Date now = new Date(); |
| | | taskWrk.setStatus(5); |
| | | taskWrk.setStatus(9); |
| | | taskWrk.setWrkSts(14); |
| | | taskWrk.setModiTime(now); |
| | | taskWrk.setCompleteTime(now); |
| | |
| | | crnCommand.setDestinationPosY(Utils.getBayShort(taskWrk.getTargetPoint())); // 目标库位层 |
| | | crnCommand.setDestinationPosZ(Utils.getLevShort(taskWrk.getTargetPoint())); // 目标库位排 |
| | | crnCommand.setCommand((short) 1); |
| | | if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand), false)) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令生成失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | throw new CoolException("堆垛机命令生成失败"); |
| | | } else { |
| | |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("taskNo", taskWrk.getTaskNo()); |
| | | headParam.put("status", taskWrk.getStatus()); |
| | | headParam.put("ioType", taskWrk.getIoType()); |
| | | headParam.put("ioType", taskWrk.getIoTypeWms()); |
| | | headParam.put("barcode", taskWrk.getBarcode()); |
| | | String response; |
| | | response = new HttpHandler.Builder() |
| | |
| | | command.setDestinationPosY(crnStn.getBay().shortValue()); // 目标库位列 |
| | | command.setDestinationPosZ(crnStn.getLev().shortValue()); // 目标库位层 |
| | | command.setCommand((short) 1); |
| | | if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, command), false)) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, command))) { |
| | | log.error("堆垛机命令生成失败,堆垛机号={},巷道={},任务数据={}", slave.getId(), taskWrk.getCrnNo(), JSON.toJSON(command)); |
| | | throw new CoolException("堆垛机命令生成失败"); |
| | | } else { |
| | |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("taskNo", taskWrk.getTaskNo()); |
| | | headParam.put("status", taskWrk.getStatus()); |
| | | headParam.put("ioType", taskWrk.getIoType()); |
| | | headParam.put("ioType", taskWrk.getIoTypeWms()); |
| | | headParam.put("barcode", taskWrk.getBarcode()); |
| | | String response; |
| | | response = new HttpHandler.Builder() |
| | |
| | | crnCommand.setDestinationPosY(Utils.getBayShort(taskWrk.getTargetPoint())); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(Utils.getLevShort(taskWrk.getTargetPoint())); // 目标库位层 |
| | | crnCommand.setCommand((short) 1); |
| | | if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand), false)) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 11.生成出库ID => 12.吊车出库中 |
| | |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("taskNo", taskWrk.getTaskNo()); |
| | | headParam.put("status", taskWrk.getStatus()); |
| | | headParam.put("ioType", taskWrk.getIoType()); |
| | | headParam.put("ioType", taskWrk.getIoTypeWms()); |
| | | headParam.put("barcode", taskWrk.getBarcode()); |
| | | String response; |
| | | response = new HttpHandler.Builder() |
| | |
| | | } |
| | | |
| | | // 状态:等待确认 并且 任务完成位 = 1 |
| | | if (!Cools.isEmpty(crnProtocol.getTaskFinish()) && crnProtocol.getTaskFinish() == 0 && crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) { |
| | | if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) { |
| | | //获取入库待确认工作档 |
| | | TaskWrk taskWrk = taskWrkMapper.selectCrnNoInWorking(crnProtocol.getLaneNo(), crnProtocol.getTaskNo().intValue()); |
| | | if (Cools.isEmpty(taskWrk) && crnProtocol.getTaskNo() != 999) { |
| | | log.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},巷道号={},工作号={}", crn.getId(), crnProtocol.getLaneNo(), crnProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | Thread.sleep(300); |
| | | // Thread.sleep(300); |
| | | //确认完成信号 |
| | | CrnOperatorParam crnOperatorParam = new CrnOperatorParam(); |
| | | crnOperatorParam.setCrnNo(crn.getId()); |
| | |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("taskNo", taskWrk.getTaskNo()); |
| | | headParam.put("status", taskWrk.getStatus()); |
| | | headParam.put("ioType", taskWrk.getIoType()); |
| | | headParam.put("ioType", taskWrk.getIoTypeWms()); |
| | | headParam.put("barcode", taskWrk.getBarcode()); |
| | | String response; |
| | | log.error("wcs完结任务上报wms==》", headParam); |
| | |
| | | if (rgvProtocol == null || rgvTaskProtocol == null) { |
| | | return false; |
| | | } |
| | | if (!rgvProtocol.getModeType().equals(RgvModeType.AUTO) || rgvProtocol.getRgvPos().equals(0L) || rgvTaskProtocol.getAvoid() == -1 || rgvProtocol.getRgvPosDestination() == 0L |
| | | if (!rgvProtocol.getModeType().equals(RgvModeType.AUTO) || rgvProtocol.getRgvPos().equals(0L) || rgvTaskProtocol.getAvoid() == -1 |
| | | || (!rgvProtocol.getStatusType().equals(RgvStatusType.IDLE) && !rgvProtocol.getStatusType().equals(RgvStatusType.ROAM))) { |
| | | return false; |
| | | } |
| | |
| | | // 判断是否满足取货条件 |
| | | if (staProtocol.isAutoing() |
| | | // && staProtocol.isLoading() |
| | | && staProtocol.isStaOk() |
| | | && staProtocol.getWorkNo() != 0) { |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(staProtocol.getWorkNo().toString()); |
| | | TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo()); |
| | | if (taskWrk != null) { |
| | | return taskWrk; |
| | | } |
| | |
| | | if (taskWrk == null) { |
| | | return false; |
| | | } |
| | | Integer targetPointConvert = taskWrk.getTargetPointConvert(); |
| | | // Integer targetPointConvert = taskWrk.getTargetPointConvert(); |
| | | Integer targetPointConvert = BarcodeUtils.getOutStaNo(taskWrk.getOriginTargetPoint()); |
| | | if (targetPointConvert == null) { |
| | | return false; |
| | | } |
| | | RgvSlave.RgvStn rgvStnEnd = getRgvStnNow(rgvSlave, targetPointConvert); |
| | | if (rgvStnEnd == null) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | BasDevpPosition basDevpPositionEnd = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", targetPointConvert)); |
| | | //执行 |
| | | issuedTake.setTaskNo(Long.valueOf(taskWrk.getTaskNo())); |
| | | issuedTake.setTaskStatus(1); |
| | | issuedTake.setTaskStatus(2); |
| | | issuedTake.setTaskNoDirection(issuedTake.gettaskNoDirection$(issuedTake.getTaskNo(), issuedTake.getTaskStatus())); |
| | | issuedTake.setTargetPosition(basDevpPositionSou.getPlcPosition()); |
| | | issuedTake.setIsRunning(1); |
| | | issuedTake.setDirection(rgvStn.isDirection()); |
| | | issuedTake.setDirection(basDevpPositionSou.getRgvSign()==1); |
| | | |
| | | |
| | | issuedPut.setTaskNo(Long.valueOf(taskWrk.getTaskNo())); |
| | | issuedPut.setTaskStatus(2); |
| | | issuedPut.setTaskStatus(3); |
| | | issuedPut.setTaskNoDirection(issuedPut.gettaskNoDirection$(issuedPut.getTaskNo(), issuedPut.getTaskStatus())); |
| | | issuedPut.setTargetPosition(basDevpPositionEnd.getPlcPosition()); |
| | | issuedPut.setIsRunning(1); |
| | | issuedPut.setDirection(rgvStnEnd.isDirection()); |
| | | issuedPut.setDirection(basDevpPositionEnd.getRgvSign()==1); |
| | | } catch (Exception e) { |
| | | log.error("任务生成失败issued1===》异常信息:{}", e.getMessage()); |
| | | return false; |
| | |
| | | } |
| | | // 获取工作档数据 |
| | | LedCommand ledCommand = new LedCommand(); |
| | | //请求wms |
| | | |
| | | // |
| | | // ledCommand.setWorkNo(wrkMast.getWrkNo()); |
| | | // ledCommand.setIoType(wrkMast.getIoType()); |
| | | // ledCommand.setTitle("空板出库"); |
| | | // ledCommand.setEmptyMk(true); |
| | | // ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); |
| | | // ledCommand.setLocNo(wrkMast.getLocNo()); |
| | | // ledCommand.setStaNo(wrkMast.getStaNo()); |
| | | MatDto matDto = new MatDto(); |
| | | ledCommand.getMatDtos().add(matDto); |
| | | commands.add(ledCommand); |
| | | } |
| | | Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); |