feat: 国标导入当标准性质为推荐性的时候三个字段不做必填校验

This commit is contained in:
2024-04-01 16:07:57 +08:00
parent 2103ba16b2
commit 2a6af0c082
2 changed files with 40 additions and 14 deletions
@@ -213,5 +213,12 @@ public class FieldCommon {
// 责任部门负责人 // 责任部门负责人
public static final String RESPONSIBLE_DEPARTMENT_USER = "responsible_department_user"; 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";
} }
@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile; import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@@ -91,6 +92,8 @@ public class ImportUtil {
// 从数据行开始遍历 // 从数据行开始遍历
for (int i = 3; i < sheet.getPhysicalNumberOfRows(); i++) { for (int i = 3; i < sheet.getPhysicalNumberOfRows(); i++) {
int line = i + 1; int line = i + 1;
boolean needValidMustInput = true;
String standardProperty = "";
String standardNumber = ""; String standardNumber = "";
String standardClass = ""; String standardClass = "";
String yearNumber = ""; String yearNumber = "";
@@ -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()) || if (!((TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(tag.getIsModel()) ||
TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(tag.getIsModel())) && TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(tag.getIsModel())) &&
@@ -355,6 +368,11 @@ public class ImportUtil {
// 设置是否需要校验发布日期 实施日期 // 设置是否需要校验发布日期 实施日期
isGbFbNeedValidDate = !doNotValidDateStandardStateList.contains(cellValue); isGbFbNeedValidDate = !doNotValidDateStandardStateList.contains(cellValue);
} }
// 标准性质
if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(tag.getIsModel()) &&
FieldCommon.STANDARD_PROPERTY.equals(tag.getDbFieldName())) {
standardProperty = cellValue;
}
} }
// 转为value // 转为value
cellValue = this.convertDictValue(tag.getDictField(), cellValue); cellValue = this.convertDictValue(tag.getDictField(), cellValue);
@@ -935,6 +953,7 @@ public class ImportUtil {
} }
return true; return true;
} }
// 文件校验 // 文件校验
private boolean inspectContentFileValid(String cellValue, Map<String, File> fileMap) { private boolean inspectContentFileValid(String cellValue, Map<String, File> fileMap) {
// 检查是否真的有这个文件 // 检查是否真的有这个文件