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);
}
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());
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);
}