@RequestMapping(value = "/showDispose", method = RequestMethod.POST)
public void showDispose(HttpServletResponse response, HttpSession session,PrintWriter printWriter,String page,String rows,
String clzt,String tsrqq,String tsrqz,String js,String gjz,String s_province,String s_city,String s_county){
String zmclzt = ZMStringTest(clzt);
String zmtsrqq = ZMStringTest(tsrqq);
String zmtsrqz = ZMStringTest(tsrqz);
String zmjs = ZMStringTest(js);
String zmProvince = ZMStringTest(s_province);
String zmCity = ZMStringTest(s_city);
String zmCounty = ZMStringTest(s_county);
String zmGjz = ZMStringTest(gjz);
int pageInt = 1;
int rowsInt = 20;
Long total = 0l;
Timestamp stime=null; Timestamp etime=null;
if(zmtsrqq!=null&&!zmtsrqq.equals("")&&zmtsrqz!=null&&!zmtsrqz.equals("")){
stime=Timestamp.valueOf(zmtsrqq+" 00:00:00");
etime=Timestamp.valueOf(zmtsrqz+" 00:00:00");
}
try {
if (page != null){
pageInt = Integer.parseInt(page);
}
if (rows != null) {
rowsInt = Integer.parseInt(rows);
}
List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
total = tousuService.getAllCount();
List<WxToushu> wxToushuList = tousuService.getTousuByCondition((pageInt-1)*rowsInt,rowsInt,zmclzt,stime,etime,zmjs,zmGjz,zmProvince,zmCity,zmCounty);
for(int i=0;i<wxToushuList.size();i++){
WxToushu wxToushu = wxToushuList.get(i);
Map<String,Object> map = new HashMap<String, Object>();
Integer orderid = wxToushu.getIdwxOrder();//得到订单
Integer userid = wxToushu.getIdwxUser();//得到用户
Integer wxyid = wxToushu.getIdwxWeixiuyuan();//得到维修员
WxOrder wxOrder = orderService.getById(orderid);
WxUser wxUser = userService.getById(userid);
WxWeixiuyuan wxWeixiuyuan = weixiuyuanService.getById(wxyid);
map.put("id",wxToushu.getIdwxToushu());//投诉ID
map.put("wxDanhao",wxOrder.getWxDanhao());//订单号
map.put("wxToushuDengjiriqi",wxToushu.getWxToushuDengjiriqi().toString());//投诉日期
map.put("wxUserName",wxUser.getWxUserName());//投诉人
map.put("wxUserTelephone",wxUser.getWxUserGongshilianxirendianhua());//投诉人电话
map.put("idwxWeixiuyuan", wxWeixiuyuan.getIdwxWeixiuyuan().toString());//服务工号
map.put("wxToushuFuwudianqi",wxToushu.getWxToushuFuwudianqi());//电器类别
map.put("heji",wxOrder.getHeji().toString());//合计收费
map.put("wxWeixiuyuanUsername",wxWeixiuyuan.getWxWeixiuyuanUsername());//服务技师
map.put("wxToushuXiangqing",wxToushu.getWxToushuXiangqing());//投诉内容
map.put("wxToushuDisposeStatus",wxToushu.getWxToushuDisposeStatus()==0?"未处理":"已处理");//投诉处理状态
map.put("wxToushuDisposeTime",wxToushu.getWxToushuDisposeTime());//投诉处理时间
map.put("wxToushuDisposeCourse",wxToushu.getWxToushuDisposeCourse());//投诉处理过程
map.put("wxToushuDisposePenalize",wxToushu.getWxToushuDisposePenalize().toString());//处罚金额
mapList.add(map);
}
session.setAttribute("ShowDispose",mapList);//导出做铺垫
Map<String, Object> jsonMap = new HashMap<String, Object>();//定义map
jsonMap.put("total",total);
jsonMap.put("rows",mapList);
String str = JSON.toJSONString(jsonMap);
response.setContentType("text/html;charset=utf-8");
printWriter.write(str);
} catch (Exception e) {
e.printStackTrace();
}finally {
printWriter.close();
}
}
//投诉查询导出
@RequestMapping(value = "/sho_dispose_excel", method = RequestMethod.GET)
public void exportShowDisposeExcel(HttpSession session,HttpServletResponse response) throws Exception{
List<Map> showRecommendList=(List<Map>)session.getAttribute("ShowDispose") ;//得到上文的值
String [] title={"订单","投诉日期","投诉人","投诉人电话","服务工单号","电器类别","合计收费","服务技师","投诉内容","状态","处理时间","处理过程","处罚金额"};
//创建工作薄
HSSFWorkbook wb=new HSSFWorkbook();
HSSFCellStyle style=wb.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//创建表
HSSFSheet sheet=wb.createSheet("投诉信息表");
//创建标题行
HSSFRow headRow=sheet.createRow(0);
//循环创建列
for (short i = 0; i < title.length; i++) {
HSSFCell cell=headRow.createCell(i);
cell.setCellValue(new HSSFRichTextString(title[i]));
}
for (int i = 0; i < showRecommendList.size(); i++) {
Map<String,String> map=showRecommendList.get(i);
//创建数据行
HSSFRow row=sheet.createRow(i+1);
//创建数据列
HSSFCell cell1=row.createCell((short)0);
//为每一列赋值
cell1.setCellValue(new HSSFRichTextString(map.get("wxDanhao")));
HSSFCell cell2=row.createCell((short)1);
cell2.setCellValue(new HSSFRichTextString(map.get("wxToushuDengjiriqi")));
HSSFCell cell3=row.createCell((short)2);
cell3.setCellValue(new HSSFRichTextString(map.get("wxUserName")));
HSSFCell cell4=row.createCell((short)3);
cell4.setCellValue(new HSSFRichTextString(map.get("wxUserTelephone")));
HSSFCell cell5=row.createCell((short)4);
cell5.setCellValue(new HSSFRichTextString(map.get("idwxWeixiuyuan")));
HSSFCell cell6=row.createCell((short)5);
cell6.setCellValue(new HSSFRichTextString(map.get("wxToushuFuwudianqi")));
HSSFCell cell7=row.createCell((short)6);
cell7.setCellValue(new HSSFRichTextString(map.get("heji")));
HSSFCell cell8=row.createCell((short)7);
cell8.setCellValue(new HSSFRichTextString(map.get("wxWeixiuyuanUsername")));
HSSFCell cell9=row.createCell((short)8);
cell9.setCellValue(new HSSFRichTextString(map.get("wxToushuXiangqing")));
HSSFCell cell10=row.createCell((short)9);
cell10.setCellValue(new HSSFRichTextString(map.get("wxToushuDisposeStatus")));
HSSFCell cell11=row.createCell((short)10);
cell11.setCellValue(new HSSFRichTextString(map.get("wxToushuDisposeTime")));
HSSFCell cell12=row.createCell((short)11);
cell12.setCellValue(new HSSFRichTextString(map.get("wxToushuDisposeCourse")));
HSSFCell cell13=row.createCell((short)12);
cell13.setCellValue(new HSSFRichTextString(map.get("wxToushuDisposePenalize")));
}
//创建输出流
OutputStream out=response.getOutputStream();
response.setHeader("Content-Disposition", "attachment;filename=ShowDispose.xls");
response.setContentType("application/msexcel;charset=UTF-8");
wb.write(out);
out.flush();//清除缓存
out.close();
}