feat: 大屏新增虚拟工位滚动栏与多订单轮播,附件表增加删除原因及彻底清除留痕字段
This commit is contained in:
@@ -43,12 +43,14 @@ func (s *Service) DashboardSnapshot(ctx context.Context) (*DashboardSnapshot, er
|
||||
snap.Quality = s.buildQuality(ctx, today)
|
||||
snap.Trace = s.buildTrace(ctx)
|
||||
snap.Warehouse = s.buildWarehouse(ctx)
|
||||
snap.Equipment = s.buildEquipment(ctx, today)
|
||||
snap.Equipment = s.buildEquipment(ctx, today, false)
|
||||
snap.VirtualEquipment = s.buildEquipment(ctx, today, true) // 虚拟工位(OFFLINE,不连PLC)单独下发
|
||||
snap.Agv = s.buildAgv(ctx)
|
||||
snap.Performance = s.buildPerformance(ctx, today)
|
||||
snap.Alarms = s.buildAlarms(ctx, today)
|
||||
snap.Trends = s.buildTrends(ctx)
|
||||
snap.Events = s.buildEvents(ctx)
|
||||
s.CheckBackupOverdueAlert(ctx) // 备份超期→预警中心(惰性检查,天级节流,无定时器)
|
||||
return snap, nil
|
||||
})
|
||||
}
|
||||
@@ -457,10 +459,17 @@ func (s *Service) buildWarehouse(ctx context.Context) WarehouseStats {
|
||||
// 屏1:工位实时状态(3D 场景与工位矩阵共用)
|
||||
// ============================================================
|
||||
|
||||
func (s *Service) buildEquipment(ctx context.Context, today time.Time) []StationState {
|
||||
// buildEquipment 工位实时状态聚合。
|
||||
// offlineOnly=false → 常规工位(连 PLC,前端地图 12 槽位);
|
||||
// offlineOnly=true → 虚拟工位(station_type=OFFLINE,不连 PLC、仅记录,供地图"虚拟工位"滚动栏展示)。
|
||||
func (s *Service) buildEquipment(ctx context.Context, today time.Time, offlineOnly bool) []StationState {
|
||||
typePred := station.StationTypeNEQ("OFFLINE")
|
||||
if offlineOnly {
|
||||
typePred = station.StationTypeEQ("OFFLINE")
|
||||
}
|
||||
// 工位主数据
|
||||
stMap := map[int]StationState{}
|
||||
if sts, err := s.ctx.EntClient.Station.Query().Where(station.StationTypeNEQ("OFFLINE")).All(ctx); err == nil {
|
||||
if sts, err := s.ctx.EntClient.Station.Query().Where(typePred).All(ctx); err == nil {
|
||||
for _, st := range sts {
|
||||
stMap[st.StationNo] = StationState{
|
||||
StationNo: st.StationNo,
|
||||
@@ -474,8 +483,8 @@ func (s *Service) buildEquipment(ctx context.Context, today time.Time) []Station
|
||||
}
|
||||
}
|
||||
}
|
||||
// 工位主数据缺失时兜底:按 DB 非线下位工位生成;DB 完全空时回退 1~12
|
||||
if len(stMap) == 0 {
|
||||
// 工位主数据缺失时兜底:常规工位按 DB 非线下位工位生成;DB 完全空时回退 1~12(虚拟工位无兜底)
|
||||
if len(stMap) == 0 && !offlineOnly {
|
||||
if dbStations, e := s.ctx.EntClient.Station.Query().
|
||||
Where(station.StationTypeNEQ("OFFLINE")).All(ctx); e == nil && len(dbStations) > 0 {
|
||||
for _, st := range dbStations {
|
||||
|
||||
Reference in New Issue
Block a user