气象资源设定
This commit is contained in:
parent
31b7510ec7
commit
45007d9b8f
|
@ -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<WeatherResource> weatherResourceQueryWrapper = new QueryWrapper<>();
|
||||
weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId()).eq("room_id", roomId);
|
||||
WeatherResource weatherResource = this.weatherResourceService.getOne(weatherResourceQueryWrapper);
|
||||
ResponseCmdInfo<JSONObject> 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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user