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
@@ -50,10 +51,9 @@ class Reber300Calculator(Calculator):
return price, fluctuating
def _get_network_price(self):
result = SteelRebar.get_items(self.year, self.month, 'HPB300')
price_dict = {spec: price for spec, material, price in result}
price = 0.3 * float(price_dict.get('Φ6', 0)) + 0.7 * float(price_dict.get('Φ8-10', 0))
price = round(price)
query = DataNetwork.get_query(self.year, self.month, name='光圆钢筋', spec='综合')
data = query.first()
price = round(data.price) if data else 0
fluctuating = price - getattr(self.previous_prices, 'price_network', price)
return price, fluctuating
@@ -81,7 +81,7 @@ if __name__ == '__main__':
from core.factory import ClientApp
with ClientApp().app_context():
calculator = Reber300Calculator(year=2023, month=10)
calculator = Reber300Calculator(year=2024, month=5)
result = calculator.run()
calculator.save()
print(result)