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

@@ -41,12 +41,14 @@ class DataNetwork(db.Model, Model, BaseModelMixin):
return result
@classmethod
def get_query(cls, year, month, name=None, 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
query = query.filter(cls.date >= start_date)
query = query.filter(cls.date < end_date)
if material_id:
query = query.filter(cls.material_id == material_id)
if name:
query = query.filter(cls.name.like(f'%{name}%'))
if spec: