public ApiResultI18n exportDeviceManReport(HttpServletResponse response,@RequestBody ReportPartBean reportPartBean,HttpServletRequest httpServletRequest) {
String language =httpServletRequest.getHeader("language");
List<Map<String, Object>> dataList = null;
List<DeviceManReportBean> deviceList = reportService.exportDeviceManReport(reportPartBean);// 查询到要导出的信息
if (deviceList.size() == 0) {
return ApiResultI18n.myResponse(ResponseCodeI18n.NO_DATA_EXPORT,null,language);
//return ResultUtil.error(301,"无数据导出!");
}
String fName = "设备管理_";
String sTitle = "设备号,设备名称,绑定人,绑定时间,产品组,大区,国家,代理商";
if("en_US".equals(language)){
fName = "DeviceManagement_";
sTitle = "Device number,Device name,Binding user,Last binding,Device type,Region,Country,Dealer";
}
String mapKey = "deviceNum,deviceName,userMobile,bindingTime,prodGroupDesc,regionDesc,countryDesc,agentDesc";
dataList = new ArrayList<>();
Map<String, Object> map = null;
for (DeviceManReportBean de : deviceList) {
map = new HashMap<>();
map.put("deviceNum", de.getDeviceNum());
map.put("deviceName", de.getDeviceName());
map.put("userMobile", de.getUserMobile()==null?"":de.getUserMobile());
if(null!=de.getBindingTime() && !" ".equals(de.getBindingTime())){
map.put("bindingTime", DateFormatUtils.format(de.getBindingTime(), "yyyy-MM-dd HH:mm:ss"));
}else{
map.put("bindingTime", de.getBindingTime()==null?"":de.getBindingTime());
}
map.put("prodGroupDesc", de.getProdGroupDesc());
map.put("regionDesc", de.getRegionDesc());
map.put("countryDesc", de.getCountryDesc());
map.put("agentDesc", de.getAgentDesc());
//map.put("createDate", DateFormatUtils.format(order.getCreateDate(), "yyyy/MM/dd HH:mm"));
dataList.add(map);
}
try (final OutputStream os = response.getOutputStream()) {
ExportUtil.responseSetProperties(fName, response);
ExportUtil.doExport(dataList, sTitle, mapKey, os);
return null;
} catch (Exception e) {
e.printStackTrace();
}
return ApiResultI18n.myResponse(ResponseCodeI18n.Data_Export_Error,null,language);
//return ResultUtil.error(302,"数据导出出错!");
}
springboot导出cvs
最新推荐文章于 2024-07-01 08:49:35 发布