发送天气资源消息
This commit is contained in:
parent
31cad54e46
commit
7bda68fcab
|
|
@ -18,4 +18,14 @@ public class ResponseCmdInfo<T> 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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<SimtoolWeather> weatherList = weatherService.queryByScenarioUuid(
|
||||
currentScenario.getGuid());
|
||||
WeatherResource weatherList = weatherResourceService.getOne(new QueryWrapper<WeatherResource>()
|
||||
.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<WeatherResource> weatherResourceQueryWrapper = new QueryWrapper<>();
|
||||
weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId()).eq("room_id", roomId);
|
||||
List<WeatherResource> weatherResourceList = this.weatherResourceService.list();
|
||||
weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId());
|
||||
List<WeatherResource> weatherResourceList = this.weatherResourceService.list(weatherResourceQueryWrapper);
|
||||
ResponseCmdInfo<JSONArray> 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) {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user