...
|
...
|
@@ -53,6 +53,12 @@ func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.Cre |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
var product *domain.Product
|
|
|
_, product, err = factory.FastPgProduct(transactionContext, cmd.ProductId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
newProductPlan := &domain.ProductPlan{
|
|
|
CompanyId: cmd.CompanyId,
|
|
|
OrgId: cmd.OrgId,
|
...
|
...
|
@@ -61,18 +67,27 @@ func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.Cre |
|
|
Workshop: workshop.CloneSample(),
|
|
|
WorkOn: cmd.WorkOn,
|
|
|
Machine: cmd.Machine,
|
|
|
PlanProductName: cmd.PlanProductName,
|
|
|
PlanProductName: product.ProductName,
|
|
|
PlanDevoted: &domain.UnitQuantity{
|
|
|
Unit: cmd.Unit,
|
|
|
Unit: product.ProductSpec.Unit,
|
|
|
Quantity: cmd.Quantity,
|
|
|
Weight: cmd.Weight,
|
|
|
Weight: product.ProductWeigh(cmd.Quantity),
|
|
|
UnitWeight: product.ProductSpec.UnitWeight,
|
|
|
},
|
|
|
PlanStatus: domain.PlanOffline,
|
|
|
WorkStation: &domain.WorkStation{},
|
|
|
Remark: cmd.Remark,
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
Ext: domain.NewExt(org.OrgName),
|
|
|
Ext: domain.NewExt(org.OrgName).WithProductPlanExt(&domain.ProductPlanExt{
|
|
|
ProductId: product.ProductId,
|
|
|
ProductCode: product.ProductCode,
|
|
|
ProductName: product.ProductName,
|
|
|
//ProductSpec: product.ProductSpec,
|
|
|
}),
|
|
|
}
|
|
|
if cmd.Weight > 0 {
|
|
|
newProductPlan.PlanDevoted.Weight = cmd.Weight
|
|
|
}
|
|
|
if productPlan, err = productPlanRepository.Save(newProductPlan); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -232,7 +247,26 @@ func (productPlanService *ProductPlanService) UpdateProductPlan(cmd *command.Upd |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
var product *domain.Product
|
|
|
_, product, err = factory.FastPgProduct(transactionContext, cmd.ProductId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
productPlan.Workshop = workshop.CloneSample()
|
|
|
productPlan.Ext.WithProductPlanExt(&domain.ProductPlanExt{
|
|
|
ProductId: product.ProductId,
|
|
|
ProductCode: product.ProductCode,
|
|
|
ProductName: product.ProductName,
|
|
|
//ProductSpec: product.ProductSpec,
|
|
|
})
|
|
|
productPlan.PlanDevoted.UnitWeight = product.ProductSpec.UnitWeight
|
|
|
cmd.PlanProductName = product.ProductName
|
|
|
cmd.Unit = product.ProductSpec.Unit
|
|
|
if cmd.Weight == 0 {
|
|
|
cmd.Weight = product.ProductWeigh(cmd.Quantity)
|
|
|
}
|
|
|
|
|
|
if err := productPlan.Update(tool_funs.SimpleStructToMap(cmd)); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
...
|
...
|
|