feat: 计算逻辑更新
This commit is contained in:
@@ -21,13 +21,10 @@ class Cement425Calculator(Calculator):
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='42.5级水泥')
|
||||
query = query.with_entities(func.avg(FuzhouTransportationBureau.price))
|
||||
result = query.all()
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = int(self._get_fluctuating('price_ftb', price))
|
||||
|
||||
price = int(result[0][0])
|
||||
fluctuating = price - int(getattr(self.previous_prices, 'ftb_price', price))
|
||||
return price, fluctuating
|
||||
|
||||
# def _get_ss_price(self):
|
||||
@@ -40,14 +37,15 @@ class Cement425Calculator(Calculator):
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
price = int(result[0][0])
|
||||
fluctuating = price - int(getattr(self.previous_prices, 'ftb_price', price))
|
||||
fluctuating = int(self._get_fluctuating('price_fhb', price))
|
||||
|
||||
return price, fluctuating
|
||||
|
||||
def _get_network_price(self):
|
||||
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))
|
||||
fluctuating = int(self._get_fluctuating('price_network', price))
|
||||
return price, fluctuating
|
||||
|
||||
def _get_survey_price(self):
|
||||
@@ -57,7 +55,8 @@ class Cement425Calculator(Calculator):
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
price = int(result[0][0])
|
||||
fluctuating = price - int(getattr(self.previous_prices, 'price_survey', price))
|
||||
fluctuating = int(self._get_fluctuating('price_survey', price))
|
||||
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self, round_by=5):
|
||||
|
||||
Reference in New Issue
Block a user