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,60 @@
|
||||
package recovery
|
||||
|
||||
import (
|
||||
"bj_power_mes/constants"
|
||||
"bj_power_mes/ent"
|
||||
)
|
||||
|
||||
// AssessOrderGrade 评估工单恢复等级。
|
||||
// L1: 可安全自动恢复
|
||||
// L2: 部分工件在设备中,建议确认设备状态后恢复
|
||||
// L3: 存在搬运中/加工中工件,需人工确认物理位置
|
||||
func AssessOrderGrade(jobs []*ent.Job) (grade string, manualRequired bool, message string) {
|
||||
var hasProcessing, hasOnEquipment, hasSuspended bool
|
||||
|
||||
for _, j := range jobs {
|
||||
switch j.Status {
|
||||
case constants.JobStatus_Processing:
|
||||
hasProcessing = true
|
||||
case constants.JobStatus_Suspended:
|
||||
hasSuspended = true
|
||||
}
|
||||
if j.PositionType == constants.PositionType_OnEquipment {
|
||||
hasOnEquipment = true
|
||||
}
|
||||
}
|
||||
|
||||
if hasProcessing {
|
||||
//return "L3", true, "存在加工中的工件,设备状态已丢失,需确认设备当前状态后手动恢复"
|
||||
return "L2", false, "部分工件在设备中(等待加工完成),可自动恢复"
|
||||
}
|
||||
if hasOnEquipment {
|
||||
// WAITING_UNLOAD on equipment: machine finished, slot is DONE, safe to auto-recover
|
||||
return "L2", false, "部分工件在设备中(已完成加工等待卸料),可自动恢复"
|
||||
}
|
||||
if hasSuspended {
|
||||
return "L1", false, "工件处于挂起状态,可安全自动恢复"
|
||||
}
|
||||
return "L1", false, "可安全恢复"
|
||||
}
|
||||
|
||||
// RecoveryResult 恢复结果
|
||||
type RecoveryResult struct {
|
||||
OrderID int `json:"orderId"`
|
||||
Grade string `json:"grade"`
|
||||
ManualRequired bool `json:"manualRequired"`
|
||||
Message string `json:"message"`
|
||||
RestoredCount int `json:"restoredCount"`
|
||||
ManualActionID int `json:"manualActionId,omitempty"`
|
||||
}
|
||||
|
||||
// CountRestorable 统计非终态可恢复工件数。
|
||||
func CountRestorable(jobs []*ent.Job) int {
|
||||
count := 0
|
||||
for _, j := range jobs {
|
||||
if j.Status != constants.JobStatus_Completed && j.Status != constants.JobStatus_Scrapped {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
Reference in New Issue
Block a user