|
|
|
@ -2,6 +2,7 @@ package com.jianshui.api.controller.http.invoice.v1; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.codec.Base64Decoder; |
|
|
|
|
import cn.hutool.core.codec.Base64Encoder; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
@ -45,16 +46,22 @@ import com.jianshui.system.service.ICompanyserviceService; |
|
|
|
|
import com.jianshui.system.service.IServiceManageService; |
|
|
|
|
import io.swagger.annotations.*; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.pdfbox.pdmodel.PDDocument; |
|
|
|
|
import org.apache.pdfbox.rendering.PDFRenderer; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
|
import org.springframework.ui.Model; |
|
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder; |
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes; |
|
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
import java.io.*; |
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.security.InvalidKeyException; |
|
|
|
@ -1227,7 +1234,7 @@ public class InvoiceController { |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/qrcode/{identity}", "/api/invoice/v1/qrcode","/invoice/qrcode"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/qrcode/{identity}", "/api/invoice/v1/qrcode", "/invoice/qrcode"}) |
|
|
|
|
public Object qrcode(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
|
|
|
|
|
// qrcode
|
|
|
|
@ -1266,7 +1273,7 @@ public class InvoiceController { |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/qrcodeResult/{identity}", "/api/invoice/v1/qrcodeResult","/invoice/qrcodeResult"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/qrcodeResult/{identity}", "/api/invoice/v1/qrcodeResult", "/invoice/qrcodeResult"}) |
|
|
|
|
public Object qrcodeResult(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
|
|
|
|
|
// qrcode
|
|
|
|
@ -1605,7 +1612,7 @@ public class InvoiceController { |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/queryRedConfirmationList/{identity}", "/api/invoice/v1/queryRedConfirmationList","/invoice/queryRedConfirmationList"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/queryRedConfirmationList/{identity}", "/api/invoice/v1/queryRedConfirmationList", "/invoice/queryRedConfirmationList"}) |
|
|
|
|
public Object queryRedConfirmationList(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
|
return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); |
|
|
|
@ -1639,7 +1646,7 @@ public class InvoiceController { |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/queryRedConfirmationItemList/{identity}", "/api/invoice/v1/queryRedConfirmationItemList","/invoice/queryRedConfirmationItemList"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/queryRedConfirmationItemList/{identity}", "/api/invoice/v1/queryRedConfirmationItemList", "/invoice/queryRedConfirmationItemList"}) |
|
|
|
|
public Object queryRedConfirmationItemList(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
|
return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); |
|
|
|
@ -1668,11 +1675,13 @@ public class InvoiceController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 红字确认单申请(数电专用) */ |
|
|
|
|
/** |
|
|
|
|
* 红字确认单申请(数电专用) |
|
|
|
|
*/ |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/redConfirmationApply/{identity}", "/api/invoice/v1/redConfirmationApply","/invoice/redConfirmationApply"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/redConfirmationApply/{identity}", "/api/invoice/v1/redConfirmationApply", "/invoice/redConfirmationApply"}) |
|
|
|
|
public Object RedConfirmationApply(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
|
return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); |
|
|
|
@ -1706,7 +1715,7 @@ public class InvoiceController { |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/redConfirmationConfirm/{identity}", "/api/invoice/v1/redConfirmationConfirm","/invoice/redConfirmationConfirm"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/redConfirmationConfirm/{identity}", "/api/invoice/v1/redConfirmationConfirm", "/invoice/redConfirmationConfirm"}) |
|
|
|
|
public Object redConfirmationConfirm(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
|
return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); |
|
|
|
@ -1741,7 +1750,7 @@ public class InvoiceController { |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/rpaLogin/{identity}", "/api/invoice/v1/rpaLogin","/invoice/rpaLogin"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/rpaLogin/{identity}", "/api/invoice/v1/rpaLogin", "/invoice/rpaLogin"}) |
|
|
|
|
public Object rpaLogin(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
|
return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); |
|
|
|
@ -1923,7 +1932,7 @@ public class InvoiceController { |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/mailDelivery/{identity}", "/api/invoice/v1/mailDelivery","/invoice/mailDelivery"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/mailDelivery/{identity}", "/api/invoice/v1/mailDelivery", "/invoice/mailDelivery"}) |
|
|
|
|
public Object mailDelivery(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
@ -1961,7 +1970,7 @@ public class InvoiceController { |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/fastRedInvoice/{identity}", "/api/invoice/v1/fastRedInvoice","/invoice/fastRedInvoice"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/fastRedInvoice/{identity}", "/api/invoice/v1/fastRedInvoice", "/invoice/fastRedInvoice"}) |
|
|
|
|
public Object fastRedInvoice(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
@ -1999,7 +2008,7 @@ public class InvoiceController { |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/QueryFastRedInvoiceResult/{identity}", "/api/invoice/v1/QueryFastRedInvoiceResult","/invoice/QueryFastRedInvoiceResult"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/QueryFastRedInvoiceResult/{identity}", "/api/invoice/v1/QueryFastRedInvoiceResult", "/invoice/QueryFastRedInvoiceResult"}) |
|
|
|
|
public Object QueryFastRedInvoiceResult(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
@ -2031,12 +2040,12 @@ public class InvoiceController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 数电获取发票文件接口(数电专用接口) |
|
|
|
|
* 数电获取发票文件接口(数电专用接口) |
|
|
|
|
*/ |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/QuerySdInvoiceFile/{identity}", "/api/invoice/v1/QuerySdInvoiceFile","/invoice/QuerySdInvoiceFile"}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/QuerySdInvoiceFile/{identity}", "/api/invoice/v1/QuerySdInvoiceFile", "/invoice/QuerySdInvoiceFile"}) |
|
|
|
|
public Object QuerySdInvoiceFile(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
@ -2068,4 +2077,50 @@ public class InvoiceController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发票预览 |
|
|
|
|
*/ |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping("/invoice/filePreview") |
|
|
|
|
public String filePreview(@RequestBody String id) throws Exception { |
|
|
|
|
|
|
|
|
|
System.out.println(id); |
|
|
|
|
if (StrUtil.isEmpty(id)) { |
|
|
|
|
return "未查询到发票信息"; |
|
|
|
|
} |
|
|
|
|
InvoiceFile invoiceFile = invoiceFileMapper.selectInvoiceFileById(id); |
|
|
|
|
if (BeanUtil.isEmpty(invoiceFile) || StrUtil.isEmpty(invoiceFile.getFileContent())) { |
|
|
|
|
return "未查询到发票信息"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String fileName = invoiceFile.getFileName(); |
|
|
|
|
String content = invoiceFile.getFileContent(); |
|
|
|
|
|
|
|
|
|
String co = convertPdfBase64ToImageBase64(content); |
|
|
|
|
|
|
|
|
|
return "data:image/jpeg;base64,"+co; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String convertPdfBase64ToImageBase64(String pdfBase64) throws IOException { |
|
|
|
|
// 将PDF的Base64解码为字节数组
|
|
|
|
|
byte[] pdfBytes = Base64Decoder.decode(pdfBase64); |
|
|
|
|
// 将PDF的字节数组转为PDDocument对象
|
|
|
|
|
PDDocument document = PDDocument.load(pdfBytes); |
|
|
|
|
// 使用PDFBox库将PDF转为BufferedImage
|
|
|
|
|
PDFRenderer pdfRenderer = new PDFRenderer(document); |
|
|
|
|
BufferedImage bufferedImage = pdfRenderer.renderImageWithDPI(0, 300); |
|
|
|
|
// 将BufferedImage转为Base64格式
|
|
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|
|
|
|
ImageIO.write(bufferedImage, "png", baos); |
|
|
|
|
byte[] imageBytes = baos.toByteArray(); |
|
|
|
|
String imageBase64 = Base64Encoder.encode(imageBytes); |
|
|
|
|
// 关闭PDDocument对象
|
|
|
|
|
document.close(); |
|
|
|
|
return imageBase64; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|