数据库表模型流程图
erDiagram
companies ||--o{ purchase_plans : "往来单位"
companies ||--o{ inbound_outbound : "往来单位"
companies ||--o{ weighing_slips : "供货/收货单位"
cargos ||--o{ purchase_plans : "产品"
cargos ||--o{ inbound_outbound : "产品"
cargos ||--o{ weighing_slips : "货物名称"
purchase_plans ||--o{ inbound_outbound : "1对多"
inbound_outbound ||--o{ weighing_slips : "1对多"
users ||--o{ purchase_plans : "创建"
users ||--o{ inbound_outbound : "创建"
users ||--o{ weighing_slips : "创建"
companies {
int id PK
string name UK
int is_deleted
string created_at
}
cargos {
int id PK
string name UK
int is_deleted
string created_at
}
purchase_plans {
int id PK
string plan_no "计划号(SX-YYYYMMDDMMHHSS001)"
string start_date "开始时间"
string end_date "结束时间"
string business_type "业务类型"
string product "产品"
double planned_quantity "计划量(t)"
double executed_quantity "已执行量(kg)"
string execution_status "状态"
string customer_name "往来单位"
text remarks
int is_deleted
string created_at
}
inbound_outbound {
int id PK
string date "日期"
string partner_company "往来单位"
string business_type "业务类型"
string product "产品"
double quantity "本次量(t)"
string plan_no "计划号"
string batch_no "批次号"
string vehicle_no "车牌号"
string status "状态"
int purchase_plan_id FK
text remarks
int is_deleted
string created_at
}
weighing_slips {
int id PK
string vehicle_no "车牌号"
string plan_no "计划号"
string cargo_name "货物名称"
string business_type "业务类型"
string batch_no "批次号"
string supplier "供货单位"
string consignee "收货单位"
double gross_weight "毛重(kg)"
double tare_weight "皮重(kg)"
double net_weight "净重(kg)"
int purchase_plan_id FK
int inbound_outbound_id FK
string weighing_point "称重点"
text remarks
int is_voided
string created_at
}
users {
int id PK
string username UK
string password
string role
string created_at
}
数据流向
flowchart TD
A[计划管理] -->|生成出入库单| B[出入库管理]
B -->|生成地磅单| C[地磅单管理]
A -->|计划号| B
B -->|出入库单ID| C
B -->|更新状态| A
C -->|更新状态| B
D[公司表] -->|自动创建| A
D -->|自动创建| B
D -->|自动创建| C
E[货物表] -->|自动创建| A
E -->|自动创建| B
E -->|自动创建| C
style A fill:#e1f5ff
style B fill:#fff4e1
style C fill:#e8f5e9
style D fill:#f3e5f5
style E fill:#f3e5f5
状态计算逻辑
flowchart LR
A[计划] -->|关联| B[出入库单]
B -->|关联| C[地磅单]
C -->|有地磅单且净重>0| D[出入库单状态:已入库/已出库]
C -->|无地磅单或净重=0| E[出入库单状态:待入库/待出库]
D -->|有已完成的出入库单| F[计划状态:已入库/已出库]
E -->|无已完成的出入库单| G[计划状态:待入库/待出库]
style A fill:#e1f5ff
style B fill:#fff4e1
style C fill:#e8f5e9
style D fill:#c8e6c9
style E fill:#ffccbc
style F fill:#c8e6c9
style G fill:#ffccbc