diff --git a/src/main/java/com/xkrs/controller/DispatchFirePointController.java b/src/main/java/com/xkrs/controller/DispatchFirePointController.java index 4139697..8dec24b 100644 --- a/src/main/java/com/xkrs/controller/DispatchFirePointController.java +++ b/src/main/java/com/xkrs/controller/DispatchFirePointController.java @@ -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 sysUserList = sysUserDao.findAll(); + Map> 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 groupSysUserList = sysUserMap.get(groupIndex); + groupSysUserList.add(sysUser); + } else { + List groupSysUserList = new ArrayList<>(); + groupSysUserList.add(sysUser); + sysUserMap.put(groupIndex, groupSysUserList); + } + } + for (Map.Entry> entry : sysUserMap.entrySet()) { + List 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); }