feat: 计算逻辑更新

This commit is contained in:
han0
2024-07-11 16:01:15 +08:00
parent 635279eba0
commit fa029882a2
19 changed files with 187 additions and 201 deletions

View File

@@ -20,12 +20,9 @@ class SteelPlateCalculator(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 - int(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):
@@ -33,12 +30,9 @@ class SteelPlateCalculator(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 - int(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):
@@ -49,17 +43,14 @@ class SteelPlateCalculator(Calculator):
price = 0.2 * prices.get('12mm', 0) + 0.6 * prices.get('16-20mm', 0) + 0.2 * prices.get('22-28mm', 0)
price = round(price)
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):