From 6c90be39beb1d8c2300cd22e1338dcbbf9775ac7 Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Thu, 18 Nov 2021 09:46:34 +0800
Subject: [PATCH] 污染报警信息定时任务

---
 screen-job/src/main/resources/mapper/SysAreaMapper.xml                           |   12 
 screen-job/src/main/java/com/moral/api/service/impl/AlarmInfoServiceImpl.java    |   20 +
 screen-job/src/main/resources/mapper/AlarmInfoMapper.xml                         |   16 
 screen-job/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java |   40 ++
 screen-job/src/main/java/com/moral/api/service/impl/SysAreaServiceImpl.java      |   20 +
 screen-job/src/main/java/com/moral/api/entity/AlarmInfo.java                     |   71 +++
 screen-job/src/main/java/com/moral/api/task/AlarmTask.java                       |  794 +++++++++++++++++++++++++++++++++++++++++
 screen-job/src/main/java/com/moral/api/service/AlarmInfoService.java             |   16 
 screen-job/src/main/java/com/moral/api/entity/SysArea.java                       |   43 ++
 screen-job/src/main/java/com/moral/api/mapper/AlarmInfoMapper.java               |   16 
 screen-job/src/main/java/com/moral/api/service/SysAreaService.java               |   16 
 screen-job/src/main/java/com/moral/api/service/OrganizationService.java          |   11 
 screen-job/src/main/java/com/moral/api/mapper/SysAreaMapper.java                 |   16 
 13 files changed, 1,091 insertions(+), 0 deletions(-)

diff --git a/screen-job/src/main/java/com/moral/api/entity/AlarmInfo.java b/screen-job/src/main/java/com/moral/api/entity/AlarmInfo.java
new file mode 100644
index 0000000..f17ac51
--- /dev/null
+++ b/screen-job/src/main/java/com/moral/api/entity/AlarmInfo.java
@@ -0,0 +1,71 @@
+package com.moral.api.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author moral
+ * @since 2021-11-12
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class AlarmInfo extends Model<AlarmInfo> {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * ������������
+     */
+    private Date alarmTime;
+
+    /**
+     * ������������������
+     */
+    @TableField("`index`")
+    private String index;
+
+    /**
+     * ������������������
+     */
+    private Integer deviceId;
+
+    /**
+     * ������������
+     */
+    private String alarmType;
+
+    /**
+     * ������������
+     */
+    private String alarmInformation;
+
+    /**
+     * ������������
+     */
+    private LocalDateTime createTime;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}
diff --git a/screen-job/src/main/java/com/moral/api/entity/SysArea.java b/screen-job/src/main/java/com/moral/api/entity/SysArea.java
new file mode 100644
index 0000000..ed2dde3
--- /dev/null
+++ b/screen-job/src/main/java/com/moral/api/entity/SysArea.java
@@ -0,0 +1,43 @@
+package com.moral.api.entity;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * ���������������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-11-15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class SysArea extends Model<SysArea> {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ������������
+     */
+    private Integer areaCode;
+
+    /**
+     * ������������
+     */
+    private String areaName;
+
+    /**
+     * ������������
+     */
+    private Integer parentCode;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.areaCode;
+    }
+
+}
diff --git a/screen-job/src/main/java/com/moral/api/mapper/AlarmInfoMapper.java b/screen-job/src/main/java/com/moral/api/mapper/AlarmInfoMapper.java
new file mode 100644
index 0000000..3918cc5
--- /dev/null
+++ b/screen-job/src/main/java/com/moral/api/mapper/AlarmInfoMapper.java
@@ -0,0 +1,16 @@
+package com.moral.api.mapper;
+
+import com.moral.api.entity.AlarmInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper ������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-11-12
+ */
+public interface AlarmInfoMapper extends BaseMapper<AlarmInfo> {
+
+}
diff --git a/screen-job/src/main/java/com/moral/api/mapper/SysAreaMapper.java b/screen-job/src/main/java/com/moral/api/mapper/SysAreaMapper.java
new file mode 100644
index 0000000..ed51a43
--- /dev/null
+++ b/screen-job/src/main/java/com/moral/api/mapper/SysAreaMapper.java
@@ -0,0 +1,16 @@
+package com.moral.api.mapper;
+
+import com.moral.api.entity.SysArea;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * ��������������� Mapper ������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-11-15
+ */
+public interface SysAreaMapper extends BaseMapper<SysArea> {
+
+}
diff --git a/screen-job/src/main/java/com/moral/api/service/AlarmInfoService.java b/screen-job/src/main/java/com/moral/api/service/AlarmInfoService.java
new file mode 100644
index 0000000..1422563
--- /dev/null
+++ b/screen-job/src/main/java/com/moral/api/service/AlarmInfoService.java
@@ -0,0 +1,16 @@
+package com.moral.api.service;
+
+import com.moral.api.entity.AlarmInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  ���������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-11-12
+ */
+public interface AlarmInfoService extends IService<AlarmInfo> {
+
+}
diff --git a/screen-job/src/main/java/com/moral/api/service/OrganizationService.java b/screen-job/src/main/java/com/moral/api/service/OrganizationService.java
index e92210b..e5cb484 100644
--- a/screen-job/src/main/java/com/moral/api/service/OrganizationService.java
+++ b/screen-job/src/main/java/com/moral/api/service/OrganizationService.java
@@ -3,6 +3,8 @@
 import com.moral.api.entity.Organization;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * ��������� ���������
@@ -15,4 +17,13 @@
 
     Organization getOrganizationById(int id);
 
+    /**
+      *@Description: ������������������������������������
+      *@Param: [parentId]
+      *@return: java.util.List<com.moral.api.entity.Organization> 
+      *@Author: lizijie
+      *@Date: 2021/11/9 16:48
+     **/
+    List<Organization> getAllChildrenOrganization(Integer parentId);
+
 }
diff --git a/screen-job/src/main/java/com/moral/api/service/SysAreaService.java b/screen-job/src/main/java/com/moral/api/service/SysAreaService.java
new file mode 100644
index 0000000..0c8cb4a
--- /dev/null
+++ b/screen-job/src/main/java/com/moral/api/service/SysAreaService.java
@@ -0,0 +1,16 @@
+package com.moral.api.service;
+
+import com.moral.api.entity.SysArea;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * ��������������� ���������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-11-15
+ */
+public interface SysAreaService extends IService<SysArea> {
+
+}
diff --git a/screen-job/src/main/java/com/moral/api/service/impl/AlarmInfoServiceImpl.java b/screen-job/src/main/java/com/moral/api/service/impl/AlarmInfoServiceImpl.java
new file mode 100644
index 0000000..d42f834
--- /dev/null
+++ b/screen-job/src/main/java/com/moral/api/service/impl/AlarmInfoServiceImpl.java
@@ -0,0 +1,20 @@
+package com.moral.api.service.impl;
+
+import com.moral.api.entity.AlarmInfo;
+import com.moral.api.mapper.AlarmInfoMapper;
+import com.moral.api.service.AlarmInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  ���������������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-11-12
+ */
+@Service
+public class AlarmInfoServiceImpl extends ServiceImpl<AlarmInfoMapper, AlarmInfo> implements AlarmInfoService {
+
+}
diff --git a/screen-job/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java b/screen-job/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java
index c4ffa83..a3f40e0 100644
--- a/screen-job/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java
+++ b/screen-job/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java
@@ -8,6 +8,10 @@
 import com.moral.constant.Constants;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <p>
@@ -31,4 +35,40 @@
         Organization organization = organizationMapper.selectOne(wrapper_organization);
         return organization;
     }
+
+    /**
+     * @Description: ������������������������������������
+     * @Param: []
+     * @return: java.util.List<com.moral.api.entity.Organization>
+     * @Author: ���������
+     * @Date: 2021/4/14
+     */
+    @Override
+    public List<Organization> getAllChildrenOrganization(Integer parentId) {
+        List<Organization> children = new ArrayList<>();
+        recursionQueryChildren(parentId, children);
+        return children;
+    }
+
+    /**
+     * @Description: ���������������������������������������������������children���
+     * @Param: [parent, children]
+     * @return: void
+     * @Author: ���������
+     * @Date: 2021/4/14
+     */
+    private void recursionQueryChildren(Integer parentId, List<Organization> children) {
+        QueryWrapper<Organization> queryWrapper = new QueryWrapper();
+        queryWrapper.eq("is_delete", Constants.NOT_DELETE);
+        queryWrapper.eq("parent_id", parentId);
+        List<Organization> organizations = organizationMapper.selectList(queryWrapper);
+        if (!ObjectUtils.isEmpty(organizations)) {
+            children.addAll(organizations);
+            for (Organization organization : organizations) {
+                recursionQueryChildren(organization.getId(), children);
+            }
+        } else {
+            return;
+        }
+    }
 }
diff --git a/screen-job/src/main/java/com/moral/api/service/impl/SysAreaServiceImpl.java b/screen-job/src/main/java/com/moral/api/service/impl/SysAreaServiceImpl.java
new file mode 100644
index 0000000..bb3c36e
--- /dev/null
+++ b/screen-job/src/main/java/com/moral/api/service/impl/SysAreaServiceImpl.java
@@ -0,0 +1,20 @@
+package com.moral.api.service.impl;
+
+import com.moral.api.entity.SysArea;
+import com.moral.api.mapper.SysAreaMapper;
+import com.moral.api.service.SysAreaService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * ��������������� ���������������
+ * </p>
+ *
+ * @author moral
+ * @since 2021-11-15
+ */
+@Service
+public class SysAreaServiceImpl extends ServiceImpl<SysAreaMapper, SysArea> implements SysAreaService {
+
+}
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
new file mode 100644
index 0000000..31bc955
--- /dev/null
+++ b/screen-job/src/main/java/com/moral/api/task/AlarmTask.java
@@ -0,0 +1,794 @@
+package com.moral.api.task;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.moral.api.entity.*;
+import com.moral.api.mapper.*;
+import com.moral.api.service.HistoryHourlyService;
+import com.moral.api.service.OrganizationService;
+import com.moral.constant.Constants;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
+
+import javax.annotation.Resource;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @program: screen
+ * @description: ������������������
+ * @author: lizijie
+ * @create: 2021-11-09 11:07
+ **/
+@Component
+public class AlarmTask {
+
+    @Resource
+    private OrganizationService organizationService;
+
+    @Resource
+    private HistoryHourlyService historyHourlyService;
+
+    @Autowired(required = false)
+    private DeviceMapper deviceMapper;
+
+    @Autowired(required = false)
+    private AlarmInfoMapper alarmInfoMapper;
+
+    @Autowired(required = false)
+    private OrganizationMapper organizationMapper;
+
+    @Autowired(required = false)
+    private CityAqiMapper cityAqiMapper;
+
+    @Autowired(required = false)
+    private SysAreaMapper sysAreaMapper;
+
+    @Autowired(required = false)
+    private HistoryAqiMapper historyAqiMapper;
+
+    @Autowired(required = false)
+    private GovMonitorPointMapper govMonitorPointMapper;
+
+    @XxlJob("alarmInfoInsert")
+    public ReturnT informationInsert(){
+        String params = XxlJobHelper.getJobParam();
+        Map organizationIdMap = JSON.parseObject(params);
+        List<Integer> orgIdList = (List<Integer>) organizationIdMap.get("orgId");
+        //������������
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
+        Calendar calendar = Calendar.getInstance();
+        String alarmTime = df.format(calendar.getTime())+":00:00";
+        calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
+        //Date nearData = calendar.getTime();
+        String beforTime = df.format(calendar.getTime())+":00:00";
+        calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
+        //Date previousData = calendar.getTime();
+        String previousTime = df.format(calendar.getTime())+":00:00";
+        //���������������������������������id
+        List<Integer> allOrgId = new ArrayList<>();
+        allOrgId.addAll(orgIdList);
+        //������������
+        for (Integer orgId:orgIdList) {
+            //���������������
+            List<Organization> allChildrenOrganization = organizationService.getAllChildrenOrganization(orgId);
+            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(allChildrenOrganization) || allChildrenOrganization.size() < 1){
+                for (Organization organization:allChildrenOrganization) {
+                    allOrgId.add(organization.getId());
+                }
+            }
+        }
+        //������������
+        List<Integer> allOrgIdWithoutDuplicates = allOrgId.stream().distinct().collect(Collectors.toList());
+        for (Integer orgId:allOrgIdWithoutDuplicates) {
+            //������id������������������
+            QueryWrapper<Organization> wrapper_organization = new QueryWrapper<>();
+            wrapper_organization.eq("is_delete",Constants.NOT_DELETE).eq("id",orgId);
+            Organization organization = new Organization();
+            organization = organizationMapper.selectOne(wrapper_organization);
+            //������id������������������
+            QueryWrapper<Device> wrapper_device = new QueryWrapper<>();
+            wrapper_device.eq("is_delete",Constants.NOT_DELETE).eq("organization_id",orgId);
+            List<Device> devices = new ArrayList<>();
+            devices = deviceMapper.selectList(wrapper_device);
+            if (devices.size()>0){
+                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                Date alarmDate = new Date();
+                Date nearDate = new Date();
+                Date previousDate = new Date();
+                try {
+                    alarmDate = dateFormat.parse(alarmTime);
+                    nearDate = dateFormat.parse(beforTime);
+                    previousDate = dateFormat.parse(previousTime);
+                }catch (ParseException e){
+                    e.printStackTrace();
+                }
+                for (Device device:devices) {
+                    AlarmInfo alarmInfo = new AlarmInfo();
+                    alarmInfo.setAlarmTime(alarmDate);
+                    int deviceId = device.getId();
+                    alarmInfo.setDeviceId(deviceId);
+                    String mac = device.getMac();
+                    List<HistoryHourly> historyHourlys = null;
+                    historyHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), nearDate, nearDate);
+                    if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyHourlys) || historyHourlys.size()<1){
+                        continue;
+                    }
+                    HistoryHourly historyHourly = new HistoryHourly();
+                    historyHourly = historyHourlys.get(0);
+                    if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyHourly)){
+                        continue;
+                    }
+                    Double PM2_5 = null;
+                    Double PM10 = null;
+                    Double SO2 = null;
+                    Double NO2 = null;
+                    Double CO = null;
+                    Double O3 = null;
+                    String value = historyHourly.getValue();
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject = JSONObject.parseObject(value);
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a34004"))){
+                        PM2_5=(Double.parseDouble(jsonObject.get("a34004").toString()));
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a34002"))){
+                        PM10=(Double.parseDouble(jsonObject.get("a34002").toString()));
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a21026"))){
+                        SO2=(Double.parseDouble(jsonObject.get("a21026").toString()));
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a21004"))){
+                        NO2=(Double.parseDouble(jsonObject.get("a21004").toString()));
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a21005"))){
+                        CO=(Double.parseDouble(jsonObject.get("a21005").toString()));
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(jsonObject.get("a05024"))){
+                        O3=(Double.parseDouble(jsonObject.get("a05024").toString()));
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(PM2_5)){
+                        if (PM2_5>75){
+                            alarmInfo.setIndex("PM2_5");
+                            alarmInfo.setAlarmType("������");
+                            String alarmInformation = "������["+device.getName()+"][PM2.5]���������["+PM2_5+"]������������������������[75]";
+                            alarmInfo.setAlarmInformation(alarmInformation);
+                            alarmInfoMapper.insert(alarmInfo);
+                            continue;
+                        }
+                        Double previousPM2_5 = null;
+                        List<HistoryHourly> previoushistoryHourlys = null;
+                        previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate);
+                        HistoryHourly previousHistoryHourly = new HistoryHourly();
+                        if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){
+                            previousHistoryHourly = previoushistoryHourlys.get(0);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){
+                                String previousValue = previousHistoryHourly.getValue();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(previousValue);
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a34004"))){
+                                    previousPM2_5=(Double.parseDouble(previousJsonObject.get("a34004").toString()));
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousPM2_5) && previousPM2_5!=0){
+                            if (PM2_5/previousPM2_5 > 2 || PM2_5/previousPM2_5 == 2){
+                                String multiple = String.format("%.2f",PM2_5/previousPM2_5);
+                                alarmInfo.setIndex("PM2_5");
+                                alarmInfo.setAlarmType("���������");
+                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][PM2.5]���������["+PM2_5+"]������������������������["+previousPM2_5+"]���"+multiple+"���";
+                                alarmInfo.setAlarmInformation(alarmInformation);
+                                alarmInfoMapper.insert(alarmInfo);
+                                continue;
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){
+                            int cityCode = organization.getCityCode();
+                            QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>();
+                            wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime);
+                            CityAqi cityAqi = null;
+                            cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){
+                                String cityAqiValue = cityAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double cityAqiPM2_5 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString()));
+                                if (PM2_5/cityAqiPM2_5 >=1.5){
+                                    double multiple = PM2_5/cityAqiPM2_5;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }
+                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("area_code",cityCode);
+                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("PM2_5");
+                                    alarmInfo.setAlarmType("������������������"+multiple+"%");
+                                    String alarmInformation = "["+device.getName()+"][PM2.5]���������["+PM2_5+"]������["+sysArea.getAreaName()+"]������["+cityAqiPM2_5+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){
+                            String guid = device.getGuid();
+                            QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>();
+                            historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime);
+                            HistoryAqi historyAqi = null;
+                            historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){
+                                String cityAqiValue = historyAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double govMonitorPointPM2_5 = null;
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){
+                                    govMonitorPointPM2_5 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString()));
+                                }
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointPM2_5) && PM2_5/govMonitorPointPM2_5 >=1){
+                                    double multiple = PM2_5/govMonitorPointPM2_5;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }else if (multiple >= 1){
+                                        percentage = 100;
+                                    }
+                                    QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("guid",guid);
+                                    GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("PM2_5");
+                                    alarmInfo.setAlarmType("���������������"+multiple+"%");
+                                    String alarmInformation = "["+device.getName()+"][PM2.5]���������["+PM2_5+"]������["+govMonitorPoint.getName()+"]������["+govMonitorPointPM2_5+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(PM10)){
+                        if (PM10>75150){
+                            alarmInfo.setIndex("PM10");
+                            alarmInfo.setAlarmType("������");
+                            String alarmInformation = "������["+device.getName()+"][PM10]���������["+PM10+"]������������������������[150]";
+                            alarmInfo.setAlarmInformation(alarmInformation);
+                            alarmInfoMapper.insert(alarmInfo);
+                            continue;
+                        }
+                        Double previousPM10 = null;
+                        List<HistoryHourly> previoushistoryHourlys = null;
+                        previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate);
+                        HistoryHourly previousHistoryHourly = new HistoryHourly();
+                        if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){
+                            previousHistoryHourly = previoushistoryHourlys.get(0);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){
+                                String previousValue = previousHistoryHourly.getValue();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(previousValue);
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a34002"))){
+                                    previousPM10=(Double.parseDouble(previousJsonObject.get("a34002").toString()));
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousPM10) && previousPM10!=0){
+                            if (PM10/previousPM10 > 2 || PM10/previousPM10 == 2){
+                                String multiple = String.format("%.2f",PM10/previousPM10);
+                                alarmInfo.setIndex("PM10");
+                                alarmInfo.setAlarmType("���������");
+                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][PM10]���������["+PM10+"]������������������������["+previousPM10+"]���"+multiple+"���";
+                                alarmInfo.setAlarmInformation(alarmInformation);
+                                alarmInfoMapper.insert(alarmInfo);
+                                continue;
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){
+                            int cityCode = organization.getCityCode();
+                            QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>();
+                            wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime);
+                            CityAqi cityAqi = null;
+                            cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){
+                                String cityAqiValue = cityAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double cityAqiPM10 = (Double.parseDouble(previousJsonObject.get("PM10").toString()));
+                                if (PM10/cityAqiPM10 >=1.5){
+                                    double multiple = PM10/cityAqiPM10;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }
+                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("area_code",cityCode);
+                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("PM10");
+                                    alarmInfo.setAlarmType("������������������"+percentage+"%");
+                                    String alarmInformation = "["+device.getName()+"][PM10]���������["+PM10+"]������["+sysArea.getAreaName()+"]������["+cityAqiPM10+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){
+                            String guid = device.getGuid();
+                            QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>();
+                            historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime);
+                            HistoryAqi historyAqi = null;
+                            historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){
+                                String cityAqiValue = historyAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double govMonitorPointPM10 = null;
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){
+                                    govMonitorPointPM10 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString()));
+                                }
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointPM10) && PM10/govMonitorPointPM10 >=1){
+                                    double multiple = PM10/govMonitorPointPM10;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }else if (multiple >= 1){
+                                        percentage = 100;
+                                    }
+                                    QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("guid",guid);
+                                    GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("PM10");
+                                    alarmInfo.setAlarmType("���������������"+percentage+"%");
+                                    String alarmInformation = "["+device.getName()+"][PM10]���������["+PM10+"]������["+govMonitorPoint.getName()+"]������["+govMonitorPointPM10+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(SO2)){
+                        if (SO2>500){
+                            alarmInfo.setIndex("SO2");
+                            alarmInfo.setAlarmType("������");
+                            String alarmInformation = "������["+device.getName()+"][SO2]���������["+SO2+"]������������������������[75]";
+                            alarmInfo.setAlarmInformation(alarmInformation);
+                            alarmInfoMapper.insert(alarmInfo);
+                            continue;
+                        }
+                        Double previousSO2 = null;
+                        List<HistoryHourly> previoushistoryHourlys = null;
+                        previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate);
+                        HistoryHourly previousHistoryHourly = new HistoryHourly();
+                        if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){
+                            previousHistoryHourly = previoushistoryHourlys.get(0);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){
+                                String previousValue = previousHistoryHourly.getValue();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(previousValue);
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a21026"))){
+                                    previousSO2=(Double.parseDouble(previousJsonObject.get("a21026").toString()));
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousSO2) && previousSO2!=0){
+                            if (SO2/previousSO2 > 2 || SO2/previousSO2 == 2){
+                                String multiple = String.format("%.2f",SO2/previousSO2);
+                                alarmInfo.setIndex("SO2");
+                                alarmInfo.setAlarmType("���������");
+                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][SO2]���������["+SO2+"]������������������������["+previousSO2+"]���"+multiple+"���";
+                                alarmInfo.setAlarmInformation(alarmInformation);
+                                alarmInfoMapper.insert(alarmInfo);
+                                continue;
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){
+                            int cityCode = organization.getCityCode();
+                            QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>();
+                            wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime);
+                            CityAqi cityAqi = null;
+                            cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){
+                                String cityAqiValue = cityAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double cityAqiSO2 = (Double.parseDouble(previousJsonObject.get("SO2").toString()));
+                                if (SO2/cityAqiSO2 >=1.5){
+                                    double multiple = SO2/cityAqiSO2;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }
+                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("area_code",cityCode);
+                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("SO2");
+                                    alarmInfo.setAlarmType("������������������"+percentage+"%");
+                                    String alarmInformation = "["+device.getName()+"][SO2]���������["+SO2+"]������["+sysArea.getAreaName()+"]������["+cityAqiSO2+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){
+                            String guid = device.getGuid();
+                            QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>();
+                            historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime);
+                            HistoryAqi historyAqi = null;
+                            historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){
+                                String cityAqiValue = historyAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double govMonitorPointSO2 = null;
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){
+                                    govMonitorPointSO2 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString()));
+                                }
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointSO2) && SO2/govMonitorPointSO2 >=1){
+                                    double multiple = SO2/govMonitorPointSO2;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }else if (multiple >= 1){
+                                        percentage = 100;
+                                    }
+                                    QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("guid",guid);
+                                    GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("SO2");
+                                    alarmInfo.setAlarmType("���������������"+percentage+"%");
+                                    String alarmInformation = "["+device.getName()+"][SO2]���������["+SO2+"]������["+govMonitorPoint.getName()+"]������["+govMonitorPointSO2+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(NO2)){
+                        if (NO2>200){
+                            alarmInfo.setIndex("NO2");
+                            alarmInfo.setAlarmType("������");
+                            String alarmInformation = "������["+device.getName()+"][NO2]���������["+NO2+"]������������������������[75]";
+                            alarmInfo.setAlarmInformation(alarmInformation);
+                            alarmInfoMapper.insert(alarmInfo);
+                            continue;
+                        }
+                        Double previousNO2 = null;
+                        List<HistoryHourly> previoushistoryHourlys = null;
+                        previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate);
+                        HistoryHourly previousHistoryHourly = new HistoryHourly();
+                        if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){
+                            previousHistoryHourly = previoushistoryHourlys.get(0);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){
+                                String previousValue = previousHistoryHourly.getValue();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(previousValue);
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a21004"))){
+                                    previousNO2=(Double.parseDouble(previousJsonObject.get("a21004").toString()));
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousNO2) && previousNO2!=0){
+                            if (NO2/previousNO2 > 2 || NO2/previousNO2 == 2){
+                                String multiple = String.format("%.2f",NO2/previousNO2);
+                                alarmInfo.setIndex("NO2");
+                                alarmInfo.setAlarmType("���������");
+                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][NO2]���������["+NO2+"]������������������������["+previousNO2+"]���"+multiple+"���";
+                                alarmInfo.setAlarmInformation(alarmInformation);
+                                alarmInfoMapper.insert(alarmInfo);
+                                continue;
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){
+                            int cityCode = organization.getCityCode();
+                            QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>();
+                            wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime);
+                            CityAqi cityAqi = null;
+                            cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){
+                                String cityAqiValue = cityAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double cityAqiNO2 = (Double.parseDouble(previousJsonObject.get("NO2").toString()));
+                                if (NO2/cityAqiNO2 >=1.5){
+                                    double multiple = NO2/cityAqiNO2;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }
+                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("area_code",cityCode);
+                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("NO2");
+                                    alarmInfo.setAlarmType("������������������"+percentage+"%");
+                                    String alarmInformation = "["+device.getName()+"][NO2]���������["+NO2+"]������["+sysArea.getAreaName()+"]������["+cityAqiNO2+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){
+                            String guid = device.getGuid();
+                            QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>();
+                            historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime);
+                            HistoryAqi historyAqi = null;
+                            historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){
+                                String cityAqiValue = historyAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double govMonitorPointNO2 = null;
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){
+                                    govMonitorPointNO2 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString()));
+                                }
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointNO2) && NO2/govMonitorPointNO2 >=1){
+                                    double multiple = NO2/govMonitorPointNO2;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }else if (multiple >= 1){
+                                        percentage = 100;
+                                    }
+                                    QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("guid",guid);
+                                    GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("NO2");
+                                    alarmInfo.setAlarmType("���������������"+percentage+"%");
+                                    String alarmInformation = "["+device.getName()+"][NO2]���������["+NO2+"]������["+govMonitorPoint.getName()+"]������["+govMonitorPointNO2+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(CO)){
+                        if (CO>10){
+                            alarmInfo.setIndex("CO");
+                            alarmInfo.setAlarmType("������");
+                            String alarmInformation = "������["+device.getName()+"][CO]���������["+CO+"]������������������������[75]";
+                            alarmInfo.setAlarmInformation(alarmInformation);
+                            alarmInfoMapper.insert(alarmInfo);
+                            continue;
+                        }
+                        Double previousCO = null;
+                        List<HistoryHourly> previoushistoryHourlys = null;
+                        previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate);
+                        HistoryHourly previousHistoryHourly = new HistoryHourly();
+                        if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){
+                            previousHistoryHourly = previoushistoryHourlys.get(0);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){
+                                String previousValue = previousHistoryHourly.getValue();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(previousValue);
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a21005"))){
+                                    previousCO=(Double.parseDouble(previousJsonObject.get("a21005").toString()));
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousCO) && previousCO!=0){
+                            if (CO/previousCO > 2 || CO/previousCO == 2){
+                                String multiple = String.format("%.2f",CO/previousCO);
+                                alarmInfo.setIndex("CO");
+                                alarmInfo.setAlarmType("���������");
+                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][CO]���������["+CO+"]������������������������["+previousCO+"]���"+multiple+"���";
+                                alarmInfo.setAlarmInformation(alarmInformation);
+                                alarmInfoMapper.insert(alarmInfo);
+                                continue;
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){
+                            int cityCode = organization.getCityCode();
+                            QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>();
+                            wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime);
+                            CityAqi cityAqi = null;
+                            cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){
+                                String cityAqiValue = cityAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double cityAqiCO = (Double.parseDouble(previousJsonObject.get("CO").toString()));
+                                if (CO/cityAqiCO >=1.5){
+                                    double multiple = CO/cityAqiCO;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }
+                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("area_code",cityCode);
+                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("CO");
+                                    alarmInfo.setAlarmType("������������������"+percentage+"%");
+                                    String alarmInformation = "["+device.getName()+"][CO]���������["+CO+"]������["+sysArea.getAreaName()+"]������["+cityAqiCO+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){
+                            String guid = device.getGuid();
+                            QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>();
+                            historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime);
+                            HistoryAqi historyAqi = null;
+                            historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){
+                                String cityAqiValue = historyAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double govMonitorPointCO = null;
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){
+                                    govMonitorPointCO = (Double.parseDouble(previousJsonObject.get("PM2_5").toString()));
+                                }
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointCO) && CO/govMonitorPointCO >=1){
+                                    double multiple = CO/govMonitorPointCO;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }else if (multiple >= 1){
+                                        percentage = 100;
+                                    }
+                                    QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("guid",guid);
+                                    GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("CO");
+                                    alarmInfo.setAlarmType("���������������"+percentage+"%");
+                                    String alarmInformation = "["+device.getName()+"][CO]���������["+CO+"]������["+govMonitorPoint.getName()+"]������["+govMonitorPointCO+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                    }
+                    if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(O3)){
+                        if (O3>200){
+                            alarmInfo.setIndex("O3");
+                            alarmInfo.setAlarmType("������");
+                            String alarmInformation = "������["+device.getName()+"][O3]���������["+O3+"]������������������������[75]";
+                            alarmInfo.setAlarmInformation(alarmInformation);
+                            alarmInfoMapper.insert(alarmInfo);
+                            continue;
+                        }
+                        Double previousO3 = null;
+                        List<HistoryHourly> previoushistoryHourlys = null;
+                        previoushistoryHourlys = historyHourlyService.getValueByMacAndTime(device.getMac(), previousDate, previousDate);
+                        HistoryHourly previousHistoryHourly = new HistoryHourly();
+                        if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previoushistoryHourlys) || historyHourlys.size()<1){
+                            previousHistoryHourly = previoushistoryHourlys.get(0);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousHistoryHourly)){
+                                String previousValue = previousHistoryHourly.getValue();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(previousValue);
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("a05024"))){
+                                    previousO3=(Double.parseDouble(previousJsonObject.get("a05024").toString()));
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousO3) && previousO3!=0){
+                            if (O3/previousO3 > 2 || O3/previousO3 == 2){
+                                String multiple = String.format("%.2f",O3/previousO3);
+                                alarmInfo.setIndex("O3");
+                                alarmInfo.setAlarmType("���������");
+                                String alarmInformation = "["+device.getName()+"]["+beforTime+"][O3]���������["+O3+"]������������������������["+previousO3+"]���"+multiple+"���";
+                                alarmInfo.setAlarmInformation(alarmInformation);
+                                alarmInfoMapper.insert(alarmInfo);
+                                continue;
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(organization)){
+                            int cityCode = organization.getCityCode();
+                            QueryWrapper<CityAqi> wrapper_cityAqi = new QueryWrapper<>();
+                            wrapper_cityAqi.eq("city_code",cityCode).eq("time",previousTime);
+                            CityAqi cityAqi = null;
+                            cityAqi = cityAqiMapper.selectOne(wrapper_cityAqi);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(cityAqi)){
+                                String cityAqiValue = cityAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double cityAqiO3 = (Double.parseDouble(previousJsonObject.get("O3").toString()));
+                                if (O3/cityAqiO3 >=1.5){
+                                    double multiple = O3/cityAqiO3;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }
+                                    QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("area_code",cityCode);
+                                    SysArea sysArea = sysAreaMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("O3");
+                                    alarmInfo.setAlarmType("������������������"+percentage+"%");
+                                    String alarmInformation = "["+device.getName()+"][O3]���������["+O3+"]������["+sysArea.getAreaName()+"]������["+cityAqiO3+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                        if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(device.getGuid())){
+                            String guid = device.getGuid();
+                            QueryWrapper<HistoryAqi> historyAqiQueryWrapper = new QueryWrapper<>();
+                            historyAqiQueryWrapper.eq("guid",guid).eq("time",previousTime);
+                            HistoryAqi historyAqi = null;
+                            historyAqi = historyAqiMapper.selectOne(historyAqiQueryWrapper);
+                            if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(historyAqi)){
+                                String cityAqiValue = historyAqi.getValue();
+                                JSONObject JsonObject = new JSONObject();
+                                JSONObject previousJsonObject = new JSONObject();
+                                previousJsonObject = JSONObject.parseObject(cityAqiValue);
+                                Double govMonitorPointO3 = null;
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(previousJsonObject.get("PM2_5"))){
+                                    govMonitorPointO3 = (Double.parseDouble(previousJsonObject.get("PM2_5").toString()));
+                                }
+                                if (!com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(govMonitorPointO3) && O3/govMonitorPointO3 >=1){
+                                    double multiple = O3/govMonitorPointO3;
+                                    int percentage = 0;
+                                    if (multiple >= 2.5){
+                                        percentage = 250;
+                                    }else if (multiple >= 1.5){
+                                        percentage = 150;
+                                    }else if (multiple >= 1){
+                                        percentage = 100;
+                                    }
+                                    QueryWrapper<GovMonitorPoint> sysAreaQueryWrapper = new QueryWrapper<>();
+                                    sysAreaQueryWrapper.eq("guid",guid);
+                                    GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectOne(sysAreaQueryWrapper);
+                                    alarmInfo.setIndex("O3");
+                                    alarmInfo.setAlarmType("���������������"+percentage+"%");
+                                    String alarmInformation = "["+device.getName()+"][O3]���������["+O3+"]������["+govMonitorPoint.getName()+"]������["+govMonitorPointO3+"]���"+percentage+"%";
+                                    alarmInfo.setAlarmInformation(alarmInformation);
+                                    alarmInfoMapper.insert(alarmInfo);
+                                    continue;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return ReturnT.SUCCESS;
+    }
+
+
+}
diff --git a/screen-job/src/main/resources/mapper/AlarmInfoMapper.xml b/screen-job/src/main/resources/mapper/AlarmInfoMapper.xml
new file mode 100644
index 0000000..7cf5bc0
--- /dev/null
+++ b/screen-job/src/main/resources/mapper/AlarmInfoMapper.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.moral.api.mapper.AlarmInfoMapper">
+
+        <!-- ������������������������ -->
+        <resultMap id="BaseResultMap" type="com.moral.api.entity.AlarmInfo">
+                    <id column="id" property="id" />
+                    <result column="alarm_time" property="alarmTime" />
+                    <result column="index" property="index" />
+                    <result column="device_id" property="deviceId" />
+                    <result column="alarm_type" property="alarmType" />
+                    <result column="alarm_information" property="alarmInformation" />
+                    <result column="create_time" property="createTime" />
+        </resultMap>
+
+</mapper>
\ No newline at end of file
diff --git a/screen-job/src/main/resources/mapper/SysAreaMapper.xml b/screen-job/src/main/resources/mapper/SysAreaMapper.xml
new file mode 100644
index 0000000..97e12e8
--- /dev/null
+++ b/screen-job/src/main/resources/mapper/SysAreaMapper.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.moral.api.mapper.SysAreaMapper">
+
+        <!-- ������������������������ -->
+        <resultMap id="BaseResultMap" type="com.moral.api.entity.SysArea">
+                    <id column="area_code" property="areaCode" />
+                    <result column="area_name" property="areaName" />
+                    <result column="parent_code" property="parentCode" />
+        </resultMap>
+
+</mapper>
\ No newline at end of file

--
Gitblit v1.8.0