ReportMapper.xml 21.6 KB
Newer Older
苗卫卫 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
<?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.boco.nbd.wios.manage.mapper.def.ReportMapper">

    <resultMap id="BaseResultMap" type="com.boco.nbd.wios.manage.entity.bo.ReportOrderDTO">
        <result column="supplier_id" jdbcType="INTEGER" property="supplierId" />
        <result column="supplier_name" jdbcType="VARCHAR" property="supplierName" />
        <result column="region_id" jdbcType="INTEGER" property="regionId" />
        <result column="region_name" jdbcType="VARCHAR" property="regionName" />
        <result column="count_total" jdbcType="INTEGER" property="countTotal" />
        <result column="count_unfinished" jdbcType="INTEGER" property="countUnfinished" />
        <result column="count_finished" jdbcType="INTEGER" property="countFinished" />
        <result column="count_closed" jdbcType="INTEGER" property="countClosed" />
        <result column="avg_install_time" jdbcType="DECIMAL" property="avgInstallTime" />
        <result column="finish_ratio" jdbcType="DECIMAL" property="finishRatio" />
    </resultMap>


    <sql id="reportOrderWhere">
            <if test="supplierIds != null">
                and od.install_supplier_id in ( ${supplierIds} )
            </if>
            <if test="regionId != null">
                and od.region_id = #{regionId,jdbcType=INTEGER}
            </if>
            <if test="vehicleModel != null and vehicleModel != ''" >
                and od.vehicle_model like  CONCAT(CONCAT('%', #{vehicleModel,jdbcType=VARCHAR}),'%')
            </if>
            <!-- <if test="beginTime != null  and beginTime != ''" >
                and od.survey_reserve_time <![CDATA[ >= ]]> #{beginTime,jdbcType=VARCHAR}
            </if>
            <if test="endTime != null  and endTime != ''" >
                and od.survey_reserve_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
            </if> -->
    </sql>


    <select id="countOrderGroupBySupplierAndRegion"  resultMap="BaseResultMap" parameterType="com.boco.nbd.wios.manage.entity.bo.ReportOrderBo">
        select
        od.install_supplier_id as supplier_id, ts.name as supplier_name,
        <if test="regionId == null">
            od.region_id, tr.name as region_name,
        </if>
         count(1) as count_total,
        sum(case od.status when 64 then 1 else 0 end) as count_closed,
        sum(case when od.install_finish_time is null then (case od.status when 64 then 0 else 1 end)  else 0 end) as count_unfinished,
        sum(case when od.install_finish_time is null then 0 else (case od.status when 64 then 0 else 1 end)  end) as count_finished
        from  t_order od
        join t_supplier ts on od.install_supplier_id = ts.id
        join t_region tr on od.region_id = tr.id
        where 1=1
        <if test="beginTime != null  and beginTime != ''" >
            and od.dispatch_time <![CDATA[ >= ]]> #{beginTime,jdbcType=VARCHAR}
        </if>
        <if test="endTime != null  and endTime != ''" >
            and od.dispatch_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
        </if>
        <if test="supplierIds != null">
            and od.install_supplier_id in ( ${supplierIds} )
        </if>
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and tr.id_tree like #{regionIdTreeLike}
        </if>
        <if test="vehicleModel != null and vehicleModel != ''" >
            and od.vehicle_model like  CONCAT(CONCAT('%', #{vehicleModel,jdbcType=VARCHAR}),'%')
        </if>
        group by od.install_supplier_id
        <if test="regionId == null" >
            ,od.region_id, tr.name
        </if>
        ORDER BY
		od.region_id+0 asc,
		od.install_supplier_id+0 asc
    </select>

    <select id="countOrderGroupBySupplier"  resultMap="BaseResultMap" parameterType="com.boco.nbd.wios.manage.entity.bo.ReportOrderBo">
        select
        od.install_supplier_id as supplier_id, ts.name as supplier_name,
        count(1) as count_total,
        sum(case od.status when 64 then 1 else 0 end) as count_closed,
        sum(case when od.install_finish_time is null then 1 else 0 end) as count_unfinished,
        sum(case when od.install_finish_time is null then 0 else 1 end) as count_finished
        from  t_order od
        join t_supplier ts on od.install_supplier_id = ts.id
        <if test="beginTime != null  and beginTime != ''" >
        	JOIN t_operate_log log on log.third_party_id=od.id and log.name=10
        </if>
        where 1=1
        <if test="beginTime != null  and beginTime != ''" >
            and log.create_time <![CDATA[ >= ]]> #{beginTime,jdbcType=VARCHAR}
        </if>
        <if test="endTime != null  and endTime != ''" >
            and log.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
        </if>
        <include refid="reportOrderWhere" />
        group by od.install_supplier_id,ts.name
    </select>
    <select id="calcOrderFinishedTime"  resultMap="BaseResultMap" parameterType="com.boco.nbd.wios.manage.entity.bo.ReportOrderBo">
        select od.install_supplier_id as supplier_id,
        avg(timestampdiff(hour, ol.create_time, od.install_finish_time)) as avg_install_time
        from  t_order od
        join t_operate_log ol on od.id = ol.third_party_id and ol.name=7
        <if test="beginTime != null  and beginTime != ''" >
        	JOIN t_operate_log log on log.third_party_id=od.id and log.name=10
        </if>
        where 1 = 1
        <if test="beginTime != null  and beginTime != ''" >
            and log.create_time <![CDATA[ >= ]]> #{beginTime,jdbcType=VARCHAR}
        </if>
        <if test="endTime != null  and endTime != ''" >
            and log.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
        </if>
        <include refid="reportOrderWhere" />
        group by od.install_supplier_id
    </select>
    <select id="orderResponseToAdmin" resultType="com.boco.nbd.wios.manage.entity.bo.ReportOrderResponseDTO">
        SELECT
        convert(ifnull(
        sum(
        timestampdiff(
        SECOND,
        od.dispatch_time,
        od.create_time
        )/3600
        ),
        0
        ) / COUNT(1),decimal(10,2)) as order_response,
        COUNT(od.id) cnt,
        sp.id as supplier_id,sp.NAME as supplier_name
        FROM
        t_supplier sp
        left join
        (
        select o.id,o.install_supplier_id,o.dispatch_time,ol.create_time from t_order o
        LEFT JOIN t_region r ON r.id = o.region_id
        LEFT JOIN t_operate_log ol ON o.id = ol.third_party_id
        where ol.NAME = '13'
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and r.id_tree like #{regionIdTreeLike}
        </if>
        <if test="oemId != null  and oemId != ''" >
            and o.oem_id = #{oemId,jdbcType=VARCHAR}
        </if>
        <if test="dispatchBeginTime != null  and dispatchBeginTime != ''" >
            and o.dispatch_time &gt;= #{dispatchBeginTime,jdbcType=VARCHAR}
        </if>
        <if test="dispatchEndTime != null  and dispatchEndTime != ''" >
            and o.dispatch_time &lt;= #{dispatchEndTime,jdbcType=VARCHAR}
        </if>
        ) od ON od.install_supplier_id = sp.id
        WHERE 1=1
        <if test="supplierId != null  and supplierId != ''" >
            and sp.id in
            <foreach collection="supplierId.split(',')" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        GROUP BY od.install_supplier_id,sp.NAME
    </select>
    <select id="surveyResponseToAdmin" resultType="com.boco.nbd.wios.manage.entity.bo.ReportOrderResponseDTO">
        SELECT
        convert(ifnull(
        sum(
        timestampdiff(
        SECOND,
        od.dispatch_time,
        od.survey_finish_time
        )/3600
        ),
        0
        ) / 24 / count(1),decimal(10,2)) as order_response,
        COUNT(od.id) cnt,
        sp.id as supplier_id,sp.NAME as supplier_name
        FROM
        t_supplier sp
        left join
        (
        select o.id,o.install_supplier_id,o.dispatch_time,o.survey_finish_time from t_order o
        LEFT JOIN t_region r ON r.id = o.region_id
        where o.survey_finish_time is not null
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and r.id_tree like #{regionIdTreeLike}
        </if>
        <if test="oemId != null  and oemId != ''" >
            and o.oem_id = #{oemId,jdbcType=VARCHAR}
        </if>
        <if test="dispatchBeginTime != null  and dispatchBeginTime != ''" >
            and o.dispatch_time &gt;= #{dispatchBeginTime,jdbcType=VARCHAR}
        </if>
        <if test="dispatchEndTime != null  and dispatchEndTime != ''" >
            and o.dispatch_time &lt;= #{dispatchEndTime,jdbcType=VARCHAR}
        </if>
        ) od ON od.install_supplier_id = sp.id
        WHERE
        1=1
        <if test="supplierId != null  and supplierId != ''" >
            and sp.id in
            <foreach collection="supplierId.split(',')" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        GROUP BY od.install_supplier_id,sp.NAME
    </select>
    <select id="installResponseToAdmin" resultType="com.boco.nbd.wios.manage.entity.bo.ReportOrderResponseDTO">
        SELECT
        convert(ifnull(
        sum(
        timestampdiff(
        SECOND,
        od.dispatch_time,
        od.install_finish_time
        )/3600
        ),
        0
        ) / 24 / count(1),decimal(10,2)) as order_response,
        COUNT(od.id) cnt,
        sp.id as supplier_id,sp.NAME as supplier_name
        FROM
        t_supplier sp
        left join
        (
        select o.id,o.install_supplier_id,o.dispatch_time,o.install_finish_time from t_order o
        LEFT JOIN t_region r ON r.id = o.region_id
        where o.install_finish_time is not null
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and r.id_tree like #{regionIdTreeLike}
        </if>
        <if test="oemId != null  and oemId != ''" >
            and o.oem_id = #{oemId,jdbcType=VARCHAR}
        </if>
        <if test="dispatchBeginTime != null  and dispatchBeginTime != ''" >
            and o.dispatch_time &gt;= #{dispatchBeginTime,jdbcType=VARCHAR}
        </if>
        <if test="dispatchEndTime != null  and dispatchEndTime != ''" >
            and o.dispatch_time &lt;= #{dispatchEndTime,jdbcType=VARCHAR}
        </if>
        ) od ON od.install_supplier_id = sp.id
        WHERE
        1=1
        <if test="supplierId != null  and supplierId != ''" >
            and sp.id in
            <foreach collection="supplierId.split(',')" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        GROUP BY od.install_supplier_id,sp.NAME
    </select>
    <select id="installEfficientToAdmin" resultType="com.boco.nbd.wios.manage.entity.bo.ReportOrderResponseDTO">
        SELECT
        convert(ifnull(
        sum(
        CASE
        WHEN od.`status` IN (46, 49, 52, 61) THEN
        1
        ELSE
        0
        END
        ),
        0
        ) / count(1)*100,decimal(10,2)) as order_response,
        COUNT(od.id) cnt,
        sp.id as supplier_id,sp.NAME as supplier_name
        FROM
        t_supplier sp
        left join
        (
        select o.id,o.install_supplier_id,o.dispatch_time,o.status from t_order o
        LEFT JOIN t_region r ON r.id = o.region_id
        where o.STATUS != 64
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and r.id_tree like #{regionIdTreeLike}
        </if>
        <if test="oemId != null  and oemId != ''" >
            and o.oem_id = #{oemId,jdbcType=VARCHAR}
        </if>
        <if test="dispatchBeginTime != null  and dispatchBeginTime != ''" >
            and o.dispatch_time &gt;= #{dispatchBeginTime,jdbcType=VARCHAR}
        </if>
        <if test="dispatchEndTime != null  and dispatchEndTime != ''" >
            and o.dispatch_time &lt;= #{dispatchEndTime,jdbcType=VARCHAR}
        </if>
        ) od ON od.install_supplier_id = sp.id
        WHERE
        1=1
        <if test="supplierId != null  and supplierId != ''" >
            and sp.id in
            <foreach collection="supplierId.split(',')" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        GROUP BY od.install_supplier_id,sp.NAME
    </select>
    <select id="reportPassToAdmin" resultType="com.boco.nbd.wios.manage.entity.bo.ReportOrderResponseDTO">
        SELECT
        ifnull(od.order_response,0) as order_response,
        od.cnt,
        sp.id as supplier_id,sp.NAME as supplier_name
        FROM
        t_supplier sp
        left join
        (
        select
        o.install_supplier_id,
        convert((count(DISTINCT o.id) - count(DISTINCT l2.third_party_id) ) / count(DISTINCT o.id)*100,decimal(10,2)) as order_response,
        count(DISTINCT o.id) cnt
        from t_order o
        LEFT JOIN t_region r ON r.id = o.region_id
        LEFT JOIN t_operate_log l1 ON o.id = l1.third_party_id
        LEFT JOIN t_operate_log l2 ON l2.third_party_id = l1.third_party_id
        <if test="type == 1">
        and l2.`NAME` = '28'
        WHERE l1.`NAME` in( '25','28')
        </if>
        <if test="type == 2">
        and l2.`NAME` = '55'
        WHERE l1.`NAME` in( '52','55')
        </if>
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and r.id_tree like #{regionIdTreeLike}
        </if>
        <if test="oemId != null  and oemId != ''" >
            and o.oem_id = #{oemId,jdbcType=VARCHAR}
        </if>
        <if test="dispatchBeginTime != null  and dispatchBeginTime != ''" >
            and l1.create_time &gt;= #{dispatchBeginTime,jdbcType=VARCHAR}
        </if>
        <if test="dispatchEndTime != null  and dispatchEndTime != ''" >
            and l1.create_time &lt;= #{dispatchEndTime,jdbcType=VARCHAR}
        </if>
        GROUP BY
        o.install_supplier_id
        ) od ON od.install_supplier_id = sp.id
        WHERE 1=1
        <if test="supplierId != null  and supplierId != ''" >
            and sp.id in
            <foreach collection="supplierId.split(',')" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        ORDER BY od.install_supplier_id,sp.NAME
    </select>
    <select id="orderResponseToSupplier" resultType="com.boco.nbd.wios.manage.entity.bo.ReportOrderResponseDTO">
        SELECT
        convert(ifnull(
        sum(
        timestampdiff(
        SECOND,
        od.dispatch_time,
        ol.create_time
        )/3600
        ),
        0
        ) / COUNT(1),decimal(10,2)) as order_response,
        DATE_FORMAT(ol.create_time,'%Y-%m') as month
        FROM
        t_order od
        LEFT JOIN t_region r ON r.id = od.region_id
        LEFT JOIN t_operate_log ol ON od.id = ol.third_party_id
        WHERE
        od.install_supplier_id = #{supplierId,jdbcType=VARCHAR} AND ol.NAME = '13'
        <if test="dispatchBeginTime != null  and dispatchBeginTime != ''" >
            and DATE_FORMAT(od.dispatch_time,'%Y-%m') &gt;= #{dispatchBeginTime,jdbcType=VARCHAR}
        </if>
        <if test="dispatchEndTime != null  and dispatchEndTime != ''" >
            and DATE_FORMAT(od.dispatch_time,'%Y-%m') &lt;= #{dispatchEndTime,jdbcType=VARCHAR}
        </if>
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and r.id_tree like #{regionIdTreeLike}
        </if>
        <if test="oemId != null  and oemId != ''" >
            and od.oem_id = #{oemId,jdbcType=VARCHAR}
        </if>
        GROUP BY DATE_FORMAT(od.dispatch_time,'%Y-%m')
    </select>
    <select id="surveyResponseToSupplier" resultType="com.boco.nbd.wios.manage.entity.bo.ReportOrderResponseDTO">
        SELECT
        convert(ifnull(
        sum(
        timestampdiff(
        SECOND,
        od.dispatch_time,
        od.survey_finish_time
        )/3600
        ),
        0
        ) / 24 / count(1),decimal(10,2)) as order_response,
        DATE_FORMAT(od.dispatch_time,'%Y-%m') as month
        FROM
        t_order od
        LEFT JOIN t_region r ON r.id = od.region_id
        WHERE od.survey_finish_time is not null
        and od.install_supplier_id = #{supplierId,jdbcType=VARCHAR}
        <if test="dispatchBeginTime != null  and dispatchBeginTime != ''" >
            and DATE_FORMAT(od.dispatch_time,'%Y-%m') &gt;= #{dispatchBeginTime,jdbcType=VARCHAR}
        </if>
        <if test="dispatchEndTime != null  and dispatchEndTime != ''" >
            and DATE_FORMAT(od.dispatch_time,'%Y-%m') &lt;= #{dispatchEndTime,jdbcType=VARCHAR}
        </if>
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and r.id_tree like #{regionIdTreeLike}
        </if>
        <if test="oemId != null  and oemId != ''" >
            and od.oem_id = #{oemId,jdbcType=VARCHAR}
        </if>
        GROUP BY DATE_FORMAT(od.dispatch_time,'%Y-%m')
    </select>
    <select id="installResponseToSupplier" resultType="com.boco.nbd.wios.manage.entity.bo.ReportOrderResponseDTO">
        SELECT
        convert(ifnull(
        sum(
        timestampdiff(
        SECOND,
        od.dispatch_time,
        od.install_finish_time
        )/3600
        ),
        0
        ) / 24 / count(1),decimal(10,2)) as order_response,
        DATE_FORMAT(od.dispatch_time,'%Y-%m') as month
        FROM
        t_order od
        LEFT JOIN t_region r ON r.id = od.region_id
        WHERE od.install_finish_time is not null
        and od.install_supplier_id = #{supplierId,jdbcType=VARCHAR}
        <if test="dispatchBeginTime != null  and dispatchBeginTime != ''" >
            and DATE_FORMAT(od.dispatch_time,'%Y-%m') &gt;= #{dispatchBeginTime,jdbcType=VARCHAR}
        </if>
        <if test="dispatchEndTime != null  and dispatchEndTime != ''" >
            and DATE_FORMAT(od.dispatch_time,'%Y-%m') &lt;= #{dispatchEndTime,jdbcType=VARCHAR}
        </if>
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and r.id_tree like #{regionIdTreeLike}
        </if>
        <if test="oemId != null  and oemId != ''" >
            and od.oem_id = #{oemId,jdbcType=VARCHAR}
        </if>
        GROUP BY DATE_FORMAT(od.dispatch_time,'%Y-%m')
    </select>
    <select id="installEfficientToSupplier" resultType="com.boco.nbd.wios.manage.entity.bo.ReportOrderResponseDTO">
        SELECT
        convert(ifnull(
        sum(
        CASE
        WHEN od.`status` IN (46, 49, 52, 61) THEN
        1
        ELSE
        0
        END
        ),
        0
        ) / count(1)*100,decimal(10,2)) as order_response,
        DATE_FORMAT(od.dispatch_time,'%Y-%m') as month
        FROM
        t_order od
        LEFT JOIN t_region r ON r.id = od.region_id
        WHERE
        od.STATUS != 64
        and od.install_supplier_id = #{supplierId,jdbcType=VARCHAR}
        <if test="dispatchBeginTime != null  and dispatchBeginTime != ''" >
            and DATE_FORMAT(od.dispatch_time,'%Y-%m') &gt;= #{dispatchBeginTime,jdbcType=VARCHAR}
        </if>
        <if test="dispatchEndTime != null  and dispatchEndTime != ''" >
            and DATE_FORMAT(od.dispatch_time,'%Y-%m') &lt;= #{dispatchEndTime,jdbcType=VARCHAR}
        </if>
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and r.id_tree like #{regionIdTreeLike}
        </if>
        <if test="oemId != null  and oemId != ''" >
            and od.oem_id = #{oemId,jdbcType=VARCHAR}
        </if>
        GROUP BY DATE_FORMAT(od.dispatch_time,'%Y-%m')
    </select>
    <select id="reportPassToSupplier" resultType="com.boco.nbd.wios.manage.entity.bo.ReportOrderResponseDTO">
        SELECT
        convert((count(DISTINCT od.id) - count(DISTINCT l2.third_party_id) ) / count(DISTINCT od.id)*100,decimal(10,2)) as order_response,
        DATE_FORMAT(l1.create_time,'%Y-%m') as month
        FROM
        t_order od
        LEFT JOIN t_region r ON r.id = od.region_id
        LEFT JOIN t_operate_log l1 ON od.id = l1.third_party_id
        LEFT JOIN t_operate_log l2 ON l2.third_party_id = l1.third_party_id
        <if test="type == 1">
        and l2.`NAME` = '28'
        WHERE l1.`NAME` in( '25','28')
        </if>
        <if test="type == 2">
        and l2.`NAME` = '55'
        WHERE l1.`NAME` in( '52','55')
        </if>
        and od.install_supplier_id = #{supplierId,jdbcType=VARCHAR}
        <if test="dispatchBeginTime != null  and dispatchBeginTime != ''" >
            and DATE_FORMAT(l1.create_time,'%Y-%m') &gt;= #{dispatchBeginTime,jdbcType=VARCHAR}
        </if>
        <if test="dispatchEndTime != null  and dispatchEndTime != ''" >
            and DATE_FORMAT(l1.create_time,'%Y-%m') &lt;= #{dispatchEndTime,jdbcType=VARCHAR}
        </if>
        <if test="regionIdTree != null  and regionIdTree != ''" >
            <bind name="regionIdTreeLike" value="regionIdTree + '%'"/>
            and r.id_tree like #{regionIdTreeLike}
        </if>
        <if test="oemId != null  and oemId != ''" >
            and od.oem_id = #{oemId,jdbcType=VARCHAR}
        </if>
        GROUP BY DATE_FORMAT(l1.create_time,'%Y-%m')
    </select>
</mapper>