From 7486f185f3a48b75f163a99ecd7546b525018dd0 Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Thu, 17 May 2018 10:03:48 +0800
Subject: [PATCH] 行业 优化

---
 src/main/resources/mapper/DeviceMapper.xml |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/DeviceMapper.xml b/src/main/resources/mapper/DeviceMapper.xml
index 795e325..be3deb8 100644
--- a/src/main/resources/mapper/DeviceMapper.xml
+++ b/src/main/resources/mapper/DeviceMapper.xml
@@ -177,6 +177,7 @@
 		<if test="devName!=null and ''!=devName">
 			and dev.name like CONCAT('%',#{devName},'%')
 		</if>
+			and dev.is_delete = 0
 		</where>
 	</select>
 	<select id="selectByOrgIdAndMpId" resultMap="BaseResultMap">
@@ -188,6 +189,7 @@
 				mpt.organization_id =  #{orgId}
 			</if>
 			and dev.monitor_point_id = #{mpId}
+			and dev.is_delete = 0
 		</where>
 	</select>
 	<select id="selectByMap" parameterType="java.util.Map" resultMap="BaseResultMap">
@@ -204,6 +206,7 @@
             AND dev.latitude  < #{mapBounds.Fe,jdbcType=NUMERIC}
             AND dev.latitude  > #{mapBounds.Ke,jdbcType=NUMERIC}
      		 ]]>
+			AND dev.is_delete =0
 		</where>
 	</select>
 	<resultMap id="BaseResultWithOrgIdsMap" type="com.moral.entity.Device" extends="BaseResultMap">
@@ -222,6 +225,7 @@
         left join monitor_point  mpt on dev.monitor_point_id = mpt.id
         left join profession  pro on pro.id = dev.profession_id
 		where dev.mac = #{mac,jdbcType=VARCHAR}
+		limit 0,1
 	</select>
 
 	<select id="getDeviceCountByRegion" resultType="java.lang.Integer">
@@ -248,5 +252,40 @@
 					AND mp.area_code = #{areaCode}
 					</if>
 			)
+			<if test="professionId != null">
+			AND d.profession_id = #{professionId}
+			</if>
+	</select>
+
+	<select id="getDevicesByProfession" resultType="com.moral.entity.Device">
+		SELECT
+			* 
+		FROM
+			device d 
+		WHERE
+			d.is_delete = 0 
+			AND d.monitor_point_id IN (
+				SELECT
+					mp.id 
+				FROM
+					monitor_point mp 
+				WHERE
+					mp.is_delete = 0 
+					<if test="provinceCode != null">
+					AND mp.province_code = #{provinceCode}
+					</if>
+					<if test="cityCode != null">
+					AND mp.city_code = #{cityCode}
+					</if>
+					<if test="areaCode != null">
+					AND mp.area_code = #{areaCode}
+					</if>
+					<if test="monitorPointId != null">
+					AND mp.id = #{monitorPointId}
+					</if>
+			)
+			<if test="professionId != null">
+			AND d.profession_id = #{professionId}
+			</if>
 	</select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0