zxl
2026-03-25 0b39edb68acc67ed01fbfe5d31bfa776a1b17de1
jyz-base-start/src/main/resources/xml/OilRecordMapper.xml
@@ -52,7 +52,7 @@
        select
        oil_position oilPosition, count(1) oilCount,  sum(oil_volume) OilVolume
        from t_oil_record
        where org_code =#{orgCode}
        where org_code like concat(#{orgCode}, '%')
        <if test="dateMonth != null and dateMonth != ''">and DATE_FORMAT(start_time, '%Y-%m')=#{dateMonth}</if>
        GROUP BY oil_position
    </select>
@@ -268,4 +268,43 @@
          GROUP BY model_code
        ) f on m.model_code = f.model_code
    </select>
    <select id="getVehicleFrequencyBeforeActivity" resultType="java.util.Map">
        SELECT
            COUNT(DISTINCT license_num) as totalVehicles,
            COUNT(*) as totalOilRecords,
            AVG(oil_volume) as avgOilVolume,
            SUM(oil_volume) as totalOilVolume
        FROM t_oil_record
        WHERE start_time &lt; #{startTime}
        <foreach collection="orgCodes" item="orgCode" open="AND (" separator=" OR " close=")">
            org_code LIKE concat(#{orgCode}, '%')
        </foreach>
    </select>
    <select id="getVehicleFrequencyDuringActivity" resultType="java.util.Map">
        SELECT
            COUNT(DISTINCT license_num) as totalVehicles,
            COUNT(*) as totalOilRecords,
            AVG(oil_volume) as avgOilVolume,
            SUM(oil_volume) as totalOilVolume
        FROM t_oil_record
        WHERE start_time >= #{startTime} AND start_time &lt;= #{endTime}
        <foreach collection="orgCodes" item="orgCode" open="AND (" separator=" OR " close=")">
            org_code LIKE concat(#{orgCode}, '%')
        </foreach>
    </select>
    <select id="getVehicleFrequencyAfterActivity" resultType="java.util.Map">
        SELECT
            COUNT(DISTINCT license_num) as totalVehicles,
            COUNT(*) as totalOilRecords,
            AVG(oil_volume) as avgOilVolume,
            SUM(oil_volume) as totalOilVolume
        FROM t_oil_record
        WHERE start_time > #{endTime}
        <foreach collection="orgCodes" item="orgCode" open="AND (" separator=" OR " close=")">
            org_code LIKE concat(#{orgCode}, '%')
        </foreach>
    </select>
</mapper>