新代码
This commit is contained in:
parent
92a383a9b3
commit
ac0a950025
|
@ -28,12 +28,12 @@ public class CodeGenerator {
|
|||
})
|
||||
.packageConfig(builder -> {
|
||||
builder.parent("com.hivekion") // 设置父包名
|
||||
.moduleName("scenario") // 设置模块名(可选)
|
||||
.moduleName("basedata") // 设置模块名(可选)
|
||||
.pathInfo(Collections.singletonMap(OutputFile.xml,
|
||||
basePath + "/src/main/resources/mapper/tbl")); // 设置mapperXml生成路径
|
||||
})
|
||||
.strategyConfig(builder -> {
|
||||
builder.addInclude("TBL_BATTLE_SUPPLIER".toLowerCase()) // 设置需要生成的表名(多个用逗号分隔)
|
||||
builder.addInclude("IMG_VEHICLE_IMAGE".toLowerCase()) // 设置需要生成的表名(多个用逗号分隔)
|
||||
.addTablePrefix("tbl_"); // 设置过滤表前缀
|
||||
})
|
||||
.execute();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.hivekion.scenario.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.hivekion.Global;
|
||||
|
@ -16,6 +17,7 @@ import com.hivekion.scenario.service.ScenarioTaskService;
|
|||
import com.hivekion.scenario.service.TaskLogicService;
|
||||
import com.hivekion.thread.SpringGlobalTaskManager;
|
||||
import java.time.Duration;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
@ -139,49 +141,49 @@ public class ScenarioTaskServiceImpl extends
|
|||
*/
|
||||
private void weatherTrigger(Scenario currentScenario, String roomId) {
|
||||
try {
|
||||
String weatherResources = (String) redisUtil.hget(roomId + "_" + currentScenario.getId(),
|
||||
"weather");
|
||||
List<WeatherResource> weatherList = JSONArray.parseArray(weatherResources,
|
||||
WeatherResource.class);
|
||||
int duringTime = getCurrentDuringTime(currentScenario, roomId);
|
||||
|
||||
for (WeatherResource resource : weatherList) {
|
||||
|
||||
if ("init".equals(resource.getStatus())) {
|
||||
|
||||
if (currentScenario.getStartTime().plusSeconds(duringTime)
|
||||
.isAfter(resource.getLastBegTime())) {
|
||||
log.info("{}", "start_" + resource.getWeatherType());
|
||||
resource.setStatus("running");
|
||||
ResponseCmdInfo<Void> responseCmdInfo = new ResponseCmdInfo<>();
|
||||
String weatherResources = (String) redisUtil.hget(roomId + "_" + currentScenario.getId(), "weather");
|
||||
JSONArray weatherArray = JSONArray.parseArray(weatherResources);
|
||||
String weatherStatus = redisUtil.hget(roomId + "_" + currentScenario.getId(), "weather-status") !=null?(String) redisUtil.hget(roomId + "_" + currentScenario.getId(), "weather-status"):null;
|
||||
for(int i=0;i<weatherArray.size();i++){
|
||||
com.alibaba.fastjson.JSONObject weatherObj = (com.alibaba.fastjson.JSONObject) weatherArray.get(i);
|
||||
Long timeBegstamp =Long.valueOf(weatherObj.getString("weatherBegTime"));
|
||||
Long timeEndstamp =Long.valueOf(weatherObj.getString("weatherEndTime"));
|
||||
Long duringTime = Long.valueOf(redisUtil.hget(roomId + "_" + currentScenario.getId(), "duringTime").toString());
|
||||
Long scenarioBegtime = currentScenario.getStartTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
log.info("======{}========{}========{}=====",timeBegstamp,timeEndstamp,duringTime,scenarioBegtime);
|
||||
if(scenarioBegtime+duringTime >= timeBegstamp && StringUtils.isEmpty(weatherStatus)) {
|
||||
ResponseCmdInfo<JSONObject> responseCmdInfo = new ResponseCmdInfo();
|
||||
responseCmdInfo.setScenarioId(currentScenario.getId());
|
||||
responseCmdInfo.setRoom(roomId);
|
||||
responseCmdInfo.setCmdType("start_" + resource.getWeatherType());
|
||||
responseCmdInfo.setCmdType("start-" + weatherObj.getString("weatherType"));
|
||||
responseCmdInfo.setScenarioId(currentScenario.getId());
|
||||
responseCmdInfo.setRoom(roomId);
|
||||
System.out.println(responseCmdInfo.toString());
|
||||
redisUtil.hset(roomId + "_" + currentScenario.getId(), "weather-status","start");
|
||||
Global.sendCmdInfoQueue.add(responseCmdInfo);
|
||||
}
|
||||
|
||||
}
|
||||
if ("running".equals(resource.getStatus())) {
|
||||
if (currentScenario.getStartTime().plusSeconds(duringTime)
|
||||
.isAfter(resource.getLastEndTime())) {
|
||||
log.info("{}", "stopped_" + resource.getWeatherType());
|
||||
resource.setStatus("stopped");
|
||||
ResponseCmdInfo<Void> responseCmdInfo = new ResponseCmdInfo<>();
|
||||
else if(timeBegstamp+duringTime >= timeEndstamp && StringUtils.isNotEmpty(weatherStatus)){
|
||||
ResponseCmdInfo<JSONObject> responseCmdInfo = new ResponseCmdInfo();
|
||||
responseCmdInfo.setScenarioId(currentScenario.getId());
|
||||
responseCmdInfo.setRoom(roomId);
|
||||
responseCmdInfo.setCmdType("stop_" + resource.getWeatherType());
|
||||
responseCmdInfo.setCmdType("end-" + weatherObj.getString("weatherType"));
|
||||
responseCmdInfo.setScenarioId(currentScenario.getId());
|
||||
responseCmdInfo.setRoom(roomId);
|
||||
System.out.println(responseCmdInfo.toString());
|
||||
redisUtil.hset(roomId + "_" + currentScenario.getId(), "weather-status","end");
|
||||
Global.sendCmdInfoQueue.add(responseCmdInfo);
|
||||
}else{
|
||||
ResponseCmdInfo<JSONObject> responseCmdInfo = new ResponseCmdInfo();
|
||||
responseCmdInfo.setScenarioId(currentScenario.getId());
|
||||
responseCmdInfo.setRoom(roomId);
|
||||
responseCmdInfo.setCmdType("remain-" + weatherObj.getString("weatherType"));
|
||||
responseCmdInfo.setScenarioId(currentScenario.getId());
|
||||
responseCmdInfo.setRoom(roomId);
|
||||
System.out.println(responseCmdInfo.toString());
|
||||
Global.sendCmdInfoQueue.add(responseCmdInfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
redisUtil.hset(roomId + "_" + currentScenario.getId(), "weather",
|
||||
JSONArray.toJSONString(weatherList));
|
||||
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user