Browse Source

测试

master
wenlele 1 year ago
parent
commit
09f1a6e1cd
  1. 1
      api/app/lib/routes/index.js
  2. 51
      api/app/lib/routes/organization/index.js
  3. 90
      api/app/lib/schedule/workorder_statistics.js
  4. 2
      web/client/src/sections/bigScreen/actions/index.js

1
api/app/lib/routes/index.js

@ -9,6 +9,7 @@ module.exports = function (app, router, opts) {
fs.readdirSync(path.join(__dirname, filename)).forEach((api) => { fs.readdirSync(path.join(__dirname, filename)).forEach((api) => {
if (api.indexOf('.') == 0 || api.indexOf('.js') == -1) return; if (api.indexOf('.') == 0 || api.indexOf('.js') == -1) return;
require(`./${filename}/${api}`)(app, router, opts); require(`./${filename}/${api}`)(app, router, opts);
console.log(111,filename,api);
}); });
} }
}); });

51
api/app/lib/routes/organization/index.js

@ -3,38 +3,45 @@
const data = require('../../controllers/bigScreen/index '); const data = require('../../controllers/bigScreen/index ');
module.exports = function (app, router, opts) { module.exports = function (app, router, opts) {
app.fs.api.logAttr['POST/axyData'] = { content: '获取安心云数据', visible: true };
router.post('/axyData', data.axyData);
app.fs.api.logAttr['GET/pumpInformation'] = { content: '获取泵站信息', visible: true }; try {
router.get('/pumpInformation', data.pumpInformation); app.fs.api.logAttr['POST/axyData'] = { content: '获取安心云数据', visible: true };
router.post('/axyData', data.axyData);
app.fs.api.logAttr['get/videoUrl'] = { content: '获取视频监控url', visible: true }; app.fs.api.logAttr['GET/pumpInformation'] = { content: '获取泵站信息', visible: true };
router.get('/videoUrl', data.getVideoUrl); router.get('/pumpInformation', data.pumpInformation);
app.fs.api.logAttr['get/pump/station'] = { content: '获取所有站点信息', visible: true }; app.fs.api.logAttr['get/videoUrl'] = { content: '获取视频监控url', visible: true };
router.get('/pump/station', data.getPumpStation); router.get('/videoUrl', data.getVideoUrl);
console.log('获取视频监控url');
app.fs.api.logAttr['get/pump/station'] = { content: '获取所有站点信息', visible: true };
router.get('/pump/station', data.getPumpStation);
console.log('获取所有站点信息');
app.fs.api.logAttr['get/water/level/all'] = { content: '获取所有泵站七天内最新集水池液位', visible: true }; app.fs.api.logAttr['get/water/level/all'] = { content: '获取所有泵站七天内最新集水池液位', visible: true };
router.get('/water/level/all', data.getPumpStation); router.get('/water/level/all', data.getPumpStation);
app.fs.api.logAttr['get/water/level/six'] = { content: '获取泵站6h最新集水池液位', visible: true }; app.fs.api.logAttr['get/water/level/six'] = { content: '获取泵站6h最新集水池液位', visible: true };
router.get('/water/level/six', data.getPumpStation); router.get('/water/level/six', data.getPumpStation);
app.fs.api.logAttr['get/water/pump/state/all'] = { content: '获取水泵状态', visible: true }; app.fs.api.logAttr['get/water/pump/state/all'] = { content: '获取水泵状态', visible: true };
router.get('/water/pump/state/all', data.getPumpStation); router.get('/water/pump/state/all', data.getPumpStation);
app.fs.api.logAttr['get/capacity'] = { content: '获取能耗监测数据', visible: true }; app.fs.api.logAttr['get/capacity'] = { content: '获取能耗监测数据', visible: true };
router.get('/capacity', data.getPumpStation); router.get('/capacity', data.getPumpStation);
app.fs.api.logAttr['get/currentSix'] = { content: '获取水泵数据', visible: true }; app.fs.api.logAttr['get/currentSix'] = { content: '获取水泵数据', visible: true };
router.get('/currentSix', data.getPumpStation); router.get('/currentSix', data.getPumpStation);
app.fs.api.logAttr['get/cabinet'] = { content: '获取进线柜数据', visible: true }; app.fs.api.logAttr['get/cabinet'] = { content: '获取进线柜数据', visible: true };
router.get('/cabinet', data.getPumpStation); router.get('/cabinet', data.getPumpStation);
app.fs.api.logAttr['get/threePhase'] = { content: '获取三相电流数据', visible: true };
router.get('/threePhase', data.getPumpStation);
} catch (error) {
console.log(error.response);
}
app.fs.api.logAttr['get/threePhase'] = { content: '获取三相电流数据', visible: true };
router.get('/threePhase', data.getPumpStation);

90
api/app/lib/schedule/workorder_statistics.js

@ -22,8 +22,14 @@ module.exports = function (app, opts) {
const { parseProcessData } = app.fs.utils const { parseProcessData } = app.fs.utils
let data = await getAnxinyunToken(app) let data = await getAnxinyunToken(app)
console.log(1111,data);
//获取所有泵站 //获取所有泵站
let structureList = await app.fs.anxinyun.get(`/organizations/${data.orgId}/structures?token=${data.token}`) || [] let structureList = await app.fs.anxinyun.get(`/organizations/${data.orgId}/structures?token=${data.token}`) || []
console.log('获取所有泵站',structureList);
await app.redis.set("pumpStation_structure", JSON.stringify(structureList)) await app.redis.set("pumpStation_structure", JSON.stringify(structureList))
if (structureList.length) { if (structureList.length) {
@ -209,47 +215,47 @@ module.exports = function (app, opts) {
currentSix['struc' + strucOne.id] = JSON.stringify(current.stations) currentSix['struc' + strucOne.id] = JSON.stringify(current.stations)
let threedata = [] // let threedata = []
let timeSet = new Set() // let timeSet = new Set()
if (current.stations && current.stations.length) { // if (current.stations && current.stations.length) {
current.stations.map(p => { // current.stations.map(p => {
p.data.map(s => { // p.data.map(s => {
timeSet.add(moment(s.time).format('YYYY-MM-DD HH:mm:ss')) // timeSet.add(moment(s.time).format('YYYY-MM-DD HH:mm:ss'))
}) // })
}) // })
let time = [...timeSet].sort((a, b) => moment(a).isBefore(b) ? -1 : 1) // let time = [...timeSet].sort((a, b) => moment(a).isBefore(b) ? -1 : 1)
time.map(x => { // time.map(x => {
let A = [] // let A = []
let B = [] // let B = []
let C = [] // let C = []
current.stations.map((s, index) => { // current.stations.map((s, index) => {
let abcData = s.data.find(f => moment(f.time).format('YYYY-MM-DD HH:mm:ss') == x) || {} // let abcData = s.data.find(f => moment(f.time).format('YYYY-MM-DD HH:mm:ss') == x) || {}
let a = abcData.eMotor_A_A // let a = abcData.eMotor_A_A
let b = abcData.eMotor_B_A // let b = abcData.eMotor_B_A
let c = abcData.eMotor_C_A // let c = abcData.eMotor_C_A
if (a) A.push(a) // if (a) A.push(a)
if (b) B.push(b) // if (b) B.push(b)
if (c) C.push(c) // if (c) C.push(c)
}) // })
const sum = (arr) => { // const sum = (arr) => {
let sum = 0 // let sum = 0
arr.map(h => { // arr.map(h => {
sum += h // sum += h
}) // })
return sum // return sum
} // }
threedata.push({ // threedata.push({
A: A.length && (sum(A) / A.length) || null, // A: A.length && (sum(A) / A.length) || null,
B: B.length && (sum(B) / B.length) || null, // B: B.length && (sum(B) / B.length) || null,
C: C.length && (sum(C) / C.length) || null, // C: C.length && (sum(C) / C.length) || null,
time: x // time: x
}) // })
}) // })
} // }
threePhase['struc' + strucOne.id] = JSON.stringify(threedata) // threePhase['struc' + strucOne.id] = JSON.stringify(threedata)
} }
@ -409,7 +415,7 @@ module.exports = function (app, opts) {
await app.redis.hmset("pumpStation_capacity", capacity) await app.redis.hmset("pumpStation_capacity", capacity)
await app.redis.hmset("pumpStation_currentSix", currentSix) await app.redis.hmset("pumpStation_currentSix", currentSix)
await app.redis.hmset("pumpStation_cabinet", cabinet) await app.redis.hmset("pumpStation_cabinet", cabinet)
await app.redis.hmset("pumpStation_threePhase", threePhase) // await app.redis.hmset("pumpStation_threePhase", threePhase)
} }

2
web/client/src/sections/bigScreen/actions/index.js

@ -13,7 +13,7 @@ export function getPumpStation (query = {}) {
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
actionType: 'GET_PUMP_STATION', actionType: 'GET_PUMP_STATION',
url: '/pump/station', url: 'pump/station',
query, query,
msg: { error: '获取所有站点信息失败' } msg: { error: '获取所有站点信息失败' }
}); });

Loading…
Cancel
Save