From e1ce5290da9d22522a9e80f473e1c24beb3c9196 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 29 Mar 2017 18:02:51 +0800 Subject: [PATCH] update --- route/api/modbus.js | 1 + route/api/wristband.js | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/route/api/modbus.js b/route/api/modbus.js index 9db5c52..4c8ccbc 100644 --- a/route/api/modbus.js +++ b/route/api/modbus.js @@ -213,6 +213,7 @@ router d.`uid` = ? \ and rt.`type` = ? \ and i.`uid` is not null \ + and ( a.`name` is not null or rt.`type` in (1,2)) \ 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]; diff --git a/route/api/wristband.js b/route/api/wristband.js index d6ca376..daa1825 100644 --- a/route/api/wristband.js +++ b/route/api/wristband.js @@ -23,12 +23,13 @@ router let arr = req.query; if(!arr.mac) return n('ERR0000'); + if(!arr.devid) return n('ERR0000'); let query = "insert into ??.?? values (null, ?, ?,?,?,?,?,?,?,?,?,?,?,?,unix_timestamp())"; let param = [ config.db.db9, 'rawdata', + arr.devid || '', arr.mac || '', - arr.val1 || '', arr.val2 || '', arr.val3 || '', arr.val4 || '', @@ -58,6 +59,28 @@ router } 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); module.exports = router; \ No newline at end of file