wangxy před 1 dnem
rodič
revize
721738ed7c

+ 2 - 0
fs-admin/src/main/resources/logback.xml

@@ -78,7 +78,9 @@
 
     <!-- log4j2.xml -->
     <Logger name="com.fs.his.mapper" level="debug"/>
+    <Logger name="com.fs.course.mapper" level="debug"/>
     <Logger name="com.fs.company.mapper" level="debug"/>
+    <Logger name="com.fs.hisStore.mapper" level="debug"/>
     <Logger name="org.apache.ibatis" level="debug"/>
 
 

+ 56 - 0
fs-company/src/main/java/com/fs/company/controller/course/FsCourseWatchLogController.java

@@ -142,6 +142,48 @@ public class FsCourseWatchLogController extends BaseController
 
         return getDataTable(list);
     }
+
+    @PreAuthorize("@ss.hasPermi('course:courseWatchLog:deptListExport')")
+    @GetMapping("/deptListExport")
+    public AjaxResult  deptListExport(FsCourseWatchLogListParam param){
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+
+
+        List<Long> combinedList = new ArrayList<>();
+        //本部门
+        Long deptId = loginUser.getUser().getDeptId();
+        if (deptId!=null){
+            combinedList.add(deptId);
+        }
+        //本部门的下级部门
+        List<Long> deptList = companyDeptService.selectCompanyDeptByParentId(deptId);
+        if (!deptList.isEmpty()){
+            combinedList.addAll(deptList);
+        }
+
+        param.setCuDeptIdList(combinedList);
+        param.setUserType(loginUser.getUser().getUserType());
+        param.setCompanyId(loginUser.getCompany().getCompanyId());
+
+
+        if (ObjectUtil.isNotEmpty(param.getSendType()) &&param.getSendType()==1&& param.getPeriodETime()!=null && param.getPeriodSTime()!=null) {
+            List<Long> periodIds = userCoursePeriodDaysService.selectFsUserCoursePeriodDaysByTime(param.getPeriodSTime(), param.getPeriodETime());
+
+            if (!periodIds.isEmpty()){
+                List<Long> longs = userCoursePeriodService.selectFsUserCoursePeriodListByPeriodId(periodIds, loginUser.getCompany().getCompanyId());
+                if (!longs.isEmpty()){
+                    param.setPeriodIds(longs);
+                }else {
+                   return  AjaxResult.error("请选择营期时间");
+                }
+            }else {
+                return  AjaxResult.error("请选择营期时间");
+            }
+        }
+        List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVO(param);
+        ExcelUtil<FsCourseWatchLogListVO> util = new ExcelUtil<FsCourseWatchLogListVO>(FsCourseWatchLogListVO.class);
+        return util.exportExcel(list, "部门看课记录数据");
+    }
     /**
      * 查询短链课程看课记录列表
      */
@@ -189,6 +231,20 @@ public class FsCourseWatchLogController extends BaseController
         List<FsCourseWatchLogStatisticsListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogStatisticsListVO(param);
         return getDataTable(list);
     }
+//    @PreAuthorize("@ss.hasPermi('course:courseWatchLog:statisticsExport')")
+    @GetMapping("/statisticsExport")
+    public  AjaxResult  statisticsExport(FsCourseWatchLogStatisticsListParam param)
+    {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        param.setCompanyId( loginUser.getCompany().getCompanyId());
+        if (param.getSTime()==null||param.getETime()==null){
+            return AjaxResult.error("请选择时间");
+        }
+        param.setSendType(1); //个微
+        List<FsCourseWatchLogStatisticsListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogStatisticsListVO(param);
+        ExcelUtil<FsCourseWatchLogStatisticsListVO> util = new ExcelUtil<FsCourseWatchLogStatisticsListVO>(FsCourseWatchLogStatisticsListVO.class);
+        return util.exportExcel(list, "会员看课统计");
+    }
 
     @GetMapping("/qwWatchLogStatisticsList")
     public TableDataInfo qwWatchLogStatisticsList(QwWatchLogStatisticsListParam param)

+ 24 - 4
fs-company/src/main/java/com/fs/company/controller/course/FsUserCoursePeriodController.java

@@ -13,6 +13,7 @@ import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.course.domain.FsUserCoursePeriod;
 import com.fs.course.domain.FsUserCoursePeriodDays;
 import com.fs.course.domain.FsUserCourseVideoRedPackage;
+import com.fs.course.mapper.FsUserCompanyUserMapper;
 import com.fs.course.param.CompanyRedPacketParam;
 import com.fs.course.param.FsBatchPeriodRedPackageParam;
 import com.fs.course.param.PeriodCountParam;
@@ -36,10 +37,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.time.LocalDate;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 /**
@@ -57,6 +55,7 @@ public class FsUserCoursePeriodController extends BaseController {
     private final IFsUserCoursePeriodDaysService fsUserCoursePeriodDaysService;
     private final IFsUserCourseVideoRedPackageService fsUserCourseVideoRedPackageService;
     private final TokenService tokenService;
+    private  final FsUserCompanyUserMapper fsUserCompanyUserMapper;
 
     /**
      * 查询会员营期列表
@@ -229,6 +228,27 @@ public class FsUserCoursePeriodController extends BaseController {
         PageHelper.startPage(param.getPageNum(), param.getPageSize());
         FsUserCoursePeriod period = fsUserCoursePeriodService.selectFsUserCoursePeriodById(param.getPeriodId());
         param.setMaxDate(LocalDate.now().plusDays(period.getMaxViewNum()));
+        //销售公司条件
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        param.setCompanyId(loginUser.getCompany().getCompanyId());
+        //权限查询参数
+        List< Long> salesIds=new ArrayList<>();
+        //不是管理员再过滤数据权限
+        if(!loginUser.getUser().isAdmin()){
+            //当前销售的部门经理
+            Long currentUserId = loginUser.getUser().getUserId();
+            if(currentUserId!=null){
+                List<Integer> roles = fsUserCompanyUserMapper.selectCountByUserId(currentUserId);
+                if(roles.contains(1)){
+                    //部门经理需要查询对应部门下的销售
+                    salesIds = fsUserCompanyUserMapper.selectUserIdByDeptId(loginUser.getUser().getDeptId());
+                }else {
+                    //当前销售
+                    salesIds.add(currentUserId);
+                }
+            }
+            param.setCompanyUserIds(salesIds);
+        }
         List<FsPeriodCountVO> list = fsUserCoursePeriodDaysService.periodCourseCount(param);
         long count = fsUserCoursePeriodDaysService.periodCourseByCount(param);
         PageInfo<FsPeriodCountVO> pageInfo = new PageInfo<>(list);

+ 2 - 0
fs-service/src/main/java/com/fs/course/mapper/FsCourseWatchLogMapper.java

@@ -236,6 +236,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             "</if>\n" +
             "<if test= 'sendType == 1 '> " +
             " cu.nick_name qw_user_name," +
+            " ucp.period_name period_name," +
             "</if>\n" +
             "v.title videoName,uc.course_name,\n" +
             "SUM(CASE WHEN o.log_type = '1' THEN 1 ELSE 0 END) AS type1,\n" +
@@ -264,6 +265,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             "LEFT JOIN fs_user_course uc on uc.course_id=v.course_id\n" +
             "<if test= 'sendType == 1 '> " +
             " LEFT JOIN company_user cu on cu.user_id=o.company_user_id\n" +
+            " LEFT JOIN fs_user_course_period ucp on ucp.period_id = o.period_id\n" +
             "</if>\n" +
             "where o.company_id=#{companyId} " +
             "<if test= 'sendType != null '> " +

+ 14 - 0
fs-service/src/main/java/com/fs/course/mapper/FsUserCompanyUserMapper.java

@@ -95,4 +95,18 @@ public interface FsUserCompanyUserMapper extends BaseMapper<FsUserCompanyUser>{
     List<Long> selectFsUserCompanyUserListByMap(@Param("param") Map<String, Object> param);
 
     List<FsUserCompanyUser> selectFsUserCompanyUserByIds(@Param("param") Map<String, Object> param);
+
+    /**
+     * 当前是否是部门经理
+     * @param userId
+     * @return
+     */
+    List<Integer> selectCountByUserId(@Param("userId") Long userId);
+
+    /**
+     * 根据部门id查询销售id
+     * @param deptId
+     * @return
+     */
+    List<Long> selectUserIdByDeptId(@Param("deptId") Long deptId);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/course/param/CourseAnalysisParam.java

@@ -37,5 +37,10 @@ public class CourseAnalysisParam implements Serializable {
     @ApiModelProperty(value = "视频id-管理端传参")
     private List<Long> videoIdList;
 
+    /**
+     * 销售id集合 用于数据权限参数
+     */
+    private  List<Long> companyUserIds;
+
 }
 

+ 5 - 0
fs-service/src/main/java/com/fs/course/param/PeriodCountParam.java

@@ -33,5 +33,10 @@ public class PeriodCountParam implements Serializable {
     @ApiModelProperty(value = "公司ID")
     private Long companyId;
 
+    /**
+     * 销售id集合 用于数据权限参数
+     */
+    private  List<Long> companyUserIds;
+
 }
 

+ 34 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -66,6 +66,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
 import java.time.Duration;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -1294,6 +1295,13 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
 
     @Override
     public List<FsCourseReportVO> selectFsCourseReportVO(FsCourseWatchLogStatisticsListParam param) {
+        //时间处理
+        if(param.getSTime()!=null||param.getETime()!=null){
+            Date date = removeTime(param.getSTime());
+            param.setSTime(date);
+            Date endDate = removeTime(param.getETime());
+            param.setETime(endDate);
+        }
         // 1. 查询公司基础信息
         List<FsCourseReportVO> companyList = fsCourseWatchLogMapper.selectCompanyBaseInfo(param);
         if (CollectionUtils.isEmpty(companyList)) {
@@ -1751,6 +1759,32 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
                 .setScale(2, RoundingMode.HALF_UP);
     }
 
+    public static Date removeTime(Date date) {
+        if (date == null) {
+            return null;
+        }
+
+        try {
+            // 双重保障:先格式化成字符串,再解析回来
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            String dateStr = sdf.format(date);
+            Date result = sdf.parse(dateStr);
+
+            // 再用Calendar确保清除
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(result);
+            cal.set(Calendar.HOUR_OF_DAY, 0);
+            cal.set(Calendar.MINUTE, 0);
+            cal.set(Calendar.SECOND, 0);
+            cal.set(Calendar.MILLISECOND, 0);
+
+            return cal.getTime();
+        } catch (Exception e) {
+            // 备用方案
+            return new java.sql.Date(date.getTime());
+        }
+    }
+
     /**
      * 根据看课记录id获取所有的外部联系人ids
      *

+ 1 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCoursePeriodDaysServiceImpl.java

@@ -250,6 +250,7 @@ public class FsUserCoursePeriodDaysServiceImpl extends ServiceImpl<FsUserCourseP
         courseAnalysisParam.setPeriodId(param.getPeriodId());
         courseAnalysisParam.setVideoIdList(param.getVideoIdList());
         courseAnalysisParam.setCompanyId(param.getCompanyId());
+        courseAnalysisParam.setCompanyUserIds(param.getCompanyUserIds());
         List<FsCourseAnalysisCountVO> courseCountList = fsUserMapper.courseAnalysisWatchLog(courseAnalysisParam);
         List<FsCourseAnalysisCountVO> redPacketCountList = fsUserMapper.courseAnalysisRedPacketCount(courseAnalysisParam);
         List<FsCourseAnalysisCountVO> answerCountList = fsUserMapper.courseAnalysisAnswerCount(courseAnalysisParam);

+ 1 - 1
fs-service/src/main/java/com/fs/course/vo/FsCourseWatchLogStatisticsListVO.java

@@ -39,7 +39,7 @@ public class FsCourseWatchLogStatisticsListVO {
     @Excel(name = "员工名称")
     private String userName;
 
-    @Excel(name = "创建时间")
+    @Excel(name = "创建时间",dateFormat = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date createTime;
 

+ 2 - 1
fs-service/src/main/java/com/fs/his/mapper/FsPackageOrderMapper.java

@@ -115,13 +115,14 @@ public interface FsPackageOrderMapper
             "</script>"})
     List<FsPackageOrderListVO> selectFsPackageOrderListVO(@Param("maps")FsPackageOrderParam fsPackageOrder);
 
-    @Select("select o.*,d.doctor_name,u.nick_name,u.phone,c.company_name,cu.nick_name company_user_name,fp.second_name,o.patient_json->>'$.patientName' as patientName  " +
+    @Select("select o.*,d.doctor_name,u.nick_name,u.phone,c.company_name,cu.nick_name company_user_name,fp.second_name,o.patient_json->>'$.patientName' as patientName,fo.user_name,fo.user_phone,fo.user_address " +
             " from fs_package_order o " +
             " LEFT JOIN fs_doctor d ON d.doctor_id=o.doctor_id " +
             " LEFT JOIN fs_user u ON u.user_id=o.user_id " +
             " LEFT JOIN company c on c.company_id =o.company_id " +
             " LEFT JOIN company_user cu on cu.user_id=o.company_user_id " +
             " left join fs_package fp on fp.package_id = o.package_id  " +
+            " left join fs_store_order fo on fo.order_id = o.order_id " +
             " where o.order_id=#{orderId}")
     FsPackageOrderVO selectFsPackageOrderByOrderIdVO(Long orderId);
 

+ 1 - 1
fs-service/src/main/java/com/fs/his/mapper/FsStoreOrderMapper.java

@@ -375,7 +375,7 @@ public interface FsStoreOrderMapper
             "LEFT JOIN company c on c.company_id =so.company_id " +
             "LEFT JOIN company_user cu on cu.user_id=so.company_user_id " +
             "LEFT JOIN fs_doctor fd on so.follow_doctor_id =fd.doctor_id " +
-            "LEFT JOIN fs_patient pat ON pat.patient_id=p.patient_id  WHERE so.is_del=0  and order_id= #{orderId}")
+            "LEFT JOIN fs_patient pat ON pat.patient_id=p.patient_id  WHERE so.is_del=0  and so.order_id= #{orderId}")
     FsStoreOrderVO selectFsStoreOrderByOrderIdVO(@Param("orderId") Long orderId);
 
     @Update("update fs_store_order set status=-3 where order_id=#{orderId}")

+ 15 - 0
fs-service/src/main/java/com/fs/his/vo/FsPackageOrderVO.java

@@ -148,4 +148,19 @@ public class FsPackageOrderVO {
     //别名
     private String secondName;
     private Integer source;
+
+    /**
+     * 收货人
+     */
+    private String  userName;
+
+    /**
+     * 收货人手机
+     */
+    private String  userPhone;
+
+    /**
+     * 收货地址
+     */
+    private String  userAddress;
 }

+ 35 - 1
fs-service/src/main/java/com/fs/qw/vo/QwWatchLogAllStatisticsListVO.java

@@ -1,6 +1,7 @@
 package com.fs.qw.vo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
 import lombok.Data;
 
 import java.util.Date;
@@ -8,51 +9,84 @@ import java.util.Date;
 @Data
 public class QwWatchLogAllStatisticsListVO {
     private Long id;
+    @Excel(name = "员工名称")
     private String qwUserName;
+    @Excel(name = "进线时间",dateFormat = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date createTime;
 
     /**
      * 进线数
      */
+    @Excel(name = "进线数")
     private Long line;
     /**
      * 先导课上线
      */
+    @Excel(name = "先导上线")
     private Long firstOnline;
     /**
      * 先导课完课
      */
+    @Excel(name = "先导完课")
     private Long firstOver;
     /**
      * 注册数
      */
+    @Excel(name = "注册数")
     private Long regNum;
-
+    @Excel(name = "D1上线")
     private Long d1Online;
+    @Excel(name = "D1完课")
     private Long d1Over;
+    @Excel(name = "D2上线")
     private Long d2Online;
+    @Excel(name = "D2完课")
     private Long d2Over;
+    @Excel(name = "D3上线")
     private Long d3Online;
+    @Excel(name = "D3完课")
     private Long d3Over;
+    @Excel(name = "D4上线")
     private Long d4Online;
+    @Excel(name = "D4完课")
     private Long d4Over;
+    @Excel(name = "D5上线")
     private Long d5Online;
+    @Excel(name = "D5完课")
     private Long d5Over;
+
+    @Excel(name = "D6上线")
     private Long d6Online;
+
+    @Excel(name = "D6完课")
     private Long d6Over;
+    @Excel(name = "D7上线")
     private Long d7Online;
+    @Excel(name = "D7完课")
     private Long d7Over;
+    @Excel(name = "D8上线")
     private Long d8Online;
+
+    @Excel(name = "D8完课")
     private Long d8Over;
+    @Excel(name = "D9上线")
     private Long d9Online;
+    @Excel(name = "D9完课")
     private Long d9Over;
+    @Excel(name = "D10上线")
     private Long d10Online;
+    @Excel(name = "D10完课")
     private Long d10Over;
+    @Excel(name = "D11上线")
     private Long d11Online;
+    @Excel(name = "D11完课")
     private Long d11Over;
+    @Excel(name = "D12上线")
     private Long d12Online;
+    @Excel(name = "D12完课")
     private Long d12Over;
+    @Excel(name = "D13上线")
     private Long d13Online;
     private Long d13Over;
     private Long d14Online;

+ 45 - 44
fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -1173,7 +1173,7 @@ FROM
         WHERE log.send_type =1
         <include refid="commonConditions"/>
          <if test="orderSTime != null and orderETime != null">
-            AND po.create_time BETWEEN #{orderSTime} AND #{orderETime}
+            AND DATE(po.create_time) BETWEEN #{orderSTime} AND #{orderETime}
         </if>
         ORDER BY u.register_date DESC
     </select>
@@ -1207,10 +1207,10 @@ FROM
         </if>
         WHERE log.send_type =1
         <if test="sTime != null and eTime != null">
-            AND log.create_time BETWEEN #{sTime} AND #{eTime}
+            AND  DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
         </if>
         <if test="orderSTime != null and orderETime != null">
-            AND po.create_time BETWEEN #{orderSTime} AND #{orderETime}
+            AND DATE(po.create_time) BETWEEN #{orderSTime} AND #{orderETime}
         </if>
         <!-- 销售公司 -->
         <if test="companyId != null and companyId != ''">
@@ -1276,10 +1276,10 @@ FROM
         </if>
         WHERE log.send_type =1
         <if test="sTime != null and eTime != null">
-            AND log.create_time BETWEEN #{sTime} AND #{eTime}
+            AND  DATE(log.create_time)  BETWEEN #{sTime} AND #{eTime}
         </if>
         <if test="orderSTime != null and orderETime != null">
-            AND po.create_time BETWEEN #{orderSTime} AND #{orderETime}
+            AND DATE(po.create_time)  BETWEEN #{orderSTime} AND #{orderETime}
         </if>
         <!-- 销售公司 -->
         <if test="companyId != null and companyId != ''">
@@ -1392,7 +1392,7 @@ FROM
         </foreach>
         <!--下单时间-->
         <if test="watchParam.orderSTime != null and watchParam.orderETime != null">
-            AND create_time BETWEEN #{watchParam.orderSTime} AND #{watchParam.orderETime}
+            AND DATE(create_time)  BETWEEN #{watchParam.orderSTime} AND #{watchParam.orderETime}
         </if>
         GROUP BY user_id
     </select>
@@ -1424,39 +1424,40 @@ FROM
         c.company_id AS companyId,
         c.company_name AS companyName
         FROM company c
-       <where>
-           <if test="companyId != null and companyId != ''">
-               AND company_id = #{companyId}
-           </if>
-           <if test="trainingCampId != null">
-               AND EXISTS (
-               SELECT 1 FROM fs_course_watch_log w
-               INNER JOIN fs_user_course_period p ON w.period_id = p.period_id
-               WHERE w.company_id = c.company_id
-               AND p.training_camp_id = #{trainingCampId}
-               <if test="sTime != null and eTime != null">
-                   AND w.create_time BETWEEN #{sTime} AND #{eTime}
-               </if>
-               )
-           </if>
-           <if test="periodId != null">
-               AND EXISTS (
-               SELECT 1 FROM fs_course_watch_log w
-               WHERE w.company_id = c.company_id
-               AND w.period_id = #{periodId}
-               <if test="sTime != null and eTime != null">
-                   AND w.create_time BETWEEN #{sTime} AND #{eTime}
-               </if>
-               )
-           </if>
-           <if test="(trainingCampId == null and periodId == null) and (sTime != null and eTime != null)">
-               AND EXISTS (
-               SELECT 1 FROM fs_course_watch_log w
-               WHERE w.company_id = c.company_id
-               AND w.create_time BETWEEN #{sTime} AND #{eTime}
-               )
-           </if>
-       </where>
+        <choose>
+            <!-- 当传了 trainingCampId 时 -->
+            <when test="trainingCampId != null">
+                INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id
+                INNER JOIN fs_user_course_period p ON w.period_id = p.period_id AND p.training_camp_id = #{trainingCampId}
+            </when>
+            <!-- 当传了 periodId 时 -->
+            <when test="periodId != null">
+                INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id AND w.period_id = #{periodId}
+            </when>
+            <!-- 当只传了时间范围时 -->
+            <when test="(trainingCampId == null and periodId == null) and (sTime != null and eTime != null)">
+                INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id
+            </when>
+<!--            &lt;!&ndash; 默认情况:必须有关联记录 &ndash;&gt;-->
+<!--            <otherwise>-->
+<!--                INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id-->
+<!--            </otherwise>-->
+        </choose>
+        <where>
+            <if test="companyId != null and companyId != ''">
+                AND c.company_id = #{companyId}
+            </if>
+            <if test="(trainingCampId == null and periodId == null) and (sTime != null and eTime != null)">
+                AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
+            </if>
+            <if test="trainingCampId != null and (sTime != null and eTime != null)">
+                AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
+            </if>
+            <if test="periodId != null and (sTime != null and eTime != null)">
+                AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
+            </if>
+        </where>
+        GROUP BY c.company_id, c.company_name
     </select>
     <select id="selectWatchStatistics" resultType="com.fs.his.vo.FsCourseReportVO">
         SELECT
@@ -1466,11 +1467,11 @@ FROM
         COUNT(DISTINCT CASE WHEN log_type = 1 THEN user_id END) AS watchingCount,
         COUNT(DISTINCT CASE WHEN log_type = 2 THEN user_id END) AS finishedCount,
         COUNT(DISTINCT CASE WHEN log_type = 4 THEN user_id END) AS interruptedCount,
-        COUNT(DISTINCT CASE WHEN DATE(create_time) = CURDATE() THEN user_id END) AS accessCount
+        COUNT(DISTINCT user_id) AS accessCount
         FROM fs_course_watch_log
         <where>
             <if test="sTime != null and eTime != null">
-                AND create_time BETWEEN #{sTime} AND #{eTime}
+                AND Date(create_time)  BETWEEN #{sTime} AND #{eTime}
             </if>
             <if test="trainingCampId != null">
                 AND period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id = #{trainingCampId})
@@ -1496,7 +1497,7 @@ FROM
         INNER JOIN fs_course_watch_log w ON a.watch_log_id = w.log_id
         <where>
             <if test="sTime != null and eTime != null">
-                AND w.create_time BETWEEN #{sTime} AND #{eTime}
+                AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
             </if>
             <if test="trainingCampId != null">
                 AND w.period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id = #{trainingCampId})
@@ -1522,7 +1523,7 @@ FROM
         INNER JOIN fs_course_watch_log w ON rpl.watch_log_id = w.log_id
         <where>
             <if test="sTime != null and eTime != null">
-                AND w.create_time BETWEEN #{sTime} AND #{eTime}
+                AND DATE(w.create_time)  BETWEEN #{sTime} AND #{eTime}
             </if>
             <if test="companyIds != null and companyIds.size() > 0">
                 AND w.company_id IN
@@ -1623,7 +1624,7 @@ FROM
         </if>
         <!-- 时间范围 -->
         <if test="sTime != null and eTime != null">
-            AND log.create_time BETWEEN #{sTime} AND #{eTime}
+            AND DATE(log.create_time)  BETWEEN #{sTime} AND #{eTime}
         </if>
         <!-- 训练营 -->
         <if test="trainingCampId != null and trainingCampId != ''">

+ 16 - 0
fs-service/src/main/resources/mapper/course/FsUserCompanyUserMapper.xml

@@ -193,5 +193,21 @@
             </if>
         </where>
     </select>
+    <select id="selectCountByUserId" resultType="java.lang.Integer">
+        SELECT
+            CASE WHEN
+                     cr.role_name = '部门经理' THEN
+                     1 ELSE 0
+                END AS isDepartmentManager
+        FROM
+            company_user_role cur
+                INNER JOIN company_role cr ON cur.role_id = cr.role_id
+        WHERE
+            cur.user_id = #{userId}
+    </select>
+
+    <select id="selectUserIdByDeptId" resultType="java.lang.Long">
+        SELECT  user_id FROM  `company_user` WHERE `dept_id` = #{deptId}
+    </select>
 
 </mapper>

+ 17 - 8
fs-service/src/main/resources/mapper/his/FsUserMapper.xml

@@ -115,6 +115,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">
                 AND fwl.company_id = #{companyId}
             </if>
+            <if test="companyUserIds != null and companyUserIds.size > 0">
+                AND fwl.company_user_id in
+                <foreach collection="companyUserIds" open="(" close=")" separator="," item="companyUserId">
+                    #{companyUserId}
+                </foreach>
+            </if>
         </where>
         GROUP BY
         fwl.video_id
@@ -129,11 +135,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN fs_user ON fs_user.user_id = flog.user_id
         LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
         <where>
-            <if test="companyUserId != null and companyUserId != 0 ">
-                AND flog.company_user_id = #{companyUserId}
-            </if>
-            <if test="companyUserId != null and companyUserId == 0 ">
-                and flog.company_id = #{companyId}
+            <if test="companyUserIds != null and companyUserIds.size > 0">
+                AND flog.company_user_id in
+                <foreach collection="companyUserIds" open="(" close=")" separator="," item="companyUserId">
+                    #{companyUserId}
+                </foreach>
             </if>
             <if test="periodId != null and periodId != ''">
                 AND flog.period_id =  #{periodId}
@@ -174,10 +180,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
         LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
         <where>
-            <if test="companyUserId != null and companyUserId != 0 ">
-                AND fs_course_answer_logs.company_user_id = #{companyUserId}
+            <if test="companyUserIds != null and companyUserIds.size > 0">
+                AND fs_course_answer_logs.company_user_id in
+                <foreach collection="companyUserIds" open="(" close=")" separator="," item="companyUserId">
+                    #{companyUserId}
+                </foreach>
             </if>
-            <if test="companyUserId != null and companyUserId == 0 ">
+            <if test="companyId != null and companyId != 0 ">
                 and fs_course_answer_logs.company_id = #{companyId}
             </if>
             <if test="periodId != null and periodId != ''">