Commit 1843deb2 by weijiguang

添加推送日志

parent 7e6d8cc0
package com.soss.system.jiguang.impl; package com.soss.system.jiguang.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.system.domain.vo.PushBean; import com.soss.system.domain.vo.PushBean;
import com.soss.system.jiguang.JiGuangPushService; import com.soss.system.jiguang.JiGuangPushService;
import com.soss.system.jiguang.MyJiGuangPushService; import com.soss.system.jiguang.MyJiGuangPushService;
import com.soss.system.mapper.MachineMapper; import com.soss.system.mapper.MachineMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -17,6 +19,7 @@ import java.util.List; ...@@ -17,6 +19,7 @@ import java.util.List;
* 封装业务功能相关 * 封装业务功能相关
*/ */
@Service @Service
@Slf4j
public class JiGuangPushServiceImpl implements JiGuangPushService { public class JiGuangPushServiceImpl implements JiGuangPushService {
/** 一次推送最大数量 (极光限制1000) */ /** 一次推送最大数量 (极光限制1000) */
private static final int max_size = 800; private static final int max_size = 800;
...@@ -24,28 +27,34 @@ public class JiGuangPushServiceImpl implements JiGuangPushService { ...@@ -24,28 +27,34 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
private MyJiGuangPushService jPushService; private MyJiGuangPushService jPushService;
@Autowired @Autowired
private MachineMapper machineMapper; private MachineMapper machineMapper;
/** /**
* 推送全部, 不支持附加信息 * 推送全部, 不支持附加信息
*
* @return * @return
*/ */
@Override @Override
public boolean pushAll(PushBean pushBean){ public boolean pushAll(PushBean pushBean) {
return jPushService.pushAll(pushBean); return jPushService.pushAll(pushBean);
} }
/** /**
* 推送全部ios * 推送全部ios
*
* @return * @return
*/ */
@Override @Override
public boolean pushIos(PushBean pushBean){ public boolean pushIos(PushBean pushBean) {
return jPushService.pushIos(pushBean); return jPushService.pushIos(pushBean);
} }
/** /**
* 推送ios 指定id * 推送ios 指定id
*
* @return * @return
*/ */
@Override @Override
public boolean pushIos(PushBean pushBean, String... registids){ public boolean pushIos(PushBean pushBean, String... registids) {
registids = checkRegistids(registids); // 剔除无效registed registids = checkRegistids(registids); // 剔除无效registed
while (registids.length > max_size) { // 每次推送max_size个 while (registids.length > max_size) { // 每次推送max_size个
jPushService.pushIos(pushBean, Arrays.copyOfRange(registids, 0, max_size)); jPushService.pushIos(pushBean, Arrays.copyOfRange(registids, 0, max_size));
...@@ -53,29 +62,35 @@ public class JiGuangPushServiceImpl implements JiGuangPushService { ...@@ -53,29 +62,35 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
} }
return jPushService.pushIos(pushBean, registids); return jPushService.pushIos(pushBean, registids);
} }
/** /**
* 推送全部android * 推送全部android
*
* @return * @return
*/ */
@Override @Override
public boolean pushAndroid(PushBean pushBean){ public boolean pushAndroid(PushBean pushBean) {
return jPushService.pushAndroid(pushBean); return jPushService.pushAndroid(pushBean);
} }
/** /**
* 推送android 指定id * 推送android 指定id
*
* @return * @return
*/ */
@Override @Override
public boolean pushAndroid(PushBean pushBean, String... registids){ public boolean pushAndroid(PushBean pushBean, String... registids) {
registids = checkRegistids(registids); // 剔除无效registed registids = checkRegistids(registids); // 剔除无效registedpush to
while (registids.length > max_size) { // 每次推送max_size个 while (registids.length > max_size) { // 每次推送max_size个
jPushService.pushAndroid(pushBean, Arrays.copyOfRange(registids, 0, max_size)); jPushService.pushAndroid(pushBean, Arrays.copyOfRange(registids, 0, max_size));
registids = Arrays.copyOfRange(registids, max_size, registids.length); registids = Arrays.copyOfRange(registids, max_size, registids.length);
} }
return jPushService.pushAndroid(pushBean, registids); return jPushService.pushAndroid(pushBean, registids);
} }
/** /**
* 剔除无效registed * 剔除无效registed
*
* @param registids * @param registids
* @return * @return
*/ */
...@@ -97,6 +112,7 @@ public class JiGuangPushServiceImpl implements JiGuangPushService { ...@@ -97,6 +112,7 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
PushBean pushBean = new PushBean(); PushBean pushBean = new PushBean();
pushBean.setMessageCount(jsonObject); pushBean.setMessageCount(jsonObject);
pushAndroid(pushBean, registerIds); pushAndroid(pushBean, registerIds);
log.info("push to " + JSON.toJSONString(registerIds) + ", " + JSON.toJSONString(jsonObject));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment