From 486428358c6a2252a48630df300873cb4c71a93c Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Tue, 30 Jan 2018 22:37:45 +0800
Subject: [PATCH] updated

---
 src/main/resources/mapper/MonitorPointMapper.xml |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/src/main/resources/mapper/MonitorPointMapper.xml b/src/main/resources/mapper/MonitorPointMapper.xml
index bf0a5ee..652012a 100644
--- a/src/main/resources/mapper/MonitorPointMapper.xml
+++ b/src/main/resources/mapper/MonitorPointMapper.xml
@@ -20,7 +20,7 @@
 	  <result column="area_name" property="areaName" jdbcType="VARCHAR" />
     </association>
 	  <association property="organization" javaType="com.moral.entity.Organization">
-		  <result column="organization_id" property="id" jdbcType="VARCHAR" />
+		  <result column="organization_id" property="id" jdbcType="INTEGER" />
 		  <result column="organization_name" property="name" jdbcType="VARCHAR" />
 	  </association>
   </resultMap>
@@ -100,4 +100,38 @@
 			AND mp.city_code = c.city_code
 		</if>
 	</select>
+	<select id="selectWithStateByMap" parameterType="java.util.Map" resultMap="BaseResultMap">
+
+		SELECT mpt.*,MAX(dev.state) as state from monitor_point mpt
+		LEFT JOIN device dev on dev.monitor_point_id = mpt.id
+		<where>
+			<if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)">
+				mpt.organization_id = #{orgId,jdbcType=VARCHAR}
+			</if>
+			<![CDATA[
+			AND mpt.longitude < #{mapBounds.Ge,jdbcType=NUMERIC}
+            AND mpt.longitude > #{mapBounds.Le,jdbcType=NUMERIC}
+            AND mpt.latitude  < #{mapBounds.Fe,jdbcType=NUMERIC}
+            AND mpt.latitude  > #{mapBounds.Ke,jdbcType=NUMERIC}
+		    and state<4
+			GROUP BY mpt.`id`
+     		 ]]>
+		</where>
+		UNION
+		SELECT mpt.*,MAX(dev.state) as state from monitor_point mpt
+		LEFT JOIN device dev on dev.monitor_point_id = mpt.id
+		<where>
+			<if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)">
+				mpt.organization_id = #{orgId,jdbcType=VARCHAR}
+			</if>
+			<![CDATA[
+			AND mpt.longitude < #{mapBounds.Ge,jdbcType=NUMERIC}
+            AND mpt.longitude > #{mapBounds.Le,jdbcType=NUMERIC}
+            AND mpt.latitude  < #{mapBounds.Fe,jdbcType=NUMERIC}
+            AND mpt.latitude  > #{mapBounds.Ke,jdbcType=NUMERIC}
+		    and state>3
+			GROUP BY mpt.`id`
+            ]]>
+		</where>
+	</select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0