Explorar el Código

Merge remote-tracking branch 'origin/master'

xu hace 3 meses
padre
commit
4ccf043a24
Se han modificado 3 ficheros con 236 adiciones y 75 borrados
  1. 1 1
      server/config.yaml
  2. 1 1
      server/service/parking/booth.go
  3. 234 73
      web/src/view/parking/parkingInfo.vue

+ 1 - 1
server/config.yaml

@@ -125,7 +125,7 @@ mysql:
     config: charset=utf8mb4&parseTime=True&loc=Local
     config: charset=utf8mb4&parseTime=True&loc=Local
     db-name: lc_garage
     db-name: lc_garage
     username: root
     username: root
-    password: root
+    password: 123456
     path: 127.0.0.1
     path: 127.0.0.1
     engine: ""
     engine: ""
     log-mode: error
     log-mode: error

+ 1 - 1
server/service/parking/booth.go

@@ -109,7 +109,7 @@ func (s *boothService) ListBooths(req request.BoothQuery) (int64, []dao.Booth, e
 		query = query.Where("booth_name LIKE ?", "%"+req.BoothName+"%")
 		query = query.Where("booth_name LIKE ?", "%"+req.BoothName+"%")
 	}
 	}
 
 
-	if req.BoothName != "" {
+	if req.ParkingLotID != 0 {
 		query = query.Where("parking_lot_id = ?", req.ParkingLotID)
 		query = query.Where("parking_lot_id = ?", req.ParkingLotID)
 	}
 	}
 
 

+ 234 - 73
web/src/view/parking/parkingInfo.vue

@@ -200,14 +200,23 @@
               label="进出方向"
               label="进出方向"
               align="center"
               align="center"
               width="150"
               width="150"
-              prop="direction"
-            />
+              #default="scope"
+            >
+              {{scope.row.direction === 'in' ? '进' : '出'}}
+            </el-table-column>
             <el-table-column
             <el-table-column
               label="是否允许临时车进出"
               label="是否允许临时车进出"
               align="center"
               align="center"
               width="200"
               width="200"
-              prop="allow_temporary"
-            />
+            >
+              <template #default="scope">
+                <el-button
+                    plain
+                    :type="scope.row.allow_temporary ? 'success' : 'danger'">
+                  {{scope.row.allow_temporary ? '允许' : '不允许'}}
+                </el-button>
+              </template>
+            </el-table-column>
             <el-table-column
             <el-table-column
               label="备注"
               label="备注"
               align="center"
               align="center"
@@ -254,7 +263,7 @@
                 icon="Plus"
                 icon="Plus"
                 text
                 text
                 type="success"
                 type="success"
-                @click="deviceTypeShow = true"
+                @click="openDevice('新增设备','')"
               >新增</el-button>
               >新增</el-button>
             </el-form-item>
             </el-form-item>
             <el-form-item>
             <el-form-item>
@@ -312,12 +321,19 @@
               label="端口"
               label="端口"
               align="center"
               align="center"
               width="150"
               width="150"
+              prop="port"
             />
             />
             <el-table-column
             <el-table-column
-              label="在线状态"
+              label="是否启用"
               align="center"
               align="center"
               width="150"
               width="150"
-            />
+            >
+              <template #default="scope">
+                <el-button :type="scope.row.is_active ? 'success' : 'danger'" plain>
+                  {{scope.row.is_active ? '启用' : '不启用'}}
+                </el-button>
+              </template>
+            </el-table-column>
             <el-table-column
             <el-table-column
               label="操作"
               label="操作"
               align="center"
               align="center"
@@ -332,6 +348,7 @@
                   type="primary"
                   type="primary"
                   icon="edit"
                   icon="edit"
                   text
                   text
+                  @click="openDevice('编辑设备', scope.row)"
                 >编辑</el-button>
                 >编辑</el-button>
                 <el-button
                 <el-button
                   type="primary"
                   type="primary"
@@ -351,7 +368,7 @@
     >
     >
       <el-form label-width="90">
       <el-form label-width="90">
         <el-form-item label="停车区域:">
         <el-form-item label="停车区域:">
-          <el-select v-model="positionRegionName" placeholder="请选择停车区域">
+          <el-select v-model="positionRegionName" placeholder="请选择停车区域" @change="changePositionRegion">
             <el-option v-for="item in regionList" :value="item.lot_name" :key="item.ID"></el-option>
             <el-option v-for="item in regionList" :value="item.lot_name" :key="item.ID"></el-option>
           </el-select>
           </el-select>
         </el-form-item>
         </el-form-item>
@@ -389,6 +406,16 @@
       width="500"
       width="500"
     >
     >
       <el-form>
       <el-form>
+        <el-form-item label="通道岗亭:">
+          <el-select v-model="channelPositionName" @change="changeChannelPosition">
+            <el-option
+                v-for="item in positionList"
+                :key="item.ID"
+                :value="item.booth_name"
+                :label="item.booth_name">
+            </el-option>
+          </el-select>
+        </el-form-item>
         <el-form-item label="通道编码:">
         <el-form-item label="通道编码:">
           <el-input v-model="channelData.channel_code" />
           <el-input v-model="channelData.channel_code" />
         </el-form-item>
         </el-form-item>
@@ -403,11 +430,11 @@
           >
           >
             <el-radio-button
             <el-radio-button
               label="进"
               label="进"
-              :value="false"
+              value="in"
             />
             />
             <el-radio-button
             <el-radio-button
               label="出"
               label="出"
-              :value="true"
+              value="out"
             />
             />
           </el-radio-group>
           </el-radio-group>
         </el-form-item>
         </el-form-item>
@@ -448,19 +475,60 @@
     </el-dialog>
     </el-dialog>
     <el-dialog
     <el-dialog
       v-model="deviceShow"
       v-model="deviceShow"
-      title="设备添加"
+      :title="deviceTitle"
       width="500"
       width="500"
     >
     >
-      <el-form label-width="80">
+      <el-form label-width="100">
+        <el-form-item label="设备通道:">
+          <el-select v-model="deviceChannelName" @change="changeDeviceChannel">
+            <el-option
+                v-for="item in channelList"
+                :key="item.ID"
+                :value="item.channel_name"
+                :label="item.channel_name">
+            </el-option>
+          </el-select>
+        </el-form-item>
         <el-form-item label="IP地址:">
         <el-form-item label="IP地址:">
           <el-input v-model="deviceData.ip_address" />
           <el-input v-model="deviceData.ip_address" />
         </el-form-item>
         </el-form-item>
-        <el-form-item label="名称:">
+        <el-form-item label="设备名称:">
           <el-input v-model="deviceData.device_name" />
           <el-input v-model="deviceData.device_name" />
         </el-form-item>
         </el-form-item>
-        <el-form-item label="编码:">
+        <el-form-item label="设备编码:">
           <el-input v-model="deviceData.device_code" />
           <el-input v-model="deviceData.device_code" />
         </el-form-item>
         </el-form-item>
+        <el-form-item label="连接方式:">
+          <el-select v-model="deviceData.connect_type">
+            <el-option label="tcp" value="tcp"></el-option>
+            <el-option label="serial" value="serial"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="端口:">
+          <el-input v-model="deviceData.port" type="number"></el-input>
+        </el-form-item>
+        <el-form-item label="串口名称:">
+          <el-input v-model="deviceData.com_port"></el-input>
+        </el-form-item>
+        <el-form-item label="串口波特率:">
+          <el-input v-model="deviceData.baud_rate" type="number"></el-input>
+        </el-form-item>
+        <el-form-item label="是否启用:">
+          <el-radio-group
+              v-model="deviceData.is_active"
+              size="large"
+              fill="#409eff"
+          >
+            <el-radio-button
+                label="否"
+                :value="false"
+            />
+            <el-radio-button
+                label="是"
+                :value="true"
+            />
+          </el-radio-group>
+        </el-form-item>
         <el-form-item label="备注:">
         <el-form-item label="备注:">
           <el-input
           <el-input
             v-model="deviceData.description"
             v-model="deviceData.description"
@@ -473,44 +541,13 @@
           <el-button @click="deviceShow = false">取消</el-button>
           <el-button @click="deviceShow = false">取消</el-button>
           <el-button
           <el-button
             type="primary"
             type="primary"
-            @click="deviceVlprAdd"
+            @click="deviceOperation"
           >
           >
             确认
             确认
           </el-button>
           </el-button>
         </div>
         </div>
       </template>
       </template>
     </el-dialog>
     </el-dialog>
-    <el-dialog
-      v-model="deviceTypeShow"
-      title="设备类型"
-      width="500"
-    >
-      <el-select
-        v-model="deviceData.device_type"
-        placeholder="请选择设备类型"
-        style="width: 240px"
-      >
-        <el-option
-          label="VLPR"
-          value="VLPR"
-        />
-        <el-option
-          label="ASeries"
-          value="ASeries"
-        />
-        <el-option
-          label="ASeries-G"
-          value="ASeries-G"
-        />
-      </el-select>
-      <template #footer>
-        <el-button @click="deviceTypeShow = false">取消</el-button>
-        <el-button
-          type="primary"
-          @click="confirmType"
-        >确定</el-button>
-      </template>
-    </el-dialog>
     <el-dialog v-model="regionShow" :title="regionTitle" width="500">
     <el-dialog v-model="regionShow" :title="regionTitle" width="500">
       <el-form label-width="90">
       <el-form label-width="90">
         <el-form-item label="区域编码:">
         <el-form-item label="区域编码:">
@@ -559,7 +596,7 @@ import {
   obtainChannelList,
   obtainChannelList,
   deleteChannel
   deleteChannel
 } from '@/api/channel'
 } from '@/api/channel'
-import { addDevice, obtainDeviceList } from '@/api/device'
+import { addDevice, obtainDeviceList, editDevice } from '@/api/device'
 import { addPullOver, editPullOver, obtainPullOverList, removePullOver } from '@/api/pullOver'
 import { addPullOver, editPullOver, obtainPullOverList, removePullOver } from '@/api/pullOver'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import { ElMessage, ElMessageBox } from 'element-plus'
 
 
@@ -572,7 +609,7 @@ const positionTitle = ref('岗亭新增')
 // 岗亭数据.......................................
 // 岗亭数据.......................................
 const positionRegionName = ref('')
 const positionRegionName = ref('')
 const positionData = reactive({
 const positionData = reactive({
-  id: '',
+  id: 0,
   booth_code: '',
   booth_code: '',
   booth_name: '',
   booth_name: '',
   ip_address: '',
   ip_address: '',
@@ -584,7 +621,14 @@ const guardTotal = ref(0)
 const positionList = reactive([])
 const positionList = reactive([])
 const addPosition = () => {
 const addPosition = () => {
   if (positionTitle.value === '岗亭新增') {
   if (positionTitle.value === '岗亭新增') {
-
+    if (positionData.parking_lot_id === 0) {
+      ElMessage.error('请选择停车区域')
+      return
+    }
+    if(positionData.booth_name === '' || positionData.booth_code === '' || positionData.ip_address === '') {
+      ElMessage.error('请将除备注以外的信息填写完整')
+      return
+    }
     addGuardBooth(positionData).then(res => {
     addGuardBooth(positionData).then(res => {
       if (res.code === 0) {
       if (res.code === 0) {
         ElMessage.success('添加成功')
         ElMessage.success('添加成功')
@@ -593,6 +637,14 @@ const addPosition = () => {
       }
       }
     })
     })
   } else {
   } else {
+    if (positionData.parking_lot_id === 0) {
+      ElMessage.error('请选择停车区域')
+      return
+    }
+    if(positionData.booth_name === '' || positionData.booth_code === '' || positionData.ip_address === '') {
+      ElMessage.error('请将除备注以外的信息填写完整')
+      return
+    }
     editGuardBooth(positionData).then(res => {
     editGuardBooth(positionData).then(res => {
       if (res.code === 0) {
       if (res.code === 0) {
         ElMessage.success('更新成功')
         ElMessage.success('更新成功')
@@ -603,6 +655,14 @@ const addPosition = () => {
   }
   }
 }
 }
 
 
+const changePositionRegion = (val) => {
+  regionList.forEach(item => {
+    if (item.lot_name === val) {
+      positionData.parking_lot_id = item.ID
+    }
+  })
+}
+
 const openPosition = (head, data) => {
 const openPosition = (head, data) => {
   positionTitle.value = head
   positionTitle.value = head
   positionShow.value = true
   positionShow.value = true
@@ -612,11 +672,19 @@ const openPosition = (head, data) => {
     positionData.booth_name = data.booth_name
     positionData.booth_name = data.booth_name
     positionData.ip_address = data.ip_address
     positionData.ip_address = data.ip_address
     positionData.description = data.description
     positionData.description = data.description
+    positionData.parking_lot_id = data.parking_lot_id
+    regionList.forEach(item => {
+      if (item.ID === data.parking_lot_id) {
+        positionRegionName.value = item.lot_name
+      }
+    })
   } else {
   } else {
     positionData.ip_address = ''
     positionData.ip_address = ''
     positionData.description = ''
     positionData.description = ''
     positionData.booth_code = ''
     positionData.booth_code = ''
     positionData.booth_name = ''
     positionData.booth_name = ''
+    positionData.parking_lot_id = 0
+    positionRegionName.value = ''
   }
   }
 }
 }
 const searchGuardBooth = reactive({
 const searchGuardBooth = reactive({
@@ -682,6 +750,7 @@ const delPosition = (id) => {
 // 通道管理...................................................
 // 通道管理...................................................
 // 通道数据
 // 通道数据
 const channelShow = ref(false)
 const channelShow = ref(false)
+const deviceTitle = ref('')
 const queryChannelData = reactive({
 const queryChannelData = reactive({
   parking_lot_id: 0,
   parking_lot_id: 0,
   channel_code: '',
   channel_code: '',
@@ -691,19 +760,29 @@ const queryChannelData = reactive({
   page_size: 10,
   page_size: 10,
   allow_temporary: false
   allow_temporary: false
 })
 })
-
+const channelPositionName = ref('')
 const channelData = reactive({
 const channelData = reactive({
+  id:0,
   channel_code: '',
   channel_code: '',
   channel_name: '',
   channel_name: '',
-  direction: false,
-  allow_temporary: '',
-  description: false
+  direction: 'in',
+  allow_temporary: false,
+  description: '',
+  booth_id: 0,
 })
 })
 
 
 const channelTitle = ref('通道新增')
 const channelTitle = ref('通道新增')
 
 
 const channelList = reactive([])
 const channelList = reactive([])
 
 
+const changeChannelPosition = (val) => {
+  positionList.forEach(item => {
+    if(item.booth_name === val) {
+      channelData.booth_id = item.ID
+    }
+  })
+}
+
 const openChannel = (head, data) => {
 const openChannel = (head, data) => {
   channelTitle.value = head
   channelTitle.value = head
   channelShow.value = true
   channelShow.value = true
@@ -714,17 +793,34 @@ const openChannel = (head, data) => {
     channelData.allow_temporary = data.allow_temporary
     channelData.allow_temporary = data.allow_temporary
     channelData.direction = data.direction
     channelData.direction = data.direction
     channelData.description = data.description
     channelData.description = data.description
+    channelData.booth_id = data.booth_id
+    channelList.forEach(item => {
+      if (item.ID === data.booth_id) {
+        channelPositionName.value = item.booth_name
+      }
+    })
   } else {
   } else {
     channelData.channel_code = ''
     channelData.channel_code = ''
     channelData.channel_name = ''
     channelData.channel_name = ''
     channelData.allow_temporary = false
     channelData.allow_temporary = false
-    channelData.direction = ''
+    channelData.direction = 'in'
     channelData.description = ''
     channelData.description = ''
+    channelData.booth_id = 0
+    channelPositionName.value = ''
   }
   }
 }
 }
 const channelOperation = () => {
 const channelOperation = () => {
   if (channelTitle.value === '通道新增') {
   if (channelTitle.value === '通道新增') {
+    if (channelData.booth_id === 0) {
+      ElMessage.error('请选择岗亭')
+      return
+    }
+    if(channelData.channel_name === '' ||  channelData.channel_code === '') {
+      ElMessage.error('请将除备注以外的信息填写完整')
+      return
+    }
     addChannel(channelData).then(res => {
     addChannel(channelData).then(res => {
+      console.log('添加通道操作', res.data)
       if (res.code === 0) {
       if (res.code === 0) {
         ElMessage.success('添加成功')
         ElMessage.success('添加成功')
         channelShow.value = false
         channelShow.value = false
@@ -732,6 +828,14 @@ const channelOperation = () => {
       }
       }
     })
     })
   } else {
   } else {
+    if (channelData.booth_id === 0) {
+      ElMessage.error('请选择岗亭')
+      return
+    }
+    if(channelData.channel_name === '' ||  channelData.channel_code === '') {
+      ElMessage.error('请将除备注以外的信息填写完整')
+      return
+    }
     editChannel(channelData).then(res => {
     editChannel(channelData).then(res => {
       if (res.code === 0) {
       if (res.code === 0) {
         ElMessage.success('更新成功')
         ElMessage.success('更新成功')
@@ -765,48 +869,105 @@ const deviceData = reactive({
   parking_lot_id: 0,
   parking_lot_id: 0,
   device_code: '',
   device_code: '',
   device_name: '',
   device_name: '',
-  device_type: 'VLPR',
+  baud_rate:0,
   ip_address: '',
   ip_address: '',
   port: 0,
   port: 0,
-  description: ''
+  com_port: '',
+  description: '',
+  connect_type:'',
+  is_active: false,
+  channel_id: 0
 })
 })
 
 
+const deviceChannelName = ref('')
+
 const deviceShow = ref(false)
 const deviceShow = ref(false)
 
 
-const deviceVlprAdd = async() => {
-  await addDevice(deviceData).then(res => {
-    if (res.code === 0) {
-      ElMessage.success('添加成功')
-      deviceShow.value = false
-      deviceTypeShow.value = false
-      getDeviceList()
-    } else {
-      ElMessage.error('添加失败')
-    }
-  })
+const openDevice = (head,data) => {
+  deviceTitle.value = head
+  deviceShow.value = true
+  if (head === '编辑设备') {
+    console.log('编辑信息', data)
+    deviceData.device_code = data.device_code
+    deviceData.device_name = data.device_name
+    deviceData.baud_rate = data.baud_rate
+    deviceData.ip_address = data.ip_address
+    deviceData.port = data.port
+    deviceData.com_port = data.com_port
+    deviceData.description = data.description
+    deviceData.connect_type = data.connect_type
+    deviceData.channel_id = data.channel_id
+    deviceData.is_active = data.is_active
+    channelList.forEach(item => {
+      if (item.ID === data.id) {
+        deviceChannelName.value = item.channel_name
+      }
+    })
+  } else {
+    deviceData.device_code = ''
+    deviceData.device_name = ''
+    deviceData.baud_rate = 0
+    deviceData.ip_address = ''
+    deviceData.port = 0
+    deviceData.com_port = ''
+    deviceData.description = ''
+    deviceData.connect_type = ''
+    deviceData.channel_id = 0
+    deviceData.is_active = false
+    deviceChannelName.value = ''
+  }
 }
 }
 
 
-const deviceTypeShow = ref(false)
+const deviceOperation = async() => {
+  deviceData.baud_rate = Number(deviceData.baud_rate)
+  deviceData.port = Number(deviceData.port)
+  if (deviceTitle.value === '新增设备'){
+    await addDevice(deviceData).then(res => {
+      if (res.code === 0) {
+        ElMessage.success('添加成功')
+        deviceShow.value = false
+        getDeviceList()
+      } else {
+        ElMessage.error(res.data.msg)
+      }
+    })
+  } else {
+    await editDevice(deviceData).then(res => {
+      if (res.code === 0) {
+        ElMessage.success('编辑成功')
+        deviceShow.value = false
+        getDeviceList()
+      } else {
+        ElMessage.error('编辑失败')
+      }
+    })
+  }
+}
 
 
 const deviceList = reactive([])
 const deviceList = reactive([])
 
 
-const confirmType = () => {
-  if (deviceData.device_type === 'VLPR') {
-    deviceShow.value = true
-  }
+const changeDeviceChannel = (val) => {
+  channelList.forEach(item => {
+    if (item.channel_name === val) {
+      deviceData.channel_id = item.ID
+    }
+  })
 }
 }
 
 
+
 const searchDeviceData = reactive({
 const searchDeviceData = reactive({
   parking_lot_id: 0,
   parking_lot_id: 0,
   device_code: '',
   device_code: '',
+  device_type: '',
   device_name: '',
   device_name: '',
-  status: false,
+  status: '',
   page: 1,
   page: 1,
   page_size: 10
   page_size: 10
 })
 })
 const getDeviceList = async() => {
 const getDeviceList = async() => {
   await obtainDeviceList(searchDeviceData).then(res => {
   await obtainDeviceList(searchDeviceData).then(res => {
     if (res.code === 0) {
     if (res.code === 0) {
+      console.log(res.data)
       deviceList.length = 0
       deviceList.length = 0
       if (res.data.list !== null) {
       if (res.data.list !== null) {
         deviceList.push(...res.data.list)
         deviceList.push(...res.data.list)