|
|
@@ -1149,8 +1149,186 @@
|
|
|
and su.id =#{taskStatisticsVo.userId}
|
|
|
</if>
|
|
|
</where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="queryPageElectric" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
|
|
|
+ select a.*, su.name as "userName",
|
|
|
+ inf.url as "logo",
|
|
|
+ sui.sex as "sex",
|
|
|
+ su.leader_name as "leaderName",
|
|
|
+ su2.mobile as "leaderMobile"
|
|
|
+ from (
|
|
|
+ SELECT
|
|
|
+ sd.NAME AS "deptName",
|
|
|
+ io.userid AS "userId",
|
|
|
+ sd.parent_id as "deptId",
|
|
|
+ COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
|
|
|
+ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
|
|
|
+ COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
|
|
|
+ COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
|
|
|
+ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
|
|
|
+ COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "closeRate",
|
|
|
+ (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus ) AS "contributionRate",
|
|
|
+ COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
|
|
|
+ COUNT(CASE WHEN io.order_source = 0 and iac.orderstatus = 0 THEN 1 END) as "pcOrderSource",
|
|
|
+ COUNT(CASE WHEN io.order_source = 1 and iac.orderstatus = 0 THEN 1 END) as "appOrderSource",
|
|
|
+ COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
|
|
|
+ FROM
|
|
|
+ ins_area_company iac
|
|
|
+ LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
+ LEFT JOIN sys_dept sd ON sd.id = io.deptid
|
|
|
+ <where>
|
|
|
+ sd.management_source = '3'
|
|
|
+ <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.provinceId}%"
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.cityId}%"
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.countyId}%"
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.houseId}%"
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
|
|
|
+ and io.userid =#{taskStatisticsVo.userId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
|
|
|
+ AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
|
|
|
+ AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
|
|
|
+ and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
|
|
|
+ AND sd.id in
|
|
|
+ <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
|
|
|
+ AND io.userid in
|
|
|
+ <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
|
|
|
+ <choose>
|
|
|
+ <when test="taskStatisticsVo.days =='1'">
|
|
|
+ and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
|
|
|
+ </when>
|
|
|
+
|
|
|
+ <when test="taskStatisticsVo.days =='7'">
|
|
|
+ and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
+ </when>
|
|
|
+
|
|
|
+ <when test="taskStatisticsVo.days =='30'">
|
|
|
+ and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ io.userid,
|
|
|
+ sd.NAME,
|
|
|
+ sd.id
|
|
|
+ ) a
|
|
|
+ left join sys_user su on su.id =a.userId
|
|
|
+ LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
|
|
|
+ LEFT JOIN sys_user_info sui on sui .id =su.id
|
|
|
+ LEFT JOIN sys_user su2 on su2.id =su.leader_id
|
|
|
+ <where>
|
|
|
+ <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
|
|
|
+ and su.name like concat('%',#{taskStatisticsVo.userName},'%')
|
|
|
+ </if>
|
|
|
+ <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
|
|
|
+ and su.leader_id =#{taskStatisticsVo.leaderId}
|
|
|
+ </if>
|
|
|
+ <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
|
|
|
+ and su.id =#{taskStatisticsVo.userId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="queryPageElectricTotal" resultType="java.lang.Long">
|
|
|
+ select count(0) from (
|
|
|
+ SELECT
|
|
|
+ io.userid
|
|
|
+ FROM
|
|
|
+ ins_area_company iac
|
|
|
+ LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
+ LEFT JOIN sys_dept sd ON sd.id = io.deptid
|
|
|
+ <where>
|
|
|
+ sd.management_source = '3'
|
|
|
+ <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.provinceId}%"
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.cityId}%"
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.countyId}%"
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
|
|
|
+ and io.deptid like "${taskStatisticsVo.houseId}%"
|
|
|
+ </if>
|
|
|
|
|
|
+ <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
|
|
|
+ AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
|
|
|
+ AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
|
|
|
+ and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
|
|
|
+ and io.userid =#{taskStatisticsVo.userId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
|
|
|
+ AND sd.id in
|
|
|
+ <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
|
|
|
+ AND io.userid in
|
|
|
+ <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
|
|
|
+ <choose>
|
|
|
+ <when test="taskStatisticsVo.days =='1'">
|
|
|
+ and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
|
|
|
+ </when>
|
|
|
+
|
|
|
+ <when test="taskStatisticsVo.days =='7'">
|
|
|
+ and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
+ </when>
|
|
|
+
|
|
|
+ <when test="taskStatisticsVo.days =='30'">
|
|
|
+ and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ io.userid
|
|
|
+ ) a
|
|
|
</select>
|
|
|
+
|
|
|
+
|
|
|
<select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
|
|
|
select count(0) from (
|
|
|
SELECT
|