灾害天气模拟内网数据V1.0

This commit is contained in:
syruan 2024-11-23 16:02:55 +08:00
parent e8b14dcd5e
commit cb8145e862
2 changed files with 35 additions and 3 deletions

View File

@ -289,7 +289,7 @@ public class DataCenterServiceImpl implements DataCenterService{
}
String devId= deviceVo.getDevId();
log.info("设备注册系统id---->{}",devId);
WarnConfigVo config=mapper.getDevWarnConfig(devId);
WarnConfigVo config=mapper.getDevWarnConfig(devId);
String mergerId= UuidUtils.generateUuid().toUpperCase().replaceAll("-","");
attributeVos.clear();
DevAttributeVo devAttributeVo=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"0.5µm粒子数个",vo.getGrain05(),"","grain_05","0",vo.getDataTime(),mergerId);

View File

@ -1,6 +1,6 @@
package com.bonus.data.service;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson2.JSON;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.data.entity.WatherVo;
@ -53,7 +53,6 @@ public class WatherWarnService {
private WatherMapper mapper;
/**
* 数据信息接口
* @param
@ -63,6 +62,7 @@ public class WatherWarnService {
String url = ALL_CITY_URL + "?_=" + TIME_STAMP;
String allWarningCity = getWarnCityList(url);
if (allWarningCity == null) {
genderCityWeather(); // 内网等其他情况未获取到数据那么进行模拟预警
return;
}
List<List<String>> data = getCityLists(allWarningCity);
@ -91,6 +91,38 @@ public class WatherWarnService {
}
/**
* 生成预警信息
*/
public void genderCityWeather() {
try {
String[] city = {"北京市", "天津市", "河北省", "山西省", "内蒙古自治区", "辽宁省", "吉林省", "黑龙江省", "上海市", "江苏省",
"浙江省", "安徽省", "福建省", "江西省", "山东省", "河南省", "湖北省", "湖南省", "广东省", "广西壮族自治区", "海南省", "重庆市",
"四川省", "贵州省", "云南省", "西藏自治区", "陕西省", "甘肃省"};
String[] warnType = {"龙卷风强", "强沙尘", "龙卷风", "龙卷风强", "强风", "暴风", "台风", "高温", "大雾", "飓风", "寒潮"};
String[] colorType = {"蓝色", "黄色", "橙色", "红色"};
Integer[] warnLine = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
for (int i = 0; i < RandomUtil.randomInt(1, 5); i++) {
String thisCity = city[RandomUtil.randomInt(1, 25)];
String thisWarnType = warnType[RandomUtil.randomInt(1,10)];
String thisColorType = colorType[RandomUtil.randomInt(1,3)];
String warnContent = thisCity + "气象台" + DateUtils.getCurrentYear() + "" + DateUtils.getCurrentMonth() +
"" + DateUtils.getCurrentDay() + "" + RandomUtil.randomInt(1, 24) + "" + RandomUtil.randomInt(1, 60) + "" +
"发布" + thisWarnType + thisColorType + "预警:预计" + DateUtils.getDate() +
RandomUtil.randomInt(1, 5) + "级风" + RandomUtil.randomInt(1, 100) + "米/秒" + "" +RandomUtil.randomInt(1, 100) + "米高度," +
"目前我省市已出现能见度小于" + warnLine[RandomUtil.randomInt(1,9)] + "米的雾," + "请做好防范,做好防护,做好避险。";
String type = thisWarnType + "预警";
WatherVo vo = new WatherVo(thisCity,DateUtils.getTime(),warnContent,type,thisColorType,thisCity,DateUtils.getDate());
mapper.replaceWather(vo);
}
} catch (Exception e){
log.error(e.toString(),e);
}
}
/**
* 处理所有城市灾害列表页面
*