From 2a6af0c0822131c83d0fe2c21b563d3d3b1ebff6 Mon Sep 17 00:00:00 2001 From: caihaohan Date: Mon, 1 Apr 2024 16:04:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9B=BD=E6=A0=87=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=BD=93=E6=A0=87=E5=87=86=E6=80=A7=E8=B4=A8=E4=B8=BA=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E6=80=A7=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=89=E4=B8=AA?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=B8=8D=E5=81=9A=E5=BF=85=E5=A1=AB=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../laws/common/constant/FieldCommon.java | 7 +++ .../modules/laws/common/util/ImportUtil.java | 47 +++++++++++++------ 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/laws-modules/src/main/java/com/jero/modules/laws/common/constant/FieldCommon.java b/laws-modules/src/main/java/com/jero/modules/laws/common/constant/FieldCommon.java index 81adbb67..d51e56a6 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/common/constant/FieldCommon.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/common/constant/FieldCommon.java @@ -213,5 +213,12 @@ public class FieldCommon { // 责任部门负责人 public static final String RESPONSIBLE_DEPARTMENT_USER = "responsible_department_user"; + // 适用认证 + public static final String APPLICABLE_CERTIFICATION = "applicable_certification"; + // 适用车型 + public static final String APPLICABLE_VEHICLE = "applicable_vehicle"; + // 标注性质 + public static final String STANDARD_PROPERTY = "standard_property"; + } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/common/util/ImportUtil.java b/laws-modules/src/main/java/com/jero/modules/laws/common/util/ImportUtil.java index f5475832..64db1d4e 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/common/util/ImportUtil.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/common/util/ImportUtil.java @@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.mock.web.MockMultipartFile; import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; + import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; @@ -48,7 +49,7 @@ import java.util.stream.Collectors; @Component public class ImportUtil { - @Value(value="${jero.uploadType}") + @Value(value = "${jero.uploadType}") private String uploadType; @Resource @@ -65,7 +66,7 @@ public class ImportUtil { @Resource private IOSSFileService ossFileService; - + @Resource private ISysDictItemService sysDictItemService; @@ -91,6 +92,8 @@ public class ImportUtil { // 从数据行开始遍历 for (int i = 3; i < sheet.getPhysicalNumberOfRows(); i++) { int line = i + 1; + boolean needValidMustInput = true; + String standardProperty = ""; String standardNumber = ""; String standardClass = ""; String yearNumber = ""; @@ -125,10 +128,10 @@ public class ImportUtil { if (!standardValidFlag) { if ((TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(tag.getIsModel()) || TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(tag.getIsModel())) - && + && (FieldCommon.STANDARD_NUMBER_TEMP.equals(tag.getDbFieldName()) || - FieldCommon.STANDARD_CLASS.equals(tag.getDbFieldName()) || - FieldCommon.YEAR_NUMBER.equals(tag.getDbFieldName())) + FieldCommon.STANDARD_CLASS.equals(tag.getDbFieldName()) || + FieldCommon.YEAR_NUMBER.equals(tag.getDbFieldName())) ) { if (FieldCommon.STANDARD_NUMBER_TEMP.equals(tag.getDbFieldName())) { if (cell == null) { @@ -195,7 +198,7 @@ public class ImportUtil { errMsg.append("第").append(line).append("行的标准编号已存在"); break; } - standardClass = this.convertDictValue("standard_type" , standardClass); + standardClass = this.convertDictValue("standard_type", standardClass); // 判断是否有重复数据 if (keyMap.containsKey(domesticStandardNumber)) { errMsgList.add("第" + keyMap.get(domesticStandardNumber) + "行'标准编号'与第" + line + "行数据重复。"); @@ -222,7 +225,7 @@ public class ImportUtil { errMsg.append("第").append(line).append("行的标准编号已存在"); break; } - standardClass = this.convertDictValue("standard_type_overseas" , standardClass); + standardClass = this.convertDictValue("standard_type_overseas", standardClass); // 判断是否有重复数据 if (keyMap.containsKey(foreignStandardNumber)) { errMsgList.add("第" + keyMap.get(foreignStandardNumber) + "行'标准编号'与第" + line + "行数据重复。"); @@ -239,8 +242,18 @@ public class ImportUtil { } } + // 国内标准 标准性质为推荐性的时候 零部件名称 适用认证 适用车型 非必填 + if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(tag.getIsModel()) && + standardProperty.equals("推荐性") && ( + FieldCommon.PART_NAME.equals(tag.getDbFieldName()) || + FieldCommon.APPLICABLE_CERTIFICATION.equals(tag.getDbFieldName()) || + FieldCommon.APPLICABLE_VEHICLE.equals(tag.getDbFieldName()) + )) { + needValidMustInput = false; + } + // 必填验证 - if (YesOrNoEnum.YES.getValue().equals(tag.getFieldMustInput())) { + if (YesOrNoEnum.YES.getValue().equals(tag.getFieldMustInput()) && needValidMustInput) { // 国内标准 标准状态为起草 征求意见 报批 状态的发布日期实施日期不是必填项 if (!((TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(tag.getIsModel()) || TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(tag.getIsModel())) && @@ -355,6 +368,11 @@ public class ImportUtil { // 设置是否需要校验发布日期 实施日期 isGbFbNeedValidDate = !doNotValidDateStandardStateList.contains(cellValue); } + // 标准性质 + if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(tag.getIsModel()) && + FieldCommon.STANDARD_PROPERTY.equals(tag.getDbFieldName())) { + standardProperty = cellValue; + } } // 转为value cellValue = this.convertDictValue(tag.getDictField(), cellValue); @@ -700,7 +718,7 @@ public class ImportUtil { private String convertFileIds(String cellValue, Map fileMap) { String[] pathList = cellValue.split(","); - StringBuilder fileIds = new StringBuilder(); + StringBuilder fileIds = new StringBuilder(); for (String path : pathList) { try { String bizPath = "temp"; @@ -719,7 +737,7 @@ public class ImportUtil { ossFileService.save(ossFile); fileIds.append(ossFile.getId()).append(","); } - }catch (Exception e) { + } catch (Exception e) { log.error("导入文件上传失败", e); } } @@ -746,7 +764,7 @@ public class ImportUtil { // 去除掉最后的逗号 return result.substring(0, result.length() - 1); } - + // 单选用户转换 public String convertSingleUserId(String cellValue) { QueryWrapper wrapper = new QueryWrapper<>(); @@ -792,7 +810,7 @@ public class ImportUtil { sysDepartLambdaQueryWrapper.eq(SysDepart::getDepartName, cellValue); return sysDepartService.getOne(sysDepartLambdaQueryWrapper).getId(); } - + // 字典转换 public String convertDictValue(String dictCode, String cellValue) { String[] valueList = cellValue.split(","); @@ -877,7 +895,7 @@ public class ImportUtil { } return true; } - + // 体系校验 public boolean standardSystemValid(String cellValue) { List valueList = Arrays.asList(cellValue.split(",")); @@ -928,13 +946,14 @@ public class ImportUtil { || lowerCasePath.endsWith(".jpg") || lowerCasePath.endsWith(".jpeg") || lowerCasePath.endsWith(".png") || lowerCasePath.endsWith(".avi") || lowerCasePath.endsWith(".wmv") || lowerCasePath.endsWith(".mov") - || lowerCasePath.endsWith(".rm") || lowerCasePath.endsWith(".mp4") + || lowerCasePath.endsWith(".rm") || lowerCasePath.endsWith(".mp4") || lowerCasePath.endsWith(".cad"))) { return false; } } return true; } + // 文件校验 private boolean inspectContentFileValid(String cellValue, Map fileMap) { // 检查是否真的有这个文件