doum
2026-03-10 759ccbfc701c60800da901d8b5822b3528a5b002
更改头部
已添加2个文件
已修改16个文件
666 ■■■■■ 文件已修改
admin/.env.development 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/api/business/device.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/components/business/OperaDeviceDataListWindow.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/components/business/OperaDeviceDianbiaoWindow.vue 147 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/components/business/OperaDeviceDuanluqiWindow.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/components/business/OperaDianbiaoDataListWindow.vue 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/views/business/admissionStatistics.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/views/business/carStatistics.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/views/business/deviceDianbiao.vue 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/system_gateway/src/main/resources/application-self.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/system_gateway/src/main/resources/bootstrap-dev.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/system_service/src/main/java/com/doumee/core/utils/Constants.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/device_service/src/main/java/com/doumee/tcp/WaterElectricityUtil.java 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/DeviceCloudController.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/DeviceData.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/.env.development
@@ -3,7 +3,7 @@
VUE_APP_SCREEN_URL_PREFIX  = 'http://192.168.0.7/screen/#/'
#VUE_APP_API_URL  = 'http://localhost:10010'
VUE_APP_API_URL  = 'http://192.168.0.7/system_gateway'
VUE_APP_API_URL  = 'http://localhost:10010'
#VUE_APP_API_URL  = 'http://192.168.0.7/system_gateway'
VUE_APP_AMAP_KEY='045542fc5f436b75e6c911c5c84ff8cd'
admin/src/api/business/device.js
@@ -31,6 +31,9 @@
export function create (data) {
  return request.post('/visitsAdmin/cloudService/business/device/create', data)
}
export function dianbiaoData(data) {
  return request.post('/visitsAdmin/cloudService/business/device/dianbiaoData', data)
}
// ä¿®æ”¹æ˜¯å¦é—¨ç¦å…¥å£
export function updateEntranceById (data) {
@@ -42,6 +45,9 @@
export function duanluqiCmd (data) {
  return request.post('/visitsAdmin/cloudService/business/device/duanluqiCmd', data)
}
export function dianbaoCmd (data) {
  return request.post('/visitsAdmin/cloudService/business/device/dianbaoCmd', data)
}
// å‘生led屏内容
export function setLedContent (data) {
  return request.post('/visitsAdmin/cloudService/business/hksync/setLedContent', data)
admin/src/components/business/OperaDeviceDataListWindow.vue
@@ -17,8 +17,8 @@
            <div style="flex: 1"><span  class="label">控制开关:</span>{{model.channelInfo ||'-'}}</div>
          </div>
          <div style="display: flex;margin-top: 20px;">
            <div style="flex: 1"><span  class="label">MQTT IP:</span>{{model.doorNameObj.mqttIp ||''}}</div>
            <div style="flex: 1"><span  class="label">MQTT端口:</span>{{model.doorNameObj.mqttPort||''}}</div>
            <div style="flex: 1"><span  class="label">MQTT IP:</span>{{model.doorNameObj?(model.doorNameObj.mqttIp ||''):''}}</div>
            <div style="flex: 1"><span  class="label">MQTT端口:</span>{{model.doorNameObj?(model.doorNameObj.mqttPort ||''):''}}</div>
            <div style="flex: 3">
              <span class="label">最近控制操作:</span>
              <span class="orange" >{{model.remark||''}}</span>
@@ -108,7 +108,7 @@
      visible: false,
      title: '',
      activeGroup:0,
      model:{},
      model:{doorNameObj:{}},
      groupList: [{ id: 0, name: '数据上报记录', type: 0 }, { id: 1, name: '远程控制记录', type: 1 }],
      searchForm: {
        deviceId:  null,
admin/src/components/business/OperaDeviceDianbiaoWindow.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,147 @@
<template>
    <GlobalWindow
        :title="title"
        :visible.sync="visible"
        width="65%"
        :confirm-working="isWorking"
        @confirm="confirm"
    >
        <el-form :model="form" ref="form" :rules="rules">
          <p class="tip-header" >基本信息</p>
          <el-form-item label="设备名称" prop="name">
            <el-input v-model="form.name" placeholder="请输入名称" v-trim/>
          </el-form-item>
          <el-form-item label="设备地址域" prop="no">
            <el-input v-model="form.no" placeholder="请输入设备标识符" v-trim/>
          </el-form-item>
          <el-form-item label="设备号" prop="doorNo">
            <el-input v-model="form.doorNo" placeholder="请输入序列号" v-trim/>
          </el-form-item>
          <el-form-item label="厂商" prop="manufature">
            <el-input v-model="form.manufature" placeholder="请输入厂商" v-trim/>
          </el-form-item>
          <el-form-item label="安装位置" prop="regionPathName">
            <el-input v-model="form.regionPathName" placeholder="请输入设备位置" v-trim/>
          </el-form-item>
          <el-form-item label="连接IP" prop="ip">
            <el-input v-model="form.ip" placeholder="请输入设备连接IP地址" v-trim/>
          </el-form-item>
          <el-form-item label="连接端口" prop="port">
            <el-input v-model="form.port" placeholder="请输入连接端口" v-trim/>
          </el-form-item>
          <el-form-item label="电流比" prop="channelNo">
            <el-input v-model="form.channelNo" type="number" placeholder="请输入电流比" v-trim>
              <template slot="append">/5A</template>
            </el-input>
          </el-form-item>
          <el-form-item label="密码等级" prop="pwdLevel">
            <el-input v-model="form.doorNameObj.pwdLevel" placeholder="请输入密码等级" v-trim/>
          </el-form-item>
          <el-form-item label="密码" prop="pwd">
            <el-input v-model="form.doorNameObj.pwd" placeholder="请输入连接密码" v-trim/>
          </el-form-item>
          <el-form-item label="操作者代码" prop="userCode">
            <el-input v-model="form.doorNameObj.userCode" placeholder="请输入设备操作者代码" v-trim/>
          </el-form-item>
        </el-form>
    </GlobalWindow>
</template>
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
export default {
  name: 'OperaDeviceDuanluqiWindow',
  extends: BaseOpera,
  components: { GlobalWindow },
  data () {
    return {
      // è¡¨å•数据
      form: {
        id: null,
        name: '',
        regionPathName: '',
        doorNo: '',
        no: '',
        type: 6,
        ip: '',
        port: '',
        level: '',
        doorName: '',
        doorId: '',
        doorNameObj: {
          pwdLevel: '',
          pwd: '',
          userCode: ''
        },
        channelInfo: '',
        manufature: '',
        channelNo: ''
      },
      // éªŒè¯è§„则
      rules: {
        name: [
          { required: true, message: '请输入设备名称' }
        ],
        doorName: [
          { required: true, message: '请输入设备连接密码' }
        ],
        channelNo: [
          { required: true, message: '请输入开关序号' }
        ],
        doorNo: [
          { required: true, message: '请输入设备号' }
        ],
        no: [
          { required: true, message: '请输入设备标识符' }
        ]
      }
    }
  },
  created () {
    this.config({
      api: '/business/device',
      'field.id': 'id'
    })
  },
  methods: {
    open (title, target) {
      this.title = title
      this.visible = true
      this.form.doorName = ''
      this.form.doorNameObj = {
        userCode: '',
        pwd: '',
        pwdLevel: ''
      }
      // debugger
      // æ–°å»º
      if (target == null) {
        this.$nextTick(() => {
          this.$refs.form.resetFields()
          this.form[this.configData['field.id']] = null
        })
        if(!this.form.doorNameObj){
          this.form.doorNameObj = {
            pwdLevel: '',
            pwd: '',
            userCode: ''
          }
        }
        return
      }
      // ç¼–辑
      this.$nextTick(async () => {
        if(!target.doorNameObj){
          target.doorNameObj={
            pwdLevel: '',
            pwd: '',
            userCode: ''}
        }
        for (const key in this.form) {
          this.form[key] = target[key]
        }
      })
    }
  }
}
</script>
admin/src/components/business/OperaDeviceDuanluqiWindow.vue
@@ -18,7 +18,7 @@
            <el-input v-model="form.doorNo" placeholder="请输入序列号" v-trim/>
          </el-form-item>
          <el-form-item label="厂商" prop="manufature">
            <el-input v-model="form.manufature" placeholder="请输入所在位置" v-trim/>
            <el-input v-model="form.manufature" placeholder="请输入厂商" v-trim/>
          </el-form-item>
          <el-form-item label="安装位置" prop="regionPathName">
            <el-input v-model="form.regionPathName" placeholder="请输入设备位置" v-trim/>
admin/src/components/business/OperaDianbiaoDataListWindow.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,179 @@
<template>
  <GlobalWindow
      :title="title"
      width="100%"
      :visible.sync="visible"
  >
    <TableLayout >
      <!-- æœç´¢è¡¨å• -->
      <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
        <div  style="display: block;margin-bottom: 60px;padding: 20px; border: 1px solid #f2f2f2;">
          <div style="display: block;font-size: 16px;font-weight: 600;margin-bottom: 20px;">设备信息</div>
          <div style="display: flex;">
            <div style="flex: 1"><span class="label">名称:</span>{{model.name ||''}}</div>
            <div style="flex: 1"><span  class="label">地址域:</span>{{model.no ||''}}</div>
            <div style="flex: 1"><span  class="label">设备号:</span>{{model.doorNo ||'-'}}</div>
          </div>
          <div style="display: flex;margin-top: 20px;">
            <div style="flex: 1"><span  class="label">IP:</span>{{ model.ip ||'' }}</div>
            <div style="flex: 1"><span  class="label">端口:</span>{{ model.port ||''}}</div>
            <div style="flex: 3">
              <span class="label">最近控制操作:</span>
              <span class="orange" >{{model.remark||''}}</span>
            </div>
          </div>
        </div>
        <div class="platgroup_tabs">
          <div class="tab" :class="{ active: activeGroup === item.id }" @click="groupClick(item)"
               v-for="(item, i) in groupList" :key="i">
            {{ item.name }}
          </div>
        </div>
      </el-form>
      <!-- è¡¨æ ¼å’Œåˆ†é¡µ -->
      <template  v-slot:table-wrap>
        <el-table
            v-if="activeGroup===0"
            :height="tableHeightNew"
            v-loading="isWorking.search"
            :data="tableData.list"
            stripe>
          <el-table-column prop="happenTime" label="读取时间" min-width="150px"></el-table-column>
          <el-table-column prop="val1" label="电能(KWH)" min-width="120px"></el-table-column>
          <el-table-column prop="val2" label="状态" min-width="120px">
            <template slot-scope="{row}">
              <span v-if=" row.val2 === '0000'" class="green">合闸</span>
              <span  v-else-if=" row.val2 === '0050'" class="red">分闸</span>
              <span v-else>-</span>
            </template>
          </el-table-column>
          <el-table-column prop="val3" label="电表时间" min-width="120px"></el-table-column>
        </el-table>
        <el-table
            v-if="activeGroup===1"
            :height="tableHeightNew"
            v-loading="isWorking.search"
            :data="tableData.list"
            stripe>
          <el-table-column prop="createDate" label="操作时间" min-width="150px"></el-table-column>
          <el-table-column prop="val4" label="操作人" min-width="100px" ></el-table-column>
          <el-table-column prop="val3" label="操作内容" min-width="100px">
            <template slot-scope="{row}">
                <span v-if=" row.val3 === '【合闸】'" class="green">{{row.val3||''}}</span>
                <span  v-else-if=" row.val3 === '【分闸】'" class="red">{{row.val3||''}}</span>
                <span v-else>{{row.val3||''}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="val2" label="内容" min-width="300px" show-overflow-tooltip></el-table-column>
        </el-table>
        <pagination
            @size-change="handleSizeChange"
            @current-change="handlePageChange"
            :pagination="tableData.pagination"
        >
        </pagination>
      </template>
    </TableLayout>
    <template   v-slot:footer>
      <el-button @click="visible=false">返回</el-button>
    </template>
  </GlobalWindow>
</template>
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import GlobalWindow from '@/components/common/GlobalWindow'
export default {
  name: 'OperaJkSketchCustomerWindow',
  extends: BaseTable,
  components: { GlobalWindow, TableLayout, Pagination },
  data () {
    return {
      // è¡¨å•数据
      visible: false,
      title: '',
      activeGroup:0,
      model:{doorNameObj:{}},
      groupList: [{ id: 0, name: '数据上报记录', type: 0 }, { id: 1, name: '远程控制记录', type: 1 }],
      searchForm: {
        deviceId:  null,
        val1: '',
        dataType:0
      }
    }
  },
  created () {
    this.config({
      module: '设备数据信息表',
      api: '/business/deviceData',
      'field.id': 'id',
      'field.main': 'id'
    })
    this.search()
  },
  methods: {
    groupClick (item) {
      this.activeGroup = item.id
      this.searchForm.val1 = ''
      this.searchForm.dataType = item.type
      this.search()
    },
    open (title, row) {
      this.title = title +' ã€'+ (row.name)+'】'
      this.searchForm.deviceId = row.id
      if(!row.doorNameObj) {
        row.doorNameObj = {}
      }
      this.model=row
      this.visible = true
      this.tableData = {
        // å·²é€‰ä¸­çš„æ•°æ®
        selectedRows: [],
        // æŽ’序的字段
        sorts: [],
        // å½“前页数据
        list: [],
        // åˆ†é¡µ
        pagination: {
          pageIndex: 1,
          pageSize: 10,
          total: 0
        }
      }
      this.groupClick(this.groupList[0])
    }
  }
}
</script>
<style>
.platgroup_tabs {
  flex: 1;
  display: flex;
  border-bottom: 1px solid #dfe2e8;
  margin-bottom:30px;
  .tab {
    color: #666666;
    margin-right: 40px;
    cursor: pointer;
    padding-bottom: 18px;
    border-bottom: 2px solid #fff;
  }
  .active {
    font-weight: 500;
    font-size: 15px;
    color: #2080f7;
    border-bottom: 2px solid $primary-color;
  }
}
.label{
/*  width: 80px;
  text-align: right;*/
  color: rgb(102, 102, 102);
  display: inline-block;
}
</style>
admin/src/views/business/admissionStatistics.vue
@@ -502,7 +502,7 @@
  .main_table {
    display: flex;
    align-items: start;
    align-items: flex-start;
    justify-content: space-between;
    margin-top: 10px;
    .main_table_list {
admin/src/views/business/carStatistics.vue
@@ -526,7 +526,7 @@
  .main_table {
    display: flex;
    align-items: start;
    align-items: flex-start;
    justify-content: space-between;
    margin-top: 10px;
    .main_table_list {
admin/src/views/business/deviceDianbiao.vue
@@ -31,7 +31,9 @@
              <el-table-column prop="name" label="名称" fixed min-width="150" align="center"></el-table-column>
              <el-table-column prop="no" label="电表地址域" min-width="100" align="center" ></el-table-column>
              <el-table-column prop="doorNo" label="设备号"  min-width="120" align="center" show-overflow-tooltip></el-table-column>
<!--
              <el-table-column prop="channelNo" label="开关序号" align="center" min-width="100"></el-table-column>
-->
              <el-table-column prop="manufature" label="厂商" align="center" min-width="100" show-overflow-tooltip></el-table-column>
              <el-table-column prop="regionPathName" align="center"  min-width="100" label="所在位置"></el-table-column>
              <el-table-column prop="ip" label="IP"  min-width="150" align="center" show-overflow-tooltip ></el-table-column>
@@ -43,6 +45,17 @@
                  </el-switch>
                </template>
              </el-table-column>
              <el-table-column prop="doorNameObj.pwdLevel" label="密码等级" align="center" min-width="150"></el-table-column>
              <el-table-column prop="doorNameObj.pwd" label="密码" align="center">
                <template slot-scope="{row}">
                  <span :class=" 'blue'">{{row.showPwd?row.doorNameObj.pwd:'******'}}</span>
                  <el-button  style="margin-left: 10px" v-if="row.doorNameObj.pwd!=null"
                              @click.native.p.prevent="showPassward(row)" type="text">
                    <i class="el-icon-view" :class="row.showPwd?'red':'blue'" :title="row.showPwd?'隐藏':'显示'"></i>
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column prop="doorNameObj.userCode" label="操作者代码" align="center" min-width="150"></el-table-column>
              <el-table-column prop="editDate" label="最近更新时间" align="center" min-width="150"></el-table-column>
              <el-table-column
                  label="操作"
@@ -55,6 +68,7 @@
                    <el-button type="text" @click="$refs.operaDeviceDataWindow.open('查看电表数据', row)" icon="el-icon-view" v-permissions="['business:device:update']">数据</el-button>
                    <el-button type="text" @click="send(row,1)" icon="el-icon-circle-check"  v-permissions="['business:device:update']">开闸</el-button>
                    <el-button type="text" class="red" @click="send(row,0)" icon="el-icon-circle-close"  v-permissions="['business:device:update']">关闸</el-button>
                    <el-button type="text" class="red" @click="readData(row)" icon="el-icon-circle-close"  v-permissions="['business:device:update']">读取数据</el-button>
                    <el-button type="text" class="red" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['business:device:delete']">删除</el-button>
                  </template>
                </el-table-column>
@@ -78,19 +92,20 @@
            <b class="green" v-if="form.status ===1">开闸</b>
            <b class="red" v-else>关闸</b>
          </el-form-item>
          <el-form-item label="开关序号" prop="channelNo">
            <el-input v-model="form.channelNo" type="text" placeholder="请输入开关序号 ï¼Œå¤šä¸ªç”¨è‹±æ–‡é€—号隔开,如 1,2,3" v-trim/>
          <el-form-item label="有效时间" prop="cmdDate">
            <el-date-picker type="datetime" v-model="form.cmdDate" value-format="yyyy-MM-dd HH:mm:ss"
                            placeholder="请选择有效时间"   />
          </el-form-item>
          <p class="tip-warn" style="width: 100%;"><i class="el-icon-warning"></i>设备原始开关序号信息:{{form.channelNo1}},控制多个开关,请用英文逗号隔开,如 1,2;</p>
          <p class="tip-warn" style="width: 100%;"><i class="el-icon-warning"></i></p>
        </el-form>
        <template  v-slot:footer  >
          <el-button @click="sendAction()" type="primary" v-if="form.status === 1" :loading="isWorkSending">确认开闸</el-button>
          <el-button @click="sendAction()" type="danger" v-if="form.status !== 1" :loading="isWorkSending">确认关闸</el-button>
          <el-button @click="sendAction(0)" type="primary" v-if="form.status === 1" :loading="isWorkSending">确认开闸</el-button>
          <el-button @click="sendAction(1)" type="danger" v-if="form.status !== 1" :loading="isWorkSending">确认关闸</el-button>
          <el-button @click="sendClose()">返回</el-button>
        </template>
      </el-dialog>
        <!-- æ–°å»º/修改 -->
    <OperaDeviceDuanluqiWindow ref="operaDeviceWindow" @success="handlePageChange"/>
    <OperaDeviceDianbiaoWindow ref="operaDeviceWindow" @success="handlePageChange"/>
    <OperaDeviceDataListWindow ref="operaDeviceDataWindow" @success="handlePageChange"/>
    </TableLayout>
</template>
@@ -98,12 +113,12 @@
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaDeviceDataListWindow from '@/components/business/OperaDeviceDataListWindow'
import OperaDeviceDuanluqiWindow from '@/components/business/OperaDeviceDuanluqiWindow'
import OperaDeviceDataListWindow from '@/components/business/OperaDianbiaoDataListWindow'
import OperaDeviceDianbiaoWindow from '@/components/business/OperaDeviceDianbiaoWindow'
export default {
  name: 'DeviceDuanluqi',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaDeviceDuanluqiWindow ,OperaDeviceDataListWindow},
  components: { TableLayout, Pagination, OperaDeviceDianbiaoWindow, OperaDeviceDataListWindow },
  data () {
    return {
      // æœç´¢
@@ -116,15 +131,14 @@
      isWorkSending: false,
      form: {
        id: '',
        name: '',
        channelNo: '',
        channelNo1: '',
        status: null
        status: null,
        name:null,
        cmdDate: null
      },
      visibleSend: false,
      options: [],
      rules: {
        channelNo: [{ required: true, message: '请输入需要操作的开关序号', trigger: 'blur' }],
        cmdDate: [{ required: true, message: '请选择操作有效时间' }]
      }
    }
  },
@@ -151,17 +165,16 @@
        this.$set(row, 'showPwd', false)
      }
    },
    sendAction () {
      if (!this.form.channelNo) {
        return
      }
    sendAction (status) {
      this.form.status = status
      this.$dialog.actionConfirm('确认进行电表【' + (this.form.status === 1 ? '开闸' : '关闸') + '】操作吗?', '操作确认提醒')
        .then(() => {
          console.log(this.form)
          this.isWorkSending = true
          this.api.duanluqiCmd(this.form)
          this.api.dianbaoCmd(this.form)
            .then(res => {
              this.$tip.apiSuccess(res || '请求成功')
              this.sendClose()
              this.handlePageChange()
            })
            .catch(e => {
            })
@@ -171,16 +184,27 @@
        })
        .catch(() => {})
    },
    readData (row) {
      this.api.dianbiaoData({ id: row.id })
        .then(res => {
          this.$tip.apiSuccess(res || '请求成功')
          this.handlePageChange()
        })
        .catch(e => {
        })
        .finally(() => {
          this.isWorkSending = false
        })
    },
    send (row, type) {
      this.visibleSend = true
      this.form = { id: row.id, name: row.name, channelNo: row.channelNo, status: type ,channelNo1:row.channelNo}
      this.form = { id: row.id, name: row.name, cmdDate: null, status: type}
    },
    sendClose () {
      this.visibleSend = false
      this.isWorkSending = false
      this.form = { id: '', name: '', channelNo: '', status: '',channelNo1:'' }
      this.form = { id: '', name: '', status: '', cmdDate: '' }
    }
  }
}
</script>
server/system_gateway/src/main/resources/application-self.yml
@@ -1,7 +1,7 @@
spring:
  # æ•°æ®æºé…ç½®
  datasource:
    url: jdbc:mysql://localhost:3306/antaiwuliu?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
    url: jdbc:mysql://localhost:3306/dmvisits?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
    username: root
    password: Titi@168.com
    driver-class-name: com.mysql.cj.jdbc.Driver
server/system_gateway/src/main/resources/bootstrap-dev.yml
@@ -7,7 +7,7 @@
      discovery:
        server-addr: http://192.168.0.7:8848 #配置Nacos地址
#        namespace: dmvisit
        namespace: wuhu_visit_dev
        namespace: dm_visits_test
        username: nacos
        password: nacos
    gateway:
server/system_service/src/main/java/com/doumee/core/utils/Constants.java
@@ -314,6 +314,7 @@
        public static final  int broadcaset = 3;
        public static final  int broadcasetChannel = 4;
        public static final  int duanluqi = 5;
        public static final  int dianbiao = 6;
    }
    /**
server/visits/device_service/src/main/java/com/doumee/tcp/WaterElectricityUtil.java
@@ -60,6 +60,7 @@
        return (byte) (sum & 0xFF);
    }
    public static byte[] getRequestParam(int feCount, byte[] address, byte control, byte[] data) throws IOException {
        ///FEFEFE    68  999999999999    68  01  02  65  F3C1  16
@@ -170,6 +171,17 @@
        return hexResult;
    }
    private static String addByte(String value, byte add) {
        byte b = (byte) Integer.parseInt(value, 16);
        int result = (b & 0xFF) + (add & 0xFF);
        // ç¡®ä¿ç»“果在0-255范围内(处理负数)
        if (result < 0) {
            result += 256;
        }
        String hexResult = String.format("%02X", result & 0xFF);
        return hexResult;
    }
    private static String[] parseSub33Reverse(String msg, int n) {
@@ -240,6 +252,83 @@
        map.put("total", total);
    }
    /**
     * ç”µè¡¨è·³é—¸ã€åˆé—¸
     * @param ip
     * @param port
     * @param addressBuf
     * @param type ï¼ˆ0跳闸 1合闸)
     * @param date æœ‰æ•ˆæˆªæ­¢æ—¶é—´
     * @throws IOException
     */
    private static boolean electricityControl(String ip, int port, byte[] addressBuf,int type,  String date)   {
        /**
         * N1为控制命令类型,N1=1AH代表跳闸4D,N1=1BH代表合闸4F允许N2保留
         * æƒé™å¯†ç æ“ä½œä»£ç ï¼šPAP2P1P0C3C2C1C0(02/223203/111111H)
         * 4F
         * TCP/IP直接合闸指令[2026å¹´03月09日 10:57:39]
         * Tx ->FEFEFEFE68615121010000681C1035366555776655444F33568843433659E016
         * TCP/IP直接合闸指令[2026å¹´03月09日 10:57:40]
         * Rx <-FEFEFEFE68615121010000689C004016
         * ç›´æŽ¥åˆé—¸æ‰§è¡ŒæˆåŠŸï¼ 9C
         */
        try {
            byte control = 0x1C;
            byte n1 =  0x4D;
            if(type==1){
                n1 =  0x4F;
            }
//        byte[] data0 = {0x02, 0x03, 0x32, 0x22,0x44,0x33,0x22,0x11};
            byte[] data = {0x35, 0x36, 0x65, 0x55,0x77,0x66,0x55,0x44,n1,0x33,0,0,0,0,0,0};
            byte[] data2 = getDateBytes(date);
            for (int i = 0; i < data2.length; i++) {
                data[10+i]=data2[i];
            }
            byte[] bufReq = getRequestParam(4, addressBuf, control, data);
            String reqt = bytesToHex(bufReq);
            System.out.println(reqt);
            byte[] respBuf = readDeviceData(ip, port, bufReq);
            String resp = bytesToHex(respBuf);
            System.out.println(resp);
            //FEFEFEFE68379707010000689C004216
             String msg = resp.substring(24, 26);
             return msg.equals("9C");
        }catch (Exception e){
        }
        return  false;
    }
    private static byte[] getDateBytes(String dateStr) {
//        String dateStr = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
        dateStr = dateStr.substring(2);
        // 1. éªŒè¯è¾“å…¥
        if (dateStr == null || dateStr.length() != 12) {
            throw new IllegalArgumentException("时间必须是12位十进制数");
        }
        if (!dateStr.matches("\\d{12}")) {
            throw new IllegalArgumentException("时间必须全部是数字");
        }
        // 2. å‡†å¤‡ç»“果数组(6字节)
        byte[] result = new byte[6];
        // 3. ä»Žå³å‘左每2位一组处理(小端序)
        byte add = 0x33;
        for (int i = 0; i < 6; i++) {
            // è®¡ç®—在字符串中的位置(从右向左)
            int strIndex = 10 - (i * 2);  // å› ä¸ºè¦å–两位,所以是10,8,6,4,2,0
            String twoDigits = dateStr.substring(strIndex, strIndex + 2);
            // å°†ä¸¤ä½åè¿›åˆ¶æ•°è½¬æ¢ä¸ºBCD字节
            // ä¾‹å¦‚:"25" -> 0x25
            int t = Integer.parseInt(twoDigits, 16);
            int t1 =   ( t& 0xFF) + (add & 0xFF);
            System.out.println(t1+":");
            result[i] =(byte) t1 ;
        }
        // æ³¨æ„ï¼šä¸Šé¢çš„循环顺序已经是小端序,result[0]存的是最低两位
        return result;
    }
    private static void electricityStatus(String ip, int port, byte[] addressBuf, Map<String, Object> map) throws IOException {
        byte control = 0x11;
        byte[] data = {0x36, 0x38, 0x33, 0x37};
@@ -266,8 +355,10 @@
        String ts = hexToBinary1(nArr);
        String time = "20"+ts.substring(0,6)+ts.substring(8);
        Date date = getDateByStr(time);
        System.out.println( formatData(date));
//        String resp = "FEFEFEFE   68  615121010000    68  91  06  36383337    3333    7916";
        map.put("currentTime", formatData(date));
        map.put("time", date);
//        map.put("currentTime", formatData(date));
    }
    public static Date getDateByStr(String date)  {
        TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
@@ -296,7 +387,7 @@
        return null;
    }
    public static Map<String, Object> electricity(String ip, int port, String address) throws IOException {
    public static Map<String, Object> electricityData(String ip, int port, String address) throws IOException {
        Map<String, Object> r = new HashMap<>();
        byte[] addressBuf = convertToBCDAddress(address);
        electricityTotal(ip, port, addressBuf, r);
@@ -304,7 +395,11 @@
        electricityTime(ip, port, addressBuf, r);
        return r;
    }
    public static boolean electricityAct(String ip, int port, String address,int type,String dateStr) {
        Map<String, Object> r = new HashMap<>();
        byte[] addressBuf = convertToBCDAddress(address);
       return electricityControl(ip,port,addressBuf,type,dateStr);
    }
    private static String hexToBinary(String hex) {
        StringBuilder sb = new StringBuilder();
        for (char c : hex.toCharArray()) {
@@ -328,7 +423,6 @@
        }
        return sb.toString();
    }
    private static String addHex(String hex1, String hex2) {
        int num1 = Integer.parseInt(hex1.replace("0x", ""), 16);
@@ -494,9 +588,10 @@
    public static void main(String[] args) throws IOException {
//        testWater();
//        electricityTest();
        water("192.168.1.78",1030,"000152462599");
        Map<String, Object> map = electricity("192.168.1.78", 1030, "000001215161");
        System.out.println(JSONObject.toJSONString(map));
//        water("192.168.1.78",1030,"000152462599");
//        Map<String, Object> map = electricityData("192.168.1.78", 1030, "000001215161");
//        System.out.println(JSONObject.toJSONString(map));
        electricityAct("192.168.1.78", 1030, "000001215161",0,"20260309162655");
//        FEFEFE6899254652010068810 843C3333433333333   E9 16
//        FEFEFE6899254652010068810 84  3C3333433333333E916
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/DeviceCloudController.java
@@ -49,7 +49,7 @@
    }
    @ApiOperation("修改是否门禁入口")
    @PostMapping("/updateEntranceById")
    @CloudRequiredPermission("business:company:update")
    @CloudRequiredPermission("business:device:update")
    public ApiResponse updateStatusById(@RequestBody Device param,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){
        Device d = new Device();
        d.setId(param.getId());
@@ -61,7 +61,7 @@
    }
    @ApiOperation("修改是否系统使用")
    @PostMapping("/updateUsedById")
    @CloudRequiredPermission("business:company:update")
    @CloudRequiredPermission("business:device:update")
    public ApiResponse updateUsedById(@RequestBody Device param,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){
        Device d = new Device();
        d.setId(param.getId());
@@ -73,12 +73,28 @@
    }
    @ApiOperation("执行断路器开关闸操作")
    @PostMapping("/duanluqiCmd")
    @CloudRequiredPermission("business:company:update")
    @CloudRequiredPermission("business:device:update")
    public ApiResponse duanluqiCmd(@RequestBody Device param,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){
        param.setLoginUserInfo(this.getLoginUser(token));
        deviceService.duanluqiCmd(param);
        return ApiResponse.success(null);
    }
    @ApiOperation("执行电表开关闸操作")
    @PostMapping("/dianbaoCmd")
    @CloudRequiredPermission("business:device:update")
    public ApiResponse dianbaoCmd(@RequestBody Device param,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){
        param.setLoginUserInfo(this.getLoginUser(token));
        deviceService.dianbaoCmd(param);
        return ApiResponse.success(null);
    }
    @ApiOperation("读取电表数据(电能、时间和状态)")
    @PostMapping("/dianbiaoData")
    @CloudRequiredPermission("business:device:update")
    public ApiResponse dianbiaoData(@RequestBody Device param,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){
        param.setLoginUserInfo(this.getLoginUser(token));
        deviceService.dianbiaoData(param);
        return ApiResponse.success(null);
    }
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
@@ -159,6 +159,9 @@
    @ApiModelProperty(value = "播报内容")
    @TableField(exist = false)
    private String sendInfo;
    @ApiModelProperty(value = "远程操作时间参数")
    @TableField(exist = false)
    private Date cmdDate;
    @ApiModelProperty(value = "配置参数")
    @TableField(exist = false)
    private JSONObject doorNameObj;
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/DeviceData.java
@@ -88,8 +88,8 @@
    @ExcelColumn(name="属性值7")
    private String val7;
    @ApiModelProperty(value = "数据来源 0mqtt上报综合状态 1远程控制 ", example = "1")
    @ExcelColumn(name="数据来源 0mqtt上报综合状态 1远程控制")
    @ApiModelProperty(value = "数据来源 0mqtt上报综合状态 1远程控制 2TCP读取数据 ", example = "1")
    @ExcelColumn(name="数据来源 0mqtt上报综合状态 1远程控制 2TCP读取数据")
    private Integer dataType;
}
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java
@@ -119,4 +119,7 @@
    void autoCloseCmdTimer();
    void startCheckDuanluqiSubjob();
    void dianbaoCmd(Device param);
    void dianbiaoData(Device param);
}
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
@@ -26,6 +26,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.doumee.service.business.impl.hksync.HkSyncPushServiceImpl;
import com.doumee.tcp.WaterElectricityUtil;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -33,6 +34,7 @@
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
@@ -73,7 +75,9 @@
        model.setIsdeleted(Constants.ZERO);
        model.setEditDate(new Date());
        model.setCreateDate(model.getEditDate());
        if(model.getDoorNameObj()!=null && Constants.equalsInteger(model.getType(),Constants.DEVICE_TYPE.duanluqi)){
        if(model.getDoorNameObj()!=null &&
                (Constants.equalsInteger(model.getType(),Constants.DEVICE_TYPE.duanluqi)
                ||Constants.equalsInteger(model.getType(),Constants.DEVICE_TYPE.dianbiao))){
            model.setDoorName(JSONObject.toJSONString(model.getDoorNameObj()));
            if(StringUtils.isNotBlank(model.getLevel())){
                if(getNumberByStr(model.getLevel()) <300){
@@ -115,7 +119,9 @@
    public void updateById(Device device) {
        device.setEdirot(device.getLoginUserInfo().getId()+"");
        device.setEditDate(new Date());
        if(device.getDoorNameObj()!=null && Constants.equalsInteger(device.getType(),Constants.DEVICE_TYPE.duanluqi)){
        if(device.getDoorNameObj()!=null &&
                (Constants.equalsInteger(device.getType(),Constants.DEVICE_TYPE.duanluqi)
                        ||Constants.equalsInteger(device.getType(),Constants.DEVICE_TYPE.dianbiao))){
            device.setDoorName(JSONObject.toJSONString(device.getDoorNameObj()));
        }
        Device model = deviceMapper.selectById(device.getId());
@@ -322,7 +328,9 @@
        IPage<Device> result = deviceMapper.selectPage(page, queryWrapper);
        if(result!=null){
            for(Device d : result.getRecords()){
                if(StringUtils.isNotBlank(d.getDoorName()) &&Constants.equalsInteger(d.getType(),Constants.DEVICE_TYPE.duanluqi)){
                if(StringUtils.isNotBlank(d.getDoorName())
                        && (Constants.equalsInteger(d.getType(),Constants.DEVICE_TYPE.duanluqi)||
                        Constants.equalsInteger(d.getType(),Constants.DEVICE_TYPE.dianbiao))){
                    try {
                        //断路器设备参数
                        d.setDoorNameObj(JSONObject.parseObject(d.getDoorName()));
@@ -404,6 +412,94 @@
        dealDuanluqiCmd(model,param,"device_");
    }
    @Override
    public  void dianbaoCmd(Device param){
        Device model = deviceMapper.selectById(param.getId());
        if(model ==null && Constants.equalsInteger(param.getType(),Constants.DEVICE_TYPE.dianbiao)){
            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        if (param.getStatus() == null || param.getCmdDate() == null
            ||param.getCmdDate().getTime() <= System.currentTimeMillis()) {
            //如果是开闸
            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        boolean r ;
        String date = DateUtil.formatDate(new Date(),"yyyyMMddHHmmss");
        if(Constants.equalsInteger(param.getStatus(),Constants.ONE)) {
            //如果是开闸
           r = WaterElectricityUtil.electricityAct(param.getIp(),Integer.parseInt(param.getPort()),param.getNo(),0,date);
        }else {
            //如果是合闸
            r = WaterElectricityUtil.electricityAct(param.getIp(),Integer.parseInt(param.getPort()),param.getNo(),1,date);
        }
        if(!r){
            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"远程控制电表失败,请稍后重试!");
        }
        String curremak = "【"+param.getLoginUserInfo().getRealname()
                +"】于"+ DateUtil.getPlusTime2(new Date()) +"进行了"+(Constants.equalsInteger(param.getStatus(),Constants.ONE)?"【合闸】":"【分闸】")+"操作,开关【"+param.getChannelNo()+"】;";
        deviceMapper.update(null,new UpdateWrapper<Device>().lambda()
                .set(Device::getRemark,curremak)
                .set(Device::getEditDate,new Date())
                .set(Device::getEdirot,param.getLoginUserInfo().getId())
                .eq(Device::getId,param.getId()));
        DeviceData data = new DeviceData();
        data.setCreateDate(new Date());
        data.setEditDate(new Date());
        data.setCreator(param.getLoginUserInfo().getId());
        data.setEditor(param.getLoginUserInfo().getId());
        data.setDeviceId(param.getId()+"");
        data.setDataType(Constants.ONE);//
        data.setVal1("远程控制");
        data.setVal2(curremak);
        data.setHappenTime(DateUtil.getPlusTime2(data.getCreateDate()));
        data.setVal3((Constants.equalsInteger(param.getStatus(),Constants.ONE)?"【合闸】":"【分闸】"));
        data.setVal4(param.getLoginUserInfo().getRealname());
        data.setVal5(param.getChannelNo());
        deviceDataMapper.insert(data);
    }
    @Override
    @Transactional
    public  void dianbiaoData(Device param){
        Device model = deviceMapper.selectById(param.getId());
        if(model ==null && Constants.equalsInteger(param.getType(),Constants.DEVICE_TYPE.dianbiao)){
            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        try {
            Map<String, Object>  readData=  WaterElectricityUtil.electricityData(model.getIp(),Integer.parseInt(model.getPort()),model.getNo());
            if(readData!=null){
                String curremak = "【"+param.getLoginUserInfo().getRealname()
                        +"】于"+ DateUtil.getPlusTime2(new Date()) +"进行了数据读取操作";
                Date time =(Date) readData.get("time");
                String total = (Double) readData.get("total")+"";
                String status =  (String) readData.get("status");
                model.setHkDate(new Date());//最近同步时间
                model.setOnline(Constants.ONE);//标识设备在线
                model.setRemark(curremak);
                DeviceData data = new DeviceData();
                data.setCreateDate(new Date());
                data.setEditDate(new Date());
                data.setCreator(param.getLoginUserInfo().getId());
                data.setEditor(param.getLoginUserInfo().getId());
                data.setDeviceId(param.getId()+"");
                data.setDataType(Constants.ZERO);//
                data.setVal1(total);
                data.setVal2(status);
                data.setHappenTime(DateUtil.getPlusTime2(data.getCreateDate()));
                data.setVal3(DateUtil.getPlusTime2(time));
                data.setVal4(param.getLoginUserInfo().getRealname());
                data.setVal5(param.getNo());//地址域
                deviceDataMapper.insert(data);
                deviceMapper.updateById(model);
            }
        }catch (Exception e){
            e.printStackTrace();
            log.error("电表数据读取失败,"+e.getMessage());
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"读取电表数据失败!");
        }
    }
    private void dealDuanluqiCmd(Device model, Device param,String clientIndex) {
        MqttConfig config = getMqttConfigByParam(model,clientIndex);