|  |  |  | 
|---|
|  |  |  | <select id="getRecordCountOfFlowMonitoring" resultType="java.lang.Integer"> | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCountOfFlowMonitoring | 
|---|
|  |  |  | from    pr_flow_monitoring pfm | 
|---|
|  |  |  | INNER JOIN ba_district country ON pfm.countyId = country.id | 
|---|
|  |  |  | INNER JOIN ba_district town ON pfm.townId = town.id | 
|---|
|  |  |  | INNER JOIN ba_district village ON pfm.villageId = village.id | 
|---|
|  |  |  | INNER JOIN pr_monitoring_flowmeter pmofl ON pmofl.monitoringId = pfm.id | 
|---|
|  |  |  | LEFT JOIN pr_flowmeter pf ON pf.monitoringId = pfm.id | 
|---|
|  |  |  | LEFT JOIN ba_district country ON pfm.countyId = country.id | 
|---|
|  |  |  | LEFT JOIN ba_district town ON pfm.townId = town.id | 
|---|
|  |  |  | LEFT JOIN ba_district village ON pfm.villageId = village.id | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | pfm.deleted = 0 | 
|---|
|  |  |  | <if test = "name != null and name !=''"> | 
|---|
|  |  |  | AND pfm.`name` like CONCAT('%',#{name},'%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test = "bindState != null and bindState > 0"> | 
|---|
|  |  |  | AND pmofl.operateType = ${bindState} | 
|---|
|  |  |  | <if test = "bindState ==1 "> | 
|---|
|  |  |  | AND pf.monitoringId IS NOT NULL | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test = "bindState ==2 or bindState =='' "> | 
|---|
|  |  |  | AND pf.monitoringId IS  NULL | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--根据指定条件获取流量监测站实体记录--> | 
|---|
|  |  |  | <select id="getPrFlowMonitoring" parameterType="map" resultType="com.dy.pipIrrGlobal.voPr.VoFlowMonitoring"> | 
|---|
|  |  |  | select  CAST(pfm.id AS char)                                 AS id, | 
|---|
|  |  |  | select  CAST(pfm.id AS char)                                AS id, | 
|---|
|  |  |  | CONCAT(country.`name`, town.`name`, village.`name`) AS address, | 
|---|
|  |  |  | pfm.`name`                                          AS `name`, | 
|---|
|  |  |  | pmofl.operateType                                   AS bindState | 
|---|
|  |  |  | (CASE | 
|---|
|  |  |  | WHEN pf.monitoringId IS NOT NULL THEN "已绑定" | 
|---|
|  |  |  | WHEN pf.monitoringId IS  NULL  THEN "未绑定" | 
|---|
|  |  |  | END)                                               AS bindState | 
|---|
|  |  |  | from    pr_flow_monitoring pfm | 
|---|
|  |  |  | INNER JOIN ba_district country ON pfm.countyId = country.id | 
|---|
|  |  |  | INNER JOIN ba_district town ON pfm.townId = town.id | 
|---|
|  |  |  | INNER JOIN ba_district village ON pfm.villageId = village.id | 
|---|
|  |  |  | INNER JOIN pr_monitoring_flowmeter pmofl ON pmofl.monitoringId = pfm.id | 
|---|
|  |  |  | LEFT JOIN pr_flowmeter pf ON pf.monitoringId = pfm.id | 
|---|
|  |  |  | LEFT JOIN ba_district country ON pfm.countyId = country.id | 
|---|
|  |  |  | LEFT JOIN ba_district town ON pfm.townId = town.id | 
|---|
|  |  |  | LEFT JOIN ba_district village ON pfm.villageId = village.id | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | pfm.deleted = 0 | 
|---|
|  |  |  | <if test = "name != null and name !=''"> | 
|---|
|  |  |  | AND pfm.`name` like CONCAT('%',#{name},'%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test = "bindState != null and bindState > 0"> | 
|---|
|  |  |  | AND pmofl.operateType = ${bindState} | 
|---|
|  |  |  | <if test = "bindState ==1 "> | 
|---|
|  |  |  | AND pf.monitoringId IS NOT NULL | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test = "bindState ==2 or bindState =='' "> | 
|---|
|  |  |  | AND pf.monitoringId IS  NULL | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | ORDER BY pmofl.operateDt DESC | 
|---|
|  |  |  | ORDER BY pfm.operateDt DESC | 
|---|
|  |  |  | <trim prefix="limit " > | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|