|
|
|
@ -26,6 +26,7 @@ import org.apache.ibatis.session.SqlSession; |
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
|
import org.apache.poi.ss.usermodel.DataFormatter; |
|
|
|
import org.apache.poi.ss.usermodel.DateUtil; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
@ -43,6 +44,9 @@ import java.io.InputStream; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@ -194,8 +198,10 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
task.setBuNo(inData.getBuNo()); // bu |
|
|
|
Date readDate; |
|
|
|
try { |
|
|
|
String date = getStringCellValue(row, 0); |
|
|
|
readDate = DateUtils.getDateByParten(date, "yyyy-MM-dd"); |
|
|
|
//String date = getStringCellValue(row, 0); |
|
|
|
LocalDate localDate = parseDateCell(row.getCell(0)); |
|
|
|
String formatted = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
|
|
|
readDate = DateUtils.getDateByParten(formatted, "yyyy-MM-dd"); |
|
|
|
} catch (ParseException e) { |
|
|
|
throw new RuntimeException("第" + (j+1) + "行的ReadyDate格式有误!"); |
|
|
|
} |
|
|
|
@ -245,6 +251,25 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static LocalDate parseDateCell(Cell cell) { |
|
|
|
if (cell == null) return null; |
|
|
|
|
|
|
|
try { |
|
|
|
if (cell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell)) { |
|
|
|
return cell.getDateCellValue().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
|
|
|
} else if (cell.getCellType() == CellType.STRING) { |
|
|
|
String val = cell.getStringCellValue().trim(); |
|
|
|
if (val.isEmpty()) return null; |
|
|
|
return LocalDate.parse(val, DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
System.err.println("日期格式解析失败: " + cell.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
return null; // 无法解析,返回 null 或抛异常 |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void sendMailUtil(String textHead,String text,String[] mailAddress,EcssCoDelNotifyHeaderData data) { |
|
|
|
MailSendAddressData mailSendData = qcMapper.getSendMailFromAddress(); |
|
|
|
MailUtil.sendMail(textHead, text, mailAddress, mailSendData); |
|
|
|
|