feat: 更新十一地市计算逻辑
This commit is contained in:
@@ -16,14 +16,15 @@ class FuzhouTransportationBureau(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):
|
||||
def get_query(cls, year, month, name, region='福州'):
|
||||
start_date = datetime.date(year, month, 1)
|
||||
end_date = start_date + relativedelta(months=1)
|
||||
query = cls.query
|
||||
@@ -31,4 +32,6 @@ class FuzhouTransportationBureau(db.Model):
|
||||
query = query.filter(cls.date < end_date)
|
||||
if name:
|
||||
query = query.filter(cls.name == name)
|
||||
if region:
|
||||
query = query.filter(cls.region.like(f'%{region}%'))
|
||||
return query
|
||||
|
Reference in New Issue
Block a user