|
|
@@ -21,14 +21,17 @@ import com.fs.company.domain.*;
|
|
|
import com.fs.company.param.CompanyUserAreaParam;
|
|
|
import com.fs.company.param.CompanyUserCodeParam;
|
|
|
import com.fs.company.param.CompanyUserQwParam;
|
|
|
+import com.fs.company.param.companyUserAddPrintParam;
|
|
|
import com.fs.company.service.*;
|
|
|
import com.fs.company.service.impl.CompanyDeptServiceImpl;
|
|
|
import com.fs.company.utils.DomainUtil;
|
|
|
import com.fs.company.utils.QwStatusEnum;
|
|
|
import com.fs.company.vo.*;
|
|
|
+import com.fs.config.ai.AiHostProper;
|
|
|
import com.fs.config.cloud.CloudHostProper;
|
|
|
import com.fs.config.saas.ProjectConfig;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
+import com.fs.fastgptApi.util.AudioUtils;
|
|
|
import com.fs.framework.datasource.DynamicDataSourceContextHolder;
|
|
|
import com.fs.framework.datasource.TenantDataSourceManager;
|
|
|
import com.fs.framework.security.LoginUser;
|
|
|
@@ -46,8 +49,11 @@ import com.fs.qw.service.IQwCompanyService;
|
|
|
import com.fs.qw.service.IQwUserService;
|
|
|
import com.fs.qw.vo.CompanyUserQwVO;
|
|
|
import com.fs.qw.vo.QwUserVO;
|
|
|
+import com.fs.sop.service.IQwSopTempVoiceService;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.mapper.SysConfigMapper;
|
|
|
+import com.fs.system.oss.CloudStorageService;
|
|
|
+import com.fs.system.oss.OSSFactory;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.tenant.domain.TenantInfo;
|
|
|
import com.fs.tenant.mapper.TenantInfoMapper;
|
|
|
@@ -65,6 +71,8 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
@@ -963,4 +971,74 @@ public class CompanyUserController extends BaseController {
|
|
|
List<com.fs.hisStore.domain.FsUserScrm> userList = companyUserService.selectBoundFsUsersByCompanyUserId(companyUserId);
|
|
|
return R.ok().put("data", userList);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation("上传声纹")
|
|
|
+ @PostMapping("/addVoicePrintUrl")
|
|
|
+ public R addVoicePrintUrl(@RequestBody companyUserAddPrintParam param) throws Exception {
|
|
|
+ Long userId = param.getCompanyUserId();
|
|
|
+ if (userId == null) {
|
|
|
+ try {
|
|
|
+ userId = getUserId();
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("用户失效");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ return R.error("用户失效");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(param.getVoicePrintUrl())) {
|
|
|
+ return R.error("声纹地址不能为空");
|
|
|
+ }
|
|
|
+ CompanyUser companyUser = new CompanyUser();
|
|
|
+ companyUser.setUserId(userId);
|
|
|
+ companyUser.setVoicePrintUrl(param.getVoicePrintUrl());
|
|
|
+
|
|
|
+ //转换音频格式 mp3-wav
|
|
|
+ String s = AudioUtils.audioWAVFromUrl(param.getVoicePrintUrl());
|
|
|
+ if (StringUtils.isEmpty(s)) {
|
|
|
+ return R.error("音频转换失败,请检查 ffmpeg 是否可用及 c:\\hook 目录是否存在");
|
|
|
+ }
|
|
|
+ File file = new File(s);
|
|
|
+ if (!file.isFile()) {
|
|
|
+ return R.error("音频转换失败,未生成 wav 文件: " + s);
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存文件并且上传存储桶
|
|
|
+ FileInputStream fileInputStream = new FileInputStream(file);
|
|
|
+ CloudStorageService storage = OSSFactory.build();
|
|
|
+ String wavUrl = storage.uploadSuffix(fileInputStream, ".wav");
|
|
|
+
|
|
|
+ //更新销售员工声纹
|
|
|
+ companyUser.setVoicePrintUrl(wavUrl);
|
|
|
+ companyUserService.updateCompanyUser(companyUser);
|
|
|
+
|
|
|
+// try {
|
|
|
+// CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
+// HttpPost httpPost = new HttpPost(aiHostProper.getCommonApi()+"/app/common/addCompanyAudio");
|
|
|
+// String json = "{\"url\":\""+wavUrl+"\",\"id\":\""+userId+"\"}";
|
|
|
+// StringEntity entity = new StringEntity(json);
|
|
|
+// httpPost.setEntity(entity);
|
|
|
+// httpPost.setHeader("Content-type", "application/json");
|
|
|
+// HttpResponse response = httpClient.execute(httpPost);
|
|
|
+//
|
|
|
+// if (response.getStatusLine().getStatusCode() == 200) {
|
|
|
+// String responseBody = EntityUtils.toString(response.getEntity());
|
|
|
+// com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(responseBody);
|
|
|
+// Integer code = (Integer)jsonObject.get("code");
|
|
|
+// if (code==200){
|
|
|
+// voiceService.insertQwSopTempVoiceModel(userId);
|
|
|
+// return R.ok();
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// return R.error();
|
|
|
+// }
|
|
|
+//
|
|
|
+// httpClient.close();
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+
|
|
|
+ }
|
|
|
}
|