|
@@ -5,23 +5,24 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.example.unusualsounds.common.utils.BaiDuUtils;
|
|
|
import com.example.unusualsounds.common.utils.RedisUtils;
|
|
|
import com.example.unusualsounds.common.utils.UUID;
|
|
|
import com.example.unusualsounds.common.utils.VoiceAnalysisUtils;
|
|
|
import com.example.unusualsounds.project.device.entity.DevicesSoundSensors;
|
|
|
import com.example.unusualsounds.project.device.entity.vo.RegisterSoundSensors;
|
|
|
import com.example.unusualsounds.project.device.entity.vo.SoundSensorsQueryVo;
|
|
|
-import com.example.unusualsounds.project.device.service.DevicesSoundSensorsService;
|
|
|
import com.example.unusualsounds.project.device.mapper.DevicesSoundSensorsMapper;
|
|
|
+import com.example.unusualsounds.project.device.service.DevicesSoundSensorsService;
|
|
|
+import com.example.unusualsounds.project.vox.entity.DevicesSoundSensorsList;
|
|
|
import com.example.unusualsounds.project.vox.entity.Skills;
|
|
|
import com.example.unusualsounds.project.vox.service.impl.EdgeOrganizationServiceImpl;
|
|
|
import com.example.unusualsounds.project.vox.service.impl.SkillsServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.http.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.util.Date;
|
|
@@ -34,19 +35,29 @@ import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
/**
|
|
|
-* @author pengc
|
|
|
-* @description 针对表【devices_sound_sensors(设备信息表)】的数据库操作Service实现
|
|
|
-* @createDate 2025-02-21 13:23:08
|
|
|
-*/
|
|
|
+ * @author pengc
|
|
|
+ * @description 针对表【devices_sound_sensors(设备信息表)】的数据库操作Service实现
|
|
|
+ * @createDate 2025-02-21 13:23:08
|
|
|
+ */
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class DevicesSoundSensorsServiceImpl extends ServiceImpl<DevicesSoundSensorsMapper, DevicesSoundSensors>
|
|
|
- implements DevicesSoundSensorsService{
|
|
|
+ implements DevicesSoundSensorsService {
|
|
|
+
|
|
|
+
|
|
|
+ @Value(" ${CENTER_CODE}")
|
|
|
+ private String centerCode;
|
|
|
|
|
|
+ @Value(" ${EDGE_CODE}")
|
|
|
+ private String edgeCode;
|
|
|
+
|
|
|
+ @Value(" ${CENTER_URL}")
|
|
|
+ private String centerUrl;
|
|
|
|
|
|
@Value("${vox.post-analysis-url}")
|
|
|
private String postAnalysisUrl;
|
|
|
|
|
|
+
|
|
|
@Autowired
|
|
|
private SkillsServiceImpl skillsServiceImpl;
|
|
|
|
|
@@ -64,10 +75,10 @@ public class DevicesSoundSensorsServiceImpl extends ServiceImpl<DevicesSoundSens
|
|
|
String s1 = UUID.removeHyphens(s);
|
|
|
|
|
|
QueryWrapper<DevicesSoundSensors> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("file_uuid",s1).last("limit 1");
|
|
|
+ queryWrapper.eq("file_uuid", s1).last("limit 1");
|
|
|
|
|
|
DevicesSoundSensors devicesSoundSensors = baseMapper.selectOne(queryWrapper);
|
|
|
- if (devicesSoundSensors != null){
|
|
|
+ if (devicesSoundSensors != null) {
|
|
|
return devicesSoundSensors.getFileUuid();
|
|
|
}
|
|
|
return s1;
|
|
@@ -75,27 +86,34 @@ public class DevicesSoundSensorsServiceImpl extends ServiceImpl<DevicesSoundSens
|
|
|
|
|
|
@Override
|
|
|
public boolean checkSensorName(String soundSensorName) {
|
|
|
+
|
|
|
+ //中心端不校验重名
|
|
|
+ if (StringUtils.equals(centerCode.trim(), centerUrl.trim())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
QueryWrapper<DevicesSoundSensors> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("name",soundSensorName).last("limit 1");
|
|
|
+ queryWrapper.eq("name", soundSensorName).last("limit 1");
|
|
|
|
|
|
DevicesSoundSensors devicesSoundSensors = baseMapper.selectOne(queryWrapper);
|
|
|
|
|
|
- if (devicesSoundSensors != null){
|
|
|
+ if (devicesSoundSensors != null) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean saveSensor(RegisterSoundSensors soundSensors,String remoteHost) {
|
|
|
+ public boolean saveSensor(RegisterSoundSensors soundSensors) {
|
|
|
|
|
|
DevicesSoundSensors devicesSoundSensors = initSoundSensors();
|
|
|
+ String serviceCode = this.checkServiceCode();
|
|
|
|
|
|
devicesSoundSensors.setName(soundSensors.getSoundSensorName());
|
|
|
devicesSoundSensors.setDeptUuid(soundSensors.getDeptUuid());
|
|
|
|
|
|
- if("file".equals(soundSensors.getSoundSensorType())){
|
|
|
- System.out.println("获取:"+soundSensors.getSoundFileUUid().toString());
|
|
|
+ if ("file".equals(soundSensors.getSoundSensorType())) {
|
|
|
+ System.out.println("获取:" + soundSensors.getSoundFileUUid().toString());
|
|
|
Object o = RedisUtils.get(soundSensors.getSoundFileUUid());
|
|
|
|
|
|
devicesSoundSensors.setStreamUrl(o.toString());
|
|
@@ -103,7 +121,7 @@ public class DevicesSoundSensorsServiceImpl extends ServiceImpl<DevicesSoundSens
|
|
|
devicesSoundSensors.setStatus("online");
|
|
|
devicesSoundSensors.setVideoType("file");
|
|
|
devicesSoundSensors.setFileUuid(soundSensors.getSoundFileUUid());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
devicesSoundSensors.setStreamUrl(soundSensors.getSoundSensorUrl());
|
|
|
devicesSoundSensors.setSrcUrl(soundSensors.getSoundSensorUrl());
|
|
|
devicesSoundSensors.setStatus("offline");
|
|
@@ -112,17 +130,55 @@ public class DevicesSoundSensorsServiceImpl extends ServiceImpl<DevicesSoundSens
|
|
|
HashMap<String, String> organizations = edgeOrganizationServiceImpl.getOrganizations();
|
|
|
|
|
|
devicesSoundSensors.setOrgUuid(organizations.get("orgUuid"));
|
|
|
- devicesSoundSensors.setDepartment("{\"id\":\""+soundSensors.getDeptUuid()+"\",\"name\":\""+soundSensors.getDepartment()+"\"}");
|
|
|
+ devicesSoundSensors.setDepartment("{\"id\":\"" + soundSensors.getDeptUuid() + "\",\"name\":\"" + soundSensors.getDepartment() + "\"}");
|
|
|
devicesSoundSensors.setSkillUuid(soundSensors.getSkillUuid());
|
|
|
- devicesSoundSensors.setIp(remoteHost);
|
|
|
+ devicesSoundSensors.setIp(serviceCode.trim());
|
|
|
devicesSoundSensors.setResponsiblePerson(soundSensors.getResponsiblePerson());
|
|
|
devicesSoundSensors.setDescription(soundSensors.getDescription());
|
|
|
|
|
|
- int insert = baseMapper.insert(devicesSoundSensors);
|
|
|
- RedisUtils.delete(soundSensors.getSoundFileUUid());
|
|
|
- //对文件进行立刻通知算法解析(如果是文件类型,通知算法解析)
|
|
|
+ //当前为中心端接入,直接插入
|
|
|
+ Boolean isFlag = false;
|
|
|
+ log.info("insert ----> centerCode:{},edgeCode:{}", centerCode, edgeCode);
|
|
|
+// if (StringUtils.equals(centerCode, edgeCode)) {
|
|
|
+ if (centerCode.trim().equals(edgeCode.trim())) {
|
|
|
+ log.info("当前为中心端接入,直接插入");
|
|
|
+ if (null != soundSensors.getSoundSensorIp() && StringUtils.isNotBlank(soundSensors.getSoundSensorIp())) {
|
|
|
+ devicesSoundSensors.setIp(soundSensors.getSoundSensorIp().trim());
|
|
|
+ } else {
|
|
|
+ devicesSoundSensors.setIp(centerCode.trim());
|
|
|
+ }
|
|
|
+ if (null != soundSensors.getSoundSensorUuid() && StringUtils.isNotBlank(soundSensors.getSoundSensorUuid())) {
|
|
|
+ devicesSoundSensors.setUuid(soundSensors.getSoundSensorUuid());
|
|
|
+ } else {
|
|
|
+ devicesSoundSensors.setUuid(UUID.generateUUIDWithoutHyphens());
|
|
|
+ }
|
|
|
+ int insert = baseMapper.insert(devicesSoundSensors);
|
|
|
+ RedisUtils.delete(soundSensors.getSoundFileUUid());
|
|
|
+ if (insert > 0) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //当前为边端,先插入中心再插入本地
|
|
|
+ log.info("当前为边端,先插入中心再插入本地");
|
|
|
+ String url = centerUrl + "voiceSer/uploadSensors";
|
|
|
+ log.info("to center url:{}", url);
|
|
|
+ try {
|
|
|
+ soundSensors.setSoundSensorUuid(devicesSoundSensors.getUuid());
|
|
|
+ soundSensors.setSoundSensorIp(devicesSoundSensors.getIp().trim());
|
|
|
+ isFlag = this.insertSensors(url, devicesSoundSensors, soundSensors, soundSensors.getSoundFileUUid());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("设备插入失败 e:{}", e);
|
|
|
+ isFlag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- if("file".equals(soundSensors.getSoundSensorType())){
|
|
|
+ //对文件进行立刻通知算法解析(如果是文件类型,通知算法解析)
|
|
|
+ if ("file".equals(soundSensors.getSoundSensorType())) {
|
|
|
+ log.info("对文件进行立刻通知算法解析(如果是文件类型,通知算法解析) start");
|
|
|
// QueryWrapper<Skills> skillsQueryWrapper = new QueryWrapper<>();
|
|
|
// skillsQueryWrapper.eq("uuid",soundSensors.getSkillUuid()).last("limit 1");
|
|
|
// Skills skills = skillsServiceImpl.getBaseMapper().selectOne(skillsQueryWrapper);
|
|
@@ -133,69 +189,160 @@ public class DevicesSoundSensorsServiceImpl extends ServiceImpl<DevicesSoundSens
|
|
|
for (Skills skills : skillByName) {
|
|
|
if (skills.getUuid().equals(soundSensors.getSkillUuid())) skillName = skills.getName();
|
|
|
}
|
|
|
- this.analysisSoundFile(devicesSoundSensors.getSrcUrl(),skillName, devicesSoundSensors.getUuid(),
|
|
|
- devicesSoundSensors.getName(),soundSensors.getSkillUuid());
|
|
|
- }
|
|
|
- if (insert > 0){
|
|
|
- return true;
|
|
|
- }else {
|
|
|
- return false;
|
|
|
+ this.analysisSoundFile(devicesSoundSensors.getSrcUrl(), skillName, devicesSoundSensors.getUuid(),
|
|
|
+ devicesSoundSensors.getName(), soundSensors.getSkillUuid());
|
|
|
+
|
|
|
+ log.info("对文件进行立刻通知算法解析(如果是文件类型,通知算法解析) end");
|
|
|
}
|
|
|
+ return isFlag;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public boolean updateSensorSkill(RegisterSoundSensors soundSensors) {
|
|
|
|
|
|
- UpdateWrapper<DevicesSoundSensors> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.eq("uuid",soundSensors.getSoundSensorUuid())
|
|
|
- .set("skill_uuid",soundSensors.getSkillUuid());
|
|
|
- int update = baseMapper.update(null, updateWrapper);
|
|
|
- if (update > 0){
|
|
|
- return true;
|
|
|
+ try {
|
|
|
+ Boolean isFlag = false;
|
|
|
+ //当前为边端时
|
|
|
+ log.info("当前端 centerCode:{},edgeCode:{}", centerCode, edgeCode);
|
|
|
+ if (!StringUtils.equals(centerCode.trim(), edgeCode.trim())) {
|
|
|
+// log.info("当前为中心端");
|
|
|
+ log.info("当前为边缘端");
|
|
|
+ String url = centerUrl.trim() + "voiceSer/uploadSensors";
|
|
|
+ log.info("updateSensorSkill url:{}", url);
|
|
|
+ isFlag = VoiceAnalysisUtils.postCenterSensorsUp(url, soundSensors);
|
|
|
+ } else {
|
|
|
+ isFlag = true;
|
|
|
+ log.info("当前为中心端");
|
|
|
+ }
|
|
|
+ if (isFlag) {
|
|
|
+ log.info("中心端更新成功,解析来嗯行边缘端");
|
|
|
+ } else {
|
|
|
+ log.info("中心端更新失败");
|
|
|
+ log.error("中心端 更新技能失败,进行回滚");
|
|
|
+ throw new RuntimeException("中心端 更新技能失败");
|
|
|
+ }
|
|
|
+ UpdateWrapper<DevicesSoundSensors> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.eq("uuid", soundSensors.getSoundSensorUuid())
|
|
|
+ .set("skill_uuid", soundSensors.getSkillUuid());
|
|
|
+ int update = baseMapper.update(null, updateWrapper);
|
|
|
+ if (update > 0 && isFlag) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+// if (update > 0 && isFlag) return true;
|
|
|
+// return false;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("更新技能失败,进行回滚");
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Integer delSensor(List<String> sensorUuids) {
|
|
|
+// @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean delSensor(List<String> sensorUuids) {
|
|
|
|
|
|
- QueryWrapper<DevicesSoundSensors> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.in("uuid",sensorUuids);
|
|
|
+ try {
|
|
|
+ Boolean isFlag = false;
|
|
|
+ for (String sensorUuid : sensorUuids) {
|
|
|
+ Map<String, Object> delMap = new HashMap<>();
|
|
|
+ delMap.put("uuid", sensorUuid);
|
|
|
+ List<DevicesSoundSensors> devicesSoundSensors = baseMapper.selectByMap(delMap);
|
|
|
+ if (devicesSoundSensors.size() <= 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //当为边端时
|
|
|
+ log.info("当前端 centerCode:{},edgeCode:{}", centerCode, edgeCode);
|
|
|
+ if (!StringUtils.equals(centerCode.trim(), edgeCode.trim())) {
|
|
|
+ String url = centerUrl.trim() + "voiceSer/delSensor";
|
|
|
+ log.info("当前为边缘端 url:{}", url);
|
|
|
+ isFlag = VoiceAnalysisUtils.postCenterSensorsUp(url, sensorUuids);
|
|
|
+
|
|
|
+ if (isFlag) {
|
|
|
+ log.info("中心端删除成功,接下来执行边缘端");
|
|
|
+ } else {
|
|
|
+ log.info("中心端删除失败");
|
|
|
+ log.error("中心端 删除失败,进行回滚");
|
|
|
+ throw new RuntimeException("中心端 删除失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ isFlag = true;
|
|
|
+ log.info("当前为中心端");
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<DevicesSoundSensors> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.in("uuid", sensorUuids);
|
|
|
+ int delete = baseMapper.delete(queryWrapper);
|
|
|
+ if (delete > 0 && isFlag) return true;
|
|
|
+ return false;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备删除失败,进行回滚");
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
|
|
|
- int delete = baseMapper.delete(queryWrapper);
|
|
|
|
|
|
- return delete;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<DevicesSoundSensors> getSensorList(SoundSensorsQueryVo soundSensorsQueryVo,String remoteHost) {
|
|
|
+ public DevicesSoundSensorsList getSensorList(SoundSensorsQueryVo soundSensorsQueryVo) {
|
|
|
|
|
|
Page<DevicesSoundSensors> sensorsPage = new Page<>(soundSensorsQueryVo.getPageNum(), soundSensorsQueryVo.getPageSize());
|
|
|
|
|
|
QueryWrapper<DevicesSoundSensors> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
- if (soundSensorsQueryVo.getName() != null && !"".equals(soundSensorsQueryVo.getName())){
|
|
|
- queryWrapper.like("name",soundSensorsQueryVo.getName());
|
|
|
+ if (soundSensorsQueryVo.getName() != null && !"".equals(soundSensorsQueryVo.getName())) {
|
|
|
+ queryWrapper.like("name", soundSensorsQueryVo.getName());
|
|
|
}
|
|
|
- if (soundSensorsQueryVo.getStatus() != null && !"".equals(soundSensorsQueryVo.getStatus())){
|
|
|
- queryWrapper.eq("status",soundSensorsQueryVo.getStatus());
|
|
|
+ if (soundSensorsQueryVo.getStatus() != null && !"".equals(soundSensorsQueryVo.getStatus())) {
|
|
|
+ queryWrapper.eq("status", soundSensorsQueryVo.getStatus());
|
|
|
}
|
|
|
- if(soundSensorsQueryVo.getDeptUuid() != null && !"".equals(soundSensorsQueryVo.getDeptUuid())){
|
|
|
- queryWrapper.eq("dept_uuid",soundSensorsQueryVo.getDeptUuid());
|
|
|
+ if (soundSensorsQueryVo.getDeptUuid() != null && !"".equals(soundSensorsQueryVo.getDeptUuid())) {
|
|
|
+ queryWrapper.eq("dept_uuid", soundSensorsQueryVo.getDeptUuid());
|
|
|
}
|
|
|
- if(remoteHost != null && !"".equals(remoteHost)){
|
|
|
- queryWrapper.eq("ip",remoteHost);
|
|
|
+ // todo ghjghj
|
|
|
+ log.info("------>centerCode:{},edgeCode:{}", centerCode, edgeCode);
|
|
|
+ boolean equalsCode = StringUtils.equals(centerCode.trim(), edgeCode.trim());
|
|
|
+ if (!equalsCode) {
|
|
|
+ log.info("----> ip:{}", this.checkServiceCode());
|
|
|
+ queryWrapper.eq("ip", this.checkServiceCode().trim());
|
|
|
}
|
|
|
+ // todo ghjghj
|
|
|
+ queryWrapper.orderByDesc("id");
|
|
|
IPage<DevicesSoundSensors> page = baseMapper.selectPage(sensorsPage, queryWrapper);
|
|
|
- return page;
|
|
|
+// if (!StringUtils.equals(centerCode.trim(), edgeCode.trim())) {
|
|
|
+// log.info("当前列表为边缘端");
|
|
|
+// DevicesSoundSensorsList devicesSoundSensorsList = DevicesSoundSensorsList.builder()
|
|
|
+// .edgeName(edgeCode.trim()).soundSensors(page).build();
|
|
|
+// return devicesSoundSensorsList;
|
|
|
+// }else {
|
|
|
+// log.info("当前列表为中心端");
|
|
|
+// DevicesSoundSensorsList devicesSoundSensorsList = DevicesSoundSensorsList.builder()
|
|
|
+// .edgeName(centerCode.trim()).soundSensors(page).build();
|
|
|
+// return devicesSoundSensorsList;
|
|
|
+// }
|
|
|
+ DevicesSoundSensorsList devicesSoundSensorsList = DevicesSoundSensorsList.builder()
|
|
|
+ .edgeName(checkServiceCode()).soundSensors(page).build();
|
|
|
+ return devicesSoundSensorsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean selBySensorUuid(String uuid) {
|
|
|
+ Map<String, Object> selMap = new HashMap<>();
|
|
|
+ selMap.put("uuid", uuid);
|
|
|
+ List<DevicesSoundSensors> devicesSoundSensors = baseMapper.selectByMap(selMap);
|
|
|
+ return devicesSoundSensors.size() > 0 ? true : false;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 初始化声音传感器部分基本信息
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- public DevicesSoundSensors initSoundSensors(){
|
|
|
+ public DevicesSoundSensors initSoundSensors() {
|
|
|
|
|
|
DevicesSoundSensors devicesSoundSensors = new DevicesSoundSensors();
|
|
|
devicesSoundSensors.setUuid(UUID.generateUUIDWithoutHyphens());
|
|
@@ -225,9 +372,10 @@ public class DevicesSoundSensorsServiceImpl extends ServiceImpl<DevicesSoundSens
|
|
|
|
|
|
/**
|
|
|
* 通知算法对声音文件进行解析
|
|
|
+ *
|
|
|
* @param
|
|
|
*/
|
|
|
- public void analysisSoundFile(String filePath,String skillName,String streamId,String deviceName,String skillId) {
|
|
|
+ public void analysisSoundFile(String filePath, String skillName, String streamId, String deviceName, String skillId) {
|
|
|
|
|
|
//同时支持20个用户上传文件解析
|
|
|
ExecutorService executorService = Executors.newFixedThreadPool(20);
|
|
@@ -236,25 +384,75 @@ public class DevicesSoundSensorsServiceImpl extends ServiceImpl<DevicesSoundSens
|
|
|
log.info("通知算法解析用户自定义上传文件");
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("filePath",filePath);
|
|
|
- map.put("skillName",skillName);
|
|
|
- map.put("streamId",streamId);
|
|
|
- map.put("deviceName",deviceName);
|
|
|
- map.put("skillId",skillId);
|
|
|
+ map.put("filePath", filePath);
|
|
|
+ map.put("skillName", skillName);
|
|
|
+ map.put("streamId", streamId + "_" + skillName);
|
|
|
+ map.put("deviceName", deviceName);
|
|
|
+ map.put("skillId", skillId);
|
|
|
+
|
|
|
+ map.forEach(
|
|
|
+ (k, v) -> System.out.println(k + ":" + v)
|
|
|
+ );
|
|
|
|
|
|
log.info(VoiceAnalysisUtils.postVoxAnalysis(map, postAnalysisUrl));
|
|
|
|
|
|
- },executorService);
|
|
|
+ }, executorService);
|
|
|
try {
|
|
|
future.get();
|
|
|
|
|
|
executorService.shutdown();
|
|
|
} catch (InterruptedException e) {
|
|
|
+ log.info("通知算法对声音文件进行解析 InterruptedException:{}", e);
|
|
|
throw new RuntimeException(e);
|
|
|
} catch (ExecutionException e) {
|
|
|
+ log.info("通知算法对声音文件进行解析 ExecutionException:{}", e);
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对比code,区分当前端是中心端还是边端
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String checkServiceCode() {
|
|
|
+
|
|
|
+ if (StringUtils.equals(centerCode.trim(), edgeCode.trim())) {
|
|
|
+ return centerCode.trim();
|
|
|
+ } else {
|
|
|
+ return edgeCode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 事务回滚
|
|
|
+ *
|
|
|
+ * @param url
|
|
|
+ * @param devicesSoundSensors
|
|
|
+ * @param soundFileUUid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public Boolean insertSensors(String url, DevicesSoundSensors devicesSoundSensors, RegisterSoundSensors soundSensors, String soundFileUUid) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ // todo ghjghj
|
|
|
+ Boolean aBoolean = VoiceAnalysisUtils.postCenterSensorsUp(url, soundSensors);
|
|
|
+ if (!aBoolean) {
|
|
|
+ throw new RuntimeException("插入中心端异常");
|
|
|
+ }
|
|
|
+ int insert = baseMapper.insert(devicesSoundSensors);
|
|
|
+ if (insert < 0) {
|
|
|
+ throw new RuntimeException("插入边端异常");
|
|
|
+ }
|
|
|
+ RedisUtils.delete(soundFileUUid);
|
|
|
+ if (aBoolean && insert > 0) return true;
|
|
|
+ return false;
|
|
|
+ } catch (RuntimeException e) {
|
|
|
+ log.error("插入数据库失败,进行回滚 e:{}", e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|