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-02-05 11:17:34 发布
本文介绍了一个用于设备管理报告导出的API实现,该API能够根据请求参数查询并导出设备信息,支持中英文环境,导出内容包括设备号、设备名称、绑定人等关键字段。
1538

被折叠的 条评论
为什么被折叠?



