From 5fa78e073c5c6269997e7d03b56176b157c7a327 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Wed, 16 May 2018 16:21:30 +0800
Subject: [PATCH] 设备删除,更新redis

---
 src/main/resources/mapper/DeviceMapper.xml                  |    4 ++++
 src/main/java/com/moral/mapper/DeviceMapper.java            |    7 +++++++
 src/main/java/com/moral/service/impl/DeviceServiceImpl.java |   25 +++++++++++++++++++------
 src/main/resources/system/alarmLevels.json                  |    2 +-
 4 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/moral/mapper/DeviceMapper.java b/src/main/java/com/moral/mapper/DeviceMapper.java
index bf67ff6..afba196 100644
--- a/src/main/java/com/moral/mapper/DeviceMapper.java
+++ b/src/main/java/com/moral/mapper/DeviceMapper.java
@@ -20,6 +20,13 @@
 	List<Map<String, Object>> getDeviceVersionIdByMonitorPoint(Integer monitorPointId);
 
 	List<Device> selectByOrgIdAndDevName(@Param("orgId")Integer orgId,@Param("devName")String devName);
+
+	/**
+	 *
+	 * @param orgId
+	 * @param mpId
+	 * @return ���������������������
+	 */
 	List<Device> selectByOrgIdAndMpId(@Param("orgId")Integer orgId,@Param("mpId")Integer mpId);
 	List<Device> selectByMap(Map<String, Object> params);
 	Device selectWithOrgIdsByMac(String mac);
diff --git a/src/main/java/com/moral/service/impl/DeviceServiceImpl.java b/src/main/java/com/moral/service/impl/DeviceServiceImpl.java
index 53ef55d..a009a42 100644
--- a/src/main/java/com/moral/service/impl/DeviceServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -181,7 +181,7 @@
 	 *
 	 * @param map
 	 * map��� ������ ������id���4������������
-	 * @return
+	 * @return ������������������������
 	 */
 	@Override
 	public List<Device> query(Map<String, Object> map) {
@@ -196,7 +196,7 @@
 	 * @param deviceName
 	 * @param pageSize
 	 * @param pageNo
-	 * @return
+	 * @return ���������������������
 	 */
 	@Override
 	public PageResult query(Integer orgId, String deviceName, Integer pageSize, Integer pageNo) {
@@ -218,7 +218,7 @@
 	 * @param mpId
 	 * @param pageSize
 	 * @param pageNo
-	 * @return
+	 * @return ���������������������
 	 */
 	@Override
 	public PageResult query(Integer orgId, Integer mpId, Integer pageSize, Integer pageNo) {
@@ -332,15 +332,28 @@
 		Device device = new Device();
 		device.setIsDelete(Constants.IS_DELETE_TRUE);
 		if(ids!=null&&ids.length>0){
+			Example example = new Example(ENTITY_CLASS);
+			example.or().andIn("id", Arrays.asList(ids));
 			if(ids.length==1){
 				device.setId(ids[0]);
 				deviceMapper.updateByPrimaryKeySelective(device);
 			}else{
-				Example example = new Example(ENTITY_CLASS);
-				example.or().andIn("id", Arrays.asList(ids));
 				deviceMapper.updateByExampleSelective(device,example);
 			}
-
+			List<Device> deviceList = deviceMapper.selectByExample(example);
+			List<String> adjustAndDeviceKeys = deviceList.stream().collect(
+					ArrayList<String>::new,
+					(list,dev) -> {
+						if(!StringUtils.isBlank(dev.getMac())){
+							list.add("device_"+dev.getMac());
+							list.add("adjust_"+dev.getMac());
+						}
+					},
+					(oList,nList)-> {
+						oList.addAll(nList);
+					}
+			);
+			redisUtils.remove(adjustAndDeviceKeys.toArray(new String [adjustAndDeviceKeys.size()]));
 		}
 	}
 
diff --git a/src/main/resources/mapper/DeviceMapper.xml b/src/main/resources/mapper/DeviceMapper.xml
index 4905b25..2808a19 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">
diff --git a/src/main/resources/system/alarmLevels.json b/src/main/resources/system/alarmLevels.json
index 7f7aa3c..4d9dddd 100644
--- a/src/main/resources/system/alarmLevels.json
+++ b/src/main/resources/system/alarmLevels.json
@@ -72,7 +72,7 @@
       "increment": [
         25,
         30,
-        40
+        60
       ],
       "degressEnable": 0,
       "degression": [0,0,0]

--
Gitblit v1.8.0