|
@@ -0,0 +1,75 @@
|
|
|
|
|
+package com.ydtech.modules.order.controller;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import com.ydtech.core.page.HttpResult;
|
|
|
|
|
+import com.ydtech.modules.base.controller.BaseController;
|
|
|
|
|
+import com.ydtech.modules.ins.model.vo.QuoteRespVo;
|
|
|
|
|
+import com.ydtech.modules.order.entity.vo.*;
|
|
|
|
|
+import com.ydtech.modules.order.service.ExcelExportService;
|
|
|
|
|
+import com.ydtech.utils.ExcelUtils;
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import org.apache.xmlbeans.ResourceLoader;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.InputStream;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+@Api(tags = "excel导出表 API")
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/api/excelExport")
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+public class ExcelExportController extends BaseController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ExcelExportService excelExportService;
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${upload.file.path}")
|
|
|
|
|
+ private String uploadPath;
|
|
|
|
|
+
|
|
|
|
|
+ private String EXCEL_PATH = "excel//";
|
|
|
|
|
+
|
|
|
|
|
+ private String UPLOAD_PATH = "upload//excel//";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/carBusinessDetailExcelExport")
|
|
|
|
|
+ @ApiOperation("车险业务明细表导出")
|
|
|
|
|
+ public HttpResult<QuoteRespVo> carBusinessDetail(@RequestBody CarBusinessDetailQueryVo carBusinessDetailQueryVo) {
|
|
|
|
|
+ List<CarBusinessDetailVo> carBusinessDetailList = excelExportService.getCarBusinessDetailList(getUserId(), carBusinessDetailQueryVo);
|
|
|
|
|
+ ExcelUtils<CarBusinessDetailVo> excelUtils = new ExcelUtils<CarBusinessDetailVo>();
|
|
|
|
|
+ //读取模版文件
|
|
|
|
|
+ String templatePath = ResourceLoader.class.getClassLoader().getResource("template/car_business_detail.xlsx").getPath();
|
|
|
|
|
+ String fileName = "车险业务明细" + System.currentTimeMillis() + ".xlsx";
|
|
|
|
|
+ String saveFilePath = uploadPath+"//" + EXCEL_PATH + fileName;
|
|
|
|
|
+ String resultPath = UPLOAD_PATH + fileName;
|
|
|
|
|
+ String sheetName = "车险业务明细表";
|
|
|
|
|
+ if(excelUtils.writeExcel(templatePath,saveFilePath,sheetName, CarBusinessDetailVo.class,carBusinessDetailList)){
|
|
|
|
|
+ return HttpResult.ok(resultPath);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return HttpResult.error("导出车险业务明细表失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/revenueExpenditureDetailExcelExport")
|
|
|
|
|
+ @ApiModelProperty("收支明细表导出")
|
|
|
|
|
+ public HttpResult<QuoteRespVo> revenueExpenditureDetailExcelExport(@RequestBody CarBusinessDetailQueryVo carBusinessDetailQueryVo) {
|
|
|
|
|
+ List<RevenueExpenditureDetailVo> revenueExpenditureDetailList = excelExportService.getRevenueExpenditureDetailList(getUserId(), carBusinessDetailQueryVo);
|
|
|
|
|
+ ExcelUtils<RevenueExpenditureDetailVo> excelUtils = new ExcelUtils<RevenueExpenditureDetailVo>();
|
|
|
|
|
+ //读取模版文件
|
|
|
|
|
+ String templatePath = ResourceLoader.class.getClassLoader().getResource("template/revenue_expenditure_detail.xlsx").getPath();
|
|
|
|
|
+ String fileName = "收支明细表" + System.currentTimeMillis() + ".xlsx";
|
|
|
|
|
+ String saveFilePath = uploadPath+"//" + EXCEL_PATH + fileName;
|
|
|
|
|
+ String resultPath = UPLOAD_PATH + fileName;
|
|
|
|
|
+ String sheetName = "收支明细表";
|
|
|
|
|
+ if(excelUtils.writeExcel(templatePath,saveFilePath,sheetName, RevenueExpenditureDetailVo.class,revenueExpenditureDetailList)){
|
|
|
|
|
+ return HttpResult.ok(resultPath);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return HttpResult.error("导出收支明细表失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|