InNmmsStaticController.java
3.5 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.tianbo.analysis.controller;
import cn.afterturn.easypoi.entity.vo.NormalExcelConstants;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.view.PoiBaseView;
import com.tianbo.analysis.model.StatictisModel;
import com.tianbo.analysis.service.FFMResolve;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;
@Api(description = "进港舱单统计")
@RestController
@RequestMapping("/statistics/")
public class InNmmsStaticController {
@Autowired
FFMResolve ffmResolve;
@ApiOperation(value = "查询进港舱单统计")
@RequestMapping("/selectDevList")
public void selectDevList(@RequestParam(value = "flightno", required = false) String flightno,
@RequestParam(value = "subTime", required = false) String subTime,
@RequestParam(value = "nowTime", required = false) String nowTime,
ModelMap map, HttpServletRequest request, HttpServletResponse response){
List<StatictisModel> list=ffmResolve.selectDevList(flightno,subTime,nowTime);
ExportParams params = new ExportParams("进港舱单统计", "进港舱单统计");
map.put(NormalExcelConstants.DATA_LIST, list);
map.put(NormalExcelConstants.CLASS, StatictisModel.class);
map.put(NormalExcelConstants.PARAMS, params);
map.put(NormalExcelConstants.FILE_NAME, "进港舱单统计");
PoiBaseView.render(map, request, response, NormalExcelConstants.EASYPOI_EXCEL_VIEW);
// return new ResultJson("200","success");
}
@RequestMapping(value = "/exportExcel")
public void exportExcel(String id,HttpServletResponse response) throws Exception {
List<StatictisModel> list=ffmResolve.selectDevList(null,"2018-06-06","2018-06-08");
ExportParams params = new ExportParams("进港舱单统计", "进港舱单统计");
Workbook workbook = ExcelExportUtil.exportExcel(params, StatictisModel.class, list);
String fileName = "saleData.xlsx";
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel; charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
OutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
}
}
//@Data
//class ExcelDemo {
//
// @Excel(name = "员工名称")
// private String employeesName;
//
// @Excel(name = "员工图片",type = 2 ,width = 30 , height = 50)
// private String image;
//
// @Excel(name = "员工年龄")
// private Integer age;
//
// @Excel(name = "创建日期", format = "yyyy-MM-dd HH:mm", width = 20)
// private Date createDate;
//
// @Excel(name = "更新日期", format = "yyyy/MM/dd HH:mm", width = 20)
// private Date updateDate;
//
//}