Files
bj_power/bj_power_mes/internal/logic/dock/common.go
T

50 lines
921 B
Go

package dock
import (
"fmt"
"bj_power_mes/constants"
"bj_power_mes/ent"
"bj_power_mes/internal/types"
)
func statusToString(s int) string {
switch s {
case 0:
return "EMPTY"
case 1:
return "FILL"
case 2:
return "PROCESSING"
case 3:
return "DONE"
default:
return fmt.Sprintf("UNKNOWN_%d", s)
}
}
func determineDockSlotStatus(slot *ent.DockSlot, job *ent.Job) int {
if slot.CurrentJobId == nil || *slot.CurrentJobId == 0 {
return 0 // EMPTY
}
if job.Status == constants.JobStatus_Created {
return 1 // FILL
}
if job.Status == constants.JobStatus_Completed {
return 3 // DONE
}
return 2 // PROCESSING
}
func toJobBrief(j *ent.Job) *types.JobBrief {
brief := &types.JobBrief{
Id: j.ID,
WorkOrderId: j.WorkOrderId,
WorkpieceNo: j.WorkpieceNo,
ProductTypeId: j.ProductTypeId,
Status: string(j.Status),
CurrentStepId: j.CurrentStepId,
}
return brief
}