| | |
| | | var _config = global.configs[mac]; |
| | | if(_config == null) { |
| | | _config = { |
| | | mac: mac, |
| | | address: "江苏省昆山市摩瑞尔电器", |
| | | location: {
|
| | | lat:31.430616, |
| | |
| | | email: "it01@moral.org.cn",
|
| | | open_id: "o-RTuwvMHWotyirPHLmdSB_dKoQU" |
| | | } |
| | | configs[mac] = _config; |
| | | } |
| | | } |
| | | |
| | |
| | | db.collection("devices").find().toArray(function(err, docs) { |
| | | docs.forEach(function(doc) { |
| | | var mac = doc.mac; |
| | | var address = doc.address; |
| | | var location = doc.location; |
| | | var notice = doc.notice; |
| | | if(notice == null) { |
| | | var userID = doc.userID; |
| | | db.collection("users").find({"_id": userID}).limit(1).next(function(err, user){ |
| | | if(user) { |
| | | global.configs[mac] = { |
| | | address: address, |
| | | location: location, |
| | | notice: { |
| | | tel: user.username, |
| | | email: user.email, |
| | | open_id: user.open_id |
| | | if(mac != null) { |
| | | var address = doc.address || ""; |
| | | var location = doc.location || {}; |
| | | var notice = doc.notice; |
| | | if(notice == null || notice == {}) { |
| | | var userID = doc.userID; |
| | | db.collection("users").find({"_id": userID}).limit(1).next(function(err, user){ |
| | | if(user) { |
| | | global.configs[mac] = { |
| | | mac: mac, |
| | | address: address, |
| | | location: location, |
| | | notice: { |
| | | tel: user.username, |
| | | email: user.email, |
| | | open_id: user.open_id |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | global.configs[mac] = { |
| | | mac: mac, |
| | | address: address, |
| | | location: location, |
| | | notice: notice |
| | | } |
| | | }); |
| | | } else { |
| | | global.configs[mac] = { |
| | | address: address, |
| | | location: location, |
| | | notice: notice |
| | | } |
| | | } |
| | | }); |