feat: 更新十一地市计算逻辑

This commit is contained in:
han0
2024-07-10 16:08:47 +08:00
parent 5afcfc4846
commit 967bb57136
19 changed files with 144 additions and 139 deletions

View File

@@ -1,6 +1,7 @@
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
@@ -42,10 +43,9 @@ class SteelSectionCalculator(Calculator):
return price, fluctuating
def _get_network_price(self):
result = SteelSection.get_items(self.year, self.month)
if not result[0][0]:
return 0, 0
price = round(result[0][0])
query = DataNetwork.get_query(self.year, self.month, name='型钢')
data = query.first()
price = round(data.price) if data else 0
fluctuating = price - getattr(self.previous_prices, 'price_network', price)
return price, fluctuating
@@ -73,7 +73,7 @@ if __name__ == '__main__':
from core.factory import ClientApp
with ClientApp().app_context():
calculator = SteelSectionCalculator(year=2023, month=11)
calculator = SteelSectionCalculator(year=2024, month=5)
result = calculator.run()
calculator.save()
print(result)