feat: 计算逻辑更新
This commit is contained in:
@@ -21,12 +21,9 @@ class SteelSectionCalculator(Calculator):
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='型钢')
|
||||
query = query.with_entities(func.avg(FuzhouTransportationBureau.price))
|
||||
result = query.all()
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
price = int(result[0][0])
|
||||
fluctuating = price - getattr(self.previous_prices, 'ftb_price', price)
|
||||
data = query.first()
|
||||
price = int(data.price) if data else 0
|
||||
fluctuating = int(self._get_fluctuating('price_ftb', price))
|
||||
return price, fluctuating
|
||||
|
||||
# def _get_ss_price(self):
|
||||
@@ -34,30 +31,23 @@ class SteelSectionCalculator(Calculator):
|
||||
|
||||
def _get_fhb_price(self):
|
||||
query = FuzhouHighwayBureau.get_query(self.year, self.month, name='型钢')
|
||||
query = query.with_entities(func.avg(FuzhouHighwayBureau.price))
|
||||
result = query.all()
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
price = int(result[0][0])
|
||||
fluctuating = price - getattr(self.previous_prices, 'ftb_price', price)
|
||||
data = query.first()
|
||||
price = int(data.price) if data else 0
|
||||
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='型钢')
|
||||
data = query.first()
|
||||
price = round(data.price) if data else 0
|
||||
|
||||
fluctuating = price - getattr(self.previous_prices, 'price_network', price)
|
||||
fluctuating = int(self._get_fluctuating('price_network', price))
|
||||
return price, fluctuating
|
||||
|
||||
def _get_survey_price(self):
|
||||
query = FujianSurvey.get_query(self.year, self.month, name='型钢')
|
||||
query = query.with_entities(func.avg(FujianSurvey.price))
|
||||
result = query.all()
|
||||
if not result[0][0]:
|
||||
return 0, 0
|
||||
price = int(result[0][0])
|
||||
fluctuating = price - getattr(self.previous_prices, 'price_survey', price)
|
||||
data = query.first()
|
||||
price = int(data.price) if data else 0
|
||||
fluctuating = int(self._get_fluctuating('price_survey', price))
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self):
|
||||
|
Reference in New Issue
Block a user