Создал модуль cleaning-builders для общих билдеров. Добавил PlannerAllTodayBuilder и ISchedulerChecker для валидации и создания PlannerAllToday.
This commit is contained in:
parent
384847168b
commit
e5239c7a24
3 changed files with 135 additions and 0 deletions
37
clearing-parent/cleaning-builders/pom.xml
Normal file
37
clearing-parent/cleaning-builders/pom.xml
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>ru.spcex.clearing</groupId>
|
||||||
|
<artifactId>clearing-parent</artifactId>
|
||||||
|
<version>SPCEX-1.0.0.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>cleaning-builders</artifactId>
|
||||||
|
<name>cleaning-builders</name>
|
||||||
|
<description>Cleaning builders module</description>
|
||||||
|
<version>SPCEX-1.0.0.0</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ru.spcex.clearing</groupId>
|
||||||
|
<artifactId>classes</artifactId>
|
||||||
|
<version>SPCEX-1.0.0.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ru.spcex.platform</groupId>
|
||||||
|
<artifactId>platform-enum</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package ru.spcex.clearing.scheduler;
|
||||||
|
|
||||||
|
import ru.clearing.classes.statics.data.scheduler.Planner;
|
||||||
|
import ru.clearing.classes.statics.data.scheduler.PlannerAllToday;
|
||||||
|
import ru.clearing.classes.statics.data.scheduler.PlannerTemplate;
|
||||||
|
import ru.spcex.platform.enumeration.Parent;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
public class PlannerAllTodayBuilder {
|
||||||
|
private Long id;
|
||||||
|
private String task;
|
||||||
|
private LocalTime taskTime;
|
||||||
|
private LocalDate clearingDate;
|
||||||
|
private String market;
|
||||||
|
private String taskStatus;
|
||||||
|
private Long companyId;
|
||||||
|
private Long securityId;
|
||||||
|
private String parent;
|
||||||
|
|
||||||
|
public static PlannerAllTodayBuilder builder() {
|
||||||
|
return new PlannerAllTodayBuilder();
|
||||||
|
}
|
||||||
|
private PlannerAllTodayBuilder(){}
|
||||||
|
|
||||||
|
public PlannerAllTodayBuilder append(PlannerTemplate plannerTemplate){
|
||||||
|
this.task = plannerTemplate.getTask();
|
||||||
|
this.taskTime = plannerTemplate.getTaskTime();
|
||||||
|
this.taskStatus = plannerTemplate.getTaskStatus();
|
||||||
|
this.companyId = plannerTemplate.getCompanyId();
|
||||||
|
this.securityId = plannerTemplate.getSecurityId();
|
||||||
|
this.parent = Parent.Planner.getKey();
|
||||||
|
this.id = plannerTemplate.getId();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlannerAllTodayBuilder append(Planner plannerTemplate){
|
||||||
|
this.task = plannerTemplate.getTask();
|
||||||
|
this.taskTime = plannerTemplate.getTaskTime();
|
||||||
|
this.clearingDate = plannerTemplate.getClearingDate();
|
||||||
|
this.market = plannerTemplate.getMarket();
|
||||||
|
this.taskStatus = plannerTemplate.getTaskStatus();
|
||||||
|
this.companyId = plannerTemplate.getCompanyId();
|
||||||
|
this.securityId = plannerTemplate.getSecurityId();
|
||||||
|
this.parent = Parent.Planner.getKey();
|
||||||
|
this.id = plannerTemplate.getId();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlannerAllToday build() {
|
||||||
|
PlannerAllToday res = new PlannerAllToday();
|
||||||
|
res.setTask(this.task);
|
||||||
|
res.setTaskTime(this.taskTime);
|
||||||
|
res.setClearingDate(this.clearingDate);
|
||||||
|
res.setMarket(this.market);
|
||||||
|
res.setTaskStatus(this.taskStatus);
|
||||||
|
res.setCompanyId(this.companyId);
|
||||||
|
res.setSecurityId(this.securityId);
|
||||||
|
res.setParent(this.parent);
|
||||||
|
res.setParentId(this.id);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package ru.spcex.clearing.scheduler;
|
||||||
|
|
||||||
|
import ru.clearing.classes.statics.data.scheduler.ClearingCalendar;
|
||||||
|
import ru.clearing.classes.statics.data.scheduler.Planner;
|
||||||
|
import ru.clearing.classes.statics.data.scheduler.PlannerAllToday;
|
||||||
|
import ru.spcex.platform.enumeration.DayStatus;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
public class ISchedulerChecker {
|
||||||
|
|
||||||
|
public static boolean isValidPlanner(Planner planner, LocalDate currentDate) {
|
||||||
|
return planner.getTaskStatus() != null && (planner.getClearingDate() == null || planner.getClearingDate().isEqual(currentDate));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean needRemoveByPlanner(Planner planner, PlannerAllToday plannerAllToday) {
|
||||||
|
return (planner.getTaskTime() != null && planner.getTaskTime().equals(plannerAllToday.getTaskTime()))
|
||||||
|
&& (planner.getCompanyId() != null && planner.getCompanyId().equals(plannerAllToday.getCompanyId()))
|
||||||
|
&& (planner.getSecurityId() != null && planner.getSecurityId().equals(plannerAllToday.getSecurityId()))
|
||||||
|
&& (planner.getTask() != null && planner.getTask().equalsIgnoreCase(plannerAllToday.getTask()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isWeekend тек.день=СБ-ВС<br>
|
||||||
|
*/
|
||||||
|
public static boolean isValidWorkday(ClearingCalendar clearingCalendar, boolean isWeekend) {
|
||||||
|
if (clearingCalendar.getDayStatus() != null && clearingCalendar.getDayStatus().equalsIgnoreCase(DayStatus.Workday.getKey())) {
|
||||||
|
if (isWeekend) {
|
||||||
|
return clearingCalendar.getCompanyId() != null && clearingCalendar.getCompanyId() != 0;
|
||||||
|
} else return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue