diff --git a/laws-modules/src/main/java/com/jero/modules/laws/enterprise/util/EnterpriseStandardUtil.java b/laws-modules/src/main/java/com/jero/modules/laws/enterprise/util/EnterpriseStandardUtil.java index 76b34c56..5a22af52 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/enterprise/util/EnterpriseStandardUtil.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/enterprise/util/EnterpriseStandardUtil.java @@ -157,11 +157,11 @@ public class EnterpriseStandardUtil { public static Map splitStandardNumber(String 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})" + "([A-Z]+)/([A-Z]+)\\s+([0-9A-Z])(\\d+(?:\\.\\d+)?)[-—](\\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}) (\\d)(\\d{4})-([A-Za-z0-9]+)",// 正常格式 +// "([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]+)", }; Map map = new HashMap<>(); @@ -173,13 +173,14 @@ public class EnterpriseStandardUtil { String esCode = matcher.group(1); String eNameCode = matcher.group(2); String sCategoryCode = matcher.group(3); + String sequenceNumber = matcher.group(4); 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.STANDARD_NUMBER_TEMP, sequenceNumber); map.put(FieldCommon.YEAR_NUMBER, yearNum); - isMatched = true; break; // 匹配成功,跳出循环 } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/standard/entity/LawsEnterpriseStandard.java b/laws-modules/src/main/java/com/jero/modules/laws/standard/entity/LawsEnterpriseStandard.java index c4662b07..50098abd 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/standard/entity/LawsEnterpriseStandard.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/standard/entity/LawsEnterpriseStandard.java @@ -306,6 +306,12 @@ public class LawsEnterpriseStandard implements Serializable { @ApiModelProperty(value = "顺序号") private String standardNumberTemp; + /** + * 老法规系统Id + */ + @ApiModelProperty(value = "老法规系统Id") + private String oldSystemId; + @TableField(exist = false) private static final long serialVersionUID = 1809789807789012221L; } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/standard/service/impl/LawsEnterpriseStandardServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/standard/service/impl/LawsEnterpriseStandardServiceImpl.java index 0fe4ff69..f3eb59dd 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/standard/service/impl/LawsEnterpriseStandardServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/standard/service/impl/LawsEnterpriseStandardServiceImpl.java @@ -17,6 +17,8 @@ import com.jero.modules.laws.common.constant.FieldCommon; import com.jero.modules.laws.enterprise.entity.OldSystemImportDTO; import com.jero.modules.laws.enterprise.service.ESSequenceNumberProvider; import com.jero.modules.laws.enterprise.util.EnterpriseStandardUtil; +import com.jero.modules.laws.home.common.LawsHomeSearchCommon; +import com.jero.modules.laws.home.service.ILawsHomeSearchService; import com.jero.modules.laws.oldSystem.entity.OldSystemDepartRelation; import com.jero.modules.laws.oldSystem.service.OldSystemDepartRelationService; import com.jero.modules.laws.standard.entity.LawsDomesticStandard; @@ -32,6 +34,7 @@ import com.jero.modules.system.entity.SysUser; import com.jero.modules.system.service.ISysDepartService; import com.jero.modules.system.service.ISysUserService; import io.minio.errors.MinioException; +import lombok.Cleanup; import lombok.extern.slf4j.Slf4j; import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -96,6 +99,9 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl> standardNumberToFileMap = ossFileList.stream().collect(Collectors.groupingBy(OSSFile::getStandardNo)); // 4. 遍历待保存或更新的列表,设置ID + StringBuilder oldIds = new StringBuilder(); + StringBuilder newIds = new StringBuilder(); for (LawsDomesticStandard entity : gbList) { LawsDomesticStandard existingEntity = standardNumberToEntityMap.get(entity.getStandardNumber()); if (existingEntity != null) { @@ -319,6 +330,12 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(OSSFile::getStandardId, existingEntity.getId()); + ossFileService.remove(wrapper); + // 拼接老id + oldIds.append(existingEntity.getId()).append(","); } String tdbzh = entity.getSubstituteStandardNumber(); String btdbzh = entity.getReplacedByStandardNumber(); @@ -341,6 +358,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl 0) { + oldIds = new StringBuilder(oldIds.substring(0, oldIds.length() - 1)); + lawsHomeSearchService.updateEsData(LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD, oldIds.toString(), LawsHomeSearchCommon.LAWS_ES_DELETE); + } + // 同步es数据库 + if (newIds.length() > 0) { + newIds = new StringBuilder(newIds.substring(0, newIds.length() - 1)); + lawsHomeSearchService.updateEsData(LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD, newIds.toString(), LawsHomeSearchCommon.LAWS_ES_ADD); + } } private void oldSysESImport(List esDatalist, List errImportList) { @@ -361,7 +389,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl> standardNumberToFileMap = ossFileList.stream().collect(Collectors.groupingBy(OSSFile::getStandardNo)); // 4. 遍历待保存或更新的列表,设置ID + StringBuilder oldIds = new StringBuilder(); + StringBuilder newIds = new StringBuilder(); for (LawsEnterpriseStandard entity : esList) { String curStandardNumber = entity.getStandardNumber(); LawsEnterpriseStandard existingEntity = standardNumberToEntityMap.get(entity.getStandardNumber()); if (existingEntity != null) { // 如果存在,则先删后增 this.removeById(existingEntity.getId()); + // 代替 + lawsReplacedStandardService.removeRelation(existingEntity.getStandardNumber(), 1); // 删除文件关联 LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); wrapper.eq(OSSFile::getStandardId, existingEntity.getId()); ossFileService.remove(wrapper); - // 代替 - lawsReplacedStandardService.removeRelation(existingEntity.getStandardNumber(), 1); + // 拼接老id + oldIds.append(existingEntity.getId()).append(","); } String tdbzh = entity.getSubstituteStandardNumber(); String btdbzh = entity.getReplacedByStandardNumber(); @@ -482,6 +515,9 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl 0) { + oldIds = new StringBuilder(oldIds.substring(0, oldIds.length() - 1)); + lawsHomeSearchService.updateEsData(LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD, oldIds.toString(), LawsHomeSearchCommon.LAWS_ES_DELETE); + } + // 同步es数据库 + if (newIds.length() > 0) { + newIds = new StringBuilder(newIds.substring(0, newIds.length() - 1)); + lawsHomeSearchService.updateEsData(LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD, newIds.toString(), LawsHomeSearchCommon.LAWS_ES_ADD); + } } @Override