diff --git a/src/main/java/com/hivekion/common/entity/ResponseCmdInfo.java b/src/main/java/com/hivekion/common/entity/ResponseCmdInfo.java index 5b14df8..e06fce2 100644 --- a/src/main/java/com/hivekion/common/entity/ResponseCmdInfo.java +++ b/src/main/java/com/hivekion/common/entity/ResponseCmdInfo.java @@ -18,4 +18,14 @@ public class ResponseCmdInfo implements java.io.Serializable { private String room; private Integer scenarioId; private T data; + + @Override + public String toString() { + return "ResponseCmdInfo{" + + "cmdType='" + cmdType + '\'' + + ", room='" + room + '\'' + + ", scenarioId=" + scenarioId + + ", data=" + data + + '}'; + } } diff --git a/src/main/java/com/hivekion/scenario/service/impl/ScenarioTaskServiceImpl.java b/src/main/java/com/hivekion/scenario/service/impl/ScenarioTaskServiceImpl.java index d835449..ce50287 100644 --- a/src/main/java/com/hivekion/scenario/service/impl/ScenarioTaskServiceImpl.java +++ b/src/main/java/com/hivekion/scenario/service/impl/ScenarioTaskServiceImpl.java @@ -20,6 +20,7 @@ import com.hivekion.scenario.service.TaskLogicService; import com.hivekion.thread.SpringGlobalTaskManager; import java.time.format.DateTimeFormatter; import java.util.List; +import javax.annotation.PostConstruct; import javax.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -51,23 +52,25 @@ public class ScenarioTaskServiceImpl extends @Resource private TaskLogicService taskLogicService; + @Override public void start(Integer id, String roomId) { //想定当前持续时间 - redisUtil.hset(roomId + "_" + id, "duringTime", 0); + redisUtil.hset(roomId + "_" + id, "duringTime", "0"); //想定当前状态 redisUtil.hset(roomId + "_" + id, "states", "running"); Scenario currentScenario = scenarioService.getScenarioById(id); //查询天气数据 - List weatherList = weatherService.queryByScenarioUuid( - currentScenario.getGuid()); + WeatherResource weatherList = weatherResourceService.getOne(new QueryWrapper() + .eq("scenario_id",id)); +// currentScenario.getGuid()); //放入天气数据 - redisUtil.hset(roomId + "_" + id, "weather", weatherList); + redisUtil.hset(roomId + "_" + id, "weather", weatherList.getWeatherType()); //查询任务 ScenarioTask queryTask = new ScenarioTask(); queryTask.setScenarioId(id); - redisUtil.hset(roomId + "_" + id, "taskList", queryTaskList(queryTask)); + redisUtil.hset(roomId + "_" + id, "taskList", queryTaskList(queryTask).get(0).getTaskType()); new Thread(() -> { springGlobalTaskManager.startPerSecondTask(roomId + "_" + id + "_task", () -> { @@ -122,8 +125,8 @@ public class ScenarioTaskServiceImpl extends private void weatherTrigger(Scenario currentScenario, String roomId) { try { QueryWrapper weatherResourceQueryWrapper = new QueryWrapper<>(); - weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId()).eq("room_id", roomId); - List weatherResourceList = this.weatherResourceService.list(); + weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId()); + List weatherResourceList = this.weatherResourceService.list(weatherResourceQueryWrapper); ResponseCmdInfo responseCmdInfo = new ResponseCmdInfo(); responseCmdInfo.setScenarioId(currentScenario.getId()); responseCmdInfo.setRoom(roomId); @@ -137,6 +140,7 @@ public class ScenarioTaskServiceImpl extends responseCmdInfo.setCmdType("66-" + weatherResource.getWeatherType()); } responseCmdInfo.setData(weatherMsgArray); + System.out.println(responseCmdInfo.toString()); Global.sendCmdInfoQueue.add(responseCmdInfo); } catch (Exception ex) {