New file |
| | |
| | | package com.moral.api.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.*; |
| | | import com.moral.api.service.HistoryHourlyService; |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.moral.constant.Constants; |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.context.XxlJobHelper; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @program: screen |
| | | * @description: 警报定时任务 |
| | | * @author: lizijie |
| | | * @create: 2021-11-09 11:07 |
| | | **/ |
| | | @Component |
| | | public class AlarmTask { |
| | | |
| | | @Resource |
| | | private OrganizationService organizationService; |
| | | |
| | | @Resource |
| | | private HistoryHourlyService historyHourlyService; |
| | | |
| | | @Autowired(required = false) |
| | | private DeviceMapper deviceMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private AlarmInfoMapper alarmInfoMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private OrganizationMapper organizationMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private CityAqiMapper cityAqiMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private SysAreaMapper sysAreaMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private HistoryAqiMapper historyAqiMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private GovMonitorPointMapper govMonitorPointMapper; |
| | | |
| | | @XxlJob("alarmInfoInsert") |
| | | public ReturnT informationInsert(){ |
| | | String params = XxlJobHelper.getJobParam(); |
| | | Map organizationIdMap = JSON.parseObject(params); |
| | | List<Integer> orgIdList = (List<Integer>) organizationIdMap.get("orgId"); |
| | | //获取时间 |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | String alarmTime = df.format(calendar.getTime())+":00:00"; |
| | | calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1); |
| | | //Date nearData = calendar.getTime(); |
| | | String beforTime = df.format(calendar.getTime())+":00:00"; |
| | | calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1); |
| | | //Date previousData = calendar.getTime(); |
| | | String previousTime = df.format(calendar.getTime())+":00:00"; |
| | | //定义一个集合,存放所有id |
| | | List<Integer> allOrgId = new ArrayList<>(); |
| | | allOrgId.addAll(orgIdList); |
| | | //循环集合 |
| | | for (Integer orgId:orgIdList) { |
| | | //所有子组织 |
| | | List<Organization> allChildrenOrganization = organizationService.getAllChildrenOrganization(orgId); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(allChildrenOrganization) || allChildrenOrganization.size() < 1){ |
| | | for (Organization organization:allChildrenOrganization) { |
| | | allOrgId.add(organization.getId()); |
| | | } |
| | | } |
| | | } |
| | | //集合去重 |
| | | List<Integer> allOrgIdWithoutDuplicates = allOrgId.stream().distinct().collect(Collectors.toList()); |
| | | for (Integer orgId:allOrgIdWithoutDuplicates) { |
| | | //根据id查询所属设备 |
| | | QueryWrapper<Organization> wrapper_organization = new QueryWrapper<>(); |
| | | wrapper_organization.eq("is_delete",Constants.NOT_DELETE).eq("id",orgId); |
| | | Organization organization = new Organization(); |
| | | organization = organizationMapper.selectOne(wrapper_organization); |
| | | //根据id查询所属设备 |
| | | QueryWrapper<Device> wrapper_device = new QueryWrapper<>(); |
| | | wrapper_device.eq("is_delete",Constants.NOT_DELETE).eq("organization_id",orgId); |
| | | List<Device> devices = new ArrayList<>(); |
| | | devices = deviceMapper.selectList(wrapper_device); |
| | | if (devices.size()>0){ |
| | | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date alarmDate = new Date(); |
| | | Date nearDate = new Date(); |
| | | Date previousDate = new Date(); |
| | | try { |
| | | alarmDate = dateFormat.parse(alarmTime); |
| | | nearDate = dateFormat.parse(beforTime); |
| | | previousDate = dateFormat.parse(previousTime); |
| | | }catch (ParseException e){ |
| | | e.printStackTrace(); |
| | | } |
| | | for (Device device:devices) { |
| | | AlarmInfo alarmInfo = new AlarmInfo(); |
| | | alarmInfo.setAlarmTime(alarmDate); |
| | | int deviceId = device.getId(); |
| | | alarmInfo.setDeviceId(deviceId); |
| | | String mac = device.getMac(); |
| | | List<HistoryHourly> historyHourlys = null; |
| | | historyHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), nearDate, nearDate); |
| | | if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyHourlys) || historyHourlys.size()<1){ |
| | | continue; |
| | | } |
| | | HistoryHourly historyHourly = new HistoryHourly(); |
| | | historyHourly = historyHourlys.get(0); |
| | | if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyHourly)){ |
| | | continue; |
| | | } |
| | | Double PM2_5 = null; |
| | | Double PM10 = null; |
| | | Double SO2 = null; |
| | | Double NO2 = null; |
| | | Double CO = null; |
| | | Double O3 = null; |
| | | String value = historyHourly.getValue(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject = JSONObject.parseObject(value); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a34004"))){ |
| | | PM2_5=(Double.parseDouble(jsonObject.get("a34004").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a34002"))){ |
| | | PM10=(Double.parseDouble(jsonObject.get("a34002").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a21026"))){ |
| | | SO2=(Double.parseDouble(jsonObject.get("a21026").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a21004"))){ |
| | | NO2=(Double.parseDouble(jsonObject.get("a21004").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a21005"))){ |
| | | CO=(Double.parseDouble(jsonObject.get("a21005").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a05024"))){ |
| | | O3=(Double.parseDouble(jsonObject.get("a05024").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(PM2_5)){ |
| | | if (PM2_5>75){ |
| | | alarmInfo.setIndex("PM2_5"); |
| | | alarmInfo.setAlarmType("超限"); |
| | | String alarmInformation = "站点["+device.getName()+"][PM2.5]浓度值["+PM2_5+"]超过限定的标准值[75]"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | Double previousPM2_5 = null; |
| | | List<HistoryHourly> previoushistoryHourlys = null; |
| | | previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate); |
| | | HistoryHourly previousHistoryHourly = new HistoryHourly(); |
| | | if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){ |
| | | previousHistoryHourly = previoushistoryHourlys.get(0); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){ |
| | | String previousValue = previousHistoryHourly.getValue(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(previousValue); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a34004"))){ |
| | | previousPM2_5=(Double.parseDouble(previousJsonObject.get("a34004").toString())); |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousPM2_5) && previousPM2_5!=0){ |
| | | if (PM2_5/previousPM2_5 > 2 || PM2_5/previousPM2_5 == 2){ |
| | | String multiple = String.format("%.2f",PM2_5/previousPM2_5); |
| | | alarmInfo.setIndex("PM2_5"); |
| | | alarmInfo.setAlarmType("突然高"); |
| | | String alarmInformation = "["+device.getName()+"]["+beforTime+"][PM2.5]浓度值["+PM2_5+"]超过上小时的浓度["+previousPM2_5+"]的"+multiple+"倍"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){ |
| | | int cityCode = organization.getCityCode(); |
| | | QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>(); |
| | | wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime); |
| | | CityAqi cityAqi = null; |
| | | cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){ |
| | | String cityAqiValue = cityAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double cityAqiPM2_5 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString())); |
| | | if (PM2_5/cityAqiPM2_5 >=1.5){ |
| | | double multiple = PM2_5/cityAqiPM2_5; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | } |
| | | QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("area_code",cityCode); |
| | | SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("PM2_5"); |
| | | alarmInfo.setAlarmType("超过市区均值"+multiple+"%"); |
| | | String alarmInformation = "["+device.getName()+"][PM2.5]浓度值["+PM2_5+"]超过["+sysArea.getAreaName()+"]均值["+cityAqiPM2_5+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){ |
| | | String guid = device.getGuid(); |
| | | QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>(); |
| | | historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime); |
| | | HistoryAqi historyAqi = null; |
| | | historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){ |
| | | String cityAqiValue = historyAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double govMonitorPointPM2_5 = null; |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){ |
| | | govMonitorPointPM2_5 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointPM2_5) && PM2_5/govMonitorPointPM2_5 >=1){ |
| | | double multiple = PM2_5/govMonitorPointPM2_5; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | }else if (multiple >= 1){ |
| | | percentage = 100; |
| | | } |
| | | QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("guid",guid); |
| | | GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("PM2_5"); |
| | | alarmInfo.setAlarmType("超过国控站"+multiple+"%"); |
| | | String alarmInformation = "["+device.getName()+"][PM2.5]浓度值["+PM2_5+"]超过["+govMonitorPoint.getName()+"]均值["+govMonitorPointPM2_5+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(PM10)){ |
| | | if (PM10>75150){ |
| | | alarmInfo.setIndex("PM10"); |
| | | alarmInfo.setAlarmType("超限"); |
| | | String alarmInformation = "站点["+device.getName()+"][PM10]浓度值["+PM10+"]超过限定的标准值[150]"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | Double previousPM10 = null; |
| | | List<HistoryHourly> previoushistoryHourlys = null; |
| | | previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate); |
| | | HistoryHourly previousHistoryHourly = new HistoryHourly(); |
| | | if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){ |
| | | previousHistoryHourly = previoushistoryHourlys.get(0); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){ |
| | | String previousValue = previousHistoryHourly.getValue(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(previousValue); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a34002"))){ |
| | | previousPM10=(Double.parseDouble(previousJsonObject.get("a34002").toString())); |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousPM10) && previousPM10!=0){ |
| | | if (PM10/previousPM10 > 2 || PM10/previousPM10 == 2){ |
| | | String multiple = String.format("%.2f",PM10/previousPM10); |
| | | alarmInfo.setIndex("PM10"); |
| | | alarmInfo.setAlarmType("突然高"); |
| | | String alarmInformation = "["+device.getName()+"]["+beforTime+"][PM10]浓度值["+PM10+"]超过上小时的浓度["+previousPM10+"]的"+multiple+"倍"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){ |
| | | int cityCode = organization.getCityCode(); |
| | | QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>(); |
| | | wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime); |
| | | CityAqi cityAqi = null; |
| | | cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){ |
| | | String cityAqiValue = cityAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double cityAqiPM10 = (Double.parseDouble(previousJsonObject.get("PM10").toString())); |
| | | if (PM10/cityAqiPM10 >=1.5){ |
| | | double multiple = PM10/cityAqiPM10; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | } |
| | | QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("area_code",cityCode); |
| | | SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("PM10"); |
| | | alarmInfo.setAlarmType("超过市区均值"+percentage+"%"); |
| | | String alarmInformation = "["+device.getName()+"][PM10]浓度值["+PM10+"]超过["+sysArea.getAreaName()+"]均值["+cityAqiPM10+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){ |
| | | String guid = device.getGuid(); |
| | | QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>(); |
| | | historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime); |
| | | HistoryAqi historyAqi = null; |
| | | historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){ |
| | | String cityAqiValue = historyAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double govMonitorPointPM10 = null; |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){ |
| | | govMonitorPointPM10 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointPM10) && PM10/govMonitorPointPM10 >=1){ |
| | | double multiple = PM10/govMonitorPointPM10; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | }else if (multiple >= 1){ |
| | | percentage = 100; |
| | | } |
| | | QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("guid",guid); |
| | | GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("PM10"); |
| | | alarmInfo.setAlarmType("超过国控站"+percentage+"%"); |
| | | String alarmInformation = "["+device.getName()+"][PM10]浓度值["+PM10+"]超过["+govMonitorPoint.getName()+"]均值["+govMonitorPointPM10+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(SO2)){ |
| | | if (SO2>500){ |
| | | alarmInfo.setIndex("SO2"); |
| | | alarmInfo.setAlarmType("超限"); |
| | | String alarmInformation = "站点["+device.getName()+"][SO2]浓度值["+SO2+"]超过限定的标准值[75]"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | Double previousSO2 = null; |
| | | List<HistoryHourly> previoushistoryHourlys = null; |
| | | previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate); |
| | | HistoryHourly previousHistoryHourly = new HistoryHourly(); |
| | | if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){ |
| | | previousHistoryHourly = previoushistoryHourlys.get(0); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){ |
| | | String previousValue = previousHistoryHourly.getValue(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(previousValue); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a21026"))){ |
| | | previousSO2=(Double.parseDouble(previousJsonObject.get("a21026").toString())); |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousSO2) && previousSO2!=0){ |
| | | if (SO2/previousSO2 > 2 || SO2/previousSO2 == 2){ |
| | | String multiple = String.format("%.2f",SO2/previousSO2); |
| | | alarmInfo.setIndex("SO2"); |
| | | alarmInfo.setAlarmType("突然高"); |
| | | String alarmInformation = "["+device.getName()+"]["+beforTime+"][SO2]浓度值["+SO2+"]超过上小时的浓度["+previousSO2+"]的"+multiple+"倍"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){ |
| | | int cityCode = organization.getCityCode(); |
| | | QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>(); |
| | | wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime); |
| | | CityAqi cityAqi = null; |
| | | cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){ |
| | | String cityAqiValue = cityAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double cityAqiSO2 = (Double.parseDouble(previousJsonObject.get("SO2").toString())); |
| | | if (SO2/cityAqiSO2 >=1.5){ |
| | | double multiple = SO2/cityAqiSO2; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | } |
| | | QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("area_code",cityCode); |
| | | SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("SO2"); |
| | | alarmInfo.setAlarmType("超过市区均值"+percentage+"%"); |
| | | String alarmInformation = "["+device.getName()+"][SO2]浓度值["+SO2+"]超过["+sysArea.getAreaName()+"]均值["+cityAqiSO2+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){ |
| | | String guid = device.getGuid(); |
| | | QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>(); |
| | | historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime); |
| | | HistoryAqi historyAqi = null; |
| | | historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){ |
| | | String cityAqiValue = historyAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double govMonitorPointSO2 = null; |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){ |
| | | govMonitorPointSO2 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointSO2) && SO2/govMonitorPointSO2 >=1){ |
| | | double multiple = SO2/govMonitorPointSO2; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | }else if (multiple >= 1){ |
| | | percentage = 100; |
| | | } |
| | | QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("guid",guid); |
| | | GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("SO2"); |
| | | alarmInfo.setAlarmType("超过国控站"+percentage+"%"); |
| | | String alarmInformation = "["+device.getName()+"][SO2]浓度值["+SO2+"]超过["+govMonitorPoint.getName()+"]均值["+govMonitorPointSO2+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(NO2)){ |
| | | if (NO2>200){ |
| | | alarmInfo.setIndex("NO2"); |
| | | alarmInfo.setAlarmType("超限"); |
| | | String alarmInformation = "站点["+device.getName()+"][NO2]浓度值["+NO2+"]超过限定的标准值[75]"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | Double previousNO2 = null; |
| | | List<HistoryHourly> previoushistoryHourlys = null; |
| | | previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate); |
| | | HistoryHourly previousHistoryHourly = new HistoryHourly(); |
| | | if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){ |
| | | previousHistoryHourly = previoushistoryHourlys.get(0); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){ |
| | | String previousValue = previousHistoryHourly.getValue(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(previousValue); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a21004"))){ |
| | | previousNO2=(Double.parseDouble(previousJsonObject.get("a21004").toString())); |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousNO2) && previousNO2!=0){ |
| | | if (NO2/previousNO2 > 2 || NO2/previousNO2 == 2){ |
| | | String multiple = String.format("%.2f",NO2/previousNO2); |
| | | alarmInfo.setIndex("NO2"); |
| | | alarmInfo.setAlarmType("突然高"); |
| | | String alarmInformation = "["+device.getName()+"]["+beforTime+"][NO2]浓度值["+NO2+"]超过上小时的浓度["+previousNO2+"]的"+multiple+"倍"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){ |
| | | int cityCode = organization.getCityCode(); |
| | | QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>(); |
| | | wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime); |
| | | CityAqi cityAqi = null; |
| | | cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){ |
| | | String cityAqiValue = cityAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double cityAqiNO2 = (Double.parseDouble(previousJsonObject.get("NO2").toString())); |
| | | if (NO2/cityAqiNO2 >=1.5){ |
| | | double multiple = NO2/cityAqiNO2; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | } |
| | | QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("area_code",cityCode); |
| | | SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("NO2"); |
| | | alarmInfo.setAlarmType("超过市区均值"+percentage+"%"); |
| | | String alarmInformation = "["+device.getName()+"][NO2]浓度值["+NO2+"]超过["+sysArea.getAreaName()+"]均值["+cityAqiNO2+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){ |
| | | String guid = device.getGuid(); |
| | | QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>(); |
| | | historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime); |
| | | HistoryAqi historyAqi = null; |
| | | historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){ |
| | | String cityAqiValue = historyAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double govMonitorPointNO2 = null; |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){ |
| | | govMonitorPointNO2 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointNO2) && NO2/govMonitorPointNO2 >=1){ |
| | | double multiple = NO2/govMonitorPointNO2; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | }else if (multiple >= 1){ |
| | | percentage = 100; |
| | | } |
| | | QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("guid",guid); |
| | | GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("NO2"); |
| | | alarmInfo.setAlarmType("超过国控站"+percentage+"%"); |
| | | String alarmInformation = "["+device.getName()+"][NO2]浓度值["+NO2+"]超过["+govMonitorPoint.getName()+"]均值["+govMonitorPointNO2+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(CO)){ |
| | | if (CO>10){ |
| | | alarmInfo.setIndex("CO"); |
| | | alarmInfo.setAlarmType("超限"); |
| | | String alarmInformation = "站点["+device.getName()+"][CO]浓度值["+CO+"]超过限定的标准值[75]"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | Double previousCO = null; |
| | | List<HistoryHourly> previoushistoryHourlys = null; |
| | | previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate); |
| | | HistoryHourly previousHistoryHourly = new HistoryHourly(); |
| | | if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){ |
| | | previousHistoryHourly = previoushistoryHourlys.get(0); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){ |
| | | String previousValue = previousHistoryHourly.getValue(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(previousValue); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a21005"))){ |
| | | previousCO=(Double.parseDouble(previousJsonObject.get("a21005").toString())); |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousCO) && previousCO!=0){ |
| | | if (CO/previousCO > 2 || CO/previousCO == 2){ |
| | | String multiple = String.format("%.2f",CO/previousCO); |
| | | alarmInfo.setIndex("CO"); |
| | | alarmInfo.setAlarmType("突然高"); |
| | | String alarmInformation = "["+device.getName()+"]["+beforTime+"][CO]浓度值["+CO+"]超过上小时的浓度["+previousCO+"]的"+multiple+"倍"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){ |
| | | int cityCode = organization.getCityCode(); |
| | | QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>(); |
| | | wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime); |
| | | CityAqi cityAqi = null; |
| | | cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){ |
| | | String cityAqiValue = cityAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double cityAqiCO = (Double.parseDouble(previousJsonObject.get("CO").toString())); |
| | | if (CO/cityAqiCO >=1.5){ |
| | | double multiple = CO/cityAqiCO; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | } |
| | | QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("area_code",cityCode); |
| | | SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("CO"); |
| | | alarmInfo.setAlarmType("超过市区均值"+percentage+"%"); |
| | | String alarmInformation = "["+device.getName()+"][CO]浓度值["+CO+"]超过["+sysArea.getAreaName()+"]均值["+cityAqiCO+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){ |
| | | String guid = device.getGuid(); |
| | | QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>(); |
| | | historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime); |
| | | HistoryAqi historyAqi = null; |
| | | historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){ |
| | | String cityAqiValue = historyAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double govMonitorPointCO = null; |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){ |
| | | govMonitorPointCO = (Double.parseDouble(previousJsonObject.get("PM2_5").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointCO) && CO/govMonitorPointCO >=1){ |
| | | double multiple = CO/govMonitorPointCO; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | }else if (multiple >= 1){ |
| | | percentage = 100; |
| | | } |
| | | QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("guid",guid); |
| | | GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("CO"); |
| | | alarmInfo.setAlarmType("超过国控站"+percentage+"%"); |
| | | String alarmInformation = "["+device.getName()+"][CO]浓度值["+CO+"]超过["+govMonitorPoint.getName()+"]均值["+govMonitorPointCO+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(O3)){ |
| | | if (O3>200){ |
| | | alarmInfo.setIndex("O3"); |
| | | alarmInfo.setAlarmType("超限"); |
| | | String alarmInformation = "站点["+device.getName()+"][O3]浓度值["+O3+"]超过限定的标准值[75]"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | Double previousO3 = null; |
| | | List<HistoryHourly> previoushistoryHourlys = null; |
| | | previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate); |
| | | HistoryHourly previousHistoryHourly = new HistoryHourly(); |
| | | if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){ |
| | | previousHistoryHourly = previoushistoryHourlys.get(0); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){ |
| | | String previousValue = previousHistoryHourly.getValue(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(previousValue); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a05024"))){ |
| | | previousO3=(Double.parseDouble(previousJsonObject.get("a05024").toString())); |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousO3) && previousO3!=0){ |
| | | if (O3/previousO3 > 2 || O3/previousO3 == 2){ |
| | | String multiple = String.format("%.2f",O3/previousO3); |
| | | alarmInfo.setIndex("O3"); |
| | | alarmInfo.setAlarmType("突然高"); |
| | | String alarmInformation = "["+device.getName()+"]["+beforTime+"][O3]浓度值["+O3+"]超过上小时的浓度["+previousO3+"]的"+multiple+"倍"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){ |
| | | int cityCode = organization.getCityCode(); |
| | | QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>(); |
| | | wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime); |
| | | CityAqi cityAqi = null; |
| | | cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){ |
| | | String cityAqiValue = cityAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double cityAqiO3 = (Double.parseDouble(previousJsonObject.get("O3").toString())); |
| | | if (O3/cityAqiO3 >=1.5){ |
| | | double multiple = O3/cityAqiO3; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | } |
| | | QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("area_code",cityCode); |
| | | SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("O3"); |
| | | alarmInfo.setAlarmType("超过市区均值"+percentage+"%"); |
| | | String alarmInformation = "["+device.getName()+"][O3]浓度值["+O3+"]超过["+sysArea.getAreaName()+"]均值["+cityAqiO3+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){ |
| | | String guid = device.getGuid(); |
| | | QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>(); |
| | | historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime); |
| | | HistoryAqi historyAqi = null; |
| | | historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper); |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){ |
| | | String cityAqiValue = historyAqi.getValue(); |
| | | JSONObject JsonObject = new JSONObject(); |
| | | JSONObject previousJsonObject = new JSONObject(); |
| | | previousJsonObject = JSONObject.parseObject(cityAqiValue); |
| | | Double govMonitorPointO3 = null; |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){ |
| | | govMonitorPointO3 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString())); |
| | | } |
| | | if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointO3) && O3/govMonitorPointO3 >=1){ |
| | | double multiple = O3/govMonitorPointO3; |
| | | int percentage = 0; |
| | | if (multiple >= 2.5){ |
| | | percentage = 250; |
| | | }else if (multiple >= 1.5){ |
| | | percentage = 150; |
| | | }else if (multiple >= 1){ |
| | | percentage = 100; |
| | | } |
| | | QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>(); |
| | | sysAreaQueryWrapper.eq("guid",guid); |
| | | GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper); |
| | | alarmInfo.setIndex("O3"); |
| | | alarmInfo.setAlarmType("超过国控站"+percentage+"%"); |
| | | String alarmInformation = "["+device.getName()+"][O3]浓度值["+O3+"]超过["+govMonitorPoint.getName()+"]均值["+govMonitorPointO3+"]的"+percentage+"%"; |
| | | alarmInfo.setAlarmInformation(alarmInformation); |
| | | alarmInfoMapper.insert(alarmInfo); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | |
| | | } |