ialbert 2026-05-21 17:20:56 +03:00
parent c60e37d699
commit 030c41b55a
2 changed files with 53 additions and 4 deletions

View file

@ -0,0 +1,38 @@
package ru.spcex.clearing.component.predicate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.clearing.platform.dictionary.SessionTypeDictionary;
import ru.spcex.platform.imdg.api.Imdg;
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
import ru.spcex.platform.utils.text.TextUtil;
public class SessionNameByType {
private static final Logger log = LoggerFactory.getLogger(SessionNameByType.class);
private final Imdg<SessionTypeDictionary> imdg;
public static SessionNameByType withSsnTypeImdg(final Imdg<SessionTypeDictionary> imdg) {
return new SessionNameByType(imdg);
}
private SessionNameByType(Imdg<SessionTypeDictionary> imdg) {
this.imdg = imdg;
}
public String getName(String code) {
if (code == null) throw new NullPointerException("cannot search SessionType name with null arg");
ImdgPredicateBuilder pb = imdg.predicateBuilder();
SessionTypeDictionary dictionaryRecord = imdg.getSingleObjectByPredicate(
pb.equals("code", code)
);
if (dictionaryRecord == null) {
log.warn("couldn't find SessionDictionary for code '{}'", code);
return code;
}
if (TextUtil.isEmpty(dictionaryRecord.getName())) {
log.warn("SessionDictionary#name for code '{}' is null", code);
return code;
}
return dictionaryRecord.getName();
}
}

View file

@ -23,7 +23,9 @@ import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Service;
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
import ru.clearing.classes.statics.data.registry.Registry;
import ru.clearing.platform.dictionary.SessionTypeDictionary;
import ru.spcex.clearing.component.GroupRgsKey;
import static ru.spcex.clearing.component.predicate.SessionNameByType.withSsnTypeImdg;
import ru.spcex.clearing.component.predicate.cash.CategoryByCompanyIdCashingPredicate;
import ru.spcex.clearing.component.predicate.cash.registry.AssetByTcrCompanyAccountCashedPredicate;
import ru.spcex.clearing.error.RgsError;
@ -61,10 +63,12 @@ public class InspectionObligationsPrecAction extends ReviseStage1Action {
private final Logger log = LoggerFactory.getLogger(getClass());
private final Imdg<Registry> registryImdg;
private final Imdg<ClearingMemberCategory> cmcImdg;
private final Imdg<SessionTypeDictionary> ssnTypeImdg;
private final ImdgId idGen;
private final IMessageResolver msgResolver = new SimpleMessageResolver();
private Function<List<String>, Boolean> cmcFilter;
private SessionType sessionType;
private String ssnName;
private Long sessionId;
@Autowired
@ -72,6 +76,7 @@ public class InspectionObligationsPrecAction extends ReviseStage1Action {
super(imdgProvider);
this.registryImdg = imdgProvider.getCashingImdg(IMDGDistributedNames.Map_Registry, Registry.class, null);
this.cmcImdg = imdgProvider.getCashingImdg(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class, null);
this.ssnTypeImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SessionTypeDictionary, SessionTypeDictionary.class);
this.idGen = imdgProvider.getImdgIdGenerator();
}
@ -91,6 +96,7 @@ public class InspectionObligationsPrecAction extends ReviseStage1Action {
);
this.sessionId = ctx.getExtendedState().get(DataEnum.sessionId, Long.class);
this.sessionType = ctx.getExtendedState().get(DataEnum.sessionType, SessionType.class);
this.ssnName = withSsnTypeImdg(ssnTypeImdg).getName(sessionType.getKey());
inspectionObligations(ctx);
} finally {
a___Cash.clear();
@ -251,13 +257,18 @@ public class InspectionObligationsPrecAction extends ReviseStage1Action {
pmt.setRegistryStatus(RegistryStatus.PROC.getKey());
rgssToStore.put(pmt.getId(), pmt);
if (notificationMessage[0] == null) {
notificationMessage[0] = new StringBuilder("Сформированы PM*T регистры:");
notificationMessage[0] = new StringBuilder(
"Сессия «%s» завершена. Выявлена задолженность:".formatted(ssnName)
);
}
notificationMessage[0].append("\nдля компании %s регистр %d;".formatted(pmt.getShortName(), pmt.getId()));
notificationMessage[0].append("\nКомпания %s, код %s, %s %s;".formatted(
pmt.getShortName(), pmt.getTradingCode(), pmt.getBalance(), pmt.getSecuritySymbol())
);
});
if (notificationMessage[0] != null) {
ctx.getExtendedState().getVariables().put(DataEnum.notificationMessage, notificationMessage[0].toString());
if (notificationMessage[0] == null) { // сформированно 0 PM_T регистров
notificationMessage[0] = new StringBuilder("Сессия «%s» завершена. Задолженность не выявлена".formatted(ssnName));
}
ctx.getExtendedState().getVariables().put(DataEnum.notificationMessage, notificationMessage[0].toString());
ctx.getExtendedState().getVariables().put(DataEnum.erroneousRegistries, errs);
ctx.getExtendedState().getVariables().put(DataEnum.inspectionObligationStashedRgs, rgssToStore);
}