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