瀏覽代碼

今正总后台新增
-通话记录统计
今正优化
-通话记录统计-部门查询条条件-能查询到所选部门及其下级

lk 6 天之前
父節點
當前提交
1fc1b0de11

+ 328 - 0
fs-admin/src/main/java/com/fs/qw/controller/QwUserVoiceLogController.java

@@ -0,0 +1,328 @@
+package com.fs.qw.controller;
+
+import com.fs.common.annotation.Log;
+import com.fs.common.constant.HttpStatus;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.page.PageDomain;
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.core.page.TableSupport;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.ServletUtils;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.company.service.ICompanyUserService;
+//import com.fs.framework.security.LoginUser;
+//import com.fs.framework.service.TokenService;
+import com.fs.qw.domain.QwUserVoiceLog;
+import com.fs.qw.param.QwTagSearchParam;
+import com.fs.qw.service.IQwTagService;
+import com.fs.qw.service.IQwUserVoiceLogService;
+import com.fs.qw.vo.QwUserVoiceLogTotalVo;
+import com.fs.qw.vo.QwUserVoiceLogVo;
+import com.github.pagehelper.PageHelper;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 企微用户通话记录Controller
+ *
+ * @author fs
+ * @date 2025-05-08
+ */
+@RestController
+@RequestMapping("/qw/qwUserVoiceLog")
+public class QwUserVoiceLogController extends BaseController
+{
+    @Autowired
+    private IQwUserVoiceLogService qwUserVoiceLogService;
+
+//    @Autowired
+//    private TokenService tokenService;
+
+    @Autowired
+    private IQwTagService iQwTagService;
+
+    @Autowired
+    private ICompanyUserService userService;
+
+//    /**
+//     * 查询企微用户通话记录列表
+//     */
+//    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:list')")
+//    @GetMapping("/list")
+//    public TableDataInfo list(QwUserVoiceLogVo qwUserVoiceLog)
+//    {
+//        startPage();
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        qwUserVoiceLog.setCompanyId(loginUser.getCompany().getCompanyId());
+//        List<QwUserVoiceLogVo> list = qwUserVoiceLogService.selectQwUserVoiceLogList(qwUserVoiceLog);
+//        return getDataTable(list);
+//    }
+
+
+//    /**
+//     * 查询企微用户通话记录列表
+//     */
+//    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:list')")
+//    @PostMapping("/newList")
+//    public TableDataInfo newList(@RequestBody QwUserVoiceLogVo qwUserVoiceLog)
+//    {
+//        PageHelper.startPage(qwUserVoiceLog.getPageNum(), qwUserVoiceLog.getPageSize());
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        qwUserVoiceLog.setCompanyId(loginUser.getCompany().getCompanyId());
+//        List<QwUserVoiceLogVo> list = qwUserVoiceLogService.selectQwUserVoiceLogList(qwUserVoiceLog);
+//        list.forEach(item->{
+//
+//            if (!Objects.equals(item.getQwExternalContact().getTagIds(), "[]") && item.getQwExternalContact().getTagIds()!=null) {
+//                QwTagSearchParam param = new QwTagSearchParam();
+//                Gson gson = new Gson();
+//                List<String> tagIds = gson.fromJson(
+//                        item.getQwExternalContact().getTagIds(),
+//                        new TypeToken<List<String>>() {
+//                        }.getType()
+//                );
+//                param.setTagIds(tagIds);
+//                item.setTagIdsName(iQwTagService.selectQwTagListByTagIds(param));
+//            }
+//        });
+//        return getDataTable(list);
+//    }
+
+//    /**
+//     * 查询我的通话记录列表
+//     * @param qwUserVoiceLog
+//     * @return
+//     */
+//    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:myList')")
+//    @GetMapping("/myList")
+//    public TableDataInfo myList(QwUserVoiceLogVo qwUserVoiceLog)
+//    {
+//        startPage();
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        qwUserVoiceLog.setCompanyUserId(loginUser.getUser().getUserId());
+//        qwUserVoiceLog.setCompanyId(loginUser.getCompany().getCompanyId());
+//        List<QwUserVoiceLogVo> list = qwUserVoiceLogService.selectQwUserVoiceLogList(qwUserVoiceLog);
+//        return getDataTable(list);
+//    }
+
+//    /**
+//     * 导出我的通话记录
+//     */
+//
+//    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:myExport')")
+//    @Log(title = "我的通话记录", businessType = BusinessType.EXPORT)
+//    @GetMapping("/myExport")
+//    public AjaxResult myExport(QwUserVoiceLogVo qwUserVoiceLog)
+//    {
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        qwUserVoiceLog.setCompanyUserId(loginUser.getUser().getUserId());
+//        qwUserVoiceLog.setCompanyId(loginUser.getCompany().getCompanyId());
+//        List<QwUserVoiceLogVo> list = qwUserVoiceLogService.selectQwUserVoiceLogList(qwUserVoiceLog);
+//        list.forEach(m-> {
+//            m.setCompanyUserName(m.getCompanyUser().getUserName());
+//            m.setCompanyName(m.getCompany().getCompanyName());
+//            m.setExtName(m.getQwExternalContact().getName());
+//            m.setQwUserName(m.getQwUser().getQwUserName());
+//        });
+//        ExcelUtil<QwUserVoiceLogVo> util = new ExcelUtil<QwUserVoiceLogVo>(QwUserVoiceLogVo.class);
+//        return util.exportExcel(list, "企微用户通话记录数据");
+//    }
+
+
+    /**
+     * 统计查询企微用户通话记录
+     * @param qwUserVoiceLog
+     * @return
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:totalList')")
+    @GetMapping("/totalList")
+    public TableDataInfo totalList(QwUserVoiceLogTotalVo qwUserVoiceLog)
+    {
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        qwUserVoiceLog.setCompanyId(loginUser.getCompany().getCompanyId());
+        qwUserVoiceLog.setQwUserId(1L);
+        List<QwUserVoiceLogTotalVo> list = qwUserVoiceLogService.selectQwUserVoiceLogTotalList(qwUserVoiceLog);
+        list.forEach(item->{
+            if(item.getQwExternalContact() != null){
+                if (item.getQwExternalContact().getTagIds() != null && !Objects.equals(item.getQwExternalContact().getTagIds(), "[]")) {
+                    QwTagSearchParam param = new QwTagSearchParam();
+                    Gson gson = new Gson();
+                    List<String> tagIds = gson.fromJson(
+                            item.getQwExternalContact().getTagIds(),
+                            new TypeToken<List<String>>() {
+                            }.getType()
+                    );
+                    param.setTagIds(tagIds);
+                    item.setTagIdsName(iQwTagService.selectQwTagListByTagIds(param));
+                }
+            }
+        });
+
+        // 获取分页参数
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = pageDomain.getPageNum();
+        Integer pageSize = pageDomain.getPageSize();
+
+        int total = list.size();
+        // 在内存中进行分页处理
+        if (pageNum != null && pageSize != null) {
+            int fromIndex = (pageNum - 1) * pageSize;
+            int toIndex = Math.min(fromIndex + pageSize, total);
+
+            // 确保索引不越界
+            if (fromIndex < total) {
+                list = list.subList(fromIndex, toIndex);
+            } else {
+                list = new ArrayList<>(); // 返回空列表
+            }
+        }
+
+        // 构造返回结果
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.SUCCESS);
+        rspData.setMsg("查询成功");
+        rspData.setRows(list);
+        rspData.setTotal(total);
+        return rspData;
+    }
+
+
+    @GetMapping("/sellTotalList")
+    public TableDataInfo sellTotalList(QwUserVoiceLogTotalVo qwUserVoiceLog)
+    {
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        qwUserVoiceLog.setCompanyId(loginUser.getCompany().getCompanyId());
+        List<QwUserVoiceLogTotalVo> list = qwUserVoiceLogService.selectQwUserVoiceLogTotalList(qwUserVoiceLog);
+
+        // 获取分页参数
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = pageDomain.getPageNum();
+        Integer pageSize = pageDomain.getPageSize();
+
+        int total = list.size();
+        // 在内存中进行分页处理
+        if (pageNum != null && pageSize != null) {
+            int fromIndex = (pageNum - 1) * pageSize;
+            int toIndex = Math.min(fromIndex + pageSize, total);
+
+            // 确保索引不越界
+            if (fromIndex < total) {
+                list = list.subList(fromIndex, toIndex);
+            } else {
+                list = new ArrayList<>(); // 返回空列表
+            }
+        }
+
+        // 构造返回结果
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.SUCCESS);
+        rspData.setMsg("查询成功");
+        rspData.setRows(list);
+        rspData.setTotal(total);
+        return rspData;
+    }
+
+    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:sellTotalExport')")
+    @Log(title = "企微用户通话记录统计", businessType = BusinessType.EXPORT)
+    @GetMapping("/sellTotalExport")
+    public AjaxResult sellTotalExport(QwUserVoiceLogTotalVo qwUserVoiceLog)
+    {
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        qwUserVoiceLog.setCompanyId(loginUser.getCompany().getCompanyId());
+        List<QwUserVoiceLogTotalVo> list = qwUserVoiceLogService.selectQwUserVoiceLogTotalList(qwUserVoiceLog);
+        list.forEach(m-> {
+            m.setQwUserName(m.getQwUser().getQwUserName());
+        });
+        ExcelUtil<QwUserVoiceLogTotalVo> util = new ExcelUtil<QwUserVoiceLogTotalVo>(QwUserVoiceLogTotalVo.class);
+        return util.exportExcel(list, "企微用户通话记录数据");
+    }
+
+//    /**
+//     * 导出统计企微用户通话记录
+//     */
+//    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:totalExport')")
+//    @Log(title = "企微用户通话记录统计", businessType = BusinessType.EXPORT)
+//    @GetMapping("/totalExport")
+//    public AjaxResult totalExport(QwUserVoiceLogTotalVo qwUserVoiceLog)
+//    {
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        qwUserVoiceLog.setCompanyId(loginUser.getCompany().getCompanyId());
+//        qwUserVoiceLog.setQwUserId(1L);
+//        List<QwUserVoiceLogTotalVo> list = qwUserVoiceLogService.selectQwUserVoiceLogTotalList(qwUserVoiceLog);
+//        list.forEach(m-> {
+//            m.setQwUserName(m.getQwUser().getQwUserName());
+//        });
+//        ExcelUtil<QwUserVoiceLogTotalVo> util = new ExcelUtil<QwUserVoiceLogTotalVo>(QwUserVoiceLogTotalVo.class);
+//        return util.exportExcel(list, "企微用户通话记录数据");
+//    }
+
+
+    /**
+     * 导出企微用户通话记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:export')")
+    @Log(title = "企微用户通话记录", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(QwUserVoiceLogVo qwUserVoiceLog)
+    {
+        List<QwUserVoiceLogVo> list = qwUserVoiceLogService.selectQwUserVoiceLogList(qwUserVoiceLog);
+        list.forEach(m-> {
+            m.setCompanyUserName(m.getCompanyUser().getUserName());
+            m.setCompanyName(m.getCompany().getCompanyName());
+            m.setExtName(m.getQwExternalContact().getName());
+            m.setQwUserName(m.getQwUser().getQwUserName());
+        });
+        ExcelUtil<QwUserVoiceLogVo> util = new ExcelUtil<QwUserVoiceLogVo>(QwUserVoiceLogVo.class);
+        return util.exportExcel(list, "企微用户通话记录数据");
+    }
+
+    /**
+     * 获取企微用户通话记录详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(qwUserVoiceLogService.selectQwUserVoiceLogById(id));
+    }
+
+    /**
+     * 新增企微用户通话记录
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:add')")
+    @Log(title = "企微用户通话记录", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody QwUserVoiceLog qwUserVoiceLog)
+    {
+        return toAjax(qwUserVoiceLogService.insertQwUserVoiceLog(qwUserVoiceLog));
+    }
+
+    /**
+     * 修改企微用户通话记录
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:edit')")
+    @Log(title = "企微用户通话记录", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody QwUserVoiceLog qwUserVoiceLog)
+    {
+        return toAjax(qwUserVoiceLogService.updateQwUserVoiceLog(qwUserVoiceLog));
+    }
+
+    /**
+     * 删除企微用户通话记录
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwUserVoiceLog:remove')")
+    @Log(title = "企微用户通话记录", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(qwUserVoiceLogService.deleteQwUserVoiceLogByIds(ids));
+    }
+}

+ 8 - 1
fs-service/src/main/java/com/fs/qw/service/impl/QwUserVoiceLogServiceImpl.java

@@ -2,7 +2,9 @@ package com.fs.qw.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fs.common.utils.DateUtils;
+import com.fs.company.domain.CompanyDept;
 import com.fs.company.domain.CompanyUser;
+import com.fs.company.mapper.CompanyDeptMapper;
 import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.qw.domain.*;
 import com.fs.qw.mapper.QwExternalContactMapper;
@@ -50,6 +52,9 @@ public class QwUserVoiceLogServiceImpl extends ServiceImpl<QwUserVoiceLogMapper,
 
     @Autowired
     private CompanyUserMapper companyUserMapper;
+    @Autowired
+    private CompanyDeptMapper companyDeptMapper;
+
     /**
      * 查询企微用户通话记录
      *
@@ -136,9 +141,11 @@ public class QwUserVoiceLogServiceImpl extends ServiceImpl<QwUserVoiceLogMapper,
 
             // 如果有部门过滤条件,则预先过滤用户列表
             if (qwUserVoiceLog.getDeptId() != null) {
+                Set<Long> deptIds = companyDeptMapper.selectChildrenDeptById(qwUserVoiceLog.getDeptId()).stream().map(CompanyDept::getDeptId).collect(Collectors.toSet());
                 companyUserMap.entrySet().removeIf(entry ->
                         entry.getValue().getDeptId() == null ||
-                                !entry.getValue().getDeptId().equals(qwUserVoiceLog.getDeptId()));
+                                !deptIds.contains(entry.getValue().getDeptId()));//需要deptId及其下级的部门
+//                                !entry.getValue().getDeptId().equals(qwUserVoiceLog.getDeptId()));
             }
 
             // 设置用户姓名和部门ID

+ 2 - 2
fs-user-app/src/main/java/com/fs/app/controller/CompanyUserController.java

@@ -198,7 +198,7 @@ public class CompanyUserController extends AppBaseController {
         companyUser.setVoicePrintUrl(param.getVoicePrintUrl());
 
         //转换音频格式 mp3-wav
-        String s = AudioUtils.audioWAVFromUrl(param.getVoicePrintUrl());
+        String s = AudioUtils.audioWAVFromUrl(param.getVoicePrintUrl());//需要本地c盘根目录有ffmpeg.exe,silk_v3_decoder.exe,silk_v3_encoder.exe
         //保存文件并且上传存储桶
         System.out.println(s);
         File file = new File(s);
@@ -567,7 +567,7 @@ public class CompanyUserController extends AppBaseController {
         MultipartFile convert = FileToMultipartConverterUtil.convert(file);
         R r = voiceCloneController.uploadVoice(vcCompanyUser.getSpeakerId(), convert, 1, 0);
         if (r.get("code") != "200")
-        return AjaxResult.error("上传声纹失败", r.get("msg"));
+            return AjaxResult.error("上传声纹失败", r.get("msg"));
         vcCompanyUser.incrementTimes();
         vcCompanyUser.setUploadTime(duration);
         companyUserMapper.updateVcCompanyUser(vcCompanyUser);