From 9d35ba657fa5e3add766405d76e3ff8c4dcd4ad4 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 04 七月 2020 15:38:00 +0800
Subject: [PATCH] 多系统兼容优化

---
 fanli/src/main/java/com/yeshi/fanli/job/PushJob.java |  172 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 87 insertions(+), 85 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/job/PushJob.java b/fanli/src/main/java/com/yeshi/fanli/job/PushJob.java
index 5a6edd1..5fae0e2 100644
--- a/fanli/src/main/java/com/yeshi/fanli/job/PushJob.java
+++ b/fanli/src/main/java/com/yeshi/fanli/job/PushJob.java
@@ -7,6 +7,7 @@
 
 import javax.annotation.Resource;
 
+import com.yeshi.fanli.entity.SystemEnum;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
@@ -23,91 +24,92 @@
 
 @Component
 public class PushJob {
-	
-	@Resource
-	private PushInfoService pushInfoService;
-	
-	@Resource
-	private PushGoodsService pushGoodsService;
-	
-	
-	/**
-	 * 鎺ㄩ�佽�佺増鏈琁OS(姣忔櫄8鐐规帹閫�)
-	 */
-	@Scheduled(cron = "0 0 20 * * ? ")
-	public void pushOldIOS() {
-		if (!Constant.IS_TASK)
-			return;
-		Scanner scanner = new Scanner(
-				this.getClass().getClassLoader().getResourceAsStream("certificate/devicetoken.txt"));
-		List<String> deviceList = new ArrayList<>();
-		while (scanner.hasNext()) {
-			deviceList.add(scanner.next().trim());
-		}
-		// 姣忔鎺ㄩ��50鏉℃暟鎹�
-		InputStream cer = null;
 
-		int p = deviceList.size() / 50 + 1;
-		JSONObject json = IOSPushFactory.createURLPush("https://0x9.me/TusaI", "鏉挎牀蹇渷鑻规灉绔繘琛屼簡閲嶅ぇ鏇存柊锛佽绔嬪嵆鍗囩骇",
-				"鏇村浼樻儬鍒革紝鏇撮珮杩斿埄锛屽敖鍦ㄦ柊鐗堣嫻鏋滅鏉挎牀蹇渷锛�");
-		for (int i = 0; i < p; i++) {
-			cer = this.getClass().getClassLoader().getResourceAsStream("certificate/鑰佺増鏈�-鐢熶骇璇佷功.p12");
-			try {
-				IOSPushUtil.pushIOS(
-						deviceList.subList(i * 50,
-								(i * 50 + 50) > deviceList.size() ? deviceList.size() : (i * 50 + 50)),
-						json, cer, "123");
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-		}
-	}
+    @Resource
+    private PushInfoService pushInfoService;
 
-	
-	
-	/**
-	 *  瀹氭椂娑堟伅鎺ㄩ�佷换鍔� 姣忎釜30绉掔埇鍙�
-	 */
-	@Scheduled(cron = "30 * * * * ? ")
-	public void pushInfo() {
-		if (!Constant.IS_TASK) {
-			return;
-		}
-		
-		// 绔欏唴淇°�佺綉椤点�佺櫨宸�
-		try {
-			List<PushInfo> listTask = pushInfoService.listTask();
-			if (listTask != null && listTask.size() > 0) {
-				for (PushInfo pushInfo: listTask) {
-					pushInfoService.taskPush(pushInfo);
-				}
-			}
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-		
-		//	浠婃棩鎺ㄨ崘
-		try {
-			List<PushGoods> listTask = pushGoodsService.listTask();
-			if (listTask != null && listTask.size() > 0) {
-				for (PushGoods pushGoods: listTask) {
-					pushGoodsService.taskPush(pushGoods);
-				}
-			}
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-		
-	}
-	
-	
-	
+    @Resource
+    private PushGoodsService pushGoodsService;
+
+
+    /**
+     * 鎺ㄩ�佽�佺増鏈琁OS(姣忔櫄8鐐规帹閫�)
+     */
+    @Scheduled(cron = "0 0 20 * * ? ")
+    public void pushOldIOS() {
+        if (!Constant.IS_TASK)
+            return;
+        Scanner scanner = new Scanner(
+                this.getClass().getClassLoader().getResourceAsStream("certificate/devicetoken.txt"));
+        List<String> deviceList = new ArrayList<>();
+        while (scanner.hasNext()) {
+            deviceList.add(scanner.next().trim());
+        }
+        // 姣忔鎺ㄩ��50鏉℃暟鎹�
+        InputStream cer = null;
+
+        int p = deviceList.size() / 50 + 1;
+        JSONObject json = IOSPushFactory.createURLPush("https://0x9.me/TusaI", "鏉挎牀蹇渷鑻规灉绔繘琛屼簡閲嶅ぇ鏇存柊锛佽绔嬪嵆鍗囩骇",
+                "鏇村浼樻儬鍒革紝鏇撮珮杩斿埄锛屽敖鍦ㄦ柊鐗堣嫻鏋滅鏉挎牀蹇渷锛�");
+        for (int i = 0; i < p; i++) {
+            cer = this.getClass().getClassLoader().getResourceAsStream("certificate/鑰佺増鏈�-鐢熶骇璇佷功.p12");
+            try {
+                IOSPushUtil.pushIOS(
+                        deviceList.subList(i * 50,
+                                (i * 50 + 50) > deviceList.size() ? deviceList.size() : (i * 50 + 50)),
+                        json, cer, "123");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+    /**
+     * 瀹氭椂娑堟伅鎺ㄩ�佷换鍔� 姣忎釜30绉掔埇鍙�
+     */
+    @Scheduled(cron = "30 * * * * ? ")
+    public void pushInfo() {
+        if (!Constant.IS_TASK) {
+            return;
+        }
+
+        for (SystemEnum system : SystemEnum.values()) {
+
+            // 绔欏唴淇°�佺綉椤点�佺櫨宸�
+            try {
+                List<PushInfo> listTask = pushInfoService.listTask(system);
+                if (listTask != null && listTask.size() > 0) {
+                    for (PushInfo pushInfo : listTask) {
+                        pushInfoService.taskPush(pushInfo);
+                    }
+                }
+            } catch (Exception e) {
+                try {
+                    LogHelper.errorDetailInfo(e);
+                } catch (Exception e1) {
+                    e1.printStackTrace();
+                }
+            }
+
+            //	浠婃棩鎺ㄨ崘
+            try {
+                List<PushGoods> listTask = pushGoodsService.listTask(system);
+                if (listTask != null && listTask.size() > 0) {
+                    for (PushGoods pushGoods : listTask) {
+                        pushGoodsService.taskPush(pushGoods);
+                    }
+                }
+            } catch (Exception e) {
+                try {
+                    LogHelper.errorDetailInfo(e);
+                } catch (Exception e1) {
+                    e1.printStackTrace();
+                }
+            }
+
+        }
+    }
+
+
 }

--
Gitblit v1.8.0