feat: 外标标准库导入支持老法规导入
This commit is contained in:
+3
-12
@@ -1642,18 +1642,9 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
// 解压缩
|
||||
String zipEntryName = FileUnZip.unZipFiles(path + File.separator + file.getOriginalFilename(), String.valueOf(path));
|
||||
|
||||
// 需求变更 不做判断
|
||||
//判断压缩包下是否只有一个文件夹
|
||||
// File fileTemp = new File(path.toUri());
|
||||
// int length = fileTemp.listFiles().length;
|
||||
// if (length > 2) {
|
||||
// FileUnZip.deleteDir(saveDirectory);
|
||||
// throw new JeroBootException(MessageUtils.getMessage(ResultCommon.FOLDER_ONLY_ONE));
|
||||
// }
|
||||
|
||||
List<File> fileList = new ArrayList<>();
|
||||
for (File file1 : Objects.requireNonNull(saveDirectory.listFiles())) {
|
||||
if (file1.getName().contains(".xls") || file1.getName().contains(".xlsx")) {
|
||||
if (file1.getName().contains(".xls") || file1.getName().contains(".xlsx") || file1.getName().contains(".xlsm")) {
|
||||
fileList.add(file1);
|
||||
}
|
||||
}
|
||||
@@ -1674,7 +1665,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
String moduleCode = "";
|
||||
if (tableName.equals(TableNameEnum.ENTERPRISE_STANDARDS.getTableName())) {
|
||||
// 检查Excel的文件名
|
||||
if (!excelName.equals("企业标准法规导入模板.xls")) {
|
||||
if (!excelName.equals("企业标准法规导入模板.xls") && !excelName.contains("xlsm")) {
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR));
|
||||
}
|
||||
@@ -1682,7 +1673,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
}
|
||||
if (tableName.equals(TableNameEnum.DOMESTIC_REGULATIONS.getTableName())) {
|
||||
// 检查Excel的文件名
|
||||
if (!excelName.equals("外来标准法规导入模板.xls")) {
|
||||
if (!excelName.equals("外来标准法规导入模板.xls") && !excelName.contains("xlsm")) {
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR));
|
||||
}
|
||||
|
||||
@@ -125,29 +125,15 @@ public class ImportUtil {
|
||||
errMsg.append("第").append(row).append("列").append(tag.getDbFieldTxt()).append("为必填 ");
|
||||
break;
|
||||
}
|
||||
try {
|
||||
standardNumber = cell.toString().trim();
|
||||
// 必须是数字
|
||||
if (!standardNumber.matches("^[0-9]+(\\.[0-9]+)?$")) {
|
||||
log.error("第" + row + "列" + tag.getDbFieldTxt() + "填写错误,标准号必须为数字 ");
|
||||
errMsg.append("第").append(row).append("列").append(tag.getDbFieldTxt()).append("填写错误,标准号必须为数字 ");
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("第" + row + "列" + tag.getDbFieldTxt() + "填写错误 ");
|
||||
errMsg.append("第").append(row).append("列").append(tag.getDbFieldTxt()).append("填写错误 ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (FieldCommon.YEAR_NUMBER.equals(tag.getDbFieldName())) {
|
||||
if (cell != null && StrUtil.isNotBlank(cell.toString().trim())) {
|
||||
// 校验是否是正确的四位数字年
|
||||
if (!cell.toString().trim().matches("^[0-9]{4}$")) {
|
||||
log.error("第" + row + "列" + tag.getDbFieldTxt() + "填写错误 ");
|
||||
errMsg.append("第").append(row).append("列").append(tag.getDbFieldTxt()).append("填写错误 ");
|
||||
break;
|
||||
// 如果有小数点则去除小数点及后面的数字
|
||||
if (cell.toString().trim().contains(".")) {
|
||||
yearNumber = cell.toString().trim().split("\\.")[0];
|
||||
} else {
|
||||
yearNumber = cell.toString().trim();
|
||||
}
|
||||
yearNumber = String.valueOf(Integer.parseInt(cell.toString().trim()));
|
||||
} else {
|
||||
yearNumber = "BLANK";
|
||||
}
|
||||
@@ -250,7 +236,8 @@ public class ImportUtil {
|
||||
}
|
||||
|
||||
// 字段长度校验
|
||||
if (FieldShowTypeEnum.TEXT_BOX.getValue().equals(tag.getFieldShowType())) {
|
||||
if (FieldShowTypeEnum.TEXT_BOX.getValue().equals(tag.getFieldShowType()) &&
|
||||
!FieldCommon.STANDARD_ENGLISH_NAME.equals(tag.getDbFieldName())) {
|
||||
if (cellValue.length() > 50) {
|
||||
log.error("第" + row + "列输入的" + tag.getDbFieldTxt() + "超过50字 ");
|
||||
errMsg.append("第").append(row).append("列输入的").append(tag.getDbFieldTxt()).append("超过50字 ");
|
||||
@@ -507,6 +494,8 @@ public class ImportUtil {
|
||||
String nodeId = sysDepartPathMap.get(value);
|
||||
return StrUtil.isNotBlank(nodeId);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -638,11 +627,6 @@ public class ImportUtil {
|
||||
|
||||
try {
|
||||
for (String dateStr : dates) {
|
||||
if (dateStr.length() < dateFormatPattern.length()) {
|
||||
// 如果日期字符串长度小于格式字符串长度,则直接返回false
|
||||
log.error("日期格式长度错误");
|
||||
return false;
|
||||
}
|
||||
// 解析日期字符串
|
||||
Date date = sdf.parse(dateStr.trim());
|
||||
// 使用Calendar获取年份
|
||||
|
||||
Reference in New Issue
Block a user