zhangqiankun 3 rokov pred
rodič
commit
07c2fdc798

+ 13 - 8
src/main/java/com/persagy/proxy/object/controller/AdmEquipmentController.java

@@ -390,21 +390,23 @@ public class AdmEquipmentController {
 	        				tempMap.put(define.getCode(), cell.getStringCellValue().trim());
 						} else if ("INTEGER".equalsIgnoreCase(define.getDataType())) {
 							try {
-								if (!CellType.NUMERIC.equals(cell.getCellTypeEnum())) {
+								if (!CellType.NUMERIC.equals(cell.getCellTypeEnum()) || StrUtil.isBlank(cell.getRawValue())) {
 									failurNum++;
                                     this.setColor(workbook, 155, 227, 255, cell);
                                     continue;
 								}
-								tempMap.put(define.getCode(), cell.getRawValue().toString().trim());
+								cell.setCellType(CellType.STRING);
+								tempMap.put(define.getCode(), cell.getStringCellValue().trim());
 							} catch (Exception e) {
 								failurNum++;
                                 this.setColor(workbook, 155, 227, 255, cell);
                                 continue;
 							}
 						} else if ("ENUM".equalsIgnoreCase(define.getDataType())) {
-							if (CellType.NUMERIC.equals(cell.getCellTypeEnum())) {
-								tempMap.put(define.getCode(), cell.getRawValue().toString().trim());
-                            } else if (CellType.STRING.equals(cell.getCellTypeEnum())) {
+							if (CellType.NUMERIC.equals(cell.getCellTypeEnum()) && StrUtil.isNotBlank(cell.getRawValue())) {
+								cell.setCellType(CellType.STRING);
+								tempMap.put(define.getCode(), cell.getStringCellValue().trim());
+                            } else if (CellType.STRING.equals(cell.getCellTypeEnum()) && StrUtil.isNotBlank(cell.getRawValue())) {
                             	tempMap.put(define.getCode(), cell.getStringCellValue().trim());
                             } else {
                             	failurNum++;
@@ -413,7 +415,8 @@ public class AdmEquipmentController {
                             }
 						} else if ("DATETIME".equalsIgnoreCase(define.getDataType())) {
                             try {
-                            	String trim = cell.getRawValue().trim();
+                            	cell.setCellType(CellType.STRING);
+                            	String trim = cell.getStringCellValue().trim();
                             	tempMap.put(define.getCode(), DateUtil.parseByPatterns(trim, "yyyyMMdd"));
                             } catch (Exception e) {
                             	failurNum++;
@@ -422,7 +425,8 @@ public class AdmEquipmentController {
                             }
 						} else if ("DOUBLE".equalsIgnoreCase(define.getDataType())) {
 							try {
-								String trim = cell.getRawValue().trim();
+								cell.setCellType(CellType.STRING);
+                            	String trim = cell.getStringCellValue().trim();
 								tempMap.put(define.getCode(), Double.parseDouble(trim));
 							} catch (Exception e) {
                             	failurNum++;
@@ -430,7 +434,8 @@ public class AdmEquipmentController {
                                 continue;
                             }
 						} else if ("BOOLEAN".equalsIgnoreCase(define.getDataType())) {
-							String trim = cell.getRawValue() == null ? null : cell.getRawValue().toString().trim();
+							cell.setCellType(CellType.STRING);
+                        	String trim = cell.getStringCellValue() == null ? null : cell.getStringCellValue().trim();
 							if ("1".equals(trim) || "0".equals(trim)) {
 								tempMap.put(define.getCode(), Double.parseDouble(trim));
 							} else {

+ 8 - 2
src/main/java/com/persagy/proxy/report/controller/RelationReportController.java

@@ -13,6 +13,7 @@ import java.util.Set;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -690,30 +691,35 @@ public class RelationReportController {
 		    		xssfRow.createCell(infosFeedback).setCellValue("本地编码不可以为空");
                     continue;
 				}
+		    	identificationCodeCell.setCellType(CellType.STRING);
 		    	XSSFCell infosCodeCell = xssfRow.getCell(infosCode);
 		    	if (infosCodeCell == null || StrUtil.isBlank(infosCodeCell.getStringCellValue())) {
 		    		failCount++;
 		    		xssfRow.createCell(infosFeedback).setCellValue("信息点编码不可以为空");
                     continue;
 				}
+		    	infosCodeCell.setCellType(CellType.STRING);
 		    	XSSFCell tableCodeCell = xssfRow.getCell(tableCode);
 		    	if (tableCodeCell == null || StrUtil.isBlank(tableCodeCell.getRawValue())) {
 		    		failCount++;
 		    		xssfRow.createCell(infosFeedback).setCellValue("表号不可以为空");
                     continue;
 				}
+		    	tableCodeCell.setCellType(CellType.STRING);
 		    	XSSFCell functionCodeCell = xssfRow.getCell(functionCode);
 		    	if (functionCodeCell == null || StrUtil.isBlank(functionCodeCell.getRawValue())) {
 		    		failCount++;
 		    		xssfRow.createCell(infosFeedback).setCellValue("功能号不可以为空");
                     continue;
 				}
+		    	functionCodeCell.setCellType(CellType.STRING);
 		    	XSSFCell classCodeIndexesCell = xssfRow.getCell(classCodeIndexes);
 		    	if (classCodeIndexesCell == null || StrUtil.isBlank(classCodeIndexesCell.getStringCellValue())) {
 		    		failCount++;
 		    		xssfRow.createCell(infosFeedback).setCellValue("设备类型不可以为空");
                     continue;
 				}
+		    	classCodeIndexesCell.setCellType(CellType.STRING);
 		    	String classCode = classCodeIndexesCell.getStringCellValue().trim();
 		    	// 验证此classCode是否存在
 		    	ObjectTypeDefine typeDefine = this.queryClassList(groupCode, projectId, classCode, AdmObjectType.SYSTEM.getIndex());
@@ -726,8 +732,8 @@ public class RelationReportController {
 		    	// 获取实际cell值
 		    	String val0 = identificationCodeCell.getStringCellValue().trim();
 		    	String val1 = infosCodeCell.getStringCellValue().trim();
-		    	String val2 = tableCodeCell.getRawValue().trim();
-		    	String val3 = functionCodeCell.getRawValue().trim();
+		    	String val2 = tableCodeCell.getStringCellValue().trim();
+		    	String val3 = functionCodeCell.getStringCellValue().trim();
 		    	
 		    	// 获取设备信息
 		    	ObjectNode criteria = objectMapper.createObjectNode();