|
@@ -123,15 +123,26 @@ public class OrderAdminController {
|
|
|
|
|
|
@RequestMapping("export.html")
|
|
|
@ResponseBody
|
|
|
- public void exposrtdown(HttpServletResponse response) throws Exception {
|
|
|
- List<Downloadlist> downloadlists = downloadlistService.downloadList(1, 10000, "", "", "");
|
|
|
- HSSFWorkbook wb = export(downloadlists);
|
|
|
- response.setContentType("application/vnd.ms-excel");
|
|
|
- response.setHeader("Content-disposition", "attachment;filename=" + new String("产品下载记录".getBytes(), "ISO8859-1") + ".xls");
|
|
|
- OutputStream ouputStream = response.getOutputStream();
|
|
|
- wb.write(ouputStream);
|
|
|
- ouputStream.flush();
|
|
|
- ouputStream.close();
|
|
|
+ public void exposrtdown(HttpServletResponse response, int type) throws Exception {
|
|
|
+ if (type == 2) {
|
|
|
+ List<Downloadlist> downloadlists = downloadlistService.downloadList(1, 10000, "", "", "");
|
|
|
+ HSSFWorkbook wb = export(downloadlists);
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + new String("产品下载记录".getBytes(), "ISO8859-1") + ".xls");
|
|
|
+ OutputStream ouputStream = response.getOutputStream();
|
|
|
+ wb.write(ouputStream);
|
|
|
+ ouputStream.flush();
|
|
|
+ ouputStream.close();
|
|
|
+ } else {
|
|
|
+ List<Orders> orders = orderService.ORDERS_LIST(1, 10000, 1, 0);
|
|
|
+ HSSFWorkbook wb = exports(orders);
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + new String("充值记录".getBytes(), "ISO8859-1") + ".xls");
|
|
|
+ OutputStream ouputStream = response.getOutputStream();
|
|
|
+ wb.write(ouputStream);
|
|
|
+ ouputStream.flush();
|
|
|
+ ouputStream.close();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -195,6 +206,62 @@ public class OrderAdminController {
|
|
|
return wb;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 表格导出
|
|
|
+ * @Param: [page, rows]
|
|
|
+ * @return: org.springframework.web.servlet.ModelAndView
|
|
|
+ * @Author: Cc
|
|
|
+ * @Date: 2019-12-19
|
|
|
+ */
|
|
|
+ String[] excelHeaders = {"序列号", "用户id", "用户昵称", "订单编号", "充值金额", "充值方式", "充值时间"};
|
|
|
+
|
|
|
+ public HSSFWorkbook exports(List<Orders> orders) {
|
|
|
+ HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
+ HSSFSheet sheet = wb.createSheet("Balances");
|
|
|
+ HSSFRow row = sheet.createRow((int) 0);
|
|
|
+ HSSFCellStyle style = wb.createCellStyle();
|
|
|
+ style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
+ for (int i = 0; i < excelHeaders.length; i++) {
|
|
|
+ HSSFCell cell = row.createCell(i);
|
|
|
+ cell.setCellValue(excelHeaders[i]);
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ sheet.autoSizeColumn(i);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < orders.size(); i++) {
|
|
|
+ Orders itme = orders.get(i);
|
|
|
+ try {
|
|
|
+ Users users = usersService.selectByKey(itme.getUsersid());
|
|
|
+ itme.setUsers(users);
|
|
|
+ row = sheet.createRow(i + 1);
|
|
|
+ row.createCell(0).setCellValue(itme.getId());
|
|
|
+ row.createCell(1).setCellValue(itme.getUsers().getId());
|
|
|
+ row.createCell(2).setCellValue(itme.getUsers().getUsername());
|
|
|
+ row.createCell(3).setCellValue(itme.getOrdersid());
|
|
|
+ row.createCell(4).setCellValue(itme.getMoneys());
|
|
|
+ row.createCell(5).setCellValue(itme.getWay());
|
|
|
+ row.createCell(6).setCellValue(fms.format(itme.getAddtime()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //求和行
|
|
|
+// row = sheet.createRow(list.size() + 1);
|
|
|
+// row.createCell(0).setCellValue("入账总计");
|
|
|
+// row.createCell(1).setCellValue(reprice);
|
|
|
+// row.createCell(2).setCellValue("支出总计:");
|
|
|
+// row.createCell(3).setCellValue(payprice);
|
|
|
+// row.createCell(4).setCellValue("小计:");
|
|
|
+// row.createCell(5).setCellValue(reprice - payprice);
|
|
|
+ sheet.autoSizeColumn((short) 0);
|
|
|
+ sheet.autoSizeColumn((short) 1);
|
|
|
+ sheet.autoSizeColumn((short) 2);
|
|
|
+ sheet.autoSizeColumn((short) 3);
|
|
|
+ sheet.autoSizeColumn((short) 4);
|
|
|
+ sheet.autoSizeColumn((short) 5);
|
|
|
+ return wb;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @return org.springframework.web.servlet.ModelAndView
|
|
|
* @Author Cc
|