| | |
| | | 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.yeshi.fanli.entity.SystemEnum;
|
| | | 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;
|
| | |
|
| | |
|
| | | /**
|
| | | * 推送老版本IOS(每晚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();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | 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; |
| | | |
| | | |
| | | /** |
| | | * 推送老版本IOS(每晚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; |
| | | } |
| | | |
| | | |
| | | } |