| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.fs.company.mapper.StatisticManageMapper">
- <resultMap id="CompanyDeptUserListMap" type="com.fs.company.domain.CompanyDeptUserInfo">
- <id column="company_id" property="companyId" />
- <result column="company_name" property="companyName"/>
- <result column="dept_id" property="deptId"/>
- <result column="dept_name" property="deptName"/>
- <result column="user_id" property="userId"/>
- <result column="user_name" property="userName"/>
- <result column="nick_name" property="nickName"/>
- </resultMap>
- <select id="getCompanyAndDeptAndDeptUserList" resultMap="CompanyDeptUserListMap">
- SELECT
- ci.company_id,
- ci.company_name,
- cd.dept_id,
- cd.dept_name,
- cu.user_id,
- cu.user_name,
- cu.nick_name
- FROM company AS ci
- LEFT JOIN company_dept AS cd ON ci.company_id = cd.company_id AND cd.STATUS = 0
- LEFT JOIN company_user AS cu ON cu.dept_id = cd.dept_id AND cu.del_flag = 0
- WHERE ci.is_del = 0 AND cd.del_flag = 0
- </select>
- <select id="getStatisticNum" resultType="com.fs.company.dto.CompanyDeptUserInfoDTO">
- with t1 as (
- SELECT
- qec.id,
- qec.company_user_id,
- qec.fs_user_id,
- qec.qw_user_id,
- qec.user_id
- FROM
- qw_external_contact AS qec
- WHERE
- date_format(qec.create_time,'%y%m%d') >= date_format(now(),'%y%m%d') and
- qec.create_time <= now()
- and qec.company_user_id IN (
- <foreach collection="userIds" item="i" separator=",">
- #{i}
- </foreach>
- )
- ),t2 as (
- select count(t1.id) as lineNum from t1
- ),t3 as (
- select count(t1.id) as activeNum from t1 where t1.fs_user_id is not null
- ),t4 as(
- select count(fcwl.qw_external_contact_id) as completeNum from t1 inner join fs_course_watch_log as fcwl on t1.id = fcwl.qw_external_contact_id where fcwl.log_type = 2
- ),t5 as (
- select count(fcal.log_id) as answerNum from t1 inner join fs_course_answer_logs as fcal where fcal.user_id = t1.user_id
- ), t6 as (
- select count(fcrpl.log_id) as redPacketNum from t1 inner join fs_course_red_packet_log as fcrpl where fcrpl.user_id = t1.user_id
- )
- select t2.lineNum, t3.activeNum, t4.completeNum, t5.answerNum, t6.redPacketNum from t2, t3, t4, t5, t6
- </select>
- </mapper>
|