feat(pricing): Automated Monthly Jordan Fuel Pricing Service via Gemini AI and Cron Schedule
This commit is contained in:
@@ -6,6 +6,7 @@ import { RoadSpeedProfile } from './road-speed-profile.entity';
|
||||
import axios from 'axios';
|
||||
import { RoadSegmentStat } from './road-stat.entity';
|
||||
import { TrafficGridService } from './traffic-grid.service';
|
||||
import { FuelPricingService } from './fuel-pricing.service';
|
||||
import { GeocodingService } from '../geocoding/geocoding.service';
|
||||
import { RedisService } from '../common/redis.service';
|
||||
|
||||
@@ -18,6 +19,7 @@ export class MapsService {
|
||||
@InjectRepository(RoadSegmentStat)
|
||||
private roadStatRepo: Repository<RoadSegmentStat>,
|
||||
private trafficGrid: TrafficGridService,
|
||||
private fuelPricingService: FuelPricingService,
|
||||
private geocodingService: GeocodingService,
|
||||
private dataSource: DataSource,
|
||||
private redisService: RedisService,
|
||||
@@ -374,8 +376,9 @@ export class MapsService {
|
||||
// Net Gasoline Consumption
|
||||
const netGasolineLiters = Math.max(0.05, baseGasolineLiters + ascentFuelPenaltyLiters - descentFuelSavingLiters + trafficFuelLiters);
|
||||
|
||||
// Pricing in Jordan: Gasoline 90 ~ 0.920 JOD/L, Diesel ~ 0.720 JOD/L
|
||||
const fuelPricePerLiter = profile === 'truck' ? 0.720 : 0.920;
|
||||
// Pricing in Jordan (Live monthly pricing updated via FuelPricingService & Gemini AI)
|
||||
const livePrices = this.fuelPricingService.getPrices();
|
||||
const fuelPricePerLiter = profile === 'truck' ? livePrices.diesel : livePrices.gasoline90;
|
||||
const estimatedCostJOD = netGasolineLiters * fuelPricePerLiter;
|
||||
|
||||
// 5. EV Energy Model (Electric Vehicles):
|
||||
@@ -384,6 +387,7 @@ export class MapsService {
|
||||
const regenEvKWh = (totalDescentMeters / 100) * 0.26;
|
||||
const trafficEvKWh = delayHours * 1.5; // HVAC & auxiliary electronics in standstill
|
||||
const netEvKWh = Math.max(0.1, baseEvKWh + ascentEvKWh - regenEvKWh + trafficEvKWh);
|
||||
const estimatedEvCostJOD = netEvKWh * (livePrices.evKWh || 0.120);
|
||||
|
||||
// Carbon Footprint: 2,310g CO2 per liter of gasoline
|
||||
const co2Grams = Math.round(netGasolineLiters * 2310);
|
||||
@@ -445,13 +449,20 @@ export class MapsService {
|
||||
estimatedGasolineLiters: Math.round(netGasolineLiters * 100) / 100,
|
||||
estimatedCostJOD: Math.round(estimatedCostJOD * 100) / 100,
|
||||
estimatedEvKWh: Math.round(netEvKWh * 100) / 100,
|
||||
estimatedEvCostJOD: Math.round(estimatedEvCostJOD * 100) / 100,
|
||||
energyRecoveredEvKWh: Math.round(regenEvKWh * 100) / 100,
|
||||
co2Kg: Math.round((co2Grams / 1000) * 100) / 100,
|
||||
trafficDelayMinutes: Math.round(delayHours * 60),
|
||||
ecoScore,
|
||||
ecoBadge: ecoBadgeArabic,
|
||||
terrainDifficulty: terrainDifficultyArabic,
|
||||
mechanicalAdvice: mechanicalAdviceArabic
|
||||
mechanicalAdvice: mechanicalAdviceArabic,
|
||||
pricingBulletin: {
|
||||
gasoline90JOD: livePrices.gasoline90,
|
||||
dieselJOD: livePrices.diesel,
|
||||
effectiveMonth: livePrices.effectiveMonth,
|
||||
source: livePrices.source,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user