add check on exist sdf57 record by dbfId
This commit is contained in:
parent
1621a3cfb9
commit
37bc4b72cd
2 changed files with 27 additions and 3 deletions
|
|
@ -1,10 +1,13 @@
|
|||
package ru.spcex.clearing.dbf.importer.logic.data.tables;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
public abstract class AbstractTable<T extends SpcexObjectBase> {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final String prefix;
|
||||
private final Class<T> clazz;
|
||||
private final String nameOfMap;
|
||||
|
|
@ -37,10 +40,15 @@ public abstract class AbstractTable<T extends SpcexObjectBase> {
|
|||
if (map == null) {
|
||||
bootMap();
|
||||
}
|
||||
map.insert(obj);
|
||||
if (checkOnExisting(obj)) {
|
||||
map.insert(obj);
|
||||
}
|
||||
}
|
||||
|
||||
private void bootMap() {
|
||||
protected boolean checkOnExisting(T obj){
|
||||
return true;
|
||||
}
|
||||
protected void bootMap() {
|
||||
map = (ImdgHazelcast<T>) hazelcastService.getImdg(nameOfMap, clazz);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
package ru.spcex.clearing.dbf.importer.logic.data.tables;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf57;
|
||||
import ru.spcex.clearing.dbf.importer.logic.data.enums.ETable;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class SDf57Table extends AbstractTable<SDf57> {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private static final String PREFIX = ETable.DF_57.name();
|
||||
private static final Class<SDf57> CLAZZ = SDf57.class;
|
||||
private static final String NAME_OF_HZ_MAP = IMDGDistributedNames.Map_SDf57;
|
||||
|
|
@ -62,4 +66,16 @@ public class SDf57Table extends AbstractTable<SDf57> {
|
|||
result.setGenerationId(fileId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkOnExisting(SDf57 obj) {
|
||||
if (map == null) {
|
||||
bootMap();
|
||||
}
|
||||
Collection<SDf57> sDf57s = map.getCollectionObjectsByFieldValues(Map.of("dbfId", obj.getDbfId()));
|
||||
if (!sDf57s.isEmpty()) {
|
||||
log.warn("Skip insert by {}, sdf57.dbfId: {}", PREFIX, obj.getDbfId());
|
||||
}
|
||||
return sDf57s.isEmpty();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue