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
|
||||
@@ -22,40 +22,40 @@ class Cement325Calculator(Calculator):
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='32.5级水泥')
|
||||
query = query.with_entities(func.avg(FuzhouTransportationBureau.price))
|
||||
result = query.all()
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
price = int(result[0][0])
|
||||
data = query.first()
|
||||
price = int(data[0]) if data[0] else 0
|
||||
|
||||
fluctuating = price - int(getattr(self.previous_prices, 'ftb_price', price))
|
||||
|
||||
return price, fluctuating
|
||||
|
||||
def _get_fhb_price(self):
|
||||
query = FuzhouHighwayBureau.get_query(self.year, self.month, name='32.5级水泥', spec='旋窑(散装)')
|
||||
query = query.with_entities(func.avg(FuzhouHighwayBureau.price))
|
||||
result = query.all()
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
price = int(result[0][0])
|
||||
data = query.first()
|
||||
price = int(data[0]) if data[0] else 0
|
||||
|
||||
fluctuating = price - int(getattr(self.previous_prices, 'ftb_price', price))
|
||||
|
||||
return price, fluctuating
|
||||
|
||||
def _get_network_price(self):
|
||||
result = Cement.get_items(self.year, self.month, spec_in=('台泥', '金牛', '炼石牌'), name_in=('P.S.A32.5', 'M32.5', 'P.P 32.5R'), pack='散装')
|
||||
prices = result[0][0]
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
price = round(prices / 5) * 5
|
||||
query = DataNetwork.get_query(self.year, self.month, name='水泥', spec='32.5')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
|
||||
fluctuating = price - int(getattr(self.previous_prices, 'price_network', price))
|
||||
|
||||
return price, fluctuating
|
||||
|
||||
def _get_survey_price(self):
|
||||
query = FujianSurvey.get_query(self.year, self.month, name='32.5级水泥', spec='旋窑')
|
||||
query = query.with_entities(func.avg(FujianSurvey.price))
|
||||
result = query.all()
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
price = int(result[0][0])
|
||||
data = query.first()
|
||||
price = int(data[0]) if data[0] else 0
|
||||
|
||||
fluctuating = price - int(getattr(self.previous_prices, 'price_survey', price))
|
||||
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self, round_by=5):
|
||||
|
Reference in New Issue
Block a user