|
|
package domain
|
|
|
|
|
|
import "time"
|
|
|
import (
|
|
|
"errors"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
PlanOnline = 1 // 计划上线
|
...
|
...
|
@@ -60,119 +63,47 @@ func (productPlan *ProductPlan) Identify() interface{} { |
|
|
}
|
|
|
|
|
|
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)
|
|
|
//}
|
|
|
if productDate, ok := data["productDateTime"]; ok {
|
|
|
productPlan.ProductDate = productDate.(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 weight, ok := data["weight"]; ok {
|
|
|
productPlan.PlanDevoted.Weight = weight.(float64)
|
|
|
}
|
|
|
if remark, ok := data["remark"]; ok {
|
|
|
productPlan.Remark = remark.(string)
|
|
|
}
|
|
|
productPlan.UpdatedAt = time.Now()
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (productPlan *ProductPlan) ChangeStatus(status int) error {
|
|
|
if productPlan.PlanStatus == status && productPlan.PlanStatus == PlanOnline {
|
|
|
return errors.New("计划已经上线")
|
|
|
}
|
|
|
if productPlan.PlanStatus == status && productPlan.PlanStatus == PlanOffline {
|
|
|
return errors.New("计划已经下线")
|
|
|
}
|
|
|
if !(productPlan.PlanStatus == PlanOnline || productPlan.PlanStatus == PlanOffline) {
|
|
|
return errors.New("计划状态有误")
|
|
|
}
|
|
|
productPlan.PlanStatus = status
|
|
|
return nil
|
|
|
} |
...
|
...
|
|