package om

import "LAPP_LF_MOM_BACKEND/grmi"

const (
	// 订单解析状态
	DemandHeadLoadingStatus    = 1 // 加载中
	DemandHeadLoadFailedStatus = 2 // 加载失败
	DemandHeadUnParsedStatus   = 3 // 待解析
	DemandHeadParsingStatus    = 4 // 解析中
	DemandHeadParsedStatus     = 5 // 已解析

	DemandMaxTry = 10
)

const (
	// Mes订单状态
	MesOrderStatusRelease      = 1 // 待生产                ===> 26
	MesOrderStatusAccomplished = 2 // 生产完成 OK      ====> 80
	MesOrderStatusScraped      = 3 // 生产完成 报废          ===> 80
	MesOrderStatusNG           = 4 // 生产暂停 NG             ===> 39

	// workOrderToMes的TriggerEvent
	TriggerEventLocked       = "locked"
	TriggerEventReleased     = "released"
	TriggerEventAccomplished = "accomplished"

	MesOutputStatusUnSend     = 1
	MesOutputStatusSended     = 2
	MesOutputStatusSendFailed = 3
	MesOutputNum              = 100
	MesOutputRetryNum         = 10
)

const (
	ParseSourceInterval = "INT"
	ParseSourceMES      = "MES"

	CacheWorkOrderType  = "Cache"
	ParseTaskTypeByTime = "ByTime"
	ParseTaskTypeByDay  = "ByDay"
)

type WorkOrderStatusChange struct {
	WorkOrderId string `json:"workOrderId"`
	Status      int    `json:"status"`
}

type WorkOrderJoin struct {
	*WorkOrder
	*WorkOrderStatus
	*WorkOrderQty
}

type WorkOrderQtyChange struct {
	WorkOrderId   string  `json:"workOrderId"`
	AccomplishQty float64 `json:"accomplishQty"`
	RunningQty    float64 `json:"runningQty"`
}

// 生产订单和它的状态的综合视图
type VOmSerialorder struct {
	SerialOrder       `xorm:"extends"`
	SerialOrderStatus `xorm:"extends"`
}

// 生产订单和它的状态的综合视图
type VOmWorkorder struct {
	WorkOrder       `xorm:"extends"`
	WorkOrderStatus `xorm:"extends"`
	WorkOrderQty    `xorm:"extends"`
}

// 用于workOrder同步到mes系统
type VOmWorkorderJoinRec struct {
	VOmWorkorder
	StatusRec WorkOrderStatusRecLst
}

// 用于serialOrder同步到mes
type VOmSerialOrderJoinRec struct {
	SerialOrder
	StatusRec SerialOrderStatusRecLst
}

// 锁定workOrder 返给前端的结构体
type LockedResponseWorkOrder struct {
	WorkOrderId string `json:"workOrderId"`
	Status      int    `json:"status"`
}

// 取消workOrder中serialOrder 前端传递数据绑定的结构体
type CancelWorkOrder struct {
	WorkOrderId string  `json:"workOrderId"`
	Qty         float64 `json:"qty"`
}

type TempDemandLstData struct {
	Qty         int
	RunningQty  int
	FinishedQty int
	CancelQty   int
	Serial      int
	Seq         int
	LastSerial  int
	LastSeq     int
	Status      int
	DemandLstLi []DemandLst
	PartCode    string
	PlanEndDate grmi.Date
}

// 创建序列工单 前端传递数据绑定的结构体
type CreateLockWorkOrder struct {
	ArtId      string `json:"artId"`
	Qty        int    `json:"qty"`
	WorkLineId string `json:"workLineId"`
}
