feat(mes): 添加定时同步可生产数量到WMS及BOM项相关标准字段

- 在main.go中添加定时任务每10分钟同步可生产数量到WMS系统
- 为BomItem实体添加relatedStandard字段及相关CRUD方法
- 为InspectionRecord实体添加reportNo、materialCode、materialName等字段
- 更新ent schema确保新字段的验证和默认值设置
- 添加必要的数据库迁移和字段映射逻辑
This commit is contained in:
SunYF
2026-09-17 12:49:07 +08:00
parent b4b274301d
commit 1cc93795ce
191 changed files with 24504 additions and 1250 deletions
+73 -8
View File
@@ -180,12 +180,16 @@ var (
{Name: "manage_mode", Type: field.TypeInt, Default: 1},
{Name: "batch_no", Type: field.TypeString, Nullable: true},
{Name: "zone_code", Type: field.TypeString, Nullable: true},
{Name: "shelf_no", Type: field.TypeString, Nullable: true},
{Name: "layer_no", Type: field.TypeString, Nullable: true},
{Name: "position_no", Type: field.TypeString, Nullable: true},
{Name: "quantity", Type: field.TypeInt, Default: 0},
{Name: "operator", Type: field.TypeString, Nullable: true},
{Name: "remark", Type: field.TypeString, Nullable: true},
{Name: "inspection_no", Type: field.TypeString},
{Name: "ownership_type", Type: field.TypeString, Default: "none"},
{Name: "ownership_no", Type: field.TypeString, Nullable: true},
{Name: "quality_status", Type: field.TypeString, Nullable: true},
{Name: "created_at", Type: field.TypeInt64},
}
// InboundOrdersTable holds the schema information for the "inbound_orders" table.
@@ -207,7 +211,7 @@ var (
{
Name: "inboundorder_operator",
Unique: false,
Columns: []*schema.Column{InboundOrdersColumns[9]},
Columns: []*schema.Column{InboundOrdersColumns[12]},
},
},
}
@@ -217,6 +221,11 @@ var (
{Name: "target_type", Type: field.TypeString},
{Name: "target_id", Type: field.TypeString},
{Name: "material_code", Type: field.TypeString},
{Name: "material_name", Type: field.TypeString, Nullable: true},
{Name: "ownership_type", Type: field.TypeString, Nullable: true},
{Name: "ownership_no", Type: field.TypeString, Nullable: true},
{Name: "related_standard", Type: field.TypeString, Nullable: true},
{Name: "manufacturer", Type: field.TypeString, Nullable: true},
{Name: "inspection_type", Type: field.TypeString, Default: "incoming"},
{Name: "status", Type: field.TypeString, Default: "未检"},
{Name: "result_value", Type: field.TypeString, Nullable: true},
@@ -252,12 +261,12 @@ var (
{
Name: "inspectionrecord_inspection_type",
Unique: false,
Columns: []*schema.Column{InspectionRecordsColumns[4]},
Columns: []*schema.Column{InspectionRecordsColumns[9]},
},
{
Name: "inspectionrecord_status",
Unique: false,
Columns: []*schema.Column{InspectionRecordsColumns[5]},
Columns: []*schema.Column{InspectionRecordsColumns[10]},
},
},
}
@@ -274,12 +283,23 @@ var (
{Name: "locked_qty", Type: field.TypeInt, Default: 0},
{Name: "quality_status", Type: field.TypeString, Default: "未检"},
{Name: "zone_code", Type: field.TypeString, Nullable: true},
{Name: "shelf_no", Type: field.TypeString, Nullable: true},
{Name: "layer_no", Type: field.TypeString, Nullable: true},
{Name: "position_no", Type: field.TypeString, Nullable: true},
{Name: "status", Type: field.TypeString, Default: "在库"},
{Name: "production_date", Type: field.TypeString, Nullable: true},
{Name: "supplier", Type: field.TypeString, Nullable: true},
{Name: "inbound_no", Type: field.TypeString, Nullable: true},
{Name: "order_no", Type: field.TypeString, Size: 64, Default: ""},
{Name: "completed_process", Type: field.TypeString, Size: 64, Default: ""},
{Name: "ownership_type", Type: field.TypeString, Nullable: true},
{Name: "ownership_no", Type: field.TypeString, Nullable: true},
{Name: "product_status", Type: field.TypeString, Nullable: true},
{Name: "related_standard", Type: field.TypeString, Nullable: true},
{Name: "test_record_no", Type: field.TypeString, Nullable: true},
{Name: "recorded_by", Type: field.TypeString, Nullable: true},
{Name: "recorded_at", Type: field.TypeInt64, Nullable: true},
{Name: "outbound_reason", Type: field.TypeString, Nullable: true},
{Name: "remark", Type: field.TypeString, Nullable: true},
{Name: "created_at", Type: field.TypeInt64},
{Name: "updated_at", Type: field.TypeInt64},
@@ -378,7 +398,6 @@ var (
{Name: "is_batch_managed", Type: field.TypeBool, Default: false},
{Name: "is_serial_managed", Type: field.TypeBool, Default: false},
{Name: "template_code", Type: field.TypeString, Nullable: true},
{Name: "drawing_no", Type: field.TypeString, Nullable: true},
{Name: "safety_stock", Type: field.TypeInt, Default: 0},
{Name: "is_active", Type: field.TypeBool, Default: true},
{Name: "created_at", Type: field.TypeInt64},
@@ -407,6 +426,19 @@ var (
},
},
}
// MaterialDemandsColumns holds the columns for the "material_demands" table.
MaterialDemandsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "material_code", Type: field.TypeString, Unique: true},
{Name: "future5_qty", Type: field.TypeInt, Default: 0},
{Name: "updated_at", Type: field.TypeInt64},
}
// MaterialDemandsTable holds the schema information for the "material_demands" table.
MaterialDemandsTable = &schema.Table{
Name: "material_demands",
Columns: MaterialDemandsColumns,
PrimaryKey: []*schema.Column{MaterialDemandsColumns[0]},
}
// OrderMaterialLedgersColumns holds the columns for the "order_material_ledgers" table.
OrderMaterialLedgersColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
@@ -417,6 +449,7 @@ var (
{Name: "out_qty", Type: field.TypeInt, Default: 0},
{Name: "status", Type: field.TypeString, Default: "进行中"},
{Name: "target_station", Type: field.TypeString, Nullable: true},
{Name: "completed_at", Type: field.TypeInt64, Nullable: true},
{Name: "remark", Type: field.TypeString, Nullable: true},
{Name: "created_at", Type: field.TypeInt64},
{Name: "updated_at", Type: field.TypeInt64},
@@ -478,6 +511,10 @@ var (
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "outbound_no", Type: field.TypeString, Unique: true},
{Name: "outbound_type", Type: field.TypeString, Default: "workorder"},
{Name: "outbound_category", Type: field.TypeString, Nullable: true},
{Name: "ownership_type", Type: field.TypeString, Nullable: true},
{Name: "ownership_no", Type: field.TypeString, Nullable: true},
{Name: "target_station", Type: field.TypeString, Nullable: true},
{Name: "order_no", Type: field.TypeString, Nullable: true},
{Name: "material_code", Type: field.TypeString},
{Name: "material_name", Type: field.TypeString, Nullable: true},
@@ -503,12 +540,12 @@ var (
{
Name: "outboundorder_order_no",
Unique: false,
Columns: []*schema.Column{OutboundOrdersColumns[3]},
Columns: []*schema.Column{OutboundOrdersColumns[7]},
},
{
Name: "outboundorder_material_code",
Unique: false,
Columns: []*schema.Column{OutboundOrdersColumns[4]},
Columns: []*schema.Column{OutboundOrdersColumns[8]},
},
{
Name: "outboundorder_outbound_type",
@@ -518,7 +555,7 @@ var (
{
Name: "outboundorder_box_no",
Unique: false,
Columns: []*schema.Column{OutboundOrdersColumns[14]},
Columns: []*schema.Column{OutboundOrdersColumns[18]},
},
},
}
@@ -549,6 +586,29 @@ var (
},
},
}
// ProducibleSnapshotsColumns holds the columns for the "producible_snapshots" table.
ProducibleSnapshotsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "product_code", Type: field.TypeString},
{Name: "product_name", Type: field.TypeString, Nullable: true},
{Name: "producible_qty", Type: field.TypeInt, Default: 0},
{Name: "short_text", Type: field.TypeString, Nullable: true},
{Name: "computed_at", Type: field.TypeInt64, Default: 0},
{Name: "synced_at", Type: field.TypeInt64},
}
// ProducibleSnapshotsTable holds the schema information for the "producible_snapshots" table.
ProducibleSnapshotsTable = &schema.Table{
Name: "producible_snapshots",
Columns: ProducibleSnapshotsColumns,
PrimaryKey: []*schema.Column{ProducibleSnapshotsColumns[0]},
Indexes: []*schema.Index{
{
Name: "produciblesnapshot_product_code",
Unique: false,
Columns: []*schema.Column{ProducibleSnapshotsColumns[1]},
},
},
}
// ReturnOrdersColumns holds the columns for the "return_orders" table.
ReturnOrdersColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
@@ -659,6 +719,9 @@ var (
{Name: "target_id", Type: field.TypeString},
{Name: "material_code", Type: field.TypeString, Nullable: true},
{Name: "zone_code", Type: field.TypeString, Nullable: true},
{Name: "shelf_no", Type: field.TypeString, Nullable: true},
{Name: "layer_no", Type: field.TypeString, Nullable: true},
{Name: "position_no", Type: field.TypeString, Nullable: true},
{Name: "book_qty", Type: field.TypeInt, Default: 0},
{Name: "scanned_qty", Type: field.TypeInt, Default: -1},
{Name: "diff_qty", Type: field.TypeInt, Default: 0},
@@ -737,7 +800,7 @@ var (
// ZonesColumns holds the columns for the "zones" table.
ZonesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "zone_code", Type: field.TypeString, Unique: true},
{Name: "zone_code", Type: field.TypeString},
{Name: "zone_name", Type: field.TypeString},
{Name: "description", Type: field.TypeString, Nullable: true},
{Name: "shelf_no", Type: field.TypeString, Nullable: true},
@@ -765,10 +828,12 @@ var (
InventoriesTable,
InventoryLocksTable,
MaterialsTable,
MaterialDemandsTable,
OrderMaterialLedgersTable,
OutboundDetailsTable,
OutboundOrdersTable,
PermissionsTable,
ProducibleSnapshotsTable,
ReturnOrdersTable,
RolesTable,
SemiFinishedsTable,