Kaynağa Gözat

看课明细查询

xgb 2 hafta önce
ebeveyn
işleme
4b4dad7e0e

+ 11 - 0
fs-company/src/main/java/com/fs/app/controller/im/FsImMsgSendLogController.java

@@ -6,7 +6,10 @@ import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.framework.security.LoginUser;
+import com.fs.framework.service.TokenService;
 import com.fs.im.domain.FsImMsgSendLog;
 import com.fs.im.service.IFsImMsgSendLogService;
 import com.github.pagehelper.PageHelper;
@@ -27,11 +30,17 @@ public class FsImMsgSendLogController extends BaseController {
     @Autowired
     private IFsImMsgSendLogService fsImMsgSendLogService;
 
+    @Autowired
+    private TokenService tokenService;
+
     /**
      * 查询 OpenIM 消息发送记录列表
      */
     @GetMapping("/listImMsgSendLog")
     public TableDataInfo list(FsImMsgSendLogRequest request) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        request.setCompanyId(loginUser.getCompany().getCompanyId());
+
         PageHelper.startPage(request.getPageNum(), request.getPageSize());
         List<FsImMsgSendLogResponse> list = fsImMsgSendLogService.selectFsImMsgSendLogInfoList(request);
         return getDataTable(list);
@@ -52,6 +61,8 @@ public class FsImMsgSendLogController extends BaseController {
      */
     @GetMapping("/getImMsgSendStatistics")
     public R statistics(FsImMsgSendLogRequest request) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        request.setCompanyId(loginUser.getCompany().getCompanyId());
         return fsImMsgSendLogService.getFsImMsgSendStatistics(request);
     }
 }

+ 2 - 2
fs-service/src/main/java/com/fs/im/service/impl/FsImMsgSendLogServiceImpl.java

@@ -207,8 +207,8 @@ public class FsImMsgSendLogServiceImpl extends ServiceImpl<FsImMsgSendLogMapper,
 
     @Override
     public R getFsImMsgSendStatistics(FsImMsgSendLogRequest request) {
-        FsImMsgSendLogStatisticsResponse log=baseMapper.getFsImMsgSendStatistics(request);
+        FsImMsgSendLogStatisticsResponse data=baseMapper.getFsImMsgSendStatistics(request);
 
-        return null;
+        return R.ok().put("data",data);
     }
 }

+ 25 - 12
fs-service/src/main/resources/mapper/im/FsImMsgSendLogMapper.xml

@@ -229,8 +229,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         d.user_id AS userId,
         d.status AS status,
         d.exception_info AS exceptionInfo
-        FROM fs_im_msg_send_log l
-        LEFT JOIN fs_im_msg_send_detail d ON l.log_id = d.log_id
+        FROM  fs_im_msg_send_detail d
+        LEFT JOIN fs_im_msg_send_log l ON l.log_id = d.log_id
         <where>
             <if test="companyUserId != null"> AND l.company_user_id = #{companyUserId}</if>
             <if test="companyId != null"> AND l.company_id = #{companyId}</if>
@@ -257,18 +257,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="getFsImMsgSendStatistics" resultType="com.fs.app.service.param.FsImMsgSendLogStatisticsResponse">
         SELECT
-            count(d.log_id) as total,
+            count(d.log_detail_id) as total,
             sum(case when d.status = 0 then 1 else 0 end) as sent,
             sum(case when d.send_status = 2 then 1 else 0 end) as pending,
-            sum(case when d.status = 1 then 1 else 0 end) as failed,
-
-            COUNT(DISTINCT log.log_id) AS total,
-            COUNT(DISTINCT log.log_id) FILTER (WHERE log.send_status = 1) AS sent,
-            COUNT(DISTINCT log.log_id) FILTER (WHERE log.send_status = 2) AS pending,
-            COUNT(DISTINCT log.log_id) FILTER (WHERE log.send_status = 3) AS failed
-        FROM
-            FROM fs_im_msg_send_log l
-        LEFT JOIN fs_im_msg_send_detail d ON l.log_id = d.log_id
+            sum(case when d.status = 1 then 1 else 0 end) as failed
+            FROM  fs_im_msg_send_detail d
+        LEFT JOIN fs_im_msg_send_log l  ON l.log_id = d.log_id
+        <where>
+            <if test="companyUserId != null"> AND l.company_user_id = #{companyUserId}</if>
+            <if test="companyId != null"> AND l.company_id = #{companyId}</if>
+            <if test="courseId != null"> AND l.course_id = #{courseId}</if>
+            <if test="courseName != null and courseName != ''"> AND l.course_name like concat('%', #{courseName}, '%')</if>
+            <if test="videoId != null"> AND l.video_id = #{videoId}</if>
+            <if test="videoName != null and videoName != ''"> AND l.video_name like concat('%', #{videoName}, '%')</if>
+            <if test="sendTitle != null and sendTitle != ''"> AND l.send_title like concat('%', #{sendTitle}, '%')</if>
+            <if test="planSendStartTime != null and planSendEndTime != null">
+                AND l.plan_send_time between #{planSendStartTime} and #{planSendEndTime}
+            </if>
+            <if test="sendType != null"> AND l.send_type = #{sendType}</if>
+            <if test="sendMode != null"> AND l.send_mode = #{sendMode}</if>
+            <if test="msgType != null"> AND l.msg_type = #{msgType}</if>
+            <if test="projectId != null"> AND l.project_id = #{projectId}</if>
+            <if test="createTimeStartTime != null and createTimeEndTime != null">
+                AND d.create_time between #{createTimeStartTime} and #{createTimeEndTime}
+            </if>
+        </where>
     </select>