add modbus preview page

This commit is contained in:
Jay
2017-04-12 14:26:01 +08:00
parent 64ad807310
commit e5bf72435c
7 changed files with 5756 additions and 5424 deletions
+49
View File
@@ -228,6 +228,55 @@ router
return n();
});
})
.post('/getalliostatus', (req, res, n) => {
if (!config.permission.modbus) return n('ERR9000');
let pros = [];
let query = "select rt.*, a.`name` as name \
from ??.?? rt \
left join ??.?? d \
on d.`node` = rt.`node` \
left join ??.?? i \
on i.`devuid` = d.`uid` \
and i.`type` = rt.`type` \
left join ??.?? a \
on a.`iouid` = i.`uid` \
and a.`portnum` = rt.`port`\
where \
i.`uid` is not null \
and ( a.`name` is not null or rt.`type` in (1,2)) \
order by rt.`type` asc, rt.`port` asc";
let param = [config.db.db6, 'jcmbrt', config.db.db5, 'device', config.db.db5, 'iolist', config.db.db5, 'aioset'];
pros.push(tool.promiseQuery(res, query, param, 'record'));
let rtq = "select * from ??.?? ";
let rtp = [config.db.db5, 'device'];
pros.push(tool.promiseQuery(res, rtq, rtp, 'rt'));
res.api_res = {
record: [],
rt: {
device: []
}
}
Promise.all(pros)
.then(d => {
for (let i in d) {
if (d[i].key == 'record') {
res.api_res.record = tool.checkArray(d[i].data);
}
if (d[i].key == 'rt') {
res.api_res.rt.device = tool.checkArray(d[i].data);
}
}
n();
})
.catch(err => rt.err(res, err, n, 'ERR8000'));
})
.post('/getiolist', (req, res, n) => {
if (!config.permission.modbus) return n('ERR9000');
let arr = req.body;