From 02bc08b1e4126d2112bb5dadddcfbd4fca0bf22d Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Wed, 29 Dec 2021 18:16:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=8A=E4=BC=A0=E5=8F=91?= =?UTF-8?q?=E7=A5=A8=E7=94=B5=E5=AD=90=E5=8F=91=E7=A5=A8pdf=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E9=83=A8=E5=88=86=E5=AE=8C=E6=88=90=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8F=91=E7=A5=A8Excel=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/XhpcInvoiceController.java | 21 +++++++++++++++---- .../invoice/mapper/XhpcInvoiceMapper.java | 10 +++++++++ .../service/impl/XhpcInvoiceServiceImpl.java | 19 +++++++++++++---- .../src/main/resources/bootstrap.yml | 3 ++- .../resources/mapper/XhpcInvoiceMapper.xml | 6 ++++++ 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java index a480949f..ec2a649c 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java @@ -11,14 +11,12 @@ import com.xhpc.invoice.domain.InvoiceToUserRequest; import com.xhpc.invoice.domain.SpecificInvoiceWrap; import com.xhpc.invoice.service.XhpcInvoiceService; import org.springframework.core.env.Environment; -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.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -37,11 +35,26 @@ public class XhpcInvoiceController extends BaseController { @Resource Environment environment; + /** + * 导出发票Excel接口 + * + * @author WH + * @date 2021/12/29 16:45 + * @since version-1.0 + */ + @GetMapping("/excel") + public AjaxResult exportExcel(@RequestParam("invoiceIds") List invoiceIds) { + //todo 将指定发票信息导入到excel表中,然后返回出去 + return AjaxResult.success("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/69852145895461/202109151137358636985214589546101.png"); + } + + /** * 上传图片到阿里云接口 * * @param invoicePdf 文件二进制对象 * @return 该文件在阿里云中的地址 + * * @author WH * @date 2021/12/29 16:40 * @since version-1.0 diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java index 7d612d8c..fbd11b3f 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java @@ -166,4 +166,14 @@ public interface XhpcInvoiceMapper { */ Long findNotReadCount(@Param("creatorId") Long creatorId, @Param("creatorType") Integer creatorType); + /** + * 更新发票状态,从未读变成已读 + * + * @param invoiceId 要更新的发票id + * @author WH + * @date 2021/12/29 17:26 + * @since version-1.0 + */ + void updateByInvoiceId(Long invoiceId); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java index 454c6209..8ad50225 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java @@ -1,6 +1,7 @@ package com.xhpc.invoice.service.impl; import cn.hutool.extra.mail.MailUtil; +import cn.hutool.http.HttpUtil; import com.xhpc.common.core.utils.DateUtils; import com.xhpc.common.core.utils.bean.BeanUtils; import com.xhpc.common.domain.XhpcChargingStation; @@ -12,6 +13,7 @@ import com.xhpc.invoice.pojo.XhpcInvoiceMapHistoryOrder; import com.xhpc.invoice.service.XhpcInvoiceService; import com.xhpc.order.domain.XhpcHistoryOrder; import com.xhpc.system.api.domain.SysUser; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -44,6 +46,8 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { SysUserMapper sysUserMapper; @Resource XhpcHistoryOrderMapper xhpcHistoryOrderMapper; + @Resource + Environment environment; /** * 通过requestData中的申请人、申请人类型、发票状态、发票起始时间、发票申请终止时间、开票起始时间、开票终点时间、当前所在页数、当前页所要显示几行,来查询发票列表信息 @@ -110,13 +114,19 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { //发送电子发票pdf到接收者邮箱 XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(requestData.getInvoiceId()); String receiveEmail = xhpcInvoice.getReceiveEmail(); - //todo 从阿里云上下载下来电子发票 - File electricInvoiceFile = new File("D:\\Enterprise_Resources\\ElectricInvoice\\ElectricInvoice.pdf"); + //从阿里云上下载下来电子发票 + String fileUrl = requestData.getEletricInvoiceUrl(); + File electricInvoiceFile = new File(environment.getProperty("file.serverStoreDisposableFileLocation") + "ElectricInvoice.pdf"); + HttpUtil.downloadFile(fileUrl, electricInvoiceFile); try { MailUtil.send(receiveEmail, "【小华充电】电子发票", "邮件来自小华充电", false, electricInvoiceFile); } catch (Exception e) { System.out.println(e.getMessage()); return Boolean.FALSE; + } finally { + if (electricInvoiceFile.exists()) { + electricInvoiceFile.delete(); + } } //更新发票数据 Long successFlag = xhpcInvoiceMapper.invoiceToUser(requestData); @@ -219,6 +229,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { * @since version-1.0 */ @Override + @Transactional(rollbackFor = Exception.class) public SpecificInvoicedResponse selectSpecificInvoiced(Long invoiceId) { //对拷发票部分数据 @@ -250,8 +261,8 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { historyOrdersDTO.setTotalItems(historyOrdersList.size()); specificInvoicedResponse.setHistoryOrders(historyOrdersDTO); - //todo 一旦掉了详情接口,去掉未读状态 - + //一旦调了详情接口,就去掉该已开发票的未读状态 + xhpcInvoiceMapper.updateByInvoiceId(invoiceId); return specificInvoicedResponse; } diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml index c5679461..9f962452 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml @@ -36,4 +36,5 @@ oss: #文件路径 file: - aliyunPath: invoicePdf/ \ No newline at end of file + aliyunPath: invoicePdf/ + serverStoreDisposableFileLocation: /www/wwwroot/xhpc.scxhua.com/disposableFiles/ \ No newline at end of file diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml index 0f28e800..ce830f28 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml @@ -677,5 +677,11 @@ drawer = #{drawer} is_read = 0 WHERE invoice_id = #{invoiceId} + + UPDATE xhpc_invoice + SET is_read = 1 + WHERE del_flag IS NULL + AND invoice_id = #{invoiceId} + \ No newline at end of file