use of fr.guiguilechat.jcelechat.jcesi.disconnected.modeled.ESIAccess in project JCELechat by guiguilechat.
the class VolumicPrice method main.
public static void main(String[] args) {
int parrallelism = Runtime.getRuntime().availableProcessors() * 1000;
System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "" + parrallelism);
ESIAccess esi = ESIAccess.INSTANCE;
RegionalMarket market = esi.markets.getMarket(10000002);
Set<String> createdItems = IntStream.of(esi.universe.cache().categories(9).get().groups).parallel().mapToObj(gi -> esi.universe.cache().groups(gi).get()).flatMap(group -> IntStream.of(group.types).parallel().mapToObj(i -> esi.universe.cache().types(i).get())).filter(type -> type.published && type.market_group_id != 0).map(type -> type.name.replace(" Blueprint", "")).collect(Collectors.toSet());
System.err.println("created items set generated " + createdItems.size());
List<TypeData> list = esi.universe.cache().categories().get().parallelStream().map(catid -> esi.universe.cache().categories(catid).get()).filter(cat -> cat.published).flatMap(cat -> IntStream.of(cat.groups).parallel().mapToObj(i -> esi.universe.cache().groups(i).get())).filter(group -> group.published).flatMap(group -> IntStream.of(group.types).parallel().mapToObj(i -> esi.universe.cache().types(i).get())).filter(type -> createdItems.contains(type.name)).peek(type -> System.err.println("type " + type.name + " is created")).map(t -> new TypeData(t, market)).collect(Collectors.toList());
System.err.println("types fetched, sorting");
Collections.sort(list, (t1, t2) -> Double.compare(t1.volPrice.get(), t2.volPrice.get()));
for (TypeData data : list) {
System.out.println(data.type.name + "\t" + data.volPrice.get());
}
}
use of fr.guiguilechat.jcelechat.jcesi.disconnected.modeled.ESIAccess in project JCELechat by guiguilechat.
the class MarketsMain method main.
public static void main(String[] args) throws InterruptedException {
int region = 10000002;
ESIAccess acc = ESIAccess.INSTANCE;
RegionalMarket market = acc.markets.getMarket(region);
// 25591 is contaminated lorentz fluid.
System.err.println("SO for " + 3200 + " of item " + 25591 + " is " + market.getSO(25591, 3200).get());
System.err.println("BO for " + 3200 + " of item " + 25591 + " is " + market.getBO(25591, 3200).get());
System.err.println("best volumes desc" + market.getHistory(25591).quarterly.getSortedVolumes().get());
System.err.println("best vol offset 0% : " + market.getHistory(25591).quarterly.getBestVolume(0).get());
System.err.println("best vol offset 2% : " + market.getHistory(25591).quarterly.getBestVolume(2).get());
while (true) {
Thread.sleep(1000);
}
}
use of fr.guiguilechat.jcelechat.jcesi.disconnected.modeled.ESIAccess in project JCELechat by guiguilechat.
the class NPCsTranslater method translate.
private static void translate(LinkedHashMap<Integer, Eagents> eagents, LinkedHashMap<String, Agent> agents, LinkedHashMap<String, Corporation> corporations, LinkedHashMap<Integer, LPOffer> offers) {
ESIAccess esi = ESIAccess.INSTANCE;
CacheStatic cache = ESIStatic.INSTANCE.cache();
// prefetch
MapHolder<Integer, R_get_corporations_corporation_id> corporationsHolder = ((ListHolder<Integer>) cache.corporations.npccorps().follow(l -> {
l.parallelStream().forEach(cache.corporations::get);
})).toMap(i -> i, i -> cache.corporations.get(i).get());
MapHolder<Integer, R_get_universe_factions> factionsHolder = cache.universe.factions().toMap(f -> f.faction_id);
eagents.values().parallelStream().map(ag -> ag.locationID).distinct().forEach(lid -> Location.resolve(null, lid).system());
//
LinkedHashMap<Integer, EnpcCorporations> ecorps = EnpcCorporations.load();
Map<Integer, String> idx2name = EinvNames.loadById();
Map<Integer, R_get_corporations_corporation_id> npcCorps = corporationsHolder.get();
Map<Integer, R_get_universe_factions> factionById = factionsHolder.get();
Map<Integer, Location> agentsLocation = eagents.entrySet().parallelStream().collect(Collectors.toMap(eag -> eag.getKey(), eag -> Location.resolve(null, eag.getValue().locationID)));
logger.info("NPC prefetch received");
for (Entry<Integer, Eagents> eagt : eagents.entrySet()) {
Agent agent = new Agent();
Eagents agt = eagt.getValue();
agent.id = eagt.getKey();
agent.corporation = ecorps.get(agt.corporationID).enName();
agent.name = idx2name.get(agent.id);
agent.isLocator = agt.isLocator;
agent.level = agt.level;
agent.type = AGENT_TYPE.of(agt.agentTypeID);
if (agent.type == null) {
logger.warn("no type for agent " + agent.name + " typeID=" + agt.agentTypeID);
}
agent.division = AGENT_DIVISION.of(agt.divisionID);
if (agent.division == null) {
logger.warn("no division for agent " + agent.name + " divisionID=" + agt.divisionID);
}
Location loc = agentsLocation.get(agent.id);
if (loc != null) {
agent.system = loc.system().name;
R_get_universe_stations_station_id station = loc.station();
if (station != null) {
agent.station = station.name;
agent.stationId = agt.locationID;
}
agents.put(agent.name, agent);
} else {
logger.warn("invalid location for agent " + agent.name + " locid=" + agt.locationID);
}
}
logger.info("translated agents data");
for (Entry<Integer, EnpcCorporations> e : ecorps.entrySet()) {
Corporation add = new Corporation();
add.id = e.getKey();
EnpcCorporations snpc = e.getValue();
add.name = snpc.enName();
R_get_universe_factions faction = factionById.get(snpc.factionID);
if (faction == null) {
logger.debug("can't find faction from id " + snpc.factionID + " for corporation " + add.name);
} else {
add.faction = faction.name;
}
R_get_corporations_corporation_id esicorp = npcCorps.get(add.id);
if (esicorp != null && esicorp.faction_id != 0) {
add.warfare = factionById.get(esicorp.faction_id).name;
}
add.concordRate = EnpcCorporations.concordRates().getOrDefault(add.id, 0.0);
if (add.id == EnpcCorporations.CONCORD_ID) {
add.concordRate = 1.0;
}
corporations.put(add.name, add);
}
Map<Integer, LPOffer> covertedOffers = corporations.values().stream().parallel().flatMap(c -> {
Requested<R_get_loyalty_stores_corporation_id_offers[]> req = esi.connection.get_loyalty_stores_offers(c.id, null);
return req.isOk() ? Stream.of(req.getOK()) : Stream.empty();
}).map(offer -> makeOffer(offer)).filter(o -> o != null).collect(Collectors.toMap(off -> off.id, off -> off, (o1, o2) -> o1));
offers.putAll(covertedOffers);
corporations.values().stream().parallel().forEach(c -> loadCorpOffers(c, esi.connection, offers));
}
Aggregations