| | |
| | | time: current.valueOf() |
| | | }); |
| | | |
| | | if(x1 >= 500) { |
| | | queue.pushToAlarm({ |
| | | mac: mac, |
| | | address: "江苏省昆山市摩瑞尔电器", |
| | | location: { |
| | | lat:31.430616, |
| | | lng:120.988327 |
| | | }, |
| | | data:{ |
| | | x1: x1, //PM2.5 |
| | | x2: x3, //PM2.5 |
| | | x3: x9, //甲醛 |
| | | x4: x11, //温度 |
| | | x5: x10, //湿度 |
| | | x6: x14 //光照强度 |
| | | }, |
| | | level: 1, |
| | | 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); |
| | |
| | | conn.close(); |
| | | }, 500); |
| | | }); |
| | | }; |
| | | |
| | | module.exports.pushToAlarm = function(data) { |
| | | amqp.connect(uri, function(err, conn) { |
| | | conn.createChannel(function(err, ch) { |
| | | var _ex = 'ex_data_alarm'; |
| | | ch.assertExchange(_ex, 'fanout', { durable: false }); |
| | | ch.publish(_ex, '', new Buffer(JSON.stringify(data))); |
| | | }); |
| | | setTimeout(function() { |
| | | conn.close(); |
| | | }, 500); |
| | | }); |
| | | }; |