<?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.njzscloud.supervisory.dispose.mapper.DisposeRecordMapper">

    <select id="export" resultType="com.njzscloud.supervisory.dispose.pojo.DisposeRecordExportResult">
        SELECT origin,
               clearing_company,
               license_plate,
               contact,
               contact_phone,
               in_weight,
               out_weight,
               suttle_weight,
               in_time,
               out_time,
               disposal_site
        FROM dispose_record
        WHERE out_time BETWEEN #{startDate} AND #{endDate}
    </select>
    <select id="statistics" resultType="com.njzscloud.supervisory.dispose.pojo.DisposeRecordStatisticsResult">
        SELECT CAST(DATE_FORMAT(out_time, '%d') AS SIGNED) dispose_day, garbage_category, SUM(suttle_weight) AS total_suttle_weight
        FROM dispose_record
        WHERE deleted = 0
          AND DATE_FORMAT(out_time, '%Y-%m') = '${date}'
        GROUP BY DATE_FORMAT(out_time, '%Y-%m-%d'), garbage_category
        ORDER BY CAST(DATE_FORMAT(out_time, '%d') AS SIGNED) DESC, garbage_category
    </select>
</mapper>
