正在显示
12 个修改的文件
包含
40 行增加
和
7 行删除
| @@ -11,7 +11,7 @@ require ( | @@ -11,7 +11,7 @@ require ( | ||
| 11 | github.com/go-pg/pg/v10 v10.9.0 | 11 | github.com/go-pg/pg/v10 v10.9.0 |
| 12 | github.com/go-redis/redis v6.15.7+incompatible | 12 | github.com/go-redis/redis v6.15.7+incompatible |
| 13 | github.com/google/go-querystring v1.1.0 // indirect | 13 | github.com/google/go-querystring v1.1.0 // indirect |
| 14 | - github.com/google/uuid v1.3.0 // indirect | 14 | + github.com/google/uuid v1.3.0 |
| 15 | github.com/imkira/go-interpol v1.1.0 // indirect | 15 | github.com/imkira/go-interpol v1.1.0 // indirect |
| 16 | github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 | 16 | github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 |
| 17 | github.com/moul/http2curl v1.0.0 // indirect | 17 | github.com/moul/http2curl v1.0.0 // indirect |
| @@ -20,7 +20,7 @@ require ( | @@ -20,7 +20,7 @@ require ( | ||
| 20 | github.com/sergi/go-diff v1.2.0 // indirect | 20 | github.com/sergi/go-diff v1.2.0 // indirect |
| 21 | github.com/smartystreets/goconvey v1.7.2 // indirect | 21 | github.com/smartystreets/goconvey v1.7.2 // indirect |
| 22 | github.com/stretchr/testify v1.7.0 | 22 | github.com/stretchr/testify v1.7.0 |
| 23 | - github.com/tidwall/gjson v1.13.0 // indirect | 23 | + github.com/tidwall/gjson v1.13.0 |
| 24 | github.com/valyala/fasthttp v1.32.0 // indirect | 24 | github.com/valyala/fasthttp v1.32.0 // indirect |
| 25 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect | 25 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect |
| 26 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect | 26 | 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/ | @@ -160,7 +160,6 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ | ||
| 160 | github.com/google/gops v0.3.7/go.mod h1:bj0cwMmX1X4XIJFTjR99R5sCxNssNJ8HebFNvoQlmgY= | 160 | github.com/google/gops v0.3.7/go.mod h1:bj0cwMmX1X4XIJFTjR99R5sCxNssNJ8HebFNvoQlmgY= |
| 161 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= | 161 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= |
| 162 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 162 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
| 163 | -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= | ||
| 164 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 163 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
| 165 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= | 164 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= |
| 166 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 165 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
| @@ -28,11 +28,14 @@ type CreateDeviceCommand struct { | @@ -28,11 +28,14 @@ type CreateDeviceCommand struct { | ||
| 28 | // 工段ID | 28 | // 工段ID |
| 29 | SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` | 29 | SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` |
| 30 | // 品牌 | 30 | // 品牌 |
| 31 | - Brand string `cname:"品牌" json:"brand" valid:"Required"` | 31 | + Brand string `cname:"品牌" json:"brand"` |
| 32 | // 设备状态 1:正常 2:封存 3:报废 | 32 | // 设备状态 1:正常 2:封存 3:报废 |
| 33 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` | 33 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` |
| 34 | // 风险等级 1:高 2:中 3:低 | 34 | // 风险等级 1:高 2:中 3:低 |
| 35 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` | 35 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` |
| 36 | + | ||
| 37 | + // 标准工时 生产单个产品的时间(单位:秒) | ||
| 38 | + UnitProductionSecTime int `cname:"标准工时" json:"unitProductionSecTime"` | ||
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | func (createDeviceCommand *CreateDeviceCommand) Valid(validation *validation.Validation) { | 41 | func (createDeviceCommand *CreateDeviceCommand) Valid(validation *validation.Validation) { |
| @@ -31,6 +31,8 @@ type UpdateDeviceCommand struct { | @@ -31,6 +31,8 @@ type UpdateDeviceCommand struct { | ||
| 31 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` | 31 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` |
| 32 | // 风险等级 1:高 2:中 3:低 | 32 | // 风险等级 1:高 2:中 3:低 |
| 33 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` | 33 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` |
| 34 | + // 标准工时 | ||
| 35 | + UnitProductionSecTime int `cname:"标准工时" json:"unitProductionSecTime"` | ||
| 34 | } | 36 | } |
| 35 | 37 | ||
| 36 | func (updateDeviceCommand *UpdateDeviceCommand) Valid(validation *validation.Validation) { | 38 | func (updateDeviceCommand *UpdateDeviceCommand) Valid(validation *validation.Validation) { |
| @@ -23,6 +23,8 @@ type DeviceDto struct { | @@ -23,6 +23,8 @@ type DeviceDto struct { | ||
| 23 | RiskLevel int `json:"riskLevel,omitempty"` | 23 | RiskLevel int `json:"riskLevel,omitempty"` |
| 24 | // 所属位置 | 24 | // 所属位置 |
| 25 | *domain.WorkStation | 25 | *domain.WorkStation |
| 26 | + // 生产单个产品的时间(单位:秒) | ||
| 27 | + UnitProductionSecTime int `json:"unitProductionSecTime"` | ||
| 26 | 28 | ||
| 27 | // 组织名称 | 29 | // 组织名称 |
| 28 | OrgName string `json:"orgName"` | 30 | OrgName string `json:"orgName"` |
| @@ -43,5 +45,8 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | @@ -43,5 +45,8 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | ||
| 43 | if m.Ext != nil { | 45 | if m.Ext != nil { |
| 44 | d.OrgName = m.Ext.OrgName | 46 | d.OrgName = m.Ext.OrgName |
| 45 | } | 47 | } |
| 48 | + if m.Ext != nil && m.Ext.DeviceExt != nil { | ||
| 49 | + d.UnitProductionSecTime = m.Ext.DeviceExt.UnitProductionSecTime | ||
| 50 | + } | ||
| 46 | return d | 51 | return d |
| 47 | } | 52 | } |
| @@ -63,7 +63,7 @@ func (deviceService *DeviceService) CreateDevice(operateInfo *domain.OperateInfo | @@ -63,7 +63,7 @@ func (deviceService *DeviceService) CreateDevice(operateInfo *domain.OperateInfo | ||
| 63 | RiskLevel: cmd.RiskLevel, | 63 | RiskLevel: cmd.RiskLevel, |
| 64 | CreatedAt: time.Now(), | 64 | CreatedAt: time.Now(), |
| 65 | UpdatedAt: time.Now(), | 65 | UpdatedAt: time.Now(), |
| 66 | - Ext: domain.NewExt(org.OrgName), | 66 | + Ext: domain.NewExt(org.OrgName).WithDeviceExt(&domain.DeviceExt{UnitProductionSecTime: cmd.UnitProductionSecTime}), |
| 67 | } | 67 | } |
| 68 | deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0) | 68 | deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0) |
| 69 | 69 |
| @@ -6,6 +6,8 @@ import ( | @@ -6,6 +6,8 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type ProductPlanDto struct { | 8 | type ProductPlanDto struct { |
| 9 | + // 生产计划ID | ||
| 10 | + ProductPlanId int `json:"productPlanId,omitempty"` | ||
| 9 | // 批号 | 11 | // 批号 |
| 10 | BatchNumber string `json:"batchNumber,omitempty"` | 12 | BatchNumber string `json:"batchNumber,omitempty"` |
| 11 | // 生产日期 | 13 | // 生产日期 |
| @@ -41,6 +43,7 @@ type ProductPlanDto struct { | @@ -41,6 +43,7 @@ type ProductPlanDto struct { | ||
| 41 | } | 43 | } |
| 42 | 44 | ||
| 43 | func (d *ProductPlanDto) LoadDto(m *domain.ProductPlan, orgId int) *ProductPlanDto { | 45 | func (d *ProductPlanDto) LoadDto(m *domain.ProductPlan, orgId int) *ProductPlanDto { |
| 46 | + d.ProductPlanId = m.ProductPlanId | ||
| 44 | d.BatchNumber = m.BatchNumber | 47 | d.BatchNumber = m.BatchNumber |
| 45 | d.ProductDate = m.ProductDate.Format("2006/01/02") | 48 | d.ProductDate = m.ProductDate.Format("2006/01/02") |
| 46 | d.WorkshopId = m.Workshop.WorkshopId | 49 | d.WorkshopId = m.Workshop.WorkshopId |
| @@ -305,7 +305,7 @@ func (productPlanService *ProductPlanService) SubmitProductRecord(submitProductR | @@ -305,7 +305,7 @@ func (productPlanService *ProductPlanService) SubmitProductRecord(submitProductR | ||
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | // 换单 | 307 | // 换单 |
| 308 | -func (productPlanService *ProductPlanService) Switch(switchCommand *command.SwitchCommand) (interface{}, error) { | 308 | +func (productPlanService *ProductPlanService) Exchange(switchCommand *command.SwitchCommand) (interface{}, error) { |
| 309 | if err := switchCommand.ValidateCommand(); err != nil { | 309 | if err := switchCommand.ValidateCommand(); err != nil { |
| 310 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 310 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
| 311 | } | 311 | } |
| @@ -103,10 +103,16 @@ func (device *Device) Update(data map[string]interface{}) error { | @@ -103,10 +103,16 @@ func (device *Device) Update(data map[string]interface{}) error { | ||
| 103 | } | 103 | } |
| 104 | if device.Ext == nil { | 104 | if device.Ext == nil { |
| 105 | device.Ext = &Ext{} | 105 | device.Ext = &Ext{} |
| 106 | + if device.Ext.DeviceExt == nil { | ||
| 107 | + device.Ext.DeviceExt = &DeviceExt{} | ||
| 108 | + } | ||
| 106 | } | 109 | } |
| 107 | if orgName, ok := data["orgName"]; ok { | 110 | if orgName, ok := data["orgName"]; ok { |
| 108 | device.Ext.OrgName = orgName.(string) | 111 | device.Ext.OrgName = orgName.(string) |
| 109 | } | 112 | } |
| 113 | + if unitProductionSecTime, ok := data["unitProductionSecTime"]; ok { | ||
| 114 | + device.Ext.DeviceExt.UnitProductionSecTime = unitProductionSecTime.(int) | ||
| 115 | + } | ||
| 110 | device.UpdatedAt = time.Now() | 116 | device.UpdatedAt = time.Now() |
| 111 | return nil | 117 | return nil |
| 112 | } | 118 | } |
pkg/domain/device_ext.go
0 → 100644
| @@ -4,6 +4,9 @@ package domain | @@ -4,6 +4,9 @@ package domain | ||
| 4 | type Ext struct { | 4 | type Ext struct { |
| 5 | // 组织名称 | 5 | // 组织名称 |
| 6 | OrgName string `json:"orgName,omitempty"` | 6 | OrgName string `json:"orgName,omitempty"` |
| 7 | + | ||
| 8 | + // 设备扩展数据 | ||
| 9 | + DeviceExt *DeviceExt `json:"deviceExt"` | ||
| 7 | } | 10 | } |
| 8 | 11 | ||
| 9 | func NewExt(orgName string) *Ext { | 12 | func NewExt(orgName string) *Ext { |
| @@ -11,3 +14,8 @@ func NewExt(orgName string) *Ext { | @@ -11,3 +14,8 @@ func NewExt(orgName string) *Ext { | ||
| 11 | OrgName: orgName, | 14 | OrgName: orgName, |
| 12 | } | 15 | } |
| 13 | } | 16 | } |
| 17 | + | ||
| 18 | +func (e *Ext) WithDeviceExt(deviceExt *DeviceExt) *Ext { | ||
| 19 | + e.DeviceExt = deviceExt | ||
| 20 | + return e | ||
| 21 | +} |
| @@ -90,7 +90,7 @@ func (controller *ProductPlanController) Switch() { | @@ -90,7 +90,7 @@ func (controller *ProductPlanController) Switch() { | ||
| 90 | productPlanService := service.NewProductPlanService(nil) | 90 | productPlanService := service.NewProductPlanService(nil) |
| 91 | switchCommand := &command.SwitchCommand{} | 91 | switchCommand := &command.SwitchCommand{} |
| 92 | Must(controller.Unmarshal(switchCommand)) | 92 | Must(controller.Unmarshal(switchCommand)) |
| 93 | - data, err := productPlanService.Switch(switchCommand) | 93 | + data, err := productPlanService.Exchange(switchCommand) |
| 94 | controller.Response(data, err) | 94 | controller.Response(data, err) |
| 95 | } | 95 | } |
| 96 | 96 |
-
请 注册 或 登录 后发表评论