parent
3265568e69
commit
e15a249caf
|
|
@ -13,7 +13,8 @@ public interface BusinessConstant {
|
||||||
String ROUTE_KMZ_BUCKET = "route-kmz";//航线桶
|
String ROUTE_KMZ_BUCKET = "route-kmz";//航线桶
|
||||||
String DOCK_MEDIA_BUCKET = "dock-media";//机库回传媒体桶
|
String DOCK_MEDIA_BUCKET = "dock-media";//机库回传媒体桶
|
||||||
String REMOTE_LOG_BUCKET = "remote-log";//机库回传媒体桶
|
String REMOTE_LOG_BUCKET = "remote-log";//机库回传媒体桶
|
||||||
String DEVICE_FIRMWARE_BUCKET = "device-firmware";
|
String DEVICE_FIRMWARE_BUCKET = "device-firmware";//设备固件桶
|
||||||
|
String SPEAKER_AUDIO_BUCKET = "speaker-audio";//喊话器音频桶
|
||||||
|
|
||||||
//********************************* route action *********************************//
|
//********************************* route action *********************************//
|
||||||
String DEFAULT_ACTION_TRIGGER_TYPE = "reachPoint";//默认动作触发器类型 到达航点执行
|
String DEFAULT_ACTION_TRIGGER_TYPE = "reachPoint";//默认动作触发器类型 到达航点执行
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,15 @@ public class MinioController {
|
||||||
|
|
||||||
return new Result<String>().ok(minioService.uploadRouteImg(dockSn, file));
|
return new Result<String>().ok(minioService.uploadRouteImg(dockSn, file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "上传喊话器音频文件")
|
||||||
|
@PostMapping("/uploadSpeakerAudio/{dockSn}")
|
||||||
|
public Result<String> uploadSpeakerAudio(@PathVariable String dockSn,
|
||||||
|
@RequestParam("file") MultipartFile file) {
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
return new Result<String>().error(ErrorCode.UPLOAD_FILE_EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Result<String>().ok(minioService.uploadSpeakerAudio(dockSn, file));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,12 +71,23 @@ public class PsdkController {
|
||||||
@PostMapping("/startSpeakerTts/{dockSn}")
|
@PostMapping("/startSpeakerTts/{dockSn}")
|
||||||
@Operation(summary = "播放TTS文本")
|
@Operation(summary = "播放TTS文本")
|
||||||
@RequiresPermissions("bus:speaker:startSpeakerTts")
|
@RequiresPermissions("bus:speaker:startSpeakerTts")
|
||||||
public Result<Object> drcSetTts(@PathVariable String dockSn, @RequestBody TtsText ttsText) {
|
public Result<Object> startSpeakerTts(@PathVariable String dockSn, @RequestBody TtsText ttsText) {
|
||||||
ValidatorUtils.validateEntity(ttsText);
|
ValidatorUtils.validateEntity(ttsText);
|
||||||
|
|
||||||
return new Result<>().ok(psdkService.startSpeakerTts(dockSn, ttsText));
|
return new Result<>().ok(psdkService.startSpeakerTts(dockSn, ttsText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@LogOperation("播放模板文本")
|
||||||
|
@PostMapping("/startSpeakerTemplate/{dockSn}")
|
||||||
|
@Operation(summary = "播放模板文本")
|
||||||
|
@RequiresPermissions("bus:speaker:startSpeakerTemplate")
|
||||||
|
public Result<Object> startSpeakerTemplate(@PathVariable String dockSn,
|
||||||
|
@Parameter(name = "id", description = "模版编号")
|
||||||
|
@RequestParam Long id) {
|
||||||
|
|
||||||
|
return new Result<>().ok(psdkService.startSpeakerTemplate(dockSn, id));
|
||||||
|
}
|
||||||
|
|
||||||
@LogOperation("播放音频文件")
|
@LogOperation("播放音频文件")
|
||||||
@PostMapping("/playAudio/{dockSn}")
|
@PostMapping("/playAudio/{dockSn}")
|
||||||
@Operation(summary = "播放音频文件")
|
@Operation(summary = "播放音频文件")
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,24 @@ package com.multictrl.modules.business.controller;
|
||||||
|
|
||||||
import com.multictrl.common.annotation.ApiOrder;
|
import com.multictrl.common.annotation.ApiOrder;
|
||||||
import com.multictrl.common.annotation.LogOperation;
|
import com.multictrl.common.annotation.LogOperation;
|
||||||
|
import com.multictrl.common.constant.Constant;
|
||||||
|
import com.multictrl.common.page.PageData;
|
||||||
import com.multictrl.common.utils.Result;
|
import com.multictrl.common.utils.Result;
|
||||||
import com.multictrl.common.validator.ValidatorUtils;
|
import com.multictrl.common.validator.ValidatorUtils;
|
||||||
|
import com.multictrl.modules.business.dto.SpeakerDTO;
|
||||||
import com.multictrl.modules.business.dto.speaker.SpeakerSet;
|
import com.multictrl.modules.business.dto.speaker.SpeakerSet;
|
||||||
import com.multictrl.modules.business.dto.speaker.TtsText;
|
import com.multictrl.modules.business.dto.speaker.TtsText;
|
||||||
import com.multictrl.modules.business.service.SpeakerService;
|
import com.multictrl.modules.business.service.SpeakerService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 喊话器控制 大疆官方AS1喊话器
|
* 喊话器控制 大疆官方AS1喊话器
|
||||||
*
|
*
|
||||||
|
|
@ -28,6 +34,43 @@ import org.springframework.web.bind.annotation.*;
|
||||||
public class SpeakerController {
|
public class SpeakerController {
|
||||||
private final SpeakerService speakerService;
|
private final SpeakerService speakerService;
|
||||||
|
|
||||||
|
@GetMapping("page")
|
||||||
|
@Operation(summary = "分页")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始"),
|
||||||
|
@Parameter(name = Constant.LIMIT, description = "每页显示记录数"),
|
||||||
|
@Parameter(name = "type", description = "类型 1:文本 2:音频"),
|
||||||
|
@Parameter(name = "dockSn", description = "机库SN码")
|
||||||
|
})
|
||||||
|
@RequiresPermissions("bus:speaker:page")
|
||||||
|
public Result<PageData<SpeakerDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||||
|
PageData<SpeakerDTO> page = speakerService.page(params);
|
||||||
|
|
||||||
|
return new Result<PageData<SpeakerDTO>>().ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@LogOperation("添加喊话模版")
|
||||||
|
@PostMapping("/addTemplate")
|
||||||
|
@Operation(summary = "添加喊话模版")
|
||||||
|
@RequiresPermissions("bus:speaker:addTemplate")
|
||||||
|
public Result<Object> addTemplate(@RequestBody SpeakerDTO speaker) {
|
||||||
|
ValidatorUtils.validateEntity(speaker);
|
||||||
|
speakerService.addTemplate(speaker);
|
||||||
|
|
||||||
|
return new Result<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@LogOperation("删除模版")
|
||||||
|
@DeleteMapping("/deleteTemplate")
|
||||||
|
@Operation(summary = "删除模版")
|
||||||
|
@RequiresPermissions("bus:speaker:deleteTemplate")
|
||||||
|
public Result<Object> deleteTemplate(@Parameter(name = "id", description = "模版编号")
|
||||||
|
@RequestParam Long id) {
|
||||||
|
speakerService.deleteTemplate(id);
|
||||||
|
|
||||||
|
return new Result<>();
|
||||||
|
}
|
||||||
|
|
||||||
@LogOperation("设置音量")
|
@LogOperation("设置音量")
|
||||||
@PostMapping("/drcSetVolume/{dockSn}")
|
@PostMapping("/drcSetVolume/{dockSn}")
|
||||||
@Operation(summary = "设置音量")
|
@Operation(summary = "设置音量")
|
||||||
|
|
@ -82,9 +125,20 @@ public class SpeakerController {
|
||||||
@PostMapping("/drcStartSpeakerTts/{dockSn}")
|
@PostMapping("/drcStartSpeakerTts/{dockSn}")
|
||||||
@Operation(summary = "播放TTS文本")
|
@Operation(summary = "播放TTS文本")
|
||||||
@RequiresPermissions("bus:speaker:drcStartSpeakerTts")
|
@RequiresPermissions("bus:speaker:drcStartSpeakerTts")
|
||||||
public Result<Object> drcSetTts(@PathVariable String dockSn, @RequestBody TtsText ttsText) {
|
public Result<Object> drcStartSpeakerTts(@PathVariable String dockSn, @RequestBody TtsText ttsText) {
|
||||||
ValidatorUtils.validateEntity(ttsText);
|
ValidatorUtils.validateEntity(ttsText);
|
||||||
|
|
||||||
return new Result<>().ok(speakerService.drcStartSpeakerTts(dockSn, ttsText));
|
return new Result<>().ok(speakerService.drcStartSpeakerTts(dockSn, ttsText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@LogOperation("播放模板文本")
|
||||||
|
@PostMapping("/drcStartSpeakerTemplate/{dockSn}")
|
||||||
|
@Operation(summary = "播放模板文本")
|
||||||
|
@RequiresPermissions("bus:speaker:drcStartSpeakerTemplate")
|
||||||
|
public Result<Object> drcStartSpeakerTemplate(@PathVariable String dockSn,
|
||||||
|
@Parameter(name = "id", description = "模版编号")
|
||||||
|
@RequestParam Long id) {
|
||||||
|
|
||||||
|
return new Result<>().ok(speakerService.drcStartSpeakerTemplate(dockSn, id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
package com.multictrl.modules.business.dto;
|
package com.multictrl.modules.business.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -10,39 +14,62 @@ import java.util.Date;
|
||||||
/**
|
/**
|
||||||
* 喊话器内容
|
* 喊话器内容
|
||||||
*
|
*
|
||||||
* @author Sdy
|
* @author Sdy
|
||||||
* @since 1.0.0 2026-05-08
|
* @since 1.0.0 2026-05-08
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(name = "喊话器内容")
|
@Schema(name = "喊话器内容")
|
||||||
public class SpeakerDTO implements Serializable {
|
public class SpeakerDTO implements Serializable {
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(name = "主键")
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
private Long id;
|
@Schema(name = "标识")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
@Schema(name = "类型 1 文本 2 音频")
|
@NotNull(message = "类型不能为空")
|
||||||
private Integer type;
|
@Min(value = 1, message = "类型错误")
|
||||||
|
@Max(value = 2, message = "类型错误")
|
||||||
|
@Schema(name = "类型 1:文本 2:音频")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
@Schema(name = "机场编号")
|
@NotBlank(message = "机场编号不能为空")
|
||||||
private String dockSn;
|
@Schema(name = "机场编号")
|
||||||
|
private String dockSn;
|
||||||
|
|
||||||
@Schema(name = "模版名称")
|
@NotBlank(message = "模版名称不能为空")
|
||||||
private String name;
|
@Schema(name = "模版名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
@Schema(name = "文本内容")
|
@Schema(name = "文本内容")
|
||||||
private String textContent;
|
private String textContent;
|
||||||
|
|
||||||
@Schema(name = "pcm音频地址")
|
@Schema(name = "源音频文件地址")
|
||||||
private String pcmPath;
|
private String mediaPath;
|
||||||
|
|
||||||
@Schema(name = "源音频文件地址")
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
private String mediaPath;
|
@Schema(name = "创建时间")
|
||||||
|
private Date createDate;
|
||||||
|
|
||||||
@Schema(name = "文件md5")
|
@JsonIgnore
|
||||||
private String md5;
|
@Schema(hidden = true)
|
||||||
|
@AssertTrue(message = "源音频文件不能为空")
|
||||||
|
public boolean isMediaPathValid() {
|
||||||
|
if (type == 2) {
|
||||||
|
return StringUtils.isNotBlank(mediaPath);
|
||||||
|
}
|
||||||
|
|
||||||
@Schema(name = "创建时间")
|
return true;
|
||||||
private Date createDate;
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Schema(hidden = true)
|
||||||
|
@AssertTrue(message = "文本内容不能为空")
|
||||||
|
public boolean isTextContentValid() {
|
||||||
|
if (type == 1) {
|
||||||
|
return StringUtils.isNotBlank(textContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,4 +36,7 @@ public interface MinioService {
|
||||||
|
|
||||||
//上传固件
|
//上传固件
|
||||||
String uploadFirmware(InputStream inputStream, String deviceName, String originalFilename);
|
String uploadFirmware(InputStream inputStream, String deviceName, String originalFilename);
|
||||||
|
|
||||||
|
//上传喊话器音频文件
|
||||||
|
String uploadSpeakerAudio(String dockSn, MultipartFile file);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ public interface PsdkService {
|
||||||
//播放TTS文本
|
//播放TTS文本
|
||||||
String startSpeakerTts(String dockSn, TtsText ttsText);
|
String startSpeakerTts(String dockSn, TtsText ttsText);
|
||||||
|
|
||||||
|
//播放模板文本
|
||||||
|
String startSpeakerTemplate(String dockSn, Long id);
|
||||||
|
|
||||||
//播放音频文件
|
//播放音频文件
|
||||||
String playAudio(String dockSn, Long id);
|
String playAudio(String dockSn, Long id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
package com.multictrl.modules.business.service;
|
package com.multictrl.modules.business.service;
|
||||||
|
|
||||||
|
import com.multictrl.common.page.PageData;
|
||||||
import com.multictrl.common.service.CrudService;
|
import com.multictrl.common.service.CrudService;
|
||||||
|
import com.multictrl.modules.business.dao.SpeakerDao;
|
||||||
import com.multictrl.modules.business.dto.SpeakerDTO;
|
import com.multictrl.modules.business.dto.SpeakerDTO;
|
||||||
import com.multictrl.modules.business.dto.speaker.SpeakerSet;
|
import com.multictrl.modules.business.dto.speaker.SpeakerSet;
|
||||||
import com.multictrl.modules.business.dto.speaker.TtsText;
|
import com.multictrl.modules.business.dto.speaker.TtsText;
|
||||||
import com.multictrl.modules.business.entity.SpeakerEntity;
|
import com.multictrl.modules.business.entity.SpeakerEntity;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 喊话器控制
|
* 喊话器控制
|
||||||
*
|
*
|
||||||
|
|
@ -14,6 +18,12 @@ import com.multictrl.modules.business.entity.SpeakerEntity;
|
||||||
*/
|
*/
|
||||||
public interface SpeakerService extends CrudService<SpeakerEntity, SpeakerDTO> {
|
public interface SpeakerService extends CrudService<SpeakerEntity, SpeakerDTO> {
|
||||||
|
|
||||||
|
//添加喊话模版
|
||||||
|
void addTemplate(SpeakerDTO speaker);
|
||||||
|
|
||||||
|
//删除模板
|
||||||
|
void deleteTemplate(Long id);
|
||||||
|
|
||||||
// 设置音量
|
// 设置音量
|
||||||
String drcSetVolume(String dockSn, Integer volume);
|
String drcSetVolume(String dockSn, Integer volume);
|
||||||
|
|
||||||
|
|
@ -31,4 +41,10 @@ public interface SpeakerService extends CrudService<SpeakerEntity, SpeakerDTO> {
|
||||||
|
|
||||||
//播放TTS文本
|
//播放TTS文本
|
||||||
String drcStartSpeakerTts(String dockSn, TtsText ttsText);
|
String drcStartSpeakerTts(String dockSn, TtsText ttsText);
|
||||||
|
|
||||||
|
//播放模板文本
|
||||||
|
String drcStartSpeakerTemplate(String dockSn, Long id);
|
||||||
|
|
||||||
|
//获取dao
|
||||||
|
SpeakerDao getDao();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,20 @@ public class MinioServiceImpl implements MinioService {
|
||||||
return BusinessConstant.DEVICE_FIRMWARE_BUCKET + "/" + path;
|
return BusinessConstant.DEVICE_FIRMWARE_BUCKET + "/" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadSpeakerAudio(String dockSn, MultipartFile file) {
|
||||||
|
//文件路径
|
||||||
|
String path = dockSn + "/" + DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN_COMPACT) + "." + FileNameUtil.extName(file.getOriginalFilename());
|
||||||
|
try {
|
||||||
|
uploadFile(file.getInputStream(), BusinessConstant.SPEAKER_AUDIO_BUCKET, path);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(ExceptionUtils.getErrorStackTrace(e));
|
||||||
|
throw new RenException(ErrorCode.OSS_UPLOAD_FILE_ERROR, file.getOriginalFilename());
|
||||||
|
}
|
||||||
|
|
||||||
|
return BusinessConstant.SPEAKER_AUDIO_BUCKET + "/" + path;
|
||||||
|
}
|
||||||
|
|
||||||
private String getMimeType(String fileName) {
|
private String getMimeType(String fileName) {
|
||||||
if (fileName == null) return "application/octet-stream";
|
if (fileName == null) return "application/octet-stream";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import com.multictrl.common.utils.CacheUtils;
|
||||||
import com.multictrl.common.utils.Utils;
|
import com.multictrl.common.utils.Utils;
|
||||||
import com.multictrl.modules.business.dto.SpeakerDTO;
|
import com.multictrl.modules.business.dto.SpeakerDTO;
|
||||||
import com.multictrl.modules.business.dto.speaker.TtsText;
|
import com.multictrl.modules.business.dto.speaker.TtsText;
|
||||||
|
import com.multictrl.modules.business.entity.SpeakerEntity;
|
||||||
import com.multictrl.modules.business.service.DJIBaseService;
|
import com.multictrl.modules.business.service.DJIBaseService;
|
||||||
import com.multictrl.modules.business.service.PsdkService;
|
import com.multictrl.modules.business.service.PsdkService;
|
||||||
import com.multictrl.modules.business.service.SpeakerService;
|
import com.multictrl.modules.business.service.SpeakerService;
|
||||||
|
|
@ -72,9 +73,21 @@ public class PsdkServiceImpl implements PsdkService {
|
||||||
return djiBaseService.executeAndReturnResult(dockSn, "speaker_tts_play_start", data);
|
return djiBaseService.executeAndReturnResult(dockSn, "speaker_tts_play_start", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String startSpeakerTemplate(String dockSn, Long id) {
|
||||||
|
SpeakerEntity speakerEntity = speakerService.selectById(id);
|
||||||
|
if (speakerEntity == null || speakerEntity.getType() != 1) {
|
||||||
|
throw new RenException(ErrorCode.PARAMS_ERROR);
|
||||||
|
}
|
||||||
|
TtsText ttsText = new TtsText();
|
||||||
|
ttsText.setName(speakerEntity.getName());
|
||||||
|
ttsText.setText(speakerEntity.getTextContent());
|
||||||
|
return startSpeakerTts(dockSn, ttsText);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String playAudio(String dockSn, Long id) {
|
public String playAudio(String dockSn, Long id) {
|
||||||
SpeakerDTO speaker = speakerService.get(id);
|
SpeakerEntity speaker = speakerService.getDao().selectById(id);
|
||||||
if (speaker == null || speaker.getType() != 2) {
|
if (speaker == null || speaker.getType() != 2) {
|
||||||
throw new RenException(ErrorCode.PARAMS_ERROR);
|
throw new RenException(ErrorCode.PARAMS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +96,11 @@ public class PsdkServiceImpl implements PsdkService {
|
||||||
file.set("format", "pcm");
|
file.set("format", "pcm");
|
||||||
file.set("name", speaker.getName());
|
file.set("name", speaker.getName());
|
||||||
file.set("md5", speaker.getMd5());
|
file.set("md5", speaker.getMd5());
|
||||||
file.set("url", sysConfig.getIp() + "/" + BusinessConstant.FILE_PATH + speaker.getPcmPath());
|
String protocol = BusinessConstant.HTTP_PROTOCOL;
|
||||||
|
if (sysConfig.getIsSsl()) {
|
||||||
|
protocol = BusinessConstant.HTTPS_PROTOCOL;
|
||||||
|
}
|
||||||
|
file.set("url", protocol + sysConfig.getIp() + ":" + sysConfig.getPort() + "/" + BusinessConstant.FILE_PATH + speaker.getPcmPath());
|
||||||
data.set("file", file);
|
data.set("file", file);
|
||||||
return djiBaseService.executeAndReturnResult(dockSn, "speaker_audio_play_start", data);
|
return djiBaseService.executeAndReturnResult(dockSn, "speaker_audio_play_start", data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,18 @@
|
||||||
package com.multictrl.modules.business.service.impl;
|
package com.multictrl.modules.business.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.multictrl.common.config.MinioConfig;
|
||||||
import com.multictrl.common.constant.BusinessConstant;
|
import com.multictrl.common.constant.BusinessConstant;
|
||||||
import com.multictrl.common.exception.ErrorCode;
|
import com.multictrl.common.exception.ErrorCode;
|
||||||
import com.multictrl.common.exception.RenException;
|
import com.multictrl.common.exception.RenException;
|
||||||
|
import com.multictrl.common.page.PageData;
|
||||||
import com.multictrl.common.service.impl.CrudServiceImpl;
|
import com.multictrl.common.service.impl.CrudServiceImpl;
|
||||||
import com.multictrl.common.utils.CacheUtils;
|
import com.multictrl.common.utils.CacheUtils;
|
||||||
|
import com.multictrl.common.utils.ConvertUtils;
|
||||||
|
import com.multictrl.common.utils.FfmpegUtils;
|
||||||
import com.multictrl.common.utils.Utils;
|
import com.multictrl.common.utils.Utils;
|
||||||
import com.multictrl.modules.business.dao.SpeakerDao;
|
import com.multictrl.modules.business.dao.SpeakerDao;
|
||||||
import com.multictrl.modules.business.dto.SpeakerDTO;
|
import com.multictrl.modules.business.dto.SpeakerDTO;
|
||||||
|
|
@ -16,6 +22,7 @@ import com.multictrl.modules.business.entity.SpeakerEntity;
|
||||||
import com.multictrl.modules.business.service.DJIBaseService;
|
import com.multictrl.modules.business.service.DJIBaseService;
|
||||||
import com.multictrl.modules.business.service.SpeakerService;
|
import com.multictrl.modules.business.service.SpeakerService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -26,14 +33,81 @@ import java.util.Map;
|
||||||
* @author Sdy
|
* @author Sdy
|
||||||
* @since 1.0.0 2026/5/6
|
* @since 1.0.0 2026/5/6
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SpeakerServiceImpl extends CrudServiceImpl<SpeakerDao, SpeakerEntity, SpeakerDTO> implements SpeakerService {
|
public class SpeakerServiceImpl extends CrudServiceImpl<SpeakerDao, SpeakerEntity, SpeakerDTO> implements SpeakerService {
|
||||||
private final DJIBaseService djiBaseService;
|
private final DJIBaseService djiBaseService;
|
||||||
|
private final MinioConfig minioConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryWrapper<SpeakerEntity> getWrapper(Map<String, Object> params) {
|
public QueryWrapper<SpeakerEntity> getWrapper(Map<String, Object> params) {
|
||||||
return null;
|
String id = (String) params.get("id");
|
||||||
|
String type = (String) params.get("type");
|
||||||
|
String dockSn = (String) params.get("dockSn");
|
||||||
|
|
||||||
|
QueryWrapper<SpeakerEntity> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq(StrUtil.isNotBlank(id), "id", id);
|
||||||
|
if (StrUtil.isNotBlank(type)) {
|
||||||
|
wrapper.eq("type", Integer.parseInt(type));
|
||||||
|
}
|
||||||
|
wrapper.eq(StrUtil.isNotBlank(dockSn), "dock_sn", dockSn);
|
||||||
|
wrapper.orderByDesc("create_date");
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTemplate(SpeakerDTO speaker) {
|
||||||
|
Long count = baseDao.selectCount(new QueryWrapper<SpeakerEntity>().eq("dock_sn", speaker.getDockSn())
|
||||||
|
.eq("name", speaker.getName()));
|
||||||
|
if (count > 0) {
|
||||||
|
throw new RenException(ErrorCode.SPEAKER_NAME_EXIST);
|
||||||
|
}
|
||||||
|
SpeakerEntity speakerEntity = ConvertUtils.sourceToTarget(speaker, SpeakerEntity.class);
|
||||||
|
Integer type = speaker.getType();
|
||||||
|
if (type == 1) {
|
||||||
|
speakerEntity.setMd5(Utils.md5Txt(speaker.getTextContent()));
|
||||||
|
} else {
|
||||||
|
String mediaPath = speaker.getMediaPath();
|
||||||
|
String path = minioConfig.getOther().getDataPath() + "/" + mediaPath;
|
||||||
|
if (!FileUtil.exist(path)) {
|
||||||
|
throw new RenException(ErrorCode.FILE_NOT_EXIST, "音频");
|
||||||
|
}
|
||||||
|
//调用ffmpeg将mp3或wav 转成pcm
|
||||||
|
String pcmPath = path.split("\\.")[0] + ".pcm";
|
||||||
|
String command = "ffmpeg -i " + path
|
||||||
|
+ " -ss 00 -t 179 -f s16le -ar 16000 -ac 1 -acodec pcm_s16le " + pcmPath;
|
||||||
|
FfmpegUtils.runCommand(command);
|
||||||
|
//轮询文件是否生成,因为ffmpeg和当前java进程不同步
|
||||||
|
int retry = 20;
|
||||||
|
while (!FileUtil.exist(pcmPath) && retry-- > 0) {
|
||||||
|
Utils.sleep(1);
|
||||||
|
log.info("ffmpeg mp3 or wav 2 pcm, await {} s", 20 - retry);
|
||||||
|
}
|
||||||
|
if (!FileUtil.exist(pcmPath)) {
|
||||||
|
throw new RenException(ErrorCode.FILE_NOT_EXIST, "pcm音频");
|
||||||
|
}
|
||||||
|
speakerEntity.setMd5(Utils.md5File(pcmPath));
|
||||||
|
speakerEntity.setPcmPath(pcmPath.replaceAll(minioConfig.getOther().getDataPath() + "/", ""));
|
||||||
|
}
|
||||||
|
baseDao.insert(speakerEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteTemplate(Long id) {
|
||||||
|
SpeakerEntity speakerEntity = selectById(id);
|
||||||
|
if (speakerEntity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Integer type = speakerEntity.getType();
|
||||||
|
if (type == 2) {
|
||||||
|
String mediaPath = speakerEntity.getMediaPath();
|
||||||
|
String pcmPath = speakerEntity.getPcmPath();
|
||||||
|
FileUtil.del(minioConfig.getOther().getDataPath() + "/" + mediaPath);
|
||||||
|
FileUtil.del(minioConfig.getOther().getDataPath() + "/" + pcmPath);
|
||||||
|
}
|
||||||
|
deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -89,6 +163,23 @@ public class SpeakerServiceImpl extends CrudServiceImpl<SpeakerDao, SpeakerEntit
|
||||||
return djiBaseService.executeDrcAndReturnResult(dockSn, "drc_speaker_tts_play_start", data);
|
return djiBaseService.executeDrcAndReturnResult(dockSn, "drc_speaker_tts_play_start", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String drcStartSpeakerTemplate(String dockSn, Long id) {
|
||||||
|
SpeakerEntity speakerEntity = selectById(id);
|
||||||
|
if (speakerEntity == null || speakerEntity.getType() != 1) {
|
||||||
|
throw new RenException(ErrorCode.PARAMS_ERROR);
|
||||||
|
}
|
||||||
|
TtsText ttsText = new TtsText();
|
||||||
|
ttsText.setName(speakerEntity.getName());
|
||||||
|
ttsText.setText(speakerEntity.getTextContent());
|
||||||
|
return drcStartSpeakerTts(dockSn, ttsText);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SpeakerDao getDao() {
|
||||||
|
return baseDao;
|
||||||
|
}
|
||||||
|
|
||||||
//获取包含psdk_index的data
|
//获取包含psdk_index的data
|
||||||
private JSONObject getDataIncludePsdkIndex(String dockSn) {
|
private JSONObject getDataIncludePsdkIndex(String dockSn) {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
|
|
|
||||||
|
|
@ -62,4 +62,6 @@ public interface ErrorCode {
|
||||||
int DEVICE_FIRMWARE_EXIST = 20021;
|
int DEVICE_FIRMWARE_EXIST = 20021;
|
||||||
int FIRMWARE_NOT_EXIST = 20022;
|
int FIRMWARE_NOT_EXIST = 20022;
|
||||||
int UAV_NOT_REGISTER = 20023;
|
int UAV_NOT_REGISTER = 20023;
|
||||||
|
int SPEAKER_NAME_EXIST = 20024;
|
||||||
|
int FILE_NOT_EXIST = 20025;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,6 @@
|
||||||
20020=\u4E0A\u4F20\u7684\u56FA\u4EF6\u5305\u65E0\u6CD5\u88AB\u89E3\u6790\uFF0C\u8BF7\u786E\u8BA4\u662F\u5426\u4ECE\u5B98\u65B9\u6E20\u9053\u83B7\u53D6
|
20020=\u4E0A\u4F20\u7684\u56FA\u4EF6\u5305\u65E0\u6CD5\u88AB\u89E3\u6790\uFF0C\u8BF7\u786E\u8BA4\u662F\u5426\u4ECE\u5B98\u65B9\u6E20\u9053\u83B7\u53D6
|
||||||
20021=\u8BE5\u8BBE\u5907\u578B\u53F7\u7684\u56FA\u4EF6\u7248\u672C\u5DF2\u5B58\u5728,\u8BF7\u52FF\u91CD\u65B0\u4E0A\u4F20
|
20021=\u8BE5\u8BBE\u5907\u578B\u53F7\u7684\u56FA\u4EF6\u7248\u672C\u5DF2\u5B58\u5728,\u8BF7\u52FF\u91CD\u65B0\u4E0A\u4F20
|
||||||
20022=\u56FA\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u56FA\u4EF6\u5347\u7EA7
|
20022=\u56FA\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u56FA\u4EF6\u5347\u7EA7
|
||||||
20023=\u65E0\u4EBA\u673A\u672A\u6CE8\u518C\uFF0C\u8BF7\u98DE\u673A\u5F00\u673A\u540E\u8FDB\u884C\u673A\u573A\u91CD\u65B0\u6CE8\u518C
|
20023=\u65E0\u4EBA\u673A\u672A\u6CE8\u518C\uFF0C\u8BF7\u98DE\u673A\u5F00\u673A\u540E\u8FDB\u884C\u673A\u573A\u91CD\u65B0\u6CE8\u518C
|
||||||
|
20024=\u558A\u8BDD\u5668\u6A21\u7248\u540D\u79F0\u5DF2\u5B58\u5728
|
||||||
|
20025={0}\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF7\u68C0\u67E5\u6587\u4EF6\u8DEF\u5F84\u662F\u5426\u6B63\u786E
|
||||||
Loading…
Reference in New Issue