新代码

This commit is contained in:
wangwenhua 2025-09-18 11:34:34 +08:00
parent 92a383a9b3
commit ac0a950025
2 changed files with 43 additions and 41 deletions

View File

@ -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();

View File

@ -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,48 +141,48 @@ 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<>();
responseCmdInfo.setScenarioId(currentScenario.getId());
responseCmdInfo.setRoom(roomId);
responseCmdInfo.setCmdType("start_" + resource.getWeatherType());
responseCmdInfo.setScenarioId(currentScenario.getId());
responseCmdInfo.setRoom(roomId);
Global.sendCmdInfoQueue.add(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-" + 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<>();
responseCmdInfo.setScenarioId(currentScenario.getId());
responseCmdInfo.setRoom(roomId);
responseCmdInfo.setCmdType("stop_" + resource.getWeatherType());
responseCmdInfo.setScenarioId(currentScenario.getId());
responseCmdInfo.setRoom(roomId);
Global.sendCmdInfoQueue.add(responseCmdInfo);
}
else if(timeBegstamp+duringTime >= timeEndstamp && StringUtils.isNotEmpty(weatherStatus)){
ResponseCmdInfo<JSONObject> responseCmdInfo = new ResponseCmdInfo();
responseCmdInfo.setScenarioId(currentScenario.getId());
responseCmdInfo.setRoom(roomId);
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) {