From 4a05f1c9c508ab7f10c5eae22a5c716f5454ca02 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 12 三月 2019 16:29:55 +0800 Subject: [PATCH] 冲突提交 --- fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java | 87 ++++++++++++++++++++++++++++++------------- 1 files changed, 60 insertions(+), 27 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java index 9576a6e..07c2392 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java @@ -13,6 +13,7 @@ import com.yeshi.fanli.controller.admin.PushController; import com.yeshi.fanli.dao.mybatis.push.DeviceTokenIOSMapper; import com.yeshi.fanli.dao.mybatis.push.PushQueueRecordMapper; +import com.yeshi.fanli.entity.AppVersionInfo; import com.yeshi.fanli.entity.bus.user.AccountMessage; import com.yeshi.fanli.entity.push.DeviceTokenIOS; import com.yeshi.fanli.entity.push.PushQueueRecord; @@ -21,6 +22,7 @@ import com.yeshi.fanli.entity.xinge.PushRecord; import com.yeshi.fanli.exception.PushException; import com.yeshi.fanli.log.PushLogHelper; +import com.yeshi.fanli.service.inter.config.AppVersionService; import com.yeshi.fanli.service.inter.push.IOSPushService; import com.yeshi.fanli.service.inter.user.UserCustomSettingsService; import com.yeshi.fanli.util.CMQManager; @@ -41,9 +43,13 @@ @Resource private UserCustomSettingsService userCustomSettingsService; + + @Resource + private AppVersionService appVersionService; + @Override - public void pushGoods(Long uid, Long auctionId, String title, String content) throws PushException { + public void pushGoods(Long uid, Long auctionId, String title, String content, List<String> listVersion) throws PushException { String url = "https://item.taobao.com/item.htm?id=" + auctionId; JSONObject json = new JSONObject(); @@ -69,7 +75,7 @@ if (uid == null || uid == 0) { - addPushIOSQueue(info, url, PushController.GOODS); + addPushIOSQueue(info, url, PushController.GOODS, listVersion); /* * // 鏌ヨIOS鎵�鏈夎澶囧彿 // TODO 闇�瑕佸叏鎺� List<String> deviceTokenList = @@ -89,7 +95,7 @@ } // IOS 鍗曟帹 - List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid); + List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid, listVersion); List<String> deviceTokenList = new ArrayList<>(); if (deviceTokenIosList != null) for (DeviceTokenIOS ios : deviceTokenIosList) { @@ -106,7 +112,7 @@ } @Override - public void pushUrl(Long uid, String url, String title, String content) throws PushException { + public void pushUrl(Long uid, String url, String title, String content, List<String> listVersion) throws PushException { JSONObject json = new JSONObject(); json.put("url", url); json.put("type", "url"); @@ -128,7 +134,7 @@ if (uid == null || uid == 0) { // TODO 闇�瑕佸叏鎺� - addPushIOSQueue(info, url, PushController.URL); + addPushIOSQueue(info, url, PushController.URL, listVersion); /* * List<String> deviceTokenList = getDeviceTokenList(1, 1000); @@ -146,7 +152,7 @@ return; // 閫氱煡鍏嶆墦鎵�(20:00-24:00 / 00:00 -08:00) } - List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid); + List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid, listVersion); List<String> deviceTokenList = new ArrayList<>(); if (deviceTokenIosList != null) for (DeviceTokenIOS ios : deviceTokenIosList) { @@ -161,7 +167,7 @@ } @Override - public void pushZNX(Long uId, AccountMessage msg, SystemZnx systemZNX) throws PushException { + public void pushZNX(Long uId, AccountMessage msg, SystemZnx systemZNX, List<String> listVersion) throws PushException { MessageInfo info = new MessageInfo(); info.setPackageName(Constant.systemCommonConfig.getAndroidPackageName()); @@ -191,7 +197,7 @@ // TODO 闇�瑕佸叏鎺� - addPushIOSQueue(info, id + "", PushController.ZNX); + addPushIOSQueue(info, id + "", PushController.ZNX, listVersion); /* * List<String> deviceTokenList = getDeviceTokenList(1, 1000); @@ -234,7 +240,7 @@ json.put("miPushUrl", String.format("%s.ui.mine.AppMailDetailActivity", Constant.systemCommonConfig.getAndroidBaseactivityName())); - List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(msg.getUserInfo().getId()); + List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(msg.getUserInfo().getId(), listVersion); List<String> deviceTokenList = new ArrayList<>(); if (deviceTokenIosList != null) for (DeviceTokenIOS ios : deviceTokenIosList) { @@ -282,13 +288,16 @@ } @Override - public List<DeviceTokenIOS> getDeviceTokenListByUid(Long uid) { - return deviceTokenIOSMapper.selectByUid(uid); + public List<DeviceTokenIOS> getDeviceTokenListByUid(Long uid, List<String> listVersion) { + // 鐗堟湰鍙� + List<Integer> listCode = appVersionService.listVersionCodeByVersions(AppVersionInfo.PLATFORM_IOS,listVersion); + + return deviceTokenIOSMapper.selectByUid(uid, listCode); } @Override public List<String> getDeviceTokenList(int page, int size) { - List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList((long) ((page - 1) * size), size); + List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList((long) ((page - 1) * size), size, null); List<String> tokenList = new ArrayList<>(); for (DeviceTokenIOS ios : list) if (!StringUtil.isNullOrEmpty(ios.getDeviceToken())) @@ -320,7 +329,7 @@ * @param json */ @Transactional - public void addPushIOSQueue(MessageInfo info, String url, int type) { + public void addPushIOSQueue(MessageInfo info, String url, int type, List<String> listVersion) { try { @@ -335,6 +344,20 @@ // 姣忔鎵ц鏉$洰 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 (versionCodes.endsWith(",")) { + versionCodes = versionCodes.substring(0, versionCodes.length() - 1); + } + } + for (long i = 0; i < tokenCount + totalCount;) { PushQueueRecord pushQueueRecord = new PushQueueRecord(); @@ -348,6 +371,9 @@ pushQueueRecord.setPushNum(pushNum); // 鎺ㄩ�佺 IOS pushQueueRecord.setType(1); + // 鐗堟湰鍙� + pushQueueRecord.setVersions(versionCodes); + if (tokenCount - i < totalCount) { // 璧峰娓告爣 @@ -398,7 +424,13 @@ 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; } @@ -417,11 +449,12 @@ long recordCursor = startCursor; for (int i = 0; i < count; i++) { - + + // 涓嶈冻50涓暟鎹� if (moveNum > total) { moveNum = (int) (endCursor - startCursor); - List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(startCursor, moveNum); + List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(startCursor, moveNum, versionArray); recordCursor = endCursor; if (list != null) { @@ -435,7 +468,7 @@ // System.out.println("recordCursorend:" +recordCursor); moveNum = (int) (endCursor - recordCursor); // System.out.println(moveNum); - List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum); + List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum, versionArray); if (list != null) { executePushIOS(list, pushQueueRecord, endCursor); PushLogHelper.iosInfo("鎺ㄩ�佹父鏍�:" + recordCursor + "锛�" + moveNum); @@ -443,7 +476,7 @@ recordCursor = endCursor; } else { - List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum); + List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum, versionArray); recordCursor = recordCursor + 50; if (list != null) { @@ -518,16 +551,16 @@ } @Override - public void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException { + public void pushWEEX(Long uid, String title, String content, String weexUrl, List<String> listVersion) throws PushException { MessageInfo info = new MessageInfo(); info.setTitle(title); info.setContent(content); info.setDescription(content); // IOS 鍏ㄦ帹 if (uid == null || uid == 0) { - addPushIOSQueue(info, weexUrl, PushController.WEEX); + addPushIOSQueue(info, weexUrl, PushController.WEEX, listVersion); } else { - List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid); + List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid, listVersion); List<String> deviceTokenList = new ArrayList<>(); if (deviceTokenIosList != null) for (DeviceTokenIOS ios : deviceTokenIosList) { @@ -542,16 +575,16 @@ } @Override - public void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException { + public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<String> listVersion) throws PushException { MessageInfo info = new MessageInfo(); info.setTitle(title); info.setContent(content); info.setDescription(content); // IOS 鍏ㄦ帹 if (uid == null || uid == 0) { - addPushIOSQueue(info, url, PushController.BAICHUAN); + addPushIOSQueue(info, url, PushController.BAICHUAN, listVersion); } else { - List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid); + List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid, listVersion); List<String> deviceTokenList = new ArrayList<>(); if (deviceTokenIosList != null) for (DeviceTokenIOS ios : deviceTokenIosList) { @@ -590,19 +623,19 @@ } @Override - public void pushWelfareCenter(Long uid, String title, String content) throws PushException { + public void pushWelfareCenter(Long uid, String title, String content, List<String> listVersion) throws PushException { MessageInfo info = new MessageInfo(); info.setTitle(title); info.setContent(content); info.setDescription(content); // IOS 鍏ㄦ帹 if (uid == null || uid == 0) { - addPushIOSQueue(info, "", PushController.WELFARE_CENTER); + addPushIOSQueue(info, "", PushController.WELFARE_CENTER, listVersion); } else { if (!validateNotDisturbSingle(uid)) { return; } - List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid); + List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid, listVersion); List<String> deviceTokenList = new ArrayList<>(); if (deviceTokenIosList != null) for (DeviceTokenIOS ios : deviceTokenIosList) { -- Gitblit v1.8.0