From de6b1898b4ff8579adde95a37ff0b411d17f5536 Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期二, 19 八月 2025 14:26:58 +0800 Subject: [PATCH] update --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 46 insertions(+), 9 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java index 5d2088e..e5cd5b0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java @@ -335,8 +335,10 @@ throw new ServiceException("公司不存在"); } String link = companyInfo.getLink(); - String[] split = link.split("="); - JSONObject jsonObject=getReport(split[split.length-1]); + if(link==null){ + return R.ok(changeVO); + } + JSONObject jsonObject=getReport(extractSnFromUrl(link)); // JSONObject jsonObject=getReport("ZZD20250508017232394218445"); if (!"1001".equals(jsonObject.getString("code"))){ return R.fail(jsonObject.get("msg")); @@ -356,6 +358,36 @@ return R.ok(changeVO); } + /** + * 从URL中提取sn参数 + * @param url 包含sn参数的URL + * @return sn参数值 + */ + public static String extractSnFromUrl(String url) { + if (url == null || url.isEmpty()) { + return null; + } + + // 查找sn参数的位置 + String snParam = "sn="; + int startIndex = url.indexOf(snParam); + + if (startIndex == -1) { + return null; // 未找到sn参数 + } + + // 计算sn值的起始位置 + startIndex += snParam.length(); + + // 查找sn值的结束位置(遇到&或字符串结束) + int endIndex = url.indexOf("&", startIndex); + if (endIndex == -1) { + endIndex = url.length(); + } + + // 提取并返回sn值 + return url.substring(startIndex, endIndex); + } @Override public R tax(String id) { @@ -365,8 +397,10 @@ throw new ServiceException("公司不存在"); } String link = companyInfo.getLink(); - String[] split = link.split("="); - JSONObject jsonObject=getReport(split[split.length-1]); + if (link == null) { + return R.ok(taxVO); + } + JSONObject jsonObject=getReport(extractSnFromUrl(link)); // JSONObject jsonObject=getReport("ZZD20250508017232394218445"); if (!"1001".equals(jsonObject.getString("code"))){ return R.fail(jsonObject.get("msg")); @@ -472,8 +506,10 @@ throw new ServiceException("公司不存在"); } String link = companyInfo.getLink(); - String[] split = link.split("="); - JSONObject jsonObject=getReport(split[split.length-1]); + if(link==null){ + return R.ok(vo); + } + JSONObject jsonObject=getReport(extractSnFromUrl(link)); // JSONObject jsonObject=getReport("ZZD20250508017232394218445"); if (!"1001".equals(jsonObject.getString("code"))){ return R.fail(jsonObject.get("msg")); @@ -486,9 +522,10 @@ //近一个月开票金额(元) JSONArray f4yPer1mDownFpInfoList = (JSONArray) invoiceInfo.get("f4yPer1mDownFpInfoList"); - JSONObject f4yPer1mDownFpInfo1 = (JSONObject) f4yPer1mDownFpInfoList.get(1); - vo.setHjjeZc1( ObjectToBigDecimal(f4yPer1mDownFpInfo1.get("hjjeZc")) ); - + if(f4yPer1mDownFpInfoList!=null){ + JSONObject f4yPer1mDownFpInfo1 = (JSONObject) f4yPer1mDownFpInfoList.get(1); + vo.setHjjeZc1( ObjectToBigDecimal(f4yPer1mDownFpInfo1.get("hjjeZc")) ); + } JSONObject fpPrevMnMthsDownFpInfoList = (JSONObject) invoiceInfo.get("fpPrevMnMthsDownFpInfoList"); JSONObject fpPrev3mthsDownFpInfoList = (JSONObject) fpPrevMnMthsDownFpInfoList.get("fpPrev3mthsDownFpInfoList"); -- Gitblit v1.7.1