From cb8145e862a85f77da39bc8f8d83e374938d5ea4 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Sat, 23 Nov 2024 16:02:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=81=BE=E5=AE=B3=E5=A4=A9=E6=B0=94=E6=A8=A1?= =?UTF-8?q?=E6=8B=9F=E5=86=85=E7=BD=91=E6=95=B0=E6=8D=AEV1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/service/DataCenterServiceImpl.java | 2 +- .../bonus/data/service/WatherWarnService.java | 36 +++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/bonus-modules/data/src/main/java/com/bonus/data/service/DataCenterServiceImpl.java b/bonus-modules/data/src/main/java/com/bonus/data/service/DataCenterServiceImpl.java index 3d6a5b7..c944bd1 100644 --- a/bonus-modules/data/src/main/java/com/bonus/data/service/DataCenterServiceImpl.java +++ b/bonus-modules/data/src/main/java/com/bonus/data/service/DataCenterServiceImpl.java @@ -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(),"m³","grain_05","0",vo.getDataTime(),mergerId); diff --git a/bonus-modules/data/src/main/java/com/bonus/data/service/WatherWarnService.java b/bonus-modules/data/src/main/java/com/bonus/data/service/WatherWarnService.java index 052e673..a0efb09 100644 --- a/bonus-modules/data/src/main/java/com/bonus/data/service/WatherWarnService.java +++ b/bonus-modules/data/src/main/java/com/bonus/data/service/WatherWarnService.java @@ -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> 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); + } + } + + /** * 处理所有城市灾害列表页面 *