Пример #1
0
class WorkHour(db.Model):
    # 表的名字:
    __tablename__ = 't_work_record'
    # 表的结构:
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('t_user.id'))
    project_id = db.Column(db.Integer, db.ForeignKey('t_project.id'))
    worktime = db.Column(db.Float)
    date = db.Column(db.String(20))  #工时日期
    time = db.Column(db.String(20))  #提交日期
    status = db.Column(db.Integer, default=1)
Пример #2
0
class ItemTable(db.Model):
    # 表的名字:
    __tablename__ = 't_ic_item_header'
    # 表的结构:
    id = db.Column(db.Integer, primary_key=True)
    project_id = db.Column(db.String(20), db.ForeignKey('t_project.id'))
    file_name = db.Column(db.String(20))
    file_id = db.Column(db.String(20))
    item_num = db.Column(db.String(20), default='')
    version = db.Column(db.String(20))
    user_id = db.Column(db.Integer, db.ForeignKey('t_user.id'))
    auditing = db.Column(db.String(20), default='')
    proofreading = db.Column(db.String(20), default='')
    approval = db.Column(db.String(20), default='')
    signer = db.Column(db.String(20), default='')
    date = db.Column(db.String(20), default='')
Пример #3
0
class Project(db.Model):
    __tablename__ = 't_project'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20))
    status = db.Column(db.Integer, default=0)
    regtime = db.Column(db.String(20), default=timeUtils.getTime('%Y-%m-%d'))
    department_id = db.Column(db.Integer, db.ForeignKey('t_department.id'))
    super_user_id = db.Column(db.Integer, db.ForeignKey('t_user.id'))
    users = db.relationship('User', secondary=project_user_table)

    #work_hours = db.relationship('WorkHour', backref=db.backref('project', order_by=id))
    def get_work_hours(self, start_time, end_time):
        return WorkHour.query.filter(WorkHour.project_id == self.id,
                                     WorkHour.date >= start_time,
                                     WorkHour.date <= end_time,
                                     WorkHour.status == 1).all()

    def get_valid_users(self):
        return [u for u in self.users if u.status > -1]
Пример #4
0
class User(UserMixin, db.Model):
    # 表的名字:
    __tablename__ = 't_user'
    # 表的结构:
    id = db.Column(db.Integer, primary_key=True)
    user = db.Column(db.String(20))
    pw = db.Column(db.String(20))
    status = db.Column(db.Integer, default=0)
    regtime = db.Column(db.String(20),
                        default=timeUtils.getTime('%Y-%m-%d %H:%M:%S'))
    department_id = db.Column(db.Integer, db.ForeignKey('t_department.id'))
    company_id = db.Column(db.Integer, db.ForeignKey('t_company.id'))
    projects = db.relationship('Project', secondary=project_user_table)
    super_projects = db.relationship("Project",
                                     backref=db.backref('super_user',
                                                        order_by=id))
    work_hours = db.relationship('WorkHour',
                                 backref=db.backref('user', order_by=id),
                                 lazy='dynamic')
    boms = db.relationship("ItemTableView",
                           backref=db.backref('user', order_by=id))

    # 登录认证的回调,写在user model中
    def get_work_hours(self, project_id):
        return WorkHour.query.filter(WorkHour.user_id == self.id,
                                     WorkHour.project_id == project_id,
                                     WorkHour.status == 1).all()

    def get_work_hours(self, project_id, start_time, end_time):
        return WorkHour.query.filter(WorkHour.user_id == self.id,
                                     WorkHour.project_id == project_id,
                                     WorkHour.date >= start_time,
                                     WorkHour.date <= end_time,
                                     WorkHour.status == 1).all()

    def get_company(self):
        return Company.query.get(int(self.company_id))
Пример #5
0
class ItemDetail(db.Model):
    # 表的名字:
    __tablename__ = 't_item_detail'
    # 表的结构:
    id = db.Column(db.Integer, primary_key=True)
    index = db.Column(db.Integer)
    item_number = db.Column(db.String(20))
    name = db.Column(db.String(20), default='')
    model = db.Column(db.String(20))
    note = db.Column(db.String(20), default='')
    install_number = db.Column(db.String(20), default='')
    unit = db.Column(db.String(20), default='PCS')
    number = db.Column(db.Integer)
    remark = db.Column(db.String(20), default='')
    ic_item_header_id = db.Column(db.Integer, db.ForeignKey('v_item_table.id'))
Пример #6
0
class ItemTableView(db.Model):
    # 表的名字:
    __tablename__ = 'v_item_table'
    # 表的结构:
    id = db.Column(db.Integer, primary_key=True)
    project_id = db.Column(db.String(20))
    file_name = db.Column(db.String(20))
    file_id = db.Column(db.String(20))
    item_num = db.Column(db.String(20), default='')
    version = db.Column(db.String(20))
    user_id = db.Column(db.Integer, db.ForeignKey('t_user.id'))
    auditing = db.Column(db.String(20), default='')
    proofreading = db.Column(db.String(20), default='')
    approval = db.Column(db.String(20), default='')
    signer = db.Column(db.String(20), default='')
    date = db.Column(db.String(20), default='')
    user_name = db.Column(db.String(20))
    project_name = db.Column(db.String(20))
    items = db.relationship("ItemDetail",
                            backref=db.backref('itemTableView', order_by=id))
Пример #7
0
class Company(db.Model):
    # 表的名字:
    __tablename__ = 't_company'
    # 表的结构:
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20),unique=True)#unique=True唯一的
    status = db.Column(db.Integer,default=0)
    logo_file = db.Column(db.String(20), default="default.png")  # unique=True唯一的
    jindee_id = db.Column(db.Integer, db.ForeignKey('t_jindee.id'))
    departments = db.relationship("Department", backref=db.backref('company', order_by=id))
    def get_valid_departments(self):
        return Department.query.filter(Department.company_id == self.id,Department.status>-1).all()
    def get_user_number(self):
        departments = Department.query.filter(Department.company_id == self.id,Department.status>-1).all()
        sum = 0
        for d in departments:
            sum = sum + d.get_user_number()
        return sum
    def get_department_number(self):
        departments = self.get_valid_departments()
        return len(departments)
    def get_admins(self):
        from whmgsystem.model.user import User
        return User.query.filter(User.company_id==self.id,User.status==100).all()
Пример #8
0
class Department(db.Model):
    # 表的名字:
    __tablename__ = 't_department'
    # 表的结构:
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20))
    status = db.Column(db.Integer,default=0)
    regtime = db.Column(db.String(20),default=timeUtils.getTime('%Y-%m-%d'))
    company_id = db.Column(db.Integer,db.ForeignKey('t_company.id'))
    users = db.relationship("User", backref=db.backref('department', order_by=id))
    projects = db.relationship("Project", backref=db.backref('department', order_by=id))
    def get_valid_projects(self):
        return Project.query.filter(Project.department_id == self.id,Project.status>-1).all()
    def get_not_project_user(self,project):
        users = project.users
        lists = []
        for user in self.users:
            if user not in users and user.status>-1:
                lists.append(user)
        return lists
    def get_finish_projects(self):
        return Project.query.filter(Project.department_id == self.id, Project.status == -1).all()
    def get_user_number(self):
        return len(self.users)
Пример #9
0
from whmgsystem import db

project_user_table = db.Table(
    't_project_user', db.metadata,
    db.Column('user_id', db.Integer, db.ForeignKey('t_user.id')),
    db.Column('project_id', db.Integer, db.ForeignKey('t_project.id')))