|
|
package com.agent.controller.system;
|
|
|
|
|
|
import com.agent.service.system.FilghtDateService;
|
|
|
import com.agent.util.ExcelExportUtil;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.OutputStream;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@RequestMapping(value = "/filghtdate")
|
|
|
@RestController
|
|
|
public class FilghtDateController{
|
|
|
|
|
|
@Autowired
|
|
|
private FilghtDateService filghtDateService;
|
|
|
|
|
|
@RequestMapping(value = "/list")
|
|
|
public String filghtList(){
|
|
|
return "system/user/filghtdateconut";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 航班日期统计 导出excel
|
|
|
* @param filghtdate1
|
|
|
* @param filghtdate2
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/filghtCount")
|
|
|
@ResponseBody
|
|
|
public void filghtcount(HttpServletRequest request, HttpServletResponse response, String filghtdate1, String filghtdate2) {
|
|
|
|
|
|
// 获取数据
|
|
|
List<Map<String, Object>> filghtcount = filghtDateService.filghtcount(filghtdate1, filghtdate2);
|
|
|
|
|
|
//excel标题
|
|
|
String[] title = {"运单号", "航空托运人名称", "航空销售代理人名称", "航协编号", "航空公司运输证明", "运输条件鉴定书","承运人",
|
|
|
"航班号", "航班日期","航班起始站","航班目的站","运单件数","运单重量","操作时间","关区","预配品名","收货人公司",
|
|
|
"收货人地址","收货人城市","收货人国家","收货人电话","收货人名称","发货人名称","发货人地址","发货人城市","发货人国家",
|
|
|
"发货人电话","发货人名称","海关回执状态","海关回执信息","发货人编码","收货人编码","货物品名","二级类名称","一级类名称",
|
|
|
"代理人三字码","代理人全称","代理人类别","代理联系人","代理联系人电话"};
|
|
|
|
|
|
//excel文件名
|
|
|
String fileName = "测试" + System.currentTimeMillis() + ".xls";
|
|
|
//sheet名
|
|
|
String sheetName = "测试统计";
|
|
|
|
|
|
String[][] content = new String[0][];
|
|
|
/**
|
|
|
* 可能空指针异常
|
|
|
*/
|
|
|
for (int i = 0; i < filghtcount.size(); i++) {
|
|
|
content = new String[title.length][];
|
|
|
Map<String, Object> map = filghtcount.get(i);
|
|
|
|
|
|
content[i][0] = map.get("SD_WAYBILL").toString();
|
|
|
content[i][1] = map.get("SD_CARGO_SHIPPER_NAME").toString();
|
|
|
content[i][2] = map.get("SD_CARGO_AGENT_NAME").toString();
|
|
|
content[i][3] = map.get("SD_IATA_NUMBER").toString();
|
|
|
content[i][4] = map.get("SD_TRANSPORT_CERTIFICATE").toString();
|
|
|
content[i][5] = map.get("SD_TRANSPORTATION_PROVE").toString();
|
|
|
content[i][6] = map.get("CARRIER").toString();
|
|
|
content[i][7] = map.get("FLIGHTNO").toString();
|
|
|
content[i][8] = map.get("FLIGHTDATE").toString();
|
|
|
content[i][9] = map.get("ORIGINATINGSTATION").toString();
|
|
|
content[i][10] = map.get("DESTINATIONSTATION").toString();
|
|
|
content[i][11] = map.get("TOTALPIECE").toString();
|
|
|
content[i][12] = map.get("TOTALWEIGHT").toString();
|
|
|
content[i][13] = map.get("STOWAGEDATE").toString();
|
|
|
content[i][14] = map.get("CUSTOMSCODE").toString();
|
|
|
content[i][15] = map.get("SH_COMPANY").toString();
|
|
|
content[i][16] = map.get("SH_ADDRESS").toString();
|
|
|
content[i][17] = map.get("SH_CITY").toString();
|
|
|
content[i][18] = map.get("SH_COUNTRY").toString();
|
|
|
content[i][19] = map.get("SH_TELEPHONE").toString();
|
|
|
content[i][20] = map.get("SH_NAME").toString();
|
|
|
content[i][21] = map.get("CO_COMPANY").toString();
|
|
|
content[i][22] = map.get("CO_ADDRESS").toString();
|
|
|
content[i][23] = map.get("CO_CITY").toString();
|
|
|
content[i][24] = map.get("CO_COUNTRY").toString();
|
|
|
content[i][25] = map.get("CO_TELEPHONE").toString();
|
|
|
content[i][26] = map.get("CO_NAME").toString();
|
|
|
content[i][27] = map.get("RESPONSE_CODE").toString();
|
|
|
content[i][28] = map.get("RESPONSE_TEXT").toString();
|
|
|
content[i][29] = map.get("SHPCUSID").toString();
|
|
|
content[i][30] = map.get("CNECUSID").toString();
|
|
|
content[i][31] = map.get("SD_CARGO_NAME").toString();
|
|
|
content[i][32] = map.get("TWO_TYPE_NAME").toString();
|
|
|
content[i][33] = map.get("TYPE_NAME").toString();
|
|
|
content[i][34] = map.get("FOR_SHORT").toString();
|
|
|
content[i][35] = map.get("FULL_NAME").toString();
|
|
|
content[i][36] = map.get("THE_SHIPPER_TYPE").toString();
|
|
|
content[i][37] = map.get("CONTACTS").toString();
|
|
|
content[i][38] = map.get("PHONE").toString();
|
|
|
|
|
|
}
|
|
|
//创建HSSFWorkbook
|
|
|
|
|
|
HSSFWorkbook wb = ExcelExportUtil.getHSSFWorkbook(sheetName, title, content, null);
|
|
|
//响应到客户端
|
|
|
try {
|
|
|
this.setResponseHeader(response, fileName);
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
wb.write(os);
|
|
|
os.flush();
|
|
|
os.close();
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//发送响应流方法
|
|
|
public void setResponseHeader(HttpServletResponse response, String fileName) {
|
|
|
try {
|
|
|
try {
|
|
|
fileName = new String(fileName.getBytes(),"ISO8859-1");
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
response.setContentType("application/octet-stream;charset=ISO8859-1");
|
|
|
response.setHeader("Content-Disposition", "attachment;filename="+ fileName);
|
|
|
response.addHeader("Pargam", "no-cache");
|
|
|
response.addHeader("Cache-Control", "no-cache");
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|