Pārlūkot izejas kodu

Merge branch 'master' of http://1.14.104.71:10880/root/ylrz_his_scrm_java

caoliqin 1 nedēļu atpakaļ
vecāks
revīzija
221073d473

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

@@ -20,17 +20,22 @@ import com.fs.course.vo.FsCourseWatchLogListVO;
 import com.fs.course.vo.FsCourseWatchLogStatisticsListVO;
 import com.fs.framework.security.LoginUser;
 import com.fs.framework.service.TokenService;
+import com.fs.qw.param.QwTagSearchParam;
 import com.fs.qw.param.QwWatchLogStatisticsListParam;
+import com.fs.qw.service.IQwTagService;
 import com.fs.qw.service.IQwWatchLogService;
 import com.fs.qw.vo.QwWatchLogAllStatisticsListVO;
 import com.fs.qw.vo.QwWatchLogStatisticsListVO;
 import com.fs.sop.mapper.SopUserLogsMapper;
+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
@@ -60,6 +65,9 @@ public class FsCourseWatchLogController extends BaseController
     @Autowired
     private IFsUserCoursePeriodDaysService userCoursePeriodDaysService;
 
+    @Autowired
+    private IQwTagService iQwTagService;
+
     /**
      * 查询短链课程看课记录列表
      */
@@ -181,6 +189,22 @@ public class FsCourseWatchLogController extends BaseController
         startPage();
 
         List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVO(param);
+        list.forEach(vo -> {
+            if (!Objects.equals(vo.getTagIds(), "[]") && vo.getTagIds()!=null) {
+                QwTagSearchParam tagParam = new QwTagSearchParam();
+                Gson gson = new Gson();
+                List<String> tagIds = gson.fromJson(
+                        vo.getTagIds(),
+                        new TypeToken<List<String>>() {
+                        }.getType()
+                );
+
+                tagParam.setTagIds(tagIds);
+
+                vo.setTagIdsName(iQwTagService.selectQwTagListByTagIds(tagParam));
+            }
+
+        });
         return getDataTable(list);
     }
 

+ 4 - 4
fs-company/src/main/java/com/fs/company/controller/qw/QwExternalContactController.java

@@ -474,8 +474,8 @@ public class QwExternalContactController extends BaseController
         return qwExternalContactService.addUserTag(Param);
     }
 
-    @PreAuthorize("@ss.hasPermi('qw:externalContact:addTag')")
-    @Log(title = "添加标签", businessType = BusinessType.UPDATE)
+    @PreAuthorize("@ss.hasPermi('qw:externalContact:addTagByWatch')")
+    @Log(title = "看课记录-添加标签", businessType = BusinessType.UPDATE)
     @PostMapping("/addTagByWatch")
     public R addTagByWatch(@RequestBody QwExtContactAddTagByWatchParam Param) throws JSONException {
 
@@ -492,8 +492,8 @@ public class QwExternalContactController extends BaseController
         return qwExternalContactService.delUserTag(Param);
     }
 
-    @PreAuthorize("@ss.hasPermi('qw:externalContact:delTag')")
-    @Log(title = "在看课记录这移除标签", businessType = BusinessType.UPDATE)
+    @PreAuthorize("@ss.hasPermi('qw:externalContact:delTagByWatch')")
+    @Log(title = "看课记录-移除标签", businessType = BusinessType.UPDATE)
     @PostMapping("/delTagByWatch")
     public R delTagByWatch(@RequestBody QwExtContactAddTagByWatchParam Param)
     {

+ 1 - 0
fs-company/src/main/java/com/fs/company/controller/store/FsUserController.java

@@ -115,6 +115,7 @@ public class FsUserController extends BaseController
     {
         startPage();
         LoginUser loginUser = SecurityUtils.getLoginUser();
+        fsUser.setCompanyId(loginUser.getCompany().getCompanyId());
         fsUser.setCompanyUserId(loginUser.getUser().getUserId());
         if(fsUser.getPhoneMk()!=null&&fsUser.getPhone()!=""){
             fsUser.setPhone(encryptPhone(fsUser.getPhoneMk()));

+ 3 - 1
fs-service/src/main/java/com/fs/course/mapper/FsCourseWatchLogMapper.java

@@ -128,6 +128,8 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
 
     List<FsCourseWatchLogListVO> selectFsCourseWatchLogListVO(@Param("maps") FsCourseWatchLogListParam param);
 
+    List<QwExternalContact> selectFsCourseWatchLogListByWatchLogVO(@Param("maps") FsCourseWatchLogListParam param);
+
     List<FsCourseWatchLogListVO> selectFsCourseWatchLogListByParam(FsCourseWatchLogListParam param);
 
     @Select("select l.*,v.title,c.course_name from fs_course_watch_log l LEFT JOIN fs_user_course_video v ON v.video_id = l.video_id LEFT JOIN fs_user_course c ON c.course_id = l.course_id WHERE l.qw_external_contact_id =#{id} ORDER BY l.create_time  desc LIMIT 1  ")
@@ -656,7 +658,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
     @Select("<script>" +
             "select qec.id,qec.user_id,qec.external_user_id,qec.corp_id,qec.tag_ids,qec.name from fs_course_watch_log qwl " +
             "left join qw_external_contact qec on qwl.qw_external_contact_id=qec.id " +
-            "        where qwl.log_id in\n" +
+            "        where qec.status=0 and qwl.log_id in\n" +
             "        <foreach collection=\"logIds\" item=\"id\" open=\"(\" separator=\",\" close=\")\">\n" +
             "            #{id}\n" +
             "        </foreach>" +

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

@@ -43,6 +43,7 @@ import com.fs.qw.mapper.QwExternalContactMapper;
 import com.fs.qw.mapper.QwUserMapper;
 import com.fs.qw.mapper.QwWatchLogMapper;
 import com.fs.qw.param.QwSidebarStatsParam;
+import com.fs.qw.param.QwTagSearchParam;
 import com.fs.qw.param.SendSopParamDetails;
 import com.fs.qw.vo.QwSopCourseFinishTempSetting;
 import com.fs.qw.vo.QwSopTempSetting;
@@ -53,6 +54,8 @@ import com.fs.store.service.cache.IFsUserCacheService;
 import com.fs.store.service.cache.IFsUserCourseCacheService;
 import com.fs.system.service.ISysConfigService;
 import com.fs.tag.service.FsTagUpdateService;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
 import com.hc.openapi.tool.util.StringUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.slf4j.Logger;

+ 8 - 0
fs-service/src/main/java/com/fs/course/vo/FsCourseWatchLogListVO.java

@@ -6,6 +6,7 @@ import com.fs.common.core.domain.BaseEntity;
 import lombok.Data;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * 短链课程看课记录对象 fs_course_watch_log
@@ -144,4 +145,11 @@ public class FsCourseWatchLogListVO extends BaseEntity
 
     //看课方式:1 app  2 小程序
     private Integer watchType;
+
+    /**
+    * 标签
+    */
+    private String tagIds;
+
+    private List<String> tagIdsName;
 }

+ 2 - 0
fs-service/src/main/java/com/fs/his/mapper/FsUserMapper.java

@@ -173,6 +173,8 @@ public interface FsUserMapper
             "</script>"})
     List<FsUserVO> selectFsUserListVOByComponentsUser(FsUserParam fsUser);
 
+    List<FsUserVO> selectFsUserListVOByExternalContact(FsUserParam fsUser);
+
     @Select("SELECT user_id\n" +
             "FROM fs_user_integral_logs\n" +
             "WHERE business_type = 2\n" +

+ 4 - 4
fs-service/src/main/java/com/fs/his/service/impl/FsUserServiceImpl.java

@@ -26,10 +26,7 @@ import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.enums.ImTypeEnum;
 import com.fs.common.param.LoginMaWxParam;
-import com.fs.common.utils.DateUtils;
-import com.fs.common.utils.DictUtils;
-import com.fs.common.utils.ParseUtils;
-import com.fs.common.utils.StringUtils;
+import com.fs.common.utils.*;
 import com.fs.company.cache.ICompanyTagCacheService;
 import com.fs.company.cache.ICompanyUserCacheService;
 import com.fs.company.domain.*;
@@ -345,6 +342,9 @@ public class FsUserServiceImpl implements IFsUserService {
 
     @Override
     public List<FsUserVO> selectFsUserListVOByComponentsUser(FsUserParam fsUser) {
+        if (CloudHostUtils.hasCloudHostName("木易华康")) {
+            return fsUserMapper.selectFsUserListVOByExternalContact(fsUser);
+        }
         return fsUserMapper.selectFsUserListVOByComponentsUser(fsUser);
     }
 

+ 1 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwUserMapper.java

@@ -275,6 +275,7 @@ public interface QwUserMapper extends BaseMapper<QwUser>
 
     @Select("SELECT\n" +
             "\tqu.id AS dictValue,\n" +
+            "\tqu.qw_user_id,\n" +
             "\tqu.qw_user_name AS dictLabel,\n" +
             "\tqu.corp_id,\n" +
             "\tqc.corp_name\n" +

+ 5 - 0
fs-service/src/main/java/com/fs/qw/param/QwExtContactAddTagByWatchParam.java

@@ -1,5 +1,6 @@
 package com.fs.qw.param;
 
+import com.fs.course.param.FsCourseWatchLogListParam;
 import lombok.Data;
 
 import java.util.List;
@@ -15,4 +16,8 @@ public class QwExtContactAddTagByWatchParam {
     */
     List<Long> logIds;
     List<String> tagIds;
+
+    private boolean filter;
+
+    private FsCourseWatchLogListParam param;
 }

+ 17 - 4
fs-service/src/main/java/com/fs/qw/service/impl/QwExternalContactServiceImpl.java

@@ -1440,7 +1440,15 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
             // 1. 批量查询所有用户数据
             List<QwExternalContact> contacts;
             try {
-                contacts = fsCourseWatchLogMapper.selectQwWatchLogFomExtContact(param.getLogIds());
+                if(param.isFilter()){
+                    param.getParam().setPageNum(null);
+                    param.getParam().setPageSize(null);
+                    param.getParam().setExternalStatus(0);
+                    contacts = fsCourseWatchLogMapper.selectFsCourseWatchLogListByWatchLogVO(param.getParam());
+                }else {
+                    contacts = fsCourseWatchLogMapper.selectQwWatchLogFomExtContact(param.getLogIds());
+                }
+
                 if (contacts == null || contacts.isEmpty()) {
                     return R.error("成功:0,失败:" + param.getLogIds().size());
                 }
@@ -1719,10 +1727,15 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
             // 1. 批量查询所有用户数据
             List<QwExternalContact> contacts;
             try {
-                contacts = fsCourseWatchLogMapper.selectQwWatchLogFomExtContact(param.getLogIds());
-                if (contacts == null || contacts.isEmpty()) {
-                    return R.error("成功:0,失败:" + param.getLogIds().size());
+                if(param.isFilter()){
+                    param.getParam().setPageNum(null);
+                    param.getParam().setPageSize(null);
+                    param.getParam().setExternalStatus(0);
+                    contacts = fsCourseWatchLogMapper.selectFsCourseWatchLogListByWatchLogVO(param.getParam());
+                }else {
+                    contacts = fsCourseWatchLogMapper.selectQwWatchLogFomExtContact(param.getLogIds());
                 }
+
             } catch (Exception e) {
                 return R.error("批量查询用户数据失败:" + e.getMessage());
             }

+ 2 - 1
fs-service/src/main/java/com/fs/qw/vo/QwOptionsVO.java

@@ -6,6 +6,7 @@ import lombok.Data;
 public class QwOptionsVO {
     String dictValue;
     String dictLabel;
-    String CorpId;
+    String qwUserId;
+    String corpId;
     String corpName;
 }

+ 2 - 2
fs-service/src/main/java/com/fs/sop/domain/QwSopTemp.java

@@ -63,7 +63,7 @@ public class QwSopTemp implements Serializable
      * 是否开启app发课
      */
     @TableField(exist = false)
-    private String openAppCourse;
+    private String openAppCourse="0";
 
     private String corpId;
 
@@ -156,7 +156,7 @@ public class QwSopTemp implements Serializable
 
     @TableField(exist = false)
     private String createByDeptName;
-    
+
     @TableField(exist = false)
     private String openIsAtAll;
 }

+ 4 - 4
fs-service/src/main/resources/application-druid-fzbt.yml

@@ -35,10 +35,10 @@ spring:
                 # 从库数据源
                 slave:
                     # 从数据源开关/默认关闭
-                    enabled: false
-                    url:
-                    username:
-                    password:
+                    enabled: true
+                    url: jdbc:mysql://172.27.0.17:3306/his?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: zGn7Vrto9ZthdLnn
                 # 初始连接数
                 initialSize: 5
                 # 最小连接池数量

+ 288 - 156
fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -35,164 +35,296 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                camp_period_time,project,period_id,watch_type  from fs_course_watch_log
     </sql>
 
-    <select id="selectFsCourseWatchLogList" parameterType="FsCourseWatchLog" resultMap="FsCourseWatchLogResult">
-        <include refid="selectFsCourseWatchLogVo"/>
-        <where>
-            <if test="userId != null "> and user_id = #{userId}</if>
-            <if test="videoId != null "> and video_id = #{videoId}</if>
-            <if test="logType != null "> and log_type = #{logType}</if>
-            <if test="qwExternalContactId != null "> and qw_external_contact_id = #{qwExternalContactId}</if>
-            <if test="duration != null "> and duration = #{duration}</if>
-            <if test="qwUserId != null  and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
-            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
-            <if test="companyId != null "> and company_id = #{companyId}</if>
-            <if test="courseId != null "> and course_id = #{courseId}</if>
-            <if test="sendType != null "> and send_type = #{sendType}</if>
-            <if test="campPeriodTime != null "> and camp_period_time = #{campPeriodTime}</if>
-            <if test="project != null "> and project = #{project}</if>
-            <if test="watchType != null "> and watch_type = #{watchType}</if>
-        </where>
-    </select>
+            <select id="selectFsCourseWatchLogList" parameterType="FsCourseWatchLog" resultMap="FsCourseWatchLogResult">
+                <include refid="selectFsCourseWatchLogVo"/>
+                <where>
+                    <if test="userId != null "> and user_id = #{userId}</if>
+                    <if test="videoId != null "> and video_id = #{videoId}</if>
+                    <if test="logType != null "> and log_type = #{logType}</if>
+                    <if test="qwExternalContactId != null "> and qw_external_contact_id = #{qwExternalContactId}</if>
+                    <if test="duration != null "> and duration = #{duration}</if>
+                    <if test="qwUserId != null  and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
+                    <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
+                    <if test="companyId != null "> and company_id = #{companyId}</if>
+                    <if test="courseId != null "> and course_id = #{courseId}</if>
+                    <if test="sendType != null "> and send_type = #{sendType}</if>
+                    <if test="campPeriodTime != null "> and camp_period_time = #{campPeriodTime}</if>
+                    <if test="project != null "> and project = #{project}</if>
+                    <if test="watchType != null "> and watch_type = #{watchType}</if>
+                </where>
+            </select>
 
-    <select id="selectFsCourseWatchLogByLogId" parameterType="Long" resultMap="FsCourseWatchLogResult">
-        <include refid="selectFsCourseWatchLogVo"/>
-        where log_id = #{logId}
-    </select>
+            <select id="selectFsCourseWatchLogByLogId" parameterType="Long" resultMap="FsCourseWatchLogResult">
+                <include refid="selectFsCourseWatchLogVo"/>
+                where log_id = #{logId}
+            </select>
 
-    <select id="selectFsCourseWatchLogListVO" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
-        select l.log_id,l.project,l.period_id,l.user_id,uc.course_name,v.title as video_name,qec.avatar as external_user_avatar,qec.status as externalStatus,
-        l.log_type,SEC_TO_TIME(l.duration) as duration,c.company_name,l.camp_period_time,l.finish_time,
-        cu.nick_name as company_user_name ,l.send_type,l.create_time,l.update_time,l.last_heartbeat_time,
-        qu.qw_user_name,qec.name as external_user_name,c.company_id,u.avatar as fsAvatar,u.nick_name as fsNickName,qec.create_time as qec_create_time,
-        u.is_vip isVip,l.reward_type,cu.dept_id, l.watch_type
-         from fs_course_watch_log l
-         left join fs_user_course_video v on v.video_id = l.video_id
-         left join fs_user_course uc on uc.course_id = l.course_id
-         left join fs_user u on u.user_id = l.user_id
-         left join company_user cu on cu.user_id = l.company_user_id
-         left join company c on c.company_id = l.company_id
-         LEFT JOIN qw_user qu on qu.id= l.qw_user_id
-         LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
-        <where>
-            <if test ='maps.isVip != null and maps.isVip == 0'>
-                and (l.user_id = 0 or l.user_id is null)
-            </if>
-            <if test ='maps.isVip != null and maps.isVip == 1'>
-                and l.user_id != 0 and l.user_id is not null
-            </if>
-            <if test ='maps.sendType !=null'>
-                and l.send_type = #{maps.sendType}
-            </if>
-            <if test ='maps.userId !=null'>
-                and l.user_id = #{maps.userId}
-            </if>
-            <if test ='maps.logId !=null'>
-                and l.log_id = #{maps.logId}
-            </if>
-            <if test ='maps.project !=null'>
-                and l.project = #{maps.project}
-            </if>
-            <if test ='maps.qwExternalContactId !=null'>
-                and l.qw_external_contact_id = #{maps.qwExternalContactId}
-            </if>
-            <if test ='maps.qwUserId !=null'>
-                and l.qw_user_id = #{maps.qwUserId}
-            </if>
-            <if test ='maps.courseId !=null'>
-                and l.course_id = #{maps.courseId}
-            </if>
-            <if test ='maps.videoId !=null'>
-                and l.video_id = #{maps.videoId}
-            </if>
-            <if test ='maps.logType !=null'>
-                and l.log_type = #{maps.logType}
-            </if>
-            <if test ='maps.companyId !=null'>
-                and l.company_id = #{maps.companyId}
-            </if>
-            <if test ='maps.watchType !=null'>
-                and l.watch_type = #{maps.watchType}
-            </if>
-            <if test ='maps.companyUserId !=null'>
-                and l.company_user_id = #{maps.companyUserId}
-            </if>
-            <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
-                and cu.nick_name  like concat('%', #{maps.companyUserName}, '%')
-            </if>
-            <if test ='maps.nickName !=null and maps.nickName!=""'>
-                and u.nick_name  like concat('%', #{maps.nickName}, '%')
-            </if>
-            <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
-                and qec.name  like concat('%', #{maps.externalUserName}, '%')
-            </if>
-            <if test= 'maps.qecSTime != null '>
-                and DATE(qec.create_time) &gt;= DATE(#{maps.qecSTime})
-            </if>
-            <if test='maps.qecETime != null '>
-                and DATE(qec.create_time) &lt;= DATE(#{maps.qecETime})
-            </if>
-            <if test= 'maps.sTime != null '>
-                and l.create_time &gt;= #{maps.sTime}
-            </if>
-            <if test='maps.eTime != null '>
-                and l.create_time &lt;= #{maps.eTime}
-            </if>
-            <if test= 'maps.scheduleStartTime != null '>
-                and l.camp_period_time &gt;= #{maps.scheduleStartTime}
-            </if>
-            <if test='maps.scheduleEndTime != null '>
-                and l.camp_period_time &lt;= #{maps.scheduleEndTime}
-            </if>
-            <if test= 'maps.upSTime != null '>
-                and l.update_time &gt;= #{maps.upSTime}
-            </if>
-            <if test='maps.upETime != null '>
-                and l.update_time &lt; date_add(#{maps.upETime}, interval 1 day)
-            </if>
-            <if test="maps.sopIds != null and maps.sopIds.size() > 0">
-                and l.sop_id in
-                <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
-                    #{sopId}
-                </foreach>
-            </if>
-            <if test ='maps.project !=null'>
-                and l.project = #{maps.project}
-            </if>
-            <if test="maps.sopId != null  and maps.sopId != '' ">
-                and l.sop_id = #{maps.sopId}
-            </if>
-            <if test="maps.externalStatus != null  and maps.externalStatus != '' ">
-                and qec.status = #{maps.externalStatus}
-            </if>
-            <if test="maps.periodId != null">
-                and l.period_id = #{maps.periodId}
-            </if>
-            <if test="maps.periodIds != null and maps.periodIds.size() > 0">
-                and l.period_id in
-                <foreach item="periodId" index="index" collection="maps.periodIds" open="(" separator="," close=")">
-                    #{periodId}
-                </foreach>
-            </if>
-            <if test="maps.qwUserName != null  and maps.qwUserName != '' ">
-                and qu.qw_user_name = #{maps.qwUserName}
-            </if>
-            <if test="maps.deptId != null  and maps.deptId != '' ">
-                and cu.dept_id = #{maps.deptId}
-            </if>
-            <if test='maps.cuDeptIdList != null and !maps.cuDeptIdList.isEmpty() and  maps.userType != "00" '>
-                AND cu.dept_id IN
-                <foreach collection='maps.cuDeptIdList' item='item' open='(' separator=',' close=')'>
-                    #{item}
-                </foreach>
-            </if>
-            <if test="maps.userIds != null and !maps.userIds.isEmpty()">
-                AND cu.user_id IN
-                    <foreach collection='maps.userIds' item='item' open='(' separator=',' close=')'>
-                        #{item}
-                    </foreach>
-            </if>
-                </where>
-                 order by l.finish_time desc,l.update_time desc,l.create_time desc
+            <select id="selectFsCourseWatchLogListVO" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
+                select l.log_id,l.project,l.period_id,l.user_id,uc.course_name,v.title as video_name,qec.avatar as external_user_avatar,qec.status as externalStatus,
+                l.log_type,SEC_TO_TIME(l.duration) as duration,c.company_name,l.camp_period_time,l.finish_time,
+                cu.nick_name as company_user_name ,l.send_type,l.create_time,l.update_time,l.last_heartbeat_time,
+                qu.qw_user_name,qec.name as external_user_name,c.company_id,u.avatar as fsAvatar,u.nick_name as fsNickName,qec.create_time as qec_create_time,
+                u.is_vip isVip,l.reward_type,cu.dept_id, l.watch_type,qec.tag_ids
+                 from fs_course_watch_log l
+                 left join fs_user_course_video v on v.video_id = l.video_id
+                 left join fs_user_course uc on uc.course_id = l.course_id
+                 left join fs_user u on u.user_id = l.user_id
+                 left join company_user cu on cu.user_id = l.company_user_id
+                 left join company c on c.company_id = l.company_id
+                 LEFT JOIN qw_user qu on qu.id= l.qw_user_id
+                 LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
+                <where>
+                    <if test ='maps.isVip != null and maps.isVip == 0'>
+                        and (l.user_id = 0 or l.user_id is null)
+                    </if>
+                    <if test ='maps.isVip != null and maps.isVip == 1'>
+                        and l.user_id != 0 and l.user_id is not null
+                    </if>
+                    <if test ='maps.sendType !=null'>
+                        and l.send_type = #{maps.sendType}
+                    </if>
+                    <if test ='maps.userId !=null'>
+                        and l.user_id = #{maps.userId}
+                    </if>
+                    <if test ='maps.logId !=null'>
+                        and l.log_id = #{maps.logId}
+                    </if>
+                    <if test ='maps.project !=null'>
+                        and l.project = #{maps.project}
+                    </if>
+                    <if test ='maps.qwExternalContactId !=null'>
+                        and l.qw_external_contact_id = #{maps.qwExternalContactId}
+                    </if>
+                    <if test ='maps.qwUserId !=null'>
+                        and l.qw_user_id = #{maps.qwUserId}
+                    </if>
+                    <if test ='maps.courseId !=null'>
+                        and l.course_id = #{maps.courseId}
+                    </if>
+                    <if test ='maps.videoId !=null'>
+                        and l.video_id = #{maps.videoId}
+                    </if>
+                    <if test ='maps.logType !=null'>
+                        and l.log_type = #{maps.logType}
+                    </if>
+                    <if test ='maps.companyId !=null'>
+                        and l.company_id = #{maps.companyId}
+                    </if>
+                    <if test ='maps.watchType !=null'>
+                        and l.watch_type = #{maps.watchType}
+                    </if>
+                    <if test ='maps.companyUserId !=null'>
+                        and l.company_user_id = #{maps.companyUserId}
+                    </if>
+                    <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
+                        and cu.nick_name  like concat('%', #{maps.companyUserName}, '%')
+                    </if>
+                    <if test ='maps.nickName !=null and maps.nickName!=""'>
+                        and u.nick_name  like concat('%', #{maps.nickName}, '%')
+                    </if>
+                    <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
+                        and qec.name  like concat('%', #{maps.externalUserName}, '%')
+                    </if>
+                    <if test= 'maps.qecSTime != null '>
+                        and DATE(qec.create_time) &gt;= DATE(#{maps.qecSTime})
+                    </if>
+                    <if test='maps.qecETime != null '>
+                        and DATE(qec.create_time) &lt;= DATE(#{maps.qecETime})
+                    </if>
+                    <if test= 'maps.sTime != null '>
+                        and l.create_time &gt;= #{maps.sTime}
+                    </if>
+                    <if test='maps.eTime != null '>
+                        and l.create_time &lt;= #{maps.eTime}
+                    </if>
+                    <if test= 'maps.scheduleStartTime != null '>
+                        and l.camp_period_time &gt;= #{maps.scheduleStartTime}
+                    </if>
+                    <if test='maps.scheduleEndTime != null '>
+                        and l.camp_period_time &lt;= #{maps.scheduleEndTime}
+                    </if>
+                    <if test= 'maps.upSTime != null '>
+                        and l.update_time &gt;= #{maps.upSTime}
+                    </if>
+                    <if test='maps.upETime != null '>
+                        and l.update_time &lt; date_add(#{maps.upETime}, interval 1 day)
+                    </if>
+                    <if test="maps.sopIds != null and maps.sopIds.size() > 0">
+                        and l.sop_id in
+                        <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
+                            #{sopId}
+                        </foreach>
+                    </if>
+                    <if test ='maps.project !=null'>
+                        and l.project = #{maps.project}
+                    </if>
+                    <if test="maps.sopId != null  and maps.sopId != '' ">
+                        and l.sop_id = #{maps.sopId}
+                    </if>
+                    <if test="maps.externalStatus != null  and maps.externalStatus != '' ">
+                        and qec.status = #{maps.externalStatus}
+                    </if>
+                    <if test="maps.periodId != null">
+                        and l.period_id = #{maps.periodId}
+                    </if>
+                    <if test="maps.periodIds != null and maps.periodIds.size() > 0">
+                        and l.period_id in
+                        <foreach item="periodId" index="index" collection="maps.periodIds" open="(" separator="," close=")">
+                            #{periodId}
+                        </foreach>
+                    </if>
+                    <if test="maps.qwUserName != null  and maps.qwUserName != '' ">
+                        and qu.qw_user_name = #{maps.qwUserName}
+                    </if>
+                    <if test="maps.deptId != null  and maps.deptId != '' ">
+                        and cu.dept_id = #{maps.deptId}
+                    </if>
+                    <if test='maps.cuDeptIdList != null and !maps.cuDeptIdList.isEmpty() and  maps.userType != "00" '>
+                        AND cu.dept_id IN
+                        <foreach collection='maps.cuDeptIdList' item='item' open='(' separator=',' close=')'>
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="maps.userIds != null and !maps.userIds.isEmpty()">
+                        AND cu.user_id IN
+                            <foreach collection='maps.userIds' item='item' open='(' separator=',' close=')'>
+                                #{item}
+                            </foreach>
+                    </if>
+                        </where>
+                         order by l.finish_time desc,l.update_time desc,l.create_time desc
+            </select>
+
+            <select id="selectFsCourseWatchLogListByWatchLogVO" resultType="com.fs.qw.domain.QwExternalContact">
+                        select qec.id,qec.user_id,qec.external_user_id,qec.corp_id,qec.tag_ids,qec.name
+                                from fs_course_watch_log l
+                        left join fs_user u on u.user_id = l.user_id
+                        left join company_user cu on cu.user_id = l.company_user_id
+                        LEFT JOIN qw_user qu on qu.id= l.qw_user_id
+                        LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
+                        <where>
+                            <if test ='maps.isVip != null and maps.isVip == 0'>
+                                and (l.user_id = 0 or l.user_id is null)
+                            </if>
+                            <if test ='maps.isVip != null and maps.isVip == 1'>
+                                and l.user_id != 0 and l.user_id is not null
+                            </if>
+                            <if test ='maps.sendType !=null'>
+                                and l.send_type = #{maps.sendType}
+                            </if>
+                            <if test ='maps.userId !=null'>
+                                and l.user_id = #{maps.userId}
+                            </if>
+                            <if test ='maps.logId !=null'>
+                                and l.log_id = #{maps.logId}
+                            </if>
+                            <if test ='maps.project !=null'>
+                                and l.project = #{maps.project}
+                            </if>
+                            <if test ='maps.qwExternalContactId !=null'>
+                                and l.qw_external_contact_id = #{maps.qwExternalContactId}
+                            </if>
+                            <if test ='maps.qwUserId !=null'>
+                                and l.qw_user_id = #{maps.qwUserId}
+                            </if>
+                            <if test ='maps.courseId !=null'>
+                                and l.course_id = #{maps.courseId}
+                            </if>
+                            <if test ='maps.videoId !=null'>
+                                and l.video_id = #{maps.videoId}
+                            </if>
+                            <if test ='maps.logType !=null'>
+                                and l.log_type = #{maps.logType}
+                            </if>
+                            <if test ='maps.companyId !=null'>
+                                and l.company_id = #{maps.companyId}
+                            </if>
+                            <if test ='maps.watchType !=null'>
+                                and l.watch_type = #{maps.watchType}
+                            </if>
+                            <if test ='maps.companyUserId !=null'>
+                                and l.company_user_id = #{maps.companyUserId}
+                            </if>
+                            <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
+                                and cu.nick_name  like concat('%', #{maps.companyUserName}, '%')
+                            </if>
+                            <if test ='maps.nickName !=null and maps.nickName!=""'>
+                                and u.nick_name  like concat('%', #{maps.nickName}, '%')
+                            </if>
+                            <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
+                                and qec.name  like concat('%', #{maps.externalUserName}, '%')
+                            </if>
+                            <if test= 'maps.qecSTime != null '>
+                                and DATE(qec.create_time) &gt;= DATE(#{maps.qecSTime})
+                            </if>
+                            <if test='maps.qecETime != null '>
+                                and DATE(qec.create_time) &lt;= DATE(#{maps.qecETime})
+                            </if>
+                            <if test= 'maps.sTime != null '>
+                                and l.create_time &gt;= #{maps.sTime}
+                            </if>
+                            <if test='maps.eTime != null '>
+                                and l.create_time &lt;= #{maps.eTime}
+                            </if>
+                            <if test= 'maps.scheduleStartTime != null '>
+                                and l.camp_period_time &gt;= #{maps.scheduleStartTime}
+                            </if>
+                            <if test='maps.scheduleEndTime != null '>
+                                and l.camp_period_time &lt;= #{maps.scheduleEndTime}
+                            </if>
+                            <if test= 'maps.upSTime != null '>
+                                and l.update_time &gt;= #{maps.upSTime}
+                            </if>
+                            <if test='maps.upETime != null '>
+                                and l.update_time &lt; date_add(#{maps.upETime}, interval 1 day)
+                            </if>
+                            <if test="maps.sopIds != null and maps.sopIds.size() > 0">
+                                and l.sop_id in
+                                <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
+                                    #{sopId}
+                                </foreach>
+                            </if>
+                            <if test ='maps.project !=null'>
+                                and l.project = #{maps.project}
+                            </if>
+                            <if test="maps.sopId != null  and maps.sopId != '' ">
+                                and l.sop_id = #{maps.sopId}
+                            </if>
+                            <if test="maps.externalStatus != null  and maps.externalStatus != '' ">
+                                and qec.status = #{maps.externalStatus}
+                            </if>
+                            <if test="maps.periodId != null">
+                                and l.period_id = #{maps.periodId}
+                            </if>
+                            <if test="maps.periodIds != null and maps.periodIds.size() > 0">
+                                and l.period_id in
+                                <foreach item="periodId" index="index" collection="maps.periodIds" open="(" separator="," close=")">
+                                    #{periodId}
+                                </foreach>
+                            </if>
+                            <if test="maps.qwUserName != null  and maps.qwUserName != '' ">
+                                and qu.qw_user_name = #{maps.qwUserName}
+                            </if>
+                            <if test="maps.deptId != null  and maps.deptId != '' ">
+                                and cu.dept_id = #{maps.deptId}
+                            </if>
+                            <if test='maps.cuDeptIdList != null and !maps.cuDeptIdList.isEmpty() and  maps.userType != "00" '>
+                                AND cu.dept_id IN
+                                <foreach collection='maps.cuDeptIdList' item='item' open='(' separator=',' close=')'>
+                                    #{item}
+                                </foreach>
+                            </if>
+                            <if test="maps.userIds != null and !maps.userIds.isEmpty()">
+                                AND cu.user_id IN
+                                <foreach collection='maps.userIds' item='item' open='(' separator=',' close=')'>
+                                    #{item}
+                                </foreach>
+                            </if>
+                        </where>
+                        GROUP BY
+                        qec.user_id,
+                        qec.external_user_id,
+                        qec.corp_id
             </select>
 
             <select id="selectFsCourseWatchLogListByParam" resultType="com.fs.course.vo.FsCourseWatchLogListVO">

+ 67 - 1
fs-service/src/main/resources/mapper/his/FsUserMapper.xml

@@ -52,10 +52,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="level" column="level"/>
         <result property="appOpenId"    column="app_open_id"    />
         <result property="appleKey"    column="apple_key"    />
+        <result property="historyApp"    column="history_app"    />
     </resultMap>
 
     <sql id="selectFsUserVo">
-        select user_id,qw_ext_id,sex,is_buy,`level`,course_ma_open_id,is_push,is_add_qw,source,login_device,is_individuation_push,store_open_id,password,jpush_id, is_vip,vip_start_date,vip_end_date,vip_level,vip_status,nick_name,integral_status, avatar, phone, integral,sign_num, status, tui_user_id, tui_time, tui_user_count, ma_open_id, mp_open_id, union_id, is_del, user_code, remark, create_time, update_time, last_ip, balance,is_weixin_auth,parent_id,qw_user_id,app_id,company_id,company_user_id,is_promoter,now_money,brokerage_price,spread_user_id, spread_time,pay_count, spread_count,user_type,app_open_id,apple_key from fs_user
+        select user_id,qw_ext_id,sex,is_buy,`level`,course_ma_open_id,is_push,is_add_qw,source,login_device,
+               is_individuation_push,store_open_id,password,jpush_id, is_vip,vip_start_date,vip_end_date,vip_level,
+               vip_status,nick_name,integral_status, avatar, phone, integral,sign_num, status, tui_user_id, tui_time,
+               tui_user_count, ma_open_id, mp_open_id, union_id, is_del, user_code, remark, create_time, update_time,
+               last_ip, balance,is_weixin_auth,parent_id,qw_user_id,app_id,company_id,company_user_id,is_promoter,
+               now_money,brokerage_price,spread_user_id, spread_time,pay_count, spread_count,user_type,
+               app_open_id,apple_key,history_app
+        from fs_user
     </sql>
 
     <select id="selectFsUserList" parameterType="FsUser" resultMap="FsUserResult">
@@ -701,6 +709,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="appId != null">app_id = #{appId},</if>
             <if test="appOpenId != null">app_open_id = #{appOpenId},</if>
             <if test="appleKey != null">apple_key = #{appleKey},</if>
+            <if test="historyApp != null">history_app = #{historyApp},</if>
         </trim>
         where user_id = #{userId}
     </update>
@@ -2482,4 +2491,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by user_id desc
     </select>
 
+    <!-- 查询企业微信外部联系人用户列表 -->
+    <select id="selectFsUserListVOByExternalContact" resultType="com.fs.his.vo.FsUserVO">
+        SELECT DISTINCT
+            f1.*,
+            f2.nick_name AS tui_name,
+            f2.phone AS tui_phone
+        FROM qw_external_contact cuu
+        LEFT JOIN fs_user f1 ON cuu.fs_user_id = f1.user_id
+        LEFT JOIN fs_user f2 ON f1.tui_user_id = f2.user_id
+        WHERE f1.is_del = 0
+            <if test="companyUserId != null">
+                AND cuu.company_user_id = #{companyUserId}
+            </if>
+            <if test="companyId != null">
+                AND cuu.company_id = #{companyId}
+            </if>
+            <if test="nickName != null and nickName != ''">
+                AND f1.nick_name LIKE CONCAT(#{nickName}, '%')
+            </if>
+            <if test="avatar != null and avatar != ''">
+                AND f1.avatar = #{avatar}
+            </if>
+            <if test="phone != null and phone != ''">
+                AND f1.phone LIKE CONCAT('%', #{phone}, '%')
+            </if>
+            <if test="status != null">
+                AND f1.status = #{status}
+            </if>
+            <if test="isBuy != null">
+                AND f1.is_buy = #{isBuy}
+            </if>
+            <if test="userId != null">
+                AND f1.user_id = #{userId}
+            </if>
+            <if test="tuiUserId != null and tuiUserId != ''">
+                AND f1.tui_user_id = #{tuiUserId}
+            </if>
+            <if test="tuiTime != null">
+                AND f1.tui_time = #{tuiTime}
+            </if>
+            <if test="userCode != null and userCode != ''">
+                AND f1.user_code = #{userCode}
+            </if>
+            <if test="lastIp != null and lastIp != ''">
+                AND f1.last_ip = #{lastIp}
+            </if>
+            <if test="sTime != null">
+                AND f1.create_time >= #{sTime}
+            </if>
+            <if test="eTime != null">
+            <![CDATA[
+                AND f1.create_time < DATE_ADD(#{eTime}, INTERVAL 1 DAY)
+            ]]>
+            </if>
+        ORDER BY f1.user_id DESC
+    </select>
+
 </mapper>