群发秸秆火订阅短信
This commit is contained in:
parent
aee65f190b
commit
03a893f893
@ -5,10 +5,12 @@ import com.xkrs.dao.FirePointOrdinaryDao;
|
||||
import com.xkrs.dao.StreetDao;
|
||||
import com.xkrs.dao.SysUserDao;
|
||||
import com.xkrs.fireseason.FireSeasonConfigService;
|
||||
import com.xkrs.model.entity.SysUserEntity;
|
||||
import com.xkrs.model.qo.AllFirePointQo;
|
||||
import com.xkrs.model.qo.UpdateFirePointQo;
|
||||
import com.xkrs.service.DispatchFirePointService;
|
||||
import com.xkrs.service.impl.FirePointServiceImpl;
|
||||
import com.xkrs.utilsnew.SMSUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
@ -18,7 +20,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
|
||||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
|
||||
@ -72,6 +74,34 @@ public class DispatchFirePointController {
|
||||
// System.out.println(i + "/" + 10000);
|
||||
// }
|
||||
|
||||
//群发短信-start
|
||||
int groupCount = 50;
|
||||
List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
||||
Map<Integer, List<SysUserEntity>> sysUserMap = new HashMap<>();
|
||||
for (int i = 0; i < sysUserList.size(); i++) {
|
||||
SysUserEntity sysUser = sysUserList.get(i);
|
||||
int groupIndex = i / groupCount;
|
||||
if (sysUserMap.containsKey(groupIndex)) {
|
||||
List<SysUserEntity> groupSysUserList = sysUserMap.get(groupIndex);
|
||||
groupSysUserList.add(sysUser);
|
||||
} else {
|
||||
List<SysUserEntity> groupSysUserList = new ArrayList<>();
|
||||
groupSysUserList.add(sysUser);
|
||||
sysUserMap.put(groupIndex, groupSysUserList);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<Integer, List<SysUserEntity>> entry : sysUserMap.entrySet()) {
|
||||
List<SysUserEntity> smsReceiverList = entry.getValue();
|
||||
String[] telephoneArray = new String[smsReceiverList.size()];
|
||||
for (int i = 0; i < smsReceiverList.size(); i++) {
|
||||
telephoneArray[i] = "86" + smsReceiverList.get(i).getUserName();
|
||||
}
|
||||
int resValue = SMSUtils.sendSmsToUser(telephoneArray, "1932636", new String[]{});
|
||||
System.out.println("resValue = " + resValue);
|
||||
}
|
||||
// int resValue = SMSUtils.sendSmsToUser(new String[]{"8615764226530"}, "1932636", new String[]{});
|
||||
// System.out.println("resValue = " + resValue);
|
||||
//群发短信-end
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OKKKK", locale);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user