فهرست منبع

优化获取时间时,非时间格式不获取

[user3] 3 سال پیش
والد
کامیت
32fe783c55
1فایلهای تغییر یافته به همراه56 افزوده شده و 28 حذف شده
  1. 56 28
      src/main/java/com/jeeplus/common/utils/excel/ImportExcelNew.java

+ 56 - 28
src/main/java/com/jeeplus/common/utils/excel/ImportExcelNew.java

@@ -188,26 +188,34 @@ public class ImportExcelNew {
 						projectReportSignatureInfo.setDescriptionOfSpecialMatters(sheet.getRow(8).getCell(i).toString());
 					}
 					if(sheet.getRow(9).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(9).getCell(i))){
-							projectReportSignatureInfo.setStampDate(sheet.getRow(9).getCell(i).getDateCellValue());
+						if(sheet.getRow(9).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(9).getCell(i))) {
+								projectReportSignatureInfo.setStampDate(sheet.getRow(9).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(10).getCell(i) != null) {
 						projectReportSignatureInfo.setPrintQuantity(sheet.getRow(10).getCell(i).toString());
 					}
 					if(sheet.getRow(11).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(11).getCell(i))){
-							projectReportSignatureInfo.setReportPreparationDate(sheet.getRow(11).getCell(i).getDateCellValue());
+						if(sheet.getRow(11).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(11).getCell(i))) {
+								projectReportSignatureInfo.setReportPreparationDate(sheet.getRow(11).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(12).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(12).getCell(i))){
-							projectReportSignatureInfo.setAgreedStartDate(sheet.getRow(12).getCell(i).getDateCellValue());
+						if(sheet.getRow(12).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(12).getCell(i))) {
+								projectReportSignatureInfo.setAgreedStartDate(sheet.getRow(12).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(13).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(13).getCell(i))){
-							projectReportSignatureInfo.setAgreedEndDate(sheet.getRow(13).getCell(i).getDateCellValue());
+						if(sheet.getRow(13).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(13).getCell(i))) {
+								projectReportSignatureInfo.setAgreedEndDate(sheet.getRow(13).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(14).getCell(i) != null) {
@@ -220,28 +228,38 @@ public class ImportExcelNew {
 						projectReportSignatureInfo.setReviewOpinion(sheet.getRow(16).getCell(i).toString());
 					}
 					if(sheet.getRow(17).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(17).getCell(i))){
-							projectReportSignatureInfo.setReviewDate(sheet.getRow(17).getCell(i).getDateCellValue());
+						if(sheet.getRow(17).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(17).getCell(i))) {
+								projectReportSignatureInfo.setReviewDate(sheet.getRow(17).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(18).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(18).getCell(i))){
-							projectReportSignatureInfo.setDateOfConsultationReport(sheet.getRow(18).getCell(i).getDateCellValue());
+						if(sheet.getRow(18).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(18).getCell(i))) {
+								projectReportSignatureInfo.setDateOfConsultationReport(sheet.getRow(18).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(19).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(19).getCell(i))){
-							projectReportSignatureInfo.setStartDateOfConsultingOperation(sheet.getRow(19).getCell(i).getDateCellValue());
+						if(sheet.getRow(19).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(19).getCell(i))) {
+								projectReportSignatureInfo.setStartDateOfConsultingOperation(sheet.getRow(19).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(20).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(20).getCell(i))){
-							projectReportSignatureInfo.setEndDateOfConsultation(sheet.getRow(20).getCell(i).getDateCellValue());
+						if(sheet.getRow(20).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(20).getCell(i))) {
+								projectReportSignatureInfo.setEndDateOfConsultation(sheet.getRow(20).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(21).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(21).getCell(i))){
-							projectReportSignatureInfo.setStartAuditDate(sheet.getRow(21).getCell(i).getDateCellValue());
+						if(sheet.getRow(21).getCell(i).getCellType()==0) {  //数值类型才获取,即为正确的日期格式
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(21).getCell(i))) {
+								projectReportSignatureInfo.setStartAuditDate(sheet.getRow(21).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(22).getCell(i) != null) {
@@ -254,28 +272,38 @@ public class ImportExcelNew {
 						projectReportSignatureInfo.setTotalContractPrice(sheet.getRow(24).getCell(i).toString());
 					}
 					if(sheet.getRow(25).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(25).getCell(i))){
-							projectReportSignatureInfo.setContractStartDate(sheet.getRow(25).getCell(i).getDateCellValue());
+						if(sheet.getRow(25).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(25).getCell(i))) {
+								projectReportSignatureInfo.setContractStartDate(sheet.getRow(25).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(26).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(26).getCell(i))){
-							projectReportSignatureInfo.setContractEndDate(sheet.getRow(26).getCell(i).getDateCellValue());
+						if(sheet.getRow(26).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(26).getCell(i))) {
+								projectReportSignatureInfo.setContractEndDate(sheet.getRow(26).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(27).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(27).getCell(i))){
-							projectReportSignatureInfo.setActualStartDate(sheet.getRow(27).getCell(i).getDateCellValue());
+						if(sheet.getRow(27).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(27).getCell(i))) {
+								projectReportSignatureInfo.setActualStartDate(sheet.getRow(27).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(28).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(28).getCell(i))){
-							projectReportSignatureInfo.setActualEndDate(sheet.getRow(28).getCell(i).getDateCellValue());
+						if(sheet.getRow(28).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(28).getCell(i))) {
+								projectReportSignatureInfo.setActualEndDate(sheet.getRow(28).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(29).getCell(i) != null) {
-						if(HSSFDateUtil.isCellDateFormatted(sheet.getRow(29).getCell(i))){
-							projectReportSignatureInfo.setCompletionAcceptanceDate(sheet.getRow(29).getCell(i).getDateCellValue());
+						if(sheet.getRow(29).getCell(i).getCellType()==0) {
+							if (HSSFDateUtil.isCellDateFormatted(sheet.getRow(29).getCell(i))) {
+								projectReportSignatureInfo.setCompletionAcceptanceDate(sheet.getRow(29).getCell(i).getDateCellValue());
+							}
 						}
 					}
 					if(sheet.getRow(30).getCell(i) != null) {