Browse Source

测试

master
wenlele 1 year ago
parent
commit
09f1a6e1cd
  1. 1
      api/app/lib/routes/index.js
  2. 9
      api/app/lib/routes/organization/index.js
  3. 86
      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);
});
}
});

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

@ -3,6 +3,8 @@
const data = require('../../controllers/bigScreen/index ');
module.exports = function (app, router, opts) {
try {
app.fs.api.logAttr['POST/axyData'] = { content: '获取安心云数据', visible: true };
router.post('/axyData', data.axyData);
@ -11,9 +13,10 @@ module.exports = function (app, router, opts) {
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);
@ -35,6 +38,10 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['get/threePhase'] = { content: '获取三相电流数据', visible: true };
router.get('/threePhase', data.getPumpStation);
} catch (error) {
console.log(error.response);
}

86
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
})
})
}
// 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)
// 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