自行导入poi3.9的jar包

  1. package com.cpic.caf.template.home.util;
  2. import java.io.BufferedOutputStream;
  3. import java.io.FileNotFoundException;
  4. import java.io.FileOutputStream;
  5. import java.io.IOException;
  6. import java.io.OutputStream;
  7. import java.lang.reflect.Field;
  8. import java.lang.reflect.InvocationTargetException;
  9. import java.lang.reflect.Method;
  10. import java.text.SimpleDateFormat;
  11. import java.util.Collection;
  12. import java.util.Date;
  13. import java.util.Iterator;
  14. import java.util.List;
  15. import java.util.Map;
  16. import java.util.Set;
  17. import java.util.regex.Matcher;
  18. import java.util.regex.Pattern;
  19. import javax.servlet.http.HttpServletResponse;
  20. import org.apache.poi.hssf.usermodel.HSSFCell;
  21. import org.apache.poi.hssf.usermodel.HSSFCellStyle;
  22. import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
  23. import org.apache.poi.hssf.usermodel.HSSFComment;
  24. import org.apache.poi.hssf.usermodel.HSSFFont;
  25. import org.apache.poi.hssf.usermodel.HSSFPatriarch;
  26. import org.apache.poi.hssf.usermodel.HSSFRichTextString;
  27. import org.apache.poi.hssf.usermodel.HSSFRow;
  28. import org.apache.poi.hssf.usermodel.HSSFSheet;
  29. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  30. import org.apache.poi.hssf.util.HSSFColor;
  31. /**
  32. *
  33. * @author librag
  34. * @version v1.0
  35. * @param <T>
  36. * 应用泛型,代表任意一个符合javabean风格的类
  37. * 注意这里为了简单起见,boolean型的属性xxx的get器方式为getXxx(),而不是isXxx()
  38. * byte[]表jpg格式的图片数据
  39. */
  40. public class ExportExcel<T>{
  41. public static final String Map = "Map";
  42. public static final String List = "List";
  43. private int List_Size = 0;
  44. /*
  45. public ExportExcel(int List_Size) {
  46. this.List_Size = List_Size;
  47. }
  48. public ExportExcel() {
  49. }*/
  50. /**
  51. * @param title
  52. * 表格标题名
  53. * @param headers
  54. * 表格属性列名数组
  55. * @param dataset 允许的类型(实体类,List<List<Object>>,List<Map<String,Object>>)
  56. * 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
  57. * javabean属性的数据类型有基本数据类型及String,Date,byte[](图片数据)
  58. * @param out
  59. * 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中
  60. * @param pattern
  61. * 如果有时间数据,设定输出格式。默认为"yyy-MM-dd"
  62. Controller示例
  63. //引用浏览器引擎下载
  64. //使用本工具类创建对象
  65. ExportExcel<对象> ex = new ExportExcel<对象>();
  66. //创建列
  67. String[] headers =
  68. { "主键", "从业者ID", "案例是作品集还是婚礼案例", "案例类型", "标题","案例地址","描述","置顶","删除状态","访问量","收藏量"};
  69. //创建值列
  70. List<对象> dataset = Service.方法名();
  71. //调用工具类对象
  72. ex.exportExcel(headers,dataset,response);
  73. //提示
  74. System.out.println("excel导出成功!");
  75. Controller示例2
  76. //直接下载到本地磁盘
  77. //使用本工具类创建对象
  78. ExportExcel<Map<String, Object>> ex = new ExportExcel<对象>();
  79. //创建列
  80. String[] headers =
  81. { "主键", "从业者ID", "案例是作品集还是婚礼案例", "案例类型", "标题","案例地址","描述","置顶","删除状态","访问量","收藏量"};
  82. //创建值列
  83. List<Map<String, Object>> dataset = Service.方法名();
  84. //调用工具类对象
  85. ex.exportExcel(headers,dataset,"E:\\文件夹名\\文件夹名");
  86. //提示
  87. System.out.println("excel导出成功!");
  88. */
  89. /**
  90. * 方法重载同时指向一个unchecked
  91. * @param dataset Value列
  92. * @param response 必须
  93. * @param path (当传入指定path时 方法会使用IO流下载到指定地址(文件夹) || 反之 会引用浏览器的下载引擎)
  94. */
  95. public void exportExcel(Collection<T> dataset,String path){
  96. exportExcel("EXCEL文档", null, dataset, "yyyy-MM-dd",path);
  97. }
  98. public void exportExcel(String[] headers, Collection<T> dataset,String path) {
  99. exportExcel("EXCEL文档", headers, dataset, "yyyy-MM-dd",path);
  100. }
  101. public void exportExcel(String[] headers, Collection<T> dataset, String pattern,String path){
  102. exportExcel("EXCEL文档", headers, dataset, pattern,path);
  103. }
  104. public void exportExcel(Collection<T> dataset,HttpServletResponse response){
  105. exportExcel("EXCEL文档", null, dataset, "yyyy-MM-dd",response);
  106. }
  107. public void exportExcel(String[] headers, Collection<T> dataset,HttpServletResponse response) {
  108. exportExcel("EXCEL文档", headers, dataset, "yyyy-MM-dd",response);
  109. }
  110. public void exportExcel(String[] headers, Collection<T> dataset, String pattern,HttpServletResponse response){
  111. exportExcel("EXCEL文档", headers, dataset, pattern,response);
  112. }
  113. public void exportExcel(String[] headers, List<List<Object>> dataset,HttpServletResponse response) {
  114. exportExcel("EXCEL文档", headers, dataset, "yyyy-MM-dd",response);
  115. }
  116. public void MapExportExcel(String[] headers, List<Map<String, Object>> dataset,HttpServletResponse response) {
  117. exportExcel("EXCEL文档", headers, dataset, "yyyy-MM-dd",response,"Map");
  118. }
  119. /**
  120. * 这是一个通用的方法,利用了JAVA的反射机制,可以将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上
  121. *
  122. * @param title 表格标题名
  123. * @param headers 表格属性列名数组
  124. * @param dataset 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
  125. * javabean属性的数据类型有基本数据类型及String,Date,byte[](图片数据)
  126. * @param pattern 如果有时间数据,设定输出格式。默认为"yyy-MM-dd"
  127. */
  128. @SuppressWarnings("unchecked")
  129. public void exportExcel(String title, String[] headers,Collection<T> dataset, String pattern,String path){
  130. // 声明一个工作薄
  131. HSSFWorkbook workbook = new HSSFWorkbook();
  132. // 生成一个表格
  133. HSSFSheet sheet = workbook.createSheet(title);
  134. // 设置表格默认列宽度为15个字节
  135. sheet.setDefaultColumnWidth((short) 15);
  136. // 生成一个样式
  137. HSSFCellStyle style = workbook.createCellStyle();
  138. // 设置这些样式
  139. style.setFillForegroundColor(HSSFColor.SKY_BLUE.index);
  140. style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  141. style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  142. style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  143. style.setBorderRight(HSSFCellStyle.BORDER_THIN);
  144. style.setBorderTop(HSSFCellStyle.BORDER_THIN);
  145. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  146. // 生成一个字体
  147. HSSFFont font = workbook.createFont();
  148. font.setColor(HSSFColor.VIOLET.index);
  149. font.setFontHeightInPoints((short) 12);
  150. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  151. // 把字体应用到当前的样式
  152. style.setFont(font);
  153. // 生成并设置另一个样式
  154. HSSFCellStyle style2 = workbook.createCellStyle();
  155. style2.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
  156. style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  157. style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  158. style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  159. style2.setBorderRight(HSSFCellStyle.BORDER_THIN);
  160. style2.setBorderTop(HSSFCellStyle.BORDER_THIN);
  161. style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  162. style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
  163. // 生成另一个字体
  164. HSSFFont font2 = workbook.createFont();
  165. font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
  166. // 把字体应用到当前的样式
  167. style2.setFont(font2);
  168. // 声明一个画图的顶级管理器
  169. HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
  170. // 定义注释的大小和位置,详见文档
  171. HSSFComment comment = patriarch.createComment(new HSSFClientAnchor(0,
  172. 0, 0, 0, (short) 4, 2, (short) 6, 5));
  173. // 设置注释内容
  174. comment.setString(new HSSFRichTextString("可以在POI中添加注释!"));
  175. // 设置注释作者,当鼠标移动到单元格上是可以在状态栏中看到该内容.
  176. comment.setAuthor("leno");
  177. // 产生表格标题行
  178. HSSFRow row = sheet.createRow(0);
  179. for (short i = 0; i < headers.length; i++)
  180. {
  181. HSSFCell cell = row.createCell(i);
  182. cell.setCellStyle(style);
  183. HSSFRichTextString text = new HSSFRichTextString(headers[i]);
  184. cell.setCellValue(text);
  185. }
  186. try
  187. {
  188. // 遍历集合数据,产生数据行
  189. Iterator<T> it = dataset.iterator();
  190. int index = 0;
  191. while (it.hasNext())
  192. {
  193. index++;
  194. row = sheet.createRow(index);
  195. T t = (T) it.next();
  196. // 利用反射,根据javabean属性的先后顺序,动态调用getXxx()方法得到属性值
  197. Field[] fields = t.getClass().getDeclaredFields();
  198. for (short i = 0; i < fields.length; i++)
  199. {
  200. HSSFCell cell = row.createCell(i);
  201. cell.setCellStyle(style2);
  202. Field field = fields[i];
  203. String fieldName = field.getName();
  204. String getMethodName = "get"
  205. + fieldName.substring(0, 1).toUpperCase()
  206. + fieldName.substring(1);
  207. Class tCls = t.getClass();
  208. Method getMethod = tCls.getMethod(getMethodName,
  209. new Class[]
  210. {});
  211. Object value = getMethod.invoke(t, new Object[]
  212. {});
  213. // 判断值的类型后进行强制类型转换
  214. String textValue = null;
  215. /* if (value instanceof Integer) {
  216. int intValue = (Integer) value;
  217. cell.setCellValue(intValue);
  218. } else if (value instanceof Float) {
  219. float fValue = (Float) value;
  220. textValue = new HSSFRichTextString(
  221. String.valueOf(fValue));
  222. cell.setCellValue(textValue);
  223. } else if (value instanceof Double) {
  224. double dValue = (Double) value;
  225. textValue = new HSSFRichTextString(
  226. String.valueOf(dValue));
  227. cell.setCellValue(textValue);
  228. } else if (value instanceof Long) {
  229. long longValue = (Long) value;
  230. cell.setCellValue(longValue);
  231. }*/
  232. if (value instanceof Boolean)
  233. {
  234. boolean bValue = (Boolean) value;
  235. textValue = "男";
  236. if (!bValue)
  237. {
  238. textValue = "女";
  239. }
  240. }
  241. else if (value instanceof Date)
  242. {
  243. Date date = (Date) value;
  244. SimpleDateFormat sdf = new SimpleDateFormat(pattern);
  245. textValue = sdf.format(date);
  246. }
  247. else if (value instanceof byte[])
  248. {
  249. // 有图片时,设置行高为60px;
  250. row.setHeightInPoints(60);
  251. // 设置图片所在列宽度为80px,注意这里单位的一个换算
  252. sheet.setColumnWidth(i, (short) (35.7 * 80));
  253. // sheet.autoSizeColumn(i);
  254. byte[] bsValue = (byte[]) value;
  255. HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0,
  256. 1023, 255, (short) 6, index, (short) 6, index);
  257. anchor.setAnchorType(2);
  258. patriarch.createPicture(anchor, workbook.addPicture(
  259. bsValue, HSSFWorkbook.PICTURE_TYPE_JPEG));
  260. }
  261. else
  262. {
  263. // 其它数据类型都当作字符串简单处理
  264. textValue = value.toString();
  265. }
  266. // 如果不是图片数据,就利用正则表达式判断textValue是否全部由数字组成
  267. if (textValue != null)
  268. {
  269. Pattern p = Pattern.compile("^//d+(//.//d+)?$");
  270. Matcher matcher = p.matcher(textValue);
  271. if (matcher.matches())
  272. {
  273. // 是数字当作double处理
  274. cell.setCellValue(Double.parseDouble(textValue));
  275. }
  276. else
  277. {
  278. HSSFRichTextString richString = new HSSFRichTextString(
  279. textValue);
  280. HSSFFont font3 = workbook.createFont();
  281. font3.setColor(HSSFColor.BLUE.index);
  282. richString.applyFont(font3);
  283. cell.setCellValue(richString);
  284. }
  285. }
  286. }
  287. }
  288. }catch (SecurityException e){
  289. e.printStackTrace();
  290. }catch (NoSuchMethodException e){
  291. e.printStackTrace();
  292. }catch (IllegalArgumentException e){
  293. e.printStackTrace();
  294. }catch (IllegalAccessException e){
  295. e.printStackTrace();
  296. }catch (InvocationTargetException e){
  297. e.printStackTrace();
  298. }finally{
  299. // 清理资源
  300. }
  301. //生成文件流
  302. IOExcle(workbook,path);
  303. }
  304. /**
  305. * (网络传输)
  306. * 这是一个通用的方法,利用了JAVA的反射机制,可以将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上
  307. * @param title 表格标题名
  308. * @param headers 表格属性列名数组
  309. * @param dataset 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
  310. * javabean属性的数据类型有基本数据类型及String,Date,byte[](图片数据)
  311. * @param pattern 如果有时间数据,设定输出格式。默认为"yyy-MM-dd"
  312. */
  313. @SuppressWarnings("unchecked")
  314. public void exportExcel(String title, String[] headers,Collection<T> dataset, String pattern,HttpServletResponse response){
  315. response.reset(); // 清除buffer缓存
  316. // 指定下载的文件名
  317. response.setHeader("Content-Disposition", "attachment;filename=contacts" + getDateTimeName() + ".xls");
  318. response.setContentType("application/vnd.ms-excel;charset=UTF-8");
  319. response.setHeader("Pragma", "no-cache");
  320. response.setHeader("Cache-Control", "no-cache");
  321. response.setDateHeader("Expires", 0);
  322. // 声明一个工作薄
  323. HSSFWorkbook workbook = new HSSFWorkbook();
  324. // 生成一个表格
  325. HSSFSheet sheet = workbook.createSheet(title);
  326. // 设置表格默认列宽度为15个字节
  327. sheet.setDefaultColumnWidth((short) 15);
  328. // 生成一个样式
  329. HSSFCellStyle style = workbook.createCellStyle();
  330. // 设置这些样式
  331. style.setFillForegroundColor(HSSFColor.SKY_BLUE.index);
  332. style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  333. style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  334. style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  335. style.setBorderRight(HSSFCellStyle.BORDER_THIN);
  336. style.setBorderTop(HSSFCellStyle.BORDER_THIN);
  337. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  338. // 生成一个字体
  339. HSSFFont font = workbook.createFont();
  340. font.setColor(HSSFColor.VIOLET.index);
  341. font.setFontHeightInPoints((short) 12);
  342. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  343. // 把字体应用到当前的样式
  344. style.setFont(font);
  345. // 生成并设置另一个样式
  346. HSSFCellStyle style2 = workbook.createCellStyle();
  347. style2.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
  348. style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  349. style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  350. style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  351. style2.setBorderRight(HSSFCellStyle.BORDER_THIN);
  352. style2.setBorderTop(HSSFCellStyle.BORDER_THIN);
  353. style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  354. style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
  355. // 生成另一个字体
  356. HSSFFont font2 = workbook.createFont();
  357. font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
  358. // 把字体应用到当前的样式
  359. style2.setFont(font2);
  360. // 声明一个画图的顶级管理器
  361. HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
  362. // 定义注释的大小和位置,详见文档
  363. HSSFComment comment = patriarch.createComment(new HSSFClientAnchor(0,
  364. 0, 0, 0, (short) 4, 2, (short) 6, 5));
  365. // 设置注释内容
  366. comment.setString(new HSSFRichTextString("可以在POI中添加注释!"));
  367. // 设置注释作者,当鼠标移动到单元格上是可以在状态栏中看到该内容.
  368. comment.setAuthor("leno");
  369. // 产生表格标题行
  370. HSSFRow row = sheet.createRow(0);
  371. for (short i = 0; i < headers.length; i++)
  372. {
  373. HSSFCell cell = row.createCell(i);
  374. cell.setCellStyle(style);
  375. HSSFRichTextString text = new HSSFRichTextString(headers[i]);
  376. cell.setCellValue(text);
  377. }
  378. try
  379. {
  380. // 遍历集合数据,产生数据行
  381. Iterator<T> it = dataset.iterator();
  382. int index = 0;
  383. while (it.hasNext()){
  384. index++;
  385. row = sheet.createRow(index);
  386. T t = (T) it.next();
  387. // 利用反射,根据javabean属性的先后顺序,动态调用getXxx()方法得到属性值
  388. Field[] fields = t.getClass().getDeclaredFields();
  389. for (short i = 0; i < fields.length; i++)
  390. {
  391. HSSFCell cell = row.createCell(i);
  392. cell.setCellStyle(style2);
  393. Field field = fields[i];
  394. String fieldName = field.getName();
  395. String getMethodName = "get"
  396. + fieldName.substring(0, 1).toUpperCase()
  397. + fieldName.substring(1);
  398. Class tCls = t.getClass();
  399. Method getMethod = tCls.getMethod(getMethodName,
  400. new Class[]
  401. {});
  402. Object value = getMethod.invoke(t, new Object[]
  403. {});
  404. // 判断值的类型后进行强制类型转换
  405. String textValue = null;
  406. if (value instanceof Boolean)
  407. {
  408. boolean bValue = (Boolean) value;
  409. textValue = "男";
  410. if (!bValue)
  411. {
  412. textValue = "女";
  413. }
  414. }
  415. else if (value instanceof Date)
  416. {
  417. Date date = (Date) value;
  418. SimpleDateFormat sdf = new SimpleDateFormat(pattern);
  419. textValue = sdf.format(date);
  420. }
  421. else if (value instanceof byte[])
  422. {
  423. // 有图片时,设置行高为60px;
  424. row.setHeightInPoints(60);
  425. // 设置图片所在列宽度为80px,注意这里单位的一个换算
  426. sheet.setColumnWidth(i, (short) (35.7 * 80));
  427. // sheet.autoSizeColumn(i);
  428. byte[] bsValue = (byte[]) value;
  429. HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0,
  430. 1023, 255, (short) 6, index, (short) 6, index);
  431. anchor.setAnchorType(2);
  432. patriarch.createPicture(anchor, workbook.addPicture(
  433. bsValue, HSSFWorkbook.PICTURE_TYPE_JPEG));
  434. }
  435. else
  436. {
  437. // 其它数据类型都当作字符串简单处理
  438. textValue = value.toString();
  439. }
  440. // 如果不是图片数据,就利用正则表达式判断textValue是否全部由数字组成
  441. if (textValue != null)
  442. {
  443. Pattern p = Pattern.compile("^//d+(//.//d+)?$");
  444. Matcher matcher = p.matcher(textValue);
  445. if (matcher.matches())
  446. {
  447. // 是数字当作double处理
  448. cell.setCellValue(Double.parseDouble(textValue));
  449. }
  450. else
  451. {
  452. HSSFRichTextString richString = new HSSFRichTextString(
  453. textValue);
  454. HSSFFont font3 = workbook.createFont();
  455. font3.setColor(HSSFColor.BLUE.index);
  456. richString.applyFont(font3);
  457. cell.setCellValue(richString);
  458. }
  459. }
  460. }
  461. }//while
  462. }catch (SecurityException e){
  463. e.printStackTrace();
  464. }catch (NoSuchMethodException e){
  465. e.printStackTrace();
  466. }catch(IllegalArgumentException e) {
  467. e.printStackTrace();
  468. }catch (IllegalAccessException e){
  469. e.printStackTrace();
  470. }catch (InvocationTargetException e){
  471. e.printStackTrace();
  472. }finally{
  473. // 清理资源
  474. }
  475. //生成文件流
  476. HTTPExcle(workbook,response);
  477. }
  478. /**
  479. * (网络传输)集合
  480. * 这是一个通用的方法,利用了JAVA的反射机制,可以将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上
  481. * @param title 表格标题名
  482. * @param headers 表格属性列名数组
  483. * @param dataset 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
  484. * javabean属性的数据类型有基本数据类型及String,Date,byte[](图片数据)
  485. * @param pattern 如果有时间数据,设定输出格式。默认为"yyy-MM-dd"
  486. */
  487. @SuppressWarnings("unchecked")
  488. public void exportExcel(String title, String[] headers,List<List<Object>> dataset, String pattern,HttpServletResponse response){
  489. response.reset(); // 清除buffer缓存
  490. // 指定下载的文件名
  491. response.setHeader("Content-Disposition", "attachment;filename=contacts" + getDateTimeName() + ".xls");
  492. response.setContentType("application/vnd.ms-excel;charset=UTF-8");
  493. response.setHeader("Pragma", "no-cache");
  494. response.setHeader("Cache-Control", "no-cache");
  495. response.setDateHeader("Expires", 0);
  496. // 声明一个工作薄
  497. HSSFWorkbook workbook = new HSSFWorkbook();
  498. // 生成一个表格
  499. HSSFSheet sheet = workbook.createSheet(title);
  500. // 设置表格默认列宽度为15个字节
  501. sheet.setDefaultColumnWidth((short) 15);
  502. // 生成一个样式
  503. HSSFCellStyle style = workbook.createCellStyle();
  504. // 设置这些样式
  505. style.setFillForegroundColor(HSSFColor.SKY_BLUE.index);
  506. style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  507. style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  508. style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  509. style.setBorderRight(HSSFCellStyle.BORDER_THIN);
  510. style.setBorderTop(HSSFCellStyle.BORDER_THIN);
  511. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  512. // 生成一个字体
  513. HSSFFont font = workbook.createFont();
  514. font.setColor(HSSFColor.VIOLET.index);
  515. font.setFontHeightInPoints((short) 12);
  516. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  517. // 把字体应用到当前的样式
  518. style.setFont(font);
  519. // 生成并设置另一个样式
  520. HSSFCellStyle style2 = workbook.createCellStyle();
  521. style2.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
  522. style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  523. style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  524. style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  525. style2.setBorderRight(HSSFCellStyle.BORDER_THIN);
  526. style2.setBorderTop(HSSFCellStyle.BORDER_THIN);
  527. style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  528. style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
  529. // 生成另一个字体
  530. HSSFFont font2 = workbook.createFont();
  531. font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
  532. // 把字体应用到当前的样式
  533. style2.setFont(font2);
  534. // 声明一个画图的顶级管理器
  535. HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
  536. // 定义注释的大小和位置,详见文档
  537. HSSFComment comment = patriarch.createComment(new HSSFClientAnchor(0,
  538. 0, 0, 0, (short) 4, 2, (short) 6, 5));
  539. // 设置注释内容
  540. comment.setString(new HSSFRichTextString("可以在POI中添加注释!"));
  541. // 设置注释作者,当鼠标移动到单元格上是可以在状态栏中看到该内容.
  542. comment.setAuthor("leno");
  543. // 产生表格标题行
  544. HSSFRow row = sheet.createRow(0);
  545. for (short i = 0; i < headers.length; i++)
  546. {
  547. HSSFCell cell = row.createCell(i);
  548. cell.setCellStyle(style);
  549. HSSFRichTextString text = new HSSFRichTextString(headers[i]);
  550. cell.setCellValue(text);
  551. }
  552. try {
  553. for (int i = 0; i < dataset.size(); i++) {
  554. //创建外层集合行
  555. HSSFRow createRow = sheet.createRow(i+1);
  556. for (int j = 0; j < dataset.get(i).size(); j++) {
  557. createRow.createCell(j).setCellValue(dataset.get(i).get(j).toString());;
  558. }
  559. }
  560. }catch (Exception e){
  561. e.printStackTrace();
  562. }finally{
  563. // 清理资源
  564. }
  565. //生成文件流
  566. HTTPExcle(workbook,response);
  567. }
  568. /**
  569. * (网络传输)集合Map
  570. * 这是一个通用的方法,利用了JAVA的反射机制,可以将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上
  571. * @param title 表格标题名
  572. * @param headers 表格属性列名数组
  573. * @param dataset 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
  574. * javabean属性的数据类型有基本数据类型及String,Date,byte[](图片数据)
  575. * @param pattern 如果有时间数据,设定输出格式。默认为"yyy-MM-dd"
  576. */
  577. @SuppressWarnings("unchecked")
  578. public void exportExcel(String title, String[] headers,List<Map<String, Object>> dataset, String pattern,HttpServletResponse response,String name){
  579. response.reset(); // 清除buffer缓存
  580. // 指定下载的文件名
  581. response.setHeader("Content-Disposition", "attachment;filename=contacts" + getDateTimeName() + ".xls");
  582. response.setContentType("application/vnd.ms-excel;charset=UTF-8");
  583. response.setHeader("Pragma", "no-cache");
  584. response.setHeader("Cache-Control", "no-cache");
  585. response.setDateHeader("Expires", 0);
  586. // 声明一个工作薄
  587. HSSFWorkbook workbook = new HSSFWorkbook();
  588. // 生成一个表格
  589. HSSFSheet sheet = workbook.createSheet(title);
  590. // 设置表格默认列宽度为15个字节
  591. sheet.setDefaultColumnWidth((short) 15);
  592. // 生成一个样式
  593. HSSFCellStyle style = workbook.createCellStyle();
  594. // 设置这些样式
  595. style.setFillForegroundColor(HSSFColor.SKY_BLUE.index);
  596. style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  597. style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  598. style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  599. style.setBorderRight(HSSFCellStyle.BORDER_THIN);
  600. style.setBorderTop(HSSFCellStyle.BORDER_THIN);
  601. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  602. // 生成一个字体
  603. HSSFFont font = workbook.createFont();
  604. font.setColor(HSSFColor.VIOLET.index);
  605. font.setFontHeightInPoints((short) 12);
  606. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  607. // 把字体应用到当前的样式
  608. style.setFont(font);
  609. // 生成并设置另一个样式
  610. HSSFCellStyle style2 = workbook.createCellStyle();
  611. style2.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
  612. style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  613. style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  614. style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  615. style2.setBorderRight(HSSFCellStyle.BORDER_THIN);
  616. style2.setBorderTop(HSSFCellStyle.BORDER_THIN);
  617. style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  618. style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
  619. // 生成另一个字体
  620. HSSFFont font2 = workbook.createFont();
  621. font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
  622. // 把字体应用到当前的样式
  623. style2.setFont(font2);
  624. // 声明一个画图的顶级管理器
  625. HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
  626. // 定义注释的大小和位置,详见文档
  627. HSSFComment comment = patriarch.createComment(new HSSFClientAnchor(0,
  628. 0, 0, 0, (short) 4, 2, (short) 6, 5));
  629. // 设置注释内容
  630. comment.setString(new HSSFRichTextString("可以在POI中添加注释!"));
  631. // 设置注释作者,当鼠标移动到单元格上是可以在状态栏中看到该内容.
  632. comment.setAuthor("leno");
  633. // 产生表格标题行
  634. HSSFRow row = sheet.createRow(0);
  635. for (short i = 0; i < headers.length; i++)
  636. {
  637. HSSFCell cell = row.createCell(i);
  638. cell.setCellStyle(style);
  639. HSSFRichTextString text = new HSSFRichTextString(headers[i]);
  640. cell.setCellValue(text);
  641. }
  642. try {
  643. dataset = nullToEmpty(dataset);
  644. for (int i = 0; i < dataset.size(); i++) {
  645. //创建外层集合行
  646. HSSFRow createRow = sheet.createRow((i+1));
  647. //第一種
  648. Set<String> set = dataset.get(i).keySet(); //取出所有的key值
  649. Iterator<String> it = set.iterator();
  650. int j = 0;
  651. while(it.hasNext()) {
  652. /* String str = null;
  653. if(it.next()!=null&&dataset.get(i)!=null&&dataset.get(i).get(it.next())!=null) {
  654. System.out.println("----------------------------");
  655. System.out.println(it.next());
  656. System.out.println(dataset.get(i).get(it.next()));
  657. str = dataset.get(i).get(it.next()).toString();
  658. }*/
  659. Object value = dataset.get(i).get(it.next());
  660. String textValue = null;
  661. if (value instanceof Boolean){
  662. boolean bValue = (Boolean) value;
  663. textValue = "男";
  664. if (!bValue)
  665. {
  666. textValue = "女";
  667. }
  668. }else if (value instanceof Date){
  669. Date date = (Date) value;
  670. SimpleDateFormat sdf = new SimpleDateFormat(pattern);
  671. textValue = sdf.format(date);
  672. }else if (value instanceof byte[]){
  673. // 有图片时,设置行高为60px;
  674. row.setHeightInPoints(60);
  675. // 设置图片所在列宽度为80px,注意这里单位的一个换算
  676. sheet.setColumnWidth(i, (short) (35.7 * 80));
  677. // sheet.autoSizeColumn(i);
  678. byte[] bsValue = (byte[]) value;
  679. HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0,
  680. 1023, 255, (short) 6, (i+1), (short) 6, (i+1));
  681. anchor.setAnchorType(2);
  682. patriarch.createPicture(anchor, workbook.addPicture(
  683. bsValue, HSSFWorkbook.PICTURE_TYPE_JPEG));
  684. }else{
  685. // 其它数据类型都当作字符串简单处理
  686. textValue = value.toString();
  687. }
  688. /*if(str!=null) {
  689. }else {
  690. createRow.createCell(j).setCellValue("");//取出元素
  691. }
  692. */
  693. // 如果不是图片数据,就利用正则表达式判断textValue是否全部由数字组成
  694. if (textValue != null)
  695. {
  696. Pattern p = Pattern.compile("^//d+(//.//d+)?$");
  697. Matcher matcher = p.matcher(textValue);
  698. if (matcher.matches())
  699. {
  700. // 是数字当作double处理
  701. createRow.createCell(j).setCellValue(Double.parseDouble(textValue));//取出元素
  702. }
  703. else
  704. {
  705. HSSFRichTextString richString = new HSSFRichTextString(
  706. textValue);
  707. HSSFFont font3 = workbook.createFont();
  708. font3.setColor(HSSFColor.BLACK.index);
  709. richString.applyFont(font3);
  710. createRow.createCell(j).setCellValue(richString);
  711. }
  712. }
  713. j++;
  714. }//判断是否有下一个
  715. }
  716. }catch (Exception e){
  717. e.printStackTrace();
  718. }finally{
  719. // 清理资源
  720. }
  721. //生成文件流
  722. HTTPExcle(workbook,response);
  723. }
  724. /************************************************************(工具方法)***************************************************************/
  725. public static void IOExcle(HSSFWorkbook workbook,String path) {
  726. OutputStream out = null;
  727. try {
  728. out = new FileOutputStream(path.replaceAll("\\\\", "/")+getDateTimeName()+".xls");
  729. workbook.write(out);
  730. } catch (FileNotFoundException e) {
  731. // TODO Auto-generated catch block
  732. e.printStackTrace();
  733. } catch (IOException e) {
  734. // TODO Auto-generated catch block
  735. e.printStackTrace();
  736. }finally{
  737. try {
  738. out.close();
  739. } catch (IOException e) {
  740. // TODO Auto-generated catch block
  741. e.printStackTrace();
  742. }
  743. };
  744. }
  745. public static void HTTPExcle(HSSFWorkbook workbook,HttpServletResponse response) {
  746. OutputStream output;
  747. try {
  748. output = response.getOutputStream();
  749. BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
  750. bufferedOutPut.flush();
  751. workbook.write(bufferedOutPut);
  752. bufferedOutPut.close();
  753. } catch (Exception e) {
  754. e.printStackTrace();
  755. }
  756. }
  757. public static String getDateTimeName() {
  758. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
  759. String format = sdf.format(new Date());
  760. return format;
  761. }
  762. /**
  763. * <p>方法名:nullToEmpty</p>
  764. * <p>功能描述:map的value如果是null处理成空字符串</p>
  765. */
  766. public static List<Map<String, Object>> nullToEmpty(List<Map<String, Object>> list) {
  767. if(list !=null && !list.isEmpty()) {
  768. for(Map<String, Object> map : list) {
  769. Set<String> set = map.keySet();
  770. if(set != null && !set.isEmpty()) {
  771. for(String key : set) {
  772. if(map.get(key) == null) {
  773. map.put(key, "");
  774. }
  775. }
  776. }
  777. }
  778. }
  779. return list;
  780. }
  781. }
  1. package com.cpic.caf.template.home.controller;
  2. import java.io.BufferedOutputStream;
  3. import java.io.FileNotFoundException;
  4. import java.io.FileOutputStream;
  5. import java.io.IOException;
  6. import java.io.OutputStream;
  7. import java.io.UnsupportedEncodingException;
  8. import java.math.BigInteger;
  9. import java.net.URLDecoder;
  10. import java.util.Date;
  11. import java.util.HashMap;
  12. import java.util.List;
  13. import java.util.Map;
  14. import java.util.Set;
  15. import javax.servlet.http.HttpServletRequest;
  16. import javax.servlet.http.HttpServletResponse;
  17. import javax.servlet.http.HttpSession;
  18. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  19. import org.slf4j.Logger;
  20. import org.slf4j.LoggerFactory;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.stereotype.Controller;
  23. import org.springframework.ui.Model;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.RequestMethod;
  26. import org.springframework.web.bind.annotation.RequestParam;
  27. import org.springframework.web.bind.annotation.ResponseBody;
  28. import com.cpic.caf.template.home.business.ProtocolAppoint;
  29. import com.cpic.caf.template.home.entity.OrderEO;
  30. import com.cpic.caf.template.home.entity.ProtocolParam;
  31. import com.cpic.caf.template.home.service.OrderService;
  32. import com.cpic.caf.template.home.util.CommonFunction;
  33. import com.cpic.caf.template.home.util.ExportExcel;
  34. import com.cpic.caf.template.home.util.HomeSQLUtil;
  35. import com.cpic.caf.template.home.util.OrderDSQLUtil;
  36. import com.cpic.caf.workers.hall.entity.WorkUserEO;
  37. import com.cpic.caf.workers.hall.entity.WorkersCaseuserEO;
  38. import com.cpic.caf.workers.hall.service.OmnipotentSqlService;
  39. import com.cpic.caf.workers.hall.service.WorkersCaseuserService;
  40. /**
  41. * 订单
  42. *
  43. * Title: 喜事码头 Description: 例子 Copyright: Copyright (c) 2018
  44. * Company:河南意莱享网络科技有限公司
  45. *
  46. * @author changshenghui
  47. * @version 1.1
  48. * @Date 2018年6月12日
  49. */
  50. @Controller
  51. public class OrderController {
  52. Logger logger = LoggerFactory.getLogger(OrderController.class);
  53. @Autowired
  54. OrderService orderService;
  55. @Autowired
  56. private OmnipotentSqlService omnipotent;
  57. @Autowired
  58. private WorkersCaseuserService WorkUserEO;
  59. /**
  60. * 获得订单信息列表(导出)
  61. *
  62. * @param model
  63. * @param request
  64. * @param pageRequest
  65. * @return
  66. */
  67. @RequestMapping(value = "/getEclise", method = RequestMethod.GET, produces = "application/json")
  68. @ResponseBody
  69. public void getOrderInfoList(Model model,HttpServletRequest request,HttpSession session,HttpServletResponse response) {
  70. ExportExcel<Map<String, Object>> ex = new ExportExcel<Map<String, Object>>();
  71. //创建列
  72. String[] headers =
  73. { "主键", "从业者ID", "案例是作品集还是婚礼案例", "案例类型", "标题","案例地址","描述","置顶","删除状态","访问量","收藏量",
  74. "排序","剩余可上传数","婚礼发生时间","创建时间","修改时间"};
  75. //创建值列
  76. List<Map<String, Object>> dataset = omnipotent.findsqlByParam("SELECT * FROM xsmt.ylx_workers_wuorder");
  77. ex.MapExportExcel(headers,dataset,response);
  78. System.out.println("excel导出成功!");
  79. }
  80. /**
  81. * 获得订单信息列表
  82. *
  83. * @param model
  84. * @param request
  85. * @param pageRequest
  86. * @return
  87. */
  88. @RequestMapping(value = "/getOrderInfoList", method = RequestMethod.GET, produces = "application/json")
  89. @ResponseBody
  90. public Map<String, Object> getOrderInfoList(Model model,
  91. HttpServletRequest request,
  92. HttpSession session,
  93. @RequestParam(value="PageIndex",required=false)Integer PageIndex,
  94. @RequestParam(value="paramIndex",required=false)Integer paramIndex,
  95. @RequestParam(value="start",required=false)Integer start,
  96. @RequestParam(value="NO",required=false)String NO,
  97. @RequestParam(value="DateParam",required=false)String DateParam,
  98. @RequestParam(value="BIZ",required=false)String BIZ
  99. ) {
  100. try {
  101. WorkUserEO attribute =(WorkUserEO) session.getAttribute("worker");//获取登录对象
  102. Integer WU_id = 1;
  103. String NO_ = "";
  104. String SQL = null;
  105. String SQLCount = null;
  106. if(attribute == null) {
  107. System.out.println("- 登录对象为空 -");
  108. }else {
  109. WU_id = attribute.getId();
  110. }
  111. if(NO!=null) {
  112. NO_ = NO;
  113. }
  114. logger.info("================================="+DateParam+"= 订单查询CYZid:"+WU_id+" into getOrderInfoList ==========================================");
  115. Map<String, Object> map = new HashMap<String, Object>();
  116. switch (paramIndex) {
  117. case 1:
  118. //查询全部订单
  119. SQL = OrderDSQLUtil.getOrderListByParams(PageIndex,WU_id,null,null,null,null,NO_,DateParam,BIZ);
  120. SQLCount = OrderDSQLUtil.getOrderListByCount(PageIndex,WU_id,null,null,null,null,NO_,DateParam,BIZ);
  121. System.out.println("查询全部订单:"+SQL);
  122. break;
  123. case 2:
  124. //查询已支付
  125. SQL = OrderDSQLUtil.getOrderListByParams(PageIndex,WU_id,1,null,null,null,NO_,DateParam,BIZ);
  126. SQLCount = OrderDSQLUtil.getOrderListByCount(PageIndex,WU_id,1,null,null,null,NO_,DateParam,BIZ);
  127. System.out.println("查询已支付:"+SQL);
  128. break;
  129. case 3:
  130. //查询待处理
  131. SQL = OrderDSQLUtil.getOrderListByParams(PageIndex,WU_id,null,5,null,null,NO_,DateParam,BIZ);
  132. SQLCount = OrderDSQLUtil.getOrderListByCount(PageIndex,WU_id,null,5,null,null,NO_,DateParam,BIZ);
  133. System.out.println("查询待处理:"+SQL);
  134. break;
  135. case 4:
  136. //查询待已付款
  137. SQL = OrderDSQLUtil.getOrderListByParams(PageIndex,WU_id,null,null,1,null,NO_,DateParam,BIZ);
  138. SQLCount = OrderDSQLUtil.getOrderListByCount(PageIndex,WU_id,null,null,1,null,NO_,DateParam,BIZ);
  139. System.out.println("查询待已付款:"+SQL);
  140. break;
  141. case 5:
  142. //查询已完成
  143. SQL = OrderDSQLUtil.getOrderListByParams(PageIndex,WU_id,null,6,null,null,NO_,DateParam,BIZ);
  144. SQLCount = OrderDSQLUtil.getOrderListByCount(PageIndex,WU_id,null,6,null,null,NO_,DateParam,BIZ);
  145. System.out.println("查询已完成:"+SQL);
  146. break;
  147. case 6:
  148. //查询已取消
  149. SQL = OrderDSQLUtil.getOrderListByParams(PageIndex,WU_id,null,null,null,1,NO_,DateParam,BIZ);
  150. SQLCount = OrderDSQLUtil.getOrderListByCount(PageIndex,WU_id,null,null,null,1,NO_,DateParam,BIZ);
  151. System.out.println("查询已取消:"+SQL);
  152. break;
  153. default:
  154. //查询全部订单
  155. SQL = OrderDSQLUtil.getOrderListByParams(PageIndex,WU_id,null,null,null,null,NO_,DateParam,BIZ);
  156. SQLCount = OrderDSQLUtil.getOrderListByCount(PageIndex,WU_id,null,null,null,null,NO_,DateParam,BIZ);
  157. System.out.println("查询全部订单:"+SQL);
  158. break;
  159. }
  160. // 查询数据
  161. List<Map<String, Object>> findsqlByParam = omnipotent.findsqlByParam(SQL);
  162. if(start !=null){
  163. // 总条数
  164. List<Map<String, Object>> findsqlByCount = omnipotent.findsqlByParam(SQLCount);
  165. map.put("totalCount", findsqlByCount.get(0).get("count"));
  166. }
  167. map.put("resultList", findsqlByParam);
  168. return map;
  169. } catch (Exception e) {
  170. e.printStackTrace();
  171. return null;
  172. }
  173. }
  174. /**
  175. * 增加订单信息
  176. *
  177. * @param model
  178. * @param request
  179. * @param pageRequest
  180. * @return
  181. */
  182. @RequestMapping(value = "/jsonAddOrderInfo", method = RequestMethod.POST)
  183. @ResponseBody
  184. public ProtocolParam addOrderInfo(Model model, HttpServletRequest request,
  185. @RequestParam Map<String, Object> pageRequest) {
  186. logger.info("======================================== JsonAddOrderInfo==================================");
  187. // 获得要添加的字段
  188. try {
  189. String no = URLDecoder.decode((String) pageRequest.get("no"),
  190. "utf-8");// 订单编号
  191. String cust_name = URLDecoder.decode(
  192. (String) pageRequest.get("custname"), "utf-8");// 客户姓名
  193. // 创建实体对象
  194. OrderEO order = new OrderEO();
  195. // 订单编号
  196. if (no != null && !"".equals(no)) {
  197. order.setNo(CommonFunction.getRandomOrderNo());
  198. }
  199. // 客户名称
  200. if (cust_name != null && !"".equals(cust_name)) {
  201. order.setCust_name(cust_name);
  202. }
  203. // 生成流水号
  204. order.setTrade_no(CommonFunction.GetNewOrderNo(no));
  205. // 服务名称
  206. order.setService_name("中式");
  207. order.setCreation_time(new Date());
  208. // 调用方法
  209. String str = HomeSQLUtil.homeOrderAddSQL(order);
  210. int count = orderService.add(str);
  211. // orderService.addOrderInfo(order);
  212. if (count > 0) {
  213. return ProtocolAppoint.succeed("新增成功", null, null);
  214. }
  215. return null;
  216. } catch (UnsupportedEncodingException e) {
  217. return ProtocolAppoint.error("新增失败", null, null);
  218. }
  219. }
  220. /**
  221. * 删除
  222. *
  223. * @param pageRequest
  224. * @return
  225. */
  226. @RequestMapping(value = "/JsonDelOrderInfo", method = RequestMethod.POST)
  227. @ResponseBody
  228. public ProtocolParam delOrderInfo(
  229. @RequestParam Map<String, Object> pageRequest) {
  230. logger.info("=============================== JsonDelOrderInfo ===============================");
  231. try {
  232. int id = Integer.parseInt(URLDecoder.decode(
  233. (String) pageRequest.get("id"), "utf-8"));
  234. String sql = HomeSQLUtil.homeDelOrderInfo(id);
  235. int count = orderService.delete(sql);
  236. if (count > 0) {
  237. return ProtocolAppoint.merry(200, "成功", null, null);
  238. }
  239. return null;
  240. } catch (Exception e) {
  241. return ProtocolAppoint.error("失败", null, null);
  242. }
  243. }
  244. @RequestMapping(value="/ModifyOrderInfo",method=RequestMethod.POST)
  245. @ResponseBody
  246. public ProtocolParam modifyOrderInfo(@RequestParam Map<String, Object> pageRequest){
  247. logger.info("============================= ModifyOrderInfo =========================================");
  248. try {
  249. int id=Integer.parseInt(URLDecoder.decode(
  250. (String) pageRequest.get("id"), "utf-8"));
  251. OrderEO order=new OrderEO();
  252. order.setNo("NO201806201543");
  253. order.setCust_name("青青");
  254. order.setId(BigInteger.valueOf(id));
  255. String sql=HomeSQLUtil.homeModifyOrderInfo(order);
  256. int count =orderService.update(sql);
  257. if(count>0){
  258. return ProtocolAppoint.merry(200, "成功", null, null);
  259. }
  260. return null;
  261. } catch (Exception e) {
  262. return ProtocolAppoint.error("失败", null, null);
  263. }
  264. }
  265. }

版权声明:本文为chengxiaolong原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/chengxiaolong/p/10206339.html