Bläddra i källkod

`点表跟新`

wenhongquan 2 år sedan
förälder
incheckning
a7c9c98ae1

+ 4 - 4
ruoyi-system/src/main/java/com/ruoyi/data/domain/bo/TblDatapointBo.java

@@ -32,7 +32,7 @@ public class TblDatapointBo extends BaseEntity {
     /**
      * 名称
      */
-    @NotBlank(message = "名称不能为空", groups = { AddGroup.class, EditGroup.class })
+    @NotNull(message = "名称不能为空", groups = { AddGroup.class, EditGroup.class })
     private String name;
 
     /**
@@ -44,13 +44,13 @@ public class TblDatapointBo extends BaseEntity {
     /**
      * 数据类型
      */
-    @NotBlank(message = "数据类型不能为空", groups = { AddGroup.class, EditGroup.class })
+//    @NotBlank(message = "数据类型不能为空", groups = { AddGroup.class, EditGroup.class })
     private Long dataType;
 
     /**
      * 从设备号
      */
-    @NotBlank(message = "从设备号不能为空", groups = { AddGroup.class, EditGroup.class })
+//    @NotBlank(message = "从设备号不能为空", groups = { AddGroup.class, EditGroup.class })
     private String slaveDeviceNumber;
 
     /**
@@ -74,7 +74,7 @@ public class TblDatapointBo extends BaseEntity {
     /**
      * 变量类型
      */
-    @NotBlank(message = "变量类型不能为空", groups = { AddGroup.class, EditGroup.class })
+//    @NotBlank(message = "变量类型不能为空", groups = { AddGroup.class, EditGroup.class })
     private String valueType;
 
     /**

+ 10 - 10
ruoyi-ui-vue3/src/api/data/sensorSbook.js → ruoyi-ui-vue3/src/api/data/sensor.js

@@ -1,44 +1,44 @@
 import request from '@/utils/request'
 
 // 查询传感器台账列表
-export function listSensorSbook(query) {
+export function listSensor(query) {
   return request({
-    url: '/data/sensorSbook/list',
+    url: '/data/sensor/list',
     method: 'get',
     params: query
   })
 }
 
 // 查询传感器台账详细
-export function getSensorSbook(id) {
+export function getSensor(id) {
   return request({
-    url: '/data/sensorSbook/' + id,
+    url: '/data/sensor/' + id,
     method: 'get'
   })
 }
 
 // 新增传感器台账
-export function addSensorSbook(data) {
+export function addSensor(data) {
   return request({
-    url: '/data/sensorSbook',
+    url: '/data/sensor',
     method: 'post',
     data: data
   })
 }
 
 // 修改传感器台账
-export function updateSensorSbook(data) {
+export function updateSensor(data) {
   return request({
-    url: '/data/sensorSbook',
+    url: '/data/sensor',
     method: 'put',
     data: data
   })
 }
 
 // 删除传感器台账
-export function delSensorSbook(id) {
+export function delSensor(id) {
   return request({
-    url: '/data/sensorSbook/' + id,
+    url: '/data/sensor/' + id,
     method: 'delete'
   })
 }

+ 2 - 2
ruoyi-ui-vue3/src/router/index.js

@@ -171,7 +171,7 @@ export const constantRoutes = [
         path: "",
         component: () => import("@/views/gateway/pointsetting/setting"),
         name: "PointSetting" ,
-        meta: { title: "点表配置", activeMenu: "/gateway/pointsetting/setting" },
+        meta: { title: "点表配置", activeMenu: "/gateway/pointsetting" },
       },
     ],
   },
@@ -184,7 +184,7 @@ export const constantRoutes = [
         path: "",
         component: () => import("@/views/gateway/pointsetting/add"),
         name: "PointSettingAdd" ,
-        meta: { title: "点表配置新增", activeMenu: "/gateway/pointsetting/add" },
+        meta: { title: "点表配置新增", activeMenu: "/gateway/pointsetting" },
       },
     ],
   },

+ 88 - 28
ruoyi-ui-vue3/src/views/gateway/pointsetting/add.vue

@@ -3,10 +3,10 @@
     <el-card class="box-card">
       <template #header>
         <div class="card-header">
-          <span>点表配置-新增</span>
+          <span>点表配置-{{route.query['type']==1?'编辑':'新增'}}</span>
           <div>
-            <el-button type="warning" @click="">复位</el-button>
-            <el-button type="primary" @click="">保存</el-button>
+            <el-button type="warning" @click="initdata">复位</el-button>
+            <el-button type="primary" @click="savedata">保存</el-button>
             <el-button type="primary" plain @click="router.back();">返回</el-button>
           </div>
         </div>
@@ -24,17 +24,17 @@
 
                 </template>
                 <div class="content-w">
-                  <el-input placeholder="请输入"/>
+                  <el-input v-model="currentpoint.name" placeholder="请输入"/>
                 </div>
               </el-descriptions-item>
               <el-descriptions-item>
                 <template #label>
                   <div style="display: inline-block;min-width: 100px;text-align: right">
-                    <span style="color: red">*</span> 设备
+                    <span style="color: red">*</span> 传感器名称
                   </div>
                 </template>
                 <div class="content-w">
-                  XXX
+                  {{currentsensor?.name}}
                 </div>
               </el-descriptions-item>
 
@@ -45,7 +45,9 @@
                   </div>
                 </template>
                 <div class="content-w">
-                  <el-input placeholder="请输入"/>
+                  <el-select v-model="currentpoint.dataType" placeholder="请选择">
+                    <el-option v-for="item in data_type" :key="parseInt(item.value)" :label="item.label" :value="parseInt(item.value)"></el-option>
+                  </el-select>
                 </div>
               </el-descriptions-item>
               <el-descriptions-item >
@@ -55,7 +57,7 @@
                   </div>
                 </template>
                 <div class="content-w">
-                  <el-input placeholder="请输入"/>
+                  <el-input v-model="currentpoint.valueType" placeholder="请输入"/>
                 </div>
               </el-descriptions-item>
 
@@ -66,7 +68,7 @@
                   </div>
                 </template>
                 <div class="content-w">
-                  <el-input placeholder="请输入"/>
+                  <el-input v-model="currentpoint.addr" placeholder="请输入"/>
                 </div>
               </el-descriptions-item>
 
@@ -77,7 +79,7 @@
                   </div>
                 </template>
                 <div class="content-w">
-                  <el-input placeholder="请输入"/>
+                  <el-input v-model="currentpoint.addrOffset" placeholder="请输入"/>
                 </div>
               </el-descriptions-item>
 
@@ -88,7 +90,7 @@
                   </div>
                 </template>
                 <div class="content-w">
-                  <el-input placeholder="请输入"/>
+                  <el-input v-model="currentpoint.len" placeholder="请输入"/>
                 </div>
               </el-descriptions-item>
               <el-descriptions-item >
@@ -98,21 +100,12 @@
                   </div>
                 </template>
                 <div class="content-w">
-                  <el-input placeholder="请输入"/>
+                  <el-input v-model="currentpoint.slaveDeviceNumber" placeholder="请输入"/>
                 </div>
               </el-descriptions-item>
 
 
-              <el-descriptions-item :span="2">
-                <template #label>
-                  <div style="display: inline-block;min-width: 100px;text-align: right;    vertical-align: top;">
-                    描述
-                  </div>
-                </template>
-                <div class="content-w" style="min-width: 400px">
-                  <el-input type="textarea" :line-count="5"  show-word-limit maxlength="200" placeholder="请输入描述"/>
-                </div>
-              </el-descriptions-item>
+
               <el-descriptions-item :span="2">
                 <template #label>
                   <div style="display: inline-block;min-width: 100px;text-align: right;    vertical-align: top;">
@@ -120,7 +113,7 @@
                   </div>
                 </template>
                 <div class="content-w" style="min-width: 400px">
-                  <el-input type="textarea" :line-count="5"  show-word-limit maxlength="200" placeholder="请输入备注"/>
+                  <el-input type="textarea" :line-count="5" v-model="currentpoint.remark"  show-word-limit maxlength="200" placeholder="请输入备注"/>
                 </div>
               </el-descriptions-item>
             </el-descriptions>
@@ -138,17 +131,84 @@
   </div>
 </template>
 
-<script setup lang="ts" name="Units">
-import {ref} from "vue";
+<script setup  name="Units">
+import {onMounted, ref} from "vue";
 import {useRoute, useRouter} from "vue-router";
-import ModbusTcp from "@/views/data/modbusTcp/index.vue";
+import {addDatapoint,updateDatapoint} from "@/api/data/datapoint";
+import {ElMessage} from "element-plus";
+const {proxy} = getCurrentInstance();
+const {data_type} = proxy.useDict("data_type");
+
 
 
 const route = useRoute();
 const router = useRouter();
 
-const tjdata = ref([]);
-const zxdata = ref([]);
+const currentpoint = ref({
+  "name": "",
+  "sensorId": 0,
+  "dataType": 1,
+  "slaveDeviceNumber": null,
+  "addr": 0,
+  "addrOffset": 0,
+  "len": 0,
+  "valueType": "",
+  "remark": null,
+  "unitName": null,
+  "unitType": null,
+  "toOffset": 0
+});
+const initdata = ()=>{
+  currentpoint.value = {
+    "name": "",
+    "sensorId": currentsensor.value.id,
+    "dataType": 1,
+    "slaveDeviceNumber": null,
+    "addr": 0,
+    "addrOffset": 0,
+    "len": 0,
+    "valueType": "",
+    "remark": null,
+    "unitName": null,
+    "unitType": null,
+    "toOffset": 0
+  }
+}
+
+const currentsensor = ref();
+
+const savedata = ()=>{
+  if(route.query['type']==1){
+    updateDatapoint(currentpoint.value).then(res=>{
+      ElMessage.success("修改成功");
+      router.back();
+    })
+  }else{
+    addDatapoint(currentpoint.value).then(res=>{
+      ElMessage.success("添加成功");
+      router.back();
+    })
+  }
+}
+
+onMounted(()=>{
+  let data = localStorage.getItem("currentpoint");
+  if(route.query['type']==1 && ( data == null||data == undefined)){
+    router.back();
+    return;
+  }
+  currentpoint.value = JSON.parse(data);
+  let data1 = localStorage.getItem("currentsensor");
+  if(data1 == null||data1 == undefined){
+    router.back();
+    return;
+  }
+  currentsensor.value = JSON.parse(data1);
+  if(route.query['type']==0){
+    initdata();
+  }
+
+})
 
 
 </script>

+ 82 - 31
ruoyi-ui-vue3/src/views/gateway/pointsetting/index.vue

@@ -11,10 +11,10 @@
                   align-items: center;
                 "
           >
-            <div style="font-size: 12px; width: 80px">设备编码:</div>
+            <div style="font-size: 12px; width: 100px">传感器编码:</div>
             <el-input
-              v-model="searchform.protocolname"
-              placeholder="设备编码"
+              v-model="searchform.sn"
+              placeholder="传感器编码"
             ></el-input>
           </div>
 
@@ -27,16 +27,16 @@
                   margin-left: 10px;
                 "
           >
-            <div style="font-size: 12px; width: 80px">设备名称:</div>
+            <div style="font-size: 12px; width: 100px">传感器名称:</div>
             <el-input
-              v-model="searchform.protocolname"
-              placeholder="设备名称"
+              v-model="searchform.name"
+              placeholder="传感器名称"
             ></el-input>
           </div>
         </div>
         <div>
-          <el-button type="primary" plain>重置</el-button>
-          <el-button type="primary">搜索</el-button>
+          <el-button type="primary" plain @click="initdata">重置</el-button>
+          <el-button type="primary" @click="getalldata">搜索</el-button>
         </div>
       </div>
 
@@ -46,8 +46,8 @@
     <el-card class="box-card" style="margin-top: 15px">
       <template #header>
         <div class="card-header">
-          <span>点表管理</span>
-          <div>
+          <span>传感器列表</span>
+          <div style="display: none">
             <el-button type="primary" @click="goadd">添加</el-button>
             <el-button type="danger">批量删除</el-button>
             <el-button type="primary" plain>显示字段</el-button>
@@ -61,22 +61,23 @@
         <el-row>
           <el-col :span="24">
             <el-table :data="tabledata" border>
-              <el-table-column type="selection" width="55" />
-              <el-table-column label="设备编码"></el-table-column>
-              <el-table-column label="设备名称"></el-table-column>
-              <el-table-column label="备用编码"></el-table-column>
-              <el-table-column label="点表数"></el-table-column>
-              <el-table-column label="上层位置"></el-table-column>
-              <el-table-column label="设备型号"></el-table-column>
-              <el-table-column label="设备模板"></el-table-column>
-              <el-table-column label="所属类型"></el-table-column>
-              <el-table-column label="负责人"></el-table-column>
-              <el-table-column label="设备用途"></el-table-column>
-              <el-table-column label="安装日期"></el-table-column>
-              <el-table-column label="安装地点地址"></el-table-column>
-              <el-table-column label="经纬度"></el-table-column>
-              <el-table-column label="状态"></el-table-column>
-              <el-table-column label="操作" fixed="right" ></el-table-column>
+              <el-table-column v-for="item in cloumdata.filter(i=>i.visible)" :prop="item.prop" :label="item.label" ></el-table-column>
+              <el-table-column label="操作" fixed="right" >
+                <template #default="scope">
+                  <div>
+                    <el-button
+                      link @click="goadd(scope.row)"
+                    >
+                      <el-tooltip effect="dark" content="查看点表配置">
+                        <el-icon>
+                          <Memo />
+                        </el-icon>
+                      </el-tooltip>
+                    </el-button>
+                  </div>
+                </template>
+
+              </el-table-column>
 
             </el-table>
           </el-col>
@@ -85,7 +86,10 @@
                            small
                            background
                            layout="prev, pager, next"
-                           :total="50"
+                           :total="pagedata.total"
+                           :page-size="pagedata.size"
+                           :current-page="pagedata.current"
+                           @current-change="onchangepage"
                            class="mt-4"
             />
           </el-col>
@@ -99,23 +103,70 @@
   </div>
 </template>
 
-<script setup lang="ts" >
+<script setup  >
 import {ref} from "vue";
 import {useRoute, useRouter} from "vue-router";
+import { listSensor} from "@/api/data/sensor";
+const {proxy} = getCurrentInstance();
+const { protocal_type,sensor_type} = proxy.useDict( "protocal_type","sensor_type");
+
 
 
 const route = useRoute();
 const router = useRouter();
 
+
+const cloumdata = ref([
+  {label: '传感器编码', prop:'sn',visible:true},
+  {label: '传感器名称', prop:'name',visible:true},
+  {label: '类型', prop:'sensorType',visible:true},
+  {label: '协议', prop:'pname',visible:true},
+  {label: '描述', prop:'sensorDesc',visible:true},
+  {label: '备注', prop:'remark',visible:true},
+]);
+
 const searchform = ref({
-  protocolname: '',
+  name: '',
+  sn:''
 })
 
-const tabledata = ref([1])
-const goadd = ()=>{
+const pagedata = ref({
+  total:0,
+  size:10,
+  current:1
+});
+const initdata = ()=>{
+  searchform.value = {
+    protocolName: '',
+  }
+  pagedata.value = {
+    total:0,
+    size:10,
+    current:1
+  }
+}
+const onchangepage = (page) => {
+  pagedata.value.current = page;
+  getalldata();
+}
+const tabledata = ref([])
+const goadd = (item)=>{
+  localStorage.setItem("currentsensor",JSON.stringify(item));
   router.push("/gateway/pointsetting/setting");
 }
 
+const getalldata = () => {
+  listSensor({...searchform.value,pageSize:pagedata.value.size,pageNum:pagedata.value.current}).then(res => {
+    const {rows,total,page,size} = res;
+    pagedata.value = {total:total,current:page, size:10};
+    tabledata.value = rows.map(item=>{
+      item["pname"] = (protocal_type.value??[]).find(i=>i.value == item.protocalType).label;
+      return item;
+    });
+  })
+}
+getalldata()
+
 
 </script>
 

+ 131 - 21
ruoyi-ui-vue3/src/views/gateway/pointsetting/setting.vue

@@ -13,7 +13,7 @@
           >
             <div style="font-size: 12px; width: 80px">点名称:</div>
             <el-input
-              v-model="searchform.protocolname"
+              v-model="searchform.name"
               placeholder="点名称"
             ></el-input>
           </div>
@@ -21,8 +21,8 @@
 
         </div>
         <div>
-          <el-button type="primary" plain>重置</el-button>
-          <el-button type="primary">搜索</el-button>
+          <el-button type="primary" plain @click="initdata">重置</el-button>
+          <el-button type="primary" @click="getalldata">搜索</el-button>
           <el-button type="primary" plain @click="router.back()">返回</el-button>
         </div>
       </div>
@@ -33,13 +33,13 @@
     <el-card class="box-card" style="margin-top: 15px">
       <template #header>
         <div class="card-header">
-          <span>点表配置:xx设备</span>
+          <span>点表配置:{{currentsensor?.name}} 传感器</span>
           <div>
             <el-button type="primary" @click="goadd">添加</el-button>
-            <el-button type="primary" plain>导入</el-button>
-            <el-button type="primary" plain>导出</el-button>
-            <el-button type="danger">批量删除</el-button>
-            <el-button type="primary" plain>显示字段</el-button>
+<!--            <el-button type="primary" plain>导入</el-button>-->
+<!--            <el-button type="primary" plain>导出</el-button>-->
+            <el-button type="danger" @click="deleteall">批量删除</el-button>
+<!--            <el-button type="primary" plain>显示字段</el-button>-->
           </div>
         </div>
 
@@ -49,16 +49,35 @@
       <div>
         <el-row>
           <el-col :span="24">
-            <el-table :data="tabledata" border>
+            <el-table :data="tabledata" ref="tableref" border>
               <el-table-column type="selection" width="55" />
-              <el-table-column label="点名称"></el-table-column>
-              <el-table-column label="数据类型"></el-table-column>
-              <el-table-column label="从设备号"></el-table-column>
-              <el-table-column label="起始地址"></el-table-column>
-              <el-table-column label="起始地址偏移量"></el-table-column>
-              <el-table-column label="待读寄存器的个数"></el-table-column>
-              <el-table-column label="变量类型"></el-table-column>
-              <el-table-column label="操作" fixed="right" ></el-table-column>
+              <el-table-column v-for="item in cloumdata.filter(i=>i.visible)" :prop="item.prop" :label="item.label" ></el-table-column>
+              <el-table-column label="操作" fixed="right" >
+                <template #default="scope">
+                  <div>
+
+                    <el-button
+                      link  @click="editpoint(scope.row,2)"
+                    >
+                      <el-tooltip effect="dark" content="编辑">
+                        <el-icon>
+                          <Edit />
+                        </el-icon>
+                      </el-tooltip>
+                    </el-button>
+
+                    <el-popconfirm title="确定删除该点位?" @confirm="deleterow(scope.row)">
+                      <template #reference>
+                        <el-button link
+                        ><el-tooltip effect="dark" content="删除"
+                        ><el-icon><Delete /></el-icon></el-tooltip
+                        ></el-button>
+                      </template>
+                    </el-popconfirm>
+                  </div>
+                </template>
+
+              </el-table-column>
 
             </el-table>
           </el-col>
@@ -67,7 +86,10 @@
                            small
                            background
                            layout="prev, pager, next"
-                           :total="50"
+                           :total="pagedata.total"
+                           :page-size="pagedata.size"
+                           :current-page="pagedata.current"
+                           @current-change="onchangepage"
                            class="mt-4"
             />
           </el-col>
@@ -82,22 +104,110 @@
 </template>
 
 <script setup lang="ts" name="Units">
-import {ref} from "vue";
+import {onMounted, ref} from "vue";
 import {useRoute, useRouter} from "vue-router";
+import {listDatapoint,addDatapoint,delDatapoint,updateDatapoint} from "@/api/data/datapoint"
+import {ElMessage, ElMessageBox} from "element-plus";
 
 
 const route = useRoute();
 const router = useRouter();
 
 const searchform = ref({
-  protocolname: '',
+  name: '',
 })
+const initdata = ()=>{
+  searchform.value = {
+    name: '',
+  }
+}
+
+const cloumdata = ref([
+  {label: '点名称', prop:'name',visible:true},
+  {label: '数据类型', prop:'dataType',visible:true},
+  {label: '从设备号', prop:'slaveDeviceNumber',visible:true},
+  {label: '起始地址', prop:'addr',visible:true},
+  {label: '起始地址偏移量', prop:'addrOffset',visible:true},
+  {label: '待读寄存器的个数', prop:'len',visible:true},
+  {label: '变量类型', prop:'valueType',visible:true},
+]);
+
+const tableref = ref(null);
 
 const tabledata = ref([1])
 const goadd = ()=>{
-  router.push("/gateway/pointsetting/add");
+  router.push("/gateway/pointsetting/add?type=0");
+}
+
+const pagedata = ref({
+  total:0,
+  size:10,
+  current:1
+});
+const onchangepage = (page) => {
+  pagedata.value.current = page;
+  getalldata();
 }
+const currentsensor = ref(null)
+
+const getalldata = ()=>{
+  listDatapoint({...searchform.value,pageSize:pagedata.value.size,pageNum:pagedata.value.current,sensorId:currentsensor.value.id}).then(res => {
+    const {rows,total,page,size} = res;
+    pagedata.value = {total:total,current:page, size:10};
+    tabledata.value = rows
+  })
+
+}
+
 
+const editpoint =(item)=>{
+  localStorage.setItem("currentpoint",JSON.stringify(item));
+  router.push("/gateway/pointsetting/add?type=1");
+}
+const deleterow =(item)=>{
+  delDatapoint(item.id).then((res)=>{
+    ElMessage.success("删除成功");
+    getalldata();
+  })
+}
+
+const deleteall = ()=>{
+  let selected =  tableref.value.getSelectionRows();
+  if(selected.length==0) {
+    ElMessage.warning("请选择要删除的行");
+    return;
+  }
+
+  if (selected.length > 0) {
+    ElMessageBox.confirm(
+      `是否删除${selected.length}条数据`,
+      "警告",
+      {
+        confirmButtonText: "确认",
+        cancelButtonText: "取消",
+        type: 'warning',
+      }
+    ).then(() => {
+
+      delDatapoint(selected.map(i => i.id).join(",")).then((res) => {
+        ElMessage.success("删除成功");
+        getalldata();
+      })
+
+    });
+  }
+
+}
+
+
+onMounted(()=>{
+  let data = localStorage.getItem("currentsensor");
+  if(data == null||data == undefined){
+    router.back()
+  }
+  currentsensor.value = JSON.parse(data);
+  getalldata();
+})
 
 </script>