feat: 更新十一地市计算逻辑
This commit is contained in:
@@ -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,11 +51,9 @@ class Reber400Calculator(Calculator):
|
||||
return price, fluctuating
|
||||
|
||||
def _get_network_price(self):
|
||||
result = SteelRebar.get_items(self.year, self.month, 'HRB400E')
|
||||
price_dict = {spec: price for spec, material, price in result}
|
||||
price = 0.2 * float(price_dict.get('Φ12', 0)) + 0.2 * float(price_dict.get('Φ14', 0)) + \
|
||||
0.4 * float(price_dict.get('Φ18-22', 0)) + 0.2 * float(price_dict.get('Φ28-32', 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
|
||||
@@ -82,7 +81,7 @@ if __name__ == '__main__':
|
||||
from core.factory import ClientApp
|
||||
|
||||
with ClientApp().app_context():
|
||||
calculator = Reber400Calculator(year=2023, month=10)
|
||||
calculator = Reber400Calculator(year=2024, month=5)
|
||||
result = calculator.run()
|
||||
calculator.save()
|
||||
print(result)
|
||||
|
Reference in New Issue
Block a user