Пустой тариф
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
package ru.dmitriymx.astralcheckreport;
|
package ru.dmitriymx.astralcheckreport;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -13,6 +15,9 @@ import ru.dmitriymx.astralcheckreport.objects.*;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class Main implements Runnable {
|
public class Main implements Runnable {
|
||||||
@@ -20,6 +25,7 @@ public class Main implements Runnable {
|
|||||||
private ExcelReader excel;
|
private ExcelReader excel;
|
||||||
private Properties properties = new Properties();
|
private Properties properties = new Properties();
|
||||||
public static long sleepThread = 100;
|
public static long sleepThread = 100;
|
||||||
|
private SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new Main().start();
|
new Main().start();
|
||||||
@@ -107,6 +113,9 @@ public class Main implements Runnable {
|
|||||||
else if (data.getTarif().equalsIgnoreCase("Базовый, 2 направ.")) {
|
else if (data.getTarif().equalsIgnoreCase("Базовый, 2 направ.")) {
|
||||||
tarif_Basic(astral, organization, data);
|
tarif_Basic(astral, organization, data);
|
||||||
}
|
}
|
||||||
|
else if (data.getTarif().equals("")) {
|
||||||
|
tarif_Empty(astral, organization, data);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
logger.info("Не задана логика для тарифа: \"{}\"", data.getTarif());
|
logger.info("Не задана логика для тарифа: \"{}\"", data.getTarif());
|
||||||
}
|
}
|
||||||
@@ -141,7 +150,7 @@ public class Main implements Runnable {
|
|||||||
// - либо один
|
// - либо один
|
||||||
// - либо соответствовать формуле "1 + доп.сертификаты"
|
// - либо соответствовать формуле "1 + доп.сертификаты"
|
||||||
JsonObject historyCert = astral.historyCert(product.id);
|
JsonObject historyCert = astral.historyCert(product.id);
|
||||||
int totalCert = historyCert.get("total").getAsInt();
|
int totalCert = historyCert.get("records").getAsInt();
|
||||||
if (totalCert > 1) {
|
if (totalCert > 1) {
|
||||||
if (totalCert != (1 + data.getAddonCert())) {
|
if (totalCert != (1 + data.getAddonCert())) {
|
||||||
logger.error("({}/{}): Ошибка количества сертификатов!", organization.inn, organization.kpp);
|
logger.error("({}/{}): Ошибка количества сертификатов!", organization.inn, organization.kpp);
|
||||||
@@ -267,6 +276,44 @@ public class Main implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Тариф: (пустое значение)
|
||||||
|
private void tarif_Empty(AstralSession astral, Organization organization, ExcelDataRow data) {
|
||||||
|
// Step 0: Количество доступных продуктов
|
||||||
|
if (organization.products.size() == 0) {
|
||||||
|
logger.warn("({}/{}): Нет доступных продуктов!", organization.inn, organization.kpp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step I: Проверяем
|
||||||
|
Product product = organization.products.get(0);
|
||||||
|
JsonObject historyCert = astral.historyCert(product.id);
|
||||||
|
int totalCert = historyCert.get("records").getAsInt();
|
||||||
|
if (totalCert < 1 + data.getAddonCert()) {
|
||||||
|
logger.warn("({}/{}): Странно... Сертификатов меньше чем надо", organization.inn, organization.kpp);
|
||||||
|
}
|
||||||
|
else if (totalCert > 1 + data.getAddonCert()) {
|
||||||
|
logger.error("({}/{}): Ошибка: сертификатов больше чем нужно!", organization.inn, organization.kpp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tarif tarif = product.contractTariffs.get(0);
|
||||||
|
JsonArray certArr = historyCert.get("rows").getAsJsonArray();
|
||||||
|
for (JsonElement element : certArr) {
|
||||||
|
JsonObject jsonObject = element.getAsJsonObject();
|
||||||
|
Date certDate;
|
||||||
|
try {
|
||||||
|
certDate = sdf.parse(jsonObject.get("cell").getAsJsonArray().get(1).getAsString());
|
||||||
|
} catch (ParseException e) {
|
||||||
|
logger.error("({}/{}): Ошибка при форматировании даты", organization.inn, organization.kpp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (certDate.before(tarif.date_initialDate)) {
|
||||||
|
logger.error("({}/{}): Ошибка: сертификат выдан раньше тарифа!", organization.inn, organization.kpp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean calcRecipients(Product product, ExcelDataRow data) {
|
private boolean calcRecipients(Product product, ExcelDataRow data) {
|
||||||
int countFNS = 0,
|
int countFNS = 0,
|
||||||
countFSS = 0,
|
countFSS = 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user