作者 yangfu

设备档案修改

... ... @@ -11,7 +11,7 @@ require (
github.com/go-pg/pg/v10 v10.9.0
github.com/go-redis/redis v6.15.7+incompatible
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.3.0
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7
github.com/moul/http2curl v1.0.0 // indirect
... ... @@ -20,7 +20,7 @@ require (
github.com/sergi/go-diff v1.2.0 // indirect
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/stretchr/testify v1.7.0
github.com/tidwall/gjson v1.13.0 // indirect
github.com/tidwall/gjson v1.13.0
github.com/valyala/fasthttp v1.32.0 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
... ...
... ... @@ -160,7 +160,6 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
github.com/google/gops v0.3.7/go.mod h1:bj0cwMmX1X4XIJFTjR99R5sCxNssNJ8HebFNvoQlmgY=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
... ...
... ... @@ -28,11 +28,14 @@ type CreateDeviceCommand struct {
// 工段ID
SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"`
// 品牌
Brand string `cname:"品牌" json:"brand" valid:"Required"`
Brand string `cname:"品牌" json:"brand"`
// 设备状态 1:正常 2:封存 3:报废
DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"`
// 风险等级 1:高 2:中 3:低
RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"`
// 标准工时 生产单个产品的时间(单位:秒)
UnitProductionSecTime int `cname:"标准工时" json:"unitProductionSecTime"`
}
func (createDeviceCommand *CreateDeviceCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -31,6 +31,8 @@ type UpdateDeviceCommand struct {
DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"`
// 风险等级 1:高 2:中 3:低
RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"`
// 标准工时
UnitProductionSecTime int `cname:"标准工时" json:"unitProductionSecTime"`
}
func (updateDeviceCommand *UpdateDeviceCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -23,6 +23,8 @@ type DeviceDto struct {
RiskLevel int `json:"riskLevel,omitempty"`
// 所属位置
*domain.WorkStation
// 生产单个产品的时间(单位:秒)
UnitProductionSecTime int `json:"unitProductionSecTime"`
// 组织名称
OrgName string `json:"orgName"`
... ... @@ -43,5 +45,8 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto {
if m.Ext != nil {
d.OrgName = m.Ext.OrgName
}
if m.Ext != nil && m.Ext.DeviceExt != nil {
d.UnitProductionSecTime = m.Ext.DeviceExt.UnitProductionSecTime
}
return d
}
... ...
... ... @@ -63,7 +63,7 @@ func (deviceService *DeviceService) CreateDevice(operateInfo *domain.OperateInfo
RiskLevel: cmd.RiskLevel,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Ext: domain.NewExt(org.OrgName),
Ext: domain.NewExt(org.OrgName).WithDeviceExt(&domain.DeviceExt{UnitProductionSecTime: cmd.UnitProductionSecTime}),
}
deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0)
... ...
... ... @@ -6,6 +6,8 @@ import (
)
type ProductPlanDto struct {
// 生产计划ID
ProductPlanId int `json:"productPlanId,omitempty"`
// 批号
BatchNumber string `json:"batchNumber,omitempty"`
// 生产日期
... ... @@ -41,6 +43,7 @@ type ProductPlanDto struct {
}
func (d *ProductPlanDto) LoadDto(m *domain.ProductPlan, orgId int) *ProductPlanDto {
d.ProductPlanId = m.ProductPlanId
d.BatchNumber = m.BatchNumber
d.ProductDate = m.ProductDate.Format("2006/01/02")
d.WorkshopId = m.Workshop.WorkshopId
... ...
... ... @@ -305,7 +305,7 @@ func (productPlanService *ProductPlanService) SubmitProductRecord(submitProductR
}
// 换单
func (productPlanService *ProductPlanService) Switch(switchCommand *command.SwitchCommand) (interface{}, error) {
func (productPlanService *ProductPlanService) Exchange(switchCommand *command.SwitchCommand) (interface{}, error) {
if err := switchCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ...
... ... @@ -103,10 +103,16 @@ func (device *Device) Update(data map[string]interface{}) error {
}
if device.Ext == nil {
device.Ext = &Ext{}
if device.Ext.DeviceExt == nil {
device.Ext.DeviceExt = &DeviceExt{}
}
}
if orgName, ok := data["orgName"]; ok {
device.Ext.OrgName = orgName.(string)
}
if unitProductionSecTime, ok := data["unitProductionSecTime"]; ok {
device.Ext.DeviceExt.UnitProductionSecTime = unitProductionSecTime.(int)
}
device.UpdatedAt = time.Now()
return nil
}
... ...
package domain
// DeviceExt 设备扩展
type DeviceExt struct {
// 生产单个产品的时间(单位:秒)
UnitProductionSecTime int `json:"unitProductionSecTime"`
}
... ...
... ... @@ -4,6 +4,9 @@ package domain
type Ext struct {
// 组织名称
OrgName string `json:"orgName,omitempty"`
// 设备扩展数据
DeviceExt *DeviceExt `json:"deviceExt"`
}
func NewExt(orgName string) *Ext {
... ... @@ -11,3 +14,8 @@ func NewExt(orgName string) *Ext {
OrgName: orgName,
}
}
func (e *Ext) WithDeviceExt(deviceExt *DeviceExt) *Ext {
e.DeviceExt = deviceExt
return e
}
... ...
... ... @@ -90,7 +90,7 @@ func (controller *ProductPlanController) Switch() {
productPlanService := service.NewProductPlanService(nil)
switchCommand := &command.SwitchCommand{}
Must(controller.Unmarshal(switchCommand))
data, err := productPlanService.Switch(switchCommand)
data, err := productPlanService.Exchange(switchCommand)
controller.Response(data, err)
}
... ...