Compare commits

2 Commits

Author SHA1 Message Date
6d58268874 根据新增业务对象插入设备语音 2025-11-11 15:10:15 +08:00
56dbfbde71 prod 2025-11-11 14:33:10 +08:00
5 changed files with 80 additions and 48 deletions

View File

@ -28,6 +28,7 @@ public class AppDeviceHBYController extends BaseController {
private final DeviceBJQBizService appDeviceService; private final DeviceBJQBizService appDeviceService;
/** /**
* 获取设备详细信息 * 获取设备详细信息
* *

View File

@ -55,32 +55,32 @@ spring:
url: jdbc:mysql://47.120.79.150:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true url: jdbc:mysql://47.120.79.150:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root username: root
password: Jq_123456# password: Jq_123456#
# # 从库数据源 # # 从库数据源
# slave: # slave:
# lazy: true # lazy: true
# type: ${spring.datasource.type} # type: ${spring.datasource.type}
# driverClassName: com.mysql.cj.jdbc.Driver # driverClassName: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: # username:
# password: # password:
# oracle: # oracle:
# type: ${spring.datasource.type} # type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver # driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE # url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT # username: ROOT
# password: root # password: root
# postgres: # postgres:
# type: ${spring.datasource.type} # type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver # driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true # url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root # username: root
# password: root # password: root
# sqlserver: # sqlserver:
# type: ${spring.datasource.type} # type: ${spring.datasource.type}
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver # driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true # url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
# username: SA # username: SA
# password: root # password: root
hikari: hikari:
# 最大连接池数量 # 最大连接池数量
maxPoolSize: 20 maxPoolSize: 20
@ -281,10 +281,10 @@ justauth:
mqtt: mqtt:
username: admin username: admin
password: #YtvpSfCNG password: #YtvpSfCNG
url: tcp://47.120.79.150:2883 url: tcp://47.120.79.150:3883
subClientId: fys_subClient subClientId: fys_subClient
subTopic: A/#,B/#,worker/location/# subTopic: A/#,status/tenantCode/#,report/tenantCode/#
pubTopic: B/# pubTopic: B/#,command/tenantCode/#
pubClientId: fys_pubClient pubClientId: fys_pubClient
# TTS语音交互配置 # TTS语音交互配置

View File

@ -13,9 +13,9 @@ import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.util.Arrays; import java.util.Arrays;
/** /**
@ -54,8 +54,9 @@ public class AppDeviceVoiceController extends BaseController {
* 新增设备语音 * 新增设备语音
*/ */
@PostMapping() @PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody AppDeviceVoiceBo bo) { public R<Void> add(@RequestPart("bo") @Validated(AddGroup.class) AppDeviceVoiceBo bo,
return toAjax(appDeviceVoiceService.insertByBo(bo)); @RequestPart(value = "file", required = false) MultipartFile file) {
return toAjax(appDeviceVoiceService.insertByBo(bo, file));
} }
/** /**

View File

@ -4,6 +4,7 @@ import com.fuyuanshen.app.domain.AppDeviceVoice;
import com.fuyuanshen.app.domain.bo.AppDeviceVoiceBo; import com.fuyuanshen.app.domain.bo.AppDeviceVoiceBo;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.mybatis.core.page.PageQuery; import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import org.springframework.web.multipart.MultipartFile;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -34,7 +35,7 @@ public interface IAppDeviceVoiceService {
/** /**
* 根据新增业务对象插入设备语音 * 根据新增业务对象插入设备语音
*/ */
Boolean insertByBo(AppDeviceVoiceBo bo); Boolean insertByBo(AppDeviceVoiceBo bo, MultipartFile file);
/** /**
* 根据编辑业务对象更新设备语音 * 根据编辑业务对象更新设备语音

View File

@ -1,20 +1,22 @@
package com.fuyuanshen.app.service.impl; package com.fuyuanshen.app.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.app.domain.AppDeviceVoice; import com.fuyuanshen.app.domain.AppDeviceVoice;
import com.fuyuanshen.app.domain.bo.AppDeviceVoiceBo; import com.fuyuanshen.app.domain.bo.AppDeviceVoiceBo;
import com.fuyuanshen.app.mapper.AppDeviceVoiceMapper; import com.fuyuanshen.app.mapper.AppDeviceVoiceMapper;
import com.fuyuanshen.app.service.IAppDeviceVoiceService; import com.fuyuanshen.app.service.IAppDeviceVoiceService;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.mybatis.core.page.PageQuery; import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.oss.core.OssClient;
import com.fuyuanshen.common.oss.entity.UploadResult;
import com.fuyuanshen.common.oss.factory.OssFactory;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 设备语音Service业务层处理 * 设备语音Service业务层处理
@ -57,16 +59,45 @@ public class AppDeviceVoiceServiceImpl implements IAppDeviceVoiceService {
* 根据新增业务对象插入设备语音 * 根据新增业务对象插入设备语音
*/ */
@Override @Override
public Boolean insertByBo(AppDeviceVoiceBo bo) { public Boolean insertByBo(AppDeviceVoiceBo bo, MultipartFile file) {
// 上传文件到MinIO
String videoUrl = "";
String coverUrl = "";
Long size = 0L;
Integer duration = 0;
String type = "";
if (file != null && !file.isEmpty()) {
try {
OssClient storage = OssFactory.instance();
String suffix = "";
String originalFilename = file.getOriginalFilename();
if (originalFilename != null && originalFilename.lastIndexOf(".") > 0) {
suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
}
UploadResult result = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType());
videoUrl = result.getUrl();
size = file.getSize();
type = file.getContentType();
// TODO: 可以通过其他方式获取音频时长,这里暂时设置为默认值
duration = 0;
// TODO: 可以生成封面图,这里暂时设置为空
coverUrl = "";
} catch (Exception e) {
// 文件上传失败处理
throw new RuntimeException("文件上传失败: " + e.getMessage());
}
}
AppDeviceVoice add = new AppDeviceVoice(); AppDeviceVoice add = new AppDeviceVoice();
add.setVideoName(bo.getVideoName()); add.setVideoName(bo.getVideoName());
add.setVideoUrl(bo.getVideoUrl()); add.setVideoUrl(videoUrl);
add.setDeviceId(bo.getDeviceId()); add.setDeviceId(bo.getDeviceId());
add.setRemark(bo.getRemark()); add.setRemark(bo.getRemark());
add.setType(bo.getType()); add.setType(type);
add.setDuration(bo.getDuration()); add.setDuration(duration);
add.setSize(bo.getSize()); add.setSize(size);
add.setCover(bo.getCover()); add.setCover(coverUrl);
return baseMapper.insert(add) > 0; return baseMapper.insert(add) > 0;
} }
@ -78,16 +109,12 @@ public class AppDeviceVoiceServiceImpl implements IAppDeviceVoiceService {
AppDeviceVoice update = new AppDeviceVoice(); AppDeviceVoice update = new AppDeviceVoice();
update.setId(bo.getId()); update.setId(bo.getId());
update.setVideoName(bo.getVideoName()); update.setVideoName(bo.getVideoName());
update.setVideoUrl(bo.getVideoUrl());
update.setDeviceId(bo.getDeviceId()); update.setDeviceId(bo.getDeviceId());
update.setRemark(bo.getRemark()); update.setRemark(bo.getRemark());
update.setType(bo.getType());
update.setDuration(bo.getDuration());
update.setSize(bo.getSize());
update.setCover(bo.getCover());
return baseMapper.updateById(update) > 0; return baseMapper.updateById(update) > 0;
} }
/** /**
* 校验并批量删除设备语音信息 * 校验并批量删除设备语音信息
*/ */
@ -96,6 +123,8 @@ public class AppDeviceVoiceServiceImpl implements IAppDeviceVoiceService {
if (ids == null || ids.isEmpty()) { if (ids == null || ids.isEmpty()) {
return false; return false;
} }
// TODO: 可以在这里添加删除MinIO文件的逻辑
return baseMapper.deleteBatchIds(ids) > 0; return baseMapper.deleteBatchIds(ids) > 0;
} }
} }