оптимизация: выделен общий алгоритм
This commit is contained in:
@@ -9,10 +9,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import ru.dmitriymx.astralcheckreport.AstralSession;
|
import ru.dmitriymx.astralcheckreport.AstralSession;
|
||||||
import ru.dmitriymx.astralcheckreport.ExcelDataRow;
|
import ru.dmitriymx.astralcheckreport.ExcelDataRow;
|
||||||
import ru.dmitriymx.astralcheckreport.Main;
|
import ru.dmitriymx.astralcheckreport.Main;
|
||||||
import ru.dmitriymx.astralcheckreport.objects.Cert;
|
import ru.dmitriymx.astralcheckreport.objects.*;
|
||||||
import ru.dmitriymx.astralcheckreport.objects.LeftObject;
|
|
||||||
import ru.dmitriymx.astralcheckreport.objects.Organization;
|
|
||||||
import ru.dmitriymx.astralcheckreport.objects.Product;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -45,7 +42,7 @@ public abstract class AbstractTarifProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int countActiveCert(List<Cert> historyCert) {
|
int countActiveCert(List<Cert> historyCert) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for (Cert cert : historyCert) {
|
for (Cert cert : historyCert) {
|
||||||
if (cert.endCertDate.after(Main.currentDate)) {
|
if (cert.endCertDate.after(Main.currentDate)) {
|
||||||
@@ -56,5 +53,21 @@ public abstract class AbstractTarifProcessor {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean checkDateCert(Organization organization) {
|
||||||
|
Product product = organization.products.get(0);
|
||||||
|
Tarif tarif = product.contractTariffs.get(0);
|
||||||
|
if (product.certs.size() > 1) {
|
||||||
|
logger.warn("({}/{}): Обнаружено более 1 сертификата!", organization.inn, organization.kpp);
|
||||||
|
}
|
||||||
|
Cert cert = product.certs.get(0);
|
||||||
|
|
||||||
|
if (cert.startCertDate.before(tarif.date_initialDate)) {
|
||||||
|
logger.error("({}/{}): Ошибка: сертификат выдан раньше тарифа!", organization.inn, organization.kpp);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void process0(AstralSession astral, Organization organization, ExcelDataRow data);
|
protected abstract void process0(AstralSession astral, Organization organization, ExcelDataRow data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,18 +52,7 @@ public class Akcia3MountTarifProcessor extends AbstractTarifProcessor {
|
|||||||
|
|
||||||
// Step III: Проверяем разницу дат.
|
// Step III: Проверяем разницу дат.
|
||||||
// Сертификат должен быть выдан в тот же день или позже, чем тариф
|
// Сертификат должен быть выдан в тот же день или позже, чем тариф
|
||||||
if (product.certs.size() > 1) {
|
checkDateCert(organization);
|
||||||
logger.warn("({}/{}): Обнаружено более 1 сертификата!", organization.inn, organization.kpp);
|
|
||||||
}
|
|
||||||
Cert cert = product.certs.get(0);
|
|
||||||
|
|
||||||
long tarifDateLong = tarif.date_initialDate.getTime();
|
|
||||||
long certDateLong = cert.startCertDate.getTime();
|
|
||||||
|
|
||||||
if (certDateLong < tarifDateLong) {
|
|
||||||
logger.error("({}/{}): Ошибка: сертификат выдан раньше тарифа!", organization.inn, organization.kpp);
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.trace("Тариф игнорируется: \"{}\"", tarif.name);
|
logger.trace("Тариф игнорируется: \"{}\"", tarif.name);
|
||||||
|
|||||||
@@ -20,22 +20,10 @@ public class BasicTarifProcessor extends AbstractTarifProcessor {
|
|||||||
protected void process0(AstralSession astral, Organization organization, ExcelDataRow data) {
|
protected void process0(AstralSession astral, Organization organization, ExcelDataRow data) {
|
||||||
// Step I: Проверяем разницу дат.
|
// Step I: Проверяем разницу дат.
|
||||||
// Сертификат должен быть выдан в тот же день или позже, чем тариф
|
// Сертификат должен быть выдан в тот же день или позже, чем тариф
|
||||||
Product product = organization.products.get(0);
|
if (!checkDateCert(organization)) return;
|
||||||
Tarif tarif = product.contractTariffs.get(0);
|
|
||||||
if (product.certs.size() > 1) {
|
|
||||||
logger.warn("({}/{}): Обнаружено более 1 сертификата!", organization.inn, organization.kpp);
|
|
||||||
}
|
|
||||||
Cert cert = product.certs.get(0);
|
|
||||||
|
|
||||||
long tarifDateLong = tarif.date_initialDate.getTime();
|
|
||||||
long certDateLong = cert.startCertDate.getTime();
|
|
||||||
|
|
||||||
if (certDateLong < tarifDateLong) {
|
|
||||||
logger.error("({}/{}): Ошибка: сертификат выдан раньше тарифа!", organization.inn, organization.kpp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step II: Проверяем кол-во Направлений
|
// Step II: Проверяем кол-во Направлений
|
||||||
|
Product product = organization.products.get(0);
|
||||||
if (!calcRecipients2(product, data)) { //TODO надо проверять по категориям
|
if (!calcRecipients2(product, data)) { //TODO надо проверять по категориям
|
||||||
logger.warn("({}/{}): Внимание! Не соответствие количества направлений!", organization.inn, organization.kpp);
|
logger.warn("({}/{}): Внимание! Не соответствие количества направлений!", organization.inn, organization.kpp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,22 +25,10 @@ public class GroupCompanyTarifProcessor extends AbstractTarifProcessor {
|
|||||||
|
|
||||||
// Step II: Проверяем разницу дат.
|
// Step II: Проверяем разницу дат.
|
||||||
// Сертификат должен быть выдан в тот же день или позже, чем тариф
|
// Сертификат должен быть выдан в тот же день или позже, чем тариф
|
||||||
Product product = organization.products.get(0);
|
if (!checkDateCert(organization)) return;
|
||||||
Tarif tarif = product.contractTariffs.get(0);
|
|
||||||
if (product.certs.size() > 1) {
|
|
||||||
logger.warn("({}/{}): Обнаружено более 1 сертификата!", organization.inn, organization.kpp);
|
|
||||||
}
|
|
||||||
Cert cert = product.certs.get(0);
|
|
||||||
|
|
||||||
long tarifDateLong = tarif.date_initialDate.getTime();
|
|
||||||
long certDateLong = cert.startCertDate.getTime();
|
|
||||||
|
|
||||||
if (certDateLong < tarifDateLong) {
|
|
||||||
logger.error("({}/{}): Ошибка: сертификат выдан раньше тарифа!", organization.inn, organization.kpp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step III: Проверяем кол-во Направлений
|
// Step III: Проверяем кол-во Направлений
|
||||||
|
Product product = organization.products.get(0);
|
||||||
if (!calcRecipients4(product, data)) { //TODO надо проверять по категориям
|
if (!calcRecipients4(product, data)) { //TODO надо проверять по категориям
|
||||||
logger.warn("({}/{}): Внимание! Не соответствие количества направлений!", organization.inn, organization.kpp);
|
logger.warn("({}/{}): Внимание! Не соответствие количества направлений!", organization.inn, organization.kpp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,10 @@ public class OptimalniyTarifProcessor extends AbstractTarifProcessor {
|
|||||||
protected void process0(AstralSession astral, Organization organization, ExcelDataRow data) {
|
protected void process0(AstralSession astral, Organization organization, ExcelDataRow data) {
|
||||||
// Step I: Проверяем разницу дат.
|
// Step I: Проверяем разницу дат.
|
||||||
// Сертификат должен быть выдан в тот же день или позже, чем тариф
|
// Сертификат должен быть выдан в тот же день или позже, чем тариф
|
||||||
Product product = organization.products.get(0);
|
if (!checkDateCert(organization)) return;
|
||||||
Tarif tarif = product.contractTariffs.get(0);
|
|
||||||
if (product.certs.size() > 1) {
|
|
||||||
logger.warn("({}/{}): Обнаружено более 1 сертификата!", organization.inn, organization.kpp);
|
|
||||||
}
|
|
||||||
Cert cert = product.certs.get(0);
|
|
||||||
|
|
||||||
long tarifDateLong = tarif.date_initialDate.getTime();
|
|
||||||
long certDateLong = cert.startCertDate.getTime();
|
|
||||||
|
|
||||||
if (certDateLong < tarifDateLong) {
|
|
||||||
logger.error("({}/{}): Ошибка: сертификат выдан раньше тарифа!", organization.inn, organization.kpp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step II: Проверяем кол-во Направлений
|
// Step II: Проверяем кол-во Направлений
|
||||||
|
Product product = organization.products.get(0);
|
||||||
if (!calcRecipients4(product, data)) { //TODO надо проверять по категориям
|
if (!calcRecipients4(product, data)) { //TODO надо проверять по категориям
|
||||||
logger.warn("({}/{}): Внимание! Не соответствие количества направлений!", organization.inn, organization.kpp);
|
logger.warn("({}/{}): Внимание! Не соответствие количества направлений!", organization.inn, organization.kpp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,22 +20,10 @@ public class StartTarifProcessor extends AbstractTarifProcessor {
|
|||||||
protected void process0(AstralSession astral, Organization organization, ExcelDataRow data) {
|
protected void process0(AstralSession astral, Organization organization, ExcelDataRow data) {
|
||||||
// Step I: Проверяем разницу дат.
|
// Step I: Проверяем разницу дат.
|
||||||
// Сертификат должен быть выдан в тот же день или позже, чем тариф
|
// Сертификат должен быть выдан в тот же день или позже, чем тариф
|
||||||
Product product = organization.products.get(0);
|
if (!checkDateCert(organization)) return;
|
||||||
Tarif tarif = product.contractTariffs.get(0);
|
|
||||||
if (product.certs.size() > 1) {
|
|
||||||
logger.warn("({}/{}): Обнаружено более 1 сертификата!", organization.inn, organization.kpp);
|
|
||||||
}
|
|
||||||
Cert cert = product.certs.get(0);
|
|
||||||
|
|
||||||
long tarifDateLong = tarif.date_initialDate.getTime();
|
|
||||||
long certDateLong = cert.startCertDate.getTime();
|
|
||||||
|
|
||||||
if (certDateLong < tarifDateLong) {
|
|
||||||
logger.error("({}/{}): Ошибка: сертификат выдан раньше тарифа!", organization.inn, organization.kpp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step II: Проверяем кол-во Направлений
|
// Step II: Проверяем кол-во Направлений
|
||||||
|
Product product = organization.products.get(0);
|
||||||
if (!calcRecipients1(product, data)) { //TODO надо проверять по категориям
|
if (!calcRecipients1(product, data)) { //TODO надо проверять по категориям
|
||||||
logger.warn("({}/{}): Внимание! Не соответствие количества направлений!", organization.inn, organization.kpp);
|
logger.warn("({}/{}): Внимание! Не соответствие количества направлений!", organization.inn, organization.kpp);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user