Explorar el Código

fix: 修改设备诊断bug

sun-chaochao hace 3 años
padre
commit
e8a5d0d234

+ 1 - 1
src/components/FTermArrayCards/index.tsx

@@ -123,7 +123,7 @@ export const FTermArrayCards: ComposedArrayCards = observer((props) => {
   };
 
   const renderAddition = () => {
-    return schema.reduceProperties((addition, schema3, key) => {
+    return schema.reduceProperties((addition: any, schema3: any, key: any) => {
       if (isAdditionComponent(schema3)) {
         return <RecursionField schema={schema3} name={key} />;
       }

+ 36 - 11
src/pages/device/Instance/Detail/Diagnose/Status/ManualInspection.tsx

@@ -3,6 +3,8 @@ import { createSchemaField } from '@formily/react';
 import type { ISchema } from '@formily/json-schema';
 import { Form, FormGrid, FormItem, Input, Password, PreviewText } from '@formily/antd';
 import { Modal } from 'antd';
+import styles from './index.less';
+import { ExclamationCircleFilled } from '@ant-design/icons';
 
 const componentMap = {
   string: 'Input',
@@ -11,12 +13,12 @@ const componentMap = {
 
 interface Props {
   close: () => void;
-  metadata: any;
+  data: any;
   ok: (data: any) => void;
 }
 
 const ManualInspection = (props: Props) => {
-  const { metadata } = props;
+  const { data } = props;
 
   const form = createForm({
     validateFirst: true,
@@ -33,9 +35,9 @@ const ManualInspection = (props: Props) => {
     },
   });
 
-  const configToSchema = (data: any[]) => {
+  const configToSchema = (list: any[]) => {
     const config = {};
-    data.forEach((item) => {
+    list.forEach((item) => {
       config[item.property] = {
         type: 'string',
         title: item.name,
@@ -47,6 +49,7 @@ const ManualInspection = (props: Props) => {
         },
         'x-component-props': {
           value: '',
+          placeholder: `请输入${item.name}`,
         },
       };
     });
@@ -64,7 +67,7 @@ const ManualInspection = (props: Props) => {
             minColumns: [1],
             maxColumns: [1],
           },
-          properties: configToSchema(metadata?.data?.properties),
+          properties: configToSchema(data?.data?.properties),
         },
       },
     };
@@ -79,42 +82,64 @@ const ManualInspection = (props: Props) => {
       </>
     );
   };
+  const renderComponent = () => (
+    <div style={{ backgroundColor: '#f6f6f6', padding: 10 }}>
+      {(data?.data?.properties || []).map((item: any) => (
+        <div key={item.property}>
+          <span>{item.name}</span>:{' '}
+          <span>{item.type.type !== 'password' ? data?.check[item.property] : '******'}</span>
+        </div>
+      ))}
+    </div>
+  );
+
   return (
     <Modal
       title="人工检查"
       onCancel={() => {
         props.close();
       }}
+      width={600}
       onOk={async () => {
         const values = (await form.submit()) as any;
-        if (metadata?.check) {
+        if (!data?.check) {
           props.ok({
             status: 'error',
-            data: metadata,
+            data: data,
           });
         } else {
           let flag = true;
           Object.keys(values).forEach((key) => {
-            if (values[key] !== metadata?.check[key]) {
+            if (values[key] !== data?.check[key]) {
               flag = false;
             }
           });
           if (flag) {
             props.ok({
               status: 'success',
-              data: metadata,
+              data: data,
             });
           } else {
             props.ok({
               status: 'error',
-              data: metadata,
+              data: data,
             });
           }
         }
       }}
       visible
     >
-      {renderConfigCard()}
+      <div className={styles.alert}>
+        <ExclamationCircleFilled style={{ marginRight: 10 }} />
+        {data.type === 'product'
+          ? `当前填写的数据将与产品-设备接入配置中的${data.data.name}数据进行比对`
+          : `当前填写的数据将与设备-实例信息配置中的${data.data.name}数据进行比对`}
+      </div>
+      <div style={{ marginTop: 10 }}>
+        已配置参数
+        {renderComponent()}
+      </div>
+      <div style={{ marginTop: 10 }}>{renderConfigCard()}</div>
     </Modal>
   );
 };

+ 50 - 93
src/pages/device/Instance/Detail/Diagnose/Status/index.tsx

@@ -306,7 +306,7 @@ const Status = observer((props: Props) => {
       } else {
         data = {
           status: proItem?.state === 1 ? 'success' : 'error',
-          text: proItem?.state === 1 ? '异常' : '正常',
+          text: proItem?.state === 1 ? '正常' : '异常',
           info:
             proItem?.state === 1 ? null : (
               <div className={styles.infoItem}>
@@ -440,8 +440,9 @@ const Status = observer((props: Props) => {
                               onClick={() => {
                                 setArtificialVisible(true);
                                 setArtificiaData({
+                                  type: 'product',
                                   data: item,
-                                  name: `productAuth${index}`,
+                                  key: `productAuth${index}`,
                                   check: proItem.configuration,
                                 });
                               }}
@@ -500,8 +501,9 @@ const Status = observer((props: Props) => {
                               onClick={() => {
                                 setArtificialVisible(true);
                                 setArtificiaData({
+                                  type: 'device',
                                   data: item,
-                                  name: `deviceAuth${index}`,
+                                  key: `deviceAuth${index}`,
                                   check: InstanceModel.detail?.configuration,
                                 });
                               }}
@@ -745,107 +747,62 @@ const Status = observer((props: Props) => {
       )}
       {artificialVisible && (
         <ManualInspection
-          metadata={artificiaData}
+          data={artificiaData}
           close={() => {
             setArtificialVisible(false);
           }}
           ok={(params: any) => {
             setArtificialVisible(false);
-            console.log(params);
             if (params.status === 'success') {
-              DiagnoseStatusModel.status[params.data.name] = {
+              DiagnoseStatusModel.status[params.data.key] = {
                 status: 'success',
                 text: '正常',
                 info: null,
               };
             } else {
-              if (!params.data.name.includes('device')) {
-                DiagnoseStatusModel.status[params.data.name] = {
-                  status: 'error',
-                  text: '异常',
-                  info: (
-                    <div className={styles.infoItem}>
-                      <Badge
-                        status="default"
-                        text={
-                          <span>
-                            产品-{params.data.name}配置错误,请
-                            <a
-                              onClick={() => {
-                                const url = getMenuPathByParams(
-                                  MENUS_CODE['device/Product/Detail'],
-                                  InstanceModel.detail?.productId,
-                                );
-                                const tab: any = window.open(`${origin}/#${url}?key=access`);
-                                tab!.onTabSaveSuccess = (value: any) => {
-                                  if (value) {
-                                    diagnoseConfig();
-                                  }
-                                };
-                              }}
-                            >
-                              重新配置
-                            </a>
-                            或
-                            <a
-                              onClick={() => {
-                                setArtificialVisible(true);
-                                setArtificiaData(params.data);
-                              }}
-                            >
-                              重新比对
-                            </a>
-                            。
-                          </span>
-                        }
-                      />
-                    </div>
-                  ),
-                };
-              } else {
-                DiagnoseStatusModel.status[params.data.name] = {
-                  status: 'error',
-                  text: '异常',
-                  info: (
-                    <div className={styles.infoItem}>
-                      <Badge
-                        status="default"
-                        text={
-                          <span>
-                            设备-{params.data.name}配置错误,请
-                            <a
-                              onClick={() => {
-                                const url = getMenuPathByParams(
-                                  MENUS_CODE['device/Product/Detail'],
-                                  InstanceModel.detail?.productId,
-                                );
-                                const tab: any = window.open(`${origin}/#${url}?key=access`);
-                                tab!.onTabSaveSuccess = (value: any) => {
-                                  if (value) {
-                                    diagnoseConfig();
-                                  }
-                                };
-                              }}
-                            >
-                              重新配置
-                            </a>
-                            或
-                            <a
-                              onClick={() => {
-                                setArtificialVisible(true);
-                                setArtificiaData(params.data);
-                              }}
-                            >
-                              重新比对
-                            </a>
-                            。
-                          </span>
-                        }
-                      />
-                    </div>
-                  ),
-                };
-              }
+              DiagnoseStatusModel.status[params.data.key] = {
+                status: 'error',
+                text: '异常',
+                info: (
+                  <div className={styles.infoItem}>
+                    <Badge
+                      status="default"
+                      text={
+                        <span>
+                          {params.data.type === 'device' ? '设备' : '产品'}-{params.data.data.name}
+                          配置错误,请
+                          <a
+                            onClick={() => {
+                              const url = getMenuPathByParams(
+                                MENUS_CODE['device/Product/Detail'],
+                                InstanceModel.detail?.productId,
+                              );
+                              const tab: any = window.open(`${origin}/#${url}?key=access`);
+                              tab!.onTabSaveSuccess = (value: any) => {
+                                if (value) {
+                                  diagnoseConfig();
+                                }
+                              };
+                            }}
+                          >
+                            重新配置
+                          </a>
+                          或
+                          <a
+                            onClick={() => {
+                              setArtificialVisible(true);
+                              setArtificiaData(params.data);
+                            }}
+                          >
+                            重新比对
+                          </a>
+                          。
+                        </span>
+                      }
+                    />
+                  </div>
+                ),
+              };
             }
           }}
         />

+ 1 - 1
src/pages/device/Instance/Detail/MetadataMap/EditableTable/index.tsx

@@ -74,7 +74,7 @@ const EditableCell = ({
             (option?.children || '').toLowerCase()?.indexOf(input.toLowerCase()) >= 0
           }
         >
-          <Select.Option value={record.metadataId}>使用原始属性</Select.Option>
+          <Select.Option value={record.metadataId}>使用物模型属性</Select.Option>
           {record.originalId !== record.metadataId && (
             <Select.Option value={record.originalId}>
               {temp?.name}({temp?.id})

+ 24 - 21
src/pages/device/Product/Detail/Access/AccessConfig/index.tsx

@@ -83,29 +83,32 @@ const AccessConfig = (props: Props) => {
       visible
       width={1200}
       title={'设备接入配置'}
-      onOk={() => {
+      onOk={async () => {
         if (!!currrent) {
-          service1
-            .update({
-              ...productModel.current,
-              transportProtocol: currrent.transport,
-              protocolName: currrent.protocolDetail.name,
-              accessId: currrent.id,
-              accessName: currrent.name,
-              accessProvider: currrent.provider,
-              messageProtocol: currrent.protocol,
-            })
-            .then((resp) => {
-              if (resp.status === 200) {
-                service1.detail(productModel.current?.id || '').then((res) => {
-                  if (res.status === 200) {
-                    productModel.current = { ...res.result };
-                    message.success('操作成功!');
+          const resp: any = await service1.update({
+            ...productModel.current,
+            transportProtocol: currrent.transport,
+            protocolName: currrent.protocolDetail.name,
+            accessId: currrent.id,
+            accessName: currrent.name,
+            accessProvider: currrent.provider,
+            messageProtocol: currrent.protocol,
+          });
+          if (resp.status === 200) {
+            service1
+              .changeDeploy(productModel.current?.id || '', 'deploy')
+              .subscribe((response) => {
+                if (response) {
+                  service1.detail(productModel.current?.id || '').then((res) => {
+                    if (res.status === 200) {
+                      productModel.current = { ...res.result };
+                      message.success('操作成功!');
+                    }
                     close();
-                  }
-                });
-              }
-            });
+                  });
+                }
+              });
+          }
         } else {
           message.success('请选择接入方式');
         }

+ 15 - 16
src/pages/device/Product/Detail/Access/index.tsx

@@ -89,11 +89,11 @@ const Access = () => {
       title: 'topic',
       dataIndex: 'topic',
       key: 'topic',
-      ellipsis: true,
-      align: 'center',
       render: (text: any) => (
         <Tooltip placement="topLeft" title={text}>
-          {text}
+          <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+            {text}
+          </div>
         </Tooltip>
       ),
     },
@@ -119,11 +119,11 @@ const Access = () => {
       title: '说明',
       dataIndex: 'description',
       key: 'description',
-      ellipsis: true,
-      align: 'center',
       render: (text: any) => (
         <Tooltip placement="topLeft" title={text}>
-          {text}
+          <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+            {text}
+          </div>
         </Tooltip>
       ),
     },
@@ -136,7 +136,6 @@ const Access = () => {
       key: 'group',
       ellipsis: true,
       width: 100,
-      align: 'center',
       onCell: (record: any, index: number) => {
         const list = (config?.routes || []).sort((a: any, b: any) => a - b) || [];
         const arr = list.filter((res: any) => {
@@ -154,11 +153,11 @@ const Access = () => {
       title: '地址',
       dataIndex: 'address',
       key: 'address',
-      ellipsis: true,
-      align: 'center',
       render: (text: any) => (
         <Tooltip placement="topLeft" title={text}>
-          {text}
+          <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+            {text}
+          </div>
         </Tooltip>
       ),
     },
@@ -166,11 +165,11 @@ const Access = () => {
       title: '示例',
       dataIndex: 'example',
       key: 'example',
-      ellipsis: true,
-      align: 'center',
       render: (text: any) => (
         <Tooltip placement="topLeft" title={text}>
-          {text}
+          <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+            {text}
+          </div>
         </Tooltip>
       ),
     },
@@ -178,11 +177,11 @@ const Access = () => {
       title: '说明',
       dataIndex: 'description',
       key: 'description',
-      ellipsis: true,
-      align: 'center',
       render: (text: any) => (
         <Tooltip placement="topLeft" title={text}>
-          {text}
+          <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+            {text}
+          </div>
         </Tooltip>
       ),
     },

+ 29 - 40
src/pages/link/AccessConfig/Detail/Access/index.tsx

@@ -152,12 +152,7 @@ const Access = (props: Props) => {
       key: 'group',
       ellipsis: true,
       align: 'center',
-      width: 80,
-      render: (text: any) => (
-        <Tooltip placement="top" title={text}>
-          {text}
-        </Tooltip>
-      ),
+      width: 100,
       onCell: (record: any, index: number) => {
         const list = (config?.routes || []).sort((a: any, b: any) => a - b) || [];
         const arr = list.filter((res: any) => {
@@ -175,12 +170,11 @@ const Access = (props: Props) => {
       title: 'topic',
       dataIndex: 'topic',
       key: 'topic',
-      ellipsis: true,
-      align: 'center',
-      with: '30%',
       render: (text: any) => (
-        <Tooltip placement="top" title={text}>
-          {text}
+        <Tooltip placement="topLeft" title={text}>
+          <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+            {text}
+          </div>
         </Tooltip>
       ),
     },
@@ -189,8 +183,8 @@ const Access = (props: Props) => {
       dataIndex: 'stream',
       key: 'stream',
       ellipsis: true,
-      width: 80,
       align: 'center',
+      width: 100,
       render: (text: any, record: any) => {
         const list = [];
         if (record?.upstream) {
@@ -206,11 +200,11 @@ const Access = (props: Props) => {
       title: '说明',
       dataIndex: 'description',
       key: 'description',
-      ellipsis: true,
-      align: 'center',
       render: (text: any) => (
-        <Tooltip placement="top" title={text}>
-          {text}
+        <Tooltip placement="topLeft" title={text}>
+          <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+            {text}
+          </div>
         </Tooltip>
       ),
     },
@@ -218,16 +212,11 @@ const Access = (props: Props) => {
 
   const columnsHTTP: any[] = [
     {
-      title: '地址',
-      dataIndex: 'address',
-      key: 'address',
+      title: '分组',
+      dataIndex: 'group',
+      key: 'group',
       ellipsis: true,
-      align: 'center',
-      render: (text: any) => (
-        <Tooltip placement="top" title={text}>
-          {text}
-        </Tooltip>
-      ),
+      width: 100,
       onCell: (record: any, index: number) => {
         const list = (config?.routes || []).sort((a: any, b: any) => a - b) || [];
         const arr = list.filter((res: any) => {
@@ -242,14 +231,14 @@ const Access = (props: Props) => {
       },
     },
     {
-      title: '分组',
-      dataIndex: 'group',
-      key: 'group',
-      ellipsis: true,
-      align: 'center',
+      title: '地址',
+      dataIndex: 'address',
+      key: 'address',
       render: (text: any) => (
-        <Tooltip placement="top" title={text}>
-          {text}
+        <Tooltip placement="topLeft" title={text}>
+          <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+            {text}
+          </div>
         </Tooltip>
       ),
     },
@@ -257,11 +246,11 @@ const Access = (props: Props) => {
       title: '示例',
       dataIndex: 'example',
       key: 'example',
-      ellipsis: true,
-      align: 'center',
       render: (text: any) => (
-        <Tooltip placement="top" title={text}>
-          {text}
+        <Tooltip placement="topLeft" title={text}>
+          <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+            {text}
+          </div>
         </Tooltip>
       ),
     },
@@ -269,11 +258,11 @@ const Access = (props: Props) => {
       title: '说明',
       dataIndex: 'description',
       key: 'description',
-      ellipsis: true,
-      align: 'center',
       render: (text: any) => (
-        <Tooltip placement="top" title={text}>
-          {text}
+        <Tooltip placement="topLeft" title={text}>
+          <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+            {text}
+          </div>
         </Tooltip>
       ),
     },

+ 7 - 1
src/pages/media/Cascade/Channel/index.tsx

@@ -28,6 +28,12 @@ const Channel = () => {
     if (resp.status === 200) {
       actionRef.current?.reload();
       message.success('操作成功!');
+      if (list.length === 1) {
+        const index = selectedRowKey.indexOf(list[0]);
+        const dt = [...selectedRowKey];
+        dt.splice(index, 1);
+        setSelectedRowKey([...dt]);
+      }
     }
   };
 
@@ -195,7 +201,7 @@ const Channel = () => {
         request={async (params) => {
           return service.queryBindChannel(id, {
             ...params,
-            sorts: [{ name: 'createTime', order: 'desc' }],
+            sorts: [{ name: 'name', order: 'desc' }],
           });
         }}
         rowKey="channelId"

+ 5 - 2
src/pages/rule-engine/Alarm/Log/SolveLog/index.tsx

@@ -4,6 +4,7 @@ import ProTable from '@jetlinks/pro-table';
 import { Modal } from 'antd';
 import { useRef, useState } from 'react';
 import { service } from '@/pages/rule-engine/Alarm/Log';
+import moment from 'moment';
 
 interface Props {
   data: Partial<AlarmLogItem>;
@@ -35,8 +36,9 @@ const SolveLog = (props: Props) => {
 
   const columns: ProColumns<AlarmLogSolveHistoryItem>[] = [
     {
-      dataIndex: 'createTime',
+      dataIndex: 'handleTIme',
       title: '处理时间',
+      render: (text: any) => <span>{moment(text).format('YYYY-MM-DD HH:mm:ss')}</span>,
     },
     {
       dataIndex: 'handleType',
@@ -44,8 +46,9 @@ const SolveLog = (props: Props) => {
       render: (text: any) => <span>{typeMap.get(text) || ''}</span>,
     },
     {
-      dataIndex: 'address',
+      dataIndex: 'createTime',
       title: '告警时间',
+      render: (text: any) => <span>{moment(text).format('YYYY-MM-DD HH:mm:ss')}</span>,
     },
     {
       dataIndex: 'description',

+ 1 - 1
src/pages/rule-engine/Alarm/Log/TabComponent/index.tsx

@@ -152,7 +152,7 @@ const TabComponent = observer((props: Props) => {
                           item.level}
                       </div>
                     </div>
-                    <div className="alarm-log-title-text">{item.name}</div>
+                    <div className="alarm-log-title-text">{item.alarmName}</div>
                   </div>
                   <div className="alarm-log-content">
                     <div className="alarm-log-image">