Exemplo n.º 1
0
class InspectTechAssess(db.Model):
    # 技术细节自评
    __tablename__ = "inspect_tech_assess"
    id = db.Column(db.Integer,
                   primary_key=True,
                   nullable=False,
                   autoincrement=True)
    system_id = db.Column(db.Integer,
                          db.ForeignKey(InspectSystems.__tablename__ + '.id'))
    tech_assess_system = db.relationship('InspectSystems')
    tech_demand_id = db.Column(
        db.Integer, db.ForeignKey(InspectTechDemands.__tablename__ + '.id'))
    tech_demand = db.relationship('InspectTechDemands')
    tech_demand_check = db.Column(db.Boolean, default=False)

    def __init__(self, system_id, tech_demand_id, tech_demand_check=False):

        self.system_id = system_id
        self.tech_demand_id = tech_demand_id
        self.tech_demand_check = tech_demand_check

    def _to_dict(self):
        # tech_assess = {
        #     self.tech_demand.tech_type.tech_classify.name: {
        #         self.tech_demand.tech_type.name: {
        #             self.tech_demand.name: self.tech_demand_check
        #         }
        #     }
        # }
        # tech_assess_dict = {
        #     "system_id": self.system_id,
        #     "tech_assess": tech_assess
        # }
        return {self.tech_demand.name: self.tech_demand_check}
Exemplo n.º 2
0
class InspectSystemsAssess(db.Model):
    #  等级自评表
    __tablename__ = 'inspect_system_assess'
    id = db.Column(db.Integer,
                   primary_key=True,
                   nullable=False,
                   autoincrement=True)
    system_id = db.Column(db.Integer,
                          db.ForeignKey(InspectSystems.__tablename__ + '.id'))
    assess_system = db.relationship('InspectSystems')
    assess_type_id = db.Column(
        db.Integer, db.ForeignKey(InspectAssessType.__tablename__ + '.id'))
    assess_type = db.relationship('InspectAssessType')
    object_injure_level_id = db.Column(
        db.Integer,
        db.ForeignKey(InspectObjectInjureLevel.__tablename__ + '.id'))
    object_injure_level = db.relationship('InspectObjectInjureLevel')
    assess_check = db.Column(db.Boolean, default=False)

    def __init__(self, system_id, assess_type_id, object_injure_level_id,
                 assess_check):
        self.system_id = system_id
        self.assess_type_id = assess_type_id
        self.object_injure_level_id = object_injure_level_id
        self.assess_check = assess_check

    def _to_dict(self):
        return {
            'assess_type': self.assess_type.name,
            self.object_injure_level.name: self.assess_check
        }
Exemplo n.º 3
0
class InspectObjectLevelRela(db.Model):
    __tablename__ = "inspect_object_level_rela"
    id = db.Column(db.Integer,
                   primary_key=True,
                   nullable=False,
                   autoincrement=True)
    object_id = db.Column(db.Integer,
                          db.ForeignKey(InspectObject.__tablename__ + '.id'))
    inspect_object = db.relationship('InspectObject')
    injure_level_id = db.Column(
        db.Integer, db.ForeignKey(InspectInjureLevel.__tablename__ + '.id'))
    injure_level = db.relationship('InspectInjureLevel')
    name = db.Column(db.String(50), nullable=True)
    level = db.Column(db.Integer, nullable=True)
    describe = db.Column(db.String(250), nullable=True)

    def __init__(self, object_id, injure_level_id, name, level, describe=None):
        self.object_id = object_id
        self.injure_level_id = injure_level_id
        self.name = name
        self.level = level
        self.describe = describe

    def _to_dict(self):
        return {
            'object_name': self.inspect_object.name,
            'level_name': self.injure_level.name
        }

    @staticmethod
    def _get_id(object_id, level_id):
        object_level_rela = db.session.query(InspectObjectLevelRela).filter\
            (InspectObjectLevelRela.object_id == object_id, InspectObjectLevelRela.injure_level_id == level_id).first()
        return object_level_rela.id
Exemplo n.º 4
0
class InspectTechDemands(db.Model):
    # 技术细节自评细则要求(name, level)唯一
    __tablename__ = "inspect_tech_demands"
    id = db.Column(db.Integer,
                   primary_key=True,
                   nullable=False,
                   autoincrement=True)
    name = db.Column(db.String(250), nullable=False)
    level = db.Column(db.Integer, nullable=False)  # level: 1-5
    tech_type_id = db.Column(
        db.Integer, db.ForeignKey(InspectTechTypes.__tablename__ + '.id'))
    tech_type = db.relationship('InspectTechTypes')
    describe = db.Column(db.String(250), nullable=True)

    def __init__(self, name, level, tech_type_id, describe=None):
        self.name = name
        self.level = level
        self.tech_type_id = tech_type_id
        self.describe = describe

    @staticmethod
    def gen_tech_demands_assess(system_level):
        tech_assess = {}
        for tech_demand in db.session.query(InspectTechDemands).filter(
                InspectTechDemands.level == system_level).all():
            classify_name = tech_demand.tech_type.tech_classify.name
            tech_type_name = tech_demand.tech_type.name
            if not tech_assess.get(classify_name):
                tech_assess[classify_name] = {}
            if not tech_assess[classify_name].get(tech_type_name):
                tech_assess[classify_name][tech_type_name] = {}
            tech_assess[classify_name][tech_type_name][
                tech_demand.name] = False
        return tech_assess
Exemplo n.º 5
0
class InspectTechTypes(db.Model):
    # 技术细节自评类型
    __tablename__ = "inspect_tech_types"
    id = db.Column(db.Integer,
                   primary_key=True,
                   nullable=False,
                   autoincrement=True)
    name = db.Column(db.String(250), nullable=False)
    tech_classify_id = db.Column(
        db.Integer, db.ForeignKey(InspectTechClassify.__tablename__ + '.id'))
    tech_classify = db.relationship('InspectTechClassify')
    describe = db.Column(db.String(250), nullable=True)

    def __init__(self, name, tech_classify_id, describe=None):
        self.name = name
        self.tech_classify_id = tech_classify_id
        self.describe = describe