feat: 增加授权码功能以及使用对应的4家后端接口

dev
huangfeng 11 months ago
parent a7cbfcea70
commit b53a8f5f18

@ -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<HashMap<String, String>> getAuth() {
HashMap<String, String> 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<String> updateAuth(@RequestBody HashMap<String, String> 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");
}
}

@ -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<String> 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;
}

@ -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<String, String> headMap = this.signHead(url);

@ -35,6 +35,8 @@ public class SmsServiceImpl implements SmsService {
public void sendSms(SmsModel model) {
List<String> dahanList = new ArrayList<>();
List<String> rabchaserList = new ArrayList<>();
List<String> m2mList = new ArrayList<>();
List<String> 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 (Constants.NetType_Dahan.equals(simcard.getType2())) {
if (StringUtils.isBlank(simcard.getIccid2())) {
throw new ApiException(termId + "该装置缺少iccid2");
}
if (Constants.NetType_Dahan.equals(simcard.getType2())) {
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 (Constants.NetType_Dahan.equals(simcard.getType2())) {
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())) {
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());
} else if (Constants.NetType_Rabchaser.equals(simcard.getType2())) {
return smsAdapter.listSms(Constants.NetType_Rabchaser, simcard.getIccid2());
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() + "暂不支持查询短信");
}

Loading…
Cancel
Save