[backend] feat: 添加用户和项目数据模型
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
# backend/src/models/__init__.py
|
||||
from .user import User
|
||||
from .project import Project
|
||||
|
||||
__all__ = ["User", "Project"]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,102 @@
|
||||
# backend/src/models/project.py
|
||||
from sqlalchemy import Column, Integer, String, Text, Date, Numeric, DateTime, Enum
|
||||
from sqlalchemy.sql import func
|
||||
from config.database import Base
|
||||
|
||||
|
||||
class Project(Base):
|
||||
__tablename__ = "projects"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, comment="项目ID")
|
||||
|
||||
# 基础信息
|
||||
project_no = Column(String(50), unique=True, nullable=False, comment="合同编号")
|
||||
power_contract_no = Column(String(100), comment="供电局项目合同编号")
|
||||
name = Column(String(200), nullable=False, comment="项目名称")
|
||||
subitem_count = Column(Integer, default=0, comment="子项个数")
|
||||
subitem_code = Column(String(50), comment="子项编码")
|
||||
total_investment = Column(Numeric(15, 2), comment="项目总投资(万元)")
|
||||
contract_amount = Column(Numeric(15, 2), comment="中标合同金额(万元)")
|
||||
warranty_ratio = Column(Numeric(5, 2), comment="质保金比例")
|
||||
settlement_amount = Column(Numeric(15, 2), comment="结算金额(万元)")
|
||||
total_cost_estimated = Column(Numeric(15, 2), comment="总成本测算")
|
||||
voltage_level = Column(String(50), comment="工程电压等级")
|
||||
engineering_type = Column(String(50), comment="工程类别")
|
||||
owner_unit = Column(String(200), comment="业主单位")
|
||||
owner_contact = Column(String(200), comment="业主联系人及电话")
|
||||
bidding_type = Column(String(50), comment="中标形式")
|
||||
signing_date = Column(Date, comment="签订日期")
|
||||
start_date = Column(Date, comment="开工日期")
|
||||
planned_end_date = Column(Date, comment="计划竣工日期")
|
||||
actual_end_date = Column(Date, comment="实际竣工日期")
|
||||
|
||||
# 质保信息
|
||||
warranty_amount = Column(Numeric(15, 2), default=0, comment="质保金(万元)")
|
||||
warranty_expiry_date = Column(Date, comment="质保期截止日")
|
||||
actual_warranty_refund_date = Column(Date, comment="实际退质保金日期")
|
||||
|
||||
# 项目信息
|
||||
project_department = Column(String(100), comment="所属项目部")
|
||||
project_leader = Column(String(200), comment="项目负责人及电话")
|
||||
payment_method = Column(Text, comment="工程款拨付方式")
|
||||
|
||||
# 成本控制
|
||||
total_cost_control = Column(Numeric(15, 2), comment="总体成本(控制)")
|
||||
is_adjusted = Column(Enum("是", "否"), default="否", comment="是否调整")
|
||||
labor_cost_control = Column(Numeric(15, 2), comment="人工成本(控制)")
|
||||
labor_cost_planned = Column(Numeric(15, 2), comment="农民工工资(计划)")
|
||||
labor_cost_paid = Column(Numeric(15, 2), comment="农民工工资(实付)")
|
||||
material_cost_control = Column(Numeric(15, 2), comment="乙供材料费(控制)")
|
||||
material_cost_payable = Column(Numeric(15, 2), comment="应付材料费")
|
||||
material_cost_actual = Column(Numeric(15, 2), comment="实际发生材料费")
|
||||
material_cost_paid = Column(Numeric(15, 2), comment="实际支付材料费")
|
||||
other_cost_control = Column(Numeric(15, 2), comment="其他费用(控制)")
|
||||
other_cost_payable = Column(Numeric(15, 2), comment="应付其他费")
|
||||
other_cost_actual = Column(Numeric(15, 2), comment="实际其他费用")
|
||||
|
||||
# 财务信息
|
||||
tax_amount = Column(Numeric(15, 2), comment="税金")
|
||||
profit = Column(Numeric(15, 2), comment="利润(万元)")
|
||||
actual_profit = Column(Numeric(15, 2), comment="实际利润(万元)")
|
||||
cost_settlement_amount = Column(Numeric(15, 2), comment="成本结算金额(万元)")
|
||||
cumulative_progress = Column(Numeric(5, 2), comment="累计进度")
|
||||
receivable_amount = Column(Numeric(15, 2), comment="应收款(完成进度款)")
|
||||
invoice_amount = Column(Numeric(15, 2), comment="开票金额(万元)")
|
||||
actual_receipt_amount = Column(Numeric(15, 2), comment="实际收款金额(万元)")
|
||||
receipt_completion_rate = Column(Numeric(5, 2), comment="实际收款完成率")
|
||||
payable_amount = Column(Numeric(15, 2), comment="应付款金额(万元)")
|
||||
actual_payment_amount = Column(Numeric(15, 2), comment="实际付款金额(万元)")
|
||||
unpaid_amount = Column(Numeric(15, 2), comment="未收款(万元)")
|
||||
payment_completion_rate = Column(Numeric(5, 2), comment="实际付款完成率")
|
||||
|
||||
# 民工工资
|
||||
labor_debt_amount = Column(Numeric(15, 2), comment="民工工资清欠金额(万元)")
|
||||
|
||||
# 结算信息
|
||||
settlement_cost_amount = Column(Numeric(15, 2), comment="结算后成本测算金额")
|
||||
settlement_labor_cost = Column(Numeric(15, 2), comment="结算人工费")
|
||||
settlement_material_cost = Column(Numeric(15, 2), comment="结算材料费")
|
||||
settlement_other_cost = Column(Numeric(15, 2), comment="结算其他费")
|
||||
|
||||
# 统计信息
|
||||
due_settlement_count = Column(Integer, comment="到期应结算项目个数")
|
||||
unsettlement_count = Column(Integer, comment="到期未完成结算个数")
|
||||
|
||||
# 其他
|
||||
problems = Column(Text, comment="存在的问题")
|
||||
suggestions = Column(Text, comment="建议措施")
|
||||
remarks = Column(Text, comment="备注")
|
||||
|
||||
# 系统字段
|
||||
created_by = Column(Integer, nullable=False, comment="创建人ID")
|
||||
created_at = Column(
|
||||
DateTime,
|
||||
server_default=func.now(),
|
||||
comment="创建时间",
|
||||
)
|
||||
updated_at = Column(
|
||||
DateTime,
|
||||
server_default=func.now(),
|
||||
onupdate=func.now(),
|
||||
comment="更新时间",
|
||||
)
|
||||
@@ -0,0 +1,29 @@
|
||||
# backend/src/models/user.py
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Enum
|
||||
from sqlalchemy.sql import func
|
||||
from config.database import Base
|
||||
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, comment="用户ID")
|
||||
username = Column(String(50), unique=True, nullable=False, comment="用户名")
|
||||
password_hash = Column(String(255), nullable=False, comment="密码哈希")
|
||||
real_name = Column(String(100), nullable=False, comment="真实姓名")
|
||||
department = Column(String(50), nullable=False, comment="部门")
|
||||
role = Column(Enum("admin", "market", "other"), nullable=False, comment="角色")
|
||||
email = Column(String(100), unique=True, comment="邮箱")
|
||||
phone = Column(String(20), comment="电话")
|
||||
is_active = Column(Boolean, default=True, comment="是否激活")
|
||||
created_at = Column(
|
||||
DateTime,
|
||||
server_default=func.now(),
|
||||
comment="创建时间",
|
||||
)
|
||||
updated_at = Column(
|
||||
DateTime,
|
||||
server_default=func.now(),
|
||||
onupdate=func.now(),
|
||||
comment="更新时间",
|
||||
)
|
||||
Reference in New Issue
Block a user