Browse Source

日期可以获取缓存内容

java8
han\hanst 5 months ago
parent
commit
38bd71c775
  1. 31
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java

31
src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java

@ -580,18 +580,43 @@ public class CoDelServiceImpl implements CoDelService {
if (cell == null) return null;
try {
if (cell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell)) {
CellType cellType = cell.getCellType();
// 处理数值类型日期格式
if (cellType == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell)) {
return cell.getDateCellValue().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
} else if (cell.getCellType() == CellType.STRING) {
}
// 处理字符串类型
else if (cellType == CellType.STRING) {
String val = cell.getStringCellValue().trim();
if (val.isEmpty()) return null;
return LocalDate.parse(val, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
// 处理公式类型 - 获取缓存结果
else if (cellType == CellType.FORMULA) {
switch (cell.getCachedFormulaResultType()) {
case NUMERIC:
// 公式结果是数值类型且是日期格式
if (DateUtil.isCellDateFormatted(cell)) {
return cell.getDateCellValue().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
break;
case STRING:
// 公式结果是字符串类型
String formulaVal = cell.getStringCellValue().trim();
if (!formulaVal.isEmpty()) {
return LocalDate.parse(formulaVal, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
break;
default:
break;
}
}
} catch (Exception e) {
System.err.println("日期格式解析失败: " + cell.toString());
}
return null; // 无法解析返回 null 或抛异常
return null; // 无法解析返回 null
}

Loading…
Cancel
Save