From 147bb6e9e40a122ca5d9c61965d9e70426bb146c Mon Sep 17 00:00:00 2001
From: kk <1910333201@qq.com>
Date: Wed, 25 Oct 2023 16:41:59 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E5=AD=97=E7=94=B3=E8=AF=B7=E8=A1=A8?=
=?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
doc/配置文件 | 5 +
.../src/main/resources/logback-spring.xml | 94 +++++++++
...noConsoleInvoiceApiZhongQiServiceImpl.java | 180 +++++++-----------
3 files changed, 165 insertions(+), 114 deletions(-)
create mode 100644 doc/配置文件
create mode 100644 jianshui-admin/src/main/resources/logback-spring.xml
diff --git a/doc/配置文件 b/doc/配置文件
new file mode 100644
index 0000000..30f7586
--- /dev/null
+++ b/doc/配置文件
@@ -0,0 +1,5 @@
+Prop配置文件:
+
+aisino_callback_url 重汽回调URL
+aisino_nginx_url 重汽nginx地址
+aisino_upload_url 重汽上传推送机动车接口
\ No newline at end of file
diff --git a/jianshui-admin/src/main/resources/logback-spring.xml b/jianshui-admin/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..4260665
--- /dev/null
+++ b/jianshui-admin/src/main/resources/logback-spring.xml
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+ ${log.pattern}
+
+
+
+
+
+ ${log.path}/sys-info.log
+
+
+
+ ${log.path}/sys-info.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ INFO
+
+ ACCEPT
+
+ DENY
+
+
+
+
+ ${log.path}/sys-error.log
+
+
+
+ ${log.path}/sys-error.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ ERROR
+
+ ACCEPT
+
+ DENY
+
+
+
+
+
+ ${log.path}/sys-user.log
+
+
+ ${log.path}/sys-user.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/AisinoConsoleInvoiceApiZhongQiServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/AisinoConsoleInvoiceApiZhongQiServiceImpl.java
index e74dc3a..35939d2 100644
--- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/AisinoConsoleInvoiceApiZhongQiServiceImpl.java
+++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/AisinoConsoleInvoiceApiZhongQiServiceImpl.java
@@ -2,23 +2,23 @@ package com.jianshui.invoice.service.impl.api;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
+import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.core.domain.entity.Companyservice;
+import com.jianshui.common.core.domain.entity.CompanyserviceDetail;
import com.jianshui.common.enums.ErrorCode;
import com.jianshui.common.exception.jianshui.JianshuiParamErrorException;
import com.jianshui.common.exception.jianshui.JianshuiServiceException;
-import com.jianshui.common.utils.BeanToMapUtils;
-import com.jianshui.common.utils.StringUtils;
-import com.jianshui.common.utils.TimeUtil;
-import com.jianshui.common.utils.ValidateUtils;
+import com.jianshui.common.utils.*;
import com.jianshui.common.utils.spring.SpringUtils;
import com.jianshui.common.utils.uuid.IdUtils;
import com.jianshui.invoice.constant.aisino.console.AisinoConsoleConstants;
@@ -51,6 +51,8 @@ import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
@@ -778,46 +780,21 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer
@Override
public HXResponse downloadRedInfo(DownloadRedInfoDTO downloadRedInfoDTO, Companyservice companyservice) {
- // 查找之前的红票
- Redinfo redinfo = new Redinfo();
- redinfo.setRedInfoNo(downloadRedInfoDTO.getBillInfoNo());
- redinfo.setCompanyId(companyservice.getCompanyid());
- QueryWrapper queryWrapper = new QueryWrapper<>();
- if (StringUtils.isNotEmpty(downloadRedInfoDTO.getInvoiceLine())) {
- queryWrapper.eq("invoice_type", downloadRedInfoDTO.getInvoiceLine());
- }
- if (StringUtils.isNotEmpty(downloadRedInfoDTO.getBuyerTaxNo())) {
- queryWrapper.eq("buyer_taxnum", downloadRedInfoDTO.getBuyerTaxNo());
- }
- if (StringUtils.isNotEmpty(downloadRedInfoDTO.getExtensionNumber())) {
- queryWrapper.eq("fjh", downloadRedInfoDTO.getExtensionNumber());
- }
- if (StringUtils.isNotEmpty(downloadRedInfoDTO.getTerminalNumber())) {
- queryWrapper.eq("terminal_number", downloadRedInfoDTO.getTerminalNumber());
- }
- if (StringUtils.isNotEmpty(downloadRedInfoDTO.getBillTimeBegin())) {
- queryWrapper.ge("bill_input_time", downloadRedInfoDTO.getBillTimeBegin());
- }
- if (StringUtils.isNotEmpty(downloadRedInfoDTO.getBillTimeEnd())) {
- queryWrapper.le("bill_input_time", downloadRedInfoDTO.getBillTimeEnd());
- }
- if (StringUtils.isNotEmpty(downloadRedInfoDTO.getBillNo())) {
- queryWrapper.le("out_trade_orderno", downloadRedInfoDTO.getBillNo());
- }
- queryWrapper.orderByDesc("id");
- queryWrapper.last(" limit 1 ");
- Redinfo redInfoResult = redinfoMapper.selectOne(queryWrapper);
- if (redInfoResult == null) {
- HXResponse response = new HXResponse("9999", "未查到指定红字信息");
- return response;
+
+ List companyserviceDetailList = companyservice.getCompanyserviceDetailList();
+ if(CollectionUtils.isEmpty(companyserviceDetailList) || StrUtil.isEmpty(companyserviceDetailList.get(0).getGoldenTaxDiskNo())){
+ throw new JianshuiServiceException("金税盘编号未配置,请联系管理员!");
}
+ String goldenTaxDiskNo = companyserviceDetailList.get(0).getGoldenTaxDiskNo();
// 组装报文
- AisinoConsoleInvoiceRedDownloadDTO downloadDTO = BeanUtil.copyProperties(redInfoResult, AisinoConsoleInvoiceRedDownloadDTO.class);
+ AisinoConsoleInvoiceRedDownloadDTO downloadDTO = BeanUtil.copyProperties(downloadRedInfoDTO, AisinoConsoleInvoiceRedDownloadDTO.class);
downloadDTO.setYQZT("N");
downloadDTO.setXXBFW("0");
downloadDTO.setPAGENO("1");
downloadDTO.setPAGESIZE("1000");
+ downloadDTO.setNSRSBH(companyservice.getSellertax());
+ downloadDTO.setSBBH(goldenTaxDiskNo);
String param = JSONUtil.toXmlStr(JSONUtil.parse(downloadDTO));
param = "\n" +
@@ -844,9 +821,6 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer
String retcode = resultJSON.get("retcode") != null ? resultJSON.get("retcode").toString() : "";
String retmsg = resultJSON.get("retmsg") != null ? resultJSON.get("retmsg").toString() : "";
- // todo-k: 下载的返回报文需要单独处理,更新信息表状态?
- // todo-k: 返回的格式看看怎么处理一把,VO都已经创建
-
if (!StringUtils.equals("0000", retcode)) {
return new HXResponse(retmsg);
@@ -1016,8 +990,10 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer
// 发起请求
AjaxResult ajaxResult = null;
+
+ JSON json = JSONUtil.parse(decryptResult);
try {
- ajaxResult = AisinoConsoleUtil.sendRequest(AisinoConsoleConstants.VEHIC, JSONUtil.parse(decryptResult), companyservice);
+ ajaxResult = AisinoConsoleUtil.sendRequest(AisinoConsoleConstants.VEHIC, json, companyservice);
} catch (Exception e) {
log.error("【销项发票】【总部控制台接口】【机动车加密】发票请求异常,请求报文{},销方信息{}", JSONUtil.parse(decryptResult).toString(), JSONObject.toJSONString(companyservice));
e.printStackTrace();
@@ -1036,13 +1012,40 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer
if("0".equals(retcode)){
- // TODO: 2023/10/24 读取nginx地址,读取数据。
- String indexPage = HttpUtil.get("http://localhost:8082/");
+ // TODO: 2023/10/25 机动车加密数据导出推送
+ /**
+ * 推送逻辑:
+ * 调用加密接口,调用成功后推送,推送中间状态断了停止推送
+ * 否则获取到推送结果之后停止推送
+ * 需要个手动重推的操作。
+ */
+
+ ICompanyservicePropService companyserviceProp = SpringUtils.getBean(ICompanyservicePropService.class);
+ CompanyserviceProp secretIdProp = companyserviceProp.selectPropByKey(companyservice.getCompanyid(), "aisino_nginx_url");
+
+ if(secretIdProp == null || StrUtil.isEmpty(secretIdProp.getValue())){
+ log.info("【销项发票】【总部控制台发票-机动车加密】推送nginx地址未配置!aisino_nginx_url");
+ return new HXResponse("推送中间件地址未配置!");
+ }
+
+ String downloadUrl = secretIdProp.getValue();
- System.out.println(indexPage);
+ cn.hutool.json.JSONObject queryDto = JSONUtil.parseObj(json);
+ if(queryDto == null){
+ log.info("【销项发票】【总部控制台发票-机动车加密】查询条件未获取到!");
+ return new HXResponse("查询条件未获取到!");
+ }
+
+ String indexPage = null;
+ try {
+ indexPage = HttpUtil.get(downloadUrl);
+ } catch (Exception e) {
+ log.info("【销项发票】【总部控制台发票-机动车加密】{}",e);
+ return new HXResponse("中间件读取失败!");
+ }
- String startDate = "2023.10.10";
- String endDate = "2023.10.12";
+ String startDate = queryDto.get("KSRQ") != null ? queryDto.get("KSRQ").toString().replace("-",".") : "";
+ String endDate = queryDto.get("JSRQ") != null ? queryDto.get("JSRQ").toString().replace("-",".") : "";
// 构建要匹配的日期范围字符串
String dateRange = startDate + "-" + endDate;
@@ -1052,95 +1055,44 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer
// 获取带有动态日期范围的标签
Elements aTags = doc.select("a[href*='%28" + dateRange + "%29.dat']");
+ String href = "";
// 遍历标签,提取href属性内容
for (Element aTag : aTags) {
- String href = aTag.attr("href");
+ href = aTag.attr("href");
log.info("读取到的机动车加密文件名为"+href);
continue;
}
- // TODO: 2023/10/24 调用重汽的推送接口
+ File file = FileUtil.file(downloadUrl + href);
+ InputStream inputStream = FileUtil.getInputStream(file);
+ // TODO: 2023/10/24 调用重汽的推送接口
HashMap paramMap = new HashMap<>();
- paramMap.put("File", "");
- paramMap.put("qyjc", "KS");
- paramMap.put("zdr", "");
-
- String result = HttpUtil.post("",paramMap);
+ paramMap.put("File", file);
+ // TODO: 2023/10/25 调整成可配置的简称
+ paramMap.put("qyjc", companyservice.getSellertax());
+ paramMap.put("zdr", companyservice.getCompanyid());
+
+ CompanyserviceProp pushUrl = companyserviceProp.selectPropByKey(companyservice.getCompanyid(), "aisino_upload_url");
+ if(pushUrl == null || StrUtil.isEmpty(pushUrl.getValue())){
+ return new HXResponse("重汽推送机动车地址未设置!");
+ }
+ String result = HttpUtil.post(pushUrl.getValue(),paramMap);
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(result);
String retCode = jsonObject.get("retCode") != null ? jsonObject.get("retCode").toString() : "";
String retMsg = jsonObject.get("retMsg") != null ? jsonObject.get("retMsg").toString() : "";
- if("1".equals(retCode)){
-
- } else if ("0".equals(retCode)) {
-
- }else {
-
- }
-
-
-
-
- return new HXResponse("0000","导出成功!");
+ // 重汽返回接口信息
+ return new HXResponse(retCode,retMsg);
}else {
return new HXResponse("9999","导出失败、发票不存在!");
}
}
- public static void main(String[] args) {
-
- // TODO: 2023/10/24 机动车加密文件读取,搭配nginx
-
- String indexPage = HttpUtil.get("http://localhost:8082/");
-
- System.out.println(indexPage);
-
- String startDate = "2023.10.10";
- String endDate = "2023.10.12";
-
- // 构建要匹配的日期范围字符串
- String dateRange = startDate + "-" + endDate;
- // 使用Jsoup解析HTML
- Document doc = Jsoup.parse(indexPage);
-
- // 获取带有动态日期范围的标签
- Elements aTags = doc.select("a[href*='%28" + dateRange + "%29.dat']");
-
- // 遍历标签,提取href属性内容
- for (Element aTag : aTags) {
- String href = aTag.attr("href");
- log.info("读取到的机动车加密文件名为"+href);
- continue;
- }
- // TODO: 2023/10/24 调用重汽的推送接口
-
- HashMap paramMap = new HashMap<>();
- paramMap.put("File", "");
- paramMap.put("qyjc", "KS");
- paramMap.put("zdr", "");
-
- String result = HttpUtil.post("",paramMap);
-
- cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(result);
-
- String retCode = jsonObject.get("retCode") != null ? jsonObject.get("retCode").toString() : "";
- String retMsg = jsonObject.get("retMsg") != null ? jsonObject.get("retMsg").toString() : "";
-
- if("1".equals(retCode)){
-
- } else if ("0".equals(retCode)) {
-
- }else {
-
- }
-
-
- }