fix: 修复趋势表三明钢铁价格未正常显示的问题
This commit is contained in:
@@ -150,7 +150,7 @@ class Calculator:
|
|||||||
return price, fluctuating
|
return price, fluctuating
|
||||||
|
|
||||||
def _get_ss_price(self):
|
def _get_ss_price(self):
|
||||||
query = SanmingSteel.get_query(self.year, self.month, name='高线', spec='φ10mm')
|
query = SanmingSteel.get_query(self.year, self.month, material=self.material_id)
|
||||||
data = query.first()
|
data = query.first()
|
||||||
price = int(data.price) if data else 0
|
price = int(data.price) if data else 0
|
||||||
fluctuating = int(self._get_fluctuating('price_ss', price))
|
fluctuating = int(self._get_fluctuating('price_ss', price))
|
||||||
|
@@ -32,7 +32,7 @@ class SanmingSteel(db.Model, Model, BaseModelMixin):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_query(cls, year, month, name, spec):
|
def get_query(cls, year, month, name=None, spec=None, material=None):
|
||||||
start_date = datetime.date(year, month, 1)
|
start_date = datetime.date(year, month, 1)
|
||||||
end_date = start_date + relativedelta(months=1)
|
end_date = start_date + relativedelta(months=1)
|
||||||
query = cls.query
|
query = cls.query
|
||||||
@@ -42,4 +42,6 @@ class SanmingSteel(db.Model, Model, BaseModelMixin):
|
|||||||
query = query.filter(cls.name == name)
|
query = query.filter(cls.name == name)
|
||||||
if spec:
|
if spec:
|
||||||
query = query.filter(cls.spec == spec)
|
query = query.filter(cls.spec == spec)
|
||||||
|
if material:
|
||||||
|
query = query.filter(cls.material == material)
|
||||||
return query
|
return query
|
||||||
|
Reference in New Issue
Block a user