From 712a78c4ed22f2b8eee6683f2e79a05b39a50e50 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 26 Apr 2017 17:26:36 +0800 Subject: [PATCH] update --- route/api/wristband.js | 44 +++++++ .../Wristband/WristbandInfo/ListItem.js | 3 +- .../WristbandInfo/WristbandHealthInfo.js | 119 ++++++++++++++++++ .../Wristband/WristbandInfo/index.js | 38 +++++- 4 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 src/components/AdminPage/Wristband/WristbandInfo/WristbandHealthInfo.js diff --git a/route/api/wristband.js b/route/api/wristband.js index 41acfa6..61d1f46 100644 --- a/route/api/wristband.js +++ b/route/api/wristband.js @@ -355,6 +355,50 @@ router .catch(err => rt.err(res, err, n, 'ERR8000')); }) + .post('/getwristbandhealthinfo', (req, res, n) => { + if (!config.permission.wristband) return n('ERR9000'); + let arr = req.body; + if (!arr.data) return n('ERR0000'); + if (!arr.data.mac) return n('ERR0060'); + if (!arr.data.stime || !arr.data.etime) return n('ERR0015'); + + let pros = []; + let query = "select log.* \ + from ??.?? log \ + where \ + log.`wphylogmac` = ? \ + and log.`wphylogtst` >= ? \ + and log.`wphylogtst` <= ? \ + order by log.`wphylogtst` desc"; + let param = [config.db.db9, 'wphylog', arr.data.mac, arr.data.stime, arr.data.etime]; + pros.push(tool.promiseQuery(res, query, param, 'record')); + + let rtq = "select * from ??.?? where `mac` = ?"; + let rtp = [config.db.db9, 'wristband', arr.data.mac]; + pros.push(tool.promiseQuery(res, rtq, rtp, 'rt')); + + res.api_res = { + record: [], + rt: { + wristband: [] + } + } + + Promise.all(pros) + .then(d => { + for (let i in d) { + let tmp = d[i]; + if (tmp.key == 'rt') { + res.api_res.rt.wristband = tool.checkArray(tmp.data); + } + if (tmp.key == 'record') { + res.api_res.record = tool.checkArray(tmp.data); + } + } + return n(); + }) + .catch(err => rt.err(res, err, n, 'ERR8000')); + }) .post('/getlocationlist', (req, res, n) => { if (!config.permission.wristband) return n('ERR9000'); diff --git a/src/components/AdminPage/Wristband/WristbandInfo/ListItem.js b/src/components/AdminPage/Wristband/WristbandInfo/ListItem.js index 5c87e61..ea1d04d 100644 --- a/src/components/AdminPage/Wristband/WristbandInfo/ListItem.js +++ b/src/components/AdminPage/Wristband/WristbandInfo/ListItem.js @@ -1,7 +1,7 @@ import React from 'react'; import { Table, Button } from 'semantic-ui-react'; -const ListItem = ({ i18n, data, delWristband, editWristband, showPathInfo }) => { +const ListItem = ({ i18n, data, delWristband, editWristband, showPathInfo, showHealthInfo }) => { return ( @@ -9,6 +9,7 @@ const ListItem = ({ i18n, data, delWristband, editWristband, showPathInfo }) =>