...
|
...
|
@@ -68,7 +68,8 @@ public class SpecialController { |
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(params = "method=getStyleListSel")
|
|
|
// @RequestMapping(params = "method=getStyleListSel")
|
|
|
@RequestMapping(params = "/getStyleListSel")
|
|
|
@ResponseBody
|
|
|
public JSONArray getStyleListSel(EnumTypeRequestBean enumTypeRequestBean) {
|
|
|
logger.info("begin getStyleListSel");
|
...
|
...
|
@@ -149,80 +150,80 @@ public class SpecialController { |
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 导出表格的excel表格
|
|
|
*
|
|
|
* @param param 批量导出的业务类型
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/export")
|
|
|
public String export(HttpServletResponse response, @RequestBody ExportParam param) {
|
|
|
File file;
|
|
|
try {
|
|
|
file = batchService.batchExport(param);
|
|
|
} catch (PlatformException e) {
|
|
|
logger.warn("export find wrong.", e);
|
|
|
return writeErrorInfo(response, e.getMessage());
|
|
|
} catch (Exception e) {
|
|
|
logger.warn("export find wrong.", e);
|
|
|
return writeErrorInfo(response, "<p>导出记录条数太多</p>");
|
|
|
}
|
|
|
try {
|
|
|
return writeFile(response, file.getName(), new FileInputStream(file), "application/vnd.ms-excel");
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
|
logger.warn("writeFile find wrong.", e);;
|
|
|
return writeErrorInfo(response, "文件不存在");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private String writeErrorInfo(HttpServletResponse response, String string) {
|
|
|
PrintWriter printWriter = null;
|
|
|
response.setHeader("Content-type", "text/html;charset=UTF-8");
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
try {
|
|
|
printWriter = response.getWriter();
|
|
|
printWriter.print(new String(string.getBytes("UTF-8"), "UTF-8"));
|
|
|
printWriter.flush();
|
|
|
} catch (IOException e) {
|
|
|
logger.warn("OS.write find wrong.", e);
|
|
|
} finally {
|
|
|
if (null != printWriter) {
|
|
|
try {
|
|
|
printWriter.close();
|
|
|
} catch (Exception e) {
|
|
|
logger.warn("OS.close find wrong.", e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 向 response 中,写入文件
|
|
|
*/
|
|
|
private String writeFile(HttpServletResponse response, String fileName, InputStream inputStream, String contentType) {
|
|
|
checkNotNull(inputStream, "inputStream is null!");
|
|
|
String msg = null;
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
response.setContentType(contentType);
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
|
|
|
try {
|
|
|
byte[] b = new byte[2048];
|
|
|
int length;
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
while ((length = inputStream.read(b)) > 0) {
|
|
|
os.write(b, 0, length);
|
|
|
}
|
|
|
os.close();
|
|
|
inputStream.close();
|
|
|
} catch (FileNotFoundException e) {
|
|
|
e.printStackTrace();
|
|
|
msg = "File not found";
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
msg = "Read file error";
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
// /**
|
|
|
// * 导出表格的excel表格
|
|
|
// *
|
|
|
// * @param param 批量导出的业务类型
|
|
|
// * @return
|
|
|
// */
|
|
|
// @RequestMapping(value = "/export")
|
|
|
// public String export(HttpServletResponse response, @RequestBody ExportParam param) {
|
|
|
// File file;
|
|
|
// try {
|
|
|
// file = batchService.batchExport(param);
|
|
|
// } catch (PlatformException e) {
|
|
|
// logger.warn("export find wrong.", e);
|
|
|
// return writeErrorInfo(response, e.getMessage());
|
|
|
// } catch (Exception e) {
|
|
|
// logger.warn("export find wrong.", e);
|
|
|
// return writeErrorInfo(response, "<p>导出记录条数太多</p>");
|
|
|
// }
|
|
|
// try {
|
|
|
// return writeFile(response, file.getName(), new FileInputStream(file), "application/vnd.ms-excel");
|
|
|
// } catch (FileNotFoundException e) {
|
|
|
//
|
|
|
// logger.warn("writeFile find wrong.", e);;
|
|
|
// return writeErrorInfo(response, "文件不存在");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// private String writeErrorInfo(HttpServletResponse response, String string) {
|
|
|
// PrintWriter printWriter = null;
|
|
|
// response.setHeader("Content-type", "text/html;charset=UTF-8");
|
|
|
// response.setCharacterEncoding("UTF-8");
|
|
|
// try {
|
|
|
// printWriter = response.getWriter();
|
|
|
// printWriter.print(new String(string.getBytes("UTF-8"), "UTF-8"));
|
|
|
// printWriter.flush();
|
|
|
// } catch (IOException e) {
|
|
|
// logger.warn("OS.write find wrong.", e);
|
|
|
// } finally {
|
|
|
// if (null != printWriter) {
|
|
|
// try {
|
|
|
// printWriter.close();
|
|
|
// } catch (Exception e) {
|
|
|
// logger.warn("OS.close find wrong.", e);
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// return null;
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * 向 response 中,写入文件
|
|
|
// */
|
|
|
// private String writeFile(HttpServletResponse response, String fileName, InputStream inputStream, String contentType) {
|
|
|
// checkNotNull(inputStream, "inputStream is null!");
|
|
|
// String msg = null;
|
|
|
// response.setCharacterEncoding("utf-8");
|
|
|
// response.setContentType(contentType);
|
|
|
// response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
|
|
|
// try {
|
|
|
// byte[] b = new byte[2048];
|
|
|
// int length;
|
|
|
// OutputStream os = response.getOutputStream();
|
|
|
// while ((length = inputStream.read(b)) > 0) {
|
|
|
// os.write(b, 0, length);
|
|
|
// }
|
|
|
// os.close();
|
|
|
// inputStream.close();
|
|
|
// } catch (FileNotFoundException e) {
|
|
|
// e.printStackTrace();
|
|
|
// msg = "File not found";
|
|
|
// } catch (IOException e) {
|
|
|
// e.printStackTrace();
|
|
|
// msg = "Read file error";
|
|
|
// }
|
|
|
// return msg;
|
|
|
// }
|
|
|
} |
...
|
...
|
|