feat: 变更计算方式

This commit is contained in:
han0
2024-12-09 17:26:32 +08:00
parent fa832e6fe5
commit 370a4861dd
9 changed files with 159 additions and 44 deletions

View File

@@ -35,7 +35,7 @@ class FuzhouHighwayBureau(db.Model, Model, BaseModelMixin):
return result
@classmethod
def get_query(cls, year, month, name, spec=None, region='福州'):
def get_query(cls, year, month, name=None, spec=None, region='福州', material_id=None):
start_date = datetime.date(year, month, 1)
end_date = start_date + relativedelta(months=1)
query = cls.query
@@ -45,6 +45,8 @@ class FuzhouHighwayBureau(db.Model, Model, BaseModelMixin):
query = query.filter(cls.name == name)
if spec:
query = query.filter(cls.spec == spec)
if material_id:
query = query.filter(cls.material_id == material_id)
if region:
query = query.filter(cls.region.like(f'%{region}%'))
return query