0

Группа компаний

This commit is contained in:
2016-05-28 22:01:24 +03:00
parent 18d76c2e79
commit 3ac5172c7b
6 changed files with 96 additions and 11 deletions

View File

@@ -6,20 +6,25 @@ package ru.dmitriymx.astralcheckreport;
class ExcelDataRow { class ExcelDataRow {
String inn, kpp, tarif; String inn, kpp, tarif;
int addonCert; int addonNaprov, fsrar, addonCert, egrul, addonKpp, tranzaks;
ExcelDataRow(String inn, String kpp, String tarif, int addonCert) { ExcelDataRow(String inn, String kpp, String tarif,
int addonNaprov, int fsrar, int addonCert, int egrul, int addonKpp, int tranzaks) {
this.inn = inn; this.inn = inn;
this.kpp = kpp; this.kpp = kpp;
this.tarif = tarif; this.tarif = tarif;
this.addonNaprov = addonNaprov;
this.fsrar = fsrar;
this.addonCert = addonCert; this.addonCert = addonCert;
this.egrul = egrul;
this.addonKpp = addonKpp;
this.tranzaks = tranzaks;
} }
@Override @Override
public String toString() { public String toString() {
return "{inn: \"" + inn + return "{inn: \"" + inn +
"\", kpp:\"" + kpp + "\", kpp:\"" + kpp +
"\", tarif:\"" + tarif + "\", tarif:\"" + tarif + "\"}";
"\", addonCert:\"" + addonCert + "\"}";
} }
} }

View File

@@ -28,14 +28,29 @@ class ExcelReader {
Cell cellKpp = row.getCell(3); Cell cellKpp = row.getCell(3);
cellKpp.setCellType(Cell.CELL_TYPE_STRING); cellKpp.setCellType(Cell.CELL_TYPE_STRING);
Cell cellTarif = row.getCell(6); Cell cellTarif = row.getCell(6);
Cell cellAddonNaprov = row.getCell(9);
cellAddonNaprov.setCellType(Cell.CELL_TYPE_NUMERIC);
Cell cellFsrar = row.getCell(10);
cellFsrar.setCellType(Cell.CELL_TYPE_NUMERIC);
Cell cellAddonCert = row.getCell(11); Cell cellAddonCert = row.getCell(11);
cellAddonCert.setCellType(Cell.CELL_TYPE_NUMERIC); cellAddonCert.setCellType(Cell.CELL_TYPE_NUMERIC);
Cell cellEgrul = row.getCell(12);
cellEgrul.setCellType(Cell.CELL_TYPE_NUMERIC);
Cell cellAddonKpp = row.getCell(13);
cellAddonKpp.setCellType(Cell.CELL_TYPE_NUMERIC);
Cell cellTranzaks = row.getCell(14);
cellTranzaks.setCellType(Cell.CELL_TYPE_NUMERIC);
return new ExcelDataRow( return new ExcelDataRow(
cellInn.getStringCellValue(), cellInn.getStringCellValue(),
cellKpp.getStringCellValue(), cellKpp.getStringCellValue(),
cellTarif.getStringCellValue(), cellTarif.getStringCellValue(),
(int)cellAddonCert.getNumericCellValue() (int)cellAddonNaprov.getNumericCellValue(),
(int)cellFsrar.getNumericCellValue(),
(int)cellAddonCert.getNumericCellValue(),
(int)cellEgrul.getNumericCellValue(),
(int)cellAddonKpp.getNumericCellValue(),
(int)cellTranzaks.getNumericCellValue()
); );
} }
} }

View File

@@ -8,14 +8,12 @@ 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;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import ru.dmitriymx.astralcheckreport.objects.Cert; import ru.dmitriymx.astralcheckreport.objects.*;
import ru.dmitriymx.astralcheckreport.objects.Organization;
import ru.dmitriymx.astralcheckreport.objects.Product;
import ru.dmitriymx.astralcheckreport.objects.Tarif;
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.util.List;
import java.util.Properties; import java.util.Properties;
public class Main implements Runnable { public class Main implements Runnable {
@@ -190,7 +188,47 @@ public class Main implements Runnable {
if (certDateLong < tarifDateLong) { if (certDateLong < tarifDateLong) {
logger.error("({}/{}): Ошибка: сертификат выдан раньше тарифа!", organization.inn, organization.kpp); logger.error("({}/{}): Ошибка: сертификат выдан раньше тарифа!", organization.inn, organization.kpp);
// return; return;
} }
// Step III: Проверяем кол-во Направлений
if (!calcRecipients(product, data)) { //TODO надо проверять по категориям
logger.warn("({}/{}): Внимание! Не соответствие количества направлений!", organization.inn, organization.kpp);
}
}
private boolean calcRecipients(Product product, ExcelDataRow data) {
int countFNS = 0,
countFSS = 0,
countRosstat = 0,
countPFR = 0,
countRosalco = 0,
countRPN = 0;
for (Recipient recipient : product.recipients) {
switch (recipient.protocolId) {
case 12:
case 10: break;
case 6:
case 13:
countFNS += recipient.kpp.size();
break;
case 5: countFSS++; break;
case 4: countRosstat++; break;
case 2: countPFR++; break;
case 9: countRosalco++; break;
case 15: countRPN++; break;
default: logger.warn("Не известный тип Направления: {}/{}/{}", recipient.protocolId, recipient.code, recipient.name);
}
}
boolean boolFNS = (countFNS == 0 || countFNS == 1 + data.addonKpp);
boolean boolFSS = (countFSS == 0 || countFSS == 1);
boolean boolRosstat = (countRosstat == 0 || countRosstat == 1);
boolean boolPFR = (countPFR == 0 || countPFR == 1);
boolean boolRosalco = (countRosalco == 0 || countRosalco == 1);
boolean boolRPN = (countRPN == 0 || countRPN == 1);
return boolFNS && boolFSS && boolRosstat && boolPFR && boolRosalco && boolRPN;
} }
} }

View File

@@ -31,7 +31,11 @@ public class OrganizationDeserialize implements JsonDeserializer<Organization> {
if (!jsonObject.get("name").getAsString().equals("Астрал Отчет")) { if (!jsonObject.get("name").getAsString().equals("Астрал Отчет")) {
continue; continue;
} }
if (!jsonObject.get("statusName").getAsString().equals("Зарегистрировано")) { String statusName = jsonObject.get("statusName").getAsString();
if (statusName.equals("Отключено")) {
logger.trace("({}/{}): статус \"Отключено\" проигнорирован", organization.inn, organization.kpp);
continue;
} else if (!statusName.equals("Зарегистрировано")) {
logger.warn("({}/{}): не известный статус: \"{}\"", organization.inn, organization.kpp, jsonObject.get("statusName").getAsString()); logger.warn("({}/{}): не известный статус: \"{}\"", organization.inn, organization.kpp, jsonObject.get("statusName").getAsString());
continue; continue;
} }

View File

@@ -14,4 +14,5 @@ public class Product {
public List<Tarif> contractTariffs; public List<Tarif> contractTariffs;
@SerializedName("people") @SerializedName("people")
public List<Cert> certs; public List<Cert> certs;
public List<Recipient> recipients;
} }

View File

@@ -0,0 +1,22 @@
/*
* DmitriyMX <mail@dmitriymx.ru>
* 2016-05-28
*/
package ru.dmitriymx.astralcheckreport.objects;
import java.util.List;
public class Recipient {
// 13 - ФНС
// 5 - ФСС
// 4 - Росстат
// 2 - ПФР
// 9 - Росалкогольрегульрование
// 15 - РПН
// 12 - ПФР макеты
// 10 - ЭДО ФНС
// 6 - ИФНС
public int protocolId;
public String name, code;
public List<String> kpp;
}