Browse Source

测试

master
wenlele 1 year ago
parent
commit
09f1a6e1cd
  1. 1
      api/app/lib/routes/index.js
  2. 55
      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) => {
if (api.indexOf('.') == 0 || api.indexOf('.js') == -1) return;
require(`./${filename}/${api}`)(app, router, opts);
console.log(111,filename,api);
});
}
});

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

@ -3,39 +3,46 @@
const data = require('../../controllers/bigScreen/index ');
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 };
router.get('/pumpInformation', data.pumpInformation);
try {
app.fs.api.logAttr['POST/axyData'] = { content: '获取安心云数据', visible: true };
router.post('/axyData', data.axyData);
app.fs.api.logAttr['get/videoUrl'] = { content: '获取视频监控url', visible: true };
router.get('/videoUrl', data.getVideoUrl);
app.fs.api.logAttr['GET/pumpInformation'] = { content: '获取泵站信息', visible: true };
router.get('/pumpInformation', data.pumpInformation);
app.fs.api.logAttr['get/pump/station'] = { content: '获取所有站点信息', visible: true };
router.get('/pump/station', data.getPumpStation);
app.fs.api.logAttr['get/videoUrl'] = { content: '获取视频监控url', visible: true };
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 };
router.get('/water/level/all', data.getPumpStation);
app.fs.api.logAttr['get/water/level/all'] = { content: '获取所有泵站七天内最新集水池液位', visible: true };
router.get('/water/level/all', data.getPumpStation);
app.fs.api.logAttr['get/water/level/six'] = { content: '获取泵站6h最新集水池液位', visible: true };
router.get('/water/level/six', data.getPumpStation);
app.fs.api.logAttr['get/water/level/six'] = { content: '获取泵站6h最新集水池液位', visible: true };
router.get('/water/level/six', data.getPumpStation);
app.fs.api.logAttr['get/water/pump/state/all'] = { content: '获取水泵状态', visible: true };
router.get('/water/pump/state/all', data.getPumpStation);
app.fs.api.logAttr['get/water/pump/state/all'] = { content: '获取水泵状态', visible: true };
router.get('/water/pump/state/all', data.getPumpStation);
app.fs.api.logAttr['get/capacity'] = { content: '获取能耗监测数据', visible: true };
router.get('/capacity', data.getPumpStation);
app.fs.api.logAttr['get/capacity'] = { content: '获取能耗监测数据', visible: true };
router.get('/capacity', data.getPumpStation);
app.fs.api.logAttr['get/currentSix'] = { content: '获取水泵数据', visible: true };
router.get('/currentSix', data.getPumpStation);
app.fs.api.logAttr['get/cabinet'] = { content: '获取进线柜数据', visible: true };
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/currentSix'] = { content: '获取水泵数据', visible: true };
router.get('/currentSix', data.getPumpStation);
app.fs.api.logAttr['get/cabinet'] = { content: '获取进线柜数据', visible: true };
router.get('/cabinet', data.getPumpStation);
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
let data = await getAnxinyunToken(app)
console.log(1111,data);
//获取所有泵站
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))
if (structureList.length) {
@ -209,47 +215,47 @@ module.exports = function (app, opts) {
currentSix['struc' + strucOne.id] = JSON.stringify(current.stations)
let threedata = []
let timeSet = new Set()
if (current.stations && current.stations.length) {
current.stations.map(p => {
p.data.map(s => {
timeSet.add(moment(s.time).format('YYYY-MM-DD HH:mm:ss'))
})
})
let time = [...timeSet].sort((a, b) => moment(a).isBefore(b) ? -1 : 1)
time.map(x => {
let A = []
let B = []
let C = []
current.stations.map((s, index) => {
let abcData = s.data.find(f => moment(f.time).format('YYYY-MM-DD HH:mm:ss') == x) || {}
let a = abcData.eMotor_A_A
let b = abcData.eMotor_B_A
let c = abcData.eMotor_C_A
if (a) A.push(a)
if (b) B.push(b)
if (c) C.push(c)
})
const sum = (arr) => {
let sum = 0
arr.map(h => {
sum += h
})
return sum
}
threedata.push({
A: A.length && (sum(A) / A.length) || null,
B: B.length && (sum(B) / B.length) || null,
C: C.length && (sum(C) / C.length) || null,
time: x
})
})
}
threePhase['struc' + strucOne.id] = JSON.stringify(threedata)
// let threedata = []
// let timeSet = new Set()
// if (current.stations && current.stations.length) {
// current.stations.map(p => {
// p.data.map(s => {
// timeSet.add(moment(s.time).format('YYYY-MM-DD HH:mm:ss'))
// })
// })
// let time = [...timeSet].sort((a, b) => moment(a).isBefore(b) ? -1 : 1)
// time.map(x => {
// let A = []
// let B = []
// let C = []
// current.stations.map((s, index) => {
// let abcData = s.data.find(f => moment(f.time).format('YYYY-MM-DD HH:mm:ss') == x) || {}
// let a = abcData.eMotor_A_A
// let b = abcData.eMotor_B_A
// let c = abcData.eMotor_C_A
// if (a) A.push(a)
// if (b) B.push(b)
// if (c) C.push(c)
// })
// const sum = (arr) => {
// let sum = 0
// arr.map(h => {
// sum += h
// })
// return sum
// }
// threedata.push({
// A: A.length && (sum(A) / A.length) || null,
// B: B.length && (sum(B) / B.length) || null,
// C: C.length && (sum(C) / C.length) || null,
// time: x
// })
// })
// }
// 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_currentSix", currentSix)
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',
dispatch: dispatch,
actionType: 'GET_PUMP_STATION',
url: '/pump/station',
url: 'pump/station',
query,
msg: { error: '获取所有站点信息失败' }
});

Loading…
Cancel
Save