Newer
Older
huludao / src / main / resources / mapper / RiverManage / BlackRiverMapper.xml
<?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.newfiber.api.pc.dao.RiverManage.BlackRiverMapper" >
   <resultMap id="blackRiver" type="com.newfiber.api.pc.model.River.BlackRiver">
     <id column="black_id" property="blackId"/>
     <result column="black_river_name" property="blackRiverName"/>
     <result column="black_type" property="blackType"/>
     <result column="black_river_start" property="blackRiverStart"/>
     <result column="black_river_end" property="blackRiverEnd"/>
     <result column="black_river_area" property="blackRiverArea"/>
     <result column="black_river_length" property="blackRiverLength"/>
     <result column="division" property="division"/>
     <result column="rivers_name" property="riversName"/>
     <result column="company" property="company"/>
     <result column="job" property="job"/>
     <result column="black_level" property="blackLevel"/>
     <result column="governance_state" property="governanceState"/>
     <result column="index_code" property="indexCode"/>
     <result column="status" property="status"/>
     <result column="site_no" property="siteNo"/>
     <result column="alarm_data_level1" property="alarmDataLevel1"/>
     <result column="alarm_data_level2" property="alarmDataLevel2"/>
     <result column="alarm_data_level3" property="alarmDataLevel3"/>
     <result column="watermeter" property="watermeter"/>
     <result column="lon" property="lon"/>
     <result column="lat" property="lat"/>
     <collection property="imageUrls" ofType="com.newfiber.api.pc.model.River.BlackRiverImageUrl">
        <id column="id" property="id"/>
       <result column="image_url" property="imageUrl"/>
       <result column="type" property="type"/>
       <result column="black_inner_id" property="blackInnerId"/>
     </collection>
   </resultMap>

    <resultMap id="oneMapInteraction" type="com.newfiber.api.pc.model.River.OneMapInteraction">
        <result property="soleNumber" column="sole_number"/>
        <result property="soleName" column="sole_name"/>
        <result property="lon" column="lon"/>
        <result property="lat" column="lat"/>
        <result property="status" column="status"/>
        <result property="commonNumber" column="common_number"/>
        <result property="indexCode" column="index_code"/>
        <result property="waterQualitySite" column="water_quality_site"/>
        <result property="waterLevelSite" column="water_level_site"/>

    </resultMap>



  <select id="selectAll" resultMap="blackRiver">
   select
      br.*,brsr.*,csr.`status`
    from
      xinyang_river.black_river br
			left join huludao_main.black_river_site_relevance brsr
			on br.black_id = brsr.black_id
      left join huludao_main.camera_resource csr on csr.index_code = brsr.index_code
  </select>


  <select id="queryPage" resultMap="blackRiver">
    select br.*,bri.* from
      (select
         *
       from
         black_river where 1 = 1
        <if test="riverName != null and riverName != ''">
          and black_river_name like concat('%',#{riverName},'%')
        </if>
        <if test="blackType != null and blackType != ''">
          and blackType = #{blackType}
        </if>
      LIMIT #{pageNo},#{pageSize}) br
        left join
      black_river_image_url bri
      on
        br.black_id = bri.black_inner_id
    order by br.black_id
  </select>

  <select id="queryCount" resultType="integer">
      select
        count(black_id)
      from
      black_river where 1 = 1
      <if test="riverName != null and riverName != ''">
        and black_river_name like concat('%',#{riverName},'%')
      </if>
      <if test="blackType != null and blackType != ''">
        and blackType = #{blackType}
      </if>
  </select>

    <select id="selectListData" resultType="com.newfiber.api.pc.model.River.RiverInfoData">
        select
        br.black_id,
        br.black_river_name,
        brs.water_site_no,
        brs.water_warn_level,
        brs.water_quality_site_no,
        brs.duty_user,
        brs.duty_user_phone
        from
        black_river br left join black_river_site brs on br.black_id = brs.black_id where br.black_id = brs.black_id
    </select>

    <select id="selectById" resultMap="blackRiver">
    select
      br.*,bri.*,brsr.*,csr.`status`
    from
      xinyang_river.black_river br
        LEFT JOIN
      xinyang_river.black_river_image_url bri
      on
        br.black_id = bri.black_inner_id
			left join huludao_main.black_river_site_relevance brsr
			on br.black_id = brsr.black_id
      left join huludao_main.camera_resource csr on csr.index_code = brsr.index_code
    where br.black_id = #{blackId}
   </select>

    <select id="oneMapBlackRiverInfo" resultMap="oneMapInteraction">
        select br.id as sole_number,black_river_name as sole_name,lon,lat,if(black_type = '河流',0,1) as status,brsr.black_id as common_number,
        brsr.site_no as water_level_site,brsr.watermeter as water_quality_site
        from black_river br
        left join huludao_main.black_river_site_relevance brsr on br.black_id = brsr.black_id
    </select>

</mapper>