feat: 老法规企标导入兼容特殊数据
This commit is contained in:
+85
-51
@@ -155,20 +155,55 @@ public class EnterpriseStandardUtil {
|
||||
}
|
||||
|
||||
public static Map<String, String> splitStandardNumber(String standardNumber) {
|
||||
// 定义多个正则表达式来匹配不同的标准号格式
|
||||
String[] regexPatterns = {
|
||||
// "([A-Z]+)\\/([A-Z]+)\\s+([0-9A-Z])(\\d+(?:\\.\\d+)?)[-—](\\w+)", // 序列号是数字的情况
|
||||
// "([A-Z]+)/([A-Z]+)\\s+([0-9A-Z])(\\([0-9A-Z]+)\\[-—](\\w+)", // 序列号数字英文混合的情况
|
||||
// "([A-Za-z]{1,2})[-\\/]([A-Za-z]{1,2})\\s+([A-Za-z0-9]{1,3})[-—–]?(\\d{4,5}(?:\\.\\d+)?)[-—–]([A-Za-z0-9]+)", // 下面四种综合的正则
|
||||
// "([A-Za-z]{1,2})\\/([A-Za-z]{1,2})\\s+([0-9A-Z])(\\d+(?:\\.\\d+)?)[-—](\\w+)",// 正常格式
|
||||
// "([A-Za-z]{1,2})\\/([A-Za-z]{1,2}) (\\d)(\\.\\d+)?-([A-Za-z0-9]+)", // 带小数的格式
|
||||
// "([A-Za-z]{1,2})\\/([A-Za-z]{1,2})\\s+([A-Za-z0-9])-([A-Za-z0-9]+)",
|
||||
"([A-Z]+)\\/([A-Z]+)\\s+([0-9A-Z])([0-9A-Za-z]+(?:\\.[0-9A-Za-z]+)?)[-—](\\w+)"
|
||||
};
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
boolean isMatched = false;
|
||||
for (String regex : regexPatterns) {
|
||||
// 特殊标准处理
|
||||
if (standardNumber.contains("Q/JHK")) {
|
||||
String specialRegex = "([A-Z]+)\\/([A-Z]+) ([0-9A-Za-z]+)[-—](\\w+)";
|
||||
Pattern pattern = Pattern.compile(specialRegex);
|
||||
Matcher matcher = pattern.matcher(standardNumber);
|
||||
if (matcher.find()) {
|
||||
String esCode = matcher.group(1).trim();
|
||||
String eNameCode = matcher.group(2).trim();
|
||||
String sequenceNumber = matcher.group(3).trim();
|
||||
String yearNum = matcher.group(4).trim();
|
||||
|
||||
map.put(FieldCommon.ENTERPRISE_STANDARD_CODE, esCode);
|
||||
map.put(FieldCommon.ENTERPRISE_NAME_CODE, eNameCode);
|
||||
map.put(FieldCommon.STANDARD_NUMBER_TEMP, sequenceNumber);
|
||||
map.put(FieldCommon.YEAR_NUMBER, yearNum);
|
||||
isMatched = true;
|
||||
}
|
||||
if (!isMatched) {
|
||||
log.error("企标标准号" + standardNumber + "拆分失败");
|
||||
}
|
||||
return map;
|
||||
} else if (standardNumber.contains("J100019-2014/XG1")) {
|
||||
String specialRegex = "([A-Z]+)\\/([A-Z]+)\\s+([0-9A-Z])([0-9A-Za-z]+(?:\\.[0-9A-Za-z]+)?)[-—]([0-9]{4}/[A-Z]{2}[0-9]-[0-9]{4})";
|
||||
Pattern pattern = Pattern.compile(specialRegex);
|
||||
Matcher matcher = pattern.matcher(standardNumber);
|
||||
if (matcher.find()) {
|
||||
String esCode = matcher.group(1).trim();
|
||||
String eNameCode = matcher.group(2).trim();
|
||||
String sCategoryCode = matcher.group(3).trim();
|
||||
String sequenceNumber = matcher.group(4).trim();
|
||||
String yearNum = matcher.group(5).trim();
|
||||
|
||||
map.put(FieldCommon.ENTERPRISE_STANDARD_CODE, esCode);
|
||||
map.put(FieldCommon.ENTERPRISE_NAME_CODE, eNameCode);
|
||||
map.put(FieldCommon.STANDARD_CATEGORY_CODE, sCategoryCode);
|
||||
map.put(FieldCommon.STANDARD_NUMBER_TEMP, sequenceNumber);
|
||||
map.put(FieldCommon.YEAR_NUMBER, yearNum);
|
||||
isMatched = true;
|
||||
}
|
||||
if (!isMatched) {
|
||||
log.error("企标标准号" + standardNumber + "拆分失败");
|
||||
}
|
||||
return map;
|
||||
} else {
|
||||
// 定义多个正则表达式来匹配不同的标准号格式
|
||||
String regex = "([A-Z]+)\\/([A-Z]+)\\s+([0-9A-Z])([0-9A-Za-z]+(?:\\.[0-9A-Za-z]+)?)[-—](\\w+)";
|
||||
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(standardNumber);
|
||||
if (matcher.find()) {
|
||||
@@ -184,52 +219,51 @@ public class EnterpriseStandardUtil {
|
||||
map.put(FieldCommon.STANDARD_NUMBER_TEMP, sequenceNumber);
|
||||
map.put(FieldCommon.YEAR_NUMBER, yearNum);
|
||||
isMatched = true;
|
||||
break; // 匹配成功,跳出循环
|
||||
}
|
||||
if (!isMatched) {
|
||||
log.error("企标标准号" + standardNumber + "拆分失败");
|
||||
}
|
||||
return map;
|
||||
}
|
||||
if (!isMatched) {
|
||||
log.error("企标标准号" + standardNumber + "拆分失败");
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验企标编号是否不重复
|
||||
* @param StandardNumber
|
||||
* @return
|
||||
*/
|
||||
public boolean verifyEnStandardNumber(String StandardNumber) {
|
||||
List<String> numList = new ArrayList<>();
|
||||
// 判断是否和企标库中重复
|
||||
numList.addAll(esService.list().stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList()));
|
||||
// 判断是否和立项流程中重复
|
||||
numList.addAll(initChangeService.list().stream().map(ProcessEsInitChange::getNewEnStandardNo).collect(Collectors.toList()));
|
||||
return !numList.contains(StandardNumber);
|
||||
}
|
||||
/**
|
||||
* 校验企标编号是否不重复
|
||||
* @param StandardNumber
|
||||
* @return
|
||||
*/
|
||||
public boolean verifyEnStandardNumber (String StandardNumber){
|
||||
List<String> numList = new ArrayList<>();
|
||||
// 判断是否和企标库中重复
|
||||
numList.addAll(esService.list().stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList()));
|
||||
// 判断是否和立项流程中重复
|
||||
numList.addAll(initChangeService.list().stream().map(ProcessEsInitChange::getNewEnStandardNo).collect(Collectors.toList()));
|
||||
return !numList.contains(StandardNumber);
|
||||
}
|
||||
|
||||
// 判断是否是空Excel
|
||||
public void isEmptyExcel(Sheet sheet) {
|
||||
// 验证前三行是否有数据
|
||||
for (int rowIndex = 0; rowIndex < 3; rowIndex++) {
|
||||
Row row = sheet.getRow(rowIndex);
|
||||
if (row == null) {
|
||||
// 如果行对象为null,表示这一行不存在,抛出异常
|
||||
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR));
|
||||
} else {
|
||||
boolean isRowEmpty = true;
|
||||
for (int cellIndex = row.getFirstCellNum(); cellIndex < row.getLastCellNum(); cellIndex++) {
|
||||
Cell cell = row.getCell(cellIndex);
|
||||
if (cell != null && cell.getCellType() != CellType.BLANK) {
|
||||
// 如果找到非空单元格,设置标志为false并跳出循环
|
||||
isRowEmpty = false;
|
||||
break;
|
||||
// 判断是否是空Excel
|
||||
public void isEmptyExcel (Sheet sheet){
|
||||
// 验证前三行是否有数据
|
||||
for (int rowIndex = 0; rowIndex < 3; rowIndex++) {
|
||||
Row row = sheet.getRow(rowIndex);
|
||||
if (row == null) {
|
||||
// 如果行对象为null,表示这一行不存在,抛出异常
|
||||
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR));
|
||||
} else {
|
||||
boolean isRowEmpty = true;
|
||||
for (int cellIndex = row.getFirstCellNum(); cellIndex < row.getLastCellNum(); cellIndex++) {
|
||||
Cell cell = row.getCell(cellIndex);
|
||||
if (cell != null && cell.getCellType() != CellType.BLANK) {
|
||||
// 如果找到非空单元格,设置标志为false并跳出循环
|
||||
isRowEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isRowEmpty) {
|
||||
// 如果行是空的,抛出异常
|
||||
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR));
|
||||
}
|
||||
}
|
||||
if (isRowEmpty) {
|
||||
// 如果行是空的,抛出异常
|
||||
throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -262,6 +262,9 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
||||
String ssrq = dto.getSsrq();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
if (StrUtil.isNotBlank(fbrq)) {
|
||||
if (fbrq.length() == 6) {
|
||||
fbrq = fbrq + "01";
|
||||
}
|
||||
Date newDate = sdf.parse(fbrq.trim());
|
||||
if (newDate != null) {
|
||||
fb.setReleaseDate(newDate);
|
||||
@@ -270,6 +273,9 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(ssrq)) {
|
||||
if (ssrq.length() == 6) {
|
||||
ssrq = ssrq + "01";
|
||||
}
|
||||
Date newDate = sdf.parse(ssrq.trim());
|
||||
if (newDate != null) {
|
||||
fb.setImplementationDate(newDate);
|
||||
|
||||
Reference in New Issue
Block a user