From 269d0db0c285fa05ecc093b7d0579b3bd8057273 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期三, 10 十二月 2025 10:53:51 +0800
Subject: [PATCH] 处理设备消息推送
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java | 132 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 115 insertions(+), 17 deletions(-)
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 de7ca96..d66c345 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,12 +1,20 @@
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;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
+import com.doumee.core.haikang.model.HKConstants;
+import com.doumee.core.haikang.model.param.BaseResponse;
+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.HttpsUtil;
import com.doumee.dao.business.*;
import com.doumee.dao.business.model.*;
+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;
@@ -46,17 +54,29 @@
private SystemDictDataBiz systemDictDataBiz;
@Autowired
private PlatformBroadcastLogMapper platformBroadcastLogMapper;
+ @Autowired
+ private InterfaceLogMapper interfaceLogMapper;
@Override
- public Integer create(Device device) {
- deviceMapper.insert(device);
- return device.getId();
+ public Integer create(Device model) {
+ model.setCreator(model.getLoginUserInfo().getId()+"");
+ model.setEdirot(model.getCreator());
+ model.setIsdeleted(Constants.ZERO);
+ model.setEditDate(new Date());
+ model.setCreateDate(model.getEditDate());
+ deviceMapper.insert(model);
+ return model.getId();
}
@Override
- public void deleteById(Integer id) {
- deviceMapper.deleteById(id);
+ public void deleteById(Integer id, LoginUserInfo userInfo) {
+ Device update = new Device();
+ update.setEdirot(userInfo.getId()+"");
+ update.setEditDate(new Date());
+ update.setIsdeleted(Constants.ONE);
+ update.setId(id);
+ deviceMapper.updateById(update);
}
@Override
@@ -66,15 +86,19 @@
}
@Override
- public void deleteByIdInBatch(List<Integer> ids) {
+ public void deleteByIdInBatch(List<Integer> ids, LoginUserInfo userInfo) {
if (CollectionUtils.isEmpty(ids)) {
return;
}
- deviceMapper.deleteBatchIds(ids);
+ for(Integer id :ids){
+ deleteById(id,userInfo);
+ }
}
@Override
public void updateById(Device device) {
+ device.setEdirot(device.getLoginUserInfo().getId()+"");
+ device.setEditDate(new Date());
deviceMapper.updateById(device);
}
@@ -101,6 +125,7 @@
@Override
public List<Device> findList(Device device) {
+ device.setIsdeleted(Constants.ZERO);
QueryWrapper<Device> wrapper = new QueryWrapper<>(device);
return deviceMapper.selectList(wrapper);
}
@@ -232,6 +257,73 @@
}
@Override
+ public void setBroadcaseBobao(Device model){
+ List<String> ids = new ArrayList<>();
+ ids.add(model.getHkId());
+ CustomBroadcastRequest request = new CustomBroadcastRequest();
+ request.setAudioPointIndexCode(ids);
+ request.setPlayDuration(15);//鍗曚綅绉�
+ request.setBroadCastMode("tts");
+ request.setPriority(1);
+ request.setState(1);//鎾斁/鍋滄鏍囪瘑 1-鎾斁锛�0-鍋滄
+ request.setPlayTtsContent(model.getSendInfo());
+ BaseResponse response = HKService.customBroadcast(request);
+ if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鍙戦�佸け璐ワ細"+ JSONObject.toJSONString(response));
+ }
+ }
+ @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) {
Device device = findById(model.getDeviceId());
if(device == null
@@ -254,7 +346,8 @@
}
}
@Override
- public void setAllLedDefualtContent() {
+ public void allLedDefualtContent() {
+ log.error( "灞忓箷鍐呭璁剧疆=======================寮�濮�========" );
int speed = 13;
try {
speed = Integer.parseInt(systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.LED_CONTENT_SPEED).getCode());
@@ -262,7 +355,7 @@
}
//鎵�鏈夋湀鍙板叧鑱旇澶囦俊鎭�
List<PlatformDevice> list = platformDeviceMapper.selectList(new MPJLambdaWrapper<PlatformDevice>().
- selectAll(PlatformDevice.class)
+ selectAll(PlatformDevice.class)
.selectAs(Platform::getLedContent,PlatformDevice::getLedContent)
.leftJoin(Platform.class,Platform::getId,PlatformDevice::getPlatformId)
.eq(PlatformDevice::getType,Constants.ZERO)
@@ -273,15 +366,20 @@
return;
}
for(PlatformDevice device :list){
- String content = device.getLedContent();
- if(StringUtils.isBlank(content)){
- continue;
- }
- PlatformBroadcastLog log1 = HkSyncPushServiceImpl.dealLedContentBiz(device.getPlatformId(),device.getHkNo(),device.getName(),content,speed,1);
- platformBroadcastLogMapper.insert(log1);
- if(log1.getHkStatus() == null || !Constants.equalsInteger(log1.getHkStatus(), Constants.TWO)){
- log.error( "瀵逛笉璧凤紝灞忓箷鍐呭璁剧疆澶辫触"+(log1!=null?log1.getHkInfo():""));
+ try {
+ String content = device.getLedContent();
+ if(StringUtils.isBlank(content)){
+ continue;
+ }
+ PlatformBroadcastLog log1 = HkSyncPushServiceImpl.dealLedContentBiz(0,device.getHkNo(),device.getName(),content,speed,1);
+ platformBroadcastLogMapper.insert(log1);
+ if(log1.getHkStatus() == null || !Constants.equalsInteger(log1.getHkStatus(), Constants.TWO)){
+ log.error( "瀵逛笉璧凤紝灞忓箷鍐呭璁剧疆澶辫触"+(log1!=null?log1.getHkInfo():""));
+ }
+ }catch (Exception e){
+ log.error( "瀵逛笉璧凤紝灞忓箷鍐呭璁剧疆寮傚父"+ device.getName());
}
}
+ log.error( "灞忓箷鍐呭璁剧疆=======================缁撴潫========" );
}
}
--
Gitblit v1.9.3