This commit is contained in:
parent
17efb7320f
commit
831497d4a8
|
|
@ -579,112 +579,4 @@ public class WsMaInfoServiceImpl implements WsMaInfoService {
|
|||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 导入数据
|
||||
// * @param file
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public AjaxResult importTbData(MultipartFile file) {
|
||||
// String fileName = file.getOriginalFilename();
|
||||
// if (fileName != null) {
|
||||
// String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||
// if (!GlobalConstants.XLSX.equalsIgnoreCase(fileExtension) && !GlobalConstants.XLS.equalsIgnoreCase(fileExtension)) {
|
||||
// // 文件后缀名不符合要求
|
||||
// return AjaxResult.error("导入失败:文件后缀名不符合要求,必须为xlsx或xls结尾");
|
||||
// }
|
||||
// }
|
||||
// try {
|
||||
// InputStream inputStream = file.getInputStream();
|
||||
// Workbook workbook = new XSSFWorkbook(inputStream);
|
||||
// Sheet sheet = workbook.getSheetAt(0);
|
||||
// // 得到Excel的行数
|
||||
// int totalRows = sheet.getPhysicalNumberOfRows();
|
||||
// // 检查是否有行数
|
||||
// if (totalRows <= 1) {
|
||||
// throw new IllegalArgumentException("导入失败:Excel文件中没有数据,请检查后重新导入");
|
||||
// }
|
||||
// // 读取第一行表头
|
||||
// Row headerRow = sheet.getRow(0);
|
||||
// if (headerRow == null) {
|
||||
// throw new IllegalArgumentException("导入失败:文件中没有表头");
|
||||
// }
|
||||
// // 获取表头的列数
|
||||
// int totalCells = headerRow.getPhysicalNumberOfCells();
|
||||
// // 预期的表头列数为5列,可以根据实际需求修改这个条件
|
||||
// if (totalCells != 5) {
|
||||
// throw new IllegalArgumentException("导入失败:表头列数与预期不符,请检查导入模板");
|
||||
// }
|
||||
// // 读取表头内容并验证每一列
|
||||
// extracted(headerRow, totalCells);
|
||||
// //读取Excel表格数据,做非空及格式判断
|
||||
// //extractedCell(sheet, totalRows, totalCells);
|
||||
// ExcelUtil<WsMaInfo> util = new ExcelUtil<>(WsMaInfo.class);
|
||||
// List<WsMaInfo> wsMaInfos = util.importExcel(file.getInputStream());
|
||||
// int result = 0;
|
||||
// for (WsMaInfo wmInfo : wsMaInfos) {
|
||||
// /*List<WsMaInfo> wsMaInfoList = mapper.queryByName(wmInfo);
|
||||
// if (CollectionUtils.isNotEmpty(wsMaInfoList)) {
|
||||
// for (WsMaInfo wmInfo : wsMaInfoList) {
|
||||
// if () {
|
||||
// //进行更新操作
|
||||
//
|
||||
// } else {
|
||||
// //新增操作
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }*/
|
||||
// }
|
||||
// if (result > 0) {
|
||||
// return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result);
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 读取Excel表头模板方法抽取
|
||||
// * @param headerRow
|
||||
// * @param totalCells
|
||||
// */
|
||||
// private void extracted(Row headerRow, int totalCells) {
|
||||
// for (int cellNum = 0; cellNum < totalCells; cellNum++) {
|
||||
// Cell cell = headerRow.getCell(cellNum);
|
||||
// // 获取单元格内容并去除首尾空格
|
||||
// String headerValue = cell.getStringCellValue().trim();
|
||||
// // 根据列索引进行验证
|
||||
// switch (cellNum) {
|
||||
// case 0:
|
||||
// if (!"姓名".equals(headerValue)) {
|
||||
// throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板");
|
||||
// }
|
||||
// break;
|
||||
// case 1:
|
||||
// if (!"性别(0 女 1 男)".equals(headerValue)) {
|
||||
// throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板");
|
||||
// }
|
||||
// break;
|
||||
// case 2:
|
||||
// if (!"岗位工种".equals(headerValue)) {
|
||||
// throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板");
|
||||
// }
|
||||
// break;
|
||||
// case 3:
|
||||
// if (!"身份证号码".equals(headerValue)) {
|
||||
// throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板");
|
||||
// }
|
||||
// break;
|
||||
// case 4:
|
||||
// if (!"电话".equals(headerValue)) {
|
||||
// throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板");
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue