核查系统api
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
6.6 KiB

  1. // package com.iflytop.nuclear.utils;
  2. //
  3. // import com.iflytop.nuclear.model.NuclearCoreConfig;
  4. // import org.apache.poi.hssf.usermodel.HSSFCell;
  5. // import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  6. // import org.apache.poi.ss.usermodel.*;
  7. // import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  8. // import org.springframework.web.multipart.MultipartFile;
  9. //
  10. // import java.io.IOException;
  11. // import java.io.InputStream;
  12. // import java.text.DecimalFormat;
  13. // import java.time.LocalDate;
  14. // import java.time.LocalDateTime;
  15. // import java.time.format.DateTimeFormatter;
  16. // import java.util.ArrayList;
  17. // import java.util.List;
  18. //
  19. // /**
  20. // * @author xjt
  21. // * @version 1.0
  22. // */
  23. // public class ExcelUtils {
  24. // //总行数
  25. // private static int totalRows = 0;
  26. // //总条数
  27. // private static int totalCells = 0;
  28. // //错误信息接收器
  29. // private static String errorMsg;
  30. //
  31. // /**
  32. // * 读EXCEL文件,获取信息集合
  33. // * @return
  34. // */
  35. // public static List<NuclearCoreConfig> getExcelInfo(MultipartFile mFile) {
  36. // String fileName = mFile.getOriginalFilename();//获取文件名
  37. // try {
  38. // if (!validateExcel(fileName)) {// 验证文件名是否合格
  39. // return null;
  40. // }
  41. // boolean isExcel2003 = true;// 根据文件名判断文件是2003版本还是2007版本
  42. // if (isExcel2007(fileName)) {
  43. // isExcel2003 = false;
  44. // }
  45. // List<NuclearCoreConfig> userList = createExcel(mFile.getInputStream(), isExcel2003);
  46. // return userList;
  47. // } catch (Exception e) {
  48. // e.printStackTrace();
  49. // }
  50. // return null;
  51. // }
  52. // /**
  53. // * 根据excel里面的内容读取客户信息
  54. // * @param is 输入流
  55. // * @param isExcel2003 excel是2003还是2007版本
  56. // * @return
  57. // * @throws IOException
  58. // */
  59. // public static List<NuclearCoreConfig> createExcel(InputStream is, boolean isExcel2003) {
  60. // try{
  61. // Workbook wb = null;
  62. // if (isExcel2003) {// 当excel是2003时,创建excel2003
  63. // wb = new HSSFWorkbook(is);
  64. // } else {// 当excel是2007时,创建excel2007
  65. // wb = new XSSFWorkbook(is);
  66. // }
  67. // List<NuclearCoreConfig> userList = readExcelValue(wb);// 读取Excel里面客户的信息
  68. // return userList;
  69. // } catch (IOException e) {
  70. // e.printStackTrace();
  71. // }
  72. // return null;
  73. // }
  74. // /**
  75. // * 读取Excel里面客户的信息
  76. // * @param wb
  77. // * @return
  78. // */
  79. // private static List<NuclearCoreConfig> readExcelValue(Workbook wb) {
  80. // //默认会跳过第一行标题
  81. // // 得到第一个shell
  82. // Sheet sheet = wb.getSheetAt(0);
  83. // // 得到Excel的行数
  84. // totalRows = sheet.getPhysicalNumberOfRows();
  85. // // 得到Excel的列数(前提是有行数)
  86. // if (totalRows > 1 && sheet.getRow(0) != null) {
  87. // totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
  88. // }
  89. // List<BuiPatientInfo> userList = new ArrayList<BuiPatientInfo>();
  90. // // 循环Excel行数
  91. // for (int r = 1; r < totalRows; r++) {
  92. // Row row = sheet.getRow(r);
  93. // if (row == null){
  94. // continue;
  95. // }
  96. // BuiPatientInfo user = new BuiPatientInfo();
  97. // // 循环Excel的列
  98. // for (int c = 0; c < totalCells-1; c++) {
  99. // Cell cell = row.getCell(c);
  100. // if (null != cell) {
  101. // if (c == 0) { //第一列
  102. // //如果是纯数字,将单元格类型转为String
  103. // if(cell.getCellTypeEnum() == CellType.NUMERIC){
  104. // cell.setCellType(CellType.STRING);
  105. // }
  106. // user.setPatientName(cell.getStringCellValue());//将单元格数据赋值给user
  107. // }
  108. // else if (c == 1){
  109. // if(cell.getCellTypeEnum() == CellType.NUMERIC){
  110. // cell.setCellType(CellType.STRING);
  111. // }
  112. // user.setPatientIdentity(cell.getStringCellValue());
  113. // }
  114. // else if (c == 2){
  115. // if(cell.getCellTypeEnum() == CellType.NUMERIC){
  116. // cell.setCellType(CellType.STRING);
  117. // }
  118. // String stringCellValue = cell.getStringCellValue();
  119. // user.setHealingId(stringCellValue);
  120. // }
  121. // else if (c == 3){
  122. // if(cell.getCellTypeEnum() == CellType.NUMERIC){
  123. // cell.setCellType(CellType.STRING);
  124. // }
  125. // user.setElseInfo(String.valueOf(cell.getStringCellValue()));
  126. // }
  127. // }
  128. // }
  129. // //将excel解析出来的数据赋值给对象添加到list中
  130. // user.setUpdateTime(LocalDateTime.now());
  131. // user.setPatientBirthdate(IdentityUtil.getPatientBirth(user.getPatientIdentity())); //拿到身份中好通过已经写好的通过身份证信息获取出生年月工具类
  132. // user.setPatientSex(IdentityUtil.getPatientSex(user.getPatientIdentity())); //通过省份证号,获取男女信息工具类
  133. // user.setPatientState(1); //当前实体类字段是固定的,不是excel数据中的。每个对象都可以再遍历完后增加固定属性值
  134. // user.setCreateId(2L);
  135. // user.setCreateTime(LocalDateTime.now());
  136. // // 添加到list
  137. // userList.add(user);
  138. // }
  139. // return userList;
  140. // }
  141. // /**
  142. // * 验证EXCEL文件
  143. // *
  144. // * @param filePath
  145. // * @return
  146. // */
  147. // public static boolean validateExcel(String filePath) {
  148. // if (filePath == null || !(isExcel2003(filePath) || isExcel2007(filePath))) {
  149. // errorMsg = "文件名不是excel格式";
  150. // return false;
  151. // }
  152. // return true;
  153. // }
  154. // // @描述:是否是2003的excel,返回true是2003
  155. // public static boolean isExcel2003(String filePath) {
  156. // return filePath.matches("^.+\\.(?i)(xls)$");
  157. // }
  158. // //@描述:是否是2007的excel,返回true是2007
  159. // public static boolean isExcel2007(String filePath) {
  160. // return filePath.matches("^.+\\.(?i)(xlsx)$");
  161. // }
  162. // }