<?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.stylefeng.guns.modular.system.dao.DriverActivityMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.DriverActivity">
|
<id column="id" property="id" />
|
<result column="name" property="name" />
|
<result column="companyId" property="companyId" />
|
<result column="insertTime" property="insertTime" />
|
<result column="status" property="status" />
|
<result column="remark" property="remark" />
|
<result column="startTime" property="startTime" />
|
<result column="endTime" property="endTime" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, name, companyId, insertTime, status, remark, startTime, endTime
|
</sql>
|
<select id="getList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
|
SELECT
|
a.*, IFNULL(o1.number, 0) + IFNULL(o2.number, 0) + IFNULL(o3.number, 0) number
|
FROM
|
t_driver_activity a
|
LEFT JOIN (
|
SELECT
|
COUNT(h.id) number,
|
o.driverActivityId
|
FROM
|
t_driver_activity_history h
|
LEFT JOIN t_driver_activity_online o ON h.activityId = o.id
|
WHERE
|
h.type = 3
|
AND h.carryOut=2
|
GROUP BY
|
o.driverActivityId
|
) o1 ON o1.driverActivityId = a.id
|
LEFT JOIN (
|
SELECT
|
COUNT(h.id) number,
|
o.driverActivityId
|
FROM
|
t_driver_activity_history h
|
LEFT JOIN t_driver_activity_order o ON h.activityId = o.id
|
WHERE
|
h.type = 4
|
AND h.carryOut=2
|
GROUP BY
|
o.driverActivityId
|
) o2 ON o2.driverActivityId = a.id
|
LEFT JOIN (
|
SELECT
|
COUNT(h.id) number,
|
o.driverActivityId
|
FROM
|
t_driver_activity_history h
|
LEFT JOIN t_driver_activity_registered o ON h.activityId = o.id
|
WHERE
|
h.type != 3
|
AND h.type != 4
|
AND h.carryOut=2
|
GROUP BY
|
o.driverActivityId
|
) o3 ON o3.driverActivityId = a.id
|
WHERE 1=1
|
<if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
|
and (a.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
|
</if>
|
<if test="name != null and name !=''">
|
and a.name like CONCAT('%',#{name},'%')
|
</if>
|
<if test="companyType != null and companyType !='' and companyType!=1">
|
and a.companyType=#{companyType}
|
</if>
|
<if test="companyId != null and companyId !='' and companyType!=1">
|
and a.companyId=#{companyId}
|
</if>
|
order by a.id desc
|
</select>
|
</mapper>
|