SmsYunPianClient implements SmsClient { @Override public SendResult batchSend(List<String> mobileList, String sign, String templateCode, String template, Map<String, String> templateParams) { template = buildTemplate(sign, template, templateParams); int maxSendSize = MAX_BATCH_SIZE; int maxSendSizeCount = mobileList.size() % maxSendSize == 0 ? mobileList.size() / maxSendSize : mobileList.size() / maxSendSize + 1; int j = 0; int j2 = mobileList.size(); for (int i = 0; i < maxSendSizeCount; i++) { StringBuffer sendMobileStr = new StringBuffer(); for (int k = j; k < j2; k++) { sendMobileStr.append(","); sendMobileStr.append(mobileList.get(k)); } String dividedMobile = sendMobileStr.toString().substring(1); Map<String, String> params = new LinkedHashMap<>(); params.put("apikey", apiKey); params.put("mobile", dividedMobile); params.put("text", template); String result = post(URL_SEND_BATCH, params); JSONObject jsonObject = JSON.parseObject(result); if (jsonObject.containsKey("code") && !(jsonObject.getInteger("code") == SUCCESS_CODE)) { throw new ServiceException(AdminErrorCodeEnum.SMS_PLATFORM_FAIL.getCode(), jsonObject.getString("detail")); } j = j2; j2 = j + maxSendSize; } return new SendResult() .setIsSuccess(true) .setCode(SUCCESS_CODE) .setMessage(SUCCESS_MESSAGE); }  @Override SendResult singleSend(String mobile, String sign, String templateCode, String template, Map<String, String> templateParams); @Override SendResult batchSend(List<String> mobileList, String sign,
                                String templateCode, String template,
                                Map<String, String> templateParams); static String post(String url, Map<String, String> paramsMap);  }
@Test public void batchSendTest() { String mobile = "13302926050"; String template = "您的验证码是#code#，打死也不告诉别人哦。"; smsYunPianClient.batchSend(Lists.newArrayList(mobile), sign, null, template, ImmutableMap.of("code", "2222")); }