feat: 更新十一地市计算逻辑
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.cement import Cement
|
||||
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
|
||||
@@ -44,11 +44,9 @@ class Cement425Calculator(Calculator):
|
||||
return price, fluctuating
|
||||
|
||||
def _get_network_price(self):
|
||||
result = Cement.get_items(self.year, self.month, spec_in=('台泥', '金牛', '炼石牌'), name_in=('P.O 42.5',), pack='散装')
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
prices = result[0][0]
|
||||
price = round(prices / 5) * 5
|
||||
query = DataNetwork.get_query(self.year, self.month, name='水泥', spec='42.5')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = price - int(getattr(self.previous_prices, 'price_network', price))
|
||||
return price, fluctuating
|
||||
|
||||
@@ -75,7 +73,7 @@ if __name__ == '__main__':
|
||||
from core.factory import ClientApp
|
||||
|
||||
with ClientApp().app_context():
|
||||
calculator = Cement425Calculator(year=2023, month=11)
|
||||
calculator = Cement425Calculator(year=2024, month=5)
|
||||
result = calculator.run()
|
||||
calculator.save()
|
||||
print(result)
|
||||
|
Reference in New Issue
Block a user