feat: 更新十一地市计算逻辑
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.fuzhou_highway_bureau import FuzhouHighwayBureau
|
||||
from commons.models.fuzhou_transportation_bureau import FuzhouTransportationBureau
|
||||
from commons.models.price_result import PriceResult
|
||||
from commons.models.steel_plate import SteelPlate
|
||||
|
||||
|
||||
class SteelPlateCalculator(Calculator):
|
||||
@@ -42,9 +42,11 @@ class SteelPlateCalculator(Calculator):
|
||||
return price, fluctuating
|
||||
|
||||
def _get_network_price(self):
|
||||
result = SteelPlate.get_items(self.year, self.month)
|
||||
prices = {spec: float(price) for spec, price in result}
|
||||
price = 0.2 * prices.get('12', 0) + 0.6 * prices.get('16-20', 0) + 0.2 * prices.get('22-28', 0)
|
||||
query = DataNetwork.get_query(self.year, self.month, name='钢板')
|
||||
data = query.all()
|
||||
prices = {item.spec.strip(): float(item.price) for item in data}
|
||||
|
||||
price = 0.2 * prices.get('12mm', 0) + 0.6 * prices.get('16-20mm', 0) + 0.2 * prices.get('22-28mm', 0)
|
||||
price = round(price)
|
||||
|
||||
fluctuating = price - getattr(self.previous_prices, 'price_network', price)
|
||||
@@ -73,7 +75,7 @@ if __name__ == '__main__':
|
||||
from core.factory import ClientApp
|
||||
|
||||
with ClientApp().app_context():
|
||||
calculator = SteelPlateCalculator(year=2023, month=11)
|
||||
calculator = SteelPlateCalculator(year=2024, month=5)
|
||||
result = calculator.run()
|
||||
calculator.save()
|
||||
print(result)
|
||||
|
Reference in New Issue
Block a user