Explorar el Código

fix: 数据采集和通知管理

100011797 hace 3 años
padre
commit
065ae03983

+ 82 - 10
src/pages/DataCollect/Collector/components/Point/CollectorCard/WritePoint.tsx

@@ -1,9 +1,12 @@
 import { Modal } from 'antd';
-import { FormItem, Input, Form } from '@formily/antd';
-import { createForm } from '@formily/core';
+import { FormItem, Input, Form, Select, ArrayTable, DatePicker, NumberPicker } from '@formily/antd';
+import { createForm, onFormInit } from '@formily/core';
 import { createSchemaField } from '@formily/react';
 import service from '../../../../service';
 import { onlyMessage } from '@/utils/util';
+import GeoComponent from '@/pages/device/Instance/Detail/Tags/location/GeoComponent';
+import { MetadataJsonInput } from '@/components';
+import { useMemo } from 'react';
 
 interface Props {
   data: Partial<PointItem>;
@@ -17,11 +20,82 @@ const WritePoint = (props: Props) => {
     components: {
       Input,
       FormItem,
-      Form,
+      Select,
+      ArrayTable,
+      DatePicker,
+      NumberPicker,
+      GeoComponent,
+      MetadataJsonInput,
     },
   });
 
-  const form = createForm();
+  const form = useMemo(
+    () =>
+      createForm({
+        effects() {
+          onFormInit((f) => {
+            let valueType: string =
+              props.data?.provider === 'OPC_UA'
+                ? props?.data?.configuration?.type || 'Number'
+                : props.data?.configuration?.codec?.provider || 'int8';
+            valueType = valueType.toLocaleLowerCase();
+            switch (valueType) {
+              case 'boolean':
+                f.setFieldState('propertyValue', async (state) => {
+                  state.dataSource = [
+                    {
+                      label: '是',
+                      value: true,
+                    },
+                    {
+                      label: '否',
+                      value: false,
+                    },
+                  ];
+                  state.componentProps = {
+                    placeholder: '请选择',
+                  };
+                  state.componentType = 'Select';
+                });
+                break;
+              case 'int8':
+              case 'int16':
+              case 'int32':
+              case 'int64':
+              case 'ieee754_float':
+              case 'ieee754_double':
+              case 'hex':
+              case 'number':
+                f.setFieldState('propertyValue', (state) => {
+                  state.componentType = 'NumberPicker';
+                  state.componentProps = {
+                    placeholder: '请输入',
+                  };
+                });
+                break;
+              case 'date':
+                f.setFieldState('propertyValue', (state) => {
+                  state.componentType = 'DatePicker';
+                  state.componentProps = {
+                    placeholder: '请选择',
+                    format: 'YYYY-MM-DD HH:mm:ss',
+                  };
+                });
+                break;
+              default:
+                f.setFieldState('propertyValue', (state) => {
+                  state.componentType = 'Input';
+                  state.componentProps = {
+                    placeholder: '请输入',
+                  };
+                });
+                break;
+            }
+          });
+        },
+      }),
+    [props.data?.id],
+  );
   const schema = {
     type: 'object',
     properties: {
@@ -55,7 +129,7 @@ const WritePoint = (props: Props) => {
   return (
     <Modal
       maskClosable={false}
-      title="编辑"
+      title="写入"
       visible
       onOk={async () => {
         const values: any = await form.submit();
@@ -67,11 +141,9 @@ const WritePoint = (props: Props) => {
         props.onCancel();
       }}
     >
-      <div style={{ marginTop: '30px' }}>
-        <Form form={form} layout="vertical">
-          <SchemaField schema={schema} />
-        </Form>
-      </div>
+      <Form form={form} layout="vertical">
+        <SchemaField schema={schema} />
+      </Form>
     </Modal>
   );
 };

+ 19 - 0
src/pages/DataCollect/Collector/components/Point/Save/opc-ua.tsx

@@ -129,6 +129,25 @@ export default (props: Props) => {
               },
             ],
           },
+          'configuration.type': {
+            title: '数据类型',
+            'x-component': 'Select',
+            'x-decorator': 'FormItem',
+            'x-decorator-props': {
+              gridSpan: 2,
+            },
+            'x-component-props': {
+              placeholder: '请选择数据类型',
+            },
+            enum: [
+              { value: 'Number', label: '数值类型' },
+              { value: 'DateTime', label: '时间类型' },
+              { value: 'Array', label: '数组类型' },
+              { value: 'String', label: '文本类型' },
+              { value: 'Boolean', label: '布尔' },
+              // {value: 'date', label: '时间类型'}
+            ],
+          },
           accessModes: {
             title: '访问类型',
             type: 'array',

+ 19 - 4
src/pages/DataCollect/Collector/components/Point/index.tsx

@@ -2,7 +2,7 @@ import { observer } from '@formily/react';
 import SearchComponent from '@/components/SearchComponent';
 import type { ProColumns } from '@jetlinks/pro-table';
 import { useEffect, useRef, useState } from 'react';
-import { useDomFullHeight } from '@/hooks';
+// import { useDomFullHeight } from '@/hooks';
 import service from '@/pages/DataCollect/service';
 import CollectorCard from './CollectorCard';
 import { Empty, PermissionButton } from '@/components';
@@ -59,7 +59,7 @@ const PointModel = model<{
 
 const PointCard = observer((props: PointCardProps) => {
   const [subscribeTopic] = useSendWebsocketMessage();
-  const { minHeight } = useDomFullHeight(`.data-collect-point`);
+  // const { minHeight } = useDomFullHeight(`.data-collect-point`);
   const [param, setParam] = useState({ pageSize: 12, terms: [] });
   const [loading, setLoading] = useState<boolean>(true);
   const { permission } = PermissionButton.usePermission('DataCollect/Collector');
@@ -230,7 +230,7 @@ const PointCard = observer((props: PointCardProps) => {
         loading={loading}
         bordered={false}
         className={'data-collect-point'}
-        style={{ position: 'relative', minHeight }}
+        style={{ position: 'relative', minHeight: 600 }}
         bodyStyle={{ paddingTop: 4 }}
       >
         <div>
@@ -365,7 +365,7 @@ const PointCard = observer((props: PointCardProps) => {
                 </div>
               </>
             ) : (
-              <div style={{ height: minHeight - 150 }}>
+              <div style={{ height: 600 }}>
                 <Empty />
               </div>
             )}
@@ -469,6 +469,21 @@ export default observer((props: Props) => {
         dataIndex: 'name',
       },
       {
+        title: '通讯协议',
+        dataIndex: 'provider',
+        valueType: 'select',
+        valueEnum: {
+          OPC_UA: {
+            text: 'OPC_UA',
+            status: 'OPC_UA',
+          },
+          MODBUS_TCP: {
+            text: 'MODBUS_TCP',
+            status: 'MODBUS_TCP',
+          },
+        },
+      },
+      {
         title: '访问类型',
         dataIndex: 'accessModes$in$any',
         valueType: 'select',

+ 2 - 1
src/pages/device/components/Metadata/Cat/index.tsx

@@ -106,7 +106,8 @@ const Cat = observer((props: Props) => {
               }
             }}
           >
-            导出模型文件
+            {/*导出模型文件*/}
+            导出
           </Button>
         </Space>
       }

+ 2 - 0
src/pages/edge/Resource/Issue/Result.tsx

@@ -24,11 +24,13 @@ const Publish = (props: Props) => {
     const errMessages: any[] = [];
     const _terms = {
       deviceId: (props.list || []).map((item) => item.id),
+      // params: {
       name: props.data.name,
       targetId: props.data.targetId,
       targetType: props.data.targetType,
       category: props.data.category,
       metadata: encodeURIComponent(props.data?.metadata || ''),
+      // }
     };
     const url = new URLSearchParams();
     Object.keys(_terms).forEach((key) => {

+ 1 - 1
src/pages/link/AccessConfig/service.ts

@@ -27,7 +27,7 @@ class Service extends BaseService<AccessItem> {
       method: 'GET',
     });
   public getNetworkList = (networkType: string, params?: any) =>
-    request(`/${SystemConst.API_BASE}/network/config/${networkType}/_alive`, {
+    request(`/${SystemConst.API_BASE}/network/config/${networkType}/_detail`, {
       method: 'GET',
       params,
     });

+ 1 - 1
src/pages/rule-engine/Scene/Save/action/notify/VariableDefinitions.tsx

@@ -183,7 +183,7 @@ export default forwardRef((props: Props, ref) => {
               name={item.id}
               label={item.name}
               initialValue={initialValue}
-              required={true}
+              required={type !== 'file' ? true : false}
               rules={rules}
             >
               {typeComponents(item)}

+ 9 - 4
src/pages/rule-engine/Scene/Save/action/notify/index.tsx

@@ -203,12 +203,17 @@ export default observer((props: Props) => {
           onChange={async (value: number) => {
             if (value === 0) {
               NotifyModel.current = value;
-            }
-            if (value === 1) {
-              if (NotifyModel.notify.notifyType) {
+            } else if (value === 1) {
+              const val = await WayRef.current?.save();
+              if (val) {
+                NotifyModel.notify.notifyType = val;
                 NotifyModel.current = value;
               } else {
-                onlyMessage('请选择通知方式', 'error');
+                if (NotifyModel.notify.notifyType) {
+                  NotifyModel.current = value;
+                } else {
+                  onlyMessage('请选择通知方式', 'error');
+                }
               }
             } else if (value === 2) {
               if (NotifyModel.notify.notifierId) {

+ 12 - 1
src/pages/system/DataSource/Management/DataTable.tsx

@@ -1,5 +1,5 @@
 import { Form, FormGrid, FormItem, Input, Password, Select } from '@formily/antd';
-import { createForm } from '@formily/core';
+import { createForm, registerValidateRules } from '@formily/core';
 import type { ISchema } from '@formily/react';
 import { createSchemaField } from '@formily/react';
 import { Modal } from 'antd';
@@ -26,6 +26,14 @@ const DataTable = (props: Props) => {
     },
   });
 
+  registerValidateRules({
+    validateId(value) {
+      if (!value) return '';
+      const reg = new RegExp('^[0-9a-zA-Z_\\\\-]+$');
+      return reg.exec(value) ? '' : 'ID只能由数字、字母、下划线、中划线组成';
+    },
+  });
+
   const schema: ISchema = {
     type: 'object',
     properties: {
@@ -50,6 +58,9 @@ const DataTable = (props: Props) => {
             required: true,
             message: '请输入名称',
           },
+          {
+            validateId: true,
+          },
         ],
         required: true,
       },

+ 12 - 12
src/pages/system/DataSource/Save/index.tsx

@@ -112,10 +112,10 @@ const Save = (props: Props) => {
               placeholder: '请输入r2bdc或者jdbc连接地址,示例:r2dbc:mysql://127.0.0.1:3306/test',
             },
             'x-validator': [
-              {
-                format: 'url',
-                message: '请输入正确的URL',
-              },
+              // {
+              //   format: 'url',
+              //   message: '请输入正确的URL',
+              // },
               {
                 required: true,
                 message: '请输入URL',
@@ -144,10 +144,10 @@ const Save = (props: Props) => {
               placeholder: '请输入管理地址,示例:http://localhost:15672',
             },
             'x-validator': [
-              {
-                format: 'url',
-                message: '请输入正确的管理地址',
-              },
+              // {
+              //   format: 'url',
+              //   message: '请输入正确的管理地址',
+              // },
               {
                 required: true,
                 message: '请输入管理地址',
@@ -176,10 +176,10 @@ const Save = (props: Props) => {
               placeholder: '请输入链接地址,示例:localhost:5672',
             },
             'x-validator': [
-              {
-                format: 'url',
-                message: '请输入正确的链接地址',
-              },
+              // {
+              //   format: 'url',
+              //   message: '请输入正确的链接地址',
+              // },
               {
                 required: true,
                 message: '请输入链接地址',