| | |
| | | package com.yeshi.fanli.service.impl.push;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<DeviceTokenIOS> getDeviceTokenListByUid(Long uid, List<String> listVersion) {
|
| | | // 版本号
|
| | | List<Integer> listCode = appVersionService.listVersionCodeByVersions(AppVersionInfo.PLATFORM_IOS,listVersion);
|
| | |
|
| | | public List<DeviceTokenIOS> getDeviceTokenListByUid(Long uid, List<String> listVersion) throws PushException {
|
| | | List<Integer> listCode = null;
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | // 版本号推送限制 |
| | | listCode = appVersionService.listVersionCodeByVersions(AppVersionInfo.PLATFORM_IOS,listVersion);
|
| | | if (listCode == null || listCode.size() == 0) {
|
| | | throw new PushException(1, "IOS推送失败,推送版本不存在!");
|
| | | }
|
| | | }
|
| | | |
| | | return deviceTokenIOSMapper.selectByUid(uid, listCode);
|
| | | }
|
| | |
|
| | |
| | | * @param json
|
| | | */
|
| | | @Transactional
|
| | | public void addPushIOSQueue(MessageInfo info, String url, int type, List<String> listVersion) {
|
| | | public void addPushIOSQueue(MessageInfo info, String url, int type, List<String> listVersion) throws PushException {
|
| | |
|
| | | try {
|
| | |
|
| | |
| | | int pushNum = 50;
|
| | |
|
| | | String versionCodes = "";
|
| | | List<Integer> listCode = appVersionService.listVersionCodeByVersions(AppVersionInfo.PLATFORM_IOS,listVersion);
|
| | |
|
| | | if (listCode != null && listCode.size() > 0) {
|
| | | for (Integer code: listCode) {
|
| | | versionCodes = versionCodes + code + ",";
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | // 加入版本推送限制
|
| | | List<Integer> listCode = appVersionService.listVersionCodeByVersions(AppVersionInfo.PLATFORM_IOS,listVersion);
|
| | | |
| | | if (listCode != null && listCode.size() > 0) {
|
| | | for (Integer code: listCode) {
|
| | | versionCodes = versionCodes + code + ",";
|
| | | }
|
| | | |
| | | // 去除末尾逗号
|
| | | if (versionCodes.endsWith(",")) {
|
| | | versionCodes = versionCodes.substring(0, versionCodes.length() - 1);
|
| | | }
|
| | | }
|
| | |
|
| | | // 去除末尾逗号
|
| | | if (versionCodes.endsWith(",")) {
|
| | | versionCodes = versionCodes.substring(0, versionCodes.length() - 1);
|
| | | if (versionCodes == null || versionCodes.trim().length() == 0) {
|
| | | throw new PushException(1, "IOS推送失败,推送版本不存在!");
|
| | | }
|
| | | |
| | | }
|
| | | |
| | |
|
| | | for (long i = 0; i < tokenCount + totalCount;) {
|
| | |
|
| | |
| | | Long startCursor = pushQueueRecord.getStartCursor();
|
| | | // 结束位置
|
| | | Long endCursor = pushQueueRecord.getEndCursor();
|
| | | // 版本号
|
| | | String[] versionArray = null;
|
| | | String versions = pushQueueRecord.getVersions();
|
| | | if (versions != null && versions.trim().length() == 0) {
|
| | | versionArray = versions.split(",");
|
| | | }
|
| | |
|
| | | if (startCursor == null && endCursor == null) {
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | // 推送的版本号
|
| | | String versions = pushQueueRecord.getVersions();
|
| | | List<Integer> listVersionCode = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | |
| | | List<String> listVersion = Arrays.asList(versions.split(","));
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | listVersionCode = new ArrayList<Integer>();
|
| | | for (String version: listVersion) {
|
| | | if (version != null && version.trim().length() > 0) {
|
| | | listVersionCode.add(Integer.parseInt(version));
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (listVersionCode == null || listVersionCode.size() == 0) {
|
| | | return; //版本号存在异常
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | int total = (int) (endCursor - startCursor);
|
| | |
|
| | | // 每次推送总条数
|
| | |
| | | // 不足50个数据
|
| | | if (moveNum > total) {
|
| | | moveNum = (int) (endCursor - startCursor);
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(startCursor, moveNum, versionArray);
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(startCursor, moveNum, listVersionCode);
|
| | | recordCursor = endCursor;
|
| | |
|
| | | if (list != null) {
|
| | |
| | | // System.out.println("recordCursorend:" +recordCursor);
|
| | | moveNum = (int) (endCursor - recordCursor);
|
| | | // System.out.println(moveNum);
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum, versionArray);
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum, listVersionCode);
|
| | | if (list != null) {
|
| | | executePushIOS(list, pushQueueRecord, endCursor);
|
| | | PushLogHelper.iosInfo("推送游标:" + recordCursor + "," + moveNum);
|
| | |
| | | recordCursor = endCursor;
|
| | |
|
| | | } else {
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum, versionArray);
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum, listVersionCode);
|
| | | recordCursor = recordCursor + 50;
|
| | |
|
| | | if (list != null) {
|
| | |
| | | PushLogHelper.iosInfo("推送游标:" + recordCursor + "," + moveNum);
|
| | | }
|
| | | }
|
| | |
|
| | | // System.out.println("recordCursor:" +recordCursor);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public void executePushIOS(List<DeviceTokenIOS> list, PushQueueRecord pushQueueRecord, long recordCursor) {
|