1 @RequestMapping(value = "/export", method = RequestMethod.POST)
2 public void export(HttpServletResponse response,@RequestBody UbsOperateRecordDto u) {
3 //根据条件查询出要导出的数据
4 List ubsOperateRecords = ubsOperateRecordService.export(u);
5
6 String fileName = "用户行为记录_" + DateUtil.getCurrentDate(DateUtil.ZH_CN_DP_NO_TRIM);
7 // 默认Sheet是1
8 String sheetName = "1";
9
10 try {
11 // 添加响应头信息
12 response.setHeader("Pragma", "No-cache");//设置头
13 response.setHeader("Cache-Control", "no-cache");// 设置头
14 response.setDateHeader("Expires", 0);// 设置日期头
15 log.info("下载文件名称为:"+fileName);
16 fileName = URLEncoder.encode(fileName, "UTF-8");
17 response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
18 response.setContentType("application/vnd.ms-excel");
19 //设置Excel信息
20 ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();
21 //设置单元格信息
22 WriteSheet writeSheet = EasyExcel.writerSheet(sheetName).head(UbsOperateRecord.class).build();
23 //开始导出数据
24 excelWriter.write(ubsOperateRecords, writeSheet);
25 excelWriter.finish();
26 } catch (IOException e) {
27 e.printStackTrace();
28 } finally {
29 try {
30 response.getOutputStream().close();
31 } catch (IOException e) {
32 e.printStackTrace();
33 }
34 }
35
36 }
1 public class UbsOperateRecord {
2
3 @ExcelProperty("ID号")
4 private Long sid;
5
6 @ExcelProperty("来源类型")
7 private String sourceType;
8
9 @ExcelProperty("事件类型")
10 private String actionClass;
11
12 @ExcelProperty("代理人编码")
13 private String actionType;
14
15 @ExcelProperty("访问时间")
16 private Date transDate;
17
18 @ExcelProperty("请求路径")
19 private String accessUrl;
20
21 @ExcelProperty("请求路径参数")
22 private String accessParam;
23
24 @ExcelProperty("资源名称")
25 private String accessTitle;
26
27 @ExcelProperty("资源路径")
28 private String sourceUrl;
29
30 @ExcelProperty("Ip地址")
31 private String ipAddress;
32
33 @ExcelProperty("客户号")
34 private String customerId;
35
36 @ExcelIgnore
37 private String sessionId;
38
39 @ExcelProperty("统计参数")
40 private String collectInfo;
41
42 @ExcelProperty("设备信息")
43 private String deviceInfo;
44
45 @ExcelIgnore
46 private String phoneNo;
47
48 @ExcelProperty("浏览器信息")
49 private String broswerInfo;
50
51 @ExcelIgnore
52 private String userAgent;
53
54 @ExcelIgnore
55 private String remark;
56
57 @ExcelIgnore
58 private String createdUser;
59
60 @ExcelIgnore
61 private Date createdDate;
62
63 @ExcelIgnore
64 private String modifiedUser;
65
66 @ExcelIgnore
67 private Date modifiedDate;
68
69 @ExcelIgnore
70 private String isDelete;
71
72 @ExcelProperty("comid")
73 private String comId;
74
75 @ExcelIgnore
76 private String comRemark;
77
78 @ExcelProperty("销售计划编码")
79 private String itemCode;
80
81 @ExcelIgnore
82 private String activityCode;
83
84 @ExcelProperty("REQUEST_URL")
85 private String requestUrl;
86
87 @ExcelProperty("业务操作ID")
88 private String businessOperateId;
89
90 @ExcelProperty("业务操作类型")
91 private String operateIdType;
92
93 @ExcelProperty("tokenKey")
94 private String tokenKey;
95
96 @ExcelProperty("渠道号")
97 private String channelNo;
98
99 @ExcelProperty("渠道机构编码")
100 private String appCode;
101 @ExcelProperty("token")
102 private String token;
103
104 public Long getSid() {
105 return sid;
106 }