feat: 国标导入当标准性质为推荐性的时候三个字段不做必填校验
This commit is contained in:
@@ -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";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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<String, File> 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<SysUser> 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<String> 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<String, File> fileMap) {
|
||||
// 检查是否真的有这个文件
|
||||
|
||||
Reference in New Issue
Block a user