完成上传发票电子发票pdf接口,部分完成导出发票Excel接口
This commit is contained in:
parent
aa4baa541b
commit
02bc08b1e4
@ -11,14 +11,12 @@ import com.xhpc.invoice.domain.InvoiceToUserRequest;
|
|||||||
import com.xhpc.invoice.domain.SpecificInvoiceWrap;
|
import com.xhpc.invoice.domain.SpecificInvoiceWrap;
|
||||||
import com.xhpc.invoice.service.XhpcInvoiceService;
|
import com.xhpc.invoice.service.XhpcInvoiceService;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
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.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,11 +35,26 @@ public class XhpcInvoiceController extends BaseController {
|
|||||||
@Resource
|
@Resource
|
||||||
Environment environment;
|
Environment environment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出发票Excel接口
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2021/12/29 16:45
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@GetMapping("/excel")
|
||||||
|
public AjaxResult exportExcel(@RequestParam("invoiceIds") List<Integer> invoiceIds) {
|
||||||
|
//todo 将指定发票信息导入到excel表中,然后返回出去
|
||||||
|
return AjaxResult.success("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/69852145895461/202109151137358636985214589546101.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传图片到阿里云接口
|
* 上传图片到阿里云接口
|
||||||
*
|
*
|
||||||
* @param invoicePdf 文件二进制对象
|
* @param invoicePdf 文件二进制对象
|
||||||
* @return 该文件在阿里云中的地址
|
* @return 该文件在阿里云中的地址
|
||||||
|
*
|
||||||
* @author WH
|
* @author WH
|
||||||
* @date 2021/12/29 16:40
|
* @date 2021/12/29 16:40
|
||||||
* @since version-1.0
|
* @since version-1.0
|
||||||
|
|||||||
@ -166,4 +166,14 @@ public interface XhpcInvoiceMapper {
|
|||||||
*/
|
*/
|
||||||
Long findNotReadCount(@Param("creatorId") Long creatorId, @Param("creatorType") Integer creatorType);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package com.xhpc.invoice.service.impl;
|
package com.xhpc.invoice.service.impl;
|
||||||
|
|
||||||
import cn.hutool.extra.mail.MailUtil;
|
import cn.hutool.extra.mail.MailUtil;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.xhpc.common.core.utils.DateUtils;
|
import com.xhpc.common.core.utils.DateUtils;
|
||||||
import com.xhpc.common.core.utils.bean.BeanUtils;
|
import com.xhpc.common.core.utils.bean.BeanUtils;
|
||||||
import com.xhpc.common.domain.XhpcChargingStation;
|
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.invoice.service.XhpcInvoiceService;
|
||||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||||
import com.xhpc.system.api.domain.SysUser;
|
import com.xhpc.system.api.domain.SysUser;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -44,6 +46,8 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
|||||||
SysUserMapper sysUserMapper;
|
SysUserMapper sysUserMapper;
|
||||||
@Resource
|
@Resource
|
||||||
XhpcHistoryOrderMapper xhpcHistoryOrderMapper;
|
XhpcHistoryOrderMapper xhpcHistoryOrderMapper;
|
||||||
|
@Resource
|
||||||
|
Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过requestData中的申请人、申请人类型、发票状态、发票起始时间、发票申请终止时间、开票起始时间、开票终点时间、当前所在页数、当前页所要显示几行,来查询发票列表信息
|
* 通过requestData中的申请人、申请人类型、发票状态、发票起始时间、发票申请终止时间、开票起始时间、开票终点时间、当前所在页数、当前页所要显示几行,来查询发票列表信息
|
||||||
@ -110,13 +114,19 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
|||||||
//发送电子发票pdf到接收者邮箱
|
//发送电子发票pdf到接收者邮箱
|
||||||
XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(requestData.getInvoiceId());
|
XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(requestData.getInvoiceId());
|
||||||
String receiveEmail = xhpcInvoice.getReceiveEmail();
|
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 {
|
try {
|
||||||
MailUtil.send(receiveEmail, "【小华充电】电子发票", "邮件来自小华充电", false, electricInvoiceFile);
|
MailUtil.send(receiveEmail, "【小华充电】电子发票", "邮件来自小华充电", false, electricInvoiceFile);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
|
} finally {
|
||||||
|
if (electricInvoiceFile.exists()) {
|
||||||
|
electricInvoiceFile.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//更新发票数据
|
//更新发票数据
|
||||||
Long successFlag = xhpcInvoiceMapper.invoiceToUser(requestData);
|
Long successFlag = xhpcInvoiceMapper.invoiceToUser(requestData);
|
||||||
@ -219,6 +229,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
|||||||
* @since version-1.0
|
* @since version-1.0
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public SpecificInvoicedResponse selectSpecificInvoiced(Long invoiceId) {
|
public SpecificInvoicedResponse selectSpecificInvoiced(Long invoiceId) {
|
||||||
|
|
||||||
//对拷发票部分数据
|
//对拷发票部分数据
|
||||||
@ -250,8 +261,8 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
|||||||
historyOrdersDTO.setTotalItems(historyOrdersList.size());
|
historyOrdersDTO.setTotalItems(historyOrdersList.size());
|
||||||
specificInvoicedResponse.setHistoryOrders(historyOrdersDTO);
|
specificInvoicedResponse.setHistoryOrders(historyOrdersDTO);
|
||||||
|
|
||||||
//todo 一旦掉了详情接口,去掉未读状态
|
//一旦调了详情接口,就去掉该已开发票的未读状态
|
||||||
|
xhpcInvoiceMapper.updateByInvoiceId(invoiceId);
|
||||||
return specificInvoicedResponse;
|
return specificInvoicedResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,3 +37,4 @@ oss:
|
|||||||
#文件路径
|
#文件路径
|
||||||
file:
|
file:
|
||||||
aliyunPath: invoicePdf/
|
aliyunPath: invoicePdf/
|
||||||
|
serverStoreDisposableFileLocation: /www/wwwroot/xhpc.scxhua.com/disposableFiles/
|
||||||
@ -677,5 +677,11 @@
|
|||||||
drawer = #{drawer} is_read = 0
|
drawer = #{drawer} is_read = 0
|
||||||
WHERE invoice_id = #{invoiceId}
|
WHERE invoice_id = #{invoiceId}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateByInvoiceId">
|
||||||
|
UPDATE xhpc_invoice
|
||||||
|
SET is_read = 1
|
||||||
|
WHERE del_flag IS NULL
|
||||||
|
AND invoice_id = #{invoiceId}
|
||||||
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user