Archived
0

fix stock and demand import

This commit is contained in:
Mo
2016-10-29 23:07:35 +03:00
parent 8d56de52a9
commit 7273c45771

View File

@@ -67,18 +67,25 @@ public class EDDNItemData extends ItemDataBase {
@Override @Override
public long getSupply() { public long getSupply() {
JsonNode n; JsonNode n;
JsonNode ln;
switch (version) { switch (version) {
case V1: case V1:
n = node.get("stationStock"); n = node.get("stationStock");
ln = node.get("supplyLevel");
break; break;
case V2: case V2:
n = node.get("supply"); n = node.get("supply");
ln = node.get("supplyLevel");
break; break;
default: default:
n = node.get("stock"); n = node.get("stock");
ln = node.get("stockBracket");
break; break;
} }
if (n != null && n.isNumber()){ if (n != null && n.isNumber()){
if (ln == null || ln.isNumber() && ln.asInt() == 0 || ln.asText().isEmpty()){
return 0;
}
return n.asLong(); return n.asLong();
} else { } else {
throw new ImportDataError("EDDN message don't have commodity supply"); throw new ImportDataError("EDDN message don't have commodity supply");
@@ -88,7 +95,20 @@ public class EDDNItemData extends ItemDataBase {
@Override @Override
public long getDemand() { public long getDemand() {
JsonNode n = node.get("demand"); JsonNode n = node.get("demand");
JsonNode ln;
switch (version) {
case V1:
case V2:
ln = node.get("demandLevel");
break;
default:
ln = node.get("demandBracket");
break;
}
if (n != null && n.isNumber()){ if (n != null && n.isNumber()){
if (ln == null || ln.isNumber() && ln.asInt() == 0 || ln.asText().isEmpty()){
return 0;
}
return n.asLong(); return n.asLong();
} else { } else {
throw new ImportDataError("EDDN message don't have commodity demand"); throw new ImportDataError("EDDN message don't have commodity demand");