JudgmentController.java
2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package cn.com.glsx.admin.modules.controller;
import cn.com.glsx.admin.common.constants.Constants;
import cn.com.glsx.admin.modules.model.export.JudgmentExport;
import cn.com.glsx.admin.modules.model.param.JudgmentSearch;
import cn.com.glsx.admin.modules.service.JudgmentService;
import cn.com.glsx.admin.modules.utils.FdfsUtils;
import cn.com.glsx.admin.modules.utils.fileupload.FileConstants;
import cn.com.glsx.admin.modules.utils.fileupload.FileUploadServerData;
import cn.com.glsx.admin.modules.utils.fileupload.FileUploadUtil;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.R;
import com.glsx.plat.office.excel.EasyExcelUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.ByteArrayOutputStream;
import java.util.List;
/**
* 大数据研判 controller
*
* @author yll
*/
@Slf4j
@RestController
@RequestMapping(value = "/judgment")
@Api(value = "大数据研判报表", tags = {"大数据研判报表"})
public class JudgmentController {
@Autowired
private JudgmentService judgmentService;
@GetMapping("/search")
@ApiOperation(value = "查询大数据研判列表")
public R findJudgmentList(JudgmentSearch judgmentSearch) {
PageInfo pageInfo = judgmentService.findJudgmentList(judgmentSearch);
return R.ok().putPageData(pageInfo);
}
@GetMapping("/export")
@ApiOperation(value = "导出大数据研判报表")
public R<String> exportJudgmentList(JudgmentSearch judgmentSearch) {
String fileName = FdfsUtils.getFileName("大数据研判报表");
List<JudgmentExport> judgmentList = judgmentService.exportJudgmentList(judgmentSearch);
// 将文件写入内存流 然后上传到文件服务器 返回文件服务器的地址给前端 前端执行下载
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
EasyExcelUtils.writeExcel(outputStream, judgmentList, fileName, JudgmentExport.class);
FileUploadServerData uploadServerData = FileUploadUtil.uploadToFileSystem(fileName, outputStream.toByteArray(), FileConstants.EXCEL_TYPE_XLSX);
return R.ok().data(uploadServerData.getSecureUrl());
}
}