diff --git a/yunze-apiCommon/src/main/java/com/yunze/apiCommon/upstreamAPI/YiDongEC/Inquire/Query_YD.java b/yunze-apiCommon/src/main/java/com/yunze/apiCommon/upstreamAPI/YiDongEC/Inquire/Query_YD.java index 986b3dc9fd11414d1c3f902cf964ddca8373af11..a379fa9e3a10f71b44161c117194bda2435df53b 100644 --- a/yunze-apiCommon/src/main/java/com/yunze/apiCommon/upstreamAPI/YiDongEC/Inquire/Query_YD.java +++ b/yunze-apiCommon/src/main/java/com/yunze/apiCommon/upstreamAPI/YiDongEC/Inquire/Query_YD.java @@ -78,8 +78,96 @@ public class Query_YD extends YD_EC_Api { String res = HttpUtil.get(pinUrl); return res; } + public String getGroup(String card_no) {//查询 卡号所在 的 语音通信分组 + //String functionNm = "/query/sim-voice-usage";//成功 但是 无信息https://api.iot.10086.cn/v5/ec/query/group-by-member + String functionNm = "/query/group-by-member";//查询不到信息 + String pinUrl = server_Ip + functionNm + "?transid=" + appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()) + "&token=" + token + "&iccid=" + card_no; + String res = HttpUtil.get(pinUrl); + Map resMap = (Map) JSONObject.parseObject(res); + String status = resMap.get("status").toString(); + if (status.equals("0")) {//成功 + List result = (List) resMap.get("result"); + Map groupList = (Map) result.get(0); + List> all = (List>) groupList.get("groupList"); + for (int i = 0; i < all.size(); i++) { + Map map = all.get(i); + String offeringName = map.get("offeringName").toString(); + if (offeringName.indexOf("语音通信") != -1) {//存在 + return map.get("groupId").toString(); + } + } + + } + + return "错误!!"; + } + public String queryWhiteVoice(Map pMap) { + String iccid = pMap.get("iccid").toString(); + String functionNm = "/query/sim-voice-usage";//成功 但是 无信息 + // String functionNm = "/query/sim-voice-margin";//查询不到信息 + String pinUrl = server_Ip + functionNm + "?transid=" + appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()) + "&token=" + token + "&iccid=" + iccid; + String res = HttpUtil.get(pinUrl); + Map resMap = JSON.parseObject(res); + String status = resMap.get("status").toString(); + if (status.equals("0")) { + List> useList = (List>) resMap.get("result"); + String voiceAmount = useList.get(0).get("voiceAmount").toString(); + return voiceAmount; + } + return "错误"; + } + public List> getWhite(Map map) {// 查询成员组 + String iccid = map.get("iccid").toString(); + String groupId = map.get("groupId").toString(); + String functionNm = "/query/member-voice-whitelist"; //https://api.iot.10086.cn/v5/ec/query/member-voice-whitelist + String pinUrl = server_Ip + functionNm + "?transid=" + appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()) + "&token=" + token + "&iccid=" + iccid + "&groupId=" + groupId; + String res = HttpUtil.get(pinUrl); + Map resMap = JSON.parseObject(res); + String status = resMap.get("status").toString(); + if (status.equals("0")) {//成功 + List> bodyList = (List>) resMap.get("result"); + Map whiteMap = bodyList.get(0); + List> whiteList = (List>) whiteMap.get("memVoiceWhiteList"); + return whiteList;//白名单列表 + } + return null; + } + public Map delWhite(Map PMap) { + HashMap rMap = new HashMap<>(); + String iccid = PMap.get("iccid").toString(); + String groupId = PMap.get("groupId").toString(); + String whiteNumber = PMap.get("delNumber").toString(); + //String whiteNumber ="18615133198"; + String operType = "1"; + try { + String functionNm = "/config/member-voice-whitelist";//配置 白名单 + String pinUrl = server_Ip + functionNm + "?transid=" + appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()) + "&token=" + token + "&iccid=" + iccid + "&groupId=" + groupId + "&operType=4" + "&whiteNumber=" + whiteNumber; + String res = HttpUtil.get(pinUrl); + Map resBody = (Map) JSON.parseObject(res); + return resBody; + } catch (Exception e) { + return null; + } + } + public Map setWhite(Map PMap) { + HashMap rMap = new HashMap<>(); + String iccid = PMap.get("iccid").toString(); + String groupId = PMap.get("groupId").toString(); + String whiteNumber = PMap.get("addNumber").toString(); + //String whiteNumber ="18615133198"; + String operType = "1"; + try { + String functionNm = "/config/member-voice-whitelist";//配置 白名单 + String pinUrl = server_Ip + functionNm + "?transid=" + appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()) + "&token=" + token + "&iccid=" + iccid + "&groupId=" + groupId + "&operType=1" + "&whiteNumber=" + whiteNumber; + String res = HttpUtil.get(pinUrl); + Map resBody = (Map) JSON.parseObject(res); + return resBody; + } catch (Exception e) { + return null; + } + } /** * 单卡接口查询卡状态 * @param card_no diff --git a/yunze-business/src/main/java/com/yunze/cn/mapper/YzVWhiteMapper.java b/yunze-business/src/main/java/com/yunze/cn/mapper/YzVWhiteMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..b4410be536394d8ea376365077b657a4623ad8e1 --- /dev/null +++ b/yunze-business/src/main/java/com/yunze/cn/mapper/YzVWhiteMapper.java @@ -0,0 +1,25 @@ +package com.yunze.cn.mapper; + + +import java.util.List; +import java.util.Map; + +/*** + * 资费组 数据层 + */ +public interface YzVWhiteMapper { + + /** + *查询 + * @param map + * @return + */ + public Map selRoute(Map map); + public Map selRouteCreate(Map map); + public Map getPacketForIccid(Map map); + public Map getPreForPacket(Map map); + + + + +} diff --git a/yunze-business/src/main/resources/mapper/quartz/yunze/YzVWhiteMapper.xml b/yunze-business/src/main/resources/mapper/quartz/yunze/YzVWhiteMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fd2b920ac9c5986bb87c6006e40bf8cd06394b2 --- /dev/null +++ b/yunze-business/src/main/resources/mapper/quartz/yunze/YzVWhiteMapper.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + diff --git a/yunze-web/src/main/java/com/yunze/web/service/impl/WhiteImpl.java b/yunze-web/src/main/java/com/yunze/web/service/impl/WhiteImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f93cf54f3b853bea3099281ae2901cb7f01320fb --- /dev/null +++ b/yunze-web/src/main/java/com/yunze/web/service/impl/WhiteImpl.java @@ -0,0 +1,128 @@ +package com.yunze.web.service.impl; + +import com.yunze.apiCommon.upstreamAPI.YiDongEC.Inquire.Query_YD; + +import com.yunze.cn.mapper.YzVWhiteMapper; +import com.yunze.web.service.White; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Auther: 程志超 + * @Date: 2023年10月16日17:22:20 + * @Description: + */ +@Component +public class WhiteImpl implements White { + @Resource + private YzVWhiteMapper yzVWhiteMapper; + + + @Override + public Map selVoice(Map Pmap) { + return null; + } + + @Override + public Map selRouteCreate(Map Pmap) { + Map route = yzVWhiteMapper.selRoute(Pmap); + String channel_id = route.get("channel_id").toString();//通道编码 + Map routeCreateMap = yzVWhiteMapper.selRouteCreate(route);//通道信息 用户名等地址 + return routeCreateMap; + } + + @Override + public Map setWhite(Map Pmap) {//设置白名单 + Map rMap = new HashMap();//返回map + Map routeCreateMap = selRouteCreate(Pmap);//获取通道信息 + if (routeCreateMap.get("cd_code").toString().equals("YiDong_EC")){ + Query_YD query = new Query_YD(routeCreateMap, routeCreateMap.get("cd_code").toString());//移动查询类 + String groupId = query.getGroup(Pmap.get("iccid").toString());// 查询 语音分组ID + Pmap.put("groupId",groupId); + Map map = query.setWhite(Pmap);//配置白名单 测试 + return map; + } + return null; + } + + @Override + public Map updWhite(Map Pmap) { + return null; + } + + @Override + public Map delWhite(Map Pmap) { + Map rMap = new HashMap();//返回map + Map routeCreateMap = selRouteCreate(Pmap);//获取通道信息 + if (routeCreateMap.get("cd_code").toString().equals("YiDong_EC")){ + Query_YD query = new Query_YD(routeCreateMap, routeCreateMap.get("cd_code").toString());//移动查询类 + String groupId = query.getGroup(Pmap.get("iccid").toString());// 查询 语音分组ID + Pmap.put("groupId",groupId); + Map map = query.delWhite(Pmap);//删除白名单 + return map; + } + return null; + } + + @Override + public Map List(Map Pmap) {//获取列表 + + Map rMap = new HashMap();//返回map + + Map routeCreateMap = selRouteCreate(Pmap);//获取通道信息 + //判断cd_code 是否为移动EC YiDong_EC + if (routeCreateMap.get("cd_code").toString().equals("YiDong_EC")){ + //是 查询白名单列表 与 语音剩余 + // + Query_YD query = new Query_YD(routeCreateMap, routeCreateMap.get("cd_code").toString());//移动查询类 + String groupId = query.getGroup(Pmap.get("iccid").toString());// 查询 语音分组ID + //获取 白名单列表 + Pmap.put("groupId",groupId); + List> whiteMap = query.getWhite(Pmap); + int size = whiteMap.size(); + + String[] arr= {"a","b","c","d","e"}; + if (5-size>=0){ + for (int i = 0; i < 5 - size; i++) { + Map addMpa = new HashMap<>(); + addMpa.put("whiteNumber",""); + addMpa.put("status","1"); + addMpa.put("status",arr[i]); + whiteMap.add(addMpa); + } + } + + rMap.put("whiteMap",whiteMap); + //query.setWhite(Pmap); 配置白名单 测试 + //获取 语音通话 + String use = query.queryWhiteVoice(Pmap); + rMap.put("use",use); + return rMap; + }else{ + //否 结束 + } + + return null; + } + + @Override + public Map getPre(Map Pmap) {// iccid -> xxx + HashMap rMap = new HashMap<>(); + + Map packetMap = yzVWhiteMapper.getPacketForIccid(Pmap); + Map preForPacket = yzVWhiteMapper.getPreForPacket(packetMap); + String pre = preForPacket.get("pre").toString(); + if (pre .equals("1")){ + rMap.put("use","0"); + return rMap; + } + rMap.put("use","1"); + + + return rMap; + } +}