Compare commits

...

2 Commits

Author SHA1 Message Date
wangwenhua
1525954f1a Merge branch 'main' of http://git.hivekion.com:3000/liyudong/simulation-backend 2025-09-14 18:34:57 +08:00
wangwenhua
7bda68fcab 发送天气资源消息 2025-09-14 18:33:09 +08:00
2 changed files with 20 additions and 6 deletions

View File

@ -18,4 +18,14 @@ public class ResponseCmdInfo<T> implements java.io.Serializable {
private String room; private String room;
private Integer scenarioId; private Integer scenarioId;
private T data; private T data;
@Override
public String toString() {
return "ResponseCmdInfo{" +
"cmdType='" + cmdType + '\'' +
", room='" + room + '\'' +
", scenarioId=" + scenarioId +
", data=" + data +
'}';
}
} }

View File

@ -21,6 +21,7 @@ import com.hivekion.statistic.service.StatisticService;
import com.hivekion.thread.SpringGlobalTaskManager; import com.hivekion.thread.SpringGlobalTaskManager;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -54,6 +55,7 @@ public class ScenarioTaskServiceImpl extends
@Resource @Resource
private TaskLogicService taskLogicService; private TaskLogicService taskLogicService;
@Override @Override
public void start(Integer id, String roomId) { public void start(Integer id, String roomId) {
log.info("id::{},roomId::{}",id,roomId); log.info("id::{},roomId::{}",id,roomId);
@ -67,14 +69,15 @@ public class ScenarioTaskServiceImpl extends
//查询天气数据 //查询天气数据
List<SimtoolWeather> weatherList = weatherService.queryByScenarioUuid( WeatherResource weatherList = weatherResourceService.getOne(new QueryWrapper<WeatherResource>()
currentScenario.getGuid()); .eq("scenario_id",id));
// currentScenario.getGuid());
//放入天气数据 //放入天气数据
redisUtil.hset(roomId + "_" + id, "weather", weatherList); redisUtil.hset(roomId + "_" + id, "weather", weatherList.getWeatherType());
//查询任务 //查询任务
ScenarioTask queryTask = new ScenarioTask(); ScenarioTask queryTask = new ScenarioTask();
queryTask.setScenarioId(id); queryTask.setScenarioId(id);
redisUtil.hset(roomId + "_" + id, "taskList", queryTaskList(queryTask)); redisUtil.hset(roomId + "_" + id, "taskList", queryTaskList(queryTask).get(0).getTaskType());
new Thread(() -> { new Thread(() -> {
springGlobalTaskManager.startPerSecondTask(roomId + "_" + id + "_task", () -> { springGlobalTaskManager.startPerSecondTask(roomId + "_" + id + "_task", () -> {
@ -135,8 +138,8 @@ public class ScenarioTaskServiceImpl extends
private void weatherTrigger(Scenario currentScenario, String roomId) { private void weatherTrigger(Scenario currentScenario, String roomId) {
try { try {
QueryWrapper<WeatherResource> weatherResourceQueryWrapper = new QueryWrapper<>(); QueryWrapper<WeatherResource> weatherResourceQueryWrapper = new QueryWrapper<>();
weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId()).eq("room_id", roomId); weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId());
List<WeatherResource> weatherResourceList = this.weatherResourceService.list(); List<WeatherResource> weatherResourceList = this.weatherResourceService.list(weatherResourceQueryWrapper);
ResponseCmdInfo<JSONArray> responseCmdInfo = new ResponseCmdInfo(); ResponseCmdInfo<JSONArray> responseCmdInfo = new ResponseCmdInfo();
responseCmdInfo.setScenarioId(currentScenario.getId()); responseCmdInfo.setScenarioId(currentScenario.getId());
responseCmdInfo.setRoom(roomId); responseCmdInfo.setRoom(roomId);
@ -150,6 +153,7 @@ public class ScenarioTaskServiceImpl extends
responseCmdInfo.setCmdType("66-" + weatherResource.getWeatherType()); responseCmdInfo.setCmdType("66-" + weatherResource.getWeatherType());
} }
responseCmdInfo.setData(weatherMsgArray); responseCmdInfo.setData(weatherMsgArray);
System.out.println(responseCmdInfo.toString());
Global.sendCmdInfoQueue.add(responseCmdInfo); Global.sendCmdInfoQueue.add(responseCmdInfo);
} catch (Exception ex) { } catch (Exception ex) {