From 2d950dce7919a2bc39464f9d264f7b96b69f6d1e Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@S0ZHK00LKCA6OYY>
Date: 星期一, 05 十一月 2018 17:05:51 +0800
Subject: [PATCH] 1.添加IOS推送日志记录 2.分享添加显示描述语

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java |  181 +++++++++++++++++++++-----------------------
 1 files changed, 86 insertions(+), 95 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java
index d2094a4..1b8730b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java
@@ -21,6 +21,7 @@
 import com.yeshi.fanli.entity.xinge.MessageInfo;
 import com.yeshi.fanli.entity.xinge.PushRecord;
 import com.yeshi.fanli.exception.PushException;
+import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.log.PushLogHelper;
 import com.yeshi.fanli.service.inter.push.IOSPushService;
 import com.yeshi.fanli.util.CMQManager;
@@ -34,10 +35,9 @@
 
 	@Resource
 	private DeviceTokenIOSMapper deviceTokenIOSMapper;
-	
+
 	@Resource
 	private PushQueueRecordMapper pushQueueRecordMapper;
-	
 
 	@Override
 	public void pushGoods(Long uid, Long auctionId, String title, String content) throws PushException {
@@ -65,26 +65,21 @@
 		pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
 
 		if (uid == null || uid == 0) {
-			
-			addPushIOSQueue(info, url, PushController.GOODS);
-			
-			
-		/*	// 鏌ヨIOS鎵�鏈夎澶囧彿
-			// TODO 闇�瑕佸叏鎺�
-			List<String> deviceTokenList = getDeviceTokenList(1, 20000);
-			// IOS 鍏ㄦ帹
-			ThreadUtil.run(new Runnable() {
 
-				@Override
-				public void run() {
-					try {
-						IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushController.GOODS);
-					} catch (Exception e) {
-						PushLogHelper.iosError(e);
-						
-					}
-				}
-			});*/
+			addPushIOSQueue(info, url, PushController.GOODS);
+
+			/*
+			 * // 鏌ヨIOS鎵�鏈夎澶囧彿 // TODO 闇�瑕佸叏鎺� List<String> deviceTokenList =
+			 * getDeviceTokenList(1, 20000); // IOS 鍏ㄦ帹 ThreadUtil.run(new
+			 * Runnable() {
+			 * 
+			 * @Override public void run() { try {
+			 * IOSPushUtil.allPushIOS(deviceTokenList, info, url,
+			 * PushController.GOODS); } catch (Exception e) {
+			 * PushLogHelper.iosError(e);
+			 * 
+			 * } } });
+			 */
 		} else {
 			// IOS 鍗曟帹
 			List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid);
@@ -125,23 +120,20 @@
 		// IOS 鍏ㄦ帹
 		if (uid == null || uid == 0) {
 			// TODO 闇�瑕佸叏鎺�
-			
+
 			addPushIOSQueue(info, url, PushController.URL);
-			
-			/*List<String> deviceTokenList = getDeviceTokenList(1, 1000);
-			ThreadUtil.run(new Runnable() {
 
-				@Override
-				public void run() {
-					try {
-
-						IOSPushUtil.allPushIOS(deviceTokenList, info, url, PushController.URL);
-
-					} catch (Exception e) {
-						PushLogHelper.iosError(e);
-					}
-				}
-			});*/
+			/*
+			 * List<String> deviceTokenList = getDeviceTokenList(1, 1000);
+			 * ThreadUtil.run(new Runnable() {
+			 * 
+			 * @Override public void run() { try {
+			 * 
+			 * IOSPushUtil.allPushIOS(deviceTokenList, info, url,
+			 * PushController.URL);
+			 * 
+			 * } catch (Exception e) { PushLogHelper.iosError(e); } } });
+			 */
 		} else {
 			List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid);
 			List<String> deviceTokenList = new ArrayList<>();
@@ -192,22 +184,21 @@
 			PushRecord pushRecord = new PushRecord();
 
 			// TODO 闇�瑕佸叏鎺�
-			
+
 			addPushIOSQueue(info, id + "", PushController.ZNX);
-			
-			/*List<String> deviceTokenList = getDeviceTokenList(1, 1000);
 
-			ThreadUtil.run(new Runnable() {
-				@Override
-				public void run() {
-					try {
-						IOSPushUtil.allPushIOS(deviceTokenList, info, id + "", PushController.ZNX);
-					} catch (Exception e) {
-						PushLogHelper.iosError(e);
-					}
-
-				}
-			});*/
+			/*
+			 * List<String> deviceTokenList = getDeviceTokenList(1, 1000);
+			 * 
+			 * ThreadUtil.run(new Runnable() {
+			 * 
+			 * @Override public void run() { try {
+			 * IOSPushUtil.allPushIOS(deviceTokenList, info, id + "",
+			 * PushController.ZNX); } catch (Exception e) {
+			 * PushLogHelper.iosError(e); }
+			 * 
+			 * } });
+			 */
 		} else if (msg != null) {
 			// 鎻掑叆鎺ㄩ�佽褰�
 			PushRecord pushRecord = new PushRecord();
@@ -248,7 +239,7 @@
 
 	@Transactional
 	@Override
-	public void addDeviceToken(Long uid,int version, String deviceToken, String device) {
+	public void addDeviceToken(Long uid, int version, String deviceToken, String device) {
 		// 濡傛灉device涓虹┖灏辫繑鍥�
 		if (StringUtil.isNullOrEmpty(device))
 			return;
@@ -301,16 +292,16 @@
 		return deviceTokenIOSMapper.selectByDevice(device);
 	}
 
-	
 	/**
 	 * 淇濆瓨鎺ㄩ�佸唴瀹瑰彧闃熷垪涓�
+	 * 
 	 * @param json
 	 */
 	@Transactional
 	public void addPushIOSQueue(MessageInfo info, String url, int type) {
-		
+
 		try {
-			
+
 			JSONObject json = IOSPushUtil.getJSONObject(info, url, type);
 
 			// 鎬绘潯鐩�
@@ -333,7 +324,7 @@
 				pushQueueRecord.setCreatetime(new Date());
 				// 姣忔鎺ㄩ�佹暟閲�
 				pushQueueRecord.setPushNum(pushNum);
-				// 鎺ㄩ�佺 IOS 
+				// 鎺ㄩ�佺 IOS
 				pushQueueRecord.setType(1);
 
 				if (tokenCount - i < totalCount) {
@@ -375,94 +366,95 @@
 		}
 
 	}
-	
-	
+
 	/**
 	 * 闃熷垪鎵ц鎺ㄩ�佹搷浣�
 	 */
 	@Override
 	public void readyPushIOS(PushQueueRecord pushQueueRecord) throws Exception {
-		
+
 		// 璧峰浣嶇疆
 		Long startCursor = pushQueueRecord.getStartCursor();
 		// 缁撴潫浣嶇疆
 		Long endCursor = pushQueueRecord.getEndCursor();
-		
+
 		if (startCursor == null && endCursor == null) {
 			return;
 		}
-		
+
 		int total = (int) (endCursor - startCursor);
-		
+
 		// 姣忔鎺ㄩ�佹�绘潯鏁�
 		int moveNum = pushQueueRecord.getPushNum();
-		
-		int count =  total/ moveNum;
-		
+
+		int count = total / moveNum;
+
 		if (total % moveNum > 0) {
-			count +=1;
+			count += 1;
 		}
-		
+
 		long recordCursor = startCursor;
-		
+
 		for (int i = 0; i < count; i++) {
-			
+
 			// 涓嶈冻50涓暟鎹�
 			if (moveNum > total) {
-				moveNum = (int) (endCursor- startCursor);
+				moveNum = (int) (endCursor - startCursor);
 				List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(startCursor, moveNum);
 				recordCursor = endCursor;
-				
+
 				if (list != null) {
 					executePushIOS(list, pushQueueRecord, recordCursor);
+					PushLogHelper.iosInfo("鎺ㄩ�佹父鏍�:" + startCursor + "锛�" + moveNum);
 				}
-				
+
 			} else {
-				
+
 				if (recordCursor + moveNum > endCursor) {
-					//System.out.println("recordCursorend:" +recordCursor);
-					moveNum =  (int) (endCursor- recordCursor);
-					//System.out.println(moveNum);
+					// System.out.println("recordCursorend:" +recordCursor);
+					moveNum = (int) (endCursor - recordCursor);
+					// System.out.println(moveNum);
 					List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum);
 					if (list != null) {
 						executePushIOS(list, pushQueueRecord, endCursor);
+						PushLogHelper.iosInfo("鎺ㄩ�佹父鏍�:" + recordCursor + "锛�" + moveNum);
 					}
 					recordCursor = endCursor;
-					
+
 				} else {
 					List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum);
 					recordCursor = recordCursor + 50;
-					
+
 					if (list != null) {
-						executePushIOS(list, pushQueueRecord, recordCursor-1);
+						executePushIOS(list, pushQueueRecord, recordCursor - 1);
+						PushLogHelper.iosInfo("鎺ㄩ�佹父鏍�:" + recordCursor + "锛�" + moveNum);
 					}
 				}
-				
-				//System.out.println("recordCursor:" +recordCursor);
+
+				// System.out.println("recordCursor:" +recordCursor);
 			}
 		}
-		
+
 	}
-	
-	
-	public void executePushIOS(List<DeviceTokenIOS> list ,PushQueueRecord pushQueueRecord, long recordCursor) {
-		
+
+	public void executePushIOS(List<DeviceTokenIOS> list, PushQueueRecord pushQueueRecord, long recordCursor) {
+
 		String jsonContent = pushQueueRecord.getJsonContent();
 		JSONObject json = JSONObject.fromObject(jsonContent);
-		
+
 		List<String> tokenList = new ArrayList<>();
-		for (DeviceTokenIOS ios : list){
-			if (!StringUtil.isNullOrEmpty(ios.getDeviceToken())){
+		for (DeviceTokenIOS ios : list) {
+			if (!StringUtil.isNullOrEmpty(ios.getDeviceToken())) {
 				tokenList.add(ios.getDeviceToken());
-				//System.out.println(ios.getDeviceToken());
+				// System.out.println(ios.getDeviceToken());
 			}
 		}
-		
+
 		if (tokenList.size() > 0) {
-			//System.out.println(tokenList.size());
+			// System.out.println(tokenList.size());
 			// 鎵ц鎺ㄩ��
 			try {
-				IOSPushUtil.executePushIOS(tokenList,json);
+				IOSPushUtil.executePushIOS(tokenList, json);
 			} catch (Exception e) {
 				// TODO Auto-generated catch block
 				e.printStackTrace();
@@ -471,10 +463,9 @@
 		pushQueueRecord.setState(1);
 		pushQueueRecord.setEndtime(new Date());
 		pushQueueRecord.setRecordCursor(recordCursor);
-		
-		//TODO 鏇存柊鏁版嵁搴�
+
+		// TODO 鏇存柊鏁版嵁搴�
 		pushQueueRecordMapper.updateByPrimaryKeySelective(pushQueueRecord);
 	}
 
-	
 }

--
Gitblit v1.8.0