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
+17 -5
View File
@@ -11,6 +11,7 @@ import (
"bj_power_mes/ent/dailyplan"
"bj_power_mes/ent/materialrequest"
"bj_power_mes/ent/plcsendlog"
"bj_power_mes/ent/station"
"bj_power_mes/ent/torquerecord"
"bj_power_mes/ent/workorder"
"bj_power_mes/ent/workpiece"
@@ -387,7 +388,7 @@ func (s *Service) buildWarehouse(ctx context.Context) WarehouseStats {
func (s *Service) buildEquipment(ctx context.Context, today time.Time) []StationState {
// 工位主数据
stMap := map[int]StationState{}
if sts, err := s.ctx.EntClient.Station.Query().All(ctx); err == nil {
if sts, err := s.ctx.EntClient.Station.Query().Where(station.StationTypeNEQ("OFFLINE")).All(ctx); err == nil {
for _, st := range sts {
stMap[st.StationNo] = StationState{
StationNo: st.StationNo,
@@ -401,10 +402,21 @@ func (s *Service) buildEquipment(ctx context.Context, today time.Time) []Station
}
}
}
// 工位主数据缺失时兜底生成 12 个工位
for i := 1; i <= 12; i++ {
if _, ok := stMap[i]; !ok {
stMap[i] = StationState{StationNo: i, Name: stationDisplayName("", i), Status: "idle"}
// 工位主数据缺失时兜底:按 DB 物理工位生成(不含 0/13 虚拟上下线位);DB 完全空时回退 1~12
if len(stMap) == 0 {
if dbStations, e := s.ctx.EntClient.Station.Query().
Where(station.StationTypeNEQ("OFFLINE")).All(ctx); e == nil && len(dbStations) > 0 {
for _, st := range dbStations {
if _, ok := stMap[st.StationNo]; !ok {
stMap[st.StationNo] = StationState{StationNo: st.StationNo, Name: stationDisplayName("", st.StationNo), Status: "idle"}
}
}
} else {
for i := 1; i <= 12; i++ {
if _, ok := stMap[i]; !ok {
stMap[i] = StationState{StationNo: i, Name: stationDisplayName("", i), Status: "idle"}
}
}
}
}