Browse Source

1.提交语音sop相关代码

jzp 4 hours ago
parent
commit
3ed5332b1b

+ 83 - 3
fs-admin/src/main/java/com/fs/qw/controller/QwSopController.java

@@ -1,5 +1,6 @@
 package com.fs.qw.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.Log;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.controller.BaseController;
@@ -16,19 +17,27 @@ import com.fs.framework.web.service.TokenService;
 import com.fs.his.vo.OptionsVO;
 import com.fs.qw.domain.QwSopUpdateStatus;
 import com.fs.qw.service.IQwUserService;
+import com.fs.qw.vo.QwUserVO;
 import com.fs.sop.domain.QwSop;
+import com.fs.sop.domain.QwSopTempContent;
+import com.fs.sop.domain.QwSopTempVoice;
 import com.fs.sop.params.QwSopAutoTime;
 import com.fs.sop.params.QwSopEditQwUserParam;
 import com.fs.sop.service.IQwSopService;
+import com.fs.sop.service.IQwSopTempContentService;
+import com.fs.sop.service.IQwSopTempVoiceService;
 import com.fs.sop.vo.SopVoiceListVo;
+import org.apache.commons.beanutils.ConvertUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.io.IOException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 企微sopController
@@ -52,6 +61,12 @@ public class QwSopController extends BaseController
     private FsUserCourseMapper fsUserCourseMapper;
     @Autowired
     private FsUserCourseVideoMapper fsUserCourseVideoMapper;
+
+    @Autowired
+    private IQwSopTempContentService qwSopTempContentService;
+
+    @Autowired
+    private IQwSopTempVoiceService voiceService;
     /**
      * 查询企微sop列表
      */
@@ -133,9 +148,59 @@ public class QwSopController extends BaseController
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         qwSop.setCreateBy(loginUser.getUser().getNickName());
         qwSop.setCreateTime(sdf.format(new Date()));
+        int count = qwSopService.insertQwSop(qwSop);
+        if(count > 0){
+            if(qwSop.getQwUserIds() != null){
+                updateTempVoiceInfo(qwSop);
+            }
+        }
+        return toAjax(count);
 
-        return toAjax(qwSopService.insertQwSop(qwSop));
+    }
+    /**
+     * 修改qwSop任务,新增或者删除qwUser
+     * @param qwSop
+     */
+    private void updateTempVoiceInfo(QwSop qwSop) {
+        try {
+            String tempId = qwSop.getTempId();
+            String[] split = qwSop.getQwUserIds().split(",");
+            Long[] qwUserIds = (Long[]) ConvertUtils.convert(split, Long.class);
 
+            List<QwSopTempContent> qwSopTempContentList = qwSopTempContentService.selectQwSopTempContentByTempId(tempId);
+            if(qwSopTempContentList != null && !qwSopTempContentList.isEmpty()){
+                for (QwSopTempContent qwSopTemp : qwSopTempContentList) {
+                    if(qwSopTemp != null && qwSopTemp.getContent() != null){
+                        String content = qwSopTemp.getContent();
+                        JSONObject jsonObject = JSONObject.parseObject(content);
+                        String voiceTxt = jsonObject.getString("value");
+                        String contentType = jsonObject.getString("contentType");
+                        if("7".equals(contentType)){
+                            List<QwUserVO> qwUserVoS = qwUserService.selectQwUserVOByIds(qwUserIds);
+                            if(qwUserVoS != null && !qwUserVoS.isEmpty()){
+                                List<Long> companyUserIdList = qwUserVoS.stream().map(QwUserVO::getCompanyUserId).collect(Collectors.toList());
+                                for (Long companyUserId : companyUserIdList) {
+                                    QwSopTempVoice qwSopTempVoice = voiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(companyUserId,voiceTxt);
+                                    if(qwSopTempVoice == null){
+                                        if(companyUserId != null && voiceTxt != null){
+                                            QwSopTempVoice tempVoice = new QwSopTempVoice();
+                                            tempVoice.setVoiceTxt(voiceTxt);
+                                            tempVoice.setCompanyUserId(companyUserId);
+                                            tempVoice.setRecordType(0);
+                                            tempVoice.setCreateTime(LocalDateTime.now());
+                                            tempVoice.setTempId(tempId);
+                                            voiceService.insertQwSopTempVoice(tempVoice);
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            logger.error("修改企微sop任务,新增或者删除qwUser异常:" + e.getMessage());
+        }
     }
 
     /**
@@ -146,7 +211,14 @@ public class QwSopController extends BaseController
     @PutMapping
     public R edit(@RequestBody QwSop qwSop)
     {
-        return qwSopService.updateQwSop(qwSop);
+        R sop = qwSopService.updateQwSop(qwSop);
+        String code = sop.get("code").toString();
+        if(code.equals("200")){
+            if(qwSop != null && qwSop.getQwUserIds() != null){
+                updateTempVoiceInfo(qwSop);
+            }
+        }
+        return sop;
     }
 
 
@@ -201,7 +273,15 @@ public class QwSopController extends BaseController
     @PreAuthorize("@ss.hasPermi('qw:sop:updateSopQwUser')")
     public R updateSopQwUser(@RequestBody QwSopEditQwUserParam param)
     {
-        return qwSopService.updateSopQwUser(param);
+        R sop = qwSopService.updateSopQwUser(param);
+        String code = sop.get("code").toString();
+        if(code.equals("200")){
+            QwSop qwSop = qwSopService.selectQwSopById(param.getId());
+            if(qwSop != null && qwSop.getQwUserIds() != null){
+                updateTempVoiceInfo(qwSop);
+            }
+        }
+        return sop;
     }
 
     /**

+ 36 - 0
fs-qw-task/src/main/java/com/fs/app/taskService/impl/SopLogsTaskServiceImpl.java

@@ -674,11 +674,40 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
         if(content.getSetting() == null){
             return;
         }
+        List<QwSopTempSetting.Content.Setting> setting = content.getSetting().stream().filter(e -> "7".equals(e.getContentType())).collect(Collectors.toList());
+        if (!setting.isEmpty()) {
+            List<String> valuesList = PubFun.listToNewList(setting, QwSopTempSetting.Content.Setting::getValue);
+            if (valuesList != null && !valuesList.isEmpty()) {
+                try {
+                    List<QwSopTempVoice> voiceList = qwSopTempVoiceService.getVoiceByText(Long.parseLong(companyUserId), valuesList);
+                    if (voiceList != null && !voiceList.isEmpty()) {
+                        Map<String, QwSopTempVoice> collect = voiceList.stream().collect(Collectors.toMap(QwSopTempVoice::getVoiceTxt, e -> e));
+                        setting.parallelStream().filter(e -> "7".equals(e.getContentType())).forEach(st -> {
+                            QwSopTempVoice voice = collect.get(st.getValue());
+                            if (voice.getVoiceUrl() == null) {
+                                return;
+                            }
+                            st.setVoiceUrl(voice.getVoiceUrl());
+                            st.setVoiceDuration(voice.getDuration() + "");
+                        });
+                    }
+                } catch (NumberFormatException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
 //        // 发送语音 end
         if (content.getType()==5){
             sopAddTag(logVo,content,sendTime);
         }
 
+        //当语音模板的qw_sop_temp_voice中无对应语音,就不生成qw_sop_logs记录
+        if (content.getType() == 7 && content.getSetting() != null && !content.getSetting().isEmpty()) {
+            if (content.getSetting().get(0).getVoiceUrl() == null) {
+                return;
+            }
+        }
+
         if (StringUtils.isNotEmpty(logVo.getChatId())) {
             QwGroupChat groupChat = groupChatMap.get(logVo.getChatId());
             ruleTimeVO.setSendType(6);
@@ -839,11 +868,18 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
             case 5:
 //                handleTagMessage(sopLogs, content);
                 break;
+            case 7:
+                handleVoiceMessage(sopLogs, content, companyUserId);
+                break;
             default:
                 log.error("未知的消息类型 {},跳过处理。", type);
                 break;
         }
     }
+    private void handleVoiceMessage(QwSopLogs sopLogs, QwSopTempSetting.Content content, String companyUserId) {
+        sopLogs.setContentJson(JSON.toJSONString(content));
+        enqueueQwSopLogs(sopLogs);
+    }
 
     private void handleNormalMessage(QwSopLogs sopLogs, QwSopTempSetting.Content content,String companyUserId) {
 

+ 7 - 5
fs-service/src/main/java/com/fs/qw/service/AsyncQwAiChatSopService.java

@@ -312,11 +312,13 @@ public class AsyncQwAiChatSopService {
             setting.setVoiceUrl(qwSopTempVoice.getVoiceUrl());
             setting.setVoiceDuration(String.valueOf(qwSopTempVoice.getDuration()));
         } else if (qwSopTempVoice == null) {
-            qwSopTempVoice = new QwSopTempVoice();
-            qwSopTempVoice.setCompanyUserId(companyUserId);
-            qwSopTempVoice.setVoiceTxt(setting.getValue());
-            qwSopTempVoice.setRecordType(0);
-            sopTempVoiceService.insertQwSopTempVoice(qwSopTempVoice);
+            if(companyUserId != null && setting.getValue() != null){
+                qwSopTempVoice = new QwSopTempVoice();
+                qwSopTempVoice.setCompanyUserId(companyUserId);
+                qwSopTempVoice.setVoiceTxt(setting.getValue());
+                qwSopTempVoice.setRecordType(0);
+                sopTempVoiceService.insertQwSopTempVoice(qwSopTempVoice);
+            }
         }
     }
 

+ 47 - 4
fs-service/src/main/java/com/fs/sop/service/impl/QwSopTempServiceImpl.java

@@ -17,12 +17,11 @@ import com.fs.course.service.IFsUserCourseVideoRedPackageService;
 import com.fs.course.utils.TimeCalculator;
 import com.fs.fastGpt.domain.FastGptChatReplaceWords;
 import com.fs.fastGpt.mapper.FastGptChatReplaceWordsMapper;
+import com.fs.qw.service.IQwUserService;
 import com.fs.qw.vo.QwSopTempSetting2;
+import com.fs.qw.vo.QwUserVO;
 import com.fs.qw.vo.SortDayVo;
-import com.fs.sop.domain.QwSopTemp;
-import com.fs.sop.domain.QwSopTempContent;
-import com.fs.sop.domain.QwSopTempDay;
-import com.fs.sop.domain.QwSopTempRules;
+import com.fs.sop.domain.*;
 import com.fs.sop.mapper.QwSopTempMapper;
 import com.fs.sop.params.QwSopShareTempParam;
 import com.fs.sop.service.*;
@@ -32,6 +31,7 @@ import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
 import io.netty.util.internal.StringUtil;
 import lombok.AllArgsConstructor;
+import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.springframework.stereotype.Service;
@@ -66,6 +66,8 @@ public class QwSopTempServiceImpl implements IQwSopTempService
     private final IFsUserCourseVideoRedPackageService fsUserCourseVideoRedPackageService;
     private final FsUserCourseVideoMapper fsUserCourseVideoMapper;
     private final FsUserCourseMapper fsUserCourseMapper;
+    private final IQwSopService qwSopService;
+    private final IQwUserService qwUserService;
 
 
     /**
@@ -236,6 +238,47 @@ public class QwSopTempServiceImpl implements IQwSopTempService
         reorder(day.getTempId());
         Map<String, Object> map = new HashMap<>();
         map.put("id", day.getId());
+        if(!voiceList.isEmpty()){
+            for (QwSopTempContent qwSopTempContent : voiceList) {
+                String content = qwSopTempContent.getContent();
+                JSONObject jsonObject = JSONObject.parseObject(content);
+                String text = jsonObject.getString("value");
+                List<QwSop> qwSopList = qwSopService.selectQwSopByTempId(tempId);//通过tempId查询出所有sop
+                if(qwSopList != null && !qwSopList.isEmpty()){
+                    for (QwSop qwSop : qwSopList) {
+                        if(qwSop != null && qwSop.getQwUserIds() != null){
+                            //查询出所有的tempContent来筛选文字
+                            List<QwSopTempContent> qwSopTempContentList = qwSopTempContentService.selectQwSopTempContentByTempId(tempId);
+                            if(qwSopTempContentList != null && !qwSopTempContentList.isEmpty()){
+                                for (QwSopTempContent qwSopTemp : qwSopTempContentList) {
+                                    if(qwSopTemp != null && qwSopTemp.getContentType() == 7){
+                                        String[] split = qwSop.getQwUserIds().split(",");
+                                        Long[] qwUserIds = (Long[]) ConvertUtils.convert(split, Long.class);
+                                        List<QwUserVO> qwUserVOS = qwUserService.selectQwUserVOByIds(qwUserIds);
+                                        if(qwUserVOS != null){
+                                            for (QwUserVO qwUserVO : qwUserVOS) {
+                                                Long companyUserId = qwUserVO.getCompanyUserId();
+                                                QwSopTempVoice qwSopTempVoice = qwSopTempVoiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(companyUserId,text);
+                                                if(qwSopTempVoice == null){
+                                                    if(companyUserId != null && text != null){
+                                                        QwSopTempVoice sopTempVoice = new QwSopTempVoice();
+                                                        sopTempVoice.setCompanyUserId(companyUserId);
+                                                        sopTempVoice.setVoiceTxt(text);
+                                                        sopTempVoice.setTempId(tempId);
+                                                        sopTempVoice.setRecordType(0);
+                                                        qwSopTempVoiceService.insertQwSopTempVoice(sopTempVoice);
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
         if(!voiceList.isEmpty()){
             rocketMQTemplate.syncSend("voice-generation", JSON.toJSONString(VoiceVo.builder().type(0).id(day.getId().toString()).build()));
         }

+ 39 - 4
fs-service/src/main/java/com/fs/sop/service/impl/SopUserLogsInfoServiceImpl.java

@@ -40,10 +40,7 @@ import com.fs.qw.vo.GroupUserExternalVo;
 import com.fs.qw.vo.QwSopCourseFinishTempSetting;
 import com.fs.qw.vo.QwSopRuleTimeVO;
 import com.fs.qw.vo.QwTagGroupListVO;
-import com.fs.sop.domain.QwSop;
-import com.fs.sop.domain.QwSopLogs;
-import com.fs.sop.domain.SopUserLogs;
-import com.fs.sop.domain.SopUserLogsInfo;
+import com.fs.sop.domain.*;
 import com.fs.sop.mapper.QwSopLogsMapper;
 import com.fs.sop.mapper.QwSopMapper;
 import com.fs.sop.mapper.SopUserLogsInfoMapper;
@@ -53,6 +50,7 @@ import com.fs.sop.params.BatchSopUserLogsInfoParamU;
 import com.fs.sop.params.SendUserLogsInfoMsgParam;
 import com.fs.sop.params.SopUserLogsParamByDate;
 import com.fs.sop.service.IQwSopService;
+import com.fs.sop.service.IQwSopTempVoiceService;
 import com.fs.sop.service.ISopUserLogsInfoService;
 import com.fs.sop.service.ISopUserLogsService;
 import com.fs.sop.vo.ExtCourseSopWatchLogVO;
@@ -167,6 +165,9 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
     @Autowired
     private CompanyMapper companyMapper;
 
+    @Autowired
+    private IQwSopTempVoiceService sopTempVoiceService;
+
 
     @Override
     public void save(SopUserLogsInfo sopUserLogsInfo) {
@@ -617,6 +618,10 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
 
                                 st.setMiniprogramPage(linkByMiniApp);
                                 break;
+                            //语音
+                            case "7":
+                                createVoiceUrl(st, companyUserId, qwSop);
+                                break;
                         }
                     }
                     setting.setSetting(list);
@@ -716,6 +721,12 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
 
                                 st.setMiniprogramPage(linkByMiniApp);
                                 break;
+                            //语音
+                            case "7":
+                                if (qwUser.getCompanyUserId() != null) {
+                                    createVoiceUrl(st, String.valueOf(qwUser.getCompanyUserId()), qwSop);
+                                }
+                                break;
                         }
                     }
                     setting.setSetting(list);
@@ -889,6 +900,10 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
 
                             st.setMiniprogramPage(linkByMiniApp);
 
+                            break;
+                        //语音
+                        case "7":
+                            createVoiceUrl(st, companyUserId, qwSop);
                             break;
                         //app
                         case "9":
@@ -948,6 +963,22 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
         return R.ok();
     }
 
+    private void createVoiceUrl(QwSopCourseFinishTempSetting.Setting st, String companyUserId, QwSop qwSop) {
+        QwSopTempVoice qwSopTempVoice = sopTempVoiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(Long.valueOf(companyUserId), st.getValue());
+        if (qwSopTempVoice != null && qwSopTempVoice.getVoiceUrl() != null && qwSopTempVoice.getRecordType() == 1) {
+            st.setVoiceUrl(qwSopTempVoice.getVoiceUrl());
+            st.setVoiceDuration(String.valueOf(qwSopTempVoice.getDuration()));
+        } else if (qwSopTempVoice == null) {
+            if(st.getValue() != null){
+                qwSopTempVoice = new QwSopTempVoice();
+                qwSopTempVoice.setCompanyUserId(Long.valueOf(companyUserId));
+                qwSopTempVoice.setVoiceTxt(st.getValue());
+                qwSopTempVoice.setRecordType(0);
+                sopTempVoiceService.insertQwSopTempVoice(qwSopTempVoice);
+            }
+        }
+    }
+
     @Override
     public R sendUserLogsInfoMsgType(SendUserLogsInfoMsgParam param) {
         //营期一键群发
@@ -1305,6 +1336,10 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
                     st.setMiniprogramPage(linkByMiniApp);
                     break;
 
+                case "7":
+                    QwSop qwSop = qwSopMapper.selectQwSopById(param.getSopId());
+                    createVoiceUrl(st, companyUserId, qwSop);
+                    break;
                 //自定义小程序
                 case "10":
 

+ 5 - 1
fs-service/src/main/resources/mapper/sop/QwSopTempContentMapper.xml

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="QwSopTempContent" id="QwSopTempContentResult">
         <result property="id"    column="id"    />
         <result property="rulesId"    column="rules_id"    />
+        <result property="contentType"    column="content_type"    />
         <result property="sendType"    column="send_type"    />
         <result property="content"    column="content"    />
         <result property="isBindUrl"    column="is_bind_url"    />
@@ -14,13 +15,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectQwSopTempContentVo">
-        select id, rules_id, send_type, content, is_bind_url, expires_days from qw_sop_temp_content
+        select id, rules_id, content_type, send_type, content, is_bind_url, expires_days from qw_sop_temp_content
     </sql>
 
     <select id="selectQwSopTempContentList" parameterType="QwSopTempContent" resultMap="QwSopTempContentResult">
         <include refid="selectQwSopTempContentVo"/>
         <where>
             <if test="rulesId != null  and rulesId != ''"> and rules_id = #{rulesId}</if>
+            <if test="contentType != null "> and content_type = #{contentType}</if>
             <if test="sendType != null "> and send_type = #{sendType}</if>
             <if test="content != null  and content != ''"> and content = #{content}</if>
             <if test="isBindUrl != null "> and is_bind_url = #{isBindUrl}</if>
@@ -56,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="id != null">id,</if>
             <if test="rulesId != null">rules_id,</if>
+            <if test="contentType != null">content_type,</if>
             <if test="sendType != null">send_type,</if>
             <if test="content != null">content,</if>
             <if test="isBindUrl != null">is_bind_url,</if>
@@ -64,6 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
             <if test="rulesId != null">#{rulesId},</if>
+            <if test="contentType != null">#{contentType},</if>
             <if test="sendType != null">#{sendType},</if>
             <if test="content != null">#{content},</if>
             <if test="isBindUrl != null">#{isBindUrl},</if>

+ 64 - 44
fs-service/src/main/resources/mapper/sop/QwSopTempVoiceMapper.xml

@@ -1,28 +1,29 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.sop.mapper.QwSopTempVoiceMapper">
 
     <resultMap type="QwSopTempVoice" id="QwSopTempVoiceResult">
         <result property="id"    column="id"    />
-        <result property="qwUserId"    column="qw_user_id"    />
+        <result property="companyUserId"    column="company_user_id"    />
         <result property="tempId"    column="temp_id"    />
         <result property="ruleId"    column="rule_id"    />
         <result property="contentId"    column="content_id"    />
         <result property="voiceTxt"    column="voice_txt"    />
         <result property="voiceUrl"    column="voice_url"    />
+        <result property="userVoiceUrl"    column="user_voice_url"    />
+        <result property="recordType"    column="record_type"    />
         <result property="createTime"    column="create_time"    />
     </resultMap>
 
     <sql id="selectQwSopTempVoiceVo">
-        select id, qw_user_id, temp_id, rule_id, content_id, voice_txt, voice_url, create_time from qw_sop_temp_voice
+        select id,company_user_id, temp_id, rule_id, content_id, voice_txt, voice_url, create_time from qw_sop_temp_voice
     </sql>
 
     <select id="selectQwSopTempVoiceList" parameterType="QwSopTempVoice" resultMap="QwSopTempVoiceResult">
         <include refid="selectQwSopTempVoiceVo"/>
         <where>
-            <if test="qwUserId != null  and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
             <if test="tempId != null  and tempId != ''"> and temp_id = #{tempId}</if>
             <if test="ruleId != null "> and rule_id = #{ruleId}</if>
             <if test="contentId != null "> and content_id = #{contentId}</if>
@@ -32,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectQwSopTempVoiceById" parameterType="Long" resultMap="QwSopTempVoiceResult">
-        <include refid="selectQwSopTempVoiceVo"/>
+        select id,company_user_id,duration, temp_id, rule_id, content_id, voice_txt, voice_url,user_voice_url,record_type, create_time from qw_sop_temp_voice
         where id = #{id}
     </select>
     <select id="listVoice" resultType="com.fs.sop.domain.QwSopTempVoice">
@@ -42,9 +43,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="getVoice" resultType="com.fs.sop.domain.QwSopTempVoice">
         select a.* from qw_sop_temp_voice a
         where a.company_user_id = #{companyUserId}
-        and a.company_id = #{companyId}
-        and a.temp_id = #{tempId}
-        and a.rule_id = #{rulesId}
+          and a.company_id = #{companyId}
+          and a.temp_id = #{tempId}
+          and a.rule_id = #{rulesId}
     </select>
     <select id="listVoiceTemp" resultType="com.fs.sop.domain.QwSopTempVoice">
         select * from qw_sop_temp_voice a where a.temp_id = #{tempId} and a.day_id =#{dayId}
@@ -59,49 +60,98 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where a.company_user_id in <foreach collection="userIdList" open="(" separator="," close=")" item="item">#{item}</foreach>
     </select>
 
+    <select id="selectQwSopTempVoiceByIdAndText" resultType="com.fs.sop.domain.QwSopTempVoice">
+        select id,company_user_id companyUserId,voice_txt voiceTxt from qw_sop_temp_voice where id = #{id}
+                                                                                            and voice_txt = #{voiceTxt} and record_type in (0,1) limit 1
+    </select>
+    <select id="selectQwSopTempVoiceByIdAndUserVoiceUrl" resultType="com.fs.sop.domain.QwSopTempVoice">
+        select id,company_user_id companyUserId from qw_sop_temp_voice where id = #{id} and record_type in (0,1,2) limit 1
+    </select>
+    <select id="selectQwSopTempVoiceNewList" resultType="com.fs.sop.domain.QwSopTempVoice">
+        select id,voice_txt voiceTxt,company_user_id companyUserId,voice_url voiceUrl,duration,record_type recordType,
+        user_voice_url userVoiceUrl from qw_sop_temp_voice
+        <where>
+            <if test="companyUserId != null"> and company_user_id = #{companyUserId}</if>
+            <if test="recordType != null"> and record_type = #{recordType}</if>
+        </where>
+        order by update_time desc,id desc
+    </select>
+
+    <select id="selectQwSopTempVoiceByQwUserIds" resultMap="QwSopTempVoiceResult">
+        select * from qw_sop_temp_voice where record_type = 0 and qw_user_id in
+        <foreach item="qwUserId" collection="ids"  open="(" separator="," close=")">
+            #{qwUserId}
+        </foreach>
+    </select>
+    <select id="selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt" resultType="com.fs.sop.domain.QwSopTempVoice">
+        select qw_user_id qwUserId,voice_url voiceUrl,voice_txt voiceTxt,user_voice_url userVoiceUrl,company_user_id companyUserId,
+               record_type recordType,duration from qw_sop_temp_voice where company_user_id = #{companyUserId} and voice_txt = #{voiceTxt}
+    </select>
+    <select id="selectQwSopTempVoiceByCompanyUserIdAndQwUserId" resultType="com.fs.sop.domain.QwSopTempVoice">
+        select id,company_user_id companyUserId,voice_url voiceUrl,voice_txt voiceTxt,duration
+        from qw_sop_temp_voice
+        where company_user_id = #{companyUserId} and qw_user_id = #{qwUserId}
+          and voice_url  is not null
+            limit 1
+    </select>
+    <select id="selectQwSopTempVoiceListLimit" resultType="com.fs.sop.domain.QwSopTempVoice">
+        select id,voice_txt voiceTxt,company_user_id companyUserId,voice_url voiceUrl,duration,record_type recordType,
+               user_voice_url userVoiceUrl from qw_sop_temp_voice
+        where record_type = #{recordType} and company_user_id is not null
+        order by date_format(create_time,'%y%m%d') desc,company_user_id desc limit 10
+    </select>
+
     <insert id="insertQwSopTempVoice" parameterType="QwSopTempVoice" useGeneratedKeys="true" keyProperty="id">
         insert into qw_sop_temp_voice
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="companyUserId != null">company_user_id,</if>
+            <if test="qwUserId != null">qw_user_id,</if>
             <if test="companyId != null">company_id,</if>
             <if test="tempId != null">temp_id,</if>
             <if test="ruleId != null">rule_id,</if>
             <if test="contentId != null">content_id,</if>
             <if test="voiceTxt != null">voice_txt,</if>
             <if test="voiceUrl != null">voice_url,</if>
+            <if test="userVoiceUrl != null">user_voice_url,</if>
             <if test="createTime != null">create_time,</if>
             <if test="duration != null">duration,</if>
-         </trim>
+            <if test="recordType != null">record_type,</if>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="companyUserId != null">#{companyUserId},</if>
+            <if test="qwUserId != null">#{qwUserId},</if>
             <if test="companyId != null">#{companyId},</if>
             <if test="tempId != null">#{tempId},</if>
             <if test="ruleId != null">#{ruleId},</if>
             <if test="contentId != null">#{contentId},</if>
             <if test="voiceTxt != null">#{voiceTxt},</if>
             <if test="voiceUrl != null">#{voiceUrl},</if>
+            <if test="userVoiceUrl != null">#{userVoiceUrl},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="duration != null">#{duration},</if>
-         </trim>
+            <if test="recordType != null">#{recordType},</if>
+        </trim>
     </insert>
     <insert id="insertBatch">
-        INSERT INTO qw_sop_temp_voice (temp_id, company_user_id, day_id, company_id, content_id, rule_id, voice_txt, voice_url, duration)
+        INSERT INTO qw_sop_temp_voice (temp_id, company_user_id, day_id, company_id, content_id, rule_id, voice_txt, voice_url,record_type, duration)
         VALUES
         <foreach collection="list" item="item" separator=",">
-            (#{item.tempId}, #{item.companyUserId}, #{item.dayId}, #{item.companyId}, #{item.contentId}, #{item.ruleId}, #{item.voiceTxt}, #{item.voiceUrl}, #{item.duration})
+            (#{item.tempId}, #{item.companyUserId}, #{item.dayId}, #{item.companyId}, #{item.contentId}, #{item.ruleId}, #{item.voiceTxt}, #{item.voiceUrl}, #{item.recordType},#{item.duration})
         </foreach>
     </insert>
 
     <update id="updateQwSopTempVoice" parameterType="QwSopTempVoice">
         update qw_sop_temp_voice
         <trim prefix="SET" suffixOverrides=",">
-            <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
             <if test="tempId != null">temp_id = #{tempId},</if>
             <if test="ruleId != null">rule_id = #{ruleId},</if>
             <if test="contentId != null">content_id = #{contentId},</if>
             <if test="voiceTxt != null">voice_txt = #{voiceTxt},</if>
             <if test="voiceUrl != null">voice_url = #{voiceUrl},</if>
+            <if test="userVoiceUrl != null">user_voice_url = #{userVoiceUrl},</if>
+            <if test="recordType != null">record_type = #{recordType},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="duration != null">duration = #{duration},</if>
         </trim>
         where id = #{id}
     </update>
@@ -119,34 +169,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <delete id="remove">
         delete from qw_sop_temp_voice a where a.temp_id = #{tempId} and a.day_id =#{dayId}
     </delete>
-
-    <select id="selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt" resultType="com.fs.sop.domain.QwSopTempVoice">
-        select qw_user_id qwUserId,voice_url voiceUrl,voice_txt voiceTxt,user_voice_url userVoiceUrl,company_user_id companyUserId,
-               record_type recordType,duration from qw_sop_temp_voice where company_user_id = #{companyUserId} and voice_txt = #{voiceTxt}
-    </select>
-    <select id="selectQwSopTempVoiceByCompanyUserIdAndQwUserId" resultType="com.fs.sop.domain.QwSopTempVoice">
-        select id,company_user_id companyUserId,voice_url voiceUrl,voice_txt voiceTxt,duration
-        from qw_sop_temp_voice
-        where company_user_id = #{companyUserId} and qw_user_id = #{qwUserId}
-          and voice_url  is not null
-            limit 1
-    </select>
-    <select id="selectQwSopTempVoiceListLimit" resultType="com.fs.sop.domain.QwSopTempVoice">
-        select id,voice_txt voiceTxt,company_user_id companyUserId,voice_url voiceUrl,duration,record_type recordType,
-               user_voice_url userVoiceUrl from qw_sop_temp_voice
-        where record_type = #{recordType} and company_user_id is not null
-        order by date_format(create_time,'%y%m%d') desc,company_user_id desc limit 10
-    </select>
-    <select id="selectQwSopTempVoiceByIdAndUserVoiceUrl" resultType="com.fs.sop.domain.QwSopTempVoice">
-        select id,company_user_id companyUserId from qw_sop_temp_voice where id = #{id} and record_type in (0,1,2) limit 1
-    </select>
-    <select id="selectQwSopTempVoiceNewList" resultType="com.fs.sop.domain.QwSopTempVoice">
-        select id,voice_txt voiceTxt,company_user_id companyUserId,voice_url voiceUrl,duration,record_type recordType,
-        user_voice_url userVoiceUrl from qw_sop_temp_voice
-        <where>
-            <if test="companyUserId != null"> and company_user_id = #{companyUserId}</if>
-            <if test="recordType != null"> and record_type = #{recordType}</if>
-        </where>
-        order by update_time desc,id desc
-    </select>
 </mapper>