| | |
| | | } |
| | | List<DeviceConfig> deviceConfigs = fakeDeviceUtils.getFakeDeviceConfig(); |
| | | for (DeviceConfig device : deviceConfigs) { |
| | | if (!device.getDeviceType().equals(String.valueOf(SlaveType.Shuttle))) { |
| | | continue; |
| | | } |
| | | |
| | | excuteFakeCommand(String.valueOf(SlaveType.Shuttle) + device.getDeviceNo(), device); |
| | | } |
| | | }catch (Exception e){ |
| | |
| | | fakeStatus.put("currentCode", JSON.toJSONString(point)); |
| | | fakeStatus.put("deviceStatus", 1);//设备空闲 |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } else if (commandType.equals("move")) { |
| | | boolean firstMove = true; |
| | | |
| | | } else if (commandType.equals("move") || commandType.equals("intoLift") || commandType.equals("outLift")) { |
| | | String baseCommandKey = RedisKeyType.FAKE_SHUTTLE_MOVE_EXECUTE_COMMAND_LIST.key + deviceConfig.getDeviceNo() + "_"; |
| | | Set<String> keys = redisUtil.searchKeys(baseCommandKey); |
| | | |
| | | if (!keys.isEmpty()) { |
| | | firstMove = false; |
| | | while (true) { |
| | | Set<String> keys = redisUtil.searchKeys(baseCommandKey); |
| | | if (keys.isEmpty()) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | JSONObject body = command.getJSONObject("commandBody"); |
| | | String pathList = body.getString("path"); |
| | | List<JSONObject> list = JSON.parseArray(pathList, JSONObject.class); |
| | | |
| | | String finalKey = baseCommandKey + System.currentTimeMillis(); |
| | | redisUtil.set(finalKey, list); |
| | | redisUtil.set(finalKey, true, 60 * 2); |
| | | |
| | | if(!firstMove) { |
| | | return; |
| | | } |
| | | JSONObject body = command.getJSONObject("commandBody"); |
| | | String requestType = body.getString("requestType"); |
| | | String pathList = body.getString("path"); |
| | | List<JSONObject> executePathList = JSON.parseArray(pathList, JSONObject.class); |
| | | |
| | | fakeStatus.put("deviceStatus", 0);//设备忙碌 |
| | | fakeStatusMap.put(key, fakeStatus); |
| | |
| | | break; |
| | | } |
| | | |
| | | while (true) { |
| | | Set<String> searchKeys = redisUtil.searchKeys(baseCommandKey); |
| | | if(searchKeys.isEmpty()) { |
| | | for (JSONObject path : executePathList) { |
| | | while (true) { |
| | | JSONObject realFakeStatus = fakeStatusMap.get(key); |
| | | Integer errorCode = realFakeStatus.getInteger("errorCode"); |
| | | if (errorCode > 0) { |
| | | continue; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | TreeSet<String> treeSet = new TreeSet<>(); |
| | | for (String tmpKey : searchKeys) { |
| | | treeSet.add(tmpKey); |
| | | } |
| | | |
| | | String first = treeSet.first(); |
| | | |
| | | Object object = redisUtil.get(first); |
| | | if(object == null) { |
| | | while (true) { |
| | | if((System.currentTimeMillis() - startTime) < 1000 * 1) { |
| | | continue; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | List<JSONObject> executePathList = (List<JSONObject>) object; |
| | | for (JSONObject path : executePathList) { |
| | | while (true) { |
| | | JSONObject realFakeStatus = fakeStatusMap.get(key); |
| | | Integer errorCode = realFakeStatus.getInteger("errorCode"); |
| | | if (errorCode > 0) { |
| | | continue; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | while (true) { |
| | | if((System.currentTimeMillis() - startTime) < 1000 * 1) { |
| | | continue; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | String currentCode = fakeStatus.getString("currentCode"); |
| | | JSONObject point = JSON.parseObject(currentCode); |
| | | point.put("x", path.getInteger("xp")); |
| | | point.put("y", path.getInteger("yp")); |
| | | point.put("z", path.getInteger("z")); |
| | | fakeStatus.put("currentCode", JSON.toJSONString(point)); |
| | | fakeStatus.put("deviceStatus", 0);//设备忙碌 |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | startTime = System.currentTimeMillis(); |
| | | } |
| | | redisUtil.del(first); |
| | | String currentCode = fakeStatus.getString("currentCode"); |
| | | JSONObject point = JSON.parseObject(currentCode); |
| | | point.put("x", path.getInteger("xp")); |
| | | point.put("y", path.getInteger("yp")); |
| | | point.put("z", path.getInteger("z")); |
| | | fakeStatus.put("currentCode", JSON.toJSONString(point)); |
| | | fakeStatus.put("deviceStatus", 0);//设备忙碌 |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | startTime = System.currentTimeMillis(); |
| | | } |
| | | |
| | | fakeStatus.put("deviceStatus", 1);//设备空闲 |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | redisUtil.del(finalKey); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | } else if (requestType.equals("updateFloor")) { |
| | | fakeCommandMap.put(String.valueOf(SlaveType.Shuttle) + device.getDeviceNo(), fakeCommand); |
| | | response = genereateFakeCommandResponse(requestId, taskId, requestType); |
| | | } else if (requestType.equals("move")) { |
| | | } else if (requestType.equals("move") || requestType.equals("intoLift") || requestType.equals("outLift")) { |
| | | fakeCommandMap.put(String.valueOf(SlaveType.Shuttle) + device.getDeviceNo(), fakeCommand); |
| | | response = genereateFakeCommandResponse(requestId, taskId, requestType); |
| | | } else if (requestType.equals("readState")) { |