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