BeanUtils Object 取值赋值

/**
* 将结果集导出为Excel
*
* @param response
* @param fsc
* @param columns
* @param bizType
* @throws Exception
*/
@RequestMapping("/downExcel")
public void downExcel(HttpServletResponse response, FormSearchCondition fsc, @RequestParam(value = "columns") String columns, String bizType) throws Exception {
Page<Object> page = new Page<Object>();
page.setPageSize(50000);
List<?> list = this.docQueryManager.findDynamicDocPage(page, fsc, bizType).getResult();
String fileName = BizTypeEnum.getBizTypeEnumByVal(bizType).getName();

/*List<TSysDept> companyList = systemCommonManager.findMainByType(fsc, MainBodyEnum.COMPANY);
Map<String, String> mapCompany = new HashMap<String, String>();
for(TSysDept temp : companyList){
mapCompany.put(temp.getCompanyCode(), temp.getCompanyName());
}*/
JSONObject units = JSONObject.parseObject(getSessionCurrentUser().getUserDeptListJson());
JSONArray colArray = JSONObject.parseArray(columns);
for (Object obj : list) {
for (int i = 0; i < colArray.size(); i++) {
JSONObject objJson = colArray.getJSONObject(i);
try {
String companyNo = BeanUtils.getProperty(obj, objJson.getString("name"));
if("companyNo".equalsIgnoreCase(objJson.getString("name"))){
String companyName = units.getString(companyNo);
BeanUtils.setProperty(obj, objJson.getString("name"), companyName);
}
} catch (Exception e) {
}
}
}
reportManager.downExcel(fileName, new ArrayList<Object>(list), columns, response);
}

上一篇:Nagios 如何实现自定义多功能告警


下一篇:使用jenkins 插件自动部署项目至tomcat