Fix chache selecting for LP
This commit is contained in:
parent
bbc7c64acf
commit
bcfe0328f0
5 changed files with 15 additions and 14 deletions
|
|
@ -31,7 +31,7 @@ public interface LegalsMapMapper {
|
||||||
@Param("batchSize") int batchSize,
|
@Param("batchSize") int batchSize,
|
||||||
@Param("lastId") Long lastId);
|
@Param("lastId") Long lastId);
|
||||||
|
|
||||||
List<LegalsMap> findCachedByInnAndRegNUm(@Param("json") String json);
|
List<LegalsMap> findCachedByInnAndRegNum(@Param("json") String json);
|
||||||
|
|
||||||
void updateSearchedAt(@Param("json") String json);
|
void updateSearchedAt(@Param("json") String json);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,12 +56,13 @@ public class PackageRecordsService {
|
||||||
|
|
||||||
public Map<Pair<Long, Long>, LegalsMap> findCachedLegalsByInnAndRegNums(List<SubjectProfile> subjects) {
|
public Map<Pair<Long, Long>, LegalsMap> findCachedLegalsByInnAndRegNums(List<SubjectProfile> subjects) {
|
||||||
try {
|
try {
|
||||||
List<InnRegnumPair> innAndRegNums = subjects.stream()
|
String json = entityToJsonMapper.writeValueAsString(subjects.stream()
|
||||||
.map(s -> new InnRegnumPair(s.getInn(), s.getRegNum()))
|
.filter(Objects::nonNull)
|
||||||
.toList();
|
.map(s -> new HashMap<String, Object>() {{
|
||||||
String json = entityToJsonMapper.writeValueAsString(innAndRegNums);
|
put("inn", s.getInn());
|
||||||
|
put("reg_num", s.getRegNum());
|
||||||
return legalsMapMapper.findCachedByInnAndRegNUm(json)
|
}}).toList());
|
||||||
|
return legalsMapMapper.findCachedByInnAndRegNum(json)
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
lm -> Pair.of(lm.getInn(), lm.getRegNum()),
|
lm -> Pair.of(lm.getInn(), lm.getRegNum()),
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ public class LpFidEnricher implements Handler<SubjectPayload, SubjectPayload> {
|
||||||
|
|
||||||
packageRecordsService.saveLegalsToCache(subjectForSave);
|
packageRecordsService.saveLegalsToCache(subjectForSave);
|
||||||
|
|
||||||
return subjectForSave.stream().anyMatch(s -> s.getFid() != null);
|
return subjectForSave.stream().anyMatch(s -> s.getFid() != null) || (noFidsData.isEmpty() && !cachedRecords.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillByCache(SubjectProfile subjectProfile, LegalsMap cachedRecord) {
|
private void fillByCache(SubjectProfile subjectProfile, LegalsMap cachedRecord) {
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ public class NpFidEnricher implements Handler<SubjectPayload, SubjectPayload> {
|
||||||
|
|
||||||
packageRecordsService.saveToCache(subjectForSave);
|
packageRecordsService.saveToCache(subjectForSave);
|
||||||
|
|
||||||
return subjectForSave.stream().anyMatch(s -> s.getFid() != null);
|
return subjectForSave.stream().anyMatch(s -> s.getFid() != null) || (noFidsData.isEmpty() && !cachedRecords.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillByCache(SubjectProfile subjectProfile, PhonesMap cachedRecord) {
|
private void fillByCache(SubjectProfile subjectProfile, PhonesMap cachedRecord) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
<resultMap id="LegalsMap" type="ru.nbch.credit_tracker.entities.app.LegalsMap">
|
<resultMap id="LegalsMap" type="ru.nbch.credit_tracker.entities.app.LegalsMap">
|
||||||
<result property="id" column="id"/>
|
<result property="id" column="id"/>
|
||||||
<result property="inn" column="inn"/>
|
<result property="inn" column="inn"/>
|
||||||
<result property="regNUm" column="reg_num"/>
|
<result property="regNum" column="reg_num"/>
|
||||||
<result property="fid" column="fid"/>
|
<result property="fid" column="fid"/>
|
||||||
<result property="searchedAt" column="searched_at"/>
|
<result property="searchedAt" column="searched_at"/>
|
||||||
<result property="flag90days" column="flag_90_12"/>
|
<result property="flag90days" column="flag_90_12"/>
|
||||||
|
|
@ -58,11 +58,11 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findCachedByInnAndRegNUm" resultMap="LegalsMap">
|
<select id="findCachedByInnAndRegNum" resultMap="LegalsMap">
|
||||||
WITH src AS (SELECT inn, regNum
|
WITH src AS (SELECT inn, reg_num
|
||||||
FROM json_to_recordset(#{json}::json) AS t(
|
FROM json_to_recordset(#{json}::json) AS t(
|
||||||
inn bigint,
|
inn bigint,
|
||||||
regNum bigint
|
reg_num bigint
|
||||||
))
|
))
|
||||||
SELECT slm.id AS id,
|
SELECT slm.id AS id,
|
||||||
slm.fid as fid,
|
slm.fid as fid,
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
slm.calculated_at AS calculated_at,
|
slm.calculated_at AS calculated_at,
|
||||||
slm.last_rejected_date AS last_rejected_date
|
slm.last_rejected_date AS last_rejected_date
|
||||||
FROM signals_legals_map slm
|
FROM signals_legals_map slm
|
||||||
WHERE (slm.inn, slm.reg_num) IN (SELECT inn, regNum FROM src)
|
WHERE (slm.inn, slm.reg_num) IN (SELECT inn, reg_num FROM src)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findEligibleForFlagsUpdate" resultMap="LegalsMap">
|
<select id="findEligibleForFlagsUpdate" resultMap="LegalsMap">
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue