From 3d4d654cb24bc2293d964e8f1bc52418c089c6ee Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Sun, 25 Dec 2016 16:25:15 +0800
Subject: [PATCH] Bug修正,解决三级警报被误判成二级的判错误

---
 method.js |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/method.js b/method.js
index c53e226..0148b5d 100644
--- a/method.js
+++ b/method.js
@@ -4,6 +4,7 @@
 
 var moment = require('moment');
 var config = require('./config');
+var queue = require('./queue');
 
 module.exports.toDec = function(hex) {
     if(typeof hex === 'number') {
@@ -93,7 +94,7 @@
     this.updateDeviceLastUpdated(db, mac, function(data) {});
     
     db.collection("devices").find({ mac: mac }).limit(1).next(function(err, doc){
-        if (err) return;
+        if (err || doc == null) return;
         callback(doc);
     });
 };
@@ -168,6 +169,57 @@
 
     var current = moment();
 
+    queue.pushToMQ('ex_data_screen', {
+        mac: mac,
+        location: {
+            lat: 31.430616,
+            lng: 120.988327
+        },
+        data: {
+            x0: ferval,
+            x1: x1,  //PM2.5 - (������:ppm)
+            x2: x3,  //PM2.5 - 0.1���0.3um���
+            x3: x9,  //������
+            x4: x11, //������
+            x5: x10, //������
+            x6: x14  //������������
+        },
+        time: current.valueOf()
+    });
+
+    if(x1 > 250) {
+        var level = 1;
+        if(x1 > 750) {
+            level = 3;
+        } else if(x1 > 500) {
+            level = 2;
+        }
+        queue.pushToMQ('ex_data_alarm', {
+            mac: mac,
+            address: "���������������������������������",
+            location: {
+                lat:31.430616,
+                lng:120.988327
+            },
+            data:{
+                x0: ferval,
+                x1: x1,  //PM2.5
+                x2: x3,  //PM2.5
+                x3: x9,  //������
+                x4: x11, //������
+                x5: x10, //������
+                x6: x14  //������������
+            },
+            level: level,
+            notice: {
+                tel: "15950198162",
+                email: "it01@moral.org.cn",
+                open_id: "o-RTuwvMHWotyirPHLmdSB_dKoQU"
+            },
+            time: moment.valueOf()
+        });
+    }
+
     var rank = 0;
     if(s > 0) {
         rank = this.random(1000, 99999);//this.random(1000, 99999999);

--
Gitblit v1.8.0