From 45007d9b8f7527fbbc267bbed7b3d4b363b40576 Mon Sep 17 00:00:00 2001 From: wangwenhua <12345678> Date: Sun, 14 Sep 2025 15:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=94=E8=B1=A1=E8=B5=84=E6=BA=90=E8=AE=BE?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ScenarioTaskServiceImpl.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) 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 c69cee8..83a7e70 100644 --- a/src/main/java/com/hivekion/scenario/service/impl/ScenarioTaskServiceImpl.java +++ b/src/main/java/com/hivekion/scenario/service/impl/ScenarioTaskServiceImpl.java @@ -1,10 +1,14 @@ package com.hivekion.scenario.service.impl; +import cn.hutool.json.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hivekion.Global; import com.hivekion.baseData.entity.Scenario; +import com.hivekion.baseData.entity.WeatherResource; +import com.hivekion.baseData.service.IWeatherResourceService; import com.hivekion.baseData.service.ScenarioService; +import com.hivekion.common.entity.ResponseCmdInfo; import com.hivekion.common.redis.RedisUtil; import com.hivekion.environment.entity.SimtoolWeather; import com.hivekion.environment.service.SimtoolWeatherService; @@ -12,6 +16,9 @@ import com.hivekion.scenario.entity.ScenarioTask; import com.hivekion.scenario.mapper.ScenarioTaskMapper; import com.hivekion.scenario.service.ScenarioTaskService; import com.hivekion.thread.SpringGlobalTaskManager; + +import java.text.SimpleDateFormat; +import java.time.format.DateTimeFormatter; import java.util.List; import javax.annotation.Resource; import org.apache.commons.lang3.StringUtils; @@ -39,6 +46,9 @@ public class ScenarioTaskServiceImpl extends @Resource private ScenarioService scenarioService; + @Resource + private IWeatherResourceService weatherResourceService; + @Override public void start(Integer id, String roomId) { //想定当前持续时间 @@ -109,6 +119,25 @@ public class ScenarioTaskServiceImpl extends * @param roomId 房间ID */ private void weatherTrigger(Scenario currentScenario, String roomId) { + try { + QueryWrapper weatherResourceQueryWrapper = new QueryWrapper<>(); + weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId()).eq("room_id", roomId); + WeatherResource weatherResource = this.weatherResourceService.getOne(weatherResourceQueryWrapper); + ResponseCmdInfo responseCmdInfo = new ResponseCmdInfo(); + responseCmdInfo.setScenarioId(currentScenario.getId()); + responseCmdInfo.setRoom(roomId); + JSONObject weatherMsg = new JSONObject(); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + weatherMsg.putOnce("begTime", dtf.format(weatherResource.getLastBegTime())); + weatherMsg.putOnce("endTime", dtf.format(weatherResource.getLastEndTime())); + responseCmdInfo.setCmdType("66-" + weatherResource.getWeatherType()); + responseCmdInfo.setData(weatherMsg); + Global.sendCmdInfoQueue.add(responseCmdInfo); + }catch (Exception ex){ + ex.printStackTrace(); + log.error(ex.getMessage()); + } + }