|
|
|
@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@ -28,20 +29,30 @@ public class SmsServiceImpl implements SmsService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sendSms(SmsModel model) {
|
|
|
|
|
Terminals term = newCacheService.getTerminal(model.getTermId());
|
|
|
|
|
if (term == null) {
|
|
|
|
|
throw new ApiException("该装置不存在");
|
|
|
|
|
List<String> dahanList = new ArrayList<>();
|
|
|
|
|
List<String> rabchaserList = new ArrayList<>();
|
|
|
|
|
for (Integer termId : model.getTermIdList()) {
|
|
|
|
|
Terminals term = newCacheService.getTerminal(termId);
|
|
|
|
|
if (term == null) {
|
|
|
|
|
throw new ApiException(termId + "该装置不存在");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(term.getIccid())) {
|
|
|
|
|
throw new ApiException(termId + "该装置缺少iccid");
|
|
|
|
|
}
|
|
|
|
|
if (Constants.NetType_Dahan.equals(term.getNetType())) {
|
|
|
|
|
dahanList.add(term.getIccid());
|
|
|
|
|
} else if (Constants.NetType_Rabchaser.equals(term.getNetType())) {
|
|
|
|
|
rabchaserList.add(term.getIccid());
|
|
|
|
|
} else {
|
|
|
|
|
throw new ApiException(termId + "该装置的网络运营商类型暂不支持发短信");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(term.getIccid())) {
|
|
|
|
|
throw new ApiException("该装置缺少iccid");
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(dahanList)) {
|
|
|
|
|
smsAdapter.sendSms(Constants.NetType_Dahan, dahanList, model.getContent());
|
|
|
|
|
}
|
|
|
|
|
List<String> iccidList = new ArrayList<>();
|
|
|
|
|
iccidList.add(term.getIccid());
|
|
|
|
|
if (Constants.NetType_Dahan.equals(term.getNetType()) ||
|
|
|
|
|
Constants.NetType_Rabchaser.equals(term.getNetType())) {
|
|
|
|
|
smsAdapter.sendSms(term.getNetType(), iccidList, model.getContent());
|
|
|
|
|
} else {
|
|
|
|
|
throw new ApiException("该装置的网络运营商类型不正确");
|
|
|
|
|
if (!CollectionUtils.isEmpty(rabchaserList)) {
|
|
|
|
|
smsAdapter.sendSms(Constants.NetType_Rabchaser, rabchaserList, model.getContent());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|