Commit 1843deb2 by weijiguang

添加推送日志

parent 7e6d8cc0
package com.soss.system.jiguang.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.soss.system.domain.vo.PushBean;
import com.soss.system.jiguang.JiGuangPushService;
import com.soss.system.jiguang.MyJiGuangPushService;
import com.soss.system.mapper.MachineMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -17,6 +19,7 @@ import java.util.List;
* 封装业务功能相关
*/
@Service
@Slf4j
public class JiGuangPushServiceImpl implements JiGuangPushService {
/** 一次推送最大数量 (极光限制1000) */
private static final int max_size = 800;
......@@ -24,28 +27,34 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
private MyJiGuangPushService jPushService;
@Autowired
private MachineMapper machineMapper;
/**
* 推送全部, 不支持附加信息
*
* @return
*/
@Override
public boolean pushAll(PushBean pushBean){
public boolean pushAll(PushBean pushBean) {
return jPushService.pushAll(pushBean);
}
/**
* 推送全部ios
*
* @return
*/
@Override
public boolean pushIos(PushBean pushBean){
public boolean pushIos(PushBean pushBean) {
return jPushService.pushIos(pushBean);
}
/**
* 推送ios 指定id
*
* @return
*/
@Override
public boolean pushIos(PushBean pushBean, String... registids){
public boolean pushIos(PushBean pushBean, String... registids) {
registids = checkRegistids(registids); // 剔除无效registed
while (registids.length > max_size) { // 每次推送max_size个
jPushService.pushIos(pushBean, Arrays.copyOfRange(registids, 0, max_size));
......@@ -53,29 +62,35 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
}
return jPushService.pushIos(pushBean, registids);
}
/**
* 推送全部android
*
* @return
*/
@Override
public boolean pushAndroid(PushBean pushBean){
public boolean pushAndroid(PushBean pushBean) {
return jPushService.pushAndroid(pushBean);
}
/**
* 推送android 指定id
*
* @return
*/
@Override
public boolean pushAndroid(PushBean pushBean, String... registids){
registids = checkRegistids(registids); // 剔除无效registed
public boolean pushAndroid(PushBean pushBean, String... registids) {
registids = checkRegistids(registids); // 剔除无效registedpush to
while (registids.length > max_size) { // 每次推送max_size个
jPushService.pushAndroid(pushBean, Arrays.copyOfRange(registids, 0, max_size));
registids = Arrays.copyOfRange(registids, max_size, registids.length);
}
return jPushService.pushAndroid(pushBean, registids);
}
/**
* 剔除无效registed
*
* @param registids
* @return
*/
......@@ -97,6 +112,7 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
PushBean pushBean = new PushBean();
pushBean.setMessageCount(jsonObject);
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