Ver Fonte

【CHG】修改导入规则

zhaomn há 2 anos atrás
pai
commit
33712190b7

+ 4 - 4
railway-business/src/main/java/com/railway/business/bi/domain/ShowBpdjxjh.java

@@ -36,21 +36,21 @@ public class ShowBpdjxjh extends BaseEntity {
   private String substationName;
 
   @ApiModelProperty(value = "计划月")
-  @Excel(name = "计划月")
+  @Excel(name = "月")
   private String jhMonth;
 
   @ApiModelProperty(value = "计划日")
-  @Excel(name = "计划日")
+  @Excel(name = "日")
   private String jhDay;
 
   @ApiModelProperty(value = "兑现状态")
-  @Excel(name = "兑现状态")
+  @Excel(name = "兑现情况")
   private String completionState;
 
   @ApiModelProperty(value = "兑现日期")
   @JsonFormat(pattern = "yyyy-MM-dd")
   @DateTimeFormat(pattern = "yyyy-MM-dd")
-  @Excel(name = "兑现日期", dateFormat = "yyyy/MM/dd")
+  @Excel(name = "兑现日期", dateFormat = "MMdd")
   private LocalDate completionDate;
 
   @ApiModelProperty(value = "del_flag")

+ 7 - 7
railway-business/src/main/java/com/railway/business/bi/domain/ShowGsd.java

@@ -38,31 +38,31 @@ public class ShowGsd extends BaseEntity {
   private String lineName;
 
   @ApiModelProperty(value = "架空线路 km")
-  @Excel(name = "架空线路")
+  @Excel(name = "架空线路(km)")
   private BigDecimal jkxl;
 
   @ApiModelProperty(value = "电缆线路 km")
-  @Excel(name = "电缆线路")
+  @Excel(name = "电缆线路(km)")
   private BigDecimal dlxl;
 
   @ApiModelProperty(value = "隔离开关")
-  @Excel(name = "隔离开关")
+  @Excel(name = "隔离开关(台)")
   private Integer glkg;
 
   @ApiModelProperty(value = "断路器")
-  @Excel(name = "断路器")
+  @Excel(name = "断路器(台)")
   private Integer dlq;
 
   @ApiModelProperty(value = "电缆接头")
-  @Excel(name = "电缆接头")
+  @Excel(name = "电缆接头(个)")
   private Integer dljt;
 
   @ApiModelProperty(value = "电缆井")
-  @Excel(name = "电缆井")
+  @Excel(name = "电缆井(座)")
   private Integer dlj;
 
   @ApiModelProperty(value = "接续箱")
-  @Excel(name = "接续箱")
+  @Excel(name = "接续箱(座)")
   private Integer jxx;
 
   @ApiModelProperty(value = "维修方式")

+ 1 - 1
railway-business/src/main/java/com/railway/business/bi/domain/ShowTestPlanDt.java

@@ -25,7 +25,7 @@ public class ShowTestPlanDt extends BaseEntity {
   private Long id;
 
   @ApiModelProperty(value = "线路名称")
-  @Excel(name = "线路名称")
+  @Excel(name = "线")
   private String lineName;
 
   @ApiModelProperty(value = "所亭名称")

+ 1 - 1
railway-business/src/main/java/com/railway/business/bi/domain/ShowYdts.java

@@ -75,7 +75,7 @@ public class ShowYdts extends BaseEntity {
   @ApiModelProperty(value = "完成日期")
   @JsonFormat(pattern = "yyyy-MM-dd")
   @DateTimeFormat(pattern = "yyyy-MM-dd")
-  @Excel(name = "计划调整建议", dateFormat = "yyyy/MM/dd")
+  @Excel(name = "完成日期", dateFormat = "yyyy/MM/dd")
   private LocalDate completionDate;
 
   @ApiModelProperty(value = "计划调整建议")

+ 10 - 0
railway-business/src/main/java/com/railway/business/bi/service/impl/ShowFileServiceImpl.java

@@ -27,6 +27,7 @@ import com.railway.business.bi.service.IShowYdtsService;
 import com.railway.common.core.domain.AjaxResult;
 import com.railway.common.enums.BusinessStatus;
 import com.railway.common.utils.SecurityUtils;
+import com.railway.common.utils.StringUtils;
 import com.railway.common.utils.poi.ExcelUtil;
 import java.time.LocalDateTime;
 import java.util.List;
@@ -186,6 +187,9 @@ public class ShowFileServiceImpl implements IShowFileService {
             return AjaxResult.error("文件读取失败");
           }
           for (ShowYdts bdyc : bdList) {
+            if(StringUtils.isEmpty(bdyc.getSubstationName()) || "0".equals(bdyc.getSubstationName())){
+              continue;
+            }
             bdyc.setFileId(fileId);
             ydtsService.create(bdyc);
           }
@@ -200,6 +204,9 @@ public class ShowFileServiceImpl implements IShowFileService {
             return AjaxResult.error("文件读取失败");
           }
           for (ShowGsd dlyc : dlList) {
+            if(StringUtils.isEmpty(dlyc.getLineName()) || "0".equals(dlyc.getLineName())){
+              continue;
+            }
             dlyc.setFileId(fileId);
             gsdService.create(dlyc);
           }
@@ -214,6 +221,9 @@ public class ShowFileServiceImpl implements IShowFileService {
             return AjaxResult.error("文件读取失败");
           }
           for (ShowGsy dlyc : syList) {
+            if(StringUtils.isEmpty(dlyc.getSubstationName()) || "0".equals(dlyc.getSubstationName())){
+              continue;
+            }
             dlyc.setFileId(fileId);
             gsyService.create(dlyc);
           }

+ 1 - 1
railway-common/src/main/java/com/railway/common/utils/LocalDateUtil.java

@@ -66,7 +66,7 @@ public final class LocalDateUtil {
   private static final String[] PARSE_PATTERNS = {
       "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
       "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
-      "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
+      "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM", "yyyyMMdd"};
 
   private static final long WEEK_DAYS = 7L;
 

+ 18 - 0
railway-common/src/main/java/com/railway/common/utils/poi/ExcelDateHandlerAdapter.java

@@ -0,0 +1,18 @@
+package com.railway.common.utils.poi;
+
+/**
+ * Excel数据格式处理适配器
+ *
+ * @author railway
+ */
+public interface ExcelDateHandlerAdapter {
+
+  /**
+   * 格式化
+   *
+   * @param value 单元格数据值
+   * @param args excel注解args参数组
+   * @return 处理后的值
+   */
+  Object format(Object value, String[] args);
+}

+ 10 - 7
railway-common/src/main/java/com/railway/common/utils/poi/ExcelUtil.java

@@ -390,7 +390,7 @@ public class ExcelUtil<T> {
             if (cellMapTmp.containsKey(i)) {
               value = cellMapTmp.get(i) + value;
             }
-            if(StringUtils.isEmpty(value) && i > 0){
+            if (StringUtils.isEmpty(value) && i > 0) {
               value = cellMapTmp.get(i - 1);
             }
             cellMapTmp.put(i, value);
@@ -454,6 +454,10 @@ public class ExcelUtil<T> {
             val = Convert.toBigDecimal(val);
           } else if (Date.class == fieldType || LocalDate.class == fieldType) {
             if (val instanceof String) {
+              String dateFormat = field.getAnnotation(Excel.class).dateFormat();
+              if (StringUtils.isNotEmpty(dateFormat) && dateFormat.equals("MMdd")) {
+                val = String.valueOf(LocalDate.now().getYear()) + val;
+              }
               val = LocalDateUtil.parseDate(val);
             } else if (val instanceof Double) {
               val = DateUtil.getJavaDate((Double) val);
@@ -1353,9 +1357,9 @@ public class ExcelUtil<T> {
       return row;
     }
     Object val = "";
-    try {
-      Cell cell = row.getCell(column);
-      if (StringUtils.isNotNull(cell)) {
+    Cell cell = row.getCell(column);
+    if (StringUtils.isNotNull(cell)) {
+      try {
         if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) {
           val = cell.getNumericCellValue();
           if (DateUtil.isCellDateFormatted(cell)) {
@@ -1375,10 +1379,9 @@ public class ExcelUtil<T> {
         } else if (cell.getCellType() == CellType.ERROR) {
           val = cell.getErrorCellValue();
         }
-
+      } catch (Exception e) {
+        return String.valueOf(cell.getRichStringCellValue());
       }
-    } catch (Exception e) {
-      return val;
     }
     return val;
   }