feature: 潍焦发票查询接口开发

beta-prop-all
xingze 3 months ago
parent 5a68633294
commit dba2de2ddb
  1. 53
      jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java
  2. 1
      jianshui-framework/src/main/java/com/jianshui/framework/config/SecurityConfig.java
  3. 11
      jianshui-invoice/src/main/java/com/jianshui/invoice/domain/dto/api/elephant/DDFPZXX.java
  4. 25
      jianshui-invoice/src/main/java/com/jianshui/invoice/domain/dto/api/elephant/FILEITEMLIST.java
  5. 99
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ByInspurServiceImpl.java
  6. 97
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java

@ -447,6 +447,59 @@ public class InvoiceController {
}
/**
* xml文件下载
* @param id
* @param response
* @throws Exception
*/
@ApiImplicitParams({
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true),
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)})
@GetMapping("/invoice/xmlFileUrl/{id}")
public void xmlFileUrl(@PathVariable String id, HttpServletResponse response) throws Exception {
if (StrUtil.isEmpty(id)) {
return;
}
InvoiceFile invoiceFile = invoiceFileMapper.selectInvoiceFileById(id);
if (BeanUtil.isEmpty(invoiceFile)) {
return;
}
if (StringUtils.isNotBlank(invoiceFile.getFileContent())){
String fileName = invoiceFile.getFileName();
String content = invoiceFile.getFileContent();
try {
byte[] buffer = Base64Decoder.decode(content); // 将文件流字符串转换为字节数组
response.reset();
response.setCharacterEncoding("UTF-8");
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xml");
response.addHeader("Content-Length", "" + buffer.length);
response.setContentType("application/xml");
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
outputStream.write(buffer);
outputStream.flush();
outputStream.close(); // 关闭输出流
} catch (IOException ex) {
ex.printStackTrace();
}
}else if (StringUtils.isBlank(invoiceFile.getFileContent()) && invoiceFile.getFileName().contains(Constants.DB_SAVE)){
String fileUrl = invoiceFile.getFileName();
StorageBaseAbstractService storageInstance = storageFactory.getStorageInstance(Constants.MINIO);
StorageUrlDTO storageUrlDTO = new StorageUrlDTO();
storageUrlDTO.setStoragePath(fileUrl);
storageUrlDTO.setServiceProvider(Constants.MINIO);
storageUrlDTO.setContentType(Constants.APPLICATION_PDF);
AjaxResult file = storageInstance.getFile(storageUrlDTO);
if (file.isSuccess()){
response.sendRedirect((String) file.getData());
}
}
}
/**
* 开票查询接口订单号
*/

@ -121,6 +121,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
"/invoice/deleteInvoice",
"/invoice/findRedInfo",
"/invoice/fileUrl/**",
"/invoice/xmlFileUrl/**",
"/invoice/filePreview/**",
"/invoice/queryRedConfirmationList",
"/invoice/queryRedConfirmationItemList",

@ -17,6 +17,17 @@ public class DDFPZXX {
private JDCTXX JDCTXX; // 机动车头信息
private List<DDKZXX> DDKZXX; // 订单扩展信息
private List<DDMXXX> DDMXXX; // 发票明细
private List<FILEITEMLIST> FILEITEMLIST; // 板式文件
public List<com.jianshui.invoice.domain.dto.api.elephant.FILEITEMLIST> getFILEITEMLIST() {
return FILEITEMLIST;
}
public void setFILEITEMLIST(List<com.jianshui.invoice.domain.dto.api.elephant.FILEITEMLIST> FILEITEMLIST) {
this.FILEITEMLIST = FILEITEMLIST;
}
public void setDDFPXX(DDFPXX DDFPXX) {
this.DDFPXX = DDFPXX;
}

@ -0,0 +1,25 @@
package com.jianshui.invoice.domain.dto.api.elephant;
public class FILEITEMLIST {
// 文件内容
private String FILECONTENT;
// 文件类型
private String WJLX;
public String getFILECONTENT() {
return FILECONTENT;
}
public void setFILECONTENT(String FILECONTENT) {
this.FILECONTENT = FILECONTENT;
}
public String getWJLX() {
return WJLX;
}
public void setWJLX(String WJLX) {
this.WJLX = WJLX;
}
}

@ -498,6 +498,18 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
// todo 潍焦获取服务信息
List<CompanyserviceProp> companyservicePropList = companyservicePropMapper.selectCompanyservicePropByCompanyid(companyservice.getCompanyid());
if (CollectionUtils.isNotEmpty(companyservicePropList) && companyservicePropList.size() > 0) {
for (CompanyserviceProp companyserviceProp : companyservicePropList) {
if ("weijiao_invoice_key".equals(companyserviceProp.getKey())) {
queryBody.put("BSWJ", "0");
queryBody.put("WJLX", "ALL");
}
}
}
// TODO kk:2024/7/8 寿仙谷定制 不需要文件流
// queryBody.put("BSWJ", "1");
@ -663,7 +675,21 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
//配置文件存储类型0为数据库存储
if (Constants.STRING_0.equals(type)){
// todo 潍焦单独处理
boolean flag = false;
if (CollectionUtils.isNotEmpty(companyservicePropList) && companyservicePropList.size() > 0) {
for (CompanyserviceProp companyserviceProp : companyservicePropList) {
if ("weijiao_invoice_key".equals(companyserviceProp.getKey())) {
flag = true;
break;
}
}
}
if (flag){
saveFileUseDbWeijiao(invoice, fileId, fileName, companyservice, ddfpxx,ddfpzxx);
}else {
saveFileUseDb(invoice, fileId, fileName, companyservice, ddfpxx);
}
//配置文件存储类型1为oss存储
}else if (Constants.STRING_1.equals(type)){
saveFileUseOss(defaultStorage,invoice,ddfpxx);
@ -824,6 +850,79 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
}
private void saveFileUseDbWeijiao(Invoice invoice, String fileId, String fileName, Companyservice companyservice, DDFPXX ddfpxx, DDFPZXX ddfpzxx) {
InvoiceFile invoiceFile = new InvoiceFile();
List<FILEITEMLIST> fileitemlist = ddfpzxx.getFILEITEMLIST();
String pdfFileId = "";
String xmlFileId = "";
for (FILEITEMLIST fileitem : fileitemlist) {
if ("PDF".equals(fileitem.getWJLX())) {
pdfFileId = fileId + "pdf";
invoiceFile.setFphm(ddfpxx.getFPHM() + "pdf");
List<InvoiceFile> invoiceFileList = invoiceFileMapper.selectInvoiceFileList(invoiceFile);
if (invoiceFileList != null && invoiceFileList.size() > 0) {
invoiceFile = invoiceFileList.get(0);
invoiceFile.setFileContent(fileitem.getFILECONTENT());
invoiceFile.setFileName(fileName);
invoiceFile.setCreateTime(new Date());
invoiceFile.setIdentity(companyservice.getIdentity());
invoiceFile.setTax(companyservice.getSellertax());
pdfFileId = invoiceFile.getFileId();
invoiceFileMapper.updateInvoiceFile(invoiceFile);
} else {
invoiceFile.setId(pdfFileId);
invoiceFile.setFileContent(fileitem.getFILECONTENT());
invoiceFile.setFileId(pdfFileId);
invoiceFile.setFileName(fileName);
invoiceFile.setCreateTime(new Date());
invoiceFile.setIdentity(companyservice.getIdentity());
invoiceFile.setTax(companyservice.getSellertax());
invoiceFileMapper.insertInvoiceFile(invoiceFile);
}
}
if ("XML".equals(fileitem.getWJLX())) {
xmlFileId = fileId + "xml";
invoiceFile.setFphm(ddfpxx.getFPHM() + "xml");
List<InvoiceFile> invoiceFileList = invoiceFileMapper.selectInvoiceFileList(invoiceFile);
if (invoiceFileList != null && invoiceFileList.size() > 0) {
invoiceFile = invoiceFileList.get(0);
invoiceFile.setFileContent(fileitem.getFILECONTENT());
invoiceFile.setFileName(fileName);
invoiceFile.setCreateTime(new Date());
invoiceFile.setIdentity(companyservice.getIdentity());
invoiceFile.setTax(companyservice.getSellertax());
xmlFileId = invoiceFile.getFileId();
invoiceFileMapper.updateInvoiceFile(invoiceFile);
} else {
invoiceFile.setId(xmlFileId);
invoiceFile.setFileContent(fileitem.getFILECONTENT());
invoiceFile.setFileId(xmlFileId);
invoiceFile.setFileName(fileName);
invoiceFile.setCreateTime(new Date());
invoiceFile.setIdentity(companyservice.getIdentity());
invoiceFile.setTax(companyservice.getSellertax());
invoiceFileMapper.insertInvoiceFile(invoiceFile);
}
}
}
// 2023/11/16 kk:上传OSS转下载地址关闭,改为直接返回大象的文件流
invoice.setInvoicePdfUrl(ELE_File_URL + pdfFileId + ";" + "http://127.0.0.1:8081/invoice/xmlFileUrl/" + xmlFileId);
ICompanyservicePropService companyserviceProp = SpringUtils.getBean(ICompanyservicePropService.class);
CompanyserviceProp secretIdProp = companyserviceProp.selectPropByKey(companyservice.getCompanyid(), "elephant_invoice_file_dc");
if (secretIdProp != null) {
invoice.setInvoicePdfUrl(secretIdProp.getValue() + fileId);
}
}
private void saveFileUseOss(String defaultStorage,Invoice invoice,DDFPXX ddfpxx) {
if (StringUtils.isNotEmpty(defaultStorage) && StringUtils.isEmpty(invoice.getInvoicePdfUrl())) {
try {

@ -542,6 +542,16 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
queryBody.put("NSRSBH", companyservice.getSellertax());
queryBody.put("DDQQLSH", originBillInfo.getSystemOrderno());
// todo 潍焦获取服务信息
List<CompanyserviceProp> companyservicePropList = companyservicePropMapper.selectCompanyservicePropByCompanyid(companyservice.getCompanyid());
if (CollectionUtils.isNotEmpty(companyservicePropList) && companyservicePropList.size() > 0) {
for (CompanyserviceProp companyserviceProp : companyservicePropList) {
if ("weijiao_invoice_key".equals(companyserviceProp.getKey())) {
queryBody.put("BSWJ", "0");
queryBody.put("WJLX", "ALL");
}
}
}
debugLog("断点4", uuid, timestamp);
@ -706,7 +716,22 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
//配置文件存储类型0为数据库存储
if (Constants.STRING_0.equals(type)) {
// todo 潍焦单独处理
boolean flag = false;
if (CollectionUtils.isNotEmpty(companyservicePropList) && companyservicePropList.size() > 0) {
for (CompanyserviceProp companyserviceProp : companyservicePropList) {
if ("weijiao_invoice_key".equals(companyserviceProp.getKey())) {
flag = true;
break;
}
}
}
if (flag){
saveFileUseDbWeijiao(invoice, fileId, fileName, companyservice, ddfpxx,ddfpzxx);
}else {
saveFileUseDb(invoice, fileId, fileName, companyservice, ddfpxx);
}
//配置文件存储类型1为oss存储
} else if (Constants.STRING_1.equals(type)) {
saveFileUseOss(defaultStorage, invoice, ddfpxx);
@ -934,6 +959,78 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
}
}
private void saveFileUseDbWeijiao(Invoice invoice, String fileId, String fileName, Companyservice companyservice, DDFPXX ddfpxx, DDFPZXX ddfpzxx) {
InvoiceFile invoiceFile = new InvoiceFile();
List<FILEITEMLIST> fileitemlist = ddfpzxx.getFILEITEMLIST();
String pdfFileId = "";
String xmlFileId = "";
for (FILEITEMLIST fileitem : fileitemlist) {
if ("PDF".equals(fileitem.getWJLX())) {
pdfFileId = fileId + "pdf";
invoiceFile.setFphm(ddfpxx.getFPHM() + "pdf");
List<InvoiceFile> invoiceFileList = invoiceFileMapper.selectInvoiceFileList(invoiceFile);
if (invoiceFileList != null && invoiceFileList.size() > 0) {
invoiceFile = invoiceFileList.get(0);
invoiceFile.setFileContent(fileitem.getFILECONTENT());
invoiceFile.setFileName(fileName);
invoiceFile.setCreateTime(new Date());
invoiceFile.setIdentity(companyservice.getIdentity());
invoiceFile.setTax(companyservice.getSellertax());
pdfFileId = invoiceFile.getFileId();
invoiceFileMapper.updateInvoiceFile(invoiceFile);
} else {
invoiceFile.setId(pdfFileId);
invoiceFile.setFileContent(fileitem.getFILECONTENT());
invoiceFile.setFileId(pdfFileId);
invoiceFile.setFileName(fileName);
invoiceFile.setCreateTime(new Date());
invoiceFile.setIdentity(companyservice.getIdentity());
invoiceFile.setTax(companyservice.getSellertax());
invoiceFileMapper.insertInvoiceFile(invoiceFile);
}
}
if ("XML".equals(fileitem.getWJLX())) {
xmlFileId = fileId + "xml";
invoiceFile.setFphm(ddfpxx.getFPHM() + "xml");
List<InvoiceFile> invoiceFileList = invoiceFileMapper.selectInvoiceFileList(invoiceFile);
if (invoiceFileList != null && invoiceFileList.size() > 0) {
invoiceFile = invoiceFileList.get(0);
invoiceFile.setFileContent(fileitem.getFILECONTENT());
invoiceFile.setFileName(fileName);
invoiceFile.setCreateTime(new Date());
invoiceFile.setIdentity(companyservice.getIdentity());
invoiceFile.setTax(companyservice.getSellertax());
xmlFileId = invoiceFile.getFileId();
invoiceFileMapper.updateInvoiceFile(invoiceFile);
} else {
invoiceFile.setId(xmlFileId);
invoiceFile.setFileContent(fileitem.getFILECONTENT());
invoiceFile.setFileId(xmlFileId);
invoiceFile.setFileName(fileName);
invoiceFile.setCreateTime(new Date());
invoiceFile.setIdentity(companyservice.getIdentity());
invoiceFile.setTax(companyservice.getSellertax());
invoiceFileMapper.insertInvoiceFile(invoiceFile);
}
}
}
// 2023/11/16 kk:上传OSS转下载地址关闭,改为直接返回大象的文件流
invoice.setInvoicePdfUrl(ELE_File_URL + pdfFileId + ";" + "http://127.0.0.1:8081/invoice/xmlFileUrl/" + xmlFileId);
ICompanyservicePropService companyserviceProp = SpringUtils.getBean(ICompanyservicePropService.class);
CompanyserviceProp secretIdProp = companyserviceProp.selectPropByKey(companyservice.getCompanyid(), "elephant_invoice_file_dc");
if (secretIdProp != null) {
invoice.setInvoicePdfUrl(secretIdProp.getValue() + fileId);
}
}
private void saveFileUseDb(Invoice invoice, String fileId, String fileName, Companyservice companyservice, DDFPXX ddfpxx) {
InvoiceFile invoiceFile = new InvoiceFile();
invoiceFile.setFphm(ddfpxx.getFPHM());

Loading…
Cancel
Save