...
|
...
|
@@ -9,6 +9,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/unitConversion/dto"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/unitConversion/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
|
|
|
"time"
|
|
|
)
|
...
|
...
|
@@ -41,6 +42,13 @@ func (unitConversionService *UnitConversionService) CreateUnitConversion(operate |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
var userService = domainService.NewUserService()
|
|
|
var org *domain.Org
|
|
|
org, err = userService.Organization(cmd.OrgId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
newUnitConversion := &domain.UnitConversion{
|
|
|
CompanyId: cmd.CompanyId,
|
|
|
OrgId: cmd.OrgId,
|
...
|
...
|
@@ -51,6 +59,7 @@ func (unitConversionService *UnitConversionService) CreateUnitConversion(operate |
|
|
WorkStation: workStation,
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
Ext: domain.NewExt(org.OrgName),
|
|
|
}
|
|
|
unitConversionRepository, _, _ := factory.FastPgUnitConversion(transactionContext, 0)
|
|
|
|
...
|
...
|
@@ -87,7 +96,7 @@ func (unitConversionService *UnitConversionService) GetUnitConversion(getUnitCon |
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
result := &dto.UnitConversionDto{}
|
|
|
result.LoadDto(unitConversion)
|
|
|
result.LoadDto(unitConversion, 0)
|
|
|
return result, nil
|
|
|
|
|
|
}
|
...
|
...
|
@@ -236,11 +245,20 @@ func (unitConversionService *UnitConversionService) UpdateUnitConversion(cmd *co |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
var userService = domainService.NewUserService()
|
|
|
var org *domain.Org
|
|
|
org, err = userService.Organization(unitConversion.OrgId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
unitConversion.WorkStation = workStation
|
|
|
unitConversion.Material = cmd.Material
|
|
|
unitConversion.FromUnitQuantity = cmd.FromUnitQuantity
|
|
|
unitConversion.ToUnitQuantity = cmd.ToUnitQuantity
|
|
|
unitConversion.IntelligentWeighingFlag = cmd.IntelligentWeighingFlag
|
|
|
unitConversion.Ext = domain.NewExt(org.OrgName)
|
|
|
|
|
|
if err := unitConversion.Update(utils.ObjectToMap(cmd)); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
...
|
...
|
@@ -285,7 +303,7 @@ func (unitConversionService *UnitConversionService) SearchUnitConversion(operate |
|
|
for i := range unitConversions {
|
|
|
item := unitConversions[i]
|
|
|
newItem := &dto.UnitConversionDto{}
|
|
|
newItem.LoadDto(item)
|
|
|
newItem.LoadDto(item, operateInfo.OrgId)
|
|
|
result = append(result, newItem)
|
|
|
}
|
|
|
return count, result, nil
|
...
|
...
|
|