From a5837807e0dce94b987c4afcab576bba37ba4bd1 Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Thu, 18 Nov 2021 11:10:46 +0800
Subject: [PATCH] 定时任务添加异常处理

---
 screen-job/src/main/java/com/moral/api/task/AlarmTask.java | 1245 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 625 insertions(+), 620 deletions(-)

diff --git a/screen-job/src/main/java/com/moral/api/task/AlarmTask.java b/screen-job/src/main/java/com/moral/api/task/AlarmTask.java
index 8360cb9..4981ab6 100644
--- a/screen-job/src/main/java/com/moral/api/task/AlarmTask.java
+++ b/screen-job/src/main/java/com/moral/api/task/AlarmTask.java
@@ -61,731 +61,736 @@
     @XxlJob("alarmInfoInsert")
     public ReturnT alarmInfoInsert(){
         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());
+        try {
+            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;
+            //������������
+            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();
                     }
-                    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);
+                    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;
                         }
-                        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()));
-                                }
-                            }
+                        HistoryHourly historyHourly = new HistoryHourly();
+                        historyHourly = historyHourlys.get(0);
+                        if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyHourly)){
+                            continue;
                         }
-                        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);
+                        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()+"]["+beforTime+"][PM2.5]���������["+PM2_5+"]������������������������["+previousPM2_5+"]���"+multiple+"���";
+                                alarmInfo.setAlarmType("������");
+                                String alarmInformation = "������["+device.getName()+"][PM2.5]���������["+PM2_5+"]������������������������[75]";
                                 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;
+                            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()));
                                     }
-                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
-                                    sysAreaQueryWrapper.eq("area_code",cityCode);
-                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                }
+                            }
+                            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("������������������"+multiple+"%");
-                                    String alarmInformation = "["+device.getName()+"][PM2.5]���������["+PM2_5+"]������["+sysArea.getAreaName()+"]������["+cityAqiPM2_5+"]���"+percentage+"%";
+                                    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(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;
+                            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;
                                     }
-                                    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(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);
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(PM10)){
+                            if (PM10>75150){
                                 alarmInfo.setIndex("PM10");
-                                alarmInfo.setAlarmType("���������");
-                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][PM10]���������["+PM10+"]������������������������["+previousPM10+"]���"+multiple+"���";
+                                alarmInfo.setAlarmType("������");
+                                String alarmInformation = "������["+device.getName()+"][PM10]���������["+PM10+"]������������������������[150]";
                                 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;
+                            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()));
                                     }
-                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
-                                    sysAreaQueryWrapper.eq("area_code",cityCode);
-                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                }
+                            }
+                            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("������������������"+percentage+"%");
-                                    String alarmInformation = "["+device.getName()+"][PM10]���������["+PM10+"]������["+sysArea.getAreaName()+"]������["+cityAqiPM10+"]���"+percentage+"%";
+                                    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(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;
+                            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;
                                     }
-                                    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(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);
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(SO2)){
+                            if (SO2>500){
                                 alarmInfo.setIndex("SO2");
-                                alarmInfo.setAlarmType("���������");
-                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][SO2]���������["+SO2+"]������������������������["+previousSO2+"]���"+multiple+"���";
+                                alarmInfo.setAlarmType("������");
+                                String alarmInformation = "������["+device.getName()+"][SO2]���������["+SO2+"]������������������������[75]";
                                 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;
+                            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()));
                                     }
-                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
-                                    sysAreaQueryWrapper.eq("area_code",cityCode);
-                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                }
+                            }
+                            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("������������������"+percentage+"%");
-                                    String alarmInformation = "["+device.getName()+"][SO2]���������["+SO2+"]������["+sysArea.getAreaName()+"]������["+cityAqiSO2+"]���"+percentage+"%";
+                                    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(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;
+                            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;
                                     }
-                                    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(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);
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(NO2)){
+                            if (NO2>200){
                                 alarmInfo.setIndex("NO2");
-                                alarmInfo.setAlarmType("���������");
-                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][NO2]���������["+NO2+"]������������������������["+previousNO2+"]���"+multiple+"���";
+                                alarmInfo.setAlarmType("������");
+                                String alarmInformation = "������["+device.getName()+"][NO2]���������["+NO2+"]������������������������[75]";
                                 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;
+                            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()));
                                     }
-                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
-                                    sysAreaQueryWrapper.eq("area_code",cityCode);
-                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                }
+                            }
+                            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("������������������"+percentage+"%");
-                                    String alarmInformation = "["+device.getName()+"][NO2]���������["+NO2+"]������["+sysArea.getAreaName()+"]������["+cityAqiNO2+"]���"+percentage+"%";
+                                    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(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;
+                            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;
                                     }
-                                    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(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);
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(CO)){
+                            if (CO>10){
                                 alarmInfo.setIndex("CO");
-                                alarmInfo.setAlarmType("���������");
-                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][CO]���������["+CO+"]������������������������["+previousCO+"]���"+multiple+"���";
+                                alarmInfo.setAlarmType("������");
+                                String alarmInformation = "������["+device.getName()+"][CO]���������["+CO+"]������������������������[75]";
                                 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;
+                            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()));
                                     }
-                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
-                                    sysAreaQueryWrapper.eq("area_code",cityCode);
-                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                }
+                            }
+                            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("������������������"+percentage+"%");
-                                    String alarmInformation = "["+device.getName()+"][CO]���������["+CO+"]������["+sysArea.getAreaName()+"]������["+cityAqiCO+"]���"+percentage+"%";
+                                    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(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;
+                            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;
                                     }
-                                    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(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);
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(O3)){
+                            if (O3>200){
                                 alarmInfo.setIndex("O3");
-                                alarmInfo.setAlarmType("���������");
-                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][O3]���������["+O3+"]������������������������["+previousO3+"]���"+multiple+"���";
+                                alarmInfo.setAlarmType("������");
+                                String alarmInformation = "������["+device.getName()+"][O3]���������["+O3+"]������������������������[75]";
                                 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;
+                            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()));
                                     }
-                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
-                                    sysAreaQueryWrapper.eq("area_code",cityCode);
-                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                }
+                            }
+                            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("������������������"+percentage+"%");
-                                    String alarmInformation = "["+device.getName()+"][O3]���������["+O3+"]������["+sysArea.getAreaName()+"]������["+cityAqiO3+"]���"+percentage+"%";
+                                    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(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;
+                            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;
                                     }
-                                    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;
+                                }
+                            }
+                            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;
+                                    }
                                 }
                             }
                         }
                     }
                 }
             }
+        }catch (Exception e){
+            XxlJobHelper.log(e.getMessage());
+            return new ReturnT(ReturnT.FAIL_CODE,e.getMessage());
         }
         return ReturnT.SUCCESS;
     }

--
Gitblit v1.8.0