From 1b4b699c3908b2036f1db4f31829127fe9e7501c Mon Sep 17 00:00:00 2001 From: wenlele Date: Tue, 25 Jul 2023 20:52:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/bigScreen/index .js | 18 +++ api/app/lib/models/pump_information.js | 117 ++++++++++++++++++ api/app/lib/routes/organization/index.js | 3 + scripts/0.1/data/pump_information.sql | 25 ++++ .../sections/bigScreen/actions/bigScreen.js | 11 ++ .../sections/bigScreen/components/basis.js | 27 ++-- .../bigScreen/components/basis/right_1.js | 20 ++- .../bigScreen/components/basis/right_2.js | 4 +- .../sections/bigScreen/components/capacity.js | 31 ++--- .../bigScreen/components/electrical.js | 7 +- .../components/electrity/levelTrend.js | 4 +- .../components/electrity/lineBoxStatus.js | 2 +- .../components/electrity/voltageTrend.js | 6 +- .../bigScreen/components/realTime/below.js | 6 +- .../bigScreen/components/realTime/general.js | 6 +- .../components/realTime/softStart.js | 2 +- web/client/src/utils/webapi.js | 1 + 17 files changed, 235 insertions(+), 55 deletions(-) create mode 100644 api/app/lib/models/pump_information.js create mode 100644 scripts/0.1/data/pump_information.sql diff --git a/api/app/lib/controllers/bigScreen/index .js b/api/app/lib/controllers/bigScreen/index .js index d21f3ae..cdb4992 100644 --- a/api/app/lib/controllers/bigScreen/index .js +++ b/api/app/lib/controllers/bigScreen/index .js @@ -54,8 +54,25 @@ async function axyData (ctx, next) { } +const pumpInformation = async function (ctx) { + let errMsg = { message: '获取泵站信息失败' } + try { + const models = ctx.fs.dc.models; + const { page, limit, name } = ctx.query; + const res = await models.PumpInformation.findAll(); + + ctx.status = 200; + ctx.body = res; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = errMsg + + } +} + @@ -64,4 +81,5 @@ async function axyData (ctx, next) { module.exports = { axyData, + pumpInformation } \ No newline at end of file diff --git a/api/app/lib/models/pump_information.js b/api/app/lib/models/pump_information.js new file mode 100644 index 0000000..e68c141 --- /dev/null +++ b/api/app/lib/models/pump_information.js @@ -0,0 +1,117 @@ +/* eslint-disable*/ +'use strict'; + +module.exports = dc => { + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const PumpInformation = sequelize.define("pumpInformation", { + id: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: true, + field: "id", + autoIncrement: true, + unique: "t_pump_information_id_uindex" + }, + structureId: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: false, + field: "structure_id", + autoIncrement: false + }, + area: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "area", + autoIncrement: false + }, + scale: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "scale", + autoIncrement: false + }, + waterType: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "water_type", + autoIncrement: false + }, + elcType: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "elc_type", + autoIncrement: false + }, + byType: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "by_type", + autoIncrement: false + }, + num: { + type: DataTypes.INTEGER, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "num", + autoIncrement: false + }, + startTime: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "start_time", + autoIncrement: false + }, + reinforceTime: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "reinforce_time", + autoIncrement: false + }, + func: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "func", + autoIncrement: false + }, + + }, { + tableName: "t_pump_information", + comment: "", + indexes: [] + }); + + dc.models.PumpInformation = PumpInformation; + return PumpInformation; +}; diff --git a/api/app/lib/routes/organization/index.js b/api/app/lib/routes/organization/index.js index 2d6c26f..5b20a1e 100644 --- a/api/app/lib/routes/organization/index.js +++ b/api/app/lib/routes/organization/index.js @@ -6,4 +6,7 @@ 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); }; \ No newline at end of file diff --git a/scripts/0.1/data/pump_information.sql b/scripts/0.1/data/pump_information.sql new file mode 100644 index 0000000..d182706 --- /dev/null +++ b/scripts/0.1/data/pump_information.sql @@ -0,0 +1,25 @@ +INSERT INTO public.t_pump_information (id, structure_id, area, scale, water_type, elc_type, by_type, func, num, start_time, reinforce_time) VALUES (DEFAULT, + 3569, '东新乡', 840,'1000ZLB—4轴流泵','JSL12—14','S91000KVA','排灌结合',4,'1974年','2009年'); + + INSERT INTO public.t_pump_information (id, structure_id, area, scale, water_type, elc_type, by_type, func, num, start_time, reinforce_time) VALUES (DEFAULT, + 3592, '富山乡', 2010,'空','6台180、6台155','1250、1650','排涝',12,'1983年','2008年'); + + INSERT INTO public.t_pump_information (id, structure_id, area, scale, water_type, elc_type, by_type, func, num, start_time, reinforce_time) VALUES (DEFAULT, + 3594, '东新乡', 60 ,'ZLB28—70轴流泵','Y—200T—4','80KVA箱式变压器','纯排',2,'2013年','空'); + + INSERT INTO public.t_pump_information (id, structure_id, area, scale, water_type, elc_type, by_type, func, num, start_time, reinforce_time) VALUES (DEFAULT, + 3595, '东新乡',260,'20ZLB—70轴流泵','Y67—130kw','315KVA箱式变压器','纯排',2,'2014年','空'); + + INSERT INTO public.t_pump_information (id, structure_id, area, scale, water_type, elc_type, by_type, func, num, start_time, reinforce_time) VALUES (DEFAULT, + 3593, '东新乡',240, 'ZLB28—70轴流泵','Y—200T—4','S9315KVA','排灌结合',3,'1974年','1992年'); + + INSERT INTO public.t_pump_information (id, structure_id, area, scale, water_type, elc_type, by_type, func, num, start_time, reinforce_time) VALUES (DEFAULT, + 3598, '东新乡', 340,'ZLB28—70轴流泵','Y—200T—4','S9315KVA','排灌结合',3,'1974年','1988年'); + + INSERT INTO public.t_pump_information (id, structure_id, area, scale, water_type, elc_type, by_type, func, num, start_time, reinforce_time) VALUES (DEFAULT, + 3597, '东新乡',260,'20ZLB—70轴流泵','Y67—130kw','S9_315KVA变压器','灌溉',2,'2014年','空'); + + INSERT INTO public.t_pump_information (id, structure_id, area, scale, water_type, elc_type, by_type, func, num, start_time, reinforce_time) VALUES (DEFAULT, + 3599, '富山乡',390, '空','空','空','排涝',3,'1973年','2008年'); + + diff --git a/web/client/src/sections/bigScreen/actions/bigScreen.js b/web/client/src/sections/bigScreen/actions/bigScreen.js index 3f6ff74..d7cf19f 100644 --- a/web/client/src/sections/bigScreen/actions/bigScreen.js +++ b/web/client/src/sections/bigScreen/actions/bigScreen.js @@ -14,6 +14,17 @@ export function axyData (data = {}) { }); } +export function pumpInformation (query = {}) { + return dispatch => basicAction({ + type: 'get', + dispatch: dispatch, + actionType: 'GET_PUMP_INFORMATION', + url: `${ApiTable.pumpInformation}`, + query, + msg: { error: '获取泵站基本信息失败' } + }); +} + export default { axyData } \ No newline at end of file diff --git a/web/client/src/sections/bigScreen/components/basis.js b/web/client/src/sections/bigScreen/components/basis.js index c4411ad..db30977 100644 --- a/web/client/src/sections/bigScreen/components/basis.js +++ b/web/client/src/sections/bigScreen/components/basis.js @@ -21,20 +21,33 @@ const Basis = ({ actions, dispatch, setshowData, siteList, siteData }) => { const [pageRefresh3, setPageRefresh3] = useState(0) const [depthWater, setDepthWater] = useState([]) const [information, setInformation] = useState({}) + const [pumpInformation, setPumpInformation] = useState([]) const left1Data = useRef([]) const left2Data = useRef([]) const pumpNumber = useRef(0) + + + useEffect(() => { + dispatch(bigScreen.pumpInformation({})).then(res => { + if (res.success) { + setPumpInformation(res.payload.data || []) + } + }) + }, []) + useEffect(() => { + if (pumpInformation?.length && strucId) { + setInformation(pumpInformation?.find(v => v.structureId == strucId) || {}) + } + }, [pumpInformation, strucId]) + + useEffect(async () => { if (siteData) { setStrucId(siteData[0]?.id) - for (let key in POWER_STATIONS) { - if (POWER_STATIONS[key]?.name == siteData[0]?.name) { - setInformation(POWER_STATIONS[key]) - } - } + //获取所有泵站的集水池液位 siteData?.map(async v => { await dispatch(bigScreen.axyData({ type: 'get', url: `structures/${v.id}/factors` })).then(async r => { @@ -131,7 +144,7 @@ const Basis = ({ actions, dispatch, setshowData, siteList, siteData }) => { type: 'get', url: `stations/theme/data`, params: { query: { stations: p.payload.data[0]?.groups[0]?.stations[0]?.id, - startTime: moment().add(-12, 'hours').format('YYYY-MM-DD HH:mm:ss'), + startTime: moment().add(-6, 'hours').format('YYYY-MM-DD HH:mm:ss'), endTime: moment().format('YYYY-MM-DD HH:mm:ss'), limit: 1440 } @@ -193,7 +206,7 @@ const Basis = ({ actions, dispatch, setshowData, siteList, siteData }) => {
- +
diff --git a/web/client/src/sections/bigScreen/components/basis/right_1.js b/web/client/src/sections/bigScreen/components/basis/right_1.js index db76ee7..c93f11c 100644 --- a/web/client/src/sections/bigScreen/components/basis/right_1.js +++ b/web/client/src/sections/bigScreen/components/basis/right_1.js @@ -4,7 +4,7 @@ import { Select } from 'antd'; import '../basis.less'; import './right_1.less'; -export default function Right_1 ({ data, siteList, strucId, setStrucId, POWER_STATIONS, setInformation }) { +export default function Right_1 ({ data, siteList, pumpInformation, setPumpInformation, strucId, setStrucId, POWER_STATIONS, setInformation }) { const renderSelect = () => { return