From fa365e1770746e272b3bdb623d29285e3e34def7 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期五, 15 三月 2019 11:09:12 +0800
Subject: [PATCH] 推送优化

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java |  134 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 101 insertions(+), 33 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
index 4d914e2..0f89c07 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
@@ -1,6 +1,7 @@
 package com.yeshi.fanli.controller.admin;
 
 import java.io.PrintWriter;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -110,24 +111,41 @@
 
 		try {
 			
-			String[] uidArray = null;
-			if (uids != null) {
-				uidArray = uids.split(",");
+			List<String> listuid = null;
+			if (uids != null && uids.trim().length() > 0) {
+				listuid = Arrays.asList(uids.split(","));
+				if (listuid == null || listuid.size() == 0) {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛id鏍煎紡涓嶆纭�"));
+					return;
+				}
 			}
 			
 			
 			List<String> listVersion = null;
 			if (versions != null && versions.trim().length() > 0) {
-				listVersion  = Arrays.asList(versions.split(","));
+				List<String> list = Arrays.asList(versions.split(","));
+				
+				if (list != null && list.size() > 0) {
+					listVersion = new ArrayList<String>();
+					for (String version: list) {
+						if (version != null && version.trim().length() > 0) {
+							listVersion.add(version.trim());
+						}
+					}
+				}
+				
+				if (listVersion == null || listVersion.size() == 0) {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐗堟湰鍙锋牸寮忎笉姝g‘"));
+					return;
+				}
 			}
 			
-			if (uidArray == null) {
+			if (listuid == null) {
 				// 鍏ㄦ帹
 				pushService.pushGoods(null, title, content, url, listVersion);
 			} else {
 				// 閮ㄥ垎鐢ㄦ埛鎺ㄩ��
-				for (int i = 0; i < uidArray.length; i++) {
-					String str_uid = uidArray[i];
+				for (String str_uid: listuid) {
 					if (str_uid != null && str_uid.trim().length() > 0) {
 						pushService.pushGoods(Long.parseLong(str_uid), url, title, content, listVersion);
 					}
@@ -169,24 +187,40 @@
 
 		try {
 
-			String[] uidArray = null;
-			if (uids != null) {
-				uidArray = uids.split(",");
+			List<String> listuid = null;
+			if (uids != null && uids.trim().length() > 0) {
+				listuid = Arrays.asList(uids.split(","));
+				if (listuid == null || listuid.size() == 0) {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛id鏍煎紡涓嶆纭�"));
+					return;
+				}
 			}
-
 			
 			List<String> listVersion = null;
 			if (versions != null && versions.trim().length() > 0) {
-				listVersion  = Arrays.asList(versions.split(","));
+				List<String> list = Arrays.asList(versions.split(","));
+				
+				if (list != null && list.size() > 0) {
+					listVersion = new ArrayList<String>();
+					for (String version: list) {
+						if (version != null && version.trim().length() > 0) {
+							listVersion.add(version.trim());
+						}
+					}
+				}
+				
+				if (listVersion == null || listVersion.size() == 0) {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐗堟湰鍙锋牸寮忎笉姝g‘"));
+					return;
+				}
 			}
 			
-			if (uidArray == null) {
+			if (listuid == null) {
 				// 鍏ㄦ帹
 				pushService.pushUrl(null, title, content, url, listVersion);
 			} else {
 				// 閮ㄥ垎鎺ㄩ��
-				for (int i = 0; i < uidArray.length; i++) {
-					String str_uid = uidArray[i];
+				for (String str_uid: listuid) {
 					if (str_uid != null && str_uid.trim().length() > 0) {
 						pushService.pushUrl(Long.parseLong(str_uid), url, title, content, listVersion);
 					}
@@ -221,23 +255,40 @@
 
 		try {
 
-			String[] uidArray = null;
-			if (uids != null) {
-				uidArray = uids.split(",");
+			List<String> listuid = null;
+			if (uids != null && uids.trim().length() > 0) {
+				listuid = Arrays.asList(uids.split(","));
+				if (listuid == null || listuid.size() == 0) {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛id鏍煎紡涓嶆纭�"));
+					return;
+				}
 			}
 			
 			List<String> listVersion = null;
 			if (versions != null && versions.trim().length() > 0) {
-				listVersion  = Arrays.asList(versions.split(","));
+				List<String> list = Arrays.asList(versions.split(","));
+				
+				if (list != null && list.size() > 0) {
+					listVersion = new ArrayList<String>();
+					for (String version: list) {
+						if (version != null && version.trim().length() > 0) {
+							listVersion.add(version.trim());
+						}
+					}
+				}
+				
+				if (listVersion == null || listVersion.size() == 0) {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐗堟湰鍙锋牸寮忎笉姝g‘"));
+					return;
+				}
 			}
 			
-			if (uidArray == null) {
+			if (listuid == null) {
 				// 鍏ㄦ帹
 				pushService.pushZNX(null, title, content, listVersion);
 			} else {
 				// 閮ㄥ垎鎺ㄩ��
-				for (int i = 0; i < uidArray.length; i++) {
-					String str_uid = uidArray[i];
+				for (String str_uid: listuid) {
 					if (str_uid != null && str_uid.trim().length() > 0) {
 						pushService.pushZNX(Long.parseLong(str_uid), title, content, listVersion);
 
@@ -274,23 +325,40 @@
 
 		try {
 
-			String[] uidArray = null;
-			if (uids != null) {
-				uidArray = uids.split(",");
-			}
-
-			List<String> listVersion = null;
-			if (versions != null && versions.trim().length() > 0) {
-				listVersion  = Arrays.asList(versions.split(","));
+			List<String> listuid = null;
+			if (uids != null && uids.trim().length() > 0) {
+				listuid = Arrays.asList(uids.split(","));
+				if (listuid == null || listuid.size() == 0) {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛id鏍煎紡涓嶆纭�"));
+					return;
+				}
 			}
 			
-			if (uidArray == null) {
+			List<String> listVersion = null;
+			if (versions != null && versions.trim().length() > 0) {
+				List<String> list = Arrays.asList(versions.split(","));
+				
+				if (list != null && list.size() > 0) {
+					listVersion = new ArrayList<String>();
+					for (String version: list) {
+						if (version != null && version.trim().length() > 0) {
+							listVersion.add(version.trim());
+						}
+					}
+				}
+				
+				if (listVersion == null || listVersion.size() == 0) {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐗堟湰鍙锋牸寮忎笉姝g‘"));
+					return;
+				}
+			}
+			
+			if (listuid == null) {
 				// 鍏ㄦ帹
 				pushService.pushBaiChuanUrl(null, title, content, url, listVersion);
 			} else {
 				// 閮ㄥ垎鎺ㄩ��
-				for (int i = 0; i < uidArray.length; i++) {
-					String str_uid = uidArray[i];
+				for (String str_uid: listuid) {
 					if (str_uid != null && str_uid.trim().length() > 0) {
 						pushService.pushBaiChuanUrl(Long.parseLong(str_uid), title, content, url, listVersion);
 					}

--
Gitblit v1.8.0