| | |
| | | |
| | | R result = openUtils.createInTask(createInTaskParam); |
| | | News.info("创建入库任务,任务数据={},WMS响应={},请求响应={}", JSON.toJSON(param), JSON.toJSON(jsonObject), JSON.toJSON(result)); |
| | | try{ |
| | | String msg = ""; |
| | | HashMap<String, String> hashMap = new HashMap<>(); |
| | | hashMap.put("msg", msg); |
| | | hashMap.put("sta", "31001"); |
| | | new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/led/getError") |
| | | .setJson(JSON.toJSONString(hashMap)) |
| | | .build() |
| | | .doPost(); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | |
| | | }else { |
| | | String msg = jsonObject.getString("msg"); |
| | | HashMap<String, String> hashMap = new HashMap<>(); |
| | | hashMap.put("msg", msg); |
| | | hashMap.put("sta", "31001"); |
| | | new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/led/getError") |
| | | .setJson(JSON.toJSONString(hashMap)) |
| | | .build() |
| | | .doPost(); |
| | | News.error("入库申请失败,任务数据={},请求响应={}", JSON.toJSON(param), JSON.toJSON(jsonObject)); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | |
| | | //将地图数据存入redis |
| | | redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(map)); |
| | | redisUtil.set(DeviceRedisConstant.BASE_MAP + lev, JSON.toJSONString(map)); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | continue; |
| | | } |
| | | |
| | | //解析前判断内部目标值是否有物 有工作号 |
| | | StaProtocol staProtocolInside = devpThread.getStation().get(Utils.getStaByLev(Utils.getLev(task.getDestLoc()))); |
| | | if (staProtocolInside == null) { |
| | | continue; |
| | | } |
| | | if (staProtocolInside.isLoading() || staProtocolInside.getWorkNo() !=0) { |
| | | continue; |
| | | } |
| | | |
| | | if (Cools.isEmpty(task.getShuttleNo())) { |
| | | //分配小车 |
| | |
| | | .eq(BasLed::getDeviceId, ledDevice.getId())); |
| | | List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class); |
| | | |
| | | BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId().intValue()); |
| | | 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) { |
| | | continue; |
| | | } |
| | | String taskNo = "0"; |
| | | if (staProtocol.isOutEnable() && staProtocol.getSiteId() == 31001 ){ |
| | | 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(); |
| | | } |
| | | |
| | | 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())); |
| | | } else if (staProtocol.isInEnable() && staProtocol.getSiteId() == 31002) { |
| | | taskNo = staProtocol.getStaNo().toString(); |
| | | } |
| | | |
| | | try { |
| | | //获取WMS地址 |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |