feat: 更新十一地市计算逻辑

This commit is contained in:
han0
2024-07-10 16:08:47 +08:00
parent 5afcfc4846
commit 967bb57136
19 changed files with 144 additions and 139 deletions

View File

@@ -16,14 +16,15 @@ class FuzhouHighwayBureau(db.Model):
material_id = Column('MATERIAL_ID', String(128), comment='材料id')
unit = Column('UNIT', String(128), comment='单位')
brand = Column('BRAND', String(128), comment='品牌')
region = Column('REGION', String(128), comment='地区')
__table_args__ = (
UniqueConstraint(name, spec, date, name='Idx_key'),
UniqueConstraint(name, spec, date, region, name='Idx_key'),
{'comment': '福州公路局'},
)
@classmethod
def get_query(cls, year, month, name, spec=None):
def get_query(cls, year, month, name, spec=None, region='福州'):
start_date = datetime.date(year, month, 1)
end_date = start_date + relativedelta(months=1)
query = cls.query
@@ -33,4 +34,6 @@ class FuzhouHighwayBureau(db.Model):
query = query.filter(cls.name == name)
if spec:
query = query.filter(cls.spec == spec)
if region:
query = query.filter(cls.region.like(f'%{region}%'))
return query