This commit is contained in:
Jay 2017-03-29 18:02:51 +08:00
parent 3e66691b67
commit e1ce5290da
2 changed files with 25 additions and 1 deletions

View File

@ -213,6 +213,7 @@ router
d.`uid` = ? \ d.`uid` = ? \
and rt.`type` = ? \ and rt.`type` = ? \
and i.`uid` is not null \ and i.`uid` is not null \
and ( a.`name` is not null or rt.`type` in (1,2)) \
order by rt.`port` asc"; order by rt.`port` asc";
let param = [config.db.db6, 'jcmbrt', config.db.db5, 'device', config.db.db5, 'iolist', arr.data.type, config.db.db5, 'aioset', arr.data.id, arr.data.type]; let param = [config.db.db6, 'jcmbrt', config.db.db5, 'device', config.db.db5, 'iolist', arr.data.type, config.db.db5, 'aioset', arr.data.id, arr.data.type];

View File

@ -23,12 +23,13 @@ router
let arr = req.query; let arr = req.query;
if(!arr.mac) return n('ERR0000'); if(!arr.mac) return n('ERR0000');
if(!arr.devid) return n('ERR0000');
let query = "insert into ??.?? values (null, ?, ?,?,?,?,?,?,?,?,?,?,?,?,unix_timestamp())"; let query = "insert into ??.?? values (null, ?, ?,?,?,?,?,?,?,?,?,?,?,?,unix_timestamp())";
let param = [ let param = [
config.db.db9, config.db.db9,
'rawdata', 'rawdata',
arr.devid || '',
arr.mac || '', arr.mac || '',
arr.val1 || '',
arr.val2 || '', arr.val2 || '',
arr.val3 || '', arr.val3 || '',
arr.val4 || '', arr.val4 || '',
@ -58,6 +59,28 @@ router
} }
n(); n();
}) })
.post('/getstatus', (req,res,n) => {
let query = "select * from \
(\
select xx.*, l.`name` from ??.?? xx \
left join ??.?? l \
on l.`serialnumber` = xx.`devid` \
where xx.`timestamp` > unix_timestamp() - 10 \
order by xx.`val11` desc, xx.`timestamp` desc \
limit 65535\
) x \
group by `mac`";
let param = [config.db.db9, 'rawdata', config.db.db9, 'location']
res.db.query(query, param, (err,row) => {
if(err) return n('ERR8000');
res.api_res = {
record: tool.checkArray(row)
}
n();
})
})
.all('*', rt.send); .all('*', rt.send);
module.exports = router; module.exports = router;