Compare commits

..

No commits in common. "45a832f7777faa9c060068eca3d98e5d9f5375a0" and "e02e19c2d1a1de70ec8f97e511d866899054b0a1" have entirely different histories.

View File

@ -3,18 +3,12 @@ package com.hivekion.thread;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.hivekion.Global;
import com.hivekion.baseData.entity.Scenario;
import com.hivekion.baseData.entity.WeatherResource;
import com.hivekion.baseData.service.impl.ScenarioServiceImpl;
import com.hivekion.baseData.service.impl.WeatherResourceServiceImpl;
import com.hivekion.common.entity.RequestCmdInfo;
import com.hivekion.common.entity.ResponseCmdInfo;
import com.hivekion.room.RoomManager;
import com.hivekion.room.bean.Room;
import com.hivekion.scenario.entity.ScenarioResource;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
@ -45,10 +39,8 @@ public class HandleReceiveRunnable implements Runnable {
//消息分发业务bean处理
if (SpringUtil.getBean(WebsocketMsgWrapper.class) != null) {
try {
WebsocketMsgWrapper websocketMsgWrapper = SpringUtil.getBean(
WebsocketMsgWrapper.class);
websocketMsgWrapper.msgHandle(requestCmdInfo.getScenarioId(),
requestCmdInfo.getRoom(),
WebsocketMsgWrapper websocketMsgWrapper = SpringUtil.getBean(WebsocketMsgWrapper.class);
websocketMsgWrapper.msgHandle(requestCmdInfo.getScenarioId(), requestCmdInfo.getRoom(),
requestCmdInfo.getResourceId(), requestCmdInfo.getMessage());
} catch (Exception e) {
log.error("error::", e);
@ -60,6 +52,8 @@ public class HandleReceiveRunnable implements Runnable {
}
} catch (Exception e) {
log.error("error::", e);
}
@ -76,9 +70,6 @@ public class HandleReceiveRunnable implements Runnable {
case "get_room_info":
handleGetRootInfo(requestCmdInfo);
break;
case "get_weather":
handleGetWeather(requestCmdInfo);
break;
default:
break;
@ -139,32 +130,4 @@ public class HandleReceiveRunnable implements Runnable {
});
}
}
private void handleGetWeather(RequestCmdInfo requestCmdInfo) {
//获取想定
Scenario scenario = SpringUtil.getBean(ScenarioServiceImpl.class)
.getScenarioById(requestCmdInfo.getScenarioId());
LocalDateTime startTime = scenario.getStartTime();
Room room = RoomManager.getRoom(requestCmdInfo.getRoom());
if (room != null) {
long duringTime = room.getDuringTime();
List<WeatherResource> weatherList = SpringUtil.getBean(WeatherResourceServiceImpl.class)
.list();
weatherList.forEach(weatherResource -> {
ResponseCmdInfo<Object> respObj = new ResponseCmdInfo<>();
LocalDateTime weatherTime = weatherResource.getLastBegTime();
LocalDateTime weatherEndTime = weatherResource.getLastEndTime();
if (startTime.plusSeconds(duringTime).isAfter(weatherTime) && startTime.plusSeconds(
duringTime).isBefore(weatherEndTime)) {
respObj.setCmdType("start_" + weatherResource.getWeatherType());
}
if (startTime.plusSeconds(duringTime).isAfter(weatherEndTime)) {
respObj.setCmdType("stop_" + weatherResource.getWeatherType());
}
Global.sendCmdInfoQueue.add(respObj);
});
}
}
}