<?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.railway.business.catenary.mapper.BusJcbJcxcMapper">

  <resultMap id="BaseResultMap" type="com.railway.business.catenary.domain.BusJcbJcxc">
    <result column="id" property="id"/>
    <result column="xc_id" property="xcId"/>
    <result column="dept_id" property="deptId"/>
    <result column="dept_name" property="deptName"/>
    <result column="station_id" property="stationId"/>
    <result column="station_name" property="stationName"/>
    <result column="dept_station_id" property="deptStationId"/>
    <result column="pillar_code" property="pillarCode"/>
    <result column="xch" property="xch"/>
    <result column="temperature" property="temperature"/>
    <result column="check_date" property="checkDate"/>
    <result column="gz1lcz" property="gz1lcz"/>
    <result column="gz2lcz" property="gz2lcz"/>
    <result column="fzlcz" property="fzlcz"/>
    <result column="zglcz" property="zglcz"/>
    <result column="qglcz" property="qglcz"/>
    <result column="ngj" property="ngj"/>
    <result column="plz" property="plz"/>
    <result column="xcxzgazlg" property="xcxzgazlg"/>
    <result column="xcxzgazlg_gzms" property="xcxzgazlgGzms"/>
    <result column="hdjx" property="hdjx"/>
    <result column="hdjx_gzms" property="hdjxGzms"/>
    <result column="fhzzsq" property="fhzzsq"/>
    <result column="fhzzsq_gzms" property="fhzzsqGzms"/>
    <result column="dqssxx" property="dqssxx"/>
    <result column="dqssxx_gzms" property="dqssxxGzms"/>
    <result column="lswst" property="lswst"/>
    <result column="lswst_gzms" property="lswstGzms"/>
    <result column="xzgldydx" property="xzgldydx"/>
    <result column="xzgldydx_gzms" property="xzgldydxGzms"/>
    <result column="dxztlh" property="dxztlh"/>
    <result column="dxztlh_gzms" property="dxztlhGzms"/>
    <result column="czjj" property="czjj"/>
    <result column="lgzzgc" property="lgzzgc"/>
    <result column="gzyfzgc" property="gzyfzgc"/>
    <result column="wxj" property="wxj"/>
    <result column="wxj_gzms" property="wxjGzms"/>
    <result column="hddxxjzt" property="hddxxjzt"/>
    <result column="hddxxjzt_gzms" property="hddxxjztGzms"/>
    <result column="jcdxzt" property="jcdxzt"/>
    <result column="jcdxzt_gzms" property="jcdxztGzms"/>
    <result column="dljxzt" property="dljxzt"/>
    <result column="dljxzt_gzms" property="dljxztGzms"/>
    <result column="sbzt" property="sbzt"/>
    <result column="check_user" property="checkUser"/>
    <result column="confirm_user" property="confirmUser"/>
    <result column="czwt" property="czwt"/>
    <result column="submit_state" property="submitState"/>
    <result column="create_by" property="createBy"/>
    <result column="create_time" property="createTime"/>
    <result column="update_by" property="updateBy"/>
    <result column="update_time" property="updateTime"/>
    <result column="user_id" property="userId"/>
  </resultMap>

  <sql id="Base_Column_List">
    t.id,
    t.xc_id,
    v.dept_id,
    v.dept_name,
    v.station_name,
    v.station_id,
    t.dept_station_id,
    t.pillar_code,
    t.xch,
    t.temperature,
    t.check_date,
    t.gz1lcz,
    t.gz2lcz,
    t.fzlcz,
    t.zglcz,
    t.qglcz,
    t.ngj,
    t.plz,
    t.xcxzgazlg,
    t.xcxzgazlg_gzms,
    t.hdjx,
    t.hdjx_gzms,
    t.fhzzsq,
    t.fhzzsq_gzms,
    t.dqssxx,
    t.dqssxx_gzms,
    t.lswst,
    t.lswst_gzms,
    t.xzgldydx,
    t.xzgldydx_gzms,
    t.dxztlh,
    t.dxztlh_gzms,
    t.czjj,
    t.lgzzgc,
    t.gzyfzgc,
    t.wxj,
    t.wxj_gzms,
    t.hddxxjzt,
    t.hddxxjzt_gzms,
    t.jcdxzt,
    t.jcdxzt_gzms,
    t.dljxzt,
    t.dljxzt_gzms,
    t.sbzt,
    t.check_user,
    t.confirm_user,
    t.czwt,
    t.submit_state,
    t.create_by,
    t.create_time,
    t.update_by,
    t.update_time,
    t.user_id
  </sql>

  <insert id="insert" parameterType="com.railway.business.catenary.domain.BusJcbJcxc">
    INSERT INTO bus_jcb_jcxc
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test='null != deptStationId'>
        dept_station_id,
      </if>
      <if test='null != pillarCode'>
        pillar_code,
      </if>
      <if test='null != xcId'>
        xc_id,
      </if>
      <if test='null != xch'>
        xch,
      </if>
      <if test='null != temperature'>
        temperature,
      </if>
      <if test='null != checkDate'>
        check_date,
      </if>
      <if test='null != gz1lcz'>
        gz1lcz,
      </if>
      <if test='null != gz2lcz'>
        gz2lcz,
      </if>
      <if test='null != fzlcz'>
        fzlcz,
      </if>
      <if test='null != zglcz'>
        zglcz,
      </if>
      <if test='null != qglcz'>
        qglcz,
      </if>
      <if test='null != ngj'>
        ngj,
      </if>
      <if test='null != plz'>
        plz,
      </if>
      <if test='null != xcxzgazlg'>
        xcxzgazlg,
      </if>
      <if test='null != xcxzgazlgGzms'>
        xcxzgazlg_gzms,
      </if>
      <if test='null != hdjx'>
        hdjx,
      </if>
      <if test='null != hdjxGzms'>
        hdjx_gzms,
      </if>
      <if test='null != fhzzsq'>
        fhzzsq,
      </if>
      <if test='null != fhzzsqGzms'>
        fhzzsq_gzms,
      </if>
      <if test='null != dqssxx'>
        dqssxx,
      </if>
      <if test='null != dqssxxGzms'>
        dqssxx_gzms,
      </if>
      <if test='null != lswst'>
        lswst,
      </if>
      <if test='null != lswstGzms'>
        lswst_gzms,
      </if>
      <if test='null != xzgldydx'>
        xzgldydx,
      </if>
      <if test='null != xzgldydxGzms'>
        xzgldydx_gzms,
      </if>
      <if test='null != dxztlh'>
        dxztlh,
      </if>
      <if test='null != dxztlhGzms'>
        dxztlh_gzms,
      </if>
      <if test='null != czjj'>
        czjj,
      </if>
      <if test='null != lgzzgc'>
        lgzzgc,
      </if>
      <if test='null != gzyfzgc'>
        gzyfzgc,
      </if>
      <if test='null != wxj'>
        wxj,
      </if>
      <if test='null != wxjGzms'>
        wxj_gzms,
      </if>
      <if test='null != hddxxjzt'>
        hddxxjzt,
      </if>
      <if test='null != hddxxjztGzms'>
        hddxxjzt_gzms,
      </if>
      <if test='null != jcdxzt'>
        jcdxzt,
      </if>
      <if test='null != jcdxztGzms'>
        jcdxzt_gzms,
      </if>
      <if test='null != dljxzt'>
        dljxzt,
      </if>
      <if test='null != dljxztGzms'>
        dljxzt_gzms,
      </if>
      <if test='null != sbzt'>
        sbzt,
      </if>
      <if test='null != checkUser'>
        check_user,
      </if>
      <if test='null != czwt'>
        czwt,
      </if>
      <if test='null != submitState'>
        submit_state,
      </if>
      <if test='null != createBy'>
        create_by,
      </if>
      <if test='null != createTime'>
        create_time,
      </if>
      <if test='null != updateBy'>
        update_by,
      </if>
      <if test='null != updateTime'>
        update_time,
      </if>
      <if test='null != userId'>
        user_id
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test='null != deptStationId'>
        #{deptStationId},
      </if>
      <if test='null != pillarCode'>
        #{pillarCode},
      </if>
      <if test='null != xcId'>
        #{xcId},
      </if>
      <if test='null != xch'>
        #{xch},
      </if>
      <if test='null != temperature'>
        #{temperature},
      </if>
      <if test='null != checkDate'>
        #{checkDate},
      </if>
      <if test='null != gz1lcz'>
        #{gz1lcz},
      </if>
      <if test='null != gz2lcz'>
        #{gz2lcz},
      </if>
      <if test='null != fzlcz'>
        #{fzlcz},
      </if>
      <if test='null != zglcz'>
        #{zglcz},
      </if>
      <if test='null != qglcz'>
        #{qglcz},
      </if>
      <if test='null != ngj'>
        #{ngj},
      </if>
      <if test='null != plz'>
        #{plz},
      </if>
      <if test='null != xcxzgazlg'>
        #{xcxzgazlg},
      </if>
      <if test='null != xcxzgazlgGzms'>
        #{xcxzgazlgGzms},
      </if>
      <if test='null != hdjx'>
        #{hdjx},
      </if>
      <if test='null != hdjxGzms'>
        #{hdjxGzms},
      </if>
      <if test='null != fhzzsq'>
        #{fhzzsq},
      </if>
      <if test='null != fhzzsqGzms'>
        #{fhzzsqGzms},
      </if>
      <if test='null != dqssxx'>
        #{dqssxx},
      </if>
      <if test='null != dqssxxGzms'>
        #{dqssxxGzms},
      </if>
      <if test='null != lswst'>
        #{lswst},
      </if>
      <if test='null != lswstGzms'>
        #{lswstGzms},
      </if>
      <if test='null != xzgldydx'>
        #{xzgldydx},
      </if>
      <if test='null != xzgldydxGzms'>
        #{xzgldydxGzms},
      </if>
      <if test='null != dxztlh'>
        #{dxztlh},
      </if>
      <if test='null != dxztlhGzms'>
        #{dxztlhGzms},
      </if>
      <if test='null != czjj'>
        #{czjj},
      </if>
      <if test='null != lgzzgc'>
        #{lgzzgc},
      </if>
      <if test='null != gzyfzgc'>
        #{gzyfzgc},
      </if>
      <if test='null != wxj'>
        #{wxj},
      </if>
      <if test='null != wxjGzms'>
        #{wxjGzms},
      </if>
      <if test='null != hddxxjzt'>
        #{hddxxjzt},
      </if>
      <if test='null != hddxxjztGzms'>
        #{hddxxjztGzms},
      </if>
      <if test='null != jcdxzt'>
        #{jcdxzt},
      </if>
      <if test='null != jcdxztGzms'>
        #{jcdxztGzms},
      </if>
      <if test='null != dljxzt'>
        #{dljxzt},
      </if>
      <if test='null != dljxztGzms'>
        #{dljxztGzms},
      </if>
      <if test='null != sbzt'>
        #{sbzt},
      </if>
      <if test='null != checkUser'>
        #{checkUser},
      </if>
      <if test='null != czwt'>
        #{czwt},
      </if>
      <if test='null != submitState'>
        #{submitState},
      </if>
      <if test='null != createBy'>
        #{createBy},
      </if>
      <if test='null != createTime'>
        #{createTime},
      </if>
      <if test='null != updateBy'>
        #{updateBy},
      </if>
      <if test='null != updateTime'>
        #{updateTime},
      </if>
      <if test='null != userId'>
        #{userId}
      </if>
    </trim>
  </insert>

  <delete id="delete">
    UPDATE bus_jcb_jcxc
    set del_flag='1'
    WHERE id = #{id}
  </delete>

  <update id="update" parameterType="com.railway.business.catenary.domain.BusJcbJcxc">
    UPDATE bus_jcb_jcxc
    <set>
      <if test='null != deptStationId'>dept_station_id = #{deptStationId},</if>
      <if test='null != pillarCode'>pillar_code = #{pillarCode},</if>
      <if test='null != xch'>xc_id = #{xcId},</if>
      <if test='null != xch'>xch = #{xch},</if>
      <if test='null != temperature'>temperature = #{temperature},</if>
      <if test='null != checkDate'>check_date = #{checkDate},</if>
      <if test='null != gz1lcz'>gz1lcz = #{gz1lcz},</if>
      <if test='null != gz2lcz'>gz2lcz = #{gz2lcz},</if>
      <if test='null != gz2lcz'>fzlcz = #{fzlcz},</if>
      <if test='null != zglcz'>zglcz = #{zglcz},</if>
      <if test='null != qglcz'>qglcz = #{qglcz},</if>
      <if test='null != ngj'>ngj = #{ngj},</if>
      <if test='null != plz'>plz = #{plz},</if>
      <if test='null != xcxzgazlg'>xcxzgazlg = #{xcxzgazlg},</if>
      <if test='null != xcxzgazlgGzms'>xcxzgazlg_gzms = #{xcxzgazlgGzms},</if>
      <if test='null != hdjx'>hdjx = #{hdjx},</if>
      <if test='null != hdjxGzms'>hdjx_gzms = #{hdjxGzms},</if>
      <if test='null != fhzzsq'>fhzzsq = #{fhzzsq},</if>
      <if test='null != fhzzsqGzms'>fhzzsq_gzms = #{fhzzsqGzms},</if>
      <if test='null != dqssxx'>dqssxx = #{dqssxx},</if>
      <if test='null != dqssxxGzms'>dqssxx_gzms = #{dqssxxGzms},</if>
      <if test='null != lswst'>lswst = #{lswst},</if>
      <if test='null != lswstGzms'>lswst_gzms = #{lswstGzms},</if>
      <if test='null != xzgldydx'>xzgldydx = #{xzgldydx},</if>
      <if test='null != xzgldydxGzms'>xzgldydx_gzms = #{xzgldydxGzms},</if>
      <if test='null != dxztlh'>dxztlh = #{dxztlh},</if>
      <if test='null != dxztlhGzms'>dxztlh_gzms = #{dxztlhGzms},</if>
      <if test='null != czjj'>czjj = #{czjj},</if>
      <if test='null != lgzzgc'>lgzzgc = #{lgzzgc},</if>
      <if test='null != gzyfzgc'>gzyfzgc = #{gzyfzgc},</if>
      <if test='null != wxj'>wxj = #{wxj},</if>
      <if test='null != wxjGzms'>wxj_gzms = #{wxjGzms},</if>
      <if test='null != hddxxjzt'>hddxxjzt = #{hddxxjzt},</if>
      <if test='null != hddxxjztGzms'>hddxxjzt_gzms = #{hddxxjztGzms},</if>
      <if test='null != jcdxzt'>jcdxzt = #{jcdxzt},</if>
      <if test='null != jcdxztGzms'>jcdxzt_gzms = #{jcdxztGzms},</if>
      <if test='null != dljxzt'>dljxzt = #{dljxzt},</if>
      <if test='null != dljxztGzms'>dljxzt_gzms = #{dljxztGzms},</if>
      <if test='null != sbzt'>sbzt = #{sbzt},</if>
      <if test='null != checkUser'>check_user = #{checkUser},</if>
      <if test='null != czwt'>czwt = #{czwt},</if>
      <if test='null != submitState'>submit_state = #{submitState},</if>
      <if test='null != updateBy'>update_by = #{updateBy},</if>
      <if test='null != updateTime'>update_time = #{updateTime},</if>
      <if test='null != userId'>user_id = #{userId}</if>
    </set>
    WHERE id = #{id}
  </update>


  <select id="getInfo" resultMap="BaseResultMap">
    SELECT
    <include refid="Base_Column_List"/>
    FROM bus_jcb_jcxc t
    LEFT JOIN v_station v on t.dept_station_id = v.dept_station_id
    WHERE t.del_flag='0' and t.id = #{id}

  </select>

  <select id="getLastRecord" resultMap="BaseResultMap">
    SELECT
    a.gz1lcz, a.gz2lcz, a.fzlcz, a.zglcz, a.qglcz, a.ngj, a.plz, a.czjj, a.lgzzgc, a.gzyfzgc
    FROM bus_jcb_jcxc a,
    (
    select max(update_time) as lastTime
    from bus_jcb_jcxc
    WHERE user_id = #{user_id}
    and submit_state != '0'
    ) b
    WHERE a.update_time = b.lastTime

  </select>

  <select id="getList" resultMap="BaseResultMap">
    SELECT
    <include refid="Base_Column_List"/>
    FROM bus_jcb_jcxc t
    LEFT JOIN v_station v on t.dept_station_id = v.dept_station_id
    <where>
      t.del_flag='0'
      <if test="deptId!=null and deptId!=''">
        and v.dept_id=#{deptId}
      </if>
      <if test="stationId!=null and stationId!=''">
        and v.station_id=#{stationId}
      </if>
      <if test="stationIds!=null and stationIds.length > 0">
        and v.station_id in
        <foreach collection="stationIds" item="stationId" index="i" open="(" separator="," close=")">
          #{stationId}
        </foreach>
      </if>
      <if test="pillarCode!=null and pillarCode!=''">
        and t.pillar_code=#{pillarCode}
      </if>
      <if test="xch!=null and xch!=''">
        and t.xch=#{xch}
      </if>
      <if test="temperature!=null and temperature!=''">
        and t.temperature=#{temperature}
      </if>
      <if test="checkDate!=null">
        and t.check_date=#{checkDate}
      </if>
      <if test="gz1lcz!=null and gz1lcz!=''">
        and t.gz1lcz=#{gz1lcz}
      </if>
      <if test="gz2lcz!=null and gz2lcz!=''">
        and t.gz2lcz=#{gz2lcz}
      </if>
      <if test="fzlcz!=null and fzlcz!=''">
        and t.fzlcz=#{fzlcz}
      </if>
      <if test="zglcz!=null and zglcz!=''">
        and t.zglcz=#{zglcz}
      </if>
      <if test="qglcz!=null and qglcz!=''">
        and t.qglcz=#{qglcz}
      </if>
      <if test="ngj!=null and ngj!=''">
        and t.ngj=#{ngj}
      </if>
      <if test="plz!=null and plz!=''">
        and t.plz=#{plz}
      </if>
      <if test="xcxzgazlg!=null and xcxzgazlg!=''">
        and t.xcxzgazlg=#{xcxzgazlg}
      </if>
      <if test="xcxzgazlgGzms!=null and xcxzgazlgGzms!=''">
        and t.xcxzgazlg_gzms=#{xcxzgazlgGzms}
      </if>
      <if test="hdjx!=null and hdjx!=''">
        and t.hdjx=#{hdjx}
      </if>
      <if test="hdjxGzms!=null and hdjxGzms!=''">
        and t.hdjx_gzms=#{hdjxGzms}
      </if>
      <if test="fhzzsq!=null and fhzzsq!=''">
        and t.fhzzsq=#{fhzzsq}
      </if>
      <if test="fhzzsqGzms!=null and fhzzsqGzms!=''">
        and t.fhzzsq_gzms=#{fhzzsqGzms}
      </if>
      <if test="dqssxx!=null and dqssxx!=''">
        and t.dqssxx=#{dqssxx}
      </if>
      <if test="dqssxxGzms!=null and dqssxxGzms!=''">
        and t.dqssxx_gzms=#{dqssxxGzms}
      </if>
      <if test="lswst!=null and lswst!=''">
        and t.lswst=#{lswst}
      </if>
      <if test="lswstGzms!=null and lswstGzms!=''">
        and t.lswst_gzms=#{lswstGzms}
      </if>
      <if test="xzgldydx!=null and xzgldydx!=''">
        and t.xzgldydx=#{xzgldydx}
      </if>
      <if test="xzgldydxGzms!=null and xzgldydxGzms!=''">
        and t.xzgldydx_gzms=#{xzgldydxGzms}
      </if>
      <if test="dxztlh!=null and dxztlh!=''">
        and t.dxztlh=#{dxztlh}
      </if>
      <if test="dxztlhGzms!=null and dxztlhGzms!=''">
        and t.dxztlh_gzms=#{dxztlhGzms}
      </if>
      <if test="czjj!=null and czjj!=''">
        and t.czjj=#{czjj}
      </if>
      <if test="lgzzgc!=null and lgzzgc!=''">
        and t.lgzzgc=#{lgzzgc}
      </if>
      <if test="gzyfzgc!=null and gzyfzgc!=''">
        and t.gzyfzgc=#{gzyfzgc}
      </if>
      <if test="wxj!=null and wxj!=''">
        and t.wxj=#{wxj}
      </if>
      <if test="wxjGzms!=null and wxjGzms!=''">
        and t.wxj_gzms=#{wxjGzms}
      </if>
      <if test="hddxxjzt!=null and hddxxjzt!=''">
        and t.hddxxjzt=#{hddxxjzt}
      </if>
      <if test="hddxxjztGzms!=null and hddxxjztGzms!=''">
        and t.hddxxjzt_gzms=#{hddxxjztGzms}
      </if>
      <if test="jcdxzt!=null and jcdxzt!=''">
        and t.jcdxzt=#{jcdxzt}
      </if>
      <if test="jcdxztGzms!=null and jcdxztGzms!=''">
        and t.jcdxzt_gzms=#{jcdxztGzms}
      </if>
      <if test="dljxzt!=null and dljxzt!=''">
        and t.dljxzt=#{dljxzt}
      </if>
      <if test="dljxztGzms!=null and dljxztGzms!=''">
        and t.dljxzt_gzms=#{dljxztGzms}
      </if>
      <if test="sbzt!=null and sbzt!=''">
        and t.sbzt=#{sbzt}
      </if>
      <if test="checkUser!=null and checkUser!=''">
        and t.check_user like concat('%', #{checkUser}, '%')
      </if>
      <if test="czwt!=null and czwt!=''">
        and t.czwt=#{czwt}
      </if>
      <if test="submitState!=null and submitState!=''">
        and t.submit_state <![CDATA[ >= ]]> #{submitState}
      </if>
      <if test="createBy!=null and createBy!=''">
        and t.create_by=#{createBy}
      </if>
      <if test="createTime!=null">
        and DATE_FORMAT(t.create_time, '%Y-%m-%d') = #{createTime}
      </if>
      <if test="updateBy!=null and updateBy!=''">
        and t.update_by=#{updateBy}
      </if>
      <if test="updateTime!=null">
        and DATE_FORMAT(t.update_time, '%Y-%m-%d') = #{updateTime}
      </if>
      <if test="userId!=null and userId!=''">
        and t.user_id=#{userId}
      </if>
    </where>
    <if test="orderBy!=null and orderBy!=''">
      order by t.${orderBy}
    </if>
    <if test="isAsc!=null and isAsc!=''">
      <if test="isAsc == '1'.toString()">
        asc
      </if>
      <if test="isAsc == '0'.toString()">
        desc
      </if>
    </if>
  </select>

  <select id="getJcebList" resultMap="BaseResultMap">
    SELECT
    <include refid="Base_Column_List"/>
    FROM bus_jcb_jcxc t
    LEFT JOIN v_station v on t.dept_station_id = v.dept_station_id
    <where>
      t.del_flag='0'
      <if test="submitState!=null and submitState!=''">
        and t.submit_state <![CDATA[ >= ]]> #{submitState}
      </if>
      <if test="deptId!=null and deptId!=''">
        and v.dept_id=#{deptId}
      </if>
      <if test="stationId!=null and stationId!=''">
        and v.station_id=#{stationId}
      </if>
      <if test="stationIds!=null and stationIds.length > 0">
        and v.station_id in
        <foreach collection="stationIds" item="stationId" index="i" open="(" separator="," close=")">
          #{stationId}
        </foreach>
      </if>
      <if test="pillarCode!=null and pillarCode!=''">
        and t.pillar_code=#{pillarCode}
      </if>
      <if test="operator!=null and operator!=''">
        and t.check_user like concat('%', #{operator}, '%')
      </if>
      <if test="createBy!=null and createBy!=''">
        and t.create_by=#{createBy}
      </if>
      <if test="operationDate!=null">
        and t.check_date=#{operationDate}
      </if>
    </where>
  </select>

  <resultMap id="JcabResultMap" type="com.railway.business.catenary.domain.vo.JcebRecordVo">
    <result column="id" property="id"/>
    <result column="dept_name" property="deptName"/>
    <result column="station_name" property="stationName"/>
    <result column="check_date" property="operationDate"/>
    <result column="check_user" property="operator"/>
    <result column="jcebType" property="jcebType"/>
  </resultMap>

  <select id="getListByType" resultMap="JcabResultMap">
    SELECT t.id, v.dept_name, v.station_name, t.check_date, t.check_user, #{jcebType} as jcebType
    FROM bus_jcb_jcxc t
    LEFT JOIN v_station v on t.dept_station_id = v.dept_station_id
    <where>
      t.del_flag='0'
      <if test="submitState!=null and submitState!=''">
        and t.submit_state <![CDATA[ >= ]]> #{submitState}
      </if>
      <if test="deptId!=null and deptId!=''">
        and v.dept_id=#{deptId}
      </if>
      <if test="stationId!=null and stationId!=''">
        and v.station_id=#{stationId}
      </if>
      <if test="stationIds!=null and stationIds.length > 0">
        and v.station_id in
        <foreach collection="stationIds" item="stationId" index="i" open="(" separator="," close=")">
          #{stationId}
        </foreach>
      </if>
      <if test="pillarCode!=null and pillarCode!=''">
        and t.pillar_code=#{pillarCode}
      </if>
      <if test="operator!=null and operator!=''">
        and t.check_user like concat('%', #{operator}, '%')
      </if>
      <if test="createBy!=null and createBy!=''">
        and t.create_by=#{createBy}
      </if>
      <if test="operationDate!=null">
        and t.check_date=#{operationDate}
      </if>
    </where>
  </select>

  <resultMap id="JcabCountResultMap" type="com.railway.business.catenary.domain.vo.JcebCountVo">
    <result column="c" property="count"/>
    <result column="check_date" property="operationDate"/>
  </resultMap>

  <select id="getCountByType" resultMap="JcabCountResultMap">
    SELECT count(*) c, max(t.check_date) as check_date
    FROM bus_jcb_jcxc t
    LEFT JOIN v_station v on t.dept_station_id = v.dept_station_id
    <where>
      t.del_flag='0'
      <if test="submitState!=null and submitState!=''">
        and t.submit_state <![CDATA[ >= ]]> #{submitState}
      </if>
      <if test="deptId!=null and deptId!=''">
        and v.dept_id=#{deptId}
      </if>
      <if test="stationId!=null and stationId!=''">
        and v.station_id=#{stationId}
      </if>
      <if test="pillarCode!=null and pillarCode!=''">
        and t.pillar_code=#{pillarCode}
      </if>
      <if test="operator!=null and operator!=''">
        and t.check_user like concat('%', #{operator}, '%')
      </if>
      <if test="createBy!=null and createBy!=''">
        and t.create_by=#{createBy}
      </if>
      <if test="operationDate!=null">
        and t.check_date=#{operationDate}
      </if>
    </where>
  </select>

  <resultMap id="JcabStationMap" type="com.railway.business.catenary.domain.vo.JcebStationVo">
    <result column="station_name" property="stationName"/>
    <result column="station_id" property="stationId"/>
  </resultMap>

  <select id="listStation" resultMap="JcabStationMap">
    SELECT distinct v.station_id, v.station_name
    FROM base_jcxc t
    LEFT JOIN v_station v on t.dept_station_id = v.dept_station_id
    <where>
      t.del_flag='0' and t.xclx = 'jcxc'
      <if test="deptId!=null and deptId!=''">
        and v.dept_id=#{deptId}
      </if>
    </where>
  </select>

</mapper>