<?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.huatek.busi.mapper.LabReportBasisDataMapper">

    <select id="list" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="com.huatek.busi.dto.LabReportBasisDataDto">
        SELECT
            A.id AS id,
            A.ref_id AS refId,
            A.m_id AS mId,
            B.main_equ_id AS mainEquId,
            B.main_equ_name AS mainEquName,
            E.`name` AS equName,
            F.`name` AS gapName,
            B.equipment_type AS equType,
            D.file_name AS fileName,
            D.file_path AS filePath,
            A.test_item AS testItem,
            A.test_date AS testDate,
            A.test_staff AS testStaff,
            A.maintenance_unit AS maintenanceUnit,
            A.deleted AS deleted,
            C.offline_param AS offlineParam,
            C.valid_value_range AS valueRange,
            C.current_value AS value,
            C.unit AS unit,
            C.e_param AS rule,
            C.is_mark AS markType,
            C.test_result AS result,
            C.remark AS remark,
            A.create_time AS createTime,
            A.create_user AS createUser,
            A.update_user AS updateUser,
            A.update_time AS updateTime,
            B.sheet_name AS sheetName,
            G.mark_id AS markId
        FROM
            x_lab_report_basis_data A
        LEFT JOIN x_r_master_data B ON A.m_id = B.id
        LEFT JOIN x_lab_report_param_data C ON A.id = C.r_id
        LEFT JOIN sys_file D ON A.ref_id = D.business_id
        LEFT JOIN busi_site_tree E on B.equ_little_id = E.id
        LEFT JOIN busi_site_tree F on B.equ_little_type = F.id
        LEFT JOIN x_lab_report_mark_statistic G ON G.param_id = C.id
        WHERE
            A.`deleted` = #{deleted}
        AND B.`deleted` = #{deleted}
        AND C.`deleted` = #{deleted}
        AND D.`deleted` = #{deleted}
        AND G.`deleted` = #{deleted}
        AND E.`status` = 1
        AND B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="fileType != null and fileType != ''">
            and D.file_type = #{fileType}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="equLittleType != null and equLittleType != ''">
            AND B.equ_little_type = #{equLittleType}
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="sheetName != null and sheetName != ''">
            AND B.sheet_name like CONCAT('%',#{sheetName},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
        <if test="orderBy == null or orderBy == '' or orderWay == null or orderWay == ''">
        order by createTime, testItem DESC
        </if>
        <if test="orderBy != null and orderBy != '' and orderWay != null and orderWay != ''">
        order by #{orderBy},testItem ${orderWay}
        </if>
    </select>

    <select id="list_COUNT" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="Long">
        SELECT COUNT(0)
        FROM
        x_lab_report_basis_data A
        LEFT JOIN x_r_master_data B ON A.m_id = B.id
        LEFT JOIN x_lab_report_param_data C ON A.id = C.r_id
        LEFT JOIN x_lab_report_mark_statistic G ON G.param_id = C.id
        WHERE
        A.`deleted` = #{deleted}
        AND B.`deleted` = #{deleted}
        AND C.`deleted` = #{deleted}
        AND G.`deleted` = #{deleted}
        AND B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="equLittleType != null and equLittleType != ''">
            AND B.equ_little_type = #{equLittleType}
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="sheetName != null and sheetName != ''">
            AND B.sheet_name like CONCAT('%',#{sheetName},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
    </select>

    <select id="listBlq" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="com.huatek.busi.dto.LabReportBasisDataDto">
        SELECT
            A.id AS id,
            A.ref_id AS refId,
            A.m_id AS mId,
            B.main_equ_id AS mainEquId,
            B.main_equ_name AS mainEquName,
            E.`name` AS equName,
            F.`name` AS gapName,
            B.equipment_type AS equType,
            D.file_name AS fileName,
            D.file_path AS filePath,
            A.test_item AS testItem,
            A.test_date AS testDate,
            A.test_staff AS testStaff,
            A.maintenance_unit AS maintenanceUnit,
            A.deleted AS deleted,
            C.offline_param AS offlineParam,
            C.valid_value_range AS valueRange,
            C.current_value AS value,
            C.unit AS unit,
            C.e_param AS rule,
            C.is_mark AS markType,
            C.test_result AS result,
            C.remark AS remark,
            A.create_time AS createTime,
            A.create_user AS createUser,
            A.update_user AS updateUser,
            A.update_time AS updateTime,
            B.sheet_name AS sheetName,
            G.mark_id AS markId
        FROM
        x_lab_arrester_report_basis_data A
        LEFT JOIN x_r_arrester_data B ON A.m_id = B.id
        LEFT JOIN x_lab_arrester_report_param_data C ON A.id = C.r_id
        LEFT JOIN sys_file D ON A.ref_id = D.business_id
        LEFT JOIN busi_site_tree E on B.equ_little_id = E.id
        LEFT JOIN busi_site_tree F on B.equ_little_type = F.id
        LEFT JOIN x_lab_arrester_report_mark_statistic G ON G.param_id = C.id
        WHERE
        A.`deleted` = #{deleted}
        AND B.`deleted` = #{deleted}
        AND C.`deleted` = #{deleted}
        AND D.`deleted` = #{deleted}
        AND G.`deleted` = #{deleted}
        AND E.`status` = 1
        AND B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="fileType != null and fileType != ''">
            and D.file_type = #{fileType}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="equLittleType != null and equLittleType != ''">
            AND B.equ_little_type = #{equLittleType}
        </if>
        <if test="sheetName != null and sheetName != ''">
            AND B.sheet_name like CONCAT('%',#{sheetName},'%')
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
        <if test="orderBy == null or orderBy == '' or orderWay == null or orderWay == ''">
            order by createTime, testItem DESC
        </if>
        <if test="orderBy != null and orderBy != '' and orderWay != null and orderWay != ''">
            order by #{orderBy},testItem ${orderWay}
        </if>
    </select>

    <select id="listBlq_COUNT" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="Long">
        SELECT COUNT(0)
        FROM
        x_lab_arrester_report_basis_data A
        LEFT JOIN x_r_arrester_data B ON A.m_id = B.id
        LEFT JOIN x_lab_arrester_report_param_data C ON A.id = C.r_id
        LEFT JOIN x_lab_arrester_report_mark_statistic G ON G.param_id = C.id
        WHERE
        A.`deleted` = #{deleted}
        AND B.`deleted` = #{deleted}
        AND C.`deleted` = #{deleted}
        AND G.`deleted` = #{deleted}
        AND B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="equLittleType != null and equLittleType != ''">
            AND B.equ_little_type = #{equLittleType}
        </if>
        <if test="sheetName != null and sheetName != ''">
            AND B.sheet_name like CONCAT('%',#{sheetName},'%')
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
    </select>

    <select id="listDl" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="com.huatek.busi.dto.LabReportBasisDataDto">
        SELECT
            A.id AS id,
            A.ref_id AS refId,
            A.m_id AS mId,
            B.main_equ_id AS mainEquId,
            B.main_equ_name AS mainEquName,
            E.`name` AS equName,
            F.`name` AS gapName,
            B.equipment_type AS equType,
            D.file_name AS fileName,
            D.file_path AS filePath,
            A.test_item AS testItem,
            A.test_date AS testDate,
            A.test_staff AS testStaff,
            A.maintenance_unit AS maintenanceUnit,
            A.deleted AS deleted,
            C.offline_param AS offlineParam,
            C.valid_value_range AS valueRange,
            C.current_value AS value,
            C.unit AS unit,
            C.e_param AS rule,
            C.is_mark AS markType,
            C.test_result AS result,
            C.remark AS remark,
            A.create_time AS createTime,
            A.create_user AS createUser,
            A.update_user AS updateUser,
            A.update_time AS updateTime,
            B.sheet_name AS sheetName,
            G.mark_id AS markId
        FROM
        x_lab_cable_report_basis_data A
        LEFT JOIN x_r_cable_data B ON A.m_id = B.id
        LEFT JOIN x_lab_cable_report_param_data C ON A.id = C.r_id
        LEFT JOIN sys_file D ON A.ref_id = D.business_id
        LEFT JOIN busi_site_tree E on B.equ_little_id = E.id
        LEFT JOIN busi_site_tree F on B.equ_little_type = F.id
        LEFT JOIN x_lab_cable_report_mark_statistic G ON G.param_id = C.id
        WHERE
        A.`deleted` = #{deleted}
        AND B.`deleted` = #{deleted}
        AND C.`deleted` = #{deleted}
        AND D.`deleted` = #{deleted}
        AND G.`deleted` = #{deleted}
        AND E.`status` = 1
        AND B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="fileType != null and fileType != ''">
            and D.file_type = #{fileType}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="equLittleType != null and equLittleType != ''">
            AND B.equ_little_type = #{equLittleType}
        </if>
        <if test="sheetName != null and sheetName != ''">
            AND B.sheet_name like CONCAT('%',#{sheetName},'%')
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
        <if test="orderBy == null or orderBy == '' or orderWay == null or orderWay == ''">
            order by createTime, testItem DESC
        </if>
        <if test="orderBy != null and orderBy != '' and orderWay != null and orderWay != ''">
            order by #{orderBy},testItem ${orderWay}
        </if>
    </select>

    <select id="listDl_COUNT" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="Long">
        SELECT COUNT(0)
        FROM
        x_lab_cable_report_basis_data A
        LEFT JOIN x_r_cable_data B ON A.m_id = B.id
        LEFT JOIN x_lab_cable_report_param_data C ON A.id = C.r_id
        LEFT JOIN x_lab_cable_report_mark_statistic G ON G.param_id = C.id
        WHERE
        A.`deleted` = #{deleted}
        AND B.`deleted` = #{deleted}
        AND C.`deleted` = #{deleted}
        AND G.`deleted` = #{deleted}
        AND B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="equLittleType != null and equLittleType != ''">
            AND B.equ_little_type = #{equLittleType}
        </if>
        <if test="sheetName != null and sheetName != ''">
            AND B.sheet_name like CONCAT('%',#{sheetName},'%')
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
    </select>

    <select id="listKgg" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="com.huatek.busi.dto.LabReportBasisDataDto">
        SELECT
            A.id AS id,
            A.ref_id AS refId,
            A.m_id AS mId,
            B.main_equ_id AS mainEquId,
            B.main_equ_name AS mainEquName,
            E.`name` AS equName,
            F.`name` AS gapName,
            B.equipment_type AS equType,
            D.file_name AS fileName,
            D.file_path AS filePath,
            A.test_item AS testItem,
            A.test_date AS testDate,
            A.test_staff AS testStaff,
            A.maintenance_unit AS maintenanceUnit,
            A.deleted AS deleted,
            C.offline_param AS offlineParam,
            C.valid_value_range AS valueRange,
            C.current_value AS value,
            C.unit AS unit,
            C.e_param AS rule,
            C.is_mark AS markType,
            C.test_result AS result,
            C.remark AS remark,
            A.create_time AS createTime,
            A.create_user AS createUser,
            A.update_user AS updateUser,
            A.update_time AS updateTime,
            B.sheet_name AS sheetName,
            G.mark_id AS markId
        FROM
        x_lab_switchgear_report_basis_data A
        LEFT JOIN x_r_switchgear_data B ON A.m_id = B.id
        LEFT JOIN x_lab_switchgear_report_param_data C ON A.id = C.r_id
        LEFT JOIN sys_file D ON A.ref_id = D.business_id
        LEFT JOIN busi_site_tree E on B.equ_little_id = E.id
        LEFT JOIN busi_site_tree F on B.equ_little_type = F.id
        LEFT JOIN x_lab_switchgear_report_mark_statistic G ON G.param_id = C.id
        WHERE
        A.`deleted` = #{deleted}
        AND B.`deleted` = #{deleted}
        AND C.`deleted` = #{deleted}
        AND D.`deleted` = #{deleted}
        AND G.`deleted` = #{deleted}
        AND E.`status` = 1
        AND B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="fileType != null and fileType != ''">
            and D.file_type = #{fileType}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="equLittleType != null and equLittleType != ''">
            AND B.equ_little_type = #{equLittleType}
        </if>
        <if test="sheetName != null and sheetName != ''">
            AND B.sheet_name like CONCAT('%',#{sheetName},'%')
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
        <if test="orderBy == null or orderBy == '' or orderWay == null or orderWay == ''">
            order by createTime, testItem DESC
        </if>
        <if test="orderBy != null and orderBy != '' and orderWay != null and orderWay != ''">
            order by #{orderBy},testItem ${orderWay}
        </if>
    </select>

    <select id="listKgg_COUNT" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="Long">
        SELECT COUNT(0)
        FROM
        x_lab_switchgear_report_basis_data A
        LEFT JOIN x_r_switchgear_data B ON A.m_id = B.id
        LEFT JOIN x_lab_switchgear_report_param_data C ON A.id = C.r_id
        LEFT JOIN x_lab_switchgear_report_mark_statistic G ON G.param_id = C.id
        WHERE
        A.`deleted` = #{deleted}
        AND B.`deleted` = #{deleted}
        AND C.`deleted` = #{deleted}
        AND G.`deleted` = #{deleted}
        AND B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="equLittleType != null and equLittleType != ''">
            AND B.equ_little_type = #{equLittleType}
        </if>
        <if test="sheetName != null and sheetName != ''">
            AND B.sheet_name like CONCAT('%',#{sheetName},'%')
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
    </select>

    <select id="listGen" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="com.huatek.busi.dto.LabReportBasisDataDto">
        SELECT
            A.id AS id,
            A.ref_id AS refId,
            A.m_id AS mId,
            B.main_equ_id AS mainEquId,
            B.main_equ_name AS mainEquName,
            E.`name` AS equName,
            F.`name` AS gapName,
            B.equipment_type AS equType,
            D.file_name AS fileName,
            D.file_path AS filePath,
            A.test_item AS testItem,
            A.test_date AS testDate,
            A.test_staff AS testStaff,
            A.maintenance_unit AS maintenanceUnit,
            A.deleted AS deleted,
            C.offline_param AS offlineParam,
            C.valid_value_range AS valueRange,
            C.current_value AS value,
            C.unit AS unit,
            C.e_param AS rule,
            C.is_mark AS markType,
            C.test_result AS result,
            C.remark AS remark,
            A.create_time AS createTime,
            A.create_user AS createUser,
            A.update_user AS updateUser,
            A.update_time AS updateTime,
            B.sheet_name AS sheetName,
            G.mark_id AS markId
        FROM
        x_lab_generator_report_basis_data A
        LEFT JOIN x_r_generator_data B ON A.m_id = B.id
        LEFT JOIN x_lab_generator_report_param_data C ON A.id = C.r_id
        LEFT JOIN sys_file D ON A.ref_id = D.business_id
        LEFT JOIN busi_site_tree E on B.equ_little_id = E.id
        LEFT JOIN busi_site_tree F on B.equ_little_type = F.id
        LEFT JOIN x_lab_generator_report_mark_statistic G ON G.param_id = C.id
        WHERE
        A.`deleted` = #{deleted}
        AND B.`deleted` = #{deleted}
        AND C.`deleted` = #{deleted}
        AND D.`deleted` = #{deleted}
        AND G.`deleted` = #{deleted}
        AND E.`status` = 1
        AND B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="fileType != null and fileType != ''">
            and D.file_type = #{fileType}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="equLittleType != null and equLittleType != ''">
            AND B.equ_little_type = #{equLittleType}
        </if>
        <if test="sheetName != null and sheetName != ''">
            AND B.sheet_name like CONCAT('%',#{sheetName},'%')
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
        ) T
        <if test="orderBy == null or orderBy == '' or orderWay == null or orderWay == ''">
            order by createTime, testItem DESC
        </if>
        <if test="orderBy != null and orderBy != '' and orderWay != null and orderWay != ''">
            order by #{orderBy},testItem ${orderWay}
        </if>
    </select>

    <select id="listGen_COUNT" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="Long">
        SELECT COUNT(0)
        FROM
        x_lab_generator_report_basis_data A
        LEFT JOIN x_r_generator_data B ON A.m_id = B.id
        LEFT JOIN x_lab_generator_report_param_data C ON A.id = C.r_id
        LEFT JOIN x_lab_generator_report_mark_statistic G ON G.param_id = C.id
        WHERE
        A.`deleted` = #{deleted}
        AND B.`deleted` = #{deleted}
        AND C.`deleted` = #{deleted}
        AND G.`deleted` = #{deleted}
        AND B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="equLittleType != null and equLittleType != ''">
            AND B.equ_little_type = #{equLittleType}
        </if>
        <if test="sheetName != null and sheetName != ''">
            AND B.sheet_name like CONCAT('%',#{sheetName},'%')
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
    </select>

    <select id="findExcelList" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="com.huatek.busi.dto.LabReportBasisDataDto">
        SELECT
            DISTINCT(A.ref_id) AS refId,
            D.create_date AS createTime,
            D.file_name AS fileName,
            D.file_path AS filePath
        FROM
        x_lab_report_basis_data A
        LEFT JOIN x_r_master_data B ON A.m_id = B.id
        LEFT JOIN x_lab_report_param_data C ON A.id = C.r_id
        LEFT JOIN sys_file D ON A.ref_id = D.business_id
        LEFT JOIN busi_site_tree E on B.equ_little_id = E.id
        WHERE
            A.deleted = #{deleted}
        AND B.deleted = #{deleted}
        AND C.deleted = #{deleted}
        and B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="fileType != null and fileType != ''">
            and D.file_type = #{fileType}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
    </select>

    <select id="findBlqExcelList" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="com.huatek.busi.dto.LabReportBasisDataDto">
        SELECT
        DISTINCT(A.ref_id) AS refId,
        D.create_date AS createTime,
        D.file_name AS fileName,
        D.file_path AS filePath
        FROM
        x_lab_arrester_report_basis_data A
        LEFT JOIN x_r_arrester_data B ON A.m_id = B.id
        LEFT JOIN x_lab_arrester_report_param_data C ON A.id = C.r_id
        LEFT JOIN sys_file D ON A.ref_id = D.business_id
        LEFT JOIN busi_site_tree E on B.equ_little_id = E.id
        WHERE
        A.deleted = #{deleted}
        AND B.deleted = #{deleted}
        AND C.deleted = #{deleted}
        and B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="fileType != null and fileType != ''">
            and D.file_type = #{fileType}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
    </select>

    <select id="findDlExcelList" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="com.huatek.busi.dto.LabReportBasisDataDto">
        SELECT
        DISTINCT(A.ref_id) AS refId,
        D.create_date AS createTime,
        D.file_name AS fileName,
        D.file_path AS filePath
        FROM
        x_lab_cable_report_basis_data A
        LEFT JOIN x_r_cable_data B ON A.m_id = B.id
        LEFT JOIN x_lab_cable_report_param_data C ON A.id = C.r_id
        LEFT JOIN sys_file D ON A.ref_id = D.business_id
        LEFT JOIN busi_site_tree E on B.equ_little_id = E.id
        WHERE
        A.deleted = #{deleted}
        AND B.deleted = #{deleted}
        AND C.deleted = #{deleted}
        and B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="fileType != null and fileType != ''">
            and D.file_type = #{fileType}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
    </select>

    <select id="findKggExcelList" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="com.huatek.busi.dto.LabReportBasisDataDto">
        SELECT
        DISTINCT(A.ref_id) AS refId,
        D.create_date AS createTime,
        D.file_name AS fileName,
        D.file_path AS filePath
        FROM
        x_lab_switchgear_report_basis_data A
        LEFT JOIN x_r_switchgear_data B ON A.m_id = B.id
        LEFT JOIN x_lab_switchgear_report_param_data C ON A.id = C.r_id
        LEFT JOIN sys_file D ON A.ref_id = D.business_id
        LEFT JOIN busi_site_tree E on B.equ_little_id = E.id
        WHERE
        A.deleted = #{deleted}
        AND B.deleted = #{deleted}
        AND C.deleted = #{deleted}
        and B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="fileType != null and fileType != ''">
            and D.file_type = #{fileType}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
    </select>

    <select id="findGenExcelList" parameterType="com.huatek.busi.where.LabReportBasisDataSelectVo" resultType="com.huatek.busi.dto.LabReportBasisDataDto">
        SELECT
        DISTINCT(A.ref_id) AS refId,
        D.create_date AS createTime,
        D.file_name AS fileName,
        D.file_path AS filePath
        FROM
        x_lab_generator_report_basis_data A
        LEFT JOIN x_r_generator_data B ON A.m_id = B.id
        LEFT JOIN x_lab_generator_report_param_data C ON A.id = C.r_id
        LEFT JOIN sys_file D ON A.ref_id = D.business_id
        LEFT JOIN busi_site_tree E on B.equ_little_id = E.id
        WHERE
        A.deleted = #{deleted}
        AND B.deleted = #{deleted}
        AND C.deleted = #{deleted}
        and B.equipment_type = #{equType}
        <if test="refId != null and refId != ''">
            and A.ref_id = #{refId}
        </if>
        <if test="fileType != null and fileType != ''">
            and D.file_type = #{fileType}
        </if>
        <if test="mainEquName != null and mainEquName != ''">
            AND B.main_equ_name like CONCAT('%',#{mainEquName},'%')
        </if>
        <if test="equLittleId != null and equLittleId != ''">
            AND B.equ_little_id = #{equLittleId}
        </if>
        <if test="testItem != null and testItem != ''">
            AND A.test_item like CONCAT('%',#{testItem},'%')
        </if>
        <if test="offlineParam != null and offlineParam != ''">
            AND C.offline_param like CONCAT('%',#{offlineParam},'%')
        </if>
        <if test="startDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ >= ]]> DATE_FORMAT(#{startDate},"%Y-%m-%d")
        </if>
        <if test="endDate != null">
            AND DATE_FORMAT(A.test_date,"%Y-%m-%d") <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},"%Y-%m-%d")
        </if>
    </select>

    <update id="delete" parameterType="java.lang.String">
        UPDATE x_lab_report_basis_data
        SET deleted = 1
        WHERE
            ref_id = #{refId}
    </update>

    <update id="deleteBlq" parameterType="java.lang.String">
        UPDATE x_lab_arrester_report_basis_data
        SET deleted = 1
        WHERE
            ref_id = #{refId}
    </update>

    <update id="deleteDl" parameterType="java.lang.String">
        UPDATE x_lab_cable_report_basis_data
        SET deleted = 1
        WHERE
            ref_id = #{refId}
    </update>

    <update id="deleteKgg" parameterType="java.lang.String">
        UPDATE x_lab_switchgear_report_basis_data
        SET deleted = 1
        WHERE
            ref_id = #{refId}
    </update>

    <update id="deleteGen" parameterType="java.lang.String">
        UPDATE x_lab_generator_report_basis_data
        SET deleted = 1
        WHERE
            ref_id = #{refId}
    </update>

    <update id="updateByRefIds" parameterType="java.util.List">
        UPDATE x_lab_report_basis_data
        SET deleted = 1
        WHERE
            ref_id in
        <foreach collection="refIds" index="index" item="refId" open="(" separator="," close=")">
            #{refId}
        </foreach>
    </update>

    <update id="updateBlqByRefIds" parameterType="java.util.List">
        UPDATE x_lab_arrester_report_basis_data
        SET deleted = 1
        WHERE
        ref_id in
        <foreach collection="refIds" index="index" item="refId" open="(" separator="," close=")">
            #{refId}
        </foreach>
    </update>

    <update id="updateDlByRefIds" parameterType="java.util.List">
        UPDATE x_lab_cable_report_basis_data
        SET deleted = 1
        WHERE
        ref_id in
        <foreach collection="refIds" index="index" item="refId" open="(" separator="," close=")">
            #{refId}
        </foreach>
    </update>

    <update id="updateKggByRefIds" parameterType="java.util.List">
        UPDATE x_lab_switchgear_report_basis_data
        SET deleted = 1
        WHERE
        ref_id in
        <foreach collection="refIds" index="index" item="refId" open="(" separator="," close=")">
            #{refId}
        </foreach>
    </update>

    <update id="updateGenByRefIds" parameterType="java.util.List">
        UPDATE x_lab_generator_report_basis_data
        SET deleted = 1
        WHERE
        ref_id in
        <foreach collection="refIds" index="index" item="refId" open="(" separator="," close=")">
            #{refId}
        </foreach>
    </update>

    <select id="findId" resultType="string">
        SELECT
            id
        FROM
            busi_site_tree
        WHERE
            id = #{equlittleId}
            AND `status` = 1;
    </select>
    <select id="findLastFile" resultType="string">
        SELECT
            file_name AS fileName
        FROM
            sys_file
        WHERE
            equ_type = #{eqType}
            AND file_type = #{key}
        ORDER BY
            create_date DESC
            LIMIT 1
    </select>
    <select id="findByqInfo" resultType="com.huatek.busi.vo.BusiSiteTreeVo">
        SELECT
            A.id AS id,
            A.parent_id AS parentId,
            A.NAME AS name,
            A.site_id AS siteId,
            C.site_name AS siteName,
            B.`name` AS mvaName,
            B.system_code AS systemCode
        FROM
            busi_site_tree A
            LEFT JOIN busi_site_tree B ON B.id = A.parent_id
            LEFT JOIN busi_site C ON A.site_id = C.id
        WHERE
            A.id = #{equipmentId}
            AND A.`status` = 1
    </select>
    <select id="findGisInfo" resultType="com.huatek.busi.vo.BusiSiteTreeVo">
        SELECT
            A.id AS id,
            A.parent_id AS parentId,
            A.NAME AS name,
            A.site_id AS siteId,
            B.NAME AS parentName,
            D.site_name AS siteName,
            C.`name` AS mvaName,
            C.system_code AS systemCode
        FROM
            busi_site_tree A
            LEFT JOIN busi_site_tree B ON B.id = A.parent_id
            LEFT JOIN busi_site_tree C ON C.id = B.parent_id
            LEFT JOIN busi_site D ON A.site_id = D.id
        WHERE
            A.id = #{equipmentId}
            AND A.parent_id = #{jgId}
            AND A.`status` = 1
            AND B.`status` = 1
            AND C.`status` = 1
            AND B.id = #{jgId}
    </select>
    <select id="findEquTypeId" resultType="String">
        SELECT
            gis_type
        FROM
            busi_offline_gis_brand
        WHERE
            main_equipment_id = #{equipmentId}
    </select>

    <select id="findBusiOfflineGisBrand" resultType="com.huatek.busi.entity.BusiOfflineGisBrand">
        SELECT
       *
        FROM
        busi_offline_gis_brand
        WHERE
        main_equipment_id = #{equipmentId}
    </select>
</mapper>
