feat: 新增住建厅价格计算
This commit is contained in:
@@ -45,12 +45,19 @@ class Calculator:
|
||||
price_calculate = 0
|
||||
price_recommend = 0
|
||||
fluctuating_recommend = 0
|
||||
price_fujian = 0
|
||||
fluctuating_fujian = 0
|
||||
unit = ""
|
||||
spec = ''
|
||||
|
||||
_previous_prices = None
|
||||
_fluctuatings = []
|
||||
|
||||
def __init__(self, year, month, force=True):
|
||||
self.year = year
|
||||
self.month = month
|
||||
self.force = True # todo-2 已修改的的发布价不在覆盖计算
|
||||
|
||||
@property
|
||||
def previous_prices(self):
|
||||
if not self._previous_prices:
|
||||
@@ -78,6 +85,8 @@ class Calculator:
|
||||
'price_calculate': self.price_calculate,
|
||||
'price_recommend': self.price_recommend,
|
||||
'fluctuating_recommend': self.fluctuating_recommend,
|
||||
'price_fujian': self.price_fujian,
|
||||
'fluctuating_fujian': self.fluctuating_fujian,
|
||||
'unit': self.unit,
|
||||
'spec': self.spec,
|
||||
}
|
||||
@@ -91,6 +100,7 @@ class Calculator:
|
||||
self.price_last_month = self._get_last_month_price()
|
||||
self.price_calculate = self._get_calculate_price()
|
||||
self.price_recommend, self.fluctuating_recommend = self._get_recommend_price()
|
||||
self.price_fujian, self.fluctuating_fujian = self._get_fujian_price()
|
||||
return self
|
||||
|
||||
def _get_ftb_price(self):
|
||||
@@ -108,6 +118,9 @@ class Calculator:
|
||||
def _get_survey_price(self):
|
||||
return 0, 0
|
||||
|
||||
def _get_fujian_price(self):
|
||||
return 0, 0
|
||||
|
||||
def _get_last_month_price(self):
|
||||
return getattr(self.previous_prices, 'price_recommend', 0)
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_fujian import DataFujian
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.fuzhou_highway_bureau import FuzhouHighwayBureau
|
||||
@@ -13,10 +14,6 @@ class AsphaltDomesticCalculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='石油沥青', spec='国产')
|
||||
query = query.with_entities(func.avg(FuzhouTransportationBureau.price))
|
||||
@@ -49,6 +46,13 @@ class AsphaltDomesticCalculator(Calculator):
|
||||
fluctuating = int(self._get_fluctuating('price_survey', price))
|
||||
return price, fluctuating
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='石油沥青')
|
||||
data = query.first()
|
||||
price = data.price * 1000 if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self):
|
||||
self._fluctuatings = [self.fluctuating_network, self.fluctuating_survey]
|
||||
return super()._get_recommend_price()
|
||||
|
@@ -1,7 +1,4 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator, Helper
|
||||
from commons.models.asphalt_modifier import AsphaltModifier
|
||||
from calculators import Calculator
|
||||
|
||||
from commons.models.price_result import PriceResult
|
||||
|
||||
@@ -12,10 +9,6 @@ class AsphaltDomesticModifierCalculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_recommend_price(self):
|
||||
query = PriceResult.get_query(self.year, self.month, name='国产沥青')
|
||||
asphalt = query.first()
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_fujian import DataFujian
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.fuzhou_highway_bureau import FuzhouHighwayBureau
|
||||
@@ -14,10 +15,6 @@ class AsphaltImportedCalculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='石油沥青', spec='进口')
|
||||
query = query.with_entities(func.avg(FuzhouTransportationBureau.price))
|
||||
@@ -49,6 +46,13 @@ class AsphaltImportedCalculator(Calculator):
|
||||
fluctuating = int(self._get_fluctuating('price_survey', price))
|
||||
return price, fluctuating
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='石油沥青')
|
||||
data = query.first()
|
||||
price = data.price * 1000 if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self):
|
||||
self._fluctuatings = [self.fluctuating_network, self.fluctuating_survey]
|
||||
return super()._get_recommend_price()
|
||||
|
@@ -1,7 +1,4 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator, Helper
|
||||
from commons.models.asphalt_modifier import AsphaltModifier
|
||||
from calculators import Calculator
|
||||
|
||||
from commons.models.price_result import PriceResult
|
||||
|
||||
@@ -12,10 +9,6 @@ class AsphaltImportedModifierCalculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_recommend_price(self):
|
||||
query = PriceResult.get_query(self.year, self.month, name='进口沥青')
|
||||
asphalt = query.first()
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_fujian import DataFujian
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.fuzhou_highway_bureau import FuzhouHighwayBureau
|
||||
@@ -15,10 +16,6 @@ class Cement325Calculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='32.5级水泥')
|
||||
query = query.with_entities(func.avg(FuzhouTransportationBureau.price))
|
||||
@@ -54,6 +51,13 @@ class Cement325Calculator(Calculator):
|
||||
|
||||
return price, fluctuating
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='水泥', spec='32.5')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self, round_by=5):
|
||||
self._fluctuatings = [self.fluctuating_network, self.fluctuating_survey, self.fluctuating_fhb, self.fluctuating_ftb]
|
||||
return super()._get_recommend_price(round_by)
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_fujian import DataFujian
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.fuzhou_highway_bureau import FuzhouHighwayBureau
|
||||
@@ -15,10 +16,6 @@ class Cement425Calculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='42.5级水泥')
|
||||
data = query.first()
|
||||
@@ -59,6 +56,13 @@ class Cement425Calculator(Calculator):
|
||||
|
||||
return price, fluctuating
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='水泥', spec='42.5')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self, round_by=5):
|
||||
self._fluctuatings = [self.fluctuating_network, self.fluctuating_survey, self.fluctuating_fhb, self.fluctuating_ftb]
|
||||
return super()._get_recommend_price(round_by)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator, Helper
|
||||
from calculators import Calculator
|
||||
from commons.models.asphalt_modifier import AsphaltModifier
|
||||
|
||||
from commons.models.price_result import PriceResult
|
||||
@@ -12,10 +12,6 @@ class ModifierCalculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_recommend_price(self):
|
||||
query = AsphaltModifier.get_query(self.year, self.month)
|
||||
query = query.with_entities(func.avg(AsphaltModifier.price))
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import datetime
|
||||
|
||||
from calculators import Calculator, Helper
|
||||
from commons.models.data_fujian import DataFujian
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.fuzhou_highway_bureau import FuzhouHighwayBureau
|
||||
@@ -15,10 +16,6 @@ class Oil0Calculator(Calculator):
|
||||
unit = "kg"
|
||||
spec = "0#"
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_survey_price(self):
|
||||
query = FujianSurvey.get_query(self.year, self.month, name='柴油', spec='0#')
|
||||
data = query.first()
|
||||
@@ -36,6 +33,13 @@ class Oil0Calculator(Calculator):
|
||||
def _get_calculate_price(self, round_dit=2):
|
||||
return super()._get_calculate_price(round_dit)
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='柴油', spec='0#')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self):
|
||||
return self.price_network, self.fluctuating_network
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import datetime
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_fujian import DataFujian
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
|
||||
@@ -13,10 +14,6 @@ class Oil89Calculator(Calculator):
|
||||
unit = "kg"
|
||||
spec = "89#"
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_survey_price(self):
|
||||
query = FujianSurvey.get_query(self.year, self.month, name='汽油', spec='89#')
|
||||
data = query.first()
|
||||
@@ -31,6 +28,13 @@ class Oil89Calculator(Calculator):
|
||||
fluctuating = self._get_fluctuating('price_network', price)
|
||||
return round(price, 2), round(fluctuating, 2)
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='汽油', spec='89#')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_calculate_price(self, round_dit=2):
|
||||
return super()._get_calculate_price(round_dit)
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import datetime
|
||||
|
||||
from calculators import Calculator, Helper
|
||||
from commons.models.data_fujian import DataFujian
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.oil import Oil
|
||||
@@ -14,10 +15,6 @@ class Oil92Calculator(Calculator):
|
||||
unit = "kg"
|
||||
spec = "92#"
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_survey_price(self):
|
||||
query = FujianSurvey.get_query(self.year, self.month, name='汽油', spec='92#')
|
||||
data = query.first()
|
||||
@@ -32,6 +29,13 @@ class Oil92Calculator(Calculator):
|
||||
fluctuating = self._get_fluctuating('price_network', price)
|
||||
return round(price, 2), round(fluctuating, 2)
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='汽油', spec='92#')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_calculate_price(self, round_dit=2):
|
||||
return super()._get_calculate_price(round_dit)
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_fujian import DataFujian
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.fuzhou_highway_bureau import FuzhouHighwayBureau
|
||||
@@ -14,10 +15,6 @@ class SteelPlateCalculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='钢板')
|
||||
data = query.first()
|
||||
@@ -53,6 +50,13 @@ class SteelPlateCalculator(Calculator):
|
||||
fluctuating = int(self._get_fluctuating('price_survey', price))
|
||||
return price, fluctuating
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='钢板', spec='δ14-20')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self):
|
||||
self._fluctuatings = [self.fluctuating_network, self.fluctuating_survey, self.fluctuating_fhb, self.fluctuating_ftb]
|
||||
return super()._get_recommend_price()
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_fujian import DataFujian
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.fuzhou_highway_bureau import FuzhouHighwayBureau
|
||||
@@ -16,10 +17,6 @@ class Reber300Calculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='光圆钢筋')
|
||||
data = query.first()
|
||||
@@ -55,6 +52,13 @@ class Reber300Calculator(Calculator):
|
||||
fluctuating = int(self._get_fluctuating('price_survey', price))
|
||||
return price, fluctuating
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='圆钢筋', spec='HPB300Φ12')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self):
|
||||
self._fluctuatings = [self.fluctuating_network, self.fluctuating_survey, self.fluctuating_fhb, self.fluctuating_ftb, self.fluctuating_ss]
|
||||
return super()._get_recommend_price()
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_fujian import DataFujian
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.fuzhou_highway_bureau import FuzhouHighwayBureau
|
||||
@@ -16,10 +17,6 @@ class Reber400Calculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='带肋钢筋')
|
||||
data = query.first()
|
||||
@@ -55,6 +52,13 @@ class Reber400Calculator(Calculator):
|
||||
fluctuating = int(self._get_fluctuating('price_survey', price))
|
||||
return price, fluctuating
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='圆钢筋', spec='HRB400EΦ20')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self):
|
||||
self._fluctuatings = [self.fluctuating_network, self.fluctuating_survey, self.fluctuating_fhb, self.fluctuating_ftb, self.fluctuating_ss]
|
||||
return super()._get_recommend_price()
|
||||
|
@@ -1,12 +1,10 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_fujian import DataFujian
|
||||
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
|
||||
from commons.models.price_result import PriceResult
|
||||
from commons.models.steel_section import SteelSection
|
||||
|
||||
|
||||
class SteelSectionCalculator(Calculator):
|
||||
@@ -15,10 +13,6 @@ class SteelSectionCalculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='型钢')
|
||||
data = query.first()
|
||||
@@ -50,6 +44,13 @@ class SteelSectionCalculator(Calculator):
|
||||
fluctuating = int(self._get_fluctuating('price_survey', price))
|
||||
return price, fluctuating
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='型钢')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self):
|
||||
self._fluctuatings = [self.fluctuating_network, self.fluctuating_survey, self.fluctuating_fhb, self.fluctuating_ftb]
|
||||
return super()._get_recommend_price()
|
||||
|
@@ -1,12 +1,10 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from calculators import Calculator
|
||||
from commons.models.data_fujian import DataFujian
|
||||
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
|
||||
from commons.models.price_result import PriceResult
|
||||
from commons.models.steel_strand import SteelStrand
|
||||
|
||||
|
||||
class SteelStrandCalculator(Calculator):
|
||||
@@ -15,10 +13,6 @@ class SteelStrandCalculator(Calculator):
|
||||
unit = "t"
|
||||
spec = ""
|
||||
|
||||
def __init__(self, year, month):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_ftb_price(self):
|
||||
query = FuzhouTransportationBureau.get_query(self.year, self.month, name='钢绞线')
|
||||
data = query.first()
|
||||
@@ -50,6 +44,13 @@ class SteelStrandCalculator(Calculator):
|
||||
fluctuating = int(self._get_fluctuating('price_survey', price))
|
||||
return price, fluctuating
|
||||
|
||||
def _get_fujian_price(self):
|
||||
query = DataFujian.get_query(self.year, self.month, name='钢绞线')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_fujian', price)
|
||||
return price, fluctuating
|
||||
|
||||
def _get_recommend_price(self):
|
||||
self._fluctuatings = [self.fluctuating_network, self.fluctuating_survey, self.fluctuating_fhb, self.fluctuating_ftb]
|
||||
return super()._get_recommend_price()
|
||||
|
Reference in New Issue
Block a user