<?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.njcn.device.pms.mapper.majornetwork.RQualityParameterMapper">

    <!--获取主网数据质量-台账数据质量统计-->
    <select id="getLedgerDataQualityStat" resultType="com.njcn.device.pms.pojo.po.RQualityParameterPO">
        SELECT
        b.org_no AS orgNo,
        b.data_date AS dataDate,
        b.measurement_count AS measurementCount,
        b.effective_access_measurement_count AS effectiveAccessMeasurementCount,
        b.problem AS problem,
        b.matching_count AS matchingCount,
        b.matching_rate AS matchingRate,
        b.monitoring_integrity_rate AS monitoringIntegrityRate,
        b.data_type AS dataType,(
        SELECT
        a.problem
        FROM
        r_quality_parameter_m AS a
        WHERE
        a.org_no = b.org_no
        AND (
        b.data_date &gt;= date(
        DATE_ADD( #{param.startTime}, INTERVAL - 1 YEAR )))
        AND (
        b.data_date &lt;= date(
        DATE_ADD( #{param.endTime}, INTERVAL - 1 YEAR )))
        ) AS problemYearOnYear
        FROM
        r_quality_parameter_m AS b
        WHERE
        b.org_no IN
        <foreach collection="deptIdList" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        <if test="param.startTime != null and param.startTime != ''">
            AND DATE_FORMAT(b.data_date, '%Y-%m-%d') &gt;= DATE_FORMAT(#{param.startTime}, '%Y-%m-%d')
        </if>
        <if test="param.endTime != null and param.endTime != ''">
            AND DATE_FORMAT(b.data_date, '%Y-%m-%d') &lt;= DATE_FORMAT(#{param.endTime}, '%Y-%m-%d')
        </if>
        <if test="distributionPoint != null and distributionPoint != ''">
            AND b.data_type = #{distributionPoint}
        </if>
    </select>
</mapper>