Kaynağa Gözat

工装检测登记导入优化

DLC 1 yıl önce
ebeveyn
işleme
3a2fa2f7c4

+ 19 - 17
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/EquFrockTestRecordServiceImpl.java

@@ -13,6 +13,7 @@ import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.rwcommon.utils.StringUtils;
+import org.apache.poi.ss.usermodel.DataFormatter;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.xssf.usermodel.XSSFCell;
@@ -61,6 +62,7 @@ public class EquFrockTestRecordServiceImpl extends ServiceImpl<EquFrockTestRecor
             Date date = new Date();
             String regex = "^(\\-|\\+)?\\d+(\\.\\d+)?$";//只能是数字
             Pattern pattern = Pattern.compile(regex);
+            DataFormatter dataFormatter = new DataFormatter();
 
             for (int i = 2; i <= lastRowNum; i++) {
                 StringBuilder stringBuilder = new StringBuilder();
@@ -70,24 +72,24 @@ public class EquFrockTestRecordServiceImpl extends ServiceImpl<EquFrockTestRecor
                     continue;
                 }
                 String mainid = "";
-                String ownedfactory = row.getCell(1) == null ? "" : row.getCell(1).toString().trim();
-                String frockname = row.getCell(2) == null ? "" : row.getCell(2).toString().trim();
-                String usedept = row.getCell(3) == null ? "" : row.getCell(3).toString().trim();
-                String frocknum = row.getCell(4) == null ? "" : row.getCell(4).toString().trim();
-                String belongequname = row.getCell(5) == null ? "" : row.getCell(5).toString().trim();
+                String ownedfactory = row.getCell(1) == null ? "" : dataFormatter.formatCellValue(row.getCell(1));
+                String frockname = row.getCell(2) == null ? "" : dataFormatter.formatCellValue(row.getCell(2));
+                String usedept = row.getCell(3) == null ? "" : dataFormatter.formatCellValue(row.getCell(3));
+                String frocknum = row.getCell(4) == null ? "" : dataFormatter.formatCellValue(row.getCell(4));
+                String belongequname = row.getCell(5) == null ? "" : dataFormatter.formatCellValue(row.getCell(5));
                 String exctestdate = row.getCell(6) == null ? "" : String.valueOf(DateUtils.importExcelFormatExcel((XSSFCell) row.getCell(6)));
-                String diameter = row.getCell(7) == null ? "" : row.getCell(7).toString().trim();
-                String hs1 = row.getCell(8) == null ? "" : row.getCell(8).toString().trim();
-                String hs2 = row.getCell(9) == null ? "" : row.getCell(9).toString().trim();
-                String hs3 = row.getCell(10) == null ? "" : row.getCell(10).toString().trim();
-                String hs4 = row.getCell(11) == null ? "" : row.getCell(11).toString().trim();
-                String hs5 = row.getCell(12) == null ? "" : row.getCell(12).toString().trim();
-                String hs6 = row.getCell(13) == null ? "" : row.getCell(13).toString().trim();
-                String hs7 = row.getCell(14) == null ? "" : row.getCell(14).toString().trim();
-                String hs8 = row.getCell(15) == null ? "" : row.getCell(15).toString().trim();
-                String hs9 = row.getCell(16) == null ? "" : row.getCell(16).toString().trim();
-                String state = row.getCell(17) == null ? "" : row.getCell(17).toString().trim();
-                String remark = row.getCell(18) == null ? "" : row.getCell(18).toString().trim();
+                String diameter = row.getCell(7) == null ? "" : dataFormatter.formatCellValue(row.getCell(7));
+                String hs1 = row.getCell(8) == null ? "" : dataFormatter.formatCellValue(row.getCell(8));
+                String hs2 = row.getCell(9) == null ? "" : dataFormatter.formatCellValue(row.getCell(9));
+                String hs3 = row.getCell(10) == null ? "" : dataFormatter.formatCellValue(row.getCell(10));
+                String hs4 = row.getCell(11) == null ? "" : dataFormatter.formatCellValue(row.getCell(11));
+                String hs5 = row.getCell(12) == null ? "" : dataFormatter.formatCellValue(row.getCell(12));
+                String hs6 = row.getCell(13) == null ? "" : dataFormatter.formatCellValue(row.getCell(13));
+                String hs7 = row.getCell(14) == null ? "" : dataFormatter.formatCellValue(row.getCell(14));
+                String hs8 = row.getCell(15) == null ? "" : dataFormatter.formatCellValue(row.getCell(15));
+                String hs9 = row.getCell(16) == null ? "" : dataFormatter.formatCellValue(row.getCell(16));
+                String state = row.getCell(17) == null ? "" : dataFormatter.formatCellValue(row.getCell(17));
+                String remark = row.getCell(18) == null ? "" : dataFormatter.formatCellValue(row.getCell(18));
                 if (StringUtils.isBlank(ownedfactory)) {
                     stringBuilder.append("所属工厂必填 ");
                 }