add modbus log

This commit is contained in:
Jay
2017-03-29 15:06:50 +08:00
parent 77bf5f58d2
commit 3e66691b67
15 changed files with 5579 additions and 4735 deletions
+33
View File
@@ -498,6 +498,39 @@ router
n();
})
})
.post('/getmodbuslog', (req,res,n) => {
if (!config.permission.modbus) return n('ERR9000');
let arr = req.body;
if(!arr.data) return n('ERR0000');
if(!arr.data.ids || !Array.isArray(arr.data.ids)) return n('ERR0028');
if(!arr.data.stime || !arr.data.etime) return n('ERR0015');
let query = "select log.`node`, log.`type`, log.`port`, log.`value2` as value, log.`tst`, dev.`name` as devname, aio.`name` as aioname \
from ??.?? log \
left join ??.?? dev \
on dev.`node` = log.`node`\
left join ??.?? io \
on io.`devuid` = dev.`uid` \
and io.`type` = log.`type` \
left join ??.?? aio \
on aio.`iouid` = io.`uid` \
and aio.`portnum` = log.`port` \
where \
dev.`uid` in (?) \
and ( log.`tst` >= ? \
and log.`tst` <= ? ) \
order by log.`uid` desc, log.`tst` desc \
limit 0, 100";
let param = [config.db.db10, 'jcmbrt', config.db.db5, 'device', config.db.db5, 'iolist', config.db.db5, 'aioset', arr.data.ids, arr.data.stime, arr.data.etime];
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;