浏览代码

Merge branch 'develop' of http://120.55.44.4:10080/xujunjie/gt_client_pad into develop

Renxy 1 年之前
父节点
当前提交
63604ebee7

+ 35 - 0
src/models/eqSelfInspection.js

@@ -1,9 +1,12 @@
+import dayjs from 'dayjs';
+
 import {
   analysisResultList,
   getAutoPatrolByRouteId,
   getPatrolDumuList,
   getPatrolRecordMandateInfo,
   getRecentAutoPatrolByRouteId,
+  getRecentGaugeRecord,
   getRouteList,
   patrolRelationList,
   queryAnalysisDict,
@@ -45,6 +48,10 @@ export default {
       const { data } = yield call(queryPatrolRecord, {
         recordId: payload.routeId,
       });
+      const recentGaugeRecord = yield call(getRecentGaugeRecord, {
+        project_id: payload.projectId,
+        e_time: payload.eTime || dayjs().format('YYYY-MM-DD HH:mm:ss'),
+      });
       if (data) {
         const cacheData = yield select(
           (state) => state.eqSelfInspection.autoReport,
@@ -248,6 +255,34 @@ export default {
         data.secureChild = secureChild;
 
         callback?.(data);
+
+        if (recentGaugeRecord.code === 200) {
+          data.DrugFlowList = [
+            ...data.DrugFlowList,
+            ...recentGaugeRecord.data.DrugFlowList.map((item) => {
+              return { ...item, history: true };
+            }),
+          ];
+          data.FluidLevelList = [
+            ...data.FluidLevelList,
+            ...recentGaugeRecord.data.FluidLevelList.map((item) => {
+              return { ...item, history: true };
+            }),
+          ];
+          data.PressureCompareList = [
+            ...data.PressureCompareList,
+            ...recentGaugeRecord.data.PressureCompareList.map((item) => {
+              return { ...item, history: true };
+            }),
+          ];
+          data.WaterQualityCompareList = [
+            ...data.WaterQualityCompareList,
+            ...recentGaugeRecord.data.WaterQualityCompareList.map((item) => {
+              return { ...item, history: true };
+            }),
+          ];
+        }
+
         yield put({
           type: 'save',
           payload: { autoReport: data },

+ 1 - 1
src/pages/EqSelfInspection/List/index.js

@@ -30,7 +30,7 @@ function List(props) {
     history.push(
       `/self-inspection/detail/${projectId}/${
         record.Id
-      }?JWT-TOKEN=${GetTokenFromUrl()}`,
+      }?JWT-TOKEN=${GetTokenFromUrl()}&eTime=${record.CreatedTime}`,
     );
   };
 

+ 5 - 1
src/pages/EqSelfInspection/ReportDetail.js

@@ -1,6 +1,6 @@
 import PageContent from '@/components/PageContent';
 import PageTitle from '@/components/PageTitle';
-import { connect, useParams } from '@umijs/max';
+import { connect, useLocation, useParams } from '@umijs/max';
 import { useEffect } from 'react';
 import Detail from './components/Detail';
 
@@ -8,12 +8,16 @@ const ReportDetail = (props) => {
   const { data, dispatch, loading } = props;
 
   const { projectId, routeId } = useParams();
+  const eTime = new URLSearchParams(useLocation()?.search)?.get('eTime');
+
   useEffect(() => {
     if (routeId) {
       dispatch({
         type: 'eqSelfInspection/getPatrolDataById',
         payload: {
           routeId,
+          projectId,
+          eTime,
         },
       });
     }

+ 66 - 22
src/pages/EqSelfInspection/components/Detail.js

@@ -290,7 +290,7 @@ export function DeviceTable(props) {
   };
   const handleError = async (values) => {
     setLoading(true);
-    var res = await changeRecordStatus({
+    let res = await changeRecordStatus({
       ...values,
       Id: currentItem.Id,
       DeviceCode: currentItem.DeviceCode,
@@ -811,9 +811,19 @@ export function LiquidTable(props) {
   const columns = [
     {
       title: '设备名称',
-      width: '20%',
+      width: '12%',
       dataIndex: 'device_name',
     },
+    {
+      title: '时间',
+      dataIndex: 'record_time',
+      render: (text) => {
+        if (text) {
+          return dayjs(text).format('YYYY.MM.DD HH:mm');
+        }
+        return '-';
+      },
+    },
     {
       title: '类型',
       key: 'template_item_name',
@@ -824,12 +834,12 @@ export function LiquidTable(props) {
       dataIndex: 'origin_value',
     },
     {
-      title: '差值',
+      title: '差值/比值',
       dataIndex: 'value',
     },
     {
       title: '设定值范围',
-      width: '25%',
+      width: '18%',
       render: (record) => (
         <ThresholdDetail
           current={record.value || 0}
@@ -906,7 +916,7 @@ function LiquidLevelCom(props) {
   const [activeKey, setActiveKey] = useState('1');
 
   const errorData = useMemo(() => {
-    const errorData = allData?.filter((item) => item.status);
+    const errorData = allData?.filter((item) => item.status && !item.history);
     return errorData;
   }, [allData]);
 
@@ -929,14 +939,14 @@ function LiquidLevelCom(props) {
             },
             {
               key: '2',
-              label: `全部(${allData?.length || 0})`,
+              label: `历史记录(${allData?.length || 0})`,
               children: <div></div>,
             },
           ]}
         ></TabsContent>
       </div>
 
-      {activeKey == '1' && (
+      {activeKey === '1' && (
         <LiquidTable
           onClickItem={sendMessageToUnity}
           select={select}
@@ -945,7 +955,7 @@ function LiquidLevelCom(props) {
           type={type}
         />
       )}
-      {activeKey == '2' && (
+      {activeKey === '2' && (
         <LiquidTable
           onClickItem={sendMessageToUnity}
           select={select}
@@ -963,12 +973,22 @@ function DosingFlowTable(props) {
   const columns = [
     {
       title: '设备名称',
-      width: '20%',
+      width: '12%',
       dataIndex: 'device_name',
     },
+    {
+      title: '时间',
+      dataIndex: 'record_time',
+      render: (text) => {
+        if (text) {
+          return dayjs(text).format('YYYY.MM.DD HH:mm');
+        }
+        return '-';
+      },
+    },
     {
       title: '类型',
-      width: '1rem',
+      width: '15%',
       key: 'template_item_name',
       dataIndex: 'template_item_name',
     },
@@ -986,7 +1006,7 @@ function DosingFlowTable(props) {
     },
     {
       title: '设定值范围',
-      width: '20%',
+      width: '18%',
       render: (record) => (
         <ThresholdDetail
           current={record.value || 0}
@@ -1000,7 +1020,7 @@ function DosingFlowTable(props) {
     {
       title: '状态',
       dataIndex: 'status',
-      width: '1.25rem',
+      width: '20%',
       render: (status) => {
         switch (status) {
           case -1:
@@ -1065,7 +1085,7 @@ function DosingFlowCom(props) {
   const [activeKey, setActiveKey] = useState('1');
 
   const errorData = useMemo(() => {
-    const errorData = allData?.filter((item) => item.status);
+    const errorData = allData?.filter((item) => item.status && !item.history);
     return errorData;
   }, [allData]);
 
@@ -1088,7 +1108,7 @@ function DosingFlowCom(props) {
             },
             {
               key: '2',
-              label: `全部(${allData?.length || 0})`,
+              label: `历史记录(${allData?.length || 0})`,
               children: <div></div>,
             },
           ]}
@@ -1401,10 +1421,10 @@ function PressureGaugeTable(props) {
 
 function PressureGaugeCom(props) {
   const { sendMessageToUnity, select, allData = [], title } = props;
-  const [activeKey, setActiveKey] = useState('2');
+  const [activeKey, setActiveKey] = useState('1');
 
   const errorData = useMemo(() => {
-    const tempData = allData?.filter((item) => item.status);
+    const tempData = allData?.filter((item) => !item.history);
     return tempData;
   }, [allData]);
 
@@ -1416,18 +1436,30 @@ function PressureGaugeCom(props) {
       <div className={styles.tableTop}>
         {title}
         <TabsContent
-          defaultActiveKey="2"
+          defaultActiveKey="1"
           onChange={handleTabsChange}
           small
           items={[
+            {
+              key: '1',
+              label: `异常/警告(${errorData?.length || 0})`,
+              children: <div></div>,
+            },
             {
               key: '2',
-              label: `异常/警告(${allData?.length || 0})`,
+              label: `历史记录(${allData?.length || 0})`,
               children: <div></div>,
             },
           ]}
         ></TabsContent>
       </div>
+      {activeKey === '1' && (
+        <PressureGaugeTable
+          onClickItem={sendMessageToUnity}
+          select={select}
+          items={errorData}
+        />
+      )}
       {activeKey === '2' && (
         <PressureGaugeTable
           onClickItem={sendMessageToUnity}
@@ -1563,10 +1595,10 @@ function WaterQualityTable(props) {
 
 function WaterQualityCom(props) {
   const { sendMessageToUnity, select, allData = [], title } = props;
-  const [activeKey, setActiveKey] = useState('2');
+  const [activeKey, setActiveKey] = useState('1');
 
   const errorData = useMemo(() => {
-    const tempData = allData?.filter((item) => item.status);
+    const tempData = allData?.filter((item) => !item.history);
     return tempData;
   }, [allData]);
 
@@ -1578,18 +1610,30 @@ function WaterQualityCom(props) {
       <div className={styles.tableTop}>
         {title}
         <TabsContent
-          defaultActiveKey="2"
+          defaultActiveKey="1"
           onChange={handleTabsChange}
           small
           items={[
+            {
+              key: '1',
+              label: `异常/警告(${errorData?.length || 0})`,
+              children: <div></div>,
+            },
             {
               key: '2',
-              label: `异常/警告(${allData?.length || 0})`,
+              label: `历史记录(${allData?.length || 0})`,
               children: <div></div>,
             },
           ]}
         ></TabsContent>
       </div>
+      {activeKey === '1' && (
+        <WaterQualityTable
+          onClickItem={sendMessageToUnity}
+          select={select}
+          items={errorData}
+        />
+      )}
       {activeKey === '2' && (
         <WaterQualityTable
           onClickItem={sendMessageToUnity}

+ 1 - 0
src/pages/EqSelfInspection/index.js

@@ -112,6 +112,7 @@ const EqSelfInspection = (props) => {
         type: 'eqSelfInspection/getPatrolDataById',
         payload: {
           routeId: routeId,
+          projectId,
         },
       });
     } else {

+ 74 - 22
src/pages/SmartOps/components/DeviceAnalysis.js

@@ -114,14 +114,20 @@ const DeviceAnalysis = (props) => {
         type: '1',
         data: autoReport?.extendWarningData,
         FluidLevelList: autoReport?.FluidLevelList?.filter(
-          (item) => item.status,
+          (item) => item.status && !item.history,
+        ),
+        DrugFlowList: autoReport?.DrugFlowList?.filter(
+          (item) => item.status && !item.history,
         ),
-        DrugFlowList: autoReport?.DrugFlowList?.filter((item) => item.status),
         WaterInCheckList: autoReport?.WaterInCheckList?.filter(
           (item) => item.status,
         ),
-        PressureCompareList: autoReport?.PressureCompareList,
-        WaterQualityCompareList: autoReport?.WaterQualityCompareList,
+        PressureCompareList: autoReport?.PressureCompareList.filter(
+          (item) => !item.history,
+        ),
+        WaterQualityCompareList: autoReport?.WaterQualityCompareList.filter(
+          (item) => !item.history,
+        ),
       },
       {
         name: '全部',
@@ -166,6 +172,16 @@ const DeviceAnalysis = (props) => {
     }
   };
 
+  const calculateLength = (params) => {
+    let length = 0;
+    Object.keys(params).forEach((key) => {
+      if (key !== 'name' && key !== 'type') {
+        length += params[key]?.length;
+      }
+    });
+    return length;
+  };
+
   return (
     <Spin spinning={loading}>
       <div style={{ height: 'calc(100vh - 5.6rem)', overflow: 'auto' }}>
@@ -175,7 +191,7 @@ const DeviceAnalysis = (props) => {
           defaultActiveKey="1"
           items={data?.map((item) => {
             return {
-              label: `${item.name}(${item.data?.length || 0})`,
+              label: `${item.name}(${calculateLength(item) || 0})`,
               key: item.type,
               children: (
                 <>
@@ -197,22 +213,40 @@ const DeviceAnalysis = (props) => {
                   )}
                   {(item.type === '1'
                     ? item?.FluidLevelList.length > 0
-                    : true) && <LiquidLevel allData={item?.FluidLevelList} />}
+                    : true) && (
+                    <LiquidLevel
+                      allData={item?.FluidLevelList}
+                      type={item.type}
+                    />
+                  )}
                   {(item.type === '1'
                     ? item?.DrugFlowList.length > 0
-                    : true) && <DosingFlow allData={item?.DrugFlowList} />}
+                    : true) && (
+                    <DosingFlow allData={item?.DrugFlowList} type={item.type} />
+                  )}
                   {(item.type === '1'
                     ? item?.WaterInCheckList.length > 0
-                    : true) && <WaterFlow allData={item?.WaterInCheckList} />}
+                    : true) && (
+                    <WaterFlow
+                      allData={item?.WaterInCheckList}
+                      type={item.type}
+                    />
+                  )}
                   {(item.type === '1'
                     ? item?.PressureCompareList.length > 0
                     : true) && (
-                    <PressureGauge allData={item?.PressureCompareList} />
+                    <PressureGauge
+                      allData={item?.PressureCompareList}
+                      type={item.type}
+                    />
                   )}
                   {(item.type === '1'
                     ? item?.WaterQualityCompareList.length > 0
                     : true) && (
-                    <WaterQuality allData={item?.WaterQualityCompareList} />
+                    <WaterQuality
+                      allData={item?.WaterQualityCompareList}
+                      type={item.type}
+                    />
                   )}
                 </>
               ),
@@ -230,14 +264,23 @@ export default connect(({ eqSelfInspection, loading }) => ({
 }))(DeviceAnalysis);
 
 const LiquidLevel = (props) => {
-  const { allData } = props;
+  const { allData, type } = props;
 
   const columns = [
     {
       title: '设备名称',
-      width: '20%',
+      width: '14%',
       dataIndex: 'device_name',
     },
+    {
+      title: '时间',
+      dataIndex: 'record_time',
+      render: (text) => {
+        if (text) {
+          return dayjs(text).format('YYYY.MM.DD HH:mm');
+        }
+      },
+    },
     {
       title: '类型',
       key: 'template_item_name',
@@ -253,7 +296,7 @@ const LiquidLevel = (props) => {
     },
     {
       title: '设定值范围',
-      width: '25%',
+      width: '20%',
       render: (record) => (
         <ThresholdDetail
           current={record.value || 0}
@@ -318,21 +361,30 @@ const LiquidLevel = (props) => {
 
   return (
     <div>
-      <ModuleTitle title="液位检测" />
+      <ModuleTitle title={`液位检测${type === '1' ? '' : '(历史记录)'}`} />
       <Table dataSource={allData} columns={columns} />
     </div>
   );
 };
 
 const DosingFlow = (props) => {
-  const { allData } = props;
+  const { allData, type } = props;
 
   const columns = [
     {
       title: '设备名称',
-      width: '15%',
+      width: '14%',
       dataIndex: 'device_name',
     },
+    {
+      title: '时间',
+      dataIndex: 'record_time',
+      render: (text) => {
+        if (text) {
+          return dayjs(text).format('YYYY.MM.DD HH:mm');
+        }
+      },
+    },
     {
       title: '类型',
       key: 'template_item_name',
@@ -416,14 +468,14 @@ const DosingFlow = (props) => {
   ];
   return (
     <div>
-      <ModuleTitle title="加药流量校验" />
+      <ModuleTitle title={`加药流量校验${type === '1' ? '' : '(历史记录)'}`} />
       <Table dataSource={allData} columns={columns} />
     </div>
   );
 };
 
 const WaterFlow = (props) => {
-  const { allData } = props;
+  const { allData, type } = props;
   const columns = [
     {
       title: '设备名称',
@@ -534,7 +586,7 @@ const WaterFlow = (props) => {
 };
 
 const PressureGauge = (props) => {
-  const { allData } = props;
+  const { allData, type } = props;
 
   const columns = [
     {
@@ -644,14 +696,14 @@ const PressureGauge = (props) => {
 
   return (
     <div>
-      <ModuleTitle title="压力仪表校验" />
+      <ModuleTitle title={`压力仪表校验${type === '1' ? '' : '(历史记录)'}`} />
       <Table dataSource={allData} columns={columns} />
     </div>
   );
 };
 
 const WaterQuality = (props) => {
-  const { allData } = props;
+  const { allData, type } = props;
 
   const columns = [
     {
@@ -761,7 +813,7 @@ const WaterQuality = (props) => {
 
   return (
     <div>
-      <ModuleTitle title="水质仪表校验" />
+      <ModuleTitle title={`水质仪表校验${type === '1' ? '' : '(历史记录)'}`} />
       <Table dataSource={allData} columns={columns} />
     </div>
   );

+ 8 - 4
src/pages/SmartOps/index.js

@@ -99,6 +99,7 @@ function SmartOps(props) {
       type: 'eqSelfInspection/getPatrolDataById',
       payload: {
         routeId: patrolId || reportData.PatrolId,
+        projectId,
       },
       callback: (data) => {
         // console.log(data);
@@ -265,11 +266,14 @@ function SmartOps(props) {
   const lengthCalculate = () => {
     return (
       autoReport?.extendWarningData?.length +
-      autoReport?.FluidLevelList?.filter((item) => item.status).length +
-      autoReport?.DrugFlowList?.filter((item) => item.status)?.length +
+      autoReport?.FluidLevelList?.filter((item) => item.status && !item.history)
+        .length +
+      autoReport?.DrugFlowList?.filter((item) => item.status && !item.history)
+        ?.length +
       autoReport?.WaterInCheckList?.filter((item) => item.status)?.length +
-      autoReport?.WaterQualityCompareList?.length +
-      autoReport?.PressureCompareList?.length
+      autoReport?.WaterQualityCompareList?.filter((item) => !item.history)
+        ?.length +
+      autoReport?.PressureCompareList?.filter((item) => !item.history)?.length
     );
   };
 

+ 13 - 0
src/services/eqSelfInspection.js

@@ -96,3 +96,16 @@ export async function getMandateIDs(params) {
   );
   return res?.data || [];
 }
+
+/**
+ * 获取仪表校验历史数据
+ * @method GET
+ * @param {object} params
+ * @param {string} params.types 不传或【0】代表全查,【1】:压力,【2】:水质,【3】:液位,【4】:加药流量
+ * @param {string} params.project_id 项目ID
+ * @param {string} params.e_time 截至时间
+ * @returns
+ */
+export async function getRecentGaugeRecord(params) {
+  return request(`/api/v1/instrument/compare/recent?${stringify(params)}`);
+}