Просмотр исходного кода

财务 应收管理 应收应付功能 导出 创建文件夹

785834757 2 лет назад
Родитель
Сommit
65d2549537

+ 19 - 3
src/main/java/com/ydtech/modules/inv/controller/InvReceivableController.java

@@ -24,6 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.YearMonth;
@@ -70,9 +74,13 @@ public class InvReceivableController extends BaseController {
 
     @ApiOperation("应收表导出")
     @PostMapping("exportReceivable")
-    public HttpResult<PageResult> exportReceivable(@RequestBody InvSourceQueryVo invSourceQueryVo){
+    public HttpResult<PageResult> exportReceivable(@RequestBody InvSourceQueryVo invSourceQueryVo) throws IOException {
         List<InvSource> recivablePage = invReceivableService.getRecivableList(invSourceQueryVo);
         String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if(!Files.exists(path)){
+            Files.createDirectories(path);
+        }
         String fileName = EasyExcelUtils.downExcel(uploadPath, "应收表", InvSource.class, recivablePage);
         return HttpResult.ok(uploadUrl + "excel/" +fileName);
     }
@@ -96,9 +104,13 @@ public class InvReceivableController extends BaseController {
 
     @ApiOperation("结算导出")
     @PostMapping("exportSettlement")
-    public HttpResult<PageResult> exportSettlement(@RequestBody InvSettlementSourceQueryVo invSettlementSourceQueryVo){
+    public HttpResult<PageResult> exportSettlement(@RequestBody InvSettlementSourceQueryVo invSettlementSourceQueryVo) throws IOException {
         List<InvSettlementSource> recivableList = invReceivableService.getSettlementList(invSettlementSourceQueryVo);
         String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if(!Files.exists(path)){
+            Files.createDirectories(path);
+        }
         String fileName = EasyExcelUtils.downExcel(uploadPath, "结算表", InvSettlementSource.class, recivableList);
         return HttpResult.ok(uploadUrl + "excel/" +fileName);
     }
@@ -161,8 +173,12 @@ public class InvReceivableController extends BaseController {
 
     @ApiOperation("导出应收应付表")
     @PostMapping("excelReceivableAndSettlement")
-    public HttpResult excelReceivableAndSettlement(@RequestBody ReceivableAndSettlementQueryVo receivableAndSettlementQueryVo){
+    public HttpResult excelReceivableAndSettlement(@RequestBody ReceivableAndSettlementQueryVo receivableAndSettlementQueryVo) throws IOException {
         String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if(!Files.exists(path)){
+            Files.createDirectories(path);
+        }
         List<ReceivableAndSettlementVo> invChannelAccountList = invReceivableService.getReceivableAndSettlementList(receivableAndSettlementQueryVo);
         String fileName = EasyExcelUtils.downExcel(uploadPath, "应收应付表", ReceivableAndSettlementVo.class, invChannelAccountList);
         return HttpResult.ok(uploadUrl + "excel/" +fileName);