@SuppressWarnings({ "rawtypes", "unchecked" })
public Map<String, Object> getNewStatement(HttpServletRequest request,
HttpServletResponse response,Long grantId,String type,String operate,String columnJson) throws UnsupportedEncodingException, IOException {
List<Map<String,Object>> lMap=new ArrayList<Map<String,Object>>();
List<Map<String,Object>> cMap=new ArrayList<Map<String,Object>>();
lMap=grantApplicationPersistence.findBySql(sql.toString(),names, condition1);
Map <String, Object> colMap=new HashMap<String, Object>();
Map<String, Object> footer= getCountMap();
if("1".equals(type)){
List<List<ColumnVO>> frozenColumnsList =new ArrayList<List<ColumnVO>>();
List<ColumnVO> frozenColumnsList1= new ArrayList<ColumnVO>();
// field 字段名 名称 宽度 对齐方式 是否影藏 是否复选框 是否排序 是否冻结列
frozenColumnsList1.add(new ColumnVO("townCode","列名",80,"right",true,false,true,false,null));
frozenColumnsList1.add(new ColumnVO("townName","列名",80,"left",false,false,true,true,"linkStyle"));
frozenColumnsList.add(frozenColumnsList1);
colMap.put("frozenColumns", frozenColumnsList);
List<List<ColumnVO>> columnsList =new ArrayList<List<ColumnVO>>();
List<ColumnVO> columnsList1= new ArrayList<ColumnVO>();
List<ColumnVO> columnsList2= new ArrayList<ColumnVO>();
columnsList1.add(new ColumnVO("currentTotalSum","列名",80,"right",2,null));
columnsList1.add(new ColumnVO("currentTotalMoney","列名",80,"right",2,null,"valueToFixed"));
columnsList1.add(new ColumnVO("successPerson","列名",80,"right",2,null));
columnsList1.add(new ColumnVO("successMoney","列名",80,"right",2,null,"valueToFixed"));
columnsList1.add(new ColumnVO("failPerson","列名",80,"right",2,null,"nonzeroWarning"));
columnsList1.add(new ColumnVO("failMoney","列名",80,"right",2,null,"nonzeroWarning"));
columnsList1.add(new ColumnVO("updatePerson","列名",80,"right",2,null));
for (int j = 0; j < bankList.size(); j++) {
columnsList1.add(new ColumnVO("",bankList.get(j).get("name").toString(),80,"",null,2));
columnsList2.add(new ColumnVO("person"+bankList.get(j).get("code"),"列名",80,"right","nonzeroWarning"));
columnsList2.add(new ColumnVO("money"+bankList.get(j).get("code"),"列名",80,"right","nonzeroWarningFixed"));
footer.put("person"+bankList.get(j).get("code"), 0);
footer.put("money"+bankList.get(j).get("code"), 0);
}
columnsList.add(columnsList1);
columnsList.add(columnsList2);
colMap.put("columns", columnsList);
}
Set key=footer.keySet();
for (Map<String, Object> map : lMap) {
for (Object object : key) {
if(!"townCode".equals(object.toString())){
if(!"townName".equals(object.toString())){
double num=Double.valueOf(Assert.isNotEmpty(footer.get(object.toString()))==true?footer.get(object.toString()).toString():"0");
double a= Assert.isNotEmpty(map.get(object))?Double.valueOf(map.get(object).toString()):0;
footer.put(object.toString(),num+=a );
}else{
footer.put(object.toString(),"合计");
}
}
}
}
cMap.add(footer);
Map <String, Object> mpAll = new HashMap <String, Object>();
Map <String, Object> mp = new HashMap <String, Object>();
mp.put("total", lMap.size());
mp.put("rows", lMap);
mp.put("footer",cMap);
if("1".equals(type)){
mpAll.put("columnsMp",colMap);
mpAll.put("ta", mp);
if(Assert.isNotEmpty(operate)){
List<Map<String,Object>> date= (List<Map<String, Object>>) mp.get("rows");
List<Map<String,Object>> footerDate= (List<Map<String, Object>>) mp.get("footer");
for (Map<String, Object> map : footerDate) {
date.add(map);
}
new WorkbookUtil().exportToCollect(request, response, operate,"表名", columnJson,date);
return null;
}
return mpAll;
}
if(Assert.isNotEmpty(operate)){
List<Map<String,Object>> date= (List<Map<String, Object>>) mp.get("rows");
List<Map<String,Object>> footerDate= (List<Map<String, Object>>) mp.get("footer");
for (Map<String, Object> map : footerDate) {
date.add(map);
}
new WorkbookUtil().exportToCollect(request, response, operate,"表名", columnJson,date);
return null;
}
return mp;
}