From 0631137a90901f2e09a971fbf422ef476edb1c4e Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 06 三月 2026 09:58:21 +0800
Subject: [PATCH] 最新版本541200007
---
admin/src/views/business/deviceBroadcast.vue | 101 +++++++-
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java | 11 -
admin/src/components/business/OperaDeviceBroadcastWindow.vue | 30 --
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/HkSyncCloudController.java | 70 -----
server/system_gateway/src/main/resources/bootstrap.yml | 2
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java | 429 --------------------------------------
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java | 6
admin/.env.development | 4
8 files changed, 102 insertions(+), 551 deletions(-)
diff --git a/admin/.env.development b/admin/.env.development
index 0d060e0..5916de9 100644
--- a/admin/.env.development
+++ b/admin/.env.development
@@ -3,9 +3,9 @@
# VUE_APP_API_URL = 'https://atwl.ahzyssl.com/zhyq_interface'
-VUE_APP_API_URL = 'http://192.168.1.45:10010'
+VUE_APP_API_URL = 'http://localhost:10010'
-# VUE_APP_API_URL = 'http://192.168.0.7/system_gateway'
+#VUE_APP_API_URL = 'http://192.168.0.7/system_gateway'
# VUE_APP_API_URL = 'http://localhost:10010'
diff --git a/admin/src/components/business/OperaDeviceBroadcastWindow.vue b/admin/src/components/business/OperaDeviceBroadcastWindow.vue
index c7a4027..5f6ae87 100644
--- a/admin/src/components/business/OperaDeviceBroadcastWindow.vue
+++ b/admin/src/components/business/OperaDeviceBroadcastWindow.vue
@@ -15,18 +15,6 @@
<el-form-item label="璁惧搴忓垪鍙�" prop="no">
<el-input v-model="form.no" placeholder="璇疯緭鍏ュ簭鍒楀彿" v-trim/>
</el-form-item>
- <el-form-item label="杩炴帴IP" prop="ip">
- <el-input v-model="form.ip" placeholder="璇疯緭鍏ヨ澶囪繛鎺P鍦板潃" 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="doorId">
- <el-input v-model="form.doorId" placeholder="璇疯緭鍏ヨ澶囪繛鎺ヨ处鍙�" v-trim/>
- </el-form-item>
- <el-form-item label="杩炴帴瀵嗙爜" prop="doorName">
- <el-input v-model="form.doorName" type="password" maxlength="30" show-password></el-input>
- </el-form-item>
<el-form-item label="鎵�鍦ㄤ綅缃�" prop="regionPathName">
<el-input v-model="form.regionPathName" placeholder="璇疯緭鍏ユ墍鍦ㄤ綅缃�" v-trim/>
</el-form-item>
@@ -50,28 +38,12 @@
name: '',
regionPathName: '',
no: '',
- type: 4,
- ip: '',
- port: '',
- doorId: '',
- doorName:''
+ type: 4
},
// 楠岃瘉瑙勫垯
rules: {
name: [
{ required: true, message: '璇疯緭鍏ヨ澶囧悕绉�' }
- ],
- ip: [
- { required: true, message: '璇疯緭鍏ヨ澶囪繛鎺P鍦板潃' }
- ],
- port: [
- { required: true, message: '璇疯緭鍏ヨ澶囪繛鎺ョ鍙e彿' }
- ],
- doorId: [
- { required: true, message: '璇疯緭鍏ヨ澶囪繛鎺ヨ处鍙�' }
- ],
- doorName: [
- { required: true, message: '璇疯緭鍏ヨ澶囪繛鎺ュ瘑鐮�' }
],
hkId: [
{ required: true, message: '璇疯緭鍏ヨ澶囧敮涓�鐮�' }
diff --git a/admin/src/views/business/deviceBroadcast.vue b/admin/src/views/business/deviceBroadcast.vue
index 4731caa..9e54ee3 100644
--- a/admin/src/views/business/deviceBroadcast.vue
+++ b/admin/src/views/business/deviceBroadcast.vue
@@ -12,22 +12,37 @@
</el-form>
<!-- 琛ㄦ牸鍜屽垎椤� -->
<template v-slot:table-wrap>
- <ul class="toolbar">
- <li><el-button type="primary" @click="synchronousData">鍚屾</el-button></li>
- </ul>
+ <ul class="toolbar" v-permissions="['business:device:create', 'business:device:delete']">
+ <li><el-button type="primary" :loading="isWorking.delete" @click="synchronousData">鍚屾</el-button></li>
+ <li><el-button type="primary" @click="$refs.operaDeviceWindow.open('鏂板缓骞挎挱')" icon="el-icon-plus" v-permissions="['business:device:create']">鏂板缓</el-button></li>
+ <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:device:delete']">鍒犻櫎</el-button></li>
+ </ul>
<el-table
:height="tableHeightNew"
v-loading="isWorking.search"
:data="tableData.list"
stripe
>
+ <el-table-column type="selection" width="55"></el-table-column>
<el-table-column label="搴忓彿" width="55" fixed><template slot-scope="scope" >{{scope.$index+1}}</template></el-table-column>
<el-table-column prop="name" label="鍚嶇О"></el-table-column>
- <el-table-column prop="hkId" label="鍞竴鏍囪瘑" min-width="200"></el-table-column>
- <el-table-column prop="channelInfo" label="绫诲瀷"></el-table-column>
- <el-table-column prop="channelNo" label="璁惧鍙�"></el-table-column>
- <el-table-column prop="regionName" label="鍖哄煙缂栫爜"></el-table-column>
- <el-table-column prop="hkDate" label="鍚屾鏃堕棿"></el-table-column>
+ <el-table-column prop="hkId" label="鍞竴鏍囪瘑" ></el-table-column>
+ <el-table-column prop="no" label="搴忓垪鍙�" ></el-table-column>
+ <el-table-column prop="regionPathName" label="鎵�鍦ㄤ綅缃�"></el-table-column>
+ <el-table-column prop="editDate" label="鏈�杩戞洿鏂版椂闂�"></el-table-column>
+ <el-table-column
+ v-if="containPermissions(['business:devicerole:update', 'business:devicerole:delete'])"
+ label="鎿嶄綔"
+ align="center"
+ min-width="120"
+ fixed="right"
+ >
+ <template slot-scope="{row}">
+ <el-button type="text" @click="$refs.operaDeviceWindow.open('缂栬緫骞挎挱', row)" icon="el-icon-edit" v-permissions="['business:device:update']">缂栬緫</el-button>
+ <el-button type="text" @click="send(row)" icon="el-icon-edit" 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>
</el-table>
<pagination
@size-change="handleSizeChange"
@@ -36,8 +51,26 @@
>
</pagination>
</template>
+ <el-dialog
+ :visible.sync="visibleSend"
+ style="z-index: 100000"
+ append-to-body
+ width="50%"
+ height="50%"
+ :title="'鍙戦�佹挱鎶�-'+ form.name"
+ >
+ <el-form :model="form" ref="form" >
+ <el-form-item label="鎾姤鍐呭" prop="name" required>
+ <el-input v-model="form.sendInfo" type="textarea" placeholder="璇疯緭鍏ユ挱鎶ュ唴瀹�" v-trim/>
+ </el-form-item>
+ </el-form>
+ <template v-slot:footer >
+ <el-button @click="sendBobao()" type="primary" :loading="isWorkSending">纭</el-button>
+ <el-button @click="sendClose()">杩斿洖</el-button>
+ </template>
+ </el-dialog>
<!-- 鏂板缓/淇敼 -->
- <OperaDeviceWindow ref="operaDeviceWindow" @success="handlePageChange"/>
+ <OperaDeviceBroadcastWindow ref="operaDeviceWindow" @success="handlePageChange"/>
</TableLayout>
</template>
@@ -45,12 +78,11 @@
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
-import OperaDeviceWindow from '@/components/business/OperaDeviceWindow'
-import { syncDevices, updateEntranceById } from '@/api/business/device'
+import OperaDeviceBroadcastWindow from '@/components/business/OperaDeviceBroadcastWindow'
export default {
name: 'Device',
extends: BaseTable,
- components: { TableLayout, Pagination, OperaDeviceWindow },
+ components: { TableLayout, Pagination, OperaDeviceBroadcastWindow },
data () {
return {
// 鎼滅储
@@ -61,6 +93,14 @@
online: '',
type: 4
},
+ isWorkSending: false,
+ form: {
+ sendInfo: '',
+ id: '',
+ hkId: '',
+ name: ''
+ },
+ visibleSend: false,
options: []
}
},
@@ -74,17 +114,40 @@
this.search()
},
methods: {
- changeManufature(e, row) {
- updateEntranceById({
- id: row.id,
- isEntrance: e
- })
+ sendBobao () {
+ if(!this.form.sendInfo){
+ return
+ }
+ this.$dialog.actionConfirm('纭杩涜骞挎挱鎾姤鍚楋紵','鎿嶄綔纭鎻愰啋')
+ .then(() => {
+ this.isWorkSending = true
+ this.api.sendBobao(this.form)
+ .then(res => {
+ this.$tip.apiSuccess(res || '鎾姤璇锋眰鎴愬姛')
+ this.sendClose()
+ })
+ .catch(e => {
+ })
+ .finally(() => {
+ this.isWorkSending = false
+ })
+ })
+ .catch(() => {})
},
- synchronousData () {
+ send (row) {
+ this.visibleSend = true
+ this.form = { sendInfo: '', id: row.id, hkId: row.hkId, name: row.name }
+ },
+ sendClose () {
+ this.visibleSend = false
+ this.isWorkSending = false
+ this.form = { sendInfo: '', id: '', hkId: '', name: '' }
+ },
+ synchronousData () {
this.$dialog.actionConfirm('鎿嶄綔纭鎻愰啋', '鎮ㄧ‘璁ゅ悓姝ュ叏閮ㄤ俊鎭悧锛�')
.then(() => {
this.isWorking.delete = true
- syncDevices({type: 3})
+ syncDevices({type: 4})
.then(res => {
this.$tip.apiSuccess(res || '鍚屾鎴愬姛')
this.search()
diff --git a/server/system_gateway/src/main/resources/bootstrap.yml b/server/system_gateway/src/main/resources/bootstrap.yml
index 3d2cb09..02ca26f 100644
--- a/server/system_gateway/src/main/resources/bootstrap.yml
+++ b/server/system_gateway/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- active: pro
+ active: dev
application:
name: system_gateway
# 瀹夊叏閰嶇疆
diff --git a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/HkSyncCloudController.java b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/HkSyncCloudController.java
index 05774d8..37a5584 100644
--- a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/HkSyncCloudController.java
+++ b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/HkSyncCloudController.java
@@ -116,7 +116,7 @@
//鍚屾LED
result = hkSyncDeviceService.syncHkLed(param);
}else if(Constants.equalsInteger(param.getType(),Constants.THREE)){
- //鍚屾骞挎挱鐐�
+ //鍚屾骞挎挱
result = hkSyncDeviceService.syncHkBroadcast(param);
}else if(Constants.equalsInteger(param.getType(),Constants.FOUR)){
//鍚屾骞挎挱
@@ -320,83 +320,30 @@
@PostMapping("/regionList")
public ApiResponse<List<PageRegionInfoResponse> > getRegionList(HttpServletResponse response, @RequestHeader(Constants.HEADER_USER_TOKEN) String token ){
CarmeraListVO param =new CarmeraListVO();
- param.setWithCameras(2);
+ param.setWithCameras(0);
List<PageRegionInfoResponse> result = new ArrayList<>();
try {
- result = boardService.getRegionTree( param);
- }catch (Exception e){
-
- }
- boolean debug =false;
- if(debug && result.size()==0){
+// result = boardService.getRegionTree( param);
//------TODO---------娴嬭瘯妯℃嫙鏁版嵁----start-----
for (int i = 0; i < 5; i++) {
PageRegionInfoResponse t = new PageRegionInfoResponse();
t.setName("鎬诲尯鍩焈"+i);
t.setIndexCode(i+"_code");
t.setChildList(new ArrayList<>());
- t.setCarmeraList(new ArrayList<>());
- CarmeraListVO c= new CarmeraListVO();
- c.setName("鐩戞帶鐐�11"+i);
- c.setIndexCode("jkd11"+i);
- t.getCarmeraList().add(c);
- c= new CarmeraListVO();
- c.setName("鐩戞帶鐐�12"+i);
- c.setIndexCode("jkd12"+i);
- t.getCarmeraList().add(c);
for (int j = 0; j < 5; j++) {
PageRegionInfoResponse t1 = new PageRegionInfoResponse();
t1.setName("瀛愬尯鍩焈"+i+"_"+j);
t1.setIndexCode(i+"_"+j+"_ChildCode");
t1.setParentIndexCode(t.getIndexCode());
- t1.setCarmeraList(new ArrayList<>());
- t1.setDeviceList(new ArrayList<>());
- t1.setSensorList(new ArrayList<>());
-
- CarmeraListVO c1= new CarmeraListVO();
- c1.setName(i+"鐩戞帶鐐�111"+j);
- c1.setIndexCode(i+"jkd111"+j);
- t1.getCarmeraList().add(c1);
- c1= new CarmeraListVO();
- c1.setName(i+"鐩戞帶鐐�112"+j);
- c1.setIndexCode(i+"jkd112"+j);
- t1.getCarmeraList().add(c1);
-
-
- c1= new CarmeraListVO();
- c1.setName(i+"浼犳劅鍣�111"+j);
- c1.setIndexCode(i+"cgq111"+j);
- t1.getSensorList().add(c1);
- c1= new CarmeraListVO();
- c1.setName(i+"浼犳劅鍣�111112"+j);
- c1.setIndexCode(i+"cgq112"+j);
- t1.getSensorList().add(c1);
-
-
-
- c1= new CarmeraListVO();
- c1.setName(i+"娑堥槻璁惧111"+j);
- c1.setIndexCode(i+"xf111"+j);
- t1.getDeviceList().add(c1);
- c1= new CarmeraListVO();
- c1.setName(i+"娑堥槻璁惧111112"+j);
- c1.setIndexCode(i+"xf112"+j);
- t1.getDeviceList().add(c1);
-
t.getChildList().add(t1);
}
-
result.add(t);
}
//------TODO---------娴嬭瘯妯℃嫙鏁版嵁----end-----
+ }catch (Exception e){
+
}
return ApiResponse.success(result);
- }
- @ApiOperation("銆愭捣搴枫�戝己鍒跺埛鏂板尯鍩熴�佺洃鎺с�佹秷闃茶澶囩紦瀛�")
- @PostMapping("/refreshRegionData")
- public ApiResponse<String > refreshRegionData(HttpServletResponse response, @RequestHeader(Constants.HEADER_USER_TOKEN) String token ){
- boardService.cacheRegionAndDeviceData( );
- return ApiResponse.success(null);
}
@@ -409,12 +356,7 @@
}
@ApiOperation("銆愭捣搴枫�戝箍鎾挱鎶�")
@PostMapping("/sendBobao")
- public ApiResponse<String> setBroadcaseBobao(@RequestBody Device body , HttpServletResponse response) {
- return ApiResponse.success( deviceService.setBroadcaseBobaoHttp(body));
- }
- @ApiOperation("銆愭捣搴枫�戝箍鎾挱鎶�")
- @PostMapping("/sendBobaoOpenApi")
- public ApiResponse<List<Map<String,Object>>> sendBobaoOpenapi(@RequestBody Device body , HttpServletResponse response) {
+ public ApiResponse<List<Map<String,Object>>> setBroadcaseBobao(@RequestBody Device body , HttpServletResponse response) {
deviceService.setBroadcaseBobao(body);
return ApiResponse.success(null);
}
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
index d051ff7..b95469d 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
@@ -1,5 +1,6 @@
package com.doumee.dao.business.model;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.doumee.core.annotation.excel.ExcelColumn;
import com.doumee.service.business.third.model.LoginUserModel;
import io.swagger.annotations.ApiModel;
@@ -155,8 +156,9 @@
private String doorName;
-
-
+ @ApiModelProperty(value = "鎾姤鍐呭")
+ @TableField(exist = false)
+ private String sendInfo;
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java
index 3aef46e..840dbda 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java
@@ -5,8 +5,6 @@
import com.doumee.service.business.third.model.PageData;
import com.doumee.service.business.third.model.PageWrap;
import com.doumee.dao.business.model.Device;
-import org.eclipse.paho.client.mqttv3.MqttMessage;
-
import java.util.List;
/**
@@ -15,7 +13,6 @@
* @date 2023/11/30 15:33
*/
public interface DeviceService {
-
/**
* 鍒涘缓
@@ -111,12 +108,4 @@
void allLedDefualtContent();
void setBroadcaseBobao(Device body);
- String setBroadcaseBobaoHttp(Device body);
-
- void duanluqiCmd(Device param);
-
- void updateUsedById(Device d);
-
- void autoCloseCmdTimer();
- void startCheckDuanluqiSubjob();
}
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
index e8b905c..86fa98a 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
@@ -1,6 +1,5 @@
package com.doumee.service.business.impl;
-import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.doumee.biz.system.SystemDictDataBiz;
@@ -11,15 +10,13 @@
import com.doumee.core.haikang.model.param.request.CustomBroadcastRequest;
import com.doumee.core.haikang.model.param.request.TransparentChannelSingleRequest;
import com.doumee.core.haikang.service.HKService;
-import com.doumee.core.utils.*;
import com.doumee.dao.business.*;
import com.doumee.dao.business.model.*;
-import com.doumee.mqtt.config.MqttConfig;
-import com.doumee.mqtt.service.MqttBizService;
-import com.doumee.service.business.impl.mqtt.MqttClientCache;
import com.doumee.service.business.third.model.LoginUserInfo;
import com.doumee.service.business.third.model.PageData;
import com.doumee.service.business.third.model.PageWrap;
+import com.doumee.core.utils.Constants;
+import com.doumee.core.utils.Utils;
import com.doumee.service.business.DeviceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -29,14 +26,11 @@
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.eclipse.paho.client.mqttv3.MqttClient;
-import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
-import java.util.Date;
import java.util.stream.Collectors;
/**
@@ -49,11 +43,7 @@
public class DeviceServiceImpl implements DeviceService {
@Autowired
- private MqttBizService mqttBizService;
- @Autowired
private DeviceMapper deviceMapper;
- @Autowired
- private DeviceDataMapper deviceDataMapper;
@Autowired
private PlatformMapper platformMapper;
@Autowired
@@ -62,8 +52,6 @@
private SystemDictDataBiz systemDictDataBiz;
@Autowired
private PlatformBroadcastLogMapper platformBroadcastLogMapper;
- @Autowired
- private InterfaceLogMapper interfaceLogMapper;
@Override
@@ -73,14 +61,6 @@
model.setIsdeleted(Constants.ZERO);
model.setEditDate(new Date());
model.setCreateDate(model.getEditDate());
- if(model.getDoorNameObj()!=null && Constants.equalsInteger(model.getType(),Constants.DEVICE_TYPE.duanluqi)){
- model.setDoorName(JSONObject.toJSONString(model.getDoorNameObj()));
- if(StringUtils.isNotBlank(model.getLevel())){
- if(getNumberByStr(model.getLevel()) <300){
- throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝鎺у埗鏃堕暱蹇呴』澶т簬绛変簬300绉�");
- }
- }
- }
deviceMapper.insert(model);
return model.getId();
}
@@ -115,35 +95,7 @@
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)){
- device.setDoorName(JSONObject.toJSONString(device.getDoorNameObj()));
- }
- Device model = deviceMapper.selectById(device.getId());
- if(model ==null){
- throw new BusinessException(ResponseStatus.DATA_EMPTY);
- }
- if(Constants.equalsInteger(model.getType(),Constants.DEVICE_TYPE.duanluqi)){
- //濡傛灉鏄柗璺櫒
- if( Constants.equalsInteger(model.getIsUsed(),Constants.ZERO)
- && StringUtils.equals(device.getDoorName(),model.getDoorName())){
- //濡傛灉閰嶇疆鍙傛暟鍙戠敓浜嗗彉鍖�,璁剧疆鐘舵�佹湭鍚敤
- device.setIsUsed(Constants.ONE);
- try {
- MqttClient mqttClient = MqttClientCache.clientMapCache.get("device"+device.getId());
- if(mqttClient !=null){
- if(mqttClient.isConnected()){
- mqttClient.disconnect();
- }
- mqttClient.close();
- MqttClientCache.clientMapCache.remove("device"+device.getId());
- }
- }catch (Exception e){
- log.error("==============绔彛mqtt閾炬帴澶辫触锛�"+model.getName()+e.getMessage());
- }
- }
- }
deviceMapper.updateById(device);
-
}
@Override
@@ -158,16 +110,7 @@
@Override
public Device findById(Integer id) {
- Device d = deviceMapper.selectById(id);
- if(StringUtils.isNotBlank(d.getDoorName()) &&Constants.equalsInteger(d.getType(),Constants.DEVICE_TYPE.duanluqi)){
- try {
- //鏂矾鍣ㄨ澶囧弬鏁�
- d.setDoorNameObj(JSONObject.parseObject(d.getDoorName()));
- }catch (Exception e){
-
- }
- }
- return d;
+ return deviceMapper.selectById(id);
}
@Override
@@ -178,7 +121,6 @@
@Override
public List<Device> findList(Device device) {
- device.setIsdeleted(Constants.ZERO);
QueryWrapper<Device> wrapper = new QueryWrapper<>(device);
return deviceMapper.selectList(wrapper);
}
@@ -191,20 +133,7 @@
.eq(null !=param.getIsdeleted(),Device::getIsdeleted,param.getIsdeleted())
.eq(Objects.isNull(param.getIsdeleted()),Device::getIsdeleted,Constants.ZERO)
.eq(null != param.getHkStatus(),Device::getHkStatus,param.getHkStatus());
- List<Device> list = deviceMapper.selectList(wrapper);
- if(list!=null){
- for(Device d : list){
- if(StringUtils.isNotBlank(d.getDoorName()) &&Constants.equalsInteger(d.getType(),Constants.DEVICE_TYPE.duanluqi)){
- try {
- //鏂矾鍣ㄨ澶囧弬鏁�
- d.setDoorNameObj(JSONObject.parseObject(d.getDoorName()));
- }catch (Exception e){
-
- }
- }
- }
- }
- return list;
+ return deviceMapper.selectList(wrapper);
}
@Override
@@ -241,12 +170,6 @@
}
if (pageWrap.getModel().getName() != null) {
queryWrapper.lambda().like(Device::getName, pageWrap.getModel().getName());
- }
- if (pageWrap.getModel().getDoorNo() != null) {
- queryWrapper.lambda().like(Device::getDoorNo, pageWrap.getModel().getDoorNo());
- }
- if (pageWrap.getModel().getNo() != null) {
- queryWrapper.lambda().like(Device::getNo, pageWrap.getModel().getNo());
}
if (pageWrap.getModel().getDoorName() != null) {
queryWrapper.lambda().like(Device::getDoorName, pageWrap.getModel().getDoorName());
@@ -319,20 +242,7 @@
queryWrapper.orderByAsc(sortData.getProperty());
}
}
- 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)){
- try {
- //鏂矾鍣ㄨ澶囧弬鏁�
- d.setDoorNameObj(JSONObject.parseObject(d.getDoorName()));
- }catch (Exception e){
-
- }
- }
- }
- }
- return PageData.from(result);
+ return PageData.from(deviceMapper.selectPage(page, queryWrapper));
}
@Override
@@ -356,192 +266,6 @@
if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鍙戦�佸け璐ワ細"+ JSONObject.toJSONString(response));
}
- }
-
- @Override
- public void updateUsedById(Device param){
- Device model = deviceMapper.selectById(param.getId());
- if(model ==null && Constants.equalsInteger(param.getType(),Constants.DEVICE_TYPE.duanluqi)){
- throw new BusinessException(ResponseStatus.DATA_EMPTY);
- }
-
- MqttConfig config = getMqttConfigByParam(model,"device_");
- MqttClient mqttClient = MqttClientCache.clientMapCache.get("device"+param.getId());
- String[] topics =new String[]{Constants.MqttTopic.mts_status,
- Constants.MqttTopic.mts_attr,
- Constants.MqttTopic.mts_resp};
- if(Constants.equalsInteger(param.getIsUsed(),Constants.ONE)){
- //濡傛灉绯荤粺涓嶇敤浜嗭紝绔彛mqtt杩炴帴
- try {
- mqttClient = mqttBizService.unsubscribe(mqttClient,config ,topics);
- if(mqttClient !=null){
- if(mqttClient.isConnected()){
- mqttClient.disconnect();
- }
- mqttClient.close();
- MqttClientCache.clientMapCache.remove("device"+param.getId());
- }
- }catch (Exception e){
- log.error("==============绔彛mqtt閾炬帴澶辫触锛�"+model.getName()+e.getMessage());
- }
- }else{
- //濡傛灉寮�濮嬩娇鐢紝寮�濮嬭闃�
- mqttClient = mqttBizService.subscribe(mqttClient,config ,topics);
- if(mqttClient ==null){
- throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"寤虹珛杩炴帴澶辫触锛�");
- }
- MqttClientCache.clientMapCache.put("device"+param.getId(),mqttClient);
- }
-
- this.updateById(param);
- }
- @Override
- public void duanluqiCmd(Device param){
- Device model = deviceMapper.selectById(param.getId());
- if(model ==null && Constants.equalsInteger(param.getType(),Constants.DEVICE_TYPE.duanluqi)){
- throw new BusinessException(ResponseStatus.DATA_EMPTY);
- }
- dealDuanluqiCmd(model,param,"device_");
-
- }
-
- private void dealDuanluqiCmd(Device model, Device param,String clientIndex) {
- MqttConfig config = getMqttConfigByParam(model,clientIndex);
- MqttClient mqttClient = MqttClientCache.clientMapCache.get("device"+param.getId());
- String cmdTopic = Constants.MqttTopic.mts_cmd.replace("$CATE",model.getNo()).replace("$DEVID",model.getDoorNo());
- if(Constants.equalsInteger(param.getStatus(),Constants.ONE)){
- //濡傛灉鏄紑闂革紝鍏堣В閿�
- String cmdParamAction = CmdContants.T30A.cmdParam.replace("$DEVID", model.getDoorNo())
- .replace("$CMD", CmdContants.T30ACmd.do_err_clear)//寮傚父瑙i攣
- .replace("$BUSADDR",model.getChannelNo());
- mqttClient = mqttBizService.publish(mqttClient,config,cmdTopic, cmdParamAction);//瑙i攣鍛戒护
- if(mqttClient ==null){
- throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鎸囦护鍙戦�佸け璐ワ紒");
- }
- }
- String cmdParamAction =CmdContants.T30A.cmdParam.replace("$DEVID", model.getDoorNo())
- .replace("$CMD",(Constants.equalsInteger(param.getStatus(),Constants.ONE)?CmdContants.T30ACmd.do_turn_on:CmdContants.T30ACmd.do_turn_off))
- .replace("$BUSADDR", param.getChannelNo());
- mqttClient = mqttBizService.publish(mqttClient,config,cmdTopic, cmdParamAction);//寮�鍏抽椄鍛戒护
- if(mqttClient ==null){
- throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鎸囦护鍙戦�佸け璐ワ紒");
- }
- MqttClientCache.clientMapCache.put("device"+param.getId(),mqttClient);
- String curremak = "銆�"+param.getLoginUserInfo().getRealname()
- +"銆戜簬"+ DateUtil.getPlusTime2(new Date()) +"杩涜浜�"+(Constants.equalsInteger(param.getStatus(),Constants.ONE)?"銆愬悎闂搞��":"銆愬垎闂搞��")+"鎿嶄綔,寮�鍏炽��"+param.getChannelNo()+"銆戯紱";
- deviceMapper.update(null,new UpdateWrapper<Device>().lambda()
-// .setSql("remark = concat(ifnull(remark,''),'"+curremak+"','\n')")
- .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);
- }
-
- private MqttConfig getMqttConfigByParam(Device model,String index) {
- MqttConfig config = new MqttConfig();
- JSONObject mqtt = new JSONObject();
- if(StringUtils.isBlank(model.getNo())
- ||StringUtils.isBlank(model.getDoorNo()) ){
- throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璁惧鏍囪瘑绗﹀拰璁惧鍙锋湭閰嶇疆锛�");
- }
- if(StringUtils.isNotBlank(model.getDoorName())){
- try {
- //鏂矾鍣ㄨ澶囧弬鏁�
- mqtt = (JSONObject.parseObject(model.getDoorName()));
- }catch (Exception e){
- }
- }
- if(mqtt == null
- ||StringUtils.isBlank(mqtt.getString("mqttUsername"))
- ||StringUtils.isBlank(mqtt.getString("mqttIp"))
- ||StringUtils.isBlank(mqtt.getString("mqttPort"))
- ||StringUtils.isBlank(mqtt.getString("mqttPassword"))){
- throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璁惧mqtt鏈嶅姟鍙傛暟閰嶇疆涓嶆纭紒");
- }
- /**
- * MqttConfig config = (new MqttConfig());
- * config.setHost("tcp://192.168.0.7:1883");
- * config.setClientid("doumee1");
- * config.setPassword("doumee@168");
- * config.setUsername("doumee");
- * config.setVersion("003");
- */
- config.setVersion("003");
- config.setUsername( mqtt.getString("mqttUsername"));
- config.setPassword( mqtt.getString("mqttPassword"));
- config.setHost("tcp://"+ mqtt.getString("mqttIp")+":"+mqtt.getString("mqttPort"));
- config.setClientid(index+model.getId());
- return config;
- }
- public void mqttCallbackService(String topic, MqttMessage message){
- log.error("mqtt鏀跺埌娑堟伅=====topic锛�",topic);
- log.error("mqtt鏀跺埌娑堟伅=====message锛�",JSONObject.toJSONString(message));
- }
- @Override
- public String setBroadcaseBobaoHttp(Device param){
- Device model = deviceMapper.selectById(param.getId());
- if(model ==null && Constants.equalsInteger(param.getType(),Constants.FOUR)){
- throw new BusinessException(ResponseStatus.DATA_EMPTY);
- }
- String input = "";
-
- model.setSendInfo(param.getSendInfo());
- return sendBroadcaseBobaoHttpBiz(model,interfaceLogMapper);
- }
- public static String sendBroadcaseBobaoHttpBiz(Device model,InterfaceLogMapper interfaceLogMapper){
- //閲嶆柊涓嬪彂璁″垝
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("command","start");
- jsonObject.put("TTSContent",model.getSendInfo());
- jsonObject.put("audioLevel",6);
- jsonObject.put("audioVolume",100);
- jsonObject.put("TTSLanguageType","chinese");
- jsonObject.put("voiceType","female");
- jsonObject.put("pace",50);
- JSONArray a = new JSONArray();
- a.add(1);
- jsonObject.put("audioOutID",a);
- String params =jsonObject.toJSONString();
- log.error("========娴峰悍骞挎挱鎾斁鍏ュ弬鍐呭 : " + params);
- String result = HttpsUtil.doPutHk(model.getIp(),Integer.parseInt(StringUtils.defaultString(model.getPort(),"80")),model.getDoorId(), model.getDoorName()
- ,"/ISAPI/AccessControl/EventCardLinkageCfg/TTSAudio?format=json",params);
- log.error("========娴峰悍骞挎挱鎾斁杩斿洖鍐呭 : " + result);
-
- JSONObject resultJson = JSONObject.parseObject(result);
- Boolean success = false;
- if(Constants.equalsInteger(resultJson.getInteger("statusCode"),Constants.ONE)){
- success = true;
- }
- InterfaceLog log = new InterfaceLog();
- log.setCreateDate(new Date());
- log.setUrl("/ISAPI/AccessControl/EventCardLinkageCfg/TTSAudio?format=json");
- log.setEditDate(log.getCreateDate());
- log.setPlat(Constants.ZERO);
- log.setName("娴峰悍骞挎挱鎾斁");
- log.setIsdeleted(Constants.ZERO);
- log.setRequest(params);
- log.setType(Constants.ZERO);
- log.setSuccess(success?Constants.ZERO:Constants.ONE);
- log.setRepose(result);
- interfaceLogMapper.insert(log);
-
-
- return result;
}
@Override
public void setLedContent(TransparentChannelSingleRequest model) {
@@ -599,149 +323,8 @@
}catch (Exception e){
log.error( "瀵逛笉璧凤紝灞忓箷鍐呭璁剧疆寮傚父"+ device.getName());
}
+
}
log.error( "灞忓箷鍐呭璁剧疆=======================缁撴潫========" );
- }
-
-
- /**
- * 鏈嶅姟寮�鍚闃呬换鍔�
- */
- @Override
- public void startCheckDuanluqiSubjob() {
- List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>().lambda()
- .eq(Device::getType,Constants.DEVICE_TYPE.duanluqi)//鏂矾鍣�
- .eq(Device::getIsUsed,Constants.ZERO)
- .eq(Device::getIsdeleted,Constants.ZERO)
- );
- if(devices!=null && devices.size()>0){
- for (Device model : devices){
- try {
- MqttConfig config = getMqttConfigByParam(model,"device_");
- MqttClient mqttClient = MqttClientCache.clientMapCache.get("device"+model.getId());
- String[] topics =new String[]{Constants.MqttTopic.mts_status,
- Constants.MqttTopic.mts_attr,
- Constants.MqttTopic.mts_resp};
- //濡傛灉寮�濮嬩娇鐢紝寮�濮嬭闃�
- mqttClient = mqttBizService.subscribe(mqttClient,config ,topics);
- if(mqttClient ==null){
- throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"寤虹珛杩炴帴澶辫触锛�");
- }
- MqttClientCache.clientMapCache.put("device"+model.getId(),mqttClient);
- log.error("=======寮�濮嬭嚜鍔ㄥ畾浜巑qtt浠诲姟瀹屾垚锛�"+model.getName() );
- }catch (Exception e){
- log.error("=======寮�濮嬭嚜鍔ㄥ畾浜巑qtt浠诲姟澶辫触锛�"+model.getName()+e.getMessage());
- }
- }
-
- }
- }
- /**
- * 鏂矾鍣ㄥ垽鏂槸鍚﹂渶瑕佽繙绋嬪垎闂稿畾浜轰换鍔�
- */
- @Override
- public void autoCloseCmdTimer(){
- if(Constants.DEALING_DUANLUQI_CLOSE){
- return;
- }
- log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒寮�濮�=========");
- Constants.DEALING_DUANLUQI_CLOSE = true;
- try {
- List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>().lambda()
- .eq(Device::getType,Constants.DEVICE_TYPE.duanluqi)//鏂矾鍣�
- .isNotNull(Device::getLevel)//閰嶇疆浜嗙┖闂叉椂闀块檺鍒�
- .isNotNull(Device::getDoorName)//閰嶇疆浜哅QTT鍙傛暟
- .isNotNull(Device::getChannelInfo)//閰嶇疆浜嗘帶鍒跺紑鍏冲簭鍙�
- .eq(Device::getIsUsed,Constants.ZERO)
- .eq(Device::getIsdeleted,Constants.ZERO)
- );
- if(devices!=null && devices.size()>0){
- for(Device device : devices){
- try {
- long time = (long)getNumberByStr(device.getLevel());//鎺у埗鏃堕暱
- if(time < 300 ){
- log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄澶辫触=========绌洪棽鏃堕暱鏈纭厤缃�"+time);
- continue;
- }
- double closeDianliu = getCloseDianliuByParam(device);
- if(closeDianliu < 0 ){
- log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄澶辫触=========绌洪棽鐢垫祦闃堝�艰缃敊璇�"+closeDianliu);
- continue;
- }
- List<String> closeBtn = new ArrayList<>();
- String[] btns = device.getChannelInfo().split(",");
- Date startDate = new Date((System.currentTimeMillis()-time*1000));//鏌ヨ寮�濮嬫椂闂�
- List<DeviceData> dataList = deviceDataMapper.selectList(new QueryWrapper<DeviceData>().lambda()
- .eq(DeviceData::getDataType,Constants.ZERO)
- .eq(DeviceData::getDeviceId,device.getId())
- .in(DeviceData::getVal1,btns)
- .ge(DeviceData::getHappenTime,DateUtil.getPlusTime2(startDate))
- .orderByDesc(DeviceData::getHappenTime));
- if(dataList != null && dataList.size()>0 ){
- for(String b : btns){
- DeviceData last = getLastDataByVal1(b,dataList,closeDianliu);
- if(last !=null && StringUtils.equals(last.getVal7(),"1")){
- closeBtn.add(b);//闇�瑕佸垎闂�
- }
- }
- if(StringUtils.equals( dataList.get(0).getVal7(),"0")){
- log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄缁撴潫======鍒嗛椄鐘舵�佹棤闇�鎿嶄綔==="+device.getName());
- continue;
- }
- }
- if(closeBtn.size()>0){
- Device param = new Device();
- param.setLoginUserInfo(new LoginUserInfo());
- param.getLoginUserInfo().setRealname("绯荤粺鑷姩鎺у埗");
- param.setChannelNo(String.join(",",closeBtn));
- param.setId(device.getId());
- param.setStatus(Constants.ZERO);
- dealDuanluqiCmd(device,param,"deviceTimer_");
- }
- }catch (Exception e){
- log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄澶辫触========="+device.getName()+e.getMessage());
- }
- }
- }
- log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄鏁伴噺========="+devices.size());
- }catch (Exception e){
- log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄寮傚父========="+e.getMessage());
- }finally {
- Constants.DEALING_DUANLUQI_CLOSE = false;
- }
- log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄缁撴潫=========");
- }
-
- private double getCloseDianliuByParam(Device device) {
- try {
- JSONObject json = JSONObject.parseObject(device.getDoorName() );
- return json.getDouble("max");
- }catch (Exception e){
-
- }
- return 0;
- }
-
- private DeviceData getLastDataByVal1(String b, List<DeviceData> dataList,double limit) {
- List<DeviceData> list = new ArrayList<>();
- for(DeviceData d :dataList){
- if(StringUtils.equals(d.getVal1(),b)){
- if(limit <= getNumberByStr(d.getVal2())){
- //濡傛灉鏈夊疄鏃剁數娴佸�煎ぇ浜庣┖闂查槇鍊硷紝鍒欒〃绀哄伐浣滀腑锛屼笉鍋氬鐞�
- return null;
- }
- list.add(d);
- }
- }
- return list.size()>0?list.get(0):null;
- }
-
- private double getNumberByStr(String level) {
- try {
- return Double.parseDouble(level);
- }catch (Exception e){
-
- }
- return 0;
}
}
--
Gitblit v1.9.3