Commit d105c9aa authored by suhuiguang's avatar suhuiguang

fix(综合搜索):数据同步调整

1.检验单位、检测单位分开
parent 8300c84a
......@@ -6,7 +6,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.thymeleaf.util.ListUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Component
@Slf4j
......@@ -14,8 +17,8 @@ import java.util.List;
public class BaseEnterpriseUpdate {
public final String jyjcjg = "检验检测机构";
public final String jcdw = "检测单位";
public final String jydw = "检验单位";
public final String jcdw = "检测单位";
public final String jyjgCode = "1233-1";
public final String jcjgCode = "1233-2";
......@@ -23,25 +26,24 @@ public class BaseEnterpriseUpdate {
// 如果单位类型中包含检验检测机构、检测单位、检验单位,且有资质信息,则更新单位类型
if ((oldUnitType.contains(jyjcjg) || oldUnitType.contains(jydw) || oldUnitType.contains(jcdw)) && !ListUtils.isEmpty(unitLicences)) {
long jyjgCount = unitLicences.stream().filter(e -> e.getCertTypeCode().equals(jyjgCode)).count();
long jcjgCount = unitLicences.stream().filter(e -> e.getCertTypeCode().equals(jcjgCode)).count();
StringBuilder afterType = new StringBuilder();
long jydwCount = unitLicences.stream().filter(e -> jyjgCode.equals(e.getCertTypeCode()) || jydw.equals(e.getCertType())).count();
long jcdwCount = unitLicences.stream().filter(e -> jcjgCode.equals(e.getCertTypeCode()) || jcdw.equals(e.getCertType())).count();
// 如果资质中不含有检验和检测资质,则不更新单位类型
if (jcjgCount == 0 && jyjgCount == 0) {
if (jydwCount == 0 && jcdwCount == 0) {
return oldUnitType;
}
// 处理旧的单位类型
oldUnitType = oldUnitType.replace(jyjcjg, "").replace(jcdw, "").replace(jydw, "");
oldUnitType = oldUnitType.replace("##", "#");
oldUnitType = oldUnitType.startsWith("#") ? oldUnitType.substring(1) : oldUnitType;
oldUnitType = oldUnitType.endsWith("#") ? oldUnitType.substring(0, oldUnitType.length() - 1) : oldUnitType;
if (jcjgCount > 0) {
afterType.append("#").append(jcdw);
Set<String> units = Arrays.stream(oldUnitType.split("#")).collect(Collectors.toSet());
units.remove(jyjcjg);
units.remove(jydw);
units.remove(jcdw);
if (jydwCount > 0) {
units.add(jydw);
}
if (jyjgCount > 0) {
afterType.append("#").append(jydw);
if (jcdwCount > 0) {
units.add(jcdw);
}
return oldUnitType + afterType;
return String.join("#", units);
} else {
return oldUnitType;
}
......
......@@ -1440,7 +1440,11 @@ public class DataHandlerServiceImpl {
return esLicense;
}).collect(Collectors.toList());
esBaseEnterpriseInfo.setLicenses(licenses);
esBaseEnterpriseInfo.setUnitType(baseEnterpriseUpdate.updateJyjcUnitType(enterpriseInfo.getUnitType(), licenses));
try {
esBaseEnterpriseInfo.setUnitType(baseEnterpriseUpdate.updateJyjcUnitType(enterpriseInfo.getUnitType(), licenses));
} catch (Exception e) {
log.error("单位类型转换失败:{}", enterpriseInfo, e);
}
return esBaseEnterpriseInfo;
}).collect(Collectors.toList());
enterpriseInfoDao.saveAll(esBaseEnterpriseInfos);
......
......@@ -77,7 +77,11 @@ public class EnterpriseRefreshHandler implements IDataRefreshHandler {
return esLicense;
}).collect(Collectors.toList());
esBaseEnterpriseInfo.setLicenses(licenses);
esBaseEnterpriseInfo.setUnitType(baseEnterpriseUpdate.updateJyjcUnitType(enterpriseInfo.getUnitType(), licenses));
try {
esBaseEnterpriseInfo.setUnitType(baseEnterpriseUpdate.updateJyjcUnitType(enterpriseInfo.getUnitType(), licenses));
} catch (Exception e) {
log.error("单位类型转换失败:{}", enterpriseInfo, e);
}
enterpriseInfoDao.save(esBaseEnterpriseInfo);
// 人员更新冗余的单位信息
List<TzsUserInfo> userOfOneUnit = userInfoMapper.selectList(new LambdaQueryWrapper<TzsUserInfo>().eq(TzsUserInfo::getUnitCode, enterpriseInfo.getUseUnitCode()).eq(BaseEntity::getIsDelete, false).select(BaseEntity::getSequenceNbr));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment