|
@@ -1,9 +1,14 @@
|
|
|
package com.qmth.paper.library.api;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.boot.tools.excel.ExcelWriter;
|
|
|
+import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
|
+import com.qmth.paper.library.business.bean.result.ScanStatExportResult;
|
|
|
import com.qmth.paper.library.business.service.PaperScanStatService;
|
|
|
import com.qmth.paper.library.common.contant.ApiPrefixConstant;
|
|
|
import com.qmth.paper.library.common.contant.SystemConstant;
|
|
|
+import com.qmth.paper.library.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.paper.library.common.util.Result;
|
|
|
import com.qmth.paper.library.common.util.ResultUtil;
|
|
|
import io.swagger.annotations.*;
|
|
@@ -13,8 +18,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.constraints.Max;
|
|
|
import javax.validation.constraints.Min;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @Description 扫描统计控制类
|
|
@@ -37,4 +46,24 @@ public class PaperScanStatController {
|
|
|
return ResultUtil.ok(paperScanStatService.pageScanStat(scanDate, scanner, pageNumber, pageSize));
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "导出")
|
|
|
+ @PostMapping(value = "/export")
|
|
|
+ public void export(@ApiParam(value = "扫描日期") @RequestParam(value = "scanDate", required = false) Long scanDate,
|
|
|
+ @ApiParam(value = "扫描员") @RequestParam(value = "scanner", required = false) String scanner, HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ String fileName = URLEncoder.encode("扫描统计", "UTF-8");
|
|
|
+ response.setHeader("Content-Disposition", "inline; filename=" + fileName + ".xlsx");
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ ExcelWriter writer = ExcelWriter.create(ExcelType.XLSX);
|
|
|
+ List<ScanStatExportResult> scanStatList = paperScanStatService.listScanStat(scanDate, scanner);
|
|
|
+ if (CollectionUtils.isEmpty(scanStatList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未开始扫描");
|
|
|
+ }
|
|
|
+ writer.writeObjects("扫描统计", null, ScanStatExportResult.class, scanStatList.iterator());
|
|
|
+ writer.output(response.getOutputStream());
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|