diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/SmsServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/SmsServiceImpl.java index c9a481b..3b376cd 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/SmsServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/SmsServiceImpl.java @@ -1,10 +1,12 @@ package com.shxy.xymanager_service.impl; import com.shxy.xymanager_common.constant.Constants; +import com.shxy.xymanager_common.entity.TerminalSimcard; import com.shxy.xymanager_common.entity.Terminals; import com.shxy.xymanager_common.exception.ApiException; import com.shxy.xymanager_common.model.SmsModel; import com.shxy.xymanager_common.sms.SmsAdapter; +import com.shxy.xymanager_dao.dao.TerminalSimcardMapper; import com.shxy.xymanager_service.service.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -26,6 +28,8 @@ public class SmsServiceImpl implements SmsService { NewCacheService newCacheService; @Resource SmsAdapter smsAdapter; + @Resource + TerminalSimcardMapper simcardMapper; @Override public void sendSms(SmsModel model) { @@ -36,15 +40,19 @@ public class SmsServiceImpl implements SmsService { if (term == null) { throw new ApiException(termId + "该装置不存在"); } - if (StringUtils.isBlank(term.getIccid())) { - throw new ApiException(termId + "该装置缺少iccid"); + TerminalSimcard simcard = simcardMapper.selectByPrimaryKey(termId); + if (simcard == null) { + throw new ApiException(termId + "该装置缺少simcard信息"); + } + if (StringUtils.isBlank(simcard.getIccid2())) { + throw new ApiException(termId + "该装置缺少iccid2"); } - if (Constants.NetType_Dahan.equals(term.getNetType())) { + if (Constants.NetType_Dahan.equals(simcard.getType2())) { dahanList.add(term.getIccid()); - } else if (Constants.NetType_Rabchaser.equals(term.getNetType())) { + } else if (Constants.NetType_Rabchaser.equals(simcard.getType2())) { rabchaserList.add(term.getIccid()); } else { - throw new ApiException(termId + "该装置的网络运营商类型暂不支持发短信"); + throw new ApiException(termId + "该装置的运营商类型type2暂不支持发短信"); } }