parent
7543e4b08f
commit
ccddd98cd6
8 changed files with 21 additions and 30 deletions
|
|
@ -62,7 +62,7 @@ public class PlannerAllTodayMaker {
|
|||
List<PlannerAllToday> res = new ArrayList<>();
|
||||
|
||||
if (needAddFromPlannerTemplate(currentDate, clearingCalendarMap.values())){
|
||||
plannerTemplateMap.values().stream().filter(plannerTemplate -> Status.Active.getKey().equals(plannerTemplate.getTaskStatus()))
|
||||
plannerTemplateMap.values().stream().filter(plannerTemplate -> Status.Active.equalsByKey(plannerTemplate.getTaskStatus()))
|
||||
.forEach(plannerTemplate -> res.add(PlannerAllTodayBuilder.builder().append(plannerTemplate).build()));
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@
|
|||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>clearing-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>security-util</artifactId>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import ru.clearing.classes.statics.data.scheduler.PlannerAllToday;
|
|||
import ru.spcex.clearing.scheduler.service.TaskManager;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
|
@ -16,15 +17,14 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||
public class PlannerQueueConfig {
|
||||
private static final Logger log = LoggerFactory.getLogger(TaskManager.class);
|
||||
|
||||
private static BlockingQueue<Map.Entry<TaskManager.Process, PlannerAllToday>> plannerQueue;
|
||||
private final static BlockingQueue<Map.Entry<TaskManager.Process, PlannerAllToday>> plannerQueue = new LinkedBlockingQueue<>();
|
||||
|
||||
@Bean(name = "plannerQueue")
|
||||
public BlockingQueue<Map.Entry<TaskManager.Process, PlannerAllToday>> plannerQueue() {
|
||||
plannerQueue = new LinkedBlockingQueue<>();
|
||||
return plannerQueue;
|
||||
}
|
||||
|
||||
public static void addToPlannerQueue(TaskManager.Process process, PlannerAllToday plannerAllToday) {
|
||||
public static void addToPlannerQueue(@NotNull TaskManager.Process process, @NotNull PlannerAllToday plannerAllToday) {
|
||||
try {
|
||||
plannerQueue.put(Map.entry(process, plannerAllToday));
|
||||
} catch (InterruptedException e) {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class ClearingCalendarValidationConfig {
|
|||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
ValidationError.CompanyNotFound,
|
||||
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
DictionaryPresentRule.instance("dayStatus",
|
||||
ClearingCalendarNewRequest::getDayStatus,
|
||||
IMDGDistributedNames.Map_DayStatusDictionary,
|
||||
|
|
@ -74,7 +74,7 @@ public class ClearingCalendarValidationConfig {
|
|||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
ValidationError.CompanyNotFound,
|
||||
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
DictionaryPresentRule.instance("dayStatus",
|
||||
ClearingCalendarUpdateRequest::getDayStatus,
|
||||
IMDGDistributedNames.Map_DayStatusDictionary,
|
||||
|
|
|
|||
|
|
@ -55,13 +55,13 @@ public class PlannerTemplateValidationConfig {
|
|||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
ValidationError.CompanyNotFound,
|
||||
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
IdPresentRule.instance("securityId",
|
||||
PlannerTemplateNewRequest::getSecurityId,
|
||||
IMDGDistributedNames.Map_Security,
|
||||
Security.class,
|
||||
ValidationError.SecurityNotFound,
|
||||
security -> WorkflowStatus.Active.getKey().equals(security.getWorkflowStatus()) ? null : ValidationError.SecurityNotActive)
|
||||
security -> WorkflowStatus.Active.equalsByKey(security.getWorkflowStatus()) ? null : ValidationError.SecurityNotActive)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
@ -102,14 +102,14 @@ public class PlannerTemplateValidationConfig {
|
|||
Company.class,
|
||||
ValidationError.CompanyNotFound,
|
||||
false,
|
||||
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
IdPresentRule.instance("securityId",
|
||||
PlannerTemplateUpdateRequest::getSecurityId,
|
||||
IMDGDistributedNames.Map_Security,
|
||||
Security.class,
|
||||
ValidationError.SecurityNotFound,
|
||||
false,
|
||||
security -> WorkflowStatus.Active.getKey().equals(security.getWorkflowStatus()) ? null : ValidationError.SecurityNotActive)
|
||||
security -> WorkflowStatus.Active.equalsByKey(security.getWorkflowStatus()) ? null : ValidationError.SecurityNotActive)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,13 +62,13 @@ public class PlannerValidationConfig {
|
|||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
ValidationError.CompanyNotFound,
|
||||
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
IdPresentRule.instance("securityId",
|
||||
PlannerNewRequest::getSecurityId,
|
||||
IMDGDistributedNames.Map_Security,
|
||||
Security.class,
|
||||
ValidationError.SecurityNotFound,
|
||||
security -> WorkflowStatus.Active.getKey().equals(security.getWorkflowStatus()) ? null : ValidationError.SecurityNotActive)
|
||||
security -> WorkflowStatus.Active.equalsByKey(security.getWorkflowStatus()) ? null : ValidationError.SecurityNotActive)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
@ -117,14 +117,14 @@ public class PlannerValidationConfig {
|
|||
Company.class,
|
||||
ValidationError.CompanyNotFound,
|
||||
false,
|
||||
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : ValidationError.CompanyNotActive),
|
||||
IdPresentRule.instance("securityId",
|
||||
PlannerUpdateRequest::getSecurityId,
|
||||
IMDGDistributedNames.Map_Security,
|
||||
Security.class,
|
||||
ValidationError.SecurityNotFound,
|
||||
false,
|
||||
security -> WorkflowStatus.Active.getKey().equals(security.getWorkflowStatus()) ? null : ValidationError.SecurityNotActive)
|
||||
security -> WorkflowStatus.Active.equalsByKey(security.getWorkflowStatus()) ? null : ValidationError.SecurityNotActive)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class ClearingCalendarService extends QueueConsumer implements Initializi
|
|||
clearingCalendarMap.insert(clearingCalendar);
|
||||
log.debug("successfully processed, new id {}", clearingCalendar.getId());
|
||||
//если clearingCalendar.getClearingDate() сегодняшний день необходимо проверить/добавить plannerTemplate
|
||||
updateFromPlannerAllTodayMap(clearingCalendar);
|
||||
createPlannerAllTodayFromPlannerTemplateIfIsValidWorkday(clearingCalendar);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ public class ClearingCalendarService extends QueueConsumer implements Initializi
|
|||
clearingCalendarMap.update(clearingCalendar);
|
||||
log.debug("successfully processed, new id {}", clearingCalendar.getId());
|
||||
//если clearingCalendar.getClearingDate() сегодняшний день необходимо проверить/добавить plannerTemplate
|
||||
updateFromPlannerAllTodayMap(clearingCalendar);
|
||||
createPlannerAllTodayFromPlannerTemplateIfIsValidWorkday(clearingCalendar);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ public class ClearingCalendarService extends QueueConsumer implements Initializi
|
|||
return null;
|
||||
}
|
||||
|
||||
private void updateFromPlannerAllTodayMap(ClearingCalendar clearingCalendar) {
|
||||
private void createPlannerAllTodayFromPlannerTemplateIfIsValidWorkday(ClearingCalendar clearingCalendar) {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
if (clearingCalendar.getClearingDate() == null || !clearingCalendar.getClearingDate().equals(currentDate))
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.scheduler.Launcher;
|
||||
|
|
@ -95,18 +94,6 @@ public class TaskManager implements InitializingBean, AutoCloseable {
|
|||
});
|
||||
}
|
||||
|
||||
private static LocalDateTime dateOldTypeConvert(@NonNull Date oldDate) {
|
||||
return LocalDateTime.ofInstant(oldDate.toInstant(), ZoneId.systemDefault());
|
||||
}
|
||||
|
||||
private static LocalDate dateTypeConvert(@NonNull Date oldDate) {
|
||||
return dateOldTypeConvert(oldDate).toLocalDate();
|
||||
}
|
||||
|
||||
private static LocalTime timeTypeConvert(@NonNull Date oldDate) {
|
||||
return dateOldTypeConvert(oldDate).toLocalTime();
|
||||
}
|
||||
|
||||
// --- Обработчики PlannerAllToday ---
|
||||
public void entryAdded(PlannerAllToday task) {
|
||||
String taskStatus = task.getTaskStatus();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue