SDF57 statement.contract
This commit is contained in:
parent
e366b647cc
commit
334e01d02d
1 changed files with 23 additions and 22 deletions
|
|
@ -64,6 +64,7 @@ import java.util.function.Function;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import static ru.spcex.platform.enumeration.RegistryTradingParams.D__V;
|
||||
import static ru.spcex.platform.enumeration.RegistryTradingParams.OM_T;
|
||||
import static ru.spcex.platform.utils.number.BigDecimalUtil.safeBD;
|
||||
|
||||
@Service
|
||||
|
|
@ -656,31 +657,31 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
|
|||
return comment.replaceAll("\\s+", "");
|
||||
}
|
||||
|
||||
private static String getContractFromSpecif(String specif) {
|
||||
if (specif == null) {
|
||||
private String getContractFromSpecif(String specif) {
|
||||
if (TextUtil.isEmpty(specif)) {
|
||||
return null;
|
||||
}
|
||||
int index = specif.indexOf("№");
|
||||
if (index == -1) {
|
||||
return null;
|
||||
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
||||
ImdgPredicate prdct = pb.and(
|
||||
pb.sql(RegistryCodeSqlBuilder.getInstance(OM_T).build()),
|
||||
pb.equals("registryStatus", RegistryStatus.PROC.getKey()),
|
||||
pb.notNull("contract"),
|
||||
pb.not(pb.equals("contract", ""))
|
||||
);
|
||||
String contract = registryImdg.getCollectionObjectsByPredicate(prdct)
|
||||
.stream()
|
||||
.filter(r -> r.getValueDate() != null)
|
||||
.filter(r -> r.getRefundDate() != null)
|
||||
.filter(r -> r.getValueDate().isBefore(r.getRefundDate()))
|
||||
.map(Registry::getContract)
|
||||
.filter(specif::contains)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (contract == null) {
|
||||
log.warn("couldn't find match for specif {}", specif);
|
||||
}
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String afterN = specif.substring(index + 1);
|
||||
int countSlashes = 0;
|
||||
for(int i = 0; i < afterN.length(); i++) {
|
||||
char c = afterN.charAt(i);
|
||||
if (!Character.isWhitespace(c)) {
|
||||
buffer.append(c);
|
||||
if (c == '/') {
|
||||
countSlashes++;
|
||||
}
|
||||
} else {
|
||||
if (countSlashes == 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
return contract;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue