From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 23 一月 2024 17:17:55 +0800
Subject: [PATCH] 抖音转链修改

---
 fanli/src/main/java/com/yeshi/fanli/job/PushJob.java |  250 +++++++++++++++++++++++++++----------------------
 1 files changed, 137 insertions(+), 113 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 0e228d1..14396a7 100644
--- a/fanli/src/main/java/com/yeshi/fanli/job/PushJob.java
+++ b/fanli/src/main/java/com/yeshi/fanli/job/PushJob.java
@@ -1,113 +1,137 @@
-package com.yeshi.fanli.job;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Scanner;
-
-import javax.annotation.Resource;
-
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import com.yeshi.fanli.entity.push.PushGoods;
-import com.yeshi.fanli.entity.push.PushInfo;
-import com.yeshi.fanli.log.LogHelper;
-import com.yeshi.fanli.service.inter.push.PushGoodsService;
-import com.yeshi.fanli.service.inter.push.PushInfoService;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.factory.IOSPushFactory;
-import com.yeshi.fanli.util.push.IOSPushUtil;
-
-import net.sf.json.JSONObject;
-
-@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();
-			}
-		}
-	}
-
-	
-	
-	/**
-	 *  瀹氭椂娑堟伅鎺ㄩ�佷换鍔� 姣忎釜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();
-			}
-		}
-		
-	}
-	
-	
-	
-}
+package com.yeshi.fanli.job;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+import javax.annotation.Resource;
+
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.util.StringUtil;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import com.yeshi.fanli.entity.push.PushGoods;
+import com.yeshi.fanli.entity.push.PushInfo;
+import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.push.PushGoodsService;
+import com.yeshi.fanli.service.inter.push.PushInfoService;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.factory.IOSPushFactory;
+import com.yeshi.fanli.util.push.IOSPushUtil;
+
+import net.sf.json.JSONObject;
+
+@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();
+            }
+        }
+    }
+
+
+    /**
+     * 瀹氭椂娑堟伅鎺ㄩ�佷换鍔� 姣忎釜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();
+                }
+            }
+
+        }
+    }
+
+
+    @XxlJob("pushJob-pushById")
+    public ReturnT<String> pushById(String param) throws Exception {
+        if (!StringUtil.isNullOrEmpty(param)) {
+            Long id = Long.parseLong(param);
+            PushInfo info = pushInfoService.selectByPrimaryKey(id);
+            if (info == null)
+                return ReturnT.FAIL;
+
+            PushInfo update=new PushInfo();
+            update.setId(info.getId());
+            update.setState(PushInfo.STATE_INIT);
+            pushInfoService.updateSelectiveByPrimaryKey(update);
+            Thread.sleep(100);
+            pushInfoService.handPush(Long.parseLong(param));
+        }
+        return ReturnT.SUCCESS;
+    }
+
+
+}

--
Gitblit v1.8.0