package om

import (
	"LAPP_ACURA_MOM_BACKEND/grmi"
	baseModel "LAPP_ACURA_MOM_BACKEND/models/base"
	meModel "LAPP_ACURA_MOM_BACKEND/models/me"
	"time"
)

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"`
}

// VOmSerialorder 生产订单和它的状态的综合视图
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"`
}

// work order排序数据
type WorkOrderSort struct {
	WorkOrderId string `json:"workOrderId"`
	Sort        string `json:"sort"`
}

// work order 切割前端绑定结构体
type WorkOrderSplit struct {
	WorkOrderId string `json:"workOrderId"`
	Qty         int    `json:"qty"`
}

// serialOrder 和 serialOrderStatus 和 serialOrderPOLst
type SerialOrderPOData struct {
	SerialOrder       `xorm:"extends"`
	SerialOrderStatus `xorm:"extends"`
	SerialOrderPOLst  `xorm:"extends"`
	baseModel.Process `xorm:"extends"`
}

type SerialOrderOPData struct {
	//SerialOrder                    `xorm:"extends"`
	SerialOrderOPDetailRecvDataLst  `xorm:"extends"`
	SerialOrderOPDetail             `xorm:"extends"`
	baseModel.OPCComRule            `xorm:"extends"`
	baseModel.Operation             `xorm:"extends"`
	baseModel.TightenWrenchRuleInfo `xorm:"extends"`
}

type OperationDetailTraceData struct {
	SerialOrderOPDetailRecvDataLst  `xorm:"extends"`
	SerialOrderOPDetail             `xorm:"extends"`
	baseModel.OPCComRule            `xorm:"extends"`
	baseModel.Operation             `xorm:"extends"`
	baseModel.TightenWrenchRuleInfo `xorm:"extends"`
}

// RecvDataWithOPC SerialOrderOPRecvData 和 OPCComRule连表数据
type RecvDataWithOPC struct {
	SerialOrderOPDetailRecvDataLst `xorm:"extends"`
	baseModel.OPCComRule           `xorm:"extends"`
}

// SerialOrderWithStatusRec serialOrder和状态变更记录连表查询
type SerialOrderWithStatusRec struct {
	SerialOrder             `xorm:"extends"`
	SerialOrderStatusRecLst `xorm:"extends"`
}

type SerialOrderPOWithProcess struct {
	SerialOrderPOLst             `xorm:"extends"`
	baseModel.WorkLineProcessLst `xorm:"extends"`
	baseModel.Process            `xorm:"extends"`
}

// OrderAUPoData 生成工艺数据时 工单Id对应的
type OrderAUPoData struct {
	Config         *meModel.ShipableAUConfig
	MeOperationLi  []baseModel.MeOperation
	IsMainOrder    bool
	SFP            *baseModel.Article
	AllAttributeLi []baseModel.ArticleAttribute
	ArtRelMap      map[string]int
}

type ExportItem struct {
	SerialOrderId string `json:"ExportItem-SerialOrderId"`
	Po            string `json:"ExportItem-Po"`
	WorkPlace     string `json:"ExportItem-WorkPlace"`
	ArtId         string `json:"ExportItem-ArtId"`
	BarCode       string `json:"ExportItem-BarCode"`
	UsedTime      string `json:"ExportItem-UsedTime"`
}

type ProductTraceData struct {
	SerialOrderId string               `json:"ProductTraceData-SerialOrderId"`
	POLi          []ProductTracePOData `json:"ProductTraceData-POLi"`
}

type ProductTracePOData struct {
	PO       string                 `json:"ProductTracePOData-PO"`
	PoDesc   string                 `json:"ProductTracePOData-PoDesc"`
	PoStatus string                 `json:"ProductTracePOData-PoStatus"`
	StepLi   []ProductTraceStepData `json:"ProductTracePOData-StepLi"`
}

type ProductTraceStepData struct {
	StepNo     int                              `json:"ProductTraceStepData-StepNo"`
	StepDesc   string                           `json:"ProductTraceStepData-StepDesc"`
	RecvDataLi []SerialOrderOPDetailRecvDataLst `json:"ProductTraceStepData-RecvDataLi"`
}

// SerialOrderCraft 工单工艺相关数据
type SerialOrderCraft struct {
	SerialOrderLi []SerialOrder
	SerialOrderStatusLi []SerialOrderStatus
	SerialOrderPOLstLi []SerialOrderPOLst
	SerialOrderStepLstLi []SerialOrderStepLst
	SerialOrderOPDetailLi []SerialOrderOPDetail
	LabelHeadLi []baseModel.LabelHead
	LabelDetailLi []baseModel.LabelDetail
}

type ReplaceId struct {
	SnrId string
	PlanTime time.Time
}