product_plan.go 5.7 KB
package domain

import "time"

// 生产计划
type ProductPlan struct {
	// 生产计划ID
	ProductPlanId int `json:"productPlanId,omitempty"`
	// 企业id
	CompanyId int `json:"companyId,omitempty"`
	// 组织ID
	OrgId int `json:"orgId,omitempty"`
	// 批号
	BatchNumber string `json:"batchNumber,omitempty"`
	// 生产日期
	ProductDate time.Time `json:"productDate,omitempty"`
	// 车间
	Workshop *Workshop `json:"workshop,omitempty"`
	// 上班班次 1:全天  2:白班 4:中班  8:夜班
	WorkOn int `json:"workOn,omitempty"`
	// 机台 (A、B、C、D 区分机器大小)
	Machine string `json:"machine,omitempty"`
	// 计划的产品名称
	PlanProductName string `json:"planProductName,omitempty"`
	// 计划投入
	PlanDevoted *UnitQuantity `json:"planDevoted,omitempty"`
	// 计划状态 (1:上线 2:下线  默认下线)
	PlanStatus int `json:"planStatus,omitempty"`
	// 工作位置
	WorkStation *WorkStation `json:"workStation,omitempty"`
	// 备注
	Remark string `json:"remark,omitempty"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt,omitempty"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt,omitempty"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt,omitempty"`
	// 扩展数据
	Ext *Ext `json:"ext,omitempty"`
}

type ProductPlanRepository interface {
	Save(productPlan *ProductPlan) (*ProductPlan, error)
	Remove(productPlan *ProductPlan) (*ProductPlan, error)
	FindOne(queryOptions map[string]interface{}) (*ProductPlan, error)
	Find(queryOptions map[string]interface{}) (int64, []*ProductPlan, error)
}

func (productPlan *ProductPlan) Identify() interface{} {
	if productPlan.ProductPlanId == 0 {
		return nil
	}
	return productPlan.ProductPlanId
}

func (productPlan *ProductPlan) Update(data map[string]interface{}) error {
	//if productPlanId, ok := data["productPlanId"]; ok {
	//	productPlan.ProductPlanId = productPlanId.(int)
	//}
	//if companyId, ok := data["companyId"]; ok {
	//	productPlan.CompanyId = companyId.(int)
	//}
	//if orgId, ok := data["orgId"]; ok {
	//	productPlan.OrgId = orgId.(int)
	//}
	//if batchNumber, ok := data["batchNumber"]; ok {
	//	productPlan.BatchNumber = batchNumber.(string)
	//}
	//if productDate, ok := data["productDate"]; ok {
	//	productPlan.ProductDate = productDate.(time.Time)
	//}
	//if companyId, ok := data["companyId"]; ok {
	//	productPlan.Workshop.CompanyId = companyId.(int)
	//}
	//if orgId, ok := data["orgId"]; ok {
	//	productPlan.Workshop.OrgId = orgId.(int)
	//}
	//if workshopId, ok := data["workshopId"]; ok {
	//	productPlan.Workshop.WorkshopId = workshopId.(int)
	//}
	//if workshopName, ok := data["workshopName"]; ok {
	//	productPlan.Workshop.WorkshopName = workshopName.(string)
	//}
	//if userId, ok := data["userId"]; ok {
	//	productPlan.Workshop.Principal.UserId = userId.(int)
	//}
	//if userName, ok := data["userName"]; ok {
	//	productPlan.Workshop.Principal.UserName = userName.(string)
	//}
	//if employeeType, ok := data["employeeType"]; ok {
	//	productPlan.Workshop.Principal.EmployeeType = employeeType.(int)
	//}
	//if icCardNumber, ok := data["icCardNumber"]; ok {
	//	productPlan.Workshop.Principal.IcCardNumber = icCardNumber.(string)
	//}
	//if avatar, ok := data["avatar"]; ok {
	//	productPlan.Workshop.Principal.Avatar = avatar.(string)
	//}
	//if phone, ok := data["phone"]; ok {
	//	productPlan.Workshop.Principal.Phone = phone.(string)
	//}
	//if productLines, ok := data["productLines"]; ok {
	//	productPlan.Workshop.ProductLines = productLines.(array)
	//}
	//if createdAt, ok := data["createdAt"]; ok {
	//	productPlan.Workshop.CreatedAt = createdAt.(time.Time)
	//}
	//if updatedAt, ok := data["updatedAt"]; ok {
	//	productPlan.Workshop.UpdatedAt = updatedAt.(time.Time)
	//}
	//if deletedAt, ok := data["deletedAt"]; ok {
	//	productPlan.Workshop.DeletedAt = deletedAt.(time.Time)
	//}
	//if workOn, ok := data["workOn"]; ok {
	//	productPlan.WorkOn = workOn.(int)
	//}
	//if machine, ok := data["machine"]; ok {
	//	productPlan.Machine = machine.(string)
	//}
	//if planProductName, ok := data["planProductName"]; ok {
	//	productPlan.PlanProductName = planProductName.(string)
	//}
	//if quantity, ok := data["quantity"]; ok {
	//	productPlan.PlanDevoted.Quantity = quantity.(float64)
	//}
	//if unit, ok := data["unit"]; ok {
	//	productPlan.PlanDevoted.Unit = unit.(string)
	//}
	//if unitWeight, ok := data["unitWeight"]; ok {
	//	productPlan.PlanDevoted.UnitWeight = unitWeight.(float64)
	//}
	//if weight, ok := data["weight"]; ok {
	//	productPlan.PlanDevoted.Weight = weight.(float64)
	//}
	//if planStatus, ok := data["planStatus"]; ok {
	//	productPlan.PlanStatus = planStatus.(int)
	//}
	//if workStationId, ok := data["workStationId"]; ok {
	//	productPlan.WorkStation.WorkStationId = workStationId.(string)
	//}
	//if workshopId, ok := data["workshopId"]; ok {
	//	productPlan.WorkStation.WorkshopId = workshopId.(int)
	//}
	//if workshopName, ok := data["workshopName"]; ok {
	//	productPlan.WorkStation.WorkshopName = workshopName.(string)
	//}
	//if lineId, ok := data["lineId"]; ok {
	//	productPlan.WorkStation.LineId = lineId.(int)
	//}
	//if lineName, ok := data["lineName"]; ok {
	//	productPlan.WorkStation.LineName = lineName.(string)
	//}
	//if sectionId, ok := data["sectionId"]; ok {
	//	productPlan.WorkStation.SectionId = sectionId.(int)
	//}
	//if sectionName, ok := data["sectionName"]; ok {
	//	productPlan.WorkStation.SectionName = sectionName.(string)
	//}
	//if remark, ok := data["remark"]; ok {
	//	productPlan.Remark = remark.(string)
	//}
	//if createdAt, ok := data["createdAt"]; ok {
	//	productPlan.CreatedAt = createdAt.(time.Time)
	//}
	//if updatedAt, ok := data["updatedAt"]; ok {
	//	productPlan.UpdatedAt = updatedAt.(time.Time)
	//}
	//if deletedAt, ok := data["deletedAt"]; ok {
	//	productPlan.DeletedAt = deletedAt.(time.Time)
	//}
	return nil
}