init
This commit is contained in:
34
web/commons/models/fuzhou_transportation_bureau.py
Normal file
34
web/commons/models/fuzhou_transportation_bureau.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import datetime
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from sqlalchemy import Column, Integer, String, Date, UniqueConstraint, Numeric
|
||||
|
||||
from core.extensions import db
|
||||
|
||||
|
||||
class FuzhouTransportationBureau(db.Model):
|
||||
__tablename__ = 'FUZHOU_TRANSPORTATION_BUREAU'
|
||||
id = Column('ID', Integer, primary_key=True)
|
||||
name = Column('NAME', String(128), default='', comment='名称')
|
||||
spec = Column('SPEC', String(128), default='', comment='规格')
|
||||
price = Column('PRICE', Numeric(16, 4), default=0, comment='价格')
|
||||
date = Column('DATE', Date, comment='日期')
|
||||
material_id = Column('MATERIAL_ID', String(128), comment='材料id')
|
||||
unit = Column('UNIT', String(128), comment='单位')
|
||||
brand = Column('BRAND', String(128), comment='品牌')
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint(name, spec, date, name='Idx_key'),
|
||||
{'comment': '福州交通局'},
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_query(cls, year, month, name):
|
||||
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)
|
||||
return query
|
Reference in New Issue
Block a user