From 3741b9b36dc41c116c99556e82326d111af89586 Mon Sep 17 00:00:00 2001 From: xincheng <1447340602@qq.com> Date: Thu, 19 Jan 2023 12:19:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=B7=A1=E6=A3=80?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/patrolRecord/patrolRecord.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/app/lib/controllers/patrolRecord/patrolRecord.js b/api/app/lib/controllers/patrolRecord/patrolRecord.js index f00a75c..8f5893c 100644 --- a/api/app/lib/controllers/patrolRecord/patrolRecord.js +++ b/api/app/lib/controllers/patrolRecord/patrolRecord.js @@ -9,7 +9,7 @@ async function findPatrolRecord (ctx, next) { // patrolPlanId传all查所有 if (patrolPlanId == 'all') { /* 如果有startTime && endTime,查询所有符合条件的数据 */ - if (startTime && endTime) { + if (startTime !== 'null' && endTime !== 'null') { if (pointId) { rslt = await models.PatrolRecord.findAll({ where: { alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, @@ -32,7 +32,7 @@ async function findPatrolRecord (ctx, next) { }) } } else { - if (startTime && endTime) { + if (startTime !== 'null' && endTime !== 'null') { if (pointId) { rslt = await models.PatrolRecord.findAll({ where: { patrolPlanId: { $in: patrolPlanId.split(',') }, alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, From fb96c9cf2230e393eb30a91a9adbabfa59f750b6 Mon Sep 17 00:00:00 2001 From: xincheng <1447340602@qq.com> Date: Thu, 19 Jan 2023 13:53:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A1=E6=A3=80?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/patrolRecord/patrolRecord.js | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/api/app/lib/controllers/patrolRecord/patrolRecord.js b/api/app/lib/controllers/patrolRecord/patrolRecord.js index 8f5893c..cc1dd8b 100644 --- a/api/app/lib/controllers/patrolRecord/patrolRecord.js +++ b/api/app/lib/controllers/patrolRecord/patrolRecord.js @@ -11,13 +11,25 @@ async function findPatrolRecord (ctx, next) { /* 如果有startTime && endTime,查询所有符合条件的数据 */ if (startTime !== 'null' && endTime !== 'null') { if (pointId) { - rslt = await models.PatrolRecord.findAll({ - where: { alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, - }); + if (alarm == 'null') { + rslt = await models.PatrolRecord.findAll({ + where: { inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, + }); + } else { + rslt = await models.PatrolRecord.findAll({ + where: { alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, + }); + } } else { - rslt = await models.PatrolRecord.findAll({ - where: { alarm, inspectionTime: { $between: [startTime, endTime] } }, - }); + if (alarm == 'null') { + rslt = await models.PatrolRecord.findAll({ + where: { inspectionTime: { $between: [startTime, endTime] } }, + }); + } else { + rslt = await models.PatrolRecord.findAll({ + where: { alarm, inspectionTime: { $between: [startTime, endTime] } }, + }); + } } } else { /* 如果没有startTime && endTime,查询每个点位最新一条符合条件的数据 */ From d108330c358e9531e3f131f5a6fd62a8925509b3 Mon Sep 17 00:00:00 2001 From: mrsandmansy Date: Thu, 19 Jan 2023 14:44:00 +0800 Subject: [PATCH 3/3] =?UTF-8?q?(+)=E5=B7=A1=E6=A3=80=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sections/patrolManage/actions/index.js | 2 + .../sections/patrolManage/actions/record.js | 17 ++ .../sections/patrolManage/containers/index.js | 3 +- .../patrolManage/containers/patrolRecord.js | 175 ++++++++++++++++++ .../src/sections/patrolManage/nav-item.js | 3 + .../sections/patrolManage/reducers/record.js | 32 ++++ .../src/sections/patrolManage/routes.js | 7 +- web/client/src/utils/webapi.js | 3 + 8 files changed, 240 insertions(+), 2 deletions(-) create mode 100644 web/client/src/sections/patrolManage/actions/record.js create mode 100644 web/client/src/sections/patrolManage/containers/patrolRecord.js create mode 100644 web/client/src/sections/patrolManage/reducers/record.js diff --git a/web/client/src/sections/patrolManage/actions/index.js b/web/client/src/sections/patrolManage/actions/index.js index aaaafe9..c465b0f 100644 --- a/web/client/src/sections/patrolManage/actions/index.js +++ b/web/client/src/sections/patrolManage/actions/index.js @@ -1,7 +1,9 @@ 'use strict'; import * as plan from './plan' +import * as record from './record' export default { ...plan, + ...record, } \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/actions/record.js b/web/client/src/sections/patrolManage/actions/record.js new file mode 100644 index 0000000..a6ae77e --- /dev/null +++ b/web/client/src/sections/patrolManage/actions/record.js @@ -0,0 +1,17 @@ +'use strict'; + +import { basicAction } from '@peace/utils' + +export const GET_PATROL_RECORD_LIST = 'GET_PATROL_RECORD_LIST'; +export const GET_PATROL_RECORD_LIST_SUCCESS = 'GET_PATROL_RECORD_LIST_SUCCESS'; +export const GET_PATROL_RECORD_LIST_ERROR = 'GET_PATROL_RECORD_LIST_ERROR'; +export function records(url) { + return (dispatch) => basicAction({ + type: 'get', + dispatch, + actionType: GET_PATROL_RECORD_LIST, + url: url, + msg: { error: '获取巡检记录失败', }, + reducer: { name: 'record' } + }); +} \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/containers/index.js b/web/client/src/sections/patrolManage/containers/index.js index 4121322..d83768a 100644 --- a/web/client/src/sections/patrolManage/containers/index.js +++ b/web/client/src/sections/patrolManage/containers/index.js @@ -1,5 +1,6 @@ 'use strict'; import PatrolPlan from './patrolPlan'; +import PatrolReocrd from './patrolRecord'; -export { PatrolPlan }; \ No newline at end of file +export { PatrolPlan, PatrolReocrd }; \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/containers/patrolRecord.js b/web/client/src/sections/patrolManage/containers/patrolRecord.js new file mode 100644 index 0000000..e10829e --- /dev/null +++ b/web/client/src/sections/patrolManage/containers/patrolRecord.js @@ -0,0 +1,175 @@ + +'use strict' + +import React, { useEffect, useState } from 'react'; +import { connect } from 'react-redux'; +import { Form, Input, Select, Button, Table, Modal, DatePicker } from 'antd'; +import moment from "moment"; + +const PatrolRecord = (props) => { + const { dispatch, actions, } = props + const { patrolManage } = actions + const [tableList, settableList] = useState([]) + const [addModel, setAddModel] = useState(false) + const [modelData, setModelData] = useState({}) + const [query, setQuery] = useState({ limit: 10, page: 0 }) + const [limits, setLimits] = useState() + const format = 'YYYY-MM-DD' + const [search, setSearch] = useState({ name: null, time: [moment().add(-7, 'd').format(format), moment().format(format)], state: 'null' }) + + useEffect(() => { + record(search) + }, []) + + const record = (params) => { + dispatch(patrolManage.records(`patrolRecord/all/${params.time[0]}/${params.time[1]}/${params.state}/1`)).then(res => { + if (res.success) { + settableList(res.payload.data?.map(v => ({ ...v, key: v.id }))) + setLimits(res.payload.data?.length) + } + }) + } + + const columns = [{ + title: '结构物名称', + dataIndex: 'name', + key: 'name', + render: (text, record, index) => { + return !record.points?.project? '':
{record.points.project.name}
+ } + }, { + title: '巡检人', + dataIndex: 'type', + key: 'type', + render: (text, record, index) => { + return !record.points?.user? '':
{record.points.user.name}
+ } + }, { + title: '巡检点位', + dataIndex: 'type', + key: 'type', + render: (text, record, index) => { + return !record.points?.user? '':
{record.points.itemData.name}
+ } + }, { + title: '巡检单位', + dataIndex: 'type', + key: 'type', + render: (text, record, index) => { + return !record.points?.user? '':
{record.points.user.department.name}
+ } + }, { + title: '巡检频次', + dataIndex: 'describe', + key: 'describe', + render: (text, record, index) => { + return !record.points? '':
{record.points.frequency}
+ } + }, { + title: '上次巡检日期', + dataIndex: 'describe', + key: 'describe', + render: (text, record, index) => moment(record.lastInspectionTime).format('YYYY-MM-DD HH:mm') || '--' + }, { + title: '本次巡检日期', + dataIndex: 'describe', + key: 'describe', + render: (text, record, index) => moment(record.inspectionTime).format('YYYY-MM-DD HH:mm') || '--' + }, { + title: '巡检结果', + dataIndex: 'describe', + key: 'describe', + render: (text, record, index) => !record.alarm? '正常':'异常' + }, { + title: '操作', + dataIndex: 'operation', + key: 'operation', + render: (text, record, index) => { + return ( +
+ +
+ ) + } + } + ] + + return ( + <> +
+
{ + record({ + name: r.name, + time: [moment(r.time[0]).format(format), moment(r.time[1]).format(format)], + state: r.state + }) + }} + > + + + + + + + +