| | |
| | | // 解析小车移动工作档 |
| | | mainService.analyzeMoveTask(); |
| | | // 出库 ===>> 工作档信息写入led显示器 |
| | | // mainService.ledExecute(); |
| | | mainService.ledExecute(); |
| | | // 其他 ===>> LED显示器复位,显示默认信息 |
| | | mainService.ledReset(); |
| | | // 穿梭车 ===>> 小车电量检测充电 |
| | |
| | | .eq(BasLed::getDeviceId, ledDevice.getId())); |
| | | List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class); |
| | | |
| | | BasConveyor basConveyor = basConveyorService.getById(new LambdaQueryWrapper<BasConveyor>() |
| | | BasConveyor basConveyor = basConveyorService.getOne(new LambdaQueryWrapper<BasConveyor>() |
| | | .eq(BasConveyor::getDeviceId, led.getConveyorId().intValue())); |
| | | if (basConveyor == null) { |
| | | continue; |
| | |
| | | for (Integer staNo : staArr) { |
| | | // 获取叉车站点 |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { |
| | | if (null == staProtocol || null == staProtocol.getWorkNo()) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | // 获取工作档数据 |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, staProtocol.getWorkNo())); |
| | | if (null == task) { |
| | | if (!staProtocol.isOutEnable()){ |
| | | continue; |
| | | } |
| | | |
| | | tasks.add(task); |
| | | // 组装命令 |
| | | LedCommand ledCommand = new LedCommand(); |
| | | ledCommand.setWorkNo(task.getTaskNo()); |
| | | ledCommand.setIoType(task.getTaskCtg().intValue()); |
| | | ledCommand.setTitle(task.getTaskCtg$()); |
| | | ledCommand.setSourceLocNo(task.getOriginLoc()); |
| | | ledCommand.setLocNo(task.getDestLoc()); |
| | | ledCommand.setStaNo(Integer.parseInt(task.getDestSite())); |
| | | |
| | | String taskNo = "0"; |
| | | if (0 != staProtocol.getWorkNo()){ |
| | | Motion motion = motionService.getOne(new LambdaQueryWrapper<Motion>().eq(Motion::getMotionCtg, 9).eq(Motion::getTemp, staProtocol.getWorkNo())); |
| | | // 获取工作档数据 |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, motion.getTaskNo())); |
| | | if (null == task) { |
| | | continue; |
| | | } |
| | | taskNo = task.getWmsTaskNo(); |
| | | } |
| | | try { |
| | | //获取WMS地址 |
| | | Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, "WMS_URL").eq(Dict::getStatus, 1)); |
| | |
| | | String wmsUrl = dict.getValue(); |
| | | |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | | param.put("taskNo", task.getTaskNo()); |
| | | param.put("taskNo", taskNo); |
| | | param.put("sta",staNo); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/queryTask") |
| | | .setPath("/rpc/led/getTask") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | List<MatDto> matDtos = JSON.parseArray(jsonObject.getString("data"), MatDto.class); |
| | | ledCommand.setMatDtos(matDtos); |
| | | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | commands.add(ledCommand); |
| | | } |
| | | // 获取LED线程 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, ledDevice.getId().intValue()); |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | if (!commands.isEmpty()) { |
| | | ledThread.write(commands); |
| | | ledThread.setLedMk(false); |
| | | } |
| | | } |
| | | } |
| | |
| | | private LocService locService; |
| | | @Autowired |
| | | private DictService dictService; |
| | | @Autowired |
| | | private BasConveyorStaService basConveyorStaService; |
| | | |
| | | @Scheduled(cron = "0/1 * * * * ? ") |
| | | @Transactional |
| | |
| | | .eq(Task::getStatus, 1) |
| | | .in(Task::getTaskSts, taskSts)); |
| | | for (Task task : tasks) { |
| | | Motion motion = motionService.getOne(new LambdaQueryWrapper<Motion>().eq(Motion::getMotionCtg, 9).eq(Motion::getTaskNo, task.getTaskNo())); |
| | | List<BasConveyorSta> conveyorStas = basConveyorStaService.list(new LambdaQueryWrapper<BasConveyorSta>().in(BasConveyorSta::getTaskNo, motion.getTemp())); |
| | | if (!conveyorStas.isEmpty()) { |
| | | continue; |
| | | } |
| | | if (reportWms != null && reportWms.getValue().equals("true")) { |
| | | //获取WMS地址 |
| | | Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, "WMS_URL").eq(Dict::getStatus, 1)); |
| | |
| | | OperateResult write1 = null; // 工作号 |
| | | OperateResult write2 = null; // 目标站 |
| | | |
| | | // write1 = siemensS7Net.Write(workNoAddress, workNo); // 工作号 |
| | | // write2 = siemensS7Net.Write(staNoAddress, staNo); // 目标站 |
| | | |
| | | write1 = siemensS7Net.Write(workNoAddress, (int) workNo); // 工作号 |
| | | write2 = siemensS7Net.Write(staNoAddress, (int) staNo); // 目标站 |
| | | |
| | | if ((write1.IsSuccess && write2.IsSuccess)) { |
| | | log.info("写入输送线命令后返回成功,并且回读成功。输送线plc编号={},{},{}", siteId, JSON.toJSON(workNo), JSON.toJSON(staNo)); |
| | | return true; |
| | | }else { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", device.getId(), JSON.toJSON(array))); |
| | | log.error("写入输送线站点数据失败。输送线plc编号={},站点数据={}", device.getId(), JSON.toJSON(array)); |
| | | return false; |
| | | } |
| | | //任务下发次数 |
| | | int writeCount = 0; |
| | | do { |
| | | write1 = siemensS7Net.Write(workNoAddress, (int) workNo); // 工作号 |
| | | write2 = siemensS7Net.Write(staNoAddress, (int) staNo); |
| | | if ((write1.IsSuccess && write2.IsSuccess)) { |
| | | OperateResultExOne<byte[]> readResult = siemensS7Net.Read(staNoAddress, (short) 8); |
| | | if (readResult.IsSuccess) { |
| | | int staNo2 = siemensS7Net.getByteTransform().TransInt32(readResult.Content, 0); |
| | | int workNo2 = siemensS7Net.getByteTransform().TransInt32(readResult.Content, 4); |
| | | if (workNo == workNo2 && staNo == staNo2) { |
| | | //任务命令写入成功 |
| | | log.info("写入输送线命令后返回成功,并且回读成功。输送线plc编号={},{},{},写入次数={}", siteId, JSON.toJSON(workNo), JSON.toJSON(staNo), writeCount); |
| | | return true; |
| | | } else {//返回结果是成功了,但是真实值不相同 |
| | | writeCount++; |
| | | log.error("写入输送线命令后返回成功,但是读取任务值不一致。输送线plc编号={},{},{},写入次数={}", siteId, JSON.toJSON(workNo), JSON.toJSON(staNo), writeCount); |
| | | } |
| | | } else { |
| | | writeCount++; |
| | | log.error("写入输送线命令后读取失败。输送线plc编号={},站点数据={},{},写入次数={}", siteId, JSON.toJSON(workNo), JSON.toJSON(staNo), writeCount); |
| | | } |
| | | }else { |
| | | writeCount++; |
| | | } |
| | | }while (writeCount < 5) ; |
| | | // StaProtocol staProtocol = station.get(siteId); |
| | | // if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) { |
| | | // staProtocol.setPakMk(true); |
| | | // } |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", device.getId(), JSON.toJSON(array))); |
| | | log.error("写入输送线站点数据失败。输送线plc编号={},站点数据={}", device.getId(), JSON.toJSON(array)); |
| | | return false; |
| | | } |
| | | |
| | | @Override |