Browse Source

水泵控制修改

master
wenlele 12 months ago
parent
commit
e8486d9a9f
  1. 86
      api/app/lib/schedule/workorder_statistics.js
  2. 2
      web/client/src/sections/bigScreen/components/electrical.js
  3. 23
      web/client/src/sections/bigScreen/components/electrity/realTimeStatus.js

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

@ -1,6 +1,6 @@
const moment = require('moment')
let isDev = false
let isDev = false
// let isDev = true
@ -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)
}

2
web/client/src/sections/bigScreen/components/electrical.js

@ -49,7 +49,7 @@ const Electrical = ({ dispatch, actions, siteList, waterLevelSix, currentSix, ca
useEffect(() => {
if (currentSix?.length) {
setPumpId(currentSix[0].id)
setPumpOne(currentSix[0] || {})
// setPumpOne(currentSix[0] || {})
setVoltagePumpId(currentSix?.slice(0, 3)?.map(v => v.id))
setPumpList(currentSix || [])
setVoltagePump(currentSix?.slice(0, 3) || [])

23
web/client/src/sections/bigScreen/components/electrity/realTimeStatus.js

@ -1,8 +1,10 @@
import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux';
import moment from 'moment'
import { Select, Modal, Switch, Input, Button, Form, message } from 'antd';
const RealTimeStatus = ({dispatch, actions, user, pumpId, pumpList, setPumpId, pumpOne, strucId, siteList, setPumpOne, currentSix }) => {
const RealTimeStatus = ({ dispatch, actions, user, pumpId, pumpList, setPumpId, strucId, siteList,pumpOne, setPumpOne, currentSix }) => {
const { bigScreen } = actions;
@ -11,6 +13,7 @@ const RealTimeStatus = ({dispatch, actions, user, pumpId, pumpList, setPumpId, p
const [isModalOpen, setIsModalOpen] = useState(false);
const [pumpName, setPumpName] = useState('');
// const [pumpOne, setPumpOne] = useState({ data: [] });
const [checked, setChecked] = useState({
'模式切换': false, // 平台手动/平台液控
'启动控制': false,
@ -21,6 +24,24 @@ const RealTimeStatus = ({dispatch, actions, user, pumpId, pumpList, setPumpId, p
setPumpName(pumpList?.length ? pumpList[0].name : '')
}, [pumpList])
useEffect(() => {
dispatch(bigScreen.axyData({
type: 'get', url: `stations/theme/data`, params: {
query: {
stations: pumpId,
startTime: moment().startOf('week').format('YYYY-MM-DD HH:mm:ss'),
endTime: moment().format('YYYY-MM-DD HH:mm:ss'),
limit: 1
}
}
})).then(d => {
if (d.success) {
setPumpOne(d.payload.data?.stations[0] || { data: [] })
}
})
}, [pumpId])
useEffect(() => {
if (pumpOne?.data.length) {
setChecked({

Loading…
Cancel
Save