From b53a8f5f1872ae02977a326a669b2c43307d057c Mon Sep 17 00:00:00 2001 From: huangfeng Date: Mon, 22 Jul 2024 10:08:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E7=A0=81=E5=8A=9F=E8=83=BD=E4=BB=A5=E5=8F=8A=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E7=9A=844=E5=AE=B6=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SmsController.java | 26 ++++++++++ .../shxy/xymanager_common/sms/SmsAdapter.java | 24 +++++++-- .../xymanager_common/sms/dahan/DahanApi.java | 2 +- .../impl/SmsServiceImpl.java | 52 ++++++++++++++++--- 4 files changed, 90 insertions(+), 14 deletions(-) diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/SmsController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/SmsController.java index 7427f49..706a626 100644 --- a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/SmsController.java +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/SmsController.java @@ -4,6 +4,10 @@ import com.shxy.xymanager_common.annotation.Log; import com.shxy.xymanager_common.base.BaseController; import com.shxy.xymanager_common.base.ResponseReult; import com.shxy.xymanager_common.model.SmsModel; +import com.shxy.xymanager_common.sms.dahan.DahanWeb; +import com.shxy.xymanager_common.sms.lwwlkj.LwwlkjWeb; +import com.shxy.xymanager_common.sms.m2m.M2m10086Web; +import com.shxy.xymanager_common.sms.rabchaser.RabchaserWeb; import com.shxy.xymanager_service.service.SmsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -12,6 +16,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.HashMap; @RestController @Api(tags = {"短信相关接口"}) @@ -38,5 +43,26 @@ public class SmsController extends BaseController { return ResponseReult.success(obj); } + @GetMapping("getAuth") + @ApiOperation("查询授权") + public ResponseReult> getAuth() { + HashMap map = new HashMap<>(); + map.put("dahan", DahanWeb.cookie); + map.put("rabchaser", RabchaserWeb.authorization); + map.put("m2m10086", M2m10086Web.cookie); + map.put("lwwlkj", LwwlkjWeb.cookie); + return ResponseReult.success(map); + } + + @PostMapping("updateAuth") + @ApiOperation("更新授权") + public ResponseReult updateAuth(@RequestBody HashMap map) { + DahanWeb.cookie = map.get("dahan"); + RabchaserWeb.authorization = map.get("rabchaser"); + M2m10086Web.cookie = map.get("m2m10086"); + LwwlkjWeb.cookie = map.get("lwwlkj"); + return ResponseReult.success("OK"); + } + } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/sms/SmsAdapter.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/sms/SmsAdapter.java index 1c7f1eb..bac817c 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/sms/SmsAdapter.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/sms/SmsAdapter.java @@ -1,7 +1,9 @@ package com.shxy.xymanager_common.sms; import com.shxy.xymanager_common.constant.Constants; -import com.shxy.xymanager_common.sms.dahan.DahanApi; +import com.shxy.xymanager_common.sms.dahan.DahanWeb; +import com.shxy.xymanager_common.sms.lwwlkj.LwwlkjWeb; +import com.shxy.xymanager_common.sms.m2m.M2m10086Web; import com.shxy.xymanager_common.sms.rabchaser.RabchaserApi; import com.shxy.xymanager_common.sms.rabchaser.RabchaserWeb; import com.shxy.xymanager_common.util.DateUtil; @@ -17,26 +19,38 @@ import java.util.List; public class SmsAdapter { @Resource - DahanApi dahanApi; + DahanWeb dahanWeb; @Resource RabchaserApi rabchaserApi; @Resource RabchaserWeb rabchaserWeb; + @Resource + M2m10086Web m2m10086Web; + @Resource + LwwlkjWeb lwwlkjWeb; public void sendSms(Integer type, List iccidList, String content) { if (Constants.NetType_Dahan.equals(type)) { - dahanApi.sendSms(iccidList, content); + dahanWeb.sendSms(iccidList, content); } else if (Constants.NetType_Rabchaser.equals(type)) { rabchaserApi.sendSms(iccidList, content); + } else if (Constants.NetType_M2M10086.equals(type)) { + m2m10086Web.sendSms(iccidList, content); + } else if (Constants.NetType_LWWLKJ.equals(type)) { + lwwlkjWeb.sendSms(iccidList, content); } } public Object listSms(Integer type, String iccid) { String today = DateUtil.format(new Date(), "yyyy-MM-dd"); if (Constants.NetType_Dahan.equals(type)) { - return dahanApi.smsRecord(iccid, today); + return dahanWeb.listSms(iccid, today); } else if (Constants.NetType_Rabchaser.equals(type)) { - rabchaserWeb.selectMsgReceive(iccid, today); + rabchaserWeb.listSms(iccid, today); + } else if (Constants.NetType_M2M10086.equals(type)) { + m2m10086Web.listSms(iccid, today); + } else if (Constants.NetType_LWWLKJ.equals(type)) { + lwwlkjWeb.listSms(iccid, today); } return null; } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/sms/dahan/DahanApi.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/sms/dahan/DahanApi.java index 12ba916..ede0536 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/sms/dahan/DahanApi.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/sms/dahan/DahanApi.java @@ -55,7 +55,7 @@ public class DahanApi { } } - public Object smsRecord(String iccid, String date) { + public Object listSms(String iccid, String date) { String url = "/api/v1/card/base/sms/record/" + date + "/" + iccid; try { Map headMap = this.signHead(url); 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 7b8aba1..3a93750 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 @@ -35,6 +35,8 @@ public class SmsServiceImpl implements SmsService { public void sendSms(SmsModel model) { List dahanList = new ArrayList<>(); List rabchaserList = new ArrayList<>(); + List m2mList = new ArrayList<>(); + List lkjList = new ArrayList<>(); for (Integer termId : model.getTermIdList()) { Terminals term = newCacheService.getTerminal(termId); if (term == null) { @@ -44,13 +46,27 @@ public class SmsServiceImpl implements SmsService { if (simcard == null) { throw new ApiException(termId + "该装置缺少simcard信息"); } - if (StringUtils.isBlank(simcard.getIccid2())) { - throw new ApiException(termId + "该装置缺少iccid2"); - } + if (Constants.NetType_Dahan.equals(simcard.getType2())) { + if (StringUtils.isBlank(simcard.getIccid2())) { + throw new ApiException(termId + "该装置缺少iccid2"); + } dahanList.add(simcard.getIccid2()); } else if (Constants.NetType_Rabchaser.equals(simcard.getType2())) { + if (StringUtils.isBlank(simcard.getIccid2())) { + throw new ApiException(termId + "该装置缺少iccid2"); + } rabchaserList.add(simcard.getIccid2()); + } else if (Constants.NetType_M2M10086.equals(simcard.getType2())) { + if (StringUtils.isBlank(simcard.getIccid2())) { + throw new ApiException(termId + "该装置缺少iccid2"); + } + m2mList.add(simcard.getIccid2()); + } else if (Constants.NetType_LWWLKJ.equals(simcard.getType2())) { + if (StringUtils.isBlank(simcard.getMsisdn2())) { + throw new ApiException(termId + "该装置缺少msisdn2"); + } + lkjList.add(simcard.getMsisdn2()); } else { throw new ApiException(termId + "该装置的运营商类型type2=" + simcard.getType2() + "暂不支持发短信"); } @@ -62,6 +78,12 @@ public class SmsServiceImpl implements SmsService { if (!CollectionUtils.isEmpty(rabchaserList)) { smsAdapter.sendSms(Constants.NetType_Rabchaser, rabchaserList, model.getContent()); } + if (!CollectionUtils.isEmpty(m2mList)) { + smsAdapter.sendSms(Constants.NetType_M2M10086, m2mList, model.getContent()); + } + if (!CollectionUtils.isEmpty(lkjList)) { + smsAdapter.sendSms(Constants.NetType_LWWLKJ, lkjList, model.getContent()); + } } @Override @@ -74,13 +96,27 @@ public class SmsServiceImpl implements SmsService { if (simcard == null) { throw new ApiException(termId + "该装置缺少simcard信息"); } - if (StringUtils.isBlank(simcard.getIccid2())) { - throw new ApiException(termId + "该装置缺少iccid2"); - } + if (Constants.NetType_Dahan.equals(simcard.getType2())) { - return smsAdapter.listSms(Constants.NetType_Dahan, simcard.getIccid2()); + if (StringUtils.isBlank(simcard.getMsisdn2())) { + throw new ApiException(termId + "该装置缺少msisdn2"); + } + return smsAdapter.listSms(simcard.getType2(), simcard.getMsisdn2()); } else if (Constants.NetType_Rabchaser.equals(simcard.getType2())) { - return smsAdapter.listSms(Constants.NetType_Rabchaser, simcard.getIccid2()); + if (StringUtils.isBlank(simcard.getIccid2())) { + throw new ApiException(termId + "该装置缺少iccid2"); + } + return smsAdapter.listSms(simcard.getType2(), simcard.getIccid2()); + } else if (Constants.NetType_M2M10086.equals(simcard.getType2())) { + if (StringUtils.isBlank(simcard.getIccid2())) { + throw new ApiException(termId + "该装置缺少iccid2"); + } + return smsAdapter.listSms(simcard.getType2(), simcard.getIccid2()); + } else if (Constants.NetType_LWWLKJ.equals(simcard.getType2())) { + if (StringUtils.isBlank(simcard.getMsisdn2())) { + throw new ApiException(termId + "该装置缺少msisdn2"); + } + return smsAdapter.listSms(simcard.getType2(), simcard.getMsisdn2()); } else { throw new ApiException(termId + "该装置的运营商类型type2=" + simcard.getType2() + "暂不支持查询短信"); }