Kaynağa Gözat

ws-数据源ua订阅模式修改

ws 11 ay önce
ebeveyn
işleme
e6ebebd0c7

+ 53 - 9
industry-admin/src/views/source/dataSource/index.vue

@@ -80,7 +80,7 @@
       <!-- 数据源连接基础配置弹出层 -->
       <el-dialog :title="configTitle" width="500px" :before-close="handleConfigClose"
         :visible.sync="configVisible" :close-on-click-modal="false" :append-to-body="true">
-        <el-form ref="dataSourceFormTwo" :model='dataSourceForm' :rules="dataSourceRules" label-width='100px'>
+        <el-form ref="dataSourceFormTwo" :model='dataSourceForm' :rules="dataSourceRules" label-width='120px'>
           <el-form-item label='IP地址:' prop="ipAddress">
             <el-input v-model='dataSourceForm.ipAddress' type="text" auto-complete="off"
               placeholder="请输入IP地址"></el-input>
@@ -89,31 +89,44 @@
             <el-input v-model.number='dataSourceForm.ipPort' type="text" auto-complete="off" placeholder="请输入端口号"
               oninput="value=value.replace(/[^0-9.]/g,'')"></el-input>
           </el-form-item>
-          <el-form-item label='安全模式:' prop="securityMode" required v-if="dataSourceForm.type == 'opc_ua_real' || dataSourceForm.type == 'opc_ua_fast'">
+          <el-form-item label='安全模式:' prop="securityMode" required v-if="dataSourceForm.type == 'opc_ua_real'">
             <el-select v-model="dataSourceForm.securityMode" placeholder="请选择安全模式" style="width: calc(100% - 0px);">
               <el-option v-for="dict in securityMode" :key="dict.value" :label="dict.key"
                 :value="dict.value"></el-option>
             </el-select>
           </el-form-item>
-          <el-form-item label='安全策略:' prop="securityPolicy" required v-if="dataSourceForm.type == 'opc_ua_real' || dataSourceForm.type == 'opc_ua_fast'">
+          <el-form-item label='安全策略:' prop="securityPolicy" required v-if="dataSourceForm.type == 'opc_ua_real'">
             <el-select v-model="dataSourceForm.securityPolicy" placeholder="请选择安全策略" style="width: calc(100% - 0px);">
               <el-option v-for="dict in securityPolicy" :key="dict.value" :label="dict.key"
                 :value="dict.value"></el-option>
             </el-select>
           </el-form-item>
-          <el-form-item label="认证方式" prop="identityProvider" required
+          <el-form-item label="认证方式" prop="identityProvider" required
             v-if="dataSourceForm.type != 'opc_da_real' && dataSourceForm.type != 'modbus_real'">
             <el-radio-group v-model="dataSourceForm.identityProvider">
               <el-radio v-for="dict in identityProvider" :key="dict.value" :label="dict.value">{{ dict.key }}</el-radio>
             </el-radio-group>
           </el-form-item>
+          <el-form-item label="开启订阅模式:" prop="subscribe" required
+                        v-if="dataSourceForm.type == 'opc_ua_real'">
+            <el-radio-group v-model="dataSourceForm.subscribe" @input="subscribeEvent">
+              <el-radio :key="0" :label="0" :value="0">否</el-radio>
+              <el-radio :key="1" :label="1" :value="1">是</el-radio>
+            </el-radio-group>
+          </el-form-item>
+          <el-form-item label="采集间隔:" prop="uaInterval"
+                        v-if="dataSourceForm.type == 'opc_ua_real' && dataSourceForm.isShowSub">
+            <el-input placeholder="请输入间隔" v-model="dataSourceForm.uaInterval">
+              <template slot="append">毫秒</template>
+            </el-input>
+          </el-form-item>
           <el-form-item label='帐号:' prop="ipUserName"
-            v-if="((dataSourceForm.type != 'opc_ua_real'  && dataSourceForm.type != 'opc_ua_fast') || dataSourceForm.identityProvider == 1) && dataSourceForm.type != 'modbus_real'">
+            v-if="(dataSourceForm.type != 'opc_ua_real' || dataSourceForm.identityProvider == 1) && dataSourceForm.type != 'modbus_real'">
             <el-input v-model='dataSourceForm.ipUserName' type="text" auto-complete="off"
               placeholder="请输入帐号"></el-input>
           </el-form-item>
           <el-form-item label='密码:' prop="ipPassword" key="ipPassword"
-            v-if="((dataSourceForm.type != 'opc_ua_real'  && dataSourceForm.type != 'opc_ua_fast') || dataSourceForm.identityProvider == 1) && dataSourceForm.type != 'modbus_real'">
+            v-if="(dataSourceForm.type != 'opc_ua_real' || dataSourceForm.identityProvider == 1) && dataSourceForm.type != 'modbus_real'">
             <el-input v-model='dataSourceForm.ipPassword' clearable type="password" auto-complete="new-password"
               placeholder="请输入密码"></el-input>
           </el-form-item>
@@ -206,7 +219,10 @@ export default {
         clsId: '',
         progId: '',
         driverDescribe: '',
-        slaveId: ''
+        slaveId: '',
+        subscribe: 0,
+        isShowSub: false,
+        uaInterval: ''
       },
       // ***************** 表单校验开始 *****************
       dataSourceRules: {
@@ -296,6 +312,25 @@ export default {
         slaveId: [
           { required: true, message: '从站ID不能为空', trigger: 'blur' }
         ],
+        uaInterval: [
+          {
+            validator: (rule, value, callback) => {
+              if (this.dataSourceForm.subscribe == 1) {
+                if (!value) {
+                  callback(new Error('采集间隔不能为空'))
+                } else if (!/^[1-9]\d*$/.test(value)) {
+                  callback(new Error('采集间隔格式错误'))
+                } else if (parseInt(value) < 10) {
+                  callback(new Error('最小支持10毫秒采集间隔'))
+                } else {
+                  callback()
+                }
+              } else {
+                callback()
+              }
+            }
+          }
+        ]
       },
       // ***************** 表单校验结束 *****************
     }
@@ -317,6 +352,9 @@ export default {
   watch: {
   },
   methods: {
+    subscribeEvent(e) {
+      this.dataSourceForm.isShowSub = e == 1
+    },
     /** 获取所有数据源列表 */
     getAllDataSource() {
       getAllDataSource(this.queryParams).then(res => {
@@ -396,6 +434,9 @@ export default {
       this.dataSourceForm.driverDescribe = row.driverDescribe
       this.dataSourceForm.slaveId = row.slaveId
       this.datasourceDialogVisible = true
+      this.dataSourceForm.subscribe = row.subscribe
+      this.dataSourceForm.isShowSub = row.subscribe == 1
+      this.dataSourceForm.uaInterval = row.uaInterval
     },
     /** 数据类型树点击事件 */
     handleNodeClick(data, node, target) {
@@ -436,7 +477,10 @@ export default {
         clsId: '',
         progId: '',
         driverDescribe: '',
-        slaveId: ''
+        slaveId: '',
+        subscribe: 0,
+        isShowSub: false,
+        uaInterval: ''
       }
     },
     /** 初始化表单信息 */
@@ -450,7 +494,7 @@ export default {
         this.dataSourceForm.progId = ''
         this.dataSourceForm.driverDescribe = ''
       }
-      if (this.dataSourceForm.type === 'opc_ua_real' || this.dataSourceForm.type === 'opc_ua_fast') {
+      if (this.dataSourceForm.type === 'opc_ua_real') {
         this.dataSourceForm.securityMode = 1
         this.dataSourceForm.securityPolicy = 'http://opcfoundation.org/UA/SecurityPolicy#None'
         this.dataSourceForm.identityProvider = 0

+ 6 - 0
industry-system/cqcy-ei-common/src/main/java/com/example/opc_common/entity/DataSource.java

@@ -55,6 +55,12 @@ public class DataSource implements Serializable {
     private String dataSourceTypeKey;
     private String dataSourceTypeDescribe;
 
+    /**
+     * opc ua 订阅模式字段
+     */
+    private Integer subscribe;
+    private Integer uaInterval;
+
 
     public static DataSource convertPassword(DataSource dataSource) {
         if (Blank.isEmpty(dataSource)) {

+ 4 - 0
industry-system/cqcy-ei-common/src/main/java/com/example/opc_common/entity/DataSourceType.java

@@ -33,4 +33,8 @@ public class DataSourceType implements Serializable {
      * 数据源类型描述
      */
     private String dataSourceTypeDescribe;
+
+    private Integer subscribe;
+
+    private Integer uaInterval;
 }

+ 6 - 4
industry-system/industry-da/src/main/resources/mapper/DataSourceDao.xml

@@ -10,7 +10,7 @@
 
     <sql id="dataSourceType">
         id
-        , parent_id, data_source_type_name, data_source_type_key, sort_num, data_source_type_describe
+        , parent_id, data_source_type_name, data_source_type_key, sort_num, data_source_type_describe,subscribe,ua_interval
     </sql>
 
     <sql id="dataSourceDriver">
@@ -28,11 +28,11 @@
                                   ip_user_name,
                                   ip_password, security_mode, security_policy, identity_provider, certificate_dir,
                                   certificate_key, cls_id,
-                                  prog_id, driver_describe, create_time, slave_id)
+                                  prog_id, driver_describe, create_time, slave_id, subscribe, ua_interval)
             VALUE (#{typeId},#{userId}, #{dataSourceName}, #{dataSourceDescribe},
             #{ipAddress}, #{ipPort},
             #{ipUserName}, #{ipPassword},#{securityMode},#{securityPolicy},#{identityProvider},#{certificateDir},
-            #{certificateKey},#{clsId},#{progId},#{driverDescribe}, now(), #{slaveId})
+            #{certificateKey},#{clsId},#{progId},#{driverDescribe}, now(), #{slaveId}, #{subscribe}, #{uaInterval})
     </insert>
 
     <insert id="addDataSourceDriver" parameterType="com.example.opc_common.entity.DataSourceDriver"
@@ -71,7 +71,9 @@
             cls_id=#{clsId},
             prog_id=#{progId},
             driver_describe=#{driverDescribe},
-            slave_id = #{slaveId}
+            slave_id = #{slaveId},
+            subscribe = #{subscribe},
+            ua_interval = #{uaInterval}
         where id = #{id}
     </update>