Browse Source

控制修改

master
wenlele 12 months ago
parent
commit
fa06d705f8
  1. 86
      api/app/lib/schedule/workorder_statistics.js

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

@ -23,7 +23,7 @@ module.exports = function (app, opts) {
let data = await getAnxinyunToken(app)
console.log(1111, data);
// console.log(1111, data);
//获取所有泵站
let structureList = await app.fs.anxinyun.get(`organizations/${data.orgId}/structures?token=${data.token}`) || []
@ -217,47 +217,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)
}
@ -417,7 +417,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)
}

Loading…
Cancel
Save