|
@@ -14,10 +14,12 @@ import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.scene.constant.FileYunPath;
|
|
|
import com.fdkankan.scene.dto.AsrCallbackDTO;
|
|
|
import com.fdkankan.scene.dto.ScrbSaveDTO;
|
|
|
import com.fdkankan.scene.dto.TextVoiceTransferDTO;
|
|
|
+import com.fdkankan.scene.entity.LeaveWord;
|
|
|
import com.fdkankan.scene.entity.SceneEditInfoScrb;
|
|
|
import com.fdkankan.scene.entity.TextVoiceTransfer;
|
|
|
import com.fdkankan.scene.service.*;
|
|
@@ -31,10 +33,13 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.UUID;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -55,6 +60,8 @@ public class ScrbServiceImpl implements IScrbService {
|
|
|
|
|
|
@Autowired
|
|
|
private ISceneEditInfoService sceneEditInfoService;
|
|
|
+ @Autowired
|
|
|
+ private ILeaveWordService leaveWordService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -88,7 +95,7 @@ public class ScrbServiceImpl implements IScrbService {
|
|
|
String localVoicePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, textVoiceTransfer.getNum()) + taskId + "." + "mp3";
|
|
|
FileUtil.mkParentDirs(localVoicePath);
|
|
|
HttpUtil.downloadFile(url, localVoicePath);
|
|
|
- String obsPath = String.format(FileYunPath.SCRB_EDIT_PATH, textVoiceTransfer.getNum()) + FileUtil.getName(localVoicePath);
|
|
|
+ String obsPath = String.format(FileYunPath.SCRB_PATH, textVoiceTransfer.getNum()) + FileUtil.getName(localVoicePath);
|
|
|
fYunFileService.uploadFile(localVoicePath, obsPath);
|
|
|
textVoiceTransfer.setVoicePath(obsPath);
|
|
|
textVoiceTransfer.setResCode(status);
|
|
@@ -183,7 +190,7 @@ public class ScrbServiceImpl implements IScrbService {
|
|
|
String filename = file.getOriginalFilename();
|
|
|
File localFile = FileUtil.createTempFile(UUID.randomUUID().toString(), "." + FileUtil.extName(filename), new File(String.format(ConstantFilePath.SCENE_USER_PATH_V4, num)), true);
|
|
|
file.transferTo(localFile);
|
|
|
- String ossPath = String.format(FileYunPath.SCRB_EDIT_PATH, num) + localFile.getName();
|
|
|
+ String ossPath = String.format(FileYunPath.SCRB_PATH, num) + localFile.getName();
|
|
|
String url = fYunFileService.uploadFile(localFile.getAbsolutePath(), ossPath);
|
|
|
String taskId = asrUtil.voiceToText(url);
|
|
|
textVoiceTransfer.setTaskId(taskId);
|
|
@@ -211,7 +218,7 @@ public class ScrbServiceImpl implements IScrbService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void save(ScrbSaveDTO param) {
|
|
|
+ public void save(ScrbSaveDTO param) throws IOException {
|
|
|
if(CollUtil.isNotEmpty(param.getBaseSetting())){
|
|
|
sceneEditInfoScrbService.update(
|
|
|
new LambdaUpdateWrapper<SceneEditInfoScrb>()
|
|
@@ -242,6 +249,17 @@ public class ScrbServiceImpl implements IScrbService {
|
|
|
.eq(SceneEditInfoScrb::getNum, param.getNum())
|
|
|
.set(SceneEditInfoScrb::getNavigation, null));
|
|
|
}
|
|
|
+
|
|
|
+ //生成留言json
|
|
|
+ List<LeaveWord> list = leaveWordService.list(new LambdaQueryWrapper<LeaveWord>().eq(LeaveWord::getNum, param.getNum()).eq(LeaveWord::getStatus, CommonSuccessStatus.SUCCESS.code()));
|
|
|
+ String leaveWordKey = String.format(FileYunPath.SCRB_PATH, param.getNum()) + "leaveWord.json";
|
|
|
+ if(CollUtil.isNotEmpty(list)){
|
|
|
+ List<JSONObject> collect = list.stream().map(l -> JSON.parseObject(l.getContent())).collect(Collectors.toList());
|
|
|
+ fYunFileService.uploadFile(JSON.toJSONString(collect).getBytes(StandardCharsets.UTF_8), leaveWordKey);
|
|
|
+ }else{//没有留言直接删除
|
|
|
+ fYunFileService.deleteFile(leaveWordKey);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|