|
|
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;
|
|
|
//
|
|
|
//} |
...
|
...
|
|