Browse Source

Merge branch 'master' of http://1.14.104.71:10880/root/ylrz_his_scrm_java

caoliqin 1 week ago
parent
commit
2e5bdae7da

+ 13 - 9
fs-qw-task/src/main/java/com/fs/app/taskService/impl/SopLogsTaskServiceImpl.java

@@ -715,7 +715,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
             ruleTimeVO.setSendType(6);
             ruleTimeVO.setType(2);
             if (groupChat.getChatUserList() != null && !groupChat.getChatUserList().isEmpty()) {
-                QwSopLogs sopLogs = createBaseLog(formattedSendTime, logVo, ruleTimeVO, groupChat.getChatId(), groupChat.getName(), null, isOfficial, null);
+                QwSopLogs sopLogs = createBaseLog(formattedSendTime, logVo, ruleTimeVO, groupChat.getChatId(), groupChat.getName(), null, isOfficial, null,null);
                 handleLogBasedOnType(sopLogs, content, logVo, sendTime, courseId, videoId,
                         type, qwUserId, companyUserId, companyId, groupChat.getChatId(), welcomeText, qwUserName,
                         null, true, miniAppId, groupChat,config, miniMap, null, sendMsgType,companies);
@@ -745,7 +745,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
                     String externalUserName = contactId.getExternalUserName();
                     Long fsUserId = contactId.getFsUserId();
                     Integer grade = contactId.getGrade();
-                    QwSopLogs sopLogs = createBaseLog(formattedSendTime, logVo, ruleTimeVO, contactId.getExternalContactId(), externalUserName, fsUserId, isOfficial, contactId.getExternalId());
+                    QwSopLogs sopLogs = createBaseLog(formattedSendTime, logVo, ruleTimeVO, contactId.getExternalContactId(), externalUserName, fsUserId, isOfficial, contactId.getExternalId(),contactId.getIsDaysNotStudy());
                     handleLogBasedOnType(sopLogs, content, logVo, sendTime, courseId, videoId,
                             type, qwUserId, companyUserId, companyId, externalId, welcomeText, qwUserName, fsUserId, false, miniAppId,
                             null,config, miniMap, grade, sendMsgType,companies);
@@ -791,7 +791,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
     private QwSopLogs createBaseLog(String formattedSendTime, SopUserLogsVo logVo,
                                     QwSopRuleTimeVO ruleTimeVO, String externalContactId,
                                     String externalUserName, Long fsUserId,Integer isOfficial,
-                                    Long externalId) {
+                                    Long externalId,Integer isDaysNotStudy) {
         QwSopLogs sopLogs = new QwSopLogs();
         sopLogs.setSendTime(formattedSendTime);
         sopLogs.setQwUserid(logVo.getQwUserId());
@@ -799,6 +799,15 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
         sopLogs.setLogType(ruleTimeVO.getType());
         sopLogs.setTakeRecords(0);
 
+        if (isOfficial != 1 && Integer.valueOf(1).equals(isDaysNotStudy)) {
+            sopLogs.setSendStatus(5L);
+            sopLogs.setRemark("E级客户不发送");
+        }else {
+            sopLogs.setSendStatus(3L);
+        }
+
+        sopLogs.setReceivingStatus(0L);
+
         if (isOfficial == 1) {
 
             if (logVo.getIsSampSend()== 1) {
@@ -828,17 +837,12 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
         }
 
 
-        sopLogs.setSendStatus(3L);
-        sopLogs.setReceivingStatus(0L);
+
 
         String[] userKey = logVo.getUserId().split("\\|");
-        log.info("sopLogVo:{}", JSON.toJSONString(logVo));
-        log.info("sop_logs -》 userId:{}", logVo.getUserId());
-        log.info("sop_logs -》 userId -》 split:{}", Arrays.asList(userKey));
         sopLogs.setCompanyId(Long.valueOf(userKey[2].trim()));
         if (StringUtils.isNotEmpty(userKey[0].trim())){
             sopLogs.setQwUserKey(Long.valueOf(userKey[0].trim()));
-            log.info("qw_sop数据:{}", JSON.toJSONString(sopLogs));
         }
         sopLogs.setSopId(logVo.getSopId());
         sopLogs.setSort(Integer.valueOf(logVo.getStartTime().replaceAll("-","")));

+ 3 - 0
fs-service/src/main/java/com/fs/company/param/companyUserAddPrintParam.java

@@ -1,9 +1,12 @@
 package com.fs.company.param;
 
+import io.swagger.models.auth.In;
 import lombok.Data;
 
 @Data
 public class companyUserAddPrintParam
 {
     String  voicePrintUrl;
+    String  token;
+    Long companyUserId;
 }

+ 7 - 4
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -496,10 +496,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             return R.error(504,"未授权");
         }
 
-        if (StringUtil.strIsNullOrEmpty(fsUser.getMpOpenId())){
-            return R.error(401,"授权后可继续!");
-        }
-
         if (fsUser.getStatus()==0){
             return R.error("会员被停用,无权限,请联系客服!");
         }
@@ -534,6 +530,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
         String json = configService.selectConfigByKey("course.config");
         CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+
+
+        //服务号授权的,缺mpOpenId的重新登录
+        if (config.getMiniAppAuthType()==2 && StringUtil.strIsNullOrEmpty(fsUser.getMpOpenId())){
+            return R.error(401,"授权后可继续!");
+        }
+
         boolean oneCompanyCourse = config.isOneCompanyCourse();
         if(oneCompanyCourse && fsUser.getQwExtId() != null){
             QwExternalContact qwExternalContact = qwExternalContactMapper.selectById(fsUser.getQwExtId());

+ 8 - 2
fs-service/src/main/java/com/fs/wxwork/service/WxWorkServiceImpl.java

@@ -120,8 +120,14 @@ public class WxWorkServiceImpl implements WxWorkService {
     @Override
     public WxWorkResponseDTO<WxwLoginOutRespDTO> LoginOut(WxWorkGetQrCodeDTO param,Long serverId) {
         String url = getUrl(serverId) + "/LoginOut";
-        return WxWorkHttpUtil.postWithType(url, param, new TypeReference<WxWorkResponseDTO<WxwLoginOutRespDTO>>() {
-        });
+        try {
+            return WxWorkHttpUtil.postWithType(url, param, new TypeReference<WxWorkResponseDTO<WxwLoginOutRespDTO>>() {
+            });
+        }catch (Exception e){
+            log.error("LoginOut error",e);
+            return null;
+        }
+
     }
 
     @Override

+ 219 - 1
fs-user-app/src/main/java/com/fs/app/controller/store/CompanyUserScrmController.java

@@ -5,38 +5,64 @@ import cn.hutool.core.img.ImgUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.fs.app.annotation.Login;
 import com.fs.app.controller.AppBaseController;
 import com.fs.app.param.FsBindCompanyUserParam;
 import com.fs.common.config.FSConfig;
 import com.fs.common.core.domain.R;
+import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.CustomException;
+import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.sign.Md5Utils;
 import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.domain.CompanyUserCard;
 import com.fs.company.domain.CompanyUserUser;
+import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.company.param.CompanyUserLoginParam;
+import com.fs.company.param.companyUserAddPrintParam;
 import com.fs.company.service.ICompanyUserCardService;
 import com.fs.company.service.ICompanyUserService;
 import com.fs.company.service.ICompanyUserUserService;
+import com.fs.config.ai.AiHostProper;
+import com.fs.fastGpt.domain.FastgptChatVoiceHomo;
+import com.fs.fastGpt.mapper.FastgptChatVoiceHomoMapper;
+import com.fs.fastgptApi.util.AudioUtils;
+import com.fs.fastgptApi.vo.AudioVO;
 import com.fs.framework.security.SecurityUtils;
 import com.fs.his.dto.PayConfigDTO;
+import com.fs.his.service.IFsPrescribeService;
+import com.fs.sop.domain.QwSopTempVoice;
+import com.fs.sop.service.IQwSopTempVoiceService;
+import com.fs.system.oss.CloudStorageService;
+import com.fs.system.oss.OSSFactory;
 import com.fs.system.service.ISysConfigService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.io.FileUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+import static com.fs.app.controller.CompanyUserController.SOP_TEMP_VOICE_KEY;
 
 
 @Api("销售中心")
@@ -58,6 +84,19 @@ public class CompanyUserScrmController extends AppBaseController {
     @Autowired
     private ICompanyUserUserService companyUserUserService;
 
+
+    @Autowired
+    private CompanyUserMapper companyUserMapper;
+
+    @Autowired
+    private IFsPrescribeService fsPrescribeService;
+    @Autowired
+    private IQwSopTempVoiceService voiceService;
+    @Autowired
+    private FastgptChatVoiceHomoMapper fastgptChatVoiceHomoMapper;
+    @Autowired
+    AiHostProper aiHostProper;
+
     @PostMapping("/login")
     public R Login(@RequestBody CompanyUserLoginParam param, HttpServletRequest request){
         try {
@@ -122,7 +161,21 @@ public class CompanyUserScrmController extends AppBaseController {
         return R.ok().put("data",companyUserCard);
     }
 
-    @Login
+    @GetMapping("/query/{id}")
+    public R querySopVoiceById(@PathVariable("id") Long id){
+        QwSopTempVoice tempVoice = voiceService.selectQwSopTempVoiceById(id);
+        AudioVO audioVO = new AudioVO();
+        if(tempVoice != null){
+            audioVO.setId(tempVoice.getId());
+            audioVO.setVoiceTxt(tempVoice.getVoiceTxt());
+            audioVO.setUrl(tempVoice.getVoiceUrl());
+            audioVO.setWavUrl(tempVoice.getUserVoiceUrl());
+            audioVO.setDuration(tempVoice.getDuration());
+            audioVO.setRecordType(tempVoice.getRecordType());
+        }
+        return R.ok().put("data", audioVO);
+    }
+
     @ApiOperation("获取支付宝收款码")
     @GetMapping("/getQrImg")
     public R getQrImg(@RequestParam("token")String token,HttpServletRequest request){
@@ -219,5 +272,170 @@ public class CompanyUserScrmController extends AppBaseController {
     }
 
 
+    @ApiOperation("上传声纹")
+    @PostMapping("/addVoicePrintUrl")
+    public R addVoicePrintUrl(@RequestBody companyUserAddPrintParam param) throws Exception {
+        Long userId=param.getCompanyUserId();
+        CompanyUser companyUser = new CompanyUser();
+        companyUser.setUserId(userId);
+        companyUser.setVoicePrintUrl(param.getVoicePrintUrl());
+
+        //转换音频格式 mp3-wav
+        String s = AudioUtils.audioWAVFromUrl(param.getVoicePrintUrl());
+
+        //保存文件并且上传存储桶
+        System.out.println(s);
+        File file = new File(s);
+        FileInputStream fileInputStream = new FileInputStream(file);
+        CloudStorageService storage = OSSFactory.build();
+        String wavUrl = storage.uploadSuffix(fileInputStream, ".wav");
+
+        //更新销售员工声纹
+        companyUser.setVoicePrintUrl(wavUrl);
+        companyUserMapper.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());
+                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.error();
+
+    }
+
+    @GetMapping("/querySopVoiceList")
+    public TableDataInfo querySopVoiceList(@RequestParam("companyUserId")Long companyUserId,@RequestParam("recordType") Integer recordType){
+        startPage();
+        QwSopTempVoice sopTempVoice = new QwSopTempVoice();
+        sopTempVoice.setRecordType(recordType);
+
+        Long userId=companyUserId;
+        sopTempVoice.setCompanyUserId(userId);
+        List<QwSopTempVoice> sopTempVoices = voiceService.selectQwSopTempVoiceNewList(sopTempVoice);
+        return getDataTable(sopTempVoices);
+    }
+
+    @GetMapping("/createUserAllVoice")
+    public R createUserAllVoice(@RequestParam("companyUserId")Long companyUserId){
+        QwSopTempVoice sopTempVoice = new QwSopTempVoice();
+        sopTempVoice.setRecordType(0);
+
+        if(companyUserId==null){
+            throw  new CustomException("未登录",403);
+        }
+
+        if(companyUserId != null){
+            CompanyUser companyUser = companyUserMapper.selectCompanyUserByCompanyUserId(companyUserId);
+            if(companyUser != null && companyUser.getVoicePrintUrl() == null){
+                return R.ok().put("code",201).put("msg","账号未录制声纹,请录制后再试!");
+            }
+        }
+
+        sopTempVoice.setCompanyUserId(companyUserId);
+        List<QwSopTempVoice> sopTempVoices = voiceService.selectQwSopTempVoiceNewList(sopTempVoice);
+        if(sopTempVoices != null && !sopTempVoices.isEmpty()){
+            List<Long> newCompanyUserId = redisCache.getVoiceAllList(SOP_TEMP_VOICE_KEY);
+            if(newCompanyUserId != null && newCompanyUserId.contains(companyUserId)){
+                return R.error().put("code",202).put("msg","语音还未转换完成,请完成后再添加!");
+            }else{
+                redisCache.setVoice(SOP_TEMP_VOICE_KEY,companyUserId);
+                sopTempVoices.forEach(m -> m.setVoiceTxt(m.getVoiceTxt().replace(" ","")));
+                redisCache.setVoiceList(SOP_TEMP_VOICE_KEY + ":" + companyUserId, sopTempVoices);
+                return R.ok().put("msg","语音已加入队列进行转换,请耐心等待!");
+            }
+        }
+        return null;
+    }
+
+
+    @GetMapping("/companyUserVoice")
+    public R companyUserVoice(@RequestParam("companyUserId")Long companyUserId,@RequestParam("id") Long id){
+        AudioVO audioVO = new AudioVO();
+
+
+        List<QwSopTempVoice> sopTempVoices = redisCache.getVoiceAllList(SOP_TEMP_VOICE_KEY + ":" + companyUserId);
+        if(sopTempVoices != null && !sopTempVoices.isEmpty()){
+            List<Long> collect = sopTempVoices.stream().map(QwSopTempVoice::getId).collect(Collectors.toList());
+            if (collect.contains(id)){
+                return R.ok().put("code",202).put("msg","该语音已进入转换,请完成后再试。");
+            }
+        }
+
+        if(companyUserId != null){
+            CompanyUser companyUser = companyUserMapper.selectCompanyUserByCompanyUserId(companyUserId);
+            if(companyUser != null && companyUser.getVoicePrintUrl() == null){
+                return R.ok().put("code",201).put("msg","账号未录制声纹,请录制后再试!");
+            }
+        }
+
+        QwSopTempVoice qwSopTempVoice = voiceService.selectQwSopTempVoiceById(id);
+        if(qwSopTempVoice != null && qwSopTempVoice.getCompanyUserId() != null){
+            List<FastgptChatVoiceHomo> homos = fastgptChatVoiceHomoMapper.selectFastgptChatVoiceHomoList(new FastgptChatVoiceHomo());
+            audioVO = AudioUtils.createUserUrlAndUrl(homos,qwSopTempVoice.getCompanyUserId(), qwSopTempVoice.getVoiceTxt().replace(" ",""));
+            if(audioVO != null && audioVO.getWavUrl() != null &&  audioVO.getUrl() != null){
+                qwSopTempVoice.setVoiceUrl(audioVO.getUrl());
+                qwSopTempVoice.setUserVoiceUrl(audioVO.getWavUrl());
+                qwSopTempVoice.setDuration(audioVO.getDuration());
+                qwSopTempVoice.setRecordType(1);
+                voiceService.updateQwSopTempVoice(qwSopTempVoice);
+            }
+        }
+        return R.ok().put("data", audioVO);
+    }
+
+    /**
+     * 当只有user_voice_url时,生成表中对应条的voice_url
+     * @param userVoiceUrl  wav格式的语音文件
+     * @param id            qw_sop_temp_voice的id
+     * @return
+     */
+    @GetMapping("/companyUserVoiceNew")
+    public R companyUserVoiceNew( @RequestParam("companyUserId")Long companyUserId,@RequestParam("id") Long id,@RequestParam("userVoiceUrl") String userVoiceUrl){
+
+        AudioVO audioVO = new AudioVO();
+
+        List<QwSopTempVoice> sopTempVoices = redisCache.getVoiceAllList(SOP_TEMP_VOICE_KEY + ":" + companyUserId);
+        if(sopTempVoices != null && !sopTempVoices.isEmpty()){
+            List<Long> collect = sopTempVoices.stream().map(QwSopTempVoice::getId).collect(Collectors.toList());
+            if (collect.contains(id)){
+                return R.ok().put("code",202).put("msg","该语音已进入转换,请完成后再试。");
+            }
+        }
+
+        QwSopTempVoice qwSopTempVoice = voiceService.selectQwSopTempVoiceByIdAndUserVoiceUrl(id);
+        if(qwSopTempVoice != null && qwSopTempVoice.getId() != null){
+            audioVO = AudioUtils.createVoiceUrl(qwSopTempVoice.getCompanyUserId(), userVoiceUrl);
+            if(audioVO != null && audioVO.getUrl() != null){
+                qwSopTempVoice.setVoiceUrl(audioVO.getUrl());
+                qwSopTempVoice.setUserVoiceUrl(userVoiceUrl);
+                qwSopTempVoice.setDuration(audioVO.getDuration());
+                qwSopTempVoice.setRecordType(1);
+                voiceService.updateQwSopTempVoice(qwSopTempVoice);
+            }
+        }
+        return R.ok().put("data", audioVO);
+    }
+
 
 }