feat: 更新十一地市计算逻辑
This commit is contained in:
@@ -41,14 +41,14 @@ class DataNetwork(db.Model, Model, BaseModelMixin):
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def get_query(cls, year, month, name, spec, region="福州"):
|
||||
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
|
||||
query = query.filter(cls.date >= start_date)
|
||||
query = query.filter(cls.date < end_date)
|
||||
if name:
|
||||
query = query.filter(cls.name == name)
|
||||
query = query.filter(cls.name.like(f'%{name}%'))
|
||||
if spec:
|
||||
query = query.filter(cls.spec.like(f'%{spec}%'))
|
||||
if region:
|
||||
|
@@ -17,6 +17,7 @@ class FujianSurvey(db.Model):
|
||||
unit = Column('UNIT', String(128), comment='单位')
|
||||
brand = Column('BRAND', String(128), comment='品牌')
|
||||
tax = Column('TAX', Integer, comment='税率')
|
||||
region = Column('REGION', String(128), comment='地区')
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint(name, spec, date, name='Idx_key'),
|
||||
@@ -24,7 +25,7 @@ class FujianSurvey(db.Model):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_query(cls, year=None, month=None, name=None, spec=None, name_in=None):
|
||||
def get_query(cls, year=None, month=None, name=None, spec=None, name_in=None, region='福州'):
|
||||
query = cls.query
|
||||
if year and month:
|
||||
start_date = datetime.date(year, month, 1)
|
||||
@@ -37,4 +38,6 @@ class FujianSurvey(db.Model):
|
||||
query = query.filter(cls.name.in_(name_in))
|
||||
if spec:
|
||||
query = query.filter(cls.spec == spec)
|
||||
if region:
|
||||
query = query.filter(cls.region.like(f'%{region}%'))
|
||||
return query
|
||||
|
@@ -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
|
||||
|
@@ -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