anderx пре 4 година
родитељ
комит
cf3b393def

+ 19 - 1
src/main/java/com/goafanti/common/utils/ExcelUtils.java

@@ -19,6 +19,7 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.web.multipart.MultipartFile;
 
+import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.customer.bo.CustomerExcelBo;
 import com.goafanti.order.bo.OrderReportBo;
 import org.apache.commons.lang3.StringUtils;
@@ -747,7 +748,7 @@ public class ExcelUtils {
                     if (HSSFDateUtil.isCellDateFormatted(cell)) {
                         Date date = cell.getDateCellValue();
                         if (date != null) {
-                            value = new SimpleDateFormat("yyyy-MM-dd").format(date);//日期格式化
+                            value = new SimpleDateFormat("yyyy/MM/dd").format(date);//日期格式化
                         } else {
                             value = "";
                         }
@@ -774,6 +775,23 @@ public class ExcelUtils {
         }
         return value.trim();
     }
+    
+	public static Date getCellDate(Cell cell) {
+		Date date=new Date();
+		  if (cell != null) {
+	            switch (cell.getCellTypeEnum()) {
+	            	case NUMERIC:  //数字
+	            		 date = cell.getDateCellValue();
+	                     break;
+	                case STRING://字符串
+	                	date = DateUtils.StringToDate(cell.getStringCellValue(), AFTConstants.YYYYMMDD);
+	                default:
+	                    date = new Date();
+	            }
+		  }
+		return date;
+
+	}
 
 	
     public static Workbook getWorkBook(MultipartFile file) {

+ 5 - 5
src/main/java/com/goafanti/patent/service/impl/PatentNewServiceImpl.java

@@ -335,16 +335,13 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 						trb.setType(PatentType.getCodeByDesc(ExcelUtils.getCellValue(cell)));
 						break;
 					case 3:
-						trb.setApplyDate(DateUtils.StringToDate(ExcelUtils.getCellValue(cell), AFTConstants.YYYYMMDD));
+						trb.setApplyDate(ExcelUtils.getCellDate(cell));
 						break;
 					case 4:
 						trb.setHolders(ExcelUtils.getCellValue(cell));
 						break;
 					case 5:
-						 str=ExcelUtils.getCellValue(cell);
-						if (StringUtils.isNotEmpty(str)) {
-							trb.setAuthorizationDate(DateUtils.StringToDate(str, AFTConstants.YYYYMMDD));
-						}
+							trb.setAuthorizationDate(ExcelUtils.getCellDate(cell));
 						break;
 					case 6:
 						trb.setInventor(ExcelUtils.getCellValue(cell));
@@ -376,6 +373,9 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 		        		throw new BusinessException(new Error("表格第"+(rowNum+1)+"行[专利编号]重复导入。"));
 		        	}
 		        }
+		        if (trb.getType()==10) {
+		        	throw new BusinessException(new Error("表格第"+(rowNum+1)+"专利类型错误。"));
+				}
 		        Date date=new Date();
 		        trb.setAid(TokenManager.getAdminId());
 		        trb.setInputId(trb.getAid());