<?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.ruoyi.powerdistribution.mapper.PdmBranchLineMapper">

    <resultMap type="PdmBranchLine" id="PdmBranchLineResult">
        <result property="id"    column="id"    />
        <result property="bigFeederBranchLineId"    column="big_feeder_branch_line_id"    />
        <result property="lineNm"    column="line_nm"    />
        <result property="eqpNo"    column="eqp_no"    />
        <result property="runNo"    column="run_no"    />
        <result property="blgBigFeederId"    column="blg_big_feeder_id"    />
        <result property="blgBigFeederNm"    column="blg_big_feeder_nm"    />
        <result property="voltLvlCd"    column="volt_lvl_cd"    />
        <result property="voltLvlDsc"    column="volt_lvl_dsc"    />
        <result property="erectModeCd"    column="erect_mode_cd"    />
        <result property="erectModeDsc"    column="erect_mode_dsc"    />
        <result property="overhdLineLen"    column="overhd_line_len"    />
        <result property="cableLineLen"    column="cable_line_len"    />
        <result property="lineTolLen"    column="line_tol_len"    />
        <result property="startEqpId"    column="start_eqp_id"    />
        <result property="startEqpNm"    column="start_eqp_nm"    />
        <result property="startEqpTypCd"    column="start_eqp_typ_cd"    />
        <result property="startEqpTypDsc"    column="start_eqp_typ_dsc"    />
        <result property="lineNatureCd"    column="line_nature_cd"    />
        <result property="lineNatureDsc"    column="line_nature_dsc"    />
        <result property="blgSuperLineId"    column="blg_super_line_id"    />
        <result property="blgSuperLineNm"    column="blg_super_line_nm"    />
        <result property="blgCityId"    column="blg_city_id"    />
        <result property="blgCityNm"    column="blg_city_nm"    />
        <result property="opMaintOrgId"    column="op_maint_org_id"    />
        <result property="opMaintOrgNm"    column="op_maint_org_nm"    />
        <result property="maintTeamId"    column="maint_team_id"    />
        <result property="maintTeamNm"    column="maint_team_nm"    />
        <result property="runStCd"    column="run_st_cd"    />
        <result property="runStDsc"    column="run_st_dsc"    />
        <result property="releaseStDsc"    column="release_st_dsc"    />
        <result property="repmaintLineLen"    column="repmaint_line_len"    />
        <result property="isHaveFigur"    column="is_have_figur"    />
        <result property="stdEqpMasterId"    column="std_eqp_master_id"    />
        <result property="stdEqpMasterNm"    column="std_eqp_master_nm"    />
        <result property="shipDt"    column="ship_dt"    />
        <result property="stdOrgNo"    column="std_org_no"    />
        <result property="stdOrgNm"    column="std_org_nm"    />
        <result property="stdCityOrgNm"    column="std_city_org_nm"    />
        <result property="stdCountyOrgNo"    column="std_county_org_no"    />
        <result property="stdCountyOrgNm"    column="std_county_org_nm"    />
        <result property="dataDt"    column="data_dt"    />
        <result property="etlTm"    column="etl_tm"    />
        <result property="stdCityOrgNo"    column="std_city_org_no"    />
        <result property="startPos"    column="start_pos"    />
        <result property="eqpMasterId"    column="eqp_master_id"    />
        <result property="eqpMasterNm"    column="eqp_master_nm"    />
        <result property="battalionId"    column="battalion_id"    />
        <result property="battalionNm"    column="battalion_nm"    />
        <result property="retrogresDt"    column="retrogres_dt"    />
        <result property="createTm"    column="create_tm"    />
        <result property="latestUpdTm"    column="latest_upd_tm"    />
    </resultMap>

    <sql id="selectPdmBranchLineVo">
        select id, big_feeder_branch_line_id, line_nm, eqp_no, run_no, blg_big_feeder_id, blg_big_feeder_nm, volt_lvl_cd, volt_lvl_dsc, erect_mode_cd, erect_mode_dsc, overhd_line_len, cable_line_len, line_tol_len, start_eqp_id, start_eqp_nm, start_eqp_typ_cd, start_eqp_typ_dsc, line_nature_cd, line_nature_dsc, blg_super_line_id, blg_super_line_nm, blg_city_id, blg_city_nm, op_maint_org_id, op_maint_org_nm, maint_team_id, maint_team_nm, run_st_cd, run_st_dsc, release_st_dsc, repmaint_line_len, is_have_figur, std_eqp_master_id, std_eqp_master_nm, ship_dt, std_org_no, std_org_nm, SUBSTRING_INDEX(std_city_org_nm, '国网湖南省电力有限公司', -1)std_city_org_nm , std_county_org_no, SUBSTRING_INDEX(std_county_org_nm, '国网湖南省电力有限公司', -1)std_county_org_nm, data_dt, etl_tm, std_city_org_no, start_pos, eqp_master_id, eqp_master_nm, battalion_id, battalion_nm, retrogres_dt, create_tm, latest_upd_tm from pdm_branch_line
    </sql>

    <select id="selectPdmBranchLineList" parameterType="PdmBranchLine" resultMap="PdmBranchLineResult">
        <include refid="selectPdmBranchLineVo"/>
        <where>
            <if test="bigFeederBranchLineId != null  and bigFeederBranchLineId != ''"> and big_feeder_branch_line_id = #{bigFeederBranchLineId}</if>
            <if test="lineNm != null  and lineNm != ''"> and line_nm = #{lineNm}</if>
            <if test="eqpNo != null  and eqpNo != ''"> and eqp_no = #{eqpNo}</if>
            <if test="runNo != null  and runNo != ''"> and run_no = #{runNo}</if>
            <if test="blgBigFeederId != null  and blgBigFeederId != ''"> and blg_big_feeder_id = #{blgBigFeederId}</if>
            <if test="blgBigFeederNm != null  and blgBigFeederNm != ''"> and blg_big_feeder_nm = #{blgBigFeederNm}</if>
            <if test="voltLvlCd != null  and voltLvlCd != ''"> and volt_lvl_cd = #{voltLvlCd}</if>
            <if test="voltLvlDsc != null  and voltLvlDsc != ''"> and volt_lvl_dsc = #{voltLvlDsc}</if>
            <if test="erectModeCd != null  and erectModeCd != ''"> and erect_mode_cd = #{erectModeCd}</if>
            <if test="erectModeDsc != null  and erectModeDsc != ''"> and erect_mode_dsc = #{erectModeDsc}</if>
            <if test="overhdLineLen != null "> and overhd_line_len = #{overhdLineLen}</if>
            <if test="cableLineLen != null "> and cable_line_len = #{cableLineLen}</if>
            <if test="lineTolLen != null "> and line_tol_len = #{lineTolLen}</if>
            <if test="startEqpId != null  and startEqpId != ''"> and start_eqp_id = #{startEqpId}</if>
            <if test="startEqpNm != null  and startEqpNm != ''"> and start_eqp_nm = #{startEqpNm}</if>
            <if test="startEqpTypCd != null  and startEqpTypCd != ''"> and start_eqp_typ_cd = #{startEqpTypCd}</if>
            <if test="startEqpTypDsc != null  and startEqpTypDsc != ''"> and start_eqp_typ_dsc = #{startEqpTypDsc}</if>
            <if test="lineNatureCd != null  and lineNatureCd != ''"> and line_nature_cd = #{lineNatureCd}</if>
            <if test="lineNatureDsc != null  and lineNatureDsc != ''"> and line_nature_dsc = #{lineNatureDsc}</if>
            <if test="blgSuperLineId != null  and blgSuperLineId != ''"> and blg_super_line_id = #{blgSuperLineId}</if>
            <if test="blgSuperLineNm != null  and blgSuperLineNm != ''"> and blg_super_line_nm = #{blgSuperLineNm}</if>
            <if test="blgCityId != null  and blgCityId != ''"> and blg_city_id = #{blgCityId}</if>
            <if test="blgCityNm != null  and blgCityNm != ''"> and blg_city_nm = #{blgCityNm}</if>
            <if test="opMaintOrgId != null  and opMaintOrgId != ''"> and op_maint_org_id = #{opMaintOrgId}</if>
            <if test="opMaintOrgNm != null  and opMaintOrgNm != ''"> and op_maint_org_nm = #{opMaintOrgNm}</if>
            <if test="maintTeamId != null  and maintTeamId != ''"> and maint_team_id = #{maintTeamId}</if>
            <if test="maintTeamNm != null  and maintTeamNm != ''"> and maint_team_nm = #{maintTeamNm}</if>
            <if test="runStCd != null  and runStCd != ''"> and run_st_cd = #{runStCd}</if>
            <if test="runStDsc != null  and runStDsc != ''"> and run_st_dsc = #{runStDsc}</if>
            <if test="releaseStDsc != null  and releaseStDsc != ''"> and release_st_dsc = #{releaseStDsc}</if>
            <if test="repmaintLineLen != null "> and repmaint_line_len = #{repmaintLineLen}</if>
            <if test="isHaveFigur != null  and isHaveFigur != ''"> and is_have_figur = #{isHaveFigur}</if>
            <if test="stdEqpMasterId != null  and stdEqpMasterId != ''"> and std_eqp_master_id = #{stdEqpMasterId}</if>
            <if test="stdEqpMasterNm != null  and stdEqpMasterNm != ''"> and std_eqp_master_nm = #{stdEqpMasterNm}</if>
            <if test="shipDt != null  and shipDt != ''"> and ship_dt = #{shipDt}</if>
            <if test="stdOrgNo != null  and stdOrgNo != ''"> and std_org_no = #{stdOrgNo}</if>
            <if test="stdOrgNm != null  and stdOrgNm != ''"> and std_org_nm = #{stdOrgNm}</if>
            <if test="stdCityOrgNm != null  and stdCityOrgNm != ''"> and std_city_org_nm = #{stdCityOrgNm}</if>
            <if test="stdCountyOrgNo != null  and stdCountyOrgNo != ''"> and std_county_org_no = #{stdCountyOrgNo}</if>
            <if test="stdCountyOrgNm != null  and stdCountyOrgNm != ''"> and std_county_org_nm = #{stdCountyOrgNm}</if>
            <if test="dataDt != null  and dataDt != ''"> and data_dt = #{dataDt}</if>
            <if test="etlTm != null "> and etl_tm = #{etlTm}</if>
            <if test="stdCityOrgNo != null  and stdCityOrgNo != ''"> and std_city_org_no = #{stdCityOrgNo}</if>
            <if test="startPos != null  and startPos != ''"> and start_pos = #{startPos}</if>
            <if test="eqpMasterId != null  and eqpMasterId != ''"> and eqp_master_id = #{eqpMasterId}</if>
            <if test="eqpMasterNm != null  and eqpMasterNm != ''"> and eqp_master_nm = #{eqpMasterNm}</if>
            <if test="battalionId != null  and battalionId != ''"> and battalion_id = #{battalionId}</if>
            <if test="battalionNm != null  and battalionNm != ''"> and battalion_nm = #{battalionNm}</if>
            <if test="retrogresDt != null "> and retrogres_dt = #{retrogresDt}</if>
            <if test="createTm != null "> and create_tm = #{createTm}</if>
            <if test="latestUpdTm != null "> and latest_upd_tm = #{latestUpdTm}</if>
        </where>
    </select>

    <select id="selectPdmBranchLineById" parameterType="Long" resultMap="PdmBranchLineResult">
        <include refid="selectPdmBranchLineVo"/>
        where id = #{id}
    </select>

    <insert id="insertPdmBranchLine" parameterType="PdmBranchLine" useGeneratedKeys="true" keyProperty="id">
        insert into pdm_branch_line
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bigFeederBranchLineId != null">big_feeder_branch_line_id,</if>
            <if test="lineNm != null">line_nm,</if>
            <if test="eqpNo != null">eqp_no,</if>
            <if test="runNo != null">run_no,</if>
            <if test="blgBigFeederId != null">blg_big_feeder_id,</if>
            <if test="blgBigFeederNm != null">blg_big_feeder_nm,</if>
            <if test="voltLvlCd != null">volt_lvl_cd,</if>
            <if test="voltLvlDsc != null">volt_lvl_dsc,</if>
            <if test="erectModeCd != null">erect_mode_cd,</if>
            <if test="erectModeDsc != null">erect_mode_dsc,</if>
            <if test="overhdLineLen != null">overhd_line_len,</if>
            <if test="cableLineLen != null">cable_line_len,</if>
            <if test="lineTolLen != null">line_tol_len,</if>
            <if test="startEqpId != null">start_eqp_id,</if>
            <if test="startEqpNm != null">start_eqp_nm,</if>
            <if test="startEqpTypCd != null">start_eqp_typ_cd,</if>
            <if test="startEqpTypDsc != null">start_eqp_typ_dsc,</if>
            <if test="lineNatureCd != null">line_nature_cd,</if>
            <if test="lineNatureDsc != null">line_nature_dsc,</if>
            <if test="blgSuperLineId != null">blg_super_line_id,</if>
            <if test="blgSuperLineNm != null">blg_super_line_nm,</if>
            <if test="blgCityId != null">blg_city_id,</if>
            <if test="blgCityNm != null">blg_city_nm,</if>
            <if test="opMaintOrgId != null">op_maint_org_id,</if>
            <if test="opMaintOrgNm != null">op_maint_org_nm,</if>
            <if test="maintTeamId != null">maint_team_id,</if>
            <if test="maintTeamNm != null">maint_team_nm,</if>
            <if test="runStCd != null">run_st_cd,</if>
            <if test="runStDsc != null">run_st_dsc,</if>
            <if test="releaseStDsc != null">release_st_dsc,</if>
            <if test="repmaintLineLen != null">repmaint_line_len,</if>
            <if test="isHaveFigur != null">is_have_figur,</if>
            <if test="stdEqpMasterId != null">std_eqp_master_id,</if>
            <if test="stdEqpMasterNm != null">std_eqp_master_nm,</if>
            <if test="shipDt != null">ship_dt,</if>
            <if test="stdOrgNo != null">std_org_no,</if>
            <if test="stdOrgNm != null">std_org_nm,</if>
            <if test="stdCityOrgNm != null">std_city_org_nm,</if>
            <if test="stdCountyOrgNo != null">std_county_org_no,</if>
            <if test="stdCountyOrgNm != null">std_county_org_nm,</if>
            <if test="dataDt != null">data_dt,</if>
            <if test="etlTm != null">etl_tm,</if>
            <if test="stdCityOrgNo != null">std_city_org_no,</if>
            <if test="startPos != null">start_pos,</if>
            <if test="eqpMasterId != null">eqp_master_id,</if>
            <if test="eqpMasterNm != null">eqp_master_nm,</if>
            <if test="battalionId != null">battalion_id,</if>
            <if test="battalionNm != null">battalion_nm,</if>
            <if test="retrogresDt != null">retrogres_dt,</if>
            <if test="createTm != null">create_tm,</if>
            <if test="latestUpdTm != null">latest_upd_tm,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="bigFeederBranchLineId != null">#{bigFeederBranchLineId},</if>
            <if test="lineNm != null">#{lineNm},</if>
            <if test="eqpNo != null">#{eqpNo},</if>
            <if test="runNo != null">#{runNo},</if>
            <if test="blgBigFeederId != null">#{blgBigFeederId},</if>
            <if test="blgBigFeederNm != null">#{blgBigFeederNm},</if>
            <if test="voltLvlCd != null">#{voltLvlCd},</if>
            <if test="voltLvlDsc != null">#{voltLvlDsc},</if>
            <if test="erectModeCd != null">#{erectModeCd},</if>
            <if test="erectModeDsc != null">#{erectModeDsc},</if>
            <if test="overhdLineLen != null">#{overhdLineLen},</if>
            <if test="cableLineLen != null">#{cableLineLen},</if>
            <if test="lineTolLen != null">#{lineTolLen},</if>
            <if test="startEqpId != null">#{startEqpId},</if>
            <if test="startEqpNm != null">#{startEqpNm},</if>
            <if test="startEqpTypCd != null">#{startEqpTypCd},</if>
            <if test="startEqpTypDsc != null">#{startEqpTypDsc},</if>
            <if test="lineNatureCd != null">#{lineNatureCd},</if>
            <if test="lineNatureDsc != null">#{lineNatureDsc},</if>
            <if test="blgSuperLineId != null">#{blgSuperLineId},</if>
            <if test="blgSuperLineNm != null">#{blgSuperLineNm},</if>
            <if test="blgCityId != null">#{blgCityId},</if>
            <if test="blgCityNm != null">#{blgCityNm},</if>
            <if test="opMaintOrgId != null">#{opMaintOrgId},</if>
            <if test="opMaintOrgNm != null">#{opMaintOrgNm},</if>
            <if test="maintTeamId != null">#{maintTeamId},</if>
            <if test="maintTeamNm != null">#{maintTeamNm},</if>
            <if test="runStCd != null">#{runStCd},</if>
            <if test="runStDsc != null">#{runStDsc},</if>
            <if test="releaseStDsc != null">#{releaseStDsc},</if>
            <if test="repmaintLineLen != null">#{repmaintLineLen},</if>
            <if test="isHaveFigur != null">#{isHaveFigur},</if>
            <if test="stdEqpMasterId != null">#{stdEqpMasterId},</if>
            <if test="stdEqpMasterNm != null">#{stdEqpMasterNm},</if>
            <if test="shipDt != null">#{shipDt},</if>
            <if test="stdOrgNo != null">#{stdOrgNo},</if>
            <if test="stdOrgNm != null">#{stdOrgNm},</if>
            <if test="stdCityOrgNm != null">#{stdCityOrgNm},</if>
            <if test="stdCountyOrgNo != null">#{stdCountyOrgNo},</if>
            <if test="stdCountyOrgNm != null">#{stdCountyOrgNm},</if>
            <if test="dataDt != null">#{dataDt},</if>
            <if test="etlTm != null">#{etlTm},</if>
            <if test="stdCityOrgNo != null">#{stdCityOrgNo},</if>
            <if test="startPos != null">#{startPos},</if>
            <if test="eqpMasterId != null">#{eqpMasterId},</if>
            <if test="eqpMasterNm != null">#{eqpMasterNm},</if>
            <if test="battalionId != null">#{battalionId},</if>
            <if test="battalionNm != null">#{battalionNm},</if>
            <if test="retrogresDt != null">#{retrogresDt},</if>
            <if test="createTm != null">#{createTm},</if>
            <if test="latestUpdTm != null">#{latestUpdTm},</if>
         </trim>
    </insert>

    <update id="updatePdmBranchLine" parameterType="PdmBranchLine">
        update pdm_branch_line
        <trim prefix="SET" suffixOverrides=",">
            <if test="bigFeederBranchLineId != null">big_feeder_branch_line_id = #{bigFeederBranchLineId},</if>
            <if test="lineNm != null">line_nm = #{lineNm},</if>
            <if test="eqpNo != null">eqp_no = #{eqpNo},</if>
            <if test="runNo != null">run_no = #{runNo},</if>
            <if test="blgBigFeederId != null">blg_big_feeder_id = #{blgBigFeederId},</if>
            <if test="blgBigFeederNm != null">blg_big_feeder_nm = #{blgBigFeederNm},</if>
            <if test="voltLvlCd != null">volt_lvl_cd = #{voltLvlCd},</if>
            <if test="voltLvlDsc != null">volt_lvl_dsc = #{voltLvlDsc},</if>
            <if test="erectModeCd != null">erect_mode_cd = #{erectModeCd},</if>
            <if test="erectModeDsc != null">erect_mode_dsc = #{erectModeDsc},</if>
            <if test="overhdLineLen != null">overhd_line_len = #{overhdLineLen},</if>
            <if test="cableLineLen != null">cable_line_len = #{cableLineLen},</if>
            <if test="lineTolLen != null">line_tol_len = #{lineTolLen},</if>
            <if test="startEqpId != null">start_eqp_id = #{startEqpId},</if>
            <if test="startEqpNm != null">start_eqp_nm = #{startEqpNm},</if>
            <if test="startEqpTypCd != null">start_eqp_typ_cd = #{startEqpTypCd},</if>
            <if test="startEqpTypDsc != null">start_eqp_typ_dsc = #{startEqpTypDsc},</if>
            <if test="lineNatureCd != null">line_nature_cd = #{lineNatureCd},</if>
            <if test="lineNatureDsc != null">line_nature_dsc = #{lineNatureDsc},</if>
            <if test="blgSuperLineId != null">blg_super_line_id = #{blgSuperLineId},</if>
            <if test="blgSuperLineNm != null">blg_super_line_nm = #{blgSuperLineNm},</if>
            <if test="blgCityId != null">blg_city_id = #{blgCityId},</if>
            <if test="blgCityNm != null">blg_city_nm = #{blgCityNm},</if>
            <if test="opMaintOrgId != null">op_maint_org_id = #{opMaintOrgId},</if>
            <if test="opMaintOrgNm != null">op_maint_org_nm = #{opMaintOrgNm},</if>
            <if test="maintTeamId != null">maint_team_id = #{maintTeamId},</if>
            <if test="maintTeamNm != null">maint_team_nm = #{maintTeamNm},</if>
            <if test="runStCd != null">run_st_cd = #{runStCd},</if>
            <if test="runStDsc != null">run_st_dsc = #{runStDsc},</if>
            <if test="releaseStDsc != null">release_st_dsc = #{releaseStDsc},</if>
            <if test="repmaintLineLen != null">repmaint_line_len = #{repmaintLineLen},</if>
            <if test="isHaveFigur != null">is_have_figur = #{isHaveFigur},</if>
            <if test="stdEqpMasterId != null">std_eqp_master_id = #{stdEqpMasterId},</if>
            <if test="stdEqpMasterNm != null">std_eqp_master_nm = #{stdEqpMasterNm},</if>
            <if test="shipDt != null">ship_dt = #{shipDt},</if>
            <if test="stdOrgNo != null">std_org_no = #{stdOrgNo},</if>
            <if test="stdOrgNm != null">std_org_nm = #{stdOrgNm},</if>
            <if test="stdCityOrgNm != null">std_city_org_nm = #{stdCityOrgNm},</if>
            <if test="stdCountyOrgNo != null">std_county_org_no = #{stdCountyOrgNo},</if>
            <if test="stdCountyOrgNm != null">std_county_org_nm = #{stdCountyOrgNm},</if>
            <if test="dataDt != null">data_dt = #{dataDt},</if>
            <if test="etlTm != null">etl_tm = #{etlTm},</if>
            <if test="stdCityOrgNo != null">std_city_org_no = #{stdCityOrgNo},</if>
            <if test="startPos != null">start_pos = #{startPos},</if>
            <if test="eqpMasterId != null">eqp_master_id = #{eqpMasterId},</if>
            <if test="eqpMasterNm != null">eqp_master_nm = #{eqpMasterNm},</if>
            <if test="battalionId != null">battalion_id = #{battalionId},</if>
            <if test="battalionNm != null">battalion_nm = #{battalionNm},</if>
            <if test="retrogresDt != null">retrogres_dt = #{retrogresDt},</if>
            <if test="createTm != null">create_tm = #{createTm},</if>
            <if test="latestUpdTm != null">latest_upd_tm = #{latestUpdTm},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePdmBranchLineById" parameterType="Long">
        delete from pdm_branch_line where id = #{id}
    </delete>

    <delete id="deletePdmBranchLineByIds" parameterType="String">
        delete from pdm_branch_line where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="selectBranchLineCompleteList" parameterType="com.ruoyi.powerdistribution.domain.vo.PdmBranchLineComplete" resultType="com.ruoyi.powerdistribution.domain.vo.PdmBranchLineComplete">
        <include refid="selectPdmBranchLineVo"/>
        <where>
            <if test="lineNm != null  and lineNm != ''"> and line_nm like concat('%', #{lineNm}, '%')</if>
            <if test="eqpNo != null  and eqpNo != ''"> and eqp_no = #{eqpNo}</if>
            <if test="runNo != null  and runNo != ''"> and run_no = #{runNo}</if>
            <if test="blgBigFeederId != null  and blgBigFeederId != ''"> and blg_big_feeder_id = #{blgBigFeederId}</if>
            <if test="blgBigFeederNm != null  and blgBigFeederNm != ''"> and blg_big_feeder_nm = #{blgBigFeederNm}</if>
        </where>
    </select>
</mapper>
