Przeglądaj źródła

1.修改创建任务时创建语音模板

jzp 1 tydzień temu
rodzic
commit
34c3cbc1f9

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

@@ -1,6 +1,5 @@
 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;
@@ -17,27 +16,19 @@ 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
@@ -62,11 +53,6 @@ public class QwSopController extends BaseController
     @Autowired
     private FsUserCourseVideoMapper fsUserCourseVideoMapper;
 
-    @Autowired
-    private IQwSopTempContentService qwSopTempContentService;
-
-    @Autowired
-    private IQwSopTempVoiceService voiceService;
     /**
      * 查询企微sop列表
      */
@@ -148,62 +134,10 @@ 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(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());
-        }
-    }
-
     /**
      * 修改企微sop
      */
@@ -212,14 +146,7 @@ public class QwSopController extends BaseController
     @PutMapping
     public R edit(@RequestBody QwSop 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;
+        return qwSopService.updateQwSop(qwSop);
     }
 
 
@@ -274,15 +201,7 @@ public class QwSopController extends BaseController
     @PreAuthorize("@ss.hasPermi('qw:sop:updateSopQwUser')")
     public R updateSopQwUser(@RequestBody QwSopEditQwUserParam 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;
+        return qwSopService.updateSopQwUser(param);
     }
 
     /**

+ 85 - 3
fs-company/src/main/java/com/fs/company/controller/qw/QwSopController.java

@@ -1,5 +1,6 @@
 package com.fs.company.controller.qw;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.Log;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.controller.BaseController;
@@ -17,21 +18,29 @@ import com.fs.framework.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.ICompanySopRoleService;
 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.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 企微sopController
@@ -64,6 +73,13 @@ public class QwSopController extends BaseController
     @Autowired
     private IQwUserService iQwUserService;
 
+
+    @Autowired
+    private IQwSopTempContentService qwSopTempContentService;
+
+    @Autowired
+    private IQwSopTempVoiceService voiceService;
+
     /**
      * 查询企微sop列表
      */
@@ -228,7 +244,12 @@ public class QwSopController extends BaseController
         qwSop.setCompanyId(companyId);
         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(qwSopService.insertQwSop(qwSop));
 
     }
@@ -241,7 +262,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;
     }
 
 
@@ -267,6 +295,52 @@ public class QwSopController extends BaseController
         return toAjax(qwSopService.updateAutoSopTime(param));
     }
 
+    /**
+     * 修改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());
+        }
+    }
+
     /**
      * 删除企微sop
      */
@@ -307,7 +381,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;
     }
 
     /**