fix: rebuild MES as compilable go-zero+ent backend (renamed bj_power_mes), restore 3 workstation projects from pristine original, align naming; all Go projects go build clean
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
package eventbus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 事件构造辅助函数
|
||||
|
||||
// NewTempSlotChangedEvent 构建暂存台槽位变更事件
|
||||
func NewTempSlotChangedEvent(slotNo, jobID int, action string) Event {
|
||||
return Event{
|
||||
ID: fmt.Sprintf("tsc-%d-%d", slotNo, time.Now().UnixNano()),
|
||||
Type: EventTempSlotChanged,
|
||||
Source: "processor",
|
||||
EntityType: string(EntityTempSlot),
|
||||
EntityID: strconv.Itoa(slotNo),
|
||||
Timestamp: time.Now(),
|
||||
Payload: map[string]any{
|
||||
"slotNo": slotNo,
|
||||
"jobId": jobID,
|
||||
"action": action,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewAlarmRaisedEvent 构建报警触发事件
|
||||
func NewAlarmRaisedEvent(alarmID int, alarmCode string, level string, equipmentID int, source string) Event {
|
||||
return Event{
|
||||
ID: fmt.Sprintf("alarm-%d-%d", alarmID, time.Now().UnixNano()),
|
||||
Type: EventAlarmRaised,
|
||||
Source: source,
|
||||
EntityType: "alarm",
|
||||
EntityID: strconv.Itoa(alarmID),
|
||||
Timestamp: time.Now(),
|
||||
Payload: map[string]any{
|
||||
"alarmId": alarmID,
|
||||
"alarmCode": alarmCode,
|
||||
"level": level,
|
||||
"equipmentId": equipmentID,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewAlarmAckedEvent 构建报警确认事件
|
||||
func NewAlarmAckedEvent(alarmID int) Event {
|
||||
return Event{
|
||||
ID: fmt.Sprintf("alarm-ack-%d-%d", alarmID, time.Now().UnixNano()),
|
||||
Type: EventAlarmAcked,
|
||||
Source: "api",
|
||||
EntityType: "alarm",
|
||||
EntityID: strconv.Itoa(alarmID),
|
||||
Timestamp: time.Now(),
|
||||
Payload: map[string]any{
|
||||
"alarmId": alarmID,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewEquipmentAvailabilityChangedEvent 构建设备可用状态变更事件
|
||||
func NewEquipmentAvailabilityChangedEvent(equipmentID int, equipmentName string, enabled bool) Event {
|
||||
return Event{
|
||||
ID: fmt.Sprintf("equipment-availability-%d-%d", equipmentID, time.Now().UnixNano()),
|
||||
Type: EventEquipmentAvailabilityChanged,
|
||||
Source: "api",
|
||||
EntityType: "equipment",
|
||||
EntityID: strconv.Itoa(equipmentID),
|
||||
Timestamp: time.Now(),
|
||||
Payload: map[string]any{
|
||||
"equipmentId": equipmentID,
|
||||
"equipmentName": equipmentName,
|
||||
"enabled": enabled,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewManualActionCreatedEvent 构建人工交互创建事件
|
||||
func NewManualActionCreatedEvent(actionID int, actionType string, orderID int) Event {
|
||||
return Event{
|
||||
ID: fmt.Sprintf("ma-%d-%d", actionID, time.Now().UnixNano()),
|
||||
Type: EventManualActionCreated,
|
||||
Source: "processor",
|
||||
EntityType: "manual_action",
|
||||
EntityID: strconv.Itoa(actionID),
|
||||
Timestamp: time.Now(),
|
||||
Payload: map[string]any{
|
||||
"actionId": actionID,
|
||||
"actionType": actionType,
|
||||
"orderId": orderID,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewManualActionResolvedEvent 构建人工交互解决事件
|
||||
func NewManualActionResolvedEvent(actionID int, actionType string, resolvedAction string) Event {
|
||||
return Event{
|
||||
ID: fmt.Sprintf("ma-resolve-%d-%d", actionID, time.Now().UnixNano()),
|
||||
Type: EventManualActionResolved,
|
||||
Source: "api",
|
||||
EntityType: "manual_action",
|
||||
EntityID: strconv.Itoa(actionID),
|
||||
Timestamp: time.Now(),
|
||||
Payload: map[string]any{
|
||||
"actionId": actionID,
|
||||
"actionType": actionType,
|
||||
"resolvedAction": resolvedAction,
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user