ci: 同步企标字段名称

This commit is contained in:
2023-11-08 14:38:23 +08:00
parent 17057c704f
commit 705044ff24
5 changed files with 56 additions and 33 deletions
@@ -149,24 +149,37 @@ public class EnterpriseStandardUtil {
}
public static Map<String, String> splitStandardNumber(String standardNumber) {
// 使用正则表达式匹配所需的各个部分
Pattern pattern = Pattern.compile("([A-Za-z]{1,2})\\/([A-Za-z]{1,2}) (\\d)(\\d{4})-(\\d{4})");
Matcher matcher = pattern.matcher(standardNumber);
// 定义多个正则表达式匹配不同的标准号格式
String[] regexPatterns = {
"([A-Za-z]{1,2})[-\\/]([A-Za-z]{1,2})\\s+([A-Za-z0-9]{1,3})[-—–]?(\\d{4,5}(?:\\.\\d+)?)[-—–](\\d{4})", // 下面四种综合的正则
"([A-Za-z]{1,2})\\/([A-Za-z]{1,2}) (\\d)(\\d{4})-(\\d{4})",// 正常格式
"([A-Za-z]{1,2})\\/([A-Za-z]{1,2}) (\\d{1,3})(\\.\\d+)?-(\\d{4})", // 带小数的格式
"([A-Za-z]{1,2})\\/([A-Za-z]{1,2})\\s+([A-Za-z0-9]{1,3})-(\\d{4})", // 类别代号J11这种格式
"([A-Za-z]{1,2})[-\\/]([A-Za-z]{1,2})\\s+([A-Za-z0-9]{1,3})[-—–]\\d{4,5}(\\.\\d+)?-(\\d{4})"
};
Map<String, String> map = new HashMap<>();
if (matcher.find()) {
String esCode = matcher.group(1);
String eNameCode = matcher.group(2);
String sCategoryCode = matcher.group(3);
String yearNum = matcher.group(5);
boolean isMatched = false;
for (String regex : regexPatterns) {
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(standardNumber);
if (matcher.find()) {
String esCode = matcher.group(1);
String eNameCode = matcher.group(2);
String sCategoryCode = matcher.group(3);
String yearNum = matcher.group(5);
map.put(FieldCommon.ENTERPRISE_STANDARD_CODE, esCode);
map.put(FieldCommon.ENTERPRISE_NAME_CODE, eNameCode);
map.put(FieldCommon.STANDARD_CATEGORY_CODE, sCategoryCode);
map.put(FieldCommon.YEAR_NUMBER, yearNum);
} else {
log.error("企标标准号拆分失败");
throw new JeroBootException("企标标准号拆分失败");
map.put(FieldCommon.ENTERPRISE_STANDARD_CODE, esCode);
map.put(FieldCommon.ENTERPRISE_NAME_CODE, eNameCode);
map.put(FieldCommon.STANDARD_CATEGORY_CODE, sCategoryCode);
map.put(FieldCommon.YEAR_NUMBER, yearNum);
isMatched = true;
break; // 匹配成功,跳出循环
}
}
if (!isMatched) {
log.error("企标标准号" + standardNumber + "拆分失败");
}
return map;
}
@@ -25,6 +25,7 @@ import com.jero.modules.tag.entity.LawsTag;
import com.jero.modules.tag.enums.TableNameEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -242,8 +243,10 @@ public class LawsEnterpriseController {
@AutoLog(value = "企业法规标准-老法规企标数据库Zip导入")
@ApiOperation(value="企业法规标准-老法规企标数据库Zip导入", notes="企业法规标准-老法规企标数据库Zip导入")
@PostMapping("/importOldSystemESZip")
public Result<?> importOldSystemESZip(@RequestParam("file") MultipartFile file) {
enterpriseStandardService.importExcelOldSystem(file);
public Result<?> importOldSystemESZip(@RequestParam("file") MultipartFile file,
@ApiParam(value = "0不导入 1导入企标 2导入国标", required = true)
@RequestParam("type") String type) {
enterpriseStandardService.importExcelOldSystem(file, type);
return Result.OK("导入成功");
}
@@ -111,7 +111,7 @@ public class LawsEnterpriseStandard implements Serializable {
* 企标英文名称
*/
@ApiModelProperty(value = "企标英文名称")
private String englishName;
private String standardEnglishName;
/**
* 标准等级分类
@@ -23,5 +23,5 @@ public interface ILawsEnterpriseStandardService extends IService<LawsEnterpriseS
* @param file
* @return
*/
void importExcelOldSystem(MultipartFile file);
void importExcelOldSystem(MultipartFile file, String type);
}
@@ -105,7 +105,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
}
@Override
public void importExcelOldSystem(MultipartFile zipFile) {
public void importExcelOldSystem(MultipartFile zipFile, String type) {
// 验证文件是否为压缩格式
if (!Objects.requireNonNull(zipFile.getContentType()).contains("zip")) {
throw new JeroBootException("文件格式不正确,请上传zip格式的压缩包。");
@@ -175,18 +175,25 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
log.error("导入失败;{}", e.getMessage());
}
// 导入企标
// 判断是否需要跳过
if (esDatalist.isEmpty()) {
log.info("企标数据为空,跳过导入");
} else {
// this.oldSysESImport(esDatalist);
}
// 导入国标
// 判断是否需要跳过
if (gbDatalist.isEmpty()) {
log.info("国标数据为空,跳过导入");
} else {
this.oldSysGBImport(gbDatalist);
switch (type) {
case "0":
break;
case "1":
// 判断是否需要跳过
if (esDatalist.isEmpty()) {
log.info("企标数据为空,跳过导入");
} else {
this.oldSysESImport(esDatalist);
}
break;
case "2":
// 导入国标
// 判断是否需要跳过
if (gbDatalist.isEmpty()) {
log.info("国标数据为空,跳过导入");
} else {
this.oldSysGBImport(gbDatalist);
}
}
}
@@ -274,7 +281,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
LawsEnterpriseStandard es = new LawsEnterpriseStandard();
es.setStandardNumber(dto.getBzh());
es.setStandardName(dto.getBzmc());
es.setEnglishName(dto.getBzywmc());
es.setStandardEnglishName(dto.getBzywmc());
es.setReleaseDate(dto.getFbrq());
es.setImplementationDate(dto.getSsrq());
String standardState = dto.getBzzt();