| | |
| | | |
| | | //uni-push 一次推送最多500名用户,所以分批推送 |
| | | List<List<String>> groupList = groupListByQuantity(cIdList, 400); |
| | | groupList.forEach(item->{ |
| | | Boolean push = false; |
| | | for(List<String> cids :groupList){ |
| | | PushVO pushVO = new PushVO(); |
| | | |
| | | pushVO.setCIds(cIdList); |
| | | pushVO.setCIds(cids); |
| | | pushVO.setTitle(messageRecordList.get(0).getTheme()); |
| | | pushVO.setContent(messageRecordList.get(0).getContent()); |
| | | |
| | | HashMap<String,Object> payload = new HashMap<>(); |
| | | payload.put("title",messageRecordList.get(0).getTheme()); |
| | | payload.put("content",messageRecordList.get(0).getContent()); |
| | | payload.put("payload","test"); |
| | | HashMap<String, Object> payload = new HashMap<>(); |
| | | payload.put("title", messageRecordList.get(0).getTheme()); |
| | | payload.put("content", messageRecordList.get(0).getContent()); |
| | | payload.put("payload", "test"); |
| | | pushVO.setPayload(payload); |
| | | pushMessage(pushVO); |
| | | push = pushMessage(pushVO); |
| | | } |
| | | |
| | | }); |
| | | return true; |
| | | return push; |
| | | } |
| | | |
| | | /** |
| | | * 新增测试信息 |
| | | * |
| | | * @param messageRecordList |
| | | */ |
| | | private void addSendMsgTest(List<MessageRecord> messageRecordList) { |
| | |
| | | cIdList.add(clientIdByUserId); |
| | | pushVO.setCIds(cIdList); |
| | | |
| | | HashMap<String,Object> payload = new HashMap<>(); |
| | | payload.put("title",pushVO.getTitle()); |
| | | payload.put("content",pushVO.getContent()); |
| | | payload.put("payload","test"); |
| | | HashMap<String, Object> payload = new HashMap<>(); |
| | | payload.put("title", pushVO.getTitle()); |
| | | payload.put("content", pushVO.getContent()); |
| | | payload.put("payload", "test"); |
| | | pushVO.setPayload(payload); |
| | | |
| | | |
| | |
| | | cIdList.add(getClientIdByUserId(pushVO.getUserId())); |
| | | // return geTuiUtils.pushMsg(cIdList, pushVO.getTitle(), pushVO.getContent()); |
| | | return geTuiUtils.myPushMessage(cIdList, pushVO.getTitle(), pushVO.getContent()); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean pushMessageByUserList(PushVO pushVO) { |
| | | |
| | | if (Func.isEmpty(pushVO.getUserId())) { |
| | | throw new ServiceException("请填写用户id!"); |
| | | } |
| | | |
| | | //获取userIdList |
| | | List<String> userIdList = Arrays.asList(pushVO.getUserId().split(",")); |
| | | List<MessageRecord> messageRecordList = new ArrayList<>(); |
| | | |
| | | userIdList.forEach(userId->{ |
| | | MessageRecord messageRecord = new MessageRecord(); |
| | | |
| | | messageRecord.setContent(pushVO.getContent()); |
| | | messageRecord.setTheme(pushVO.getTitle()); |
| | | messageRecord.setRecipient(userId); |
| | | |
| | | messageRecordList.add(messageRecord); |
| | | }); |
| | | |
| | | Boolean aBoolean = pushMessageList(messageRecordList); |
| | | |
| | | return aBoolean; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | params.put("requestId", UUID.randomUUID()); |
| | | |
| | | params.put("payload",pushVO.getPayload()); |
| | | params.put("payload", pushVO.getPayload()); |
| | | UniCloudReturnRes uniCloudReturnRes = template.postForObject(UNI_CLOUD_PUSH_URL, params, UniCloudReturnRes.class); |
| | | return uniCloudReturnRes.getErrCode().equals("0") ? true : false; |
| | | |
| | |
| | | |
| | | /** |
| | | * 对集合按指定数量进行分组 |
| | | * @param list 分组的集合 |
| | | * |
| | | * @param list 分组的集合 |
| | | * @param quantity 数量 |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | public <T> List<List<T>> groupListByQuantity(List list, int quantity) { |
| | | public <T> List<List<T>> groupListByQuantity(List list, int quantity) { |
| | | if (list == null || list.size() == 0) { |
| | | return list; |
| | | } |