<?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.energy.manage.service.mappers.analysis.AnalysisGeneralFileMapper">
    <resultMap id="BaseResultMap" type="com.energy.manage.common.po.analysis.AnalysisGeneralFilePo">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="batch_code" property="batchCode" jdbcType="VARCHAR"/>
        <result column="analysis_type_code" property="analysisTypeCode" jdbcType="VARCHAR"/>
        <result column="file_addr" property="fileAddr" jdbcType="VARCHAR"/>
        <result column="auto_analysis" property="createBy" jdbcType="INTEGER"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="engine_type_code" property="engineTypeCode" jdbcType="VARCHAR"/>
    </resultMap>

    <select id="selectByCondition" parameterType="java.lang.String" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisGeneralFileVo">
        select
        general.batch_code,
        general.analysis_type_code,
        type.type_name as analysis_type_name,
        general.file_addr,
        general.engine_type_code,
        general.create_time,
        mill.machine_type_code
        from analysis_general_file general
        left join analysis_type type
        on type.type_code = general.analysis_type_code
        left join wind_engine_mill mill
        on mill.mill_type_code = general.engine_type_code
        where general.batch_code = #{batchCode,jdbcType=VARCHAR}
        <if test="analysisTypeCode != null and analysisTypeCode != ''">
            and general.analysis_type_code = #{analysisTypeCode,jdbcType=VARCHAR}
        </if>
    </select>

    <select id="selectByBatchCode" parameterType="java.lang.String" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisGeneralFileVo">
        select
        general.batch_code,
        general.analysis_type_code,
        type.type_name as analysis_type_name
        from analysis_general_file general
        left join analysis_type type
        on general.analysis_type_code = type.type_code
        where general.batch_code = #{batchCode,jdbcType=VARCHAR}
    </select>
</mapper>
