diff --git a/yunze-admin/src/main/java/com/yunze/web/controller/yunze/card/YzCardUsageController.java b/yunze-admin/src/main/java/com/yunze/web/controller/yunze/card/YzCardUsageController.java new file mode 100644 index 0000000000000000000000000000000000000000..72869825863acdb75664b7590d4eb7ae8e9bed17 --- /dev/null +++ b/yunze-admin/src/main/java/com/yunze/web/controller/yunze/card/YzCardUsageController.java @@ -0,0 +1,39 @@ +package com.yunze.web.controller.yunze.card; + +import com.yunze.common.core.controller.BaseController; +import com.yunze.common.core.domain.AjaxResult; +import com.yunze.system.service.yunze.IYzCardService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/usage") +public class YzCardUsageController extends BaseController { + @Autowired + private IYzCardService yzCardService; + + /*** + *日用量统计 + * @param query + * @return + */ + @PostMapping("/cardUsage") + public AjaxResult cardUsage(@RequestBody String query) { + try { + return yzCardService.distinguishCardType(query); + } catch (Exception e) { + return AjaxResult.error(e.getMessage()); + } + } + @PostMapping("/cardMonthUsage") + public AjaxResult cardMonthUsage(@RequestBody String query) { + try { + return yzCardService.cardMonthUsage(query); + } catch (Exception e) { + return AjaxResult.error(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/yunze-admin/src/main/java/com/yunze/web/controller/yunze/card/YzHandAddPackageController.java b/yunze-admin/src/main/java/com/yunze/web/controller/yunze/card/YzHandAddPackageController.java new file mode 100644 index 0000000000000000000000000000000000000000..96fbc5dba97318a5cdcbd7cde13648821101decf --- /dev/null +++ b/yunze-admin/src/main/java/com/yunze/web/controller/yunze/card/YzHandAddPackageController.java @@ -0,0 +1,57 @@ +package com.yunze.web.controller.yunze.card; + +import com.alibaba.fastjson.JSON; +import com.yunze.apiCommon.utils.AesEncryptUtil; +import com.yunze.common.annotation.Log; +import com.yunze.common.core.controller.BaseController; +import com.yunze.common.core.domain.AjaxResult; +import com.yunze.common.enums.BusinessType; +import com.yunze.common.utils.ServletUtils; +import com.yunze.common.utils.ip.IpUtils; +import com.yunze.system.service.YzHandAddPackageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.util.HashMap; +import java.util.Map; + +@RestController +@RequestMapping("/hand") +public class YzHandAddPackageController extends BaseController { + //创建生效类型分支 + @Autowired + private YzHandAddPackageService yzHandAddPackageService; + + @PostMapping("/addPackage") + public AjaxResult handAddPackage(@RequestBody String Pstr) { + Map Parammap = new HashMap(); + if (Pstr != null) { + Pstr = Pstr.replace("%2F", "/");//转义 / + } + try { + Pstr = AesEncryptUtil.desEncrypt(Pstr); + Parammap.putAll(JSON.parseObject((String) Pstr)); + return AjaxResult.success(AesEncryptUtil.encrypt(JSON.toJSONString(yzHandAddPackageService.handAddPackage(Parammap)))); + } catch (Exception e) { + return AjaxResult.error("加包失败 !"); + } + } + + @Log(title = "文件上传批量订购", businessType = BusinessType.IMPORT) + @PreAuthorize("@ss.hasPermi('yunze:card:import')") + @PostMapping(value = "/addPackageExcel", produces = {"application/json;charset=utf-8"}) + public AjaxResult addPackage(MultipartFile file) { + try { + return yzHandAddPackageService.addPackage(file); + } catch (Exception e) { + String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); + logger.error("
yunze:card:import
ip = " + ip + "
", e.getCause().toString()); + } + return AjaxResult.error("操作失败!"); + } +} \ No newline at end of file diff --git a/yunze-apiCommon/pom.xml b/yunze-apiCommon/pom.xml index b221e9df735940f52e00d9caf86a64c44f136c90..d688d4a26fba35f445b7bb066860a55826d87ce4 100644 --- a/yunze-apiCommon/pom.xml +++ b/yunze-apiCommon/pom.xml @@ -79,6 +79,10 @@ poi-ooxml + + org.projectlombok + lombok + org.apache.commons diff --git a/yunze-apiCommon/src/main/java/com/yunze/apiCommon/upstreamAPI/DianXinCMP5G/Inquire/Query_DX5G.java b/yunze-apiCommon/src/main/java/com/yunze/apiCommon/upstreamAPI/DianXinCMP5G/Inquire/Query_DX5G.java index dfc9243298693fa08536ae261fa2ac0784c5e510..991dabb9a8550eb012e85b3292aa3d50eb25d1f6 100644 --- a/yunze-apiCommon/src/main/java/com/yunze/apiCommon/upstreamAPI/DianXinCMP5G/Inquire/Query_DX5G.java +++ b/yunze-apiCommon/src/main/java/com/yunze/apiCommon/upstreamAPI/DianXinCMP5G/Inquire/Query_DX5G.java @@ -7,13 +7,14 @@ import com.yunze.apiCommon.upstreamAPI.DianXinCMP5G.change.ServiceAccept_DX5G; import com.yunze.apiCommon.utils.HttpUtil; import com.yunze.apiCommon.utils.UrlUtil; import com.yunze.apiCommon.utils.XmlUtil; +import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Logger; - +@Slf4j /** * 查询类接口 */ @@ -332,6 +333,36 @@ public class Query_DX5G extends DianXin_DCP5G_Api { } + /*** + * CTIOT_5GCMP_UQ002-流量查询(时间段) + */ + public Map queryTrafficByDate (String iccid,String startDate,String endDate){ + Map rMap = null; + String res = null; + // 拼接接口地址 + String Config_name = "/api/v1/openbill/queryTrafficByDate"; + String api_url = server_Ip + Config_name; + Map params = new HashMap(); + params.put("iccid", iccid);// + params.put("needDtl", "0"); + params.put("startDate",startDate); + params.put("endDate", endDate); + getSign(params); //生成sign加密值 + String param_url = UrlUtil.getUrl(api_url, params, true); + try { + res = HttpUtil.get(param_url, headers); + rMap = XmlUtil.xmlToMap(res); + try { + log.info(">>Query_DX5G - queryTraffic - :access_number {} | {}<<", iccid, JSON.toJSON(rMap)); + } catch (Exception e) { + } + } catch (Exception e) { + rMap = new HashMap<>(); + rMap.put("error", res); + System.out.println(Config_name + " 返回数据错误!" + res); + } + return rMap; + } } 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 a379fa9e3a10f71b44161c117194bda2435df53b..88eece5c670e36fdbc5965901523e4c368aec29d 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 @@ -116,6 +116,53 @@ public class Query_YD extends YD_EC_Api { } return "错误"; } + /** + * ri流量查询接口 + * + * @param card_no + * @return + */ + public String selDayUsage(String card_no,String queryDate) { + String functionNm = "/query/sim-data-usage-daily/batch"; + JSONObject retult = new JSONObject(); + JSONObject json = new JSONObject(); + if (!cd_code.equals("YiDong_EC_TengYu")) { + json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date())); + json.put("token", token); + json.put("iccids", card_no); + json.put("queryDate",queryDate); + } else { + json.put("interface", functionNm); + json.put("appid", appId); + Map requestParams = new HashMap<>(); + requestParams.put("msisdn", card_no); + json.put("requestParams", requestParams); + } + String url = server_Ip + functionNm; + String Str = send(url, json); + //System.out.println(Str); + return repeat(Str, json, url); + } + public String newDesignatedMonth(String card_no, String queryDate) { + String functionNm = "/query/sim-data-usage-monthly/batch"; + JSONObject retult = new JSONObject(); + JSONObject json = new JSONObject(); + if (!cd_code.equals("YiDong_EC_TengYu")) { + json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date())); + json.put("token", token); + json.put("iccids", card_no); + } else { + json.put("interface", functionNm); + json.put("appid", appId); + Map requestParams = new HashMap<>(); + requestParams.put("msisdn", card_no); + json.put("requestParams", requestParams); + } + json.put("queryDate", queryDate); + String url = server_Ip + functionNm; + String Str = send(url, json); + return repeat(Str, json, url); + } public List> getWhite(Map map) {// 查询成员组 String iccid = map.get("iccid").toString(); String groupId = map.get("groupId").toString(); diff --git a/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzCardFlowMapper.java b/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzCardFlowMapper.java index b0660ebbc7649045dff21b19fbe995340d038989..c29b3ee9abe1f7bdd03632b14a1d00a2973810f8 100644 --- a/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzCardFlowMapper.java +++ b/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzCardFlowMapper.java @@ -252,4 +252,6 @@ public interface YzCardFlowMapper int selCardFlow(Map stringMap); void insertFlow(Map insertMap); + + Integer filterIsAddPackage(String iccid); } diff --git a/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzCardPacketMapper.java b/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzCardPacketMapper.java index 38ef5ddf4da56356b3668e4664c0df5cc224ef0c..d994f23f93ba6663cfce031637e2a262a960a49c 100644 --- a/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzCardPacketMapper.java +++ b/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzCardPacketMapper.java @@ -149,4 +149,6 @@ public interface YzCardPacketMapper { public List> exportPacket(Map map); Map findPackageInfo(Map map); + + Map selPackageInfo(Map resMap); } diff --git a/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzOrderMapper.java b/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzOrderMapper.java index ef8ba830c10077490314bfb94091e30bd47853e9..593a10d734dbe56a5593835f6222e16c9f0d97af 100644 --- a/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzOrderMapper.java +++ b/yunze-common/src/main/java/com/yunze/common/mapper/yunze/YzOrderMapper.java @@ -1,5 +1,7 @@ package com.yunze.common.mapper.yunze; +import org.apache.ibatis.annotations.Param; + import java.util.List; import java.util.Map; @@ -222,5 +224,14 @@ public interface YzOrderMapper { * @return */ public Integer findFirstOrder(Map map); + List> filterNotAddCard(Map parammap); + + List> periodicExtension(Map parammap); + + List> nextMonth(Map parammap); + + List> activateEffect(Map parammap); + + void updateAddPackage(@Param("addPackage") int i, @Param("orderId") String orderId); } diff --git a/yunze-system/src/main/java/com/yunze/system/service/YzHandAddPackageService.java b/yunze-system/src/main/java/com/yunze/system/service/YzHandAddPackageService.java new file mode 100644 index 0000000000000000000000000000000000000000..2649209cde90a86411a9e49c150c261397cee7a5 --- /dev/null +++ b/yunze-system/src/main/java/com/yunze/system/service/YzHandAddPackageService.java @@ -0,0 +1,12 @@ +package com.yunze.system.service; + +import com.yunze.common.core.domain.AjaxResult; +import org.springframework.web.multipart.MultipartFile; + +import java.util.Map; + +public interface YzHandAddPackageService { + AjaxResult handAddPackage(Map parammap); + + AjaxResult addPackage(MultipartFile file); +} diff --git a/yunze-system/src/main/java/com/yunze/system/service/impl/YzHandAddPackageServiceImpl.java b/yunze-system/src/main/java/com/yunze/system/service/impl/YzHandAddPackageServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a7f4dafaa97d02849e6b03cb477bb6da746d3e18 --- /dev/null +++ b/yunze-system/src/main/java/com/yunze/system/service/impl/YzHandAddPackageServiceImpl.java @@ -0,0 +1,397 @@ +package com.yunze.system.service.impl; + +import com.yunze.common.core.domain.AjaxResult; + +import com.yunze.common.mapper.yunze.YzCardFlowMapper; +import com.yunze.common.mapper.yunze.YzCardMapper; +import com.yunze.common.mapper.yunze.YzCardPacketMapper; +import com.yunze.common.mapper.yunze.YzOrderMapper; +import com.yunze.common.utils.StringUtils; +import com.yunze.common.utils.yunze.ExcelConfig; +import com.yunze.common.utils.yunze.Upload; +import com.yunze.common.utils.yunze.VeDate; +import com.yunze.system.service.YzHandAddPackageService; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.File; +import java.time.LocalDate; +import java.time.temporal.TemporalAdjusters; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +@Service +public class YzHandAddPackageServiceImpl implements YzHandAddPackageService { + @Resource + private YzOrderMapper yzOrderMapper; + @Resource + private YzCardFlowMapper yzCardFlowMapper; + @Resource + private YzCardPacketMapper packetMapper; + @Resource + private YzCardMapper cardMapper; + + @Override + public AjaxResult handAddPackage(Map parammap) { + //根据不同的生效类型生成不同的Manage类 1、currentMonth||2、nextMonth||3、periodicExtension||4、activateEffect + try { + //当生效类型为1的时候是 当月生效 + if (parammap.get("validateType").toString().equals("1")) { + this.currentMonth(parammap); + } else if (parammap.get("validateType").toString().equals("2")) { + this.nextMonth(parammap); + } else if (parammap.get("validateType").toString().equals("3")) { + this.periodicExtension(parammap); + } else if (parammap.get("validateType").toString().equals("4")) { + this.activateEffect(parammap); + } + } catch (Exception e) { + return AjaxResult.error(""); + } + return AjaxResult.success(); + } + + + private AjaxResult activateEffect(Map parammap) { + try { + //根据startNo 和 endNo 去查询订单当中加包或未加包的 + List> notAddCard = yzOrderMapper.activateEffect(parammap); + if (notAddCard.size() == 0) { + return AjaxResult.error("该卡无此类型生效订单 !"); + } + for (Map resMap : notAddCard) { + //取出来加包未加包的订单,去过滤掉当月已完成定购的 + Integer aPackage = yzCardFlowMapper.filterIsAddPackage(resMap.get("iccid").toString()); + //如果未订购,走加包流程 + if (aPackage == 0) { + Map packageInfo = packetMapper.selPackageInfo(resMap); + if (packageInfo.get("packet_valid_name").toString().equals("月")) { + int month = Integer.parseInt(packageInfo.get("packet_valid_time").toString()); + //获取到期日期 + LocalDate localDate = this.setMonthEndTime(resMap.get("activateDate").toString(), month); + //修改 卡信息到期日期 + Map cardMap = new HashMap<>(); + cardMap.put("endTime", localDate + " 23:59:59"); + cardMap.put("iccid", resMap.get("iccid")); + cardMap.put("remaining", packageInfo.get("error_flow")); + cardMapper.updateEndTime(cardMap); + resMap.put("endTime", localDate + " 23:59:59"); + this.insertFlow(packageInfo, resMap); + yzOrderMapper.updateAddPackage(1, resMap.get("ord_no").toString()); + } else if (packageInfo.get("packet_valid_name").toString().equals("年")) { + int year = Integer.parseInt(packageInfo.get("packet_valid_time").toString()); + LocalDate localDate = this.setYearEndTime(resMap.get("activateDate").toString(), year); + //修改 卡信息到期日期 + Map setCardMap = new HashMap<>(); + setCardMap.put("endTime", localDate + " 23:59:59"); + setCardMap.put("iccid", resMap.get("iccid")); + setCardMap.put("remaining", packageInfo.get("error_flow")); + cardMapper.updateEndTime(setCardMap); + resMap.put("endTime", localDate + " 23:59:59"); + this.insertFlow(packageInfo, resMap); + yzOrderMapper.updateAddPackage(1, resMap.get("ord_no").toString()); + } + } + } + } catch (Exception e) { + return AjaxResult.error(e.getMessage()); + } + return AjaxResult.success(); + } + + private AjaxResult nextMonth(Map parammap) { + try { + //根据startNo 和 endNo 去查询订单当中加包或未加包的 + List> notAddCard = yzOrderMapper.nextMonth(parammap); + if (notAddCard.size() == 0) { + return AjaxResult.error("该卡无此类型生效订单 !"); + } + for (Map resMap : notAddCard) { + //取出来加包未加包的订单,去过滤掉当月已完成定购的 + Integer aPackage = yzCardFlowMapper.filterIsAddPackage(resMap.get("iccid").toString()); + //如果未订购,走加包流程 + if (aPackage == 0) { + Map packageInfo = packetMapper.selPackageInfo(resMap); + if (packageInfo.get("packet_valid_name").toString().equals("月")) { + int month = Integer.parseInt(packageInfo.get("packet_valid_time").toString()); + //获取到期日期 + LocalDate localDate = this.setNextMonthEndTime(resMap.get("createTime").toString(), month); + //修改 卡信息到期日期 + Map cardMap = new HashMap<>(); + cardMap.put("endTime", localDate + " 23:59:59"); + cardMap.put("iccid", resMap.get("iccid")); + cardMap.put("remaining", packageInfo.get("error_flow")); + cardMapper.updateEndTime(cardMap); + resMap.put("endTime", localDate + " 23:59:59"); + this.insertFlow(packageInfo, resMap); + yzOrderMapper.updateAddPackage(1, resMap.get("ord_no").toString()); + } else if (packageInfo.get("packet_valid_name").toString().equals("年")) { + int year = Integer.parseInt(packageInfo.get("packet_valid_time").toString()); + LocalDate localDate = this.setYearNextMonthEndTime(resMap.get("createTime").toString(), year); + //修改 卡信息到期日期 + Map setCardMap = new HashMap<>(); + setCardMap.put("endTime", localDate + " 23:59:59"); + setCardMap.put("iccid", resMap.get("iccid")); + setCardMap.put("remaining", packageInfo.get("error_flow")); + cardMapper.updateEndTime(setCardMap); + resMap.put("endTime", localDate + " 23:59:59"); + this.insertFlow(packageInfo, resMap); + yzOrderMapper.updateAddPackage(1, resMap.get("ord_no").toString()); + } + } + } + } catch (Exception e) { + return AjaxResult.error(e.getMessage()); + } + return AjaxResult.success(); + } + + private AjaxResult periodicExtension(Map parammap) { + try { + //根据startNo 和 endNo 去查询订单当中加包或未加包的 + List> notAddCard = yzOrderMapper.periodicExtension(parammap); + if (notAddCard.size() == 0) { + return AjaxResult.error("该卡无此类型生效订单 !"); + } + for (Map resMap : notAddCard) { + if (StringUtils.isNotNull(resMap.get("endTime"))) { + Map packageInfo = packetMapper.selPackageInfo(resMap); + if (packageInfo.get("packet_valid_name").toString().equals("月")) { + int month = Integer.parseInt(packageInfo.get("packet_valid_time").toString()); + //获取到期日期 + LocalDate localDate = this.setOnlyMonthEndTime(resMap.get("endTime").toString(), month); + //修改 卡信息到期日期 + Map cardMap = new HashMap<>(); + cardMap.put("endTime", localDate + " 23:59:59"); + cardMap.put("iccid", resMap.get("iccid")); + cardMap.put("remaining", packageInfo.get("error_flow")); + cardMapper.updateEndTime(cardMap); + resMap.put("endTime", localDate + " 23:59:59"); + this.insertFlow(packageInfo, resMap); + yzOrderMapper.updateAddPackage(1, resMap.get("ord_no").toString()); + } else if (packageInfo.get("packet_valid_name").toString().equals("年")) { + int year = Integer.parseInt(packageInfo.get("packet_valid_time").toString()); + LocalDate localDate = this.setOnlyYearEndTime(resMap.get("endTime").toString(), year); + //修改 卡信息到期日期 + Map setCardMap = new HashMap<>(); + setCardMap.put("endTime", localDate + " 23:59:59"); + setCardMap.put("iccid", resMap.get("iccid")); + setCardMap.put("remaining", packageInfo.get("error_flow")); + cardMapper.updateEndTime(setCardMap); + resMap.put("endTime", localDate + " 23:59:59"); + this.insertFlow(packageInfo, resMap); + yzOrderMapper.updateAddPackage(1, resMap.get("ord_no").toString()); + } + } + } + } catch (Exception e) { + return AjaxResult.error(e.getMessage()); + } + return AjaxResult.success(); + } + + private AjaxResult currentMonth(Map parammap) { + try { + //根据startNo 和 endNo 去查询订单当中加包或未加包的 + List> notAddCard = yzOrderMapper.filterNotAddCard(parammap); + if (notAddCard.size() == 0) { + return AjaxResult.error("该卡无此类型生效订单 !"); + } + for (Map resMap : notAddCard) { + //取出来加包未加包的订单,去过滤掉当月已完成定购的 + Integer aPackage = yzCardFlowMapper.filterIsAddPackage(resMap.get("iccid").toString()); + //如果未订购,走加包流程 + if (aPackage == 0) { + Map packageInfo = packetMapper.selPackageInfo(resMap); + if (packageInfo.get("packet_valid_name").toString().equals("月")) { + int month = Integer.parseInt(packageInfo.get("packet_valid_time").toString()); + //获取到期日期 + LocalDate localDate = this.setMonthEndTime(resMap.get("createTime").toString(), month); + //修改 卡信息到期日期 + Map cardMap = new HashMap<>(); + cardMap.put("endTime", localDate + " 23:59:59"); + cardMap.put("iccid", resMap.get("iccid")); + cardMap.put("remaining", packageInfo.get("error_flow")); + cardMapper.updateEndTime(cardMap); + resMap.put("endTime", localDate + " 23:59:59"); + this.insertFlow(packageInfo, resMap); + yzOrderMapper.updateAddPackage(1, resMap.get("ord_no").toString()); + } else if (packageInfo.get("packet_valid_name").toString().equals("年")) { + int year = Integer.parseInt(packageInfo.get("packet_valid_time").toString()); + LocalDate localDate = this.setYearEndTime(resMap.get("createTime").toString(), year); + //修改 卡信息到期日期 + Map setCardMap = new HashMap<>(); + setCardMap.put("endTime", localDate + " 23:59:59"); + setCardMap.put("iccid", resMap.get("iccid")); + setCardMap.put("remaining", packageInfo.get("error_flow")); + cardMapper.updateEndTime(setCardMap); + resMap.put("endTime", localDate + " 23:59:59"); + this.insertFlow(packageInfo, resMap); + yzOrderMapper.updateAddPackage(1, resMap.get("ord_no").toString()); + } + } + } + } catch (Exception e) { + return AjaxResult.success(e.getMessage().toString()); + } + return AjaxResult.success(); + } + + private void insertFlow(Map packageInfo, Map parammap) { + Map insertMap = new HashMap<>(); + insertMap.put("package_id", packageInfo.get("package_id").toString()); + insertMap.put("packet_id", packageInfo.get("packet_id")); + insertMap.put("ord_no", parammap.get("ord_no")); + insertMap.put("true_flow", packageInfo.get("packet_flow")); + insertMap.put("error_flow", packageInfo.get("error_flow")); + insertMap.put("start_time", VeDate.getStringDate()); + insertMap.put("end_time", parammap.get("endTime")); + insertMap.put("ord_type", "1"); + insertMap.put("status", "1"); + insertMap.put("packet_type", "0"); + insertMap.put("use_flow", 0); + insertMap.put("iccid", parammap.get("iccid").toString()); + insertMap.put("error_time", packageInfo.get("error_so")); + insertMap.put("validate_type", "0"); + insertMap.put("validate_time", ""); + yzCardFlowMapper.insertFlow(insertMap); + } + + private LocalDate setYearEndTime(String addTime, int years) { + String replace = addTime.replace("-", ""); + Integer year = Integer.valueOf(replace.substring(0, 4).toString()); + Integer month = Integer.valueOf(replace.substring(4, 6).toString()); + Integer day = Integer.valueOf(replace.substring(6, 8).toString()); + // 设置基准日期 + LocalDate baseDate = LocalDate.of(year, month, day); + // 增加X个月 + LocalDate localDate = baseDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()); + LocalDate expiryDate = localDate.plusYears(years); + return expiryDate; + } + + private LocalDate setMonthEndTime(String addTime, int monthTime) { + String replace = addTime.replace("-", ""); + Integer year = Integer.valueOf(replace.substring(0, 4).toString()); + Integer month = Integer.valueOf(replace.substring(4, 6).toString()); + Integer day = Integer.valueOf(replace.substring(6, 8).toString()); + // 设置基准日期 + LocalDate baseDate = LocalDate.of(year, month, day); + // 增加X个月 + LocalDate localDate = baseDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()); + LocalDate expiryDate = localDate.plusMonths(monthTime); + return expiryDate; + } + + private LocalDate setOnlyYearEndTime(String endTime, int years) { + String replace = endTime.replace("-", ""); + Integer year = Integer.valueOf(replace.substring(0, 4).toString()); + Integer month = Integer.valueOf(replace.substring(4, 6).toString()); + Integer day = Integer.valueOf(replace.substring(6, 8).toString()); + // 设置基准日期 + LocalDate baseDate = LocalDate.of(year, month, day); + // 增加X个月 +// LocalDate localDate = baseDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()); + LocalDate expiryDate = baseDate.plusYears(years); + return expiryDate; + } + + private LocalDate setOnlyMonthEndTime(String endTime, int monthTime) { + String replace = endTime.replace("-", ""); + Integer year = Integer.valueOf(replace.substring(0, 4).toString()); + Integer month = Integer.valueOf(replace.substring(4, 6).toString()); + Integer day = Integer.valueOf(replace.substring(6, 8).toString()); + // 设置基准日期 + LocalDate baseDate = LocalDate.of(year, month, day); + // 增加X个月 +// LocalDate localDate = baseDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()); + LocalDate expiryDate = baseDate.plusMonths(monthTime); + return expiryDate; + } + + private LocalDate setYearNextMonthEndTime(String createTime, int years) { + String replace = createTime.replace("-", ""); + Integer year = Integer.valueOf(replace.substring(0, 4).toString()); + Integer month = Integer.valueOf(replace.substring(4, 6).toString()); + Integer day = Integer.valueOf(replace.substring(6, 8).toString()); + // 设置基准日期 + LocalDate baseDate = LocalDate.of(year, month, day); + // 增加X个年 + LocalDate expiryDate = baseDate.plusYears(years); + LocalDate localDate = expiryDate.plusMonths(1); + return localDate; + } + + private LocalDate setNextMonthEndTime(String createTime, int monthTime) { + String replace = createTime.replace("-", ""); + Integer year = Integer.valueOf(replace.substring(0, 4).toString()); + Integer month = Integer.valueOf(replace.substring(4, 6).toString()); + Integer day = Integer.valueOf(replace.substring(6, 8).toString()); + // 设置基准日期 + LocalDate baseDate = LocalDate.of(year, month, day); + // 增加X个月 + LocalDate expiryDate = baseDate.plusMonths(monthTime + 1); + return expiryDate; + } + + @Override + public AjaxResult addPackage(MultipartFile file) { + String filename = file.getOriginalFilename(); + String ReadName = UUID.randomUUID().toString().replace("-", "") + filename; + String flieUrlRx = "/mnt/file/"; + ReadName = flieUrlRx + ReadName; + try { + File file2 = new File(""); + String filePath = file2.getCanonicalPath(); + File newFile = new File(filePath + ReadName); + File Url = new File(filePath + flieUrlRx + "1.txt");//tomcat 生成路径 + Upload.mkdirsmy(Url); + file.transferTo(newFile); + String path = filePath + ReadName; + ExcelConfig excelConfig = new ExcelConfig(); + String columns[] = {"iccid", "validateType"}; + List> list = excelConfig.getExcelListMap(path, columns, 0L); + System.err.println(list); + if (list.size() > 10000) { + return AjaxResult.error("加包卡总数大于10000张,请调整后重试 !"); + } + if (list.size() > 0) { + for (Map resMap : list) { + Map map = new HashMap<>(); + map.put("startNo", resMap.get("iccid").toString()); + map.put("endNo", resMap.get("iccid").toString()); + //根据Excel中的validateType去调用接口 + if (resMap.get("validateType").toString().equals("1")) { + this.currentMonth(map); + } else if (resMap.get("validateType").toString().equals("2")) { + this.nextMonth(map); + } else if (resMap.get("validateType").toString().equals("3")) { + this.periodicExtension(map); + } else if (resMap.get("validateType").toString().equals("4")) { + this.activateEffect(map); + } + } + } + } catch (Exception e) { + return AjaxResult.error(e.getMessage()); + } + return AjaxResult.success(); + } + + public static void main(String[] args) { + String replace = "2023-08-01".replace("-", ""); + Integer year = Integer.valueOf(replace.substring(0, 4).toString()); + Integer month = Integer.valueOf(replace.substring(4, 6).toString()); + Integer day = Integer.valueOf(replace.substring(6, 8).toString()); + // 设置基准日期 + LocalDate baseDate = LocalDate.of(year, month, day); + // 增加X个月 + LocalDate localDate = baseDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()); + LocalDate expiryDate = localDate.plusMonths(6); + String s = expiryDate + " 23:59:59"; + System.err.println(s); + } +} \ No newline at end of file diff --git a/yunze-system/src/main/java/com/yunze/system/service/impl/yunze/YzCardServiceImpl.java b/yunze-system/src/main/java/com/yunze/system/service/impl/yunze/YzCardServiceImpl.java index 156bd528e6beb7b74ec4f9f06673290a16615817..8e31bc8e50c18006d2abe41c0c90e5c12bd36a72 100644 --- a/yunze-system/src/main/java/com/yunze/system/service/impl/yunze/YzCardServiceImpl.java +++ b/yunze-system/src/main/java/com/yunze/system/service/impl/yunze/YzCardServiceImpl.java @@ -2,6 +2,11 @@ package com.yunze.system.service.impl.yunze; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Maps; +import com.yunze.apiCommon.upstreamAPI.DianXinCMP5G.Inquire.Query_DX5G; +import com.yunze.apiCommon.upstreamAPI.YiDongEC.Inquire.Query_YD; +import com.yunze.apiCommon.utils.Arith; import com.yunze.apiCommon.utils.InternalApiRequest; import com.yunze.common.config.RabbitMQConfig; import com.yunze.common.core.domain.AjaxResult; @@ -17,6 +22,7 @@ import com.yunze.common.mapper.yunze.card.YzCardApiOfferinginfolistMapper; import com.yunze.common.mapper.yunze.card.YzCardUsageReminderMapper; import com.yunze.common.mapper.yunze.commodity.YzWxByProductAgentMapper; import com.yunze.common.utils.ServletUtils; +import com.yunze.common.utils.StringUtils; import com.yunze.common.utils.ip.IpUtils; import com.yunze.common.utils.yunze.*; import com.yunze.system.mapper.SysDeptMapper; @@ -24,6 +30,7 @@ import com.yunze.system.mapper.SysDictDataMapper; import com.yunze.system.mapper.SysUserMapper; import com.yunze.system.service.yunze.IYzCardService; import com.yunze.system.service.yunze.IYzUserService; +import org.apache.commons.compress.utils.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.amqp.AmqpException; @@ -36,6 +43,7 @@ import javax.annotation.Resource; import java.io.File; import java.io.IOException; import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.concurrent.TimeUnit; @@ -1460,12 +1468,143 @@ public class YzCardServiceImpl implements IYzCardService { } + @Override + public AjaxResult distinguishCardType(String query) { + //区分运营商类型 移动、电信 + JSONObject object1 = JSON.parseObject(query); + List objects = new ArrayList<>(); + Map map = Maps.newHashMap(); + ArrayList dates = Lists.newArrayList(); + ArrayList usage = Lists.newArrayList(); + Double Use = 0d;//使用量 MB + //获取卡信息 + Map route = yzCardMapper.findRoute(object1); + if (StringUtils.isNull(route)) { + return AjaxResult.error("未找到相关信息"); + } + if (route.get("cd_code").toString().contains("YiDong")) { + Query_YD quer = new Query_YD(route, "YiDong_EC"); + // 获取当前日期 + LocalDate today = LocalDate.now(); + // 计算昨天 + LocalDate yesterday = today.minusDays(1); + // 创建一个列表来存储日期 + List dateList = new ArrayList<>(); + // 从昨天开始,遍历7天 + for (int i = 0; i < 7; i++) { + dateList.add(yesterday.minusDays(i)); + } + // 打印日期列表 + for (LocalDate date : dateList) { + Object replace = date.toString().replace("-", ""); + String dayUsage = quer.selDayUsage(object1.get("iccid").toString(), replace.toString()); + JSONObject day = JSONObject.parseObject(dayUsage.toString()); + if (day.get("status").toString().equals("0")) { + Map result = ((List>) day.get("result")).get(0); + Map dataAmountList = ((List>) result.get("dataAmountList")).get(0); + if (dataAmountList.get("dataAmount").toString().equals("")) { + Use = 0d; + usage.add(Use); + dates.add(date.toString().substring(5, 10)); + } else { + double kb = Double.parseDouble(dataAmountList.get("dataAmount").toString()); + Use = Arith.formatToTwo(Arith.div(kb, 1024));//KB 转 MB + usage.add(Use); + dates.add(date.toString().substring(5, 10)); + } + } + } + map.put("day", dates); + map.put("usage", usage); + } else if (route.get("cd_code").toString().contains("DianXin")) { + Query_DX5G dx5G = new Query_DX5G(route); + // 获取当前日期 + LocalDate today = LocalDate.now(); + // 计算昨天 + LocalDate yesterday = today.minusDays(1); + // 创建一个列表来存储日期 + List dateList = new ArrayList<>(); + // 从昨天开始,遍历7天 + for (int i = 0; i < 7; i++) { + dateList.add(yesterday.minusDays(i)); + } + Map stringObjectMap = new HashMap<>(); + for (LocalDate date : dateList) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); + String dateString = date.format(formatter); + stringObjectMap = dx5G.queryTrafficByDate(object1.get("iccid").toString(), dateString, dateString); + String total_bytes_cnt = stringObjectMap.get("total_bytes_cnt").toString(); + int len = total_bytes_cnt.length(); + total_bytes_cnt = total_bytes_cnt.substring(0, len - 2); + Use = Double.parseDouble(total_bytes_cnt); + usage.add(Use); + dates.add(date.toString().substring(5, 10)); + } + objects.add(route.get("card_no").toString()); + map.put("day", dates); + map.put("usage", usage); + } + return AjaxResult.success(map); + } + @Override + public AjaxResult cardMonthUsage(String query) { + //区分运营商类型 移动、电信 + JSONObject object1 = JSON.parseObject(query); + Map map = Maps.newHashMap(); + ArrayList dates = Lists.newArrayList(); + ArrayList usage = Lists.newArrayList(); + Double Use = 0d;//使用量 MB + //获取卡信息 + Map route = yzCardMapper.findRoute(object1); + if (StringUtils.isNull(route)) { + return AjaxResult.error("未找到相关信息"); + } + if (route.get("cd_code").toString().contains("YiDong")) { + Query_YD quer = new Query_YD(route, "YiDong_EC"); + // 获取当前日期(但我们只关心月份和年份) + LocalDate currentDate = LocalDate.now(); + // 设置日期格式器 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); + // 打印从当前月份开始,包括当前月份,并往前推六个月的每个月份 + for (int i = 0; i <= 6; i++) { + // 减去相应的月份数(从0开始,所以包括当前月份) + LocalDate previousOrCurrentMonth = currentDate.minusMonths(i); + dates.add(previousOrCurrentMonth.format(formatter).toString()); + // 打印格式化的月份和年份 + Object resDates = quer.newDesignatedMonth(object1.get("iccid").toString(), previousOrCurrentMonth.format(formatter).toString().replace("-", "")); + JSONObject resDate = JSONObject.parseObject(resDates.toString()); + Map dataAmountList = ((List>) resDate.get("result")).get(0); + Map Obj = ((List>) dataAmountList.get("dataAmountList")).get(0); + double kb = Double.parseDouble(Obj.get("dataAmount").toString()); + Use = Arith.formatToTwo(Arith.div(kb, 1024));//KB 转 MB + usage.add(Use); + } + map.put("day", dates); + map.put("usage", usage); + }else if (route.get("cd_code").toString().contains("DianXin")) { + return AjaxResult.error("暂未开放 !"); +// Query_DX5G dx5G = new Query_DX5G(route); +// // 获取当前日期(但我们只关心月份和年份) +// LocalDate currentDate = LocalDate.now(); +// // 设置日期格式器 +// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM"); +// String stringObjectMap = dx5G.batchQryFlowByMonth(route.get("card_no").toString(), "202406"); +// System.err.println(stringObjectMap); +// // 打印从当前月份开始,包括当前月份,并往前推六个月的每个月份 +// for (int i = 0; i <= 6; i++) { +// // 减去相应的月份数(从0开始,所以包括当前月份) +// LocalDate previousOrCurrentMonth = currentDate.minusMonths(i); +// Object format = previousOrCurrentMonth.format(formatter); +// dates.add(format.toString()); +// } +// map.put("day", dates); +// map.put("usage", usage); + } - - - + return AjaxResult.success(map); + } private void sendGetOpenDate(Map map){ diff --git a/yunze-system/src/main/java/com/yunze/system/service/yunze/IYzCardService.java b/yunze-system/src/main/java/com/yunze/system/service/yunze/IYzCardService.java index a039c90a793da6ed8d71c52bce7dda2579b904c9..4019baa66efb595b58dcd5a2a354eb8b6d6ed5a8 100644 --- a/yunze-system/src/main/java/com/yunze/system/service/yunze/IYzCardService.java +++ b/yunze-system/src/main/java/com/yunze/system/service/yunze/IYzCardService.java @@ -1,6 +1,7 @@ package com.yunze.system.service.yunze; +import com.yunze.common.core.domain.AjaxResult; import com.yunze.common.core.domain.entity.SysUser; import org.springframework.web.multipart.MultipartFile; @@ -305,6 +306,7 @@ public interface IYzCardService public String smsCC(MultipartFile file, Map map); + AjaxResult distinguishCardType(String query); - + AjaxResult cardMonthUsage(String query); } diff --git a/yunze-ui/src/api/yunze/flowcard/usage.js b/yunze-ui/src/api/yunze/flowcard/usage.js new file mode 100644 index 0000000000000000000000000000000000000000..e4b5dfe01b47e158323cb37a373c4d6bf79e8db4 --- /dev/null +++ b/yunze-ui/src/api/yunze/flowcard/usage.js @@ -0,0 +1,17 @@ +import request from '@/utils/request' + +// 查询生成表数据 +export function listUsage(query) { + return request({ + url: '/usage/cardUsage', + method: 'post', + data: query + }) +} +export function cardMonthUsage(query) { + return request({ + url: '/usage/cardMonthUsage', + method: 'post', + data: query + }) +} diff --git a/yunze-ui/src/api/yunze/order/order.js b/yunze-ui/src/api/yunze/order/order.js index 91b03a0a5b5e8288c8fe7c7c95d0f9b03ce38b97..26f42f9f86389ee8d6a77229e3ed6c45c076edb5 100644 --- a/yunze-ui/src/api/yunze/order/order.js +++ b/yunze-ui/src/api/yunze/order/order.js @@ -123,3 +123,10 @@ export function orderAudit(query) { data: query }) } +export function handAddPackage(query) { + return request({ + url: '/hand/addPackage', + method: 'post', + data: query + }) +} diff --git a/yunze-ui/src/main.js b/yunze-ui/src/main.js index 01b536da9c65fa8c7865c5a2201e551bbfaa3d10..c7692ab9a58f6e5aa674a2a0221eacfdde0493ff 100644 --- a/yunze-ui/src/main.js +++ b/yunze-ui/src/main.js @@ -22,7 +22,8 @@ import Pagination from "@/components/Pagination"; // 自定义表格工具扩展 import RightToolbar from "@/components/RightToolbar" import qrcode from './utils/yunze/qrcode'//二维码生成 - +import * as echarts from 'echarts';//引入echarts +Vue.prototype.$echarts = echarts //引入组件 // 全局方法挂载 Vue.prototype.getDicts = getDicts diff --git a/yunze-ui/src/views/yunze/flowcard/usageReport/index.vue b/yunze-ui/src/views/yunze/flowcard/usageReport/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..05b0e6fe3d93c809b88f36bb9e13dd3a3bc5cdd4 --- /dev/null +++ b/yunze-ui/src/views/yunze/flowcard/usageReport/index.vue @@ -0,0 +1,314 @@ + + + diff --git a/yunze-ui/src/views/yunze/order/orderTariff/index.vue b/yunze-ui/src/views/yunze/order/orderTariff/index.vue index ea0d7d050e0b46047dc27818f371196bc1e9ef11..511c5a9c7c8852e417bb58bcbb9af3fac6a8a28b 100644 --- a/yunze-ui/src/views/yunze/order/orderTariff/index.vue +++ b/yunze-ui/src/views/yunze/order/orderTariff/index.vue @@ -15,9 +15,10 @@
展开/折叠 - 全选/全不选 - 父子联动 - + 全选/全不选 + + 父子联动 + + :props="defaultProps"/>
- + @@ -93,7 +94,7 @@ /> - + - - + - + - + - + - - 检索类型 + + 检索类型 - + - + - + - + @@ -315,7 +316,8 @@ @click="switchMode"> - + - 公司所属 + 公司所属 导出 + >导出 + @@ -377,7 +380,8 @@ size="mini" @click="Unsubscribe" v-hasPermi="['yunze:order:nobscribe']" - >退订 + >退订 + @@ -389,6 +393,14 @@ @click="ShowUpdInfo()" >勾选操作 + 手动加包 + @@ -400,113 +412,127 @@ style="width: 110px;" >操作 - - 执行加包 - 充值审核 - + + + 充值审核 + - - + - - + + - - - - - - - - - - - - - - - - - -