Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-manufacture into dev # Conflicts: # main.go
正在显示
42 个修改的文件
包含
764 行增加
和
165 行删除
@@ -5,6 +5,7 @@ go 1.16 | @@ -5,6 +5,7 @@ go 1.16 | ||
5 | require ( | 5 | require ( |
6 | github.com/ajg/form v1.5.1 // indirect | 6 | github.com/ajg/form v1.5.1 // indirect |
7 | github.com/beego/beego/v2 v2.0.1 | 7 | github.com/beego/beego/v2 v2.0.1 |
8 | + github.com/eclipse/paho.mqtt.golang v1.3.5 | ||
8 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect | 9 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect |
9 | github.com/fatih/structs v1.1.0 // indirect | 10 | github.com/fatih/structs v1.1.0 // indirect |
10 | github.com/gavv/httpexpect v2.0.0+incompatible | 11 | github.com/gavv/httpexpect v2.0.0+incompatible |
@@ -68,6 +68,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8 | @@ -68,6 +68,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8 | ||
68 | github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= | 68 | github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= |
69 | github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= | 69 | github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= |
70 | github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= | 70 | github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= |
71 | +github.com/eclipse/paho.mqtt.golang v1.3.5 h1:sWtmgNxYM9P2sP+xEItMozsR3w0cqZFlqnNN1bdl41Y= | ||
72 | +github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc= | ||
71 | github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= | 73 | github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= |
72 | github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI= | 74 | github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI= |
73 | github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= | 75 | github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= |
@@ -474,6 +476,7 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL | @@ -474,6 +476,7 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL | ||
474 | golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | 476 | golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
475 | golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | 477 | golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
476 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | 478 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
479 | +golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= | ||
477 | golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= | 480 | golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= |
478 | golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= | 481 | golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= |
479 | golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | 482 | golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= |
@@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" |
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" |
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" |
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/mqtt" | ||
11 | 12 | ||
12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/crontab" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/crontab" |
13 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | 14 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" |
@@ -32,11 +33,10 @@ func main() { | @@ -32,11 +33,10 @@ func main() { | ||
32 | }) | 33 | }) |
33 | log.Logger.AddHook(bw) | 34 | log.Logger.AddHook(bw) |
34 | redis.InitRedis() | 35 | redis.InitRedis() |
35 | - //设置定时任务 | 36 | + go mqtt.Start() |
36 | cron := crontab.NewCrontabService(nil) | 37 | cron := crontab.NewCrontabService(nil) |
37 | cron.StartCrontabTask() | 38 | cron.StartCrontabTask() |
38 | defer cron.StopCrontabTask() | 39 | defer cron.StopCrontabTask() |
39 | - // | ||
40 | log.Logger.Info("server start!") | 40 | log.Logger.Info("server start!") |
41 | web.Run() | 41 | web.Run() |
42 | } | 42 | } |
@@ -79,7 +79,7 @@ func FastPgWorkstation(transactionContext application.TransactionContext, worksh | @@ -79,7 +79,7 @@ func FastPgWorkstation(transactionContext application.TransactionContext, worksh | ||
79 | 79 | ||
80 | if mod, err = rep.FindOne(map[string]interface{}{"workshopId": workshopId}); err != nil { | 80 | if mod, err = rep.FindOne(map[string]interface{}{"workshopId": workshopId}); err != nil { |
81 | if err == domain.ErrorNotFound { | 81 | if err == domain.ErrorNotFound { |
82 | - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间不存在") | 82 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该工作位置不存在") |
83 | } | 83 | } |
84 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 84 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
85 | } | 85 | } |
@@ -113,7 +113,7 @@ func FastPgProductJob(transactionContext application.TransactionContext, id int, | @@ -113,7 +113,7 @@ func FastPgProductJob(transactionContext application.TransactionContext, id int, | ||
113 | if id > 0 { | 113 | if id > 0 { |
114 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { | 114 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { |
115 | if err == domain.ErrorNotFound { | 115 | if err == domain.ErrorNotFound { |
116 | - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间不存在") | 116 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该工位不存在") |
117 | } | 117 | } |
118 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 118 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
119 | } | 119 | } |
@@ -142,7 +142,7 @@ func FastPgProductGroup(transactionContext application.TransactionContext, id in | @@ -142,7 +142,7 @@ func FastPgProductGroup(transactionContext application.TransactionContext, id in | ||
142 | if id > 0 { | 142 | if id > 0 { |
143 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { | 143 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { |
144 | if err == domain.ErrorNotFound { | 144 | if err == domain.ErrorNotFound { |
145 | - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间不存在") | 145 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该生产班组不存在") |
146 | } | 146 | } |
147 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 147 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
148 | } | 148 | } |
@@ -171,7 +171,7 @@ func FastPgProduct(transactionContext application.TransactionContext, id int, op | @@ -171,7 +171,7 @@ func FastPgProduct(transactionContext application.TransactionContext, id int, op | ||
171 | if id > 0 { | 171 | if id > 0 { |
172 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { | 172 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { |
173 | if err == domain.ErrorNotFound { | 173 | if err == domain.ErrorNotFound { |
174 | - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间不存在") | 174 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该产品不存在") |
175 | } | 175 | } |
176 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 176 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
177 | } | 177 | } |
@@ -197,7 +197,7 @@ func FastPgDevice(transactionContext application.TransactionContext, id int, opt | @@ -197,7 +197,7 @@ func FastPgDevice(transactionContext application.TransactionContext, id int, opt | ||
197 | if id > 0 { | 197 | if id > 0 { |
198 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { | 198 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { |
199 | if err == domain.ErrorNotFound { | 199 | if err == domain.ErrorNotFound { |
200 | - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间不存在") | 200 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该设备档案不存在") |
201 | } | 201 | } |
202 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 202 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
203 | } | 203 | } |
@@ -223,7 +223,7 @@ func FastPgProductCalendar(transactionContext application.TransactionContext, id | @@ -223,7 +223,7 @@ func FastPgProductCalendar(transactionContext application.TransactionContext, id | ||
223 | if id > 0 { | 223 | if id > 0 { |
224 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { | 224 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { |
225 | if err == domain.ErrorNotFound { | 225 | if err == domain.ErrorNotFound { |
226 | - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间不存在") | 226 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间日历不存在") |
227 | } | 227 | } |
228 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 228 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
229 | } | 229 | } |
@@ -249,7 +249,7 @@ func FastPgUnitConversion(transactionContext application.TransactionContext, id | @@ -249,7 +249,7 @@ func FastPgUnitConversion(transactionContext application.TransactionContext, id | ||
249 | if id > 0 { | 249 | if id > 0 { |
250 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { | 250 | if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { |
251 | if err == domain.ErrorNotFound { | 251 | if err == domain.ErrorNotFound { |
252 | - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间不存在") | 252 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该单位换算不存在") |
253 | } | 253 | } |
254 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 254 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
255 | } | 255 | } |
@@ -273,9 +273,9 @@ func FastPgProductPlan(transactionContext application.TransactionContext, id int | @@ -273,9 +273,9 @@ func FastPgProductPlan(transactionContext application.TransactionContext, id int | ||
273 | rep = value | 273 | rep = value |
274 | } | 274 | } |
275 | if id > 0 { | 275 | if id > 0 { |
276 | - if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { | 276 | + if mod, err = rep.FindOne(map[string]interface{}{"productPlanId": id}); err != nil { |
277 | if err == domain.ErrorNotFound { | 277 | if err == domain.ErrorNotFound { |
278 | - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间不存在") | 278 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该生产计划不存在") |
279 | } | 279 | } |
280 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 280 | return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
281 | } | 281 | } |
1 | +package dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | + "strings" | ||
6 | +) | ||
7 | + | ||
8 | +// 生产班组员工 | ||
9 | +type ProductGroupEmployeesDto struct { | ||
10 | + // 用户Id 用户唯一标识 | ||
11 | + UserId int `json:"userId,omitempty"` | ||
12 | + // 用户姓名 | ||
13 | + UserName string `json:"userName,omitempty"` | ||
14 | + // 班组名称 | ||
15 | + GroupName string `json:"groupName,omitempty"` | ||
16 | + // 上班班次 1:全天 2:白班 4:中班 8:夜班 | ||
17 | + WorkOnDescription string `json:"workOn,omitempty"` | ||
18 | + // 工作位置键值 (车间ID+'.'+生产线ID+'.'+工段ID) | ||
19 | + //WorkStationId string `json:"workStationId,omitempty"` | ||
20 | +} | ||
21 | + | ||
22 | +func NewProductGroupEmployeesDto(group *domain.ProductGroup) []*ProductGroupEmployeesDto { | ||
23 | + employees := make([]*ProductGroupEmployeesDto, 0) | ||
24 | + if group.GroupLeader != nil { | ||
25 | + employees = append(employees, NewGroupEmployee(group, group.GroupLeader)) | ||
26 | + } | ||
27 | + for i := range group.GroupMembers { | ||
28 | + employees = append(employees, NewGroupEmployee(group, group.GroupMembers[i])) | ||
29 | + } | ||
30 | + return employees | ||
31 | +} | ||
32 | + | ||
33 | +func NewGroupEmployee(group *domain.ProductGroup, u *domain.User) *ProductGroupEmployeesDto { | ||
34 | + item := &ProductGroupEmployeesDto{} | ||
35 | + item.UserId = u.UserId | ||
36 | + item.UserName = u.UserName | ||
37 | + item.GroupName = group.GroupName | ||
38 | + workOns := domain.WorkOnDescription(group.WorkOn) | ||
39 | + item.WorkOnDescription = strings.Join(workOns, ",") | ||
40 | + //item.WorkStationId = group.WorkStation.WorkStationId | ||
41 | + return item | ||
42 | +} | ||
43 | + | ||
44 | +type ProductGroupEmployeesDtos struct { | ||
45 | + Result []*ProductGroupEmployeesDto | ||
46 | + MapResult map[int]*ProductGroupEmployeesDto | ||
47 | +} | ||
48 | + | ||
49 | +func (d *ProductGroupEmployeesDtos) Append(items ...*ProductGroupEmployeesDto) { | ||
50 | + for i := range items { | ||
51 | + if _, ok := d.MapResult[items[i].UserId]; ok { | ||
52 | + continue | ||
53 | + } | ||
54 | + d.MapResult[items[i].UserId] = items[i] | ||
55 | + d.Result = append(d.Result, items[i]) | ||
56 | + } | ||
57 | +} | ||
58 | + | ||
59 | +func (d *ProductGroupEmployeesDtos) LoadDto(groups ...*domain.ProductGroup) { | ||
60 | + for i := range groups { | ||
61 | + items := NewProductGroupEmployeesDto(groups[i]) | ||
62 | + d.Append(items...) | ||
63 | + } | ||
64 | +} | ||
65 | + | ||
66 | +func NewProductGroupEmployeesDtos() *ProductGroupEmployeesDtos { | ||
67 | + return &ProductGroupEmployeesDtos{ | ||
68 | + Result: make([]*ProductGroupEmployeesDto, 0), | ||
69 | + MapResult: make(map[int]*ProductGroupEmployeesDto), | ||
70 | + } | ||
71 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | +) | ||
9 | + | ||
10 | +type SearchProductGroupEmployeesQuery struct { | ||
11 | + // 查询偏离量 | ||
12 | + //Offset int `cname:"查询偏离量" json:"offset"` | ||
13 | + // 查询限制 | ||
14 | + //Limit int `cname:"查询限制" json:"limit"` | ||
15 | + // 页码 | ||
16 | + //PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | ||
17 | + // 页数 | ||
18 | + //PageSize int `cname:"页数" json:"pageSize,omitempty"` | ||
19 | + // 当前公司 | ||
20 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
21 | + // 当前登录的组织 | ||
22 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"` | ||
23 | + // 车间ID | ||
24 | + WorkshopId int `cname:"车间ID" json: workshopId,omitempty"` | ||
25 | + // 生产线ID | ||
26 | + LineId int `cname:"生产线ID" json:"lineId,omitempty"` | ||
27 | + // 工段ID | ||
28 | + SectionId int `json:"sectionId,omitempty"` | ||
29 | +} | ||
30 | + | ||
31 | +func (listProductGroupQuery *SearchProductGroupEmployeesQuery) Valid(validation *validation.Validation) { | ||
32 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
33 | +} | ||
34 | + | ||
35 | +func (listProductGroupQuery *SearchProductGroupEmployeesQuery) ValidateQuery() error { | ||
36 | + valid := validation.Validation{} | ||
37 | + b, err := valid.Valid(listProductGroupQuery) | ||
38 | + if err != nil { | ||
39 | + return err | ||
40 | + } | ||
41 | + if !b { | ||
42 | + elem := reflect.TypeOf(listProductGroupQuery).Elem() | ||
43 | + for _, validErr := range valid.Errors { | ||
44 | + field, isExist := elem.FieldByName(validErr.Field) | ||
45 | + if isExist { | ||
46 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
47 | + } else { | ||
48 | + return fmt.Errorf(validErr.Message) | ||
49 | + } | ||
50 | + } | ||
51 | + } | ||
52 | + return nil | ||
53 | +} |
@@ -367,6 +367,48 @@ func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo * | @@ -367,6 +367,48 @@ func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo * | ||
367 | return count, results, nil | 367 | return count, results, nil |
368 | } | 368 | } |
369 | 369 | ||
370 | +// 返回生产班组服务列表 | ||
371 | +func (productGroupService *ProductGroupService) SearchProductGroupEmployees(operateInfo *domain.OperateInfo, cmd *query.SearchProductGroupEmployeesQuery) (int64, interface{}, error) { | ||
372 | + if err := cmd.ValidateQuery(); err != nil { | ||
373 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
374 | + } | ||
375 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
376 | + if err != nil { | ||
377 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
378 | + } | ||
379 | + if err := transactionContext.StartTransaction(); err != nil { | ||
380 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
381 | + } | ||
382 | + defer func() { | ||
383 | + transactionContext.RollbackTransaction() | ||
384 | + }() | ||
385 | + | ||
386 | + //workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId) | ||
387 | + queryOptions := utils.ObjectToMap(cmd) | ||
388 | + //queryOptions = workshops.FindByNameWithQuery(queryOptions, cmd.WorkshopName, cmd.LineName, "") | ||
389 | + | ||
390 | + var productGroupRepository domain.ProductGroupRepository | ||
391 | + productGroupRepository, _, _ = factory.FastPgProductGroup(transactionContext, 0) | ||
392 | + _, productGroups, err := productGroupRepository.Find(queryOptions) | ||
393 | + if err != nil { | ||
394 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
395 | + } | ||
396 | + var results = dto.NewProductGroupEmployeesDtos() | ||
397 | + for i := range productGroups { | ||
398 | + item := productGroups[i] | ||
399 | + //workStation := workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | ||
400 | + //item.WorkStation = workStation | ||
401 | + items := dto.NewProductGroupEmployeesDto(item) | ||
402 | + results.Append(items...) | ||
403 | + } | ||
404 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
405 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
406 | + } | ||
407 | + return int64(len(results.Result)), map[string]interface{}{ | ||
408 | + "employees": results.Result, | ||
409 | + }, nil | ||
410 | +} | ||
411 | + | ||
370 | func NewProductGroupService(options map[string]interface{}) *ProductGroupService { | 412 | func NewProductGroupService(options map[string]interface{}) *ProductGroupService { |
371 | newProductGroupService := &ProductGroupService{} | 413 | newProductGroupService := &ProductGroupService{} |
372 | return newProductGroupService | 414 | return newProductGroupService |
@@ -14,7 +14,7 @@ type SetOnlineCommand struct { | @@ -14,7 +14,7 @@ type SetOnlineCommand struct { | ||
14 | // 车间ID | 14 | // 车间ID |
15 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 15 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` |
16 | // 生产线ID | 16 | // 生产线ID |
17 | - LineId int `cname:"生产线ID" json:"lineId" valid:"Required"` | 17 | + //LineId int `cname:"生产线ID" json:"lineId" valid:"Required"` |
18 | // 工段ID | 18 | // 工段ID |
19 | SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` | 19 | SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` |
20 | } | 20 | } |
@@ -39,7 +39,7 @@ type UpdateProductPlanCommand struct { | @@ -39,7 +39,7 @@ type UpdateProductPlanCommand struct { | ||
39 | // 备注 | 39 | // 备注 |
40 | Remark string `cname:"备注" json:"remark" valid:"Required"` | 40 | Remark string `cname:"备注" json:"remark" valid:"Required"` |
41 | // 生产日期 | 41 | // 生产日期 |
42 | - ProductDateTime time.Time `cname:"生产日期" json:"-" ` | 42 | + ProductDateTime time.Time `cname:"生产日期" json:"productDateTime" ` |
43 | } | 43 | } |
44 | 44 | ||
45 | func (updateProductPlanCommand *UpdateProductPlanCommand) Valid(validation *validation.Validation) { | 45 | func (updateProductPlanCommand *UpdateProductPlanCommand) Valid(validation *validation.Validation) { |
@@ -19,7 +19,7 @@ type SearchProductPlanQuery struct { | @@ -19,7 +19,7 @@ type SearchProductPlanQuery struct { | ||
19 | // 当前登录的组织 | 19 | // 当前登录的组织 |
20 | OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"` | 20 | OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"` |
21 | // 匹配多个组织 | 21 | // 匹配多个组织 |
22 | - InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty" valid:"Required"` | 22 | + InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty"` |
23 | // 页码 | 23 | // 页码 |
24 | PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | 24 | PageNumber int `cname:"页码" json:"pageNumber,omitempty"` |
25 | // 页数 | 25 | // 页数 |
@@ -256,15 +256,28 @@ func (productPlanService *ProductPlanService) SetOffline(setOfflineCommand *comm | @@ -256,15 +256,28 @@ func (productPlanService *ProductPlanService) SetOffline(setOfflineCommand *comm | ||
256 | defer func() { | 256 | defer func() { |
257 | transactionContext.RollbackTransaction() | 257 | transactionContext.RollbackTransaction() |
258 | }() | 258 | }() |
259 | + | ||
260 | + var productPlanRepository domain.ProductPlanRepository | ||
261 | + var productPlan *domain.ProductPlan | ||
262 | + productPlanRepository, productPlan, _ = factory.FastPgProductPlan(transactionContext, setOfflineCommand.ProductPlanId) | ||
263 | + | ||
264 | + if err = productPlan.ChangeStatus(domain.PlanOffline); err != nil { | ||
265 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
266 | + } | ||
267 | + | ||
268 | + if productPlan, err = productPlanRepository.Save(productPlan); err != nil { | ||
269 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
270 | + } | ||
271 | + | ||
259 | if err := transactionContext.CommitTransaction(); err != nil { | 272 | if err := transactionContext.CommitTransaction(); err != nil { |
260 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 273 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
261 | } | 274 | } |
262 | - return nil, nil | 275 | + return productPlan, nil |
263 | } | 276 | } |
264 | 277 | ||
265 | // 计划上线 | 278 | // 计划上线 |
266 | -func (productPlanService *ProductPlanService) SetOnline(setOnlineCommand *command.SetOnlineCommand) (interface{}, error) { | ||
267 | - if err := setOnlineCommand.ValidateCommand(); err != nil { | 279 | +func (productPlanService *ProductPlanService) SetOnline(cmd *command.SetOnlineCommand) (interface{}, error) { |
280 | + if err := cmd.ValidateCommand(); err != nil { | ||
268 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 281 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
269 | } | 282 | } |
270 | transactionContext, err := factory.CreateTransactionContext(nil) | 283 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -277,10 +290,45 @@ func (productPlanService *ProductPlanService) SetOnline(setOnlineCommand *comman | @@ -277,10 +290,45 @@ func (productPlanService *ProductPlanService) SetOnline(setOnlineCommand *comman | ||
277 | defer func() { | 290 | defer func() { |
278 | transactionContext.RollbackTransaction() | 291 | transactionContext.RollbackTransaction() |
279 | }() | 292 | }() |
293 | + var productPlanRepository domain.ProductPlanRepository | ||
294 | + var productPlan *domain.ProductPlan | ||
295 | + | ||
296 | + productPlanRepository, productPlan, err = factory.FastPgProductPlan(transactionContext, cmd.ProductPlanId) | ||
297 | + if err != nil { | ||
298 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
299 | + } | ||
300 | + | ||
301 | + if err = productPlan.ChangeStatus(domain.PlanOnline); err != nil { | ||
302 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
303 | + } | ||
304 | + | ||
305 | + var workshop *domain.Workshop | ||
306 | + _, workshop, err = factory.FastPgWorkshop(transactionContext, cmd.WorkshopId) | ||
307 | + if err != nil { | ||
308 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
309 | + } | ||
310 | + | ||
311 | + line, section, err := workshop.FindSectionById(cmd.SectionId) | ||
312 | + if err != nil { | ||
313 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
314 | + } | ||
315 | + | ||
316 | + var workStation *domain.WorkStation | ||
317 | + workStation, err = workshop.FindWorkStation(workshop.WorkshopId, line.LineId, section.SectionId) | ||
318 | + if err != nil { | ||
319 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
320 | + } | ||
321 | + | ||
322 | + productPlan.WorkStation = workStation | ||
323 | + | ||
324 | + if productPlan, err = productPlanRepository.Save(productPlan); err != nil { | ||
325 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
326 | + } | ||
327 | + | ||
280 | if err := transactionContext.CommitTransaction(); err != nil { | 328 | if err := transactionContext.CommitTransaction(); err != nil { |
281 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 329 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
282 | } | 330 | } |
283 | - return nil, nil | 331 | + return productPlan, nil |
284 | } | 332 | } |
285 | 333 | ||
286 | // 提交成品记录 (成品 二级品) | 334 | // 提交成品记录 (成品 二级品) |
@@ -319,15 +367,49 @@ func (productPlanService *ProductPlanService) Exchange(switchCommand *command.Sw | @@ -319,15 +367,49 @@ func (productPlanService *ProductPlanService) Exchange(switchCommand *command.Sw | ||
319 | defer func() { | 367 | defer func() { |
320 | transactionContext.RollbackTransaction() | 368 | transactionContext.RollbackTransaction() |
321 | }() | 369 | }() |
370 | + var fromPlan, toPlan *domain.ProductPlan | ||
371 | + var productPlanRepository domain.ProductPlanRepository | ||
372 | + productPlanRepository, fromPlan, err = factory.FastPgProductPlan(transactionContext, switchCommand.FromProductPlanId) | ||
373 | + if err != nil { | ||
374 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
375 | + } | ||
376 | + _, toPlan, err = factory.FastPgProductPlan(transactionContext, switchCommand.ToProductPlanId) | ||
377 | + if err != nil { | ||
378 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
379 | + } | ||
380 | + | ||
381 | + // 计划下线 | ||
382 | + if err = fromPlan.ChangeStatus(domain.PlanOffline); err != nil { | ||
383 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
384 | + } | ||
385 | + if _, err = productPlanRepository.Save(fromPlan); err != nil { | ||
386 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
387 | + } | ||
388 | + | ||
389 | + var workStation *domain.WorkStation | ||
390 | + fromWorkStation := fromPlan.WorkStation | ||
391 | + _, workStation, err = factory.FastPgWorkstation(transactionContext, fromWorkStation.WorkshopId, fromWorkStation.LineId, fromWorkStation.SectionId) | ||
392 | + if err != nil { | ||
393 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
394 | + } | ||
395 | + // 计划上线 | ||
396 | + toPlan.WorkStation = workStation | ||
397 | + if err = toPlan.ChangeStatus(domain.PlanOnline); err != nil { | ||
398 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
399 | + } | ||
400 | + if _, err = productPlanRepository.Save(toPlan); err != nil { | ||
401 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
402 | + } | ||
403 | + | ||
322 | if err := transactionContext.CommitTransaction(); err != nil { | 404 | if err := transactionContext.CommitTransaction(); err != nil { |
323 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 405 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
324 | } | 406 | } |
325 | - return nil, nil | 407 | + return struct{}{}, nil |
326 | } | 408 | } |
327 | 409 | ||
328 | // 更新生产计划服务 | 410 | // 更新生产计划服务 |
329 | -func (productPlanService *ProductPlanService) UpdateProductPlan(updateProductPlanCommand *command.UpdateProductPlanCommand) (interface{}, error) { | ||
330 | - if err := updateProductPlanCommand.ValidateCommand(); err != nil { | 411 | +func (productPlanService *ProductPlanService) UpdateProductPlan(cmd *command.UpdateProductPlanCommand) (interface{}, error) { |
412 | + if err := cmd.ValidateCommand(); err != nil { | ||
331 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 413 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
332 | } | 414 | } |
333 | transactionContext, err := factory.CreateTransactionContext(nil) | 415 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -341,31 +423,38 @@ func (productPlanService *ProductPlanService) UpdateProductPlan(updateProductPla | @@ -341,31 +423,38 @@ func (productPlanService *ProductPlanService) UpdateProductPlan(updateProductPla | ||
341 | transactionContext.RollbackTransaction() | 423 | transactionContext.RollbackTransaction() |
342 | }() | 424 | }() |
343 | var productPlanRepository domain.ProductPlanRepository | 425 | var productPlanRepository domain.ProductPlanRepository |
344 | - if value, err := factory.CreateProductPlanRepository(map[string]interface{}{ | ||
345 | - "transactionContext": transactionContext, | ||
346 | - }); err != nil { | 426 | + var productPlan *domain.ProductPlan |
427 | + productPlanRepository, productPlan, err = factory.FastPgProductPlan(transactionContext, cmd.ProductPlanId) | ||
428 | + if err != nil { | ||
347 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 429 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
348 | - } else { | ||
349 | - productPlanRepository = value | ||
350 | } | 430 | } |
351 | - productPlan, err := productPlanRepository.FindOne(map[string]interface{}{"productPlanId": updateProductPlanCommand.ProductPlanId}) | 431 | + |
432 | + //if productPlan.Workshop.WorkshopId != cmd.WorkshopId{ | ||
433 | + // // 检查批次号是否有重复的 | ||
434 | + // if item, err := productPlanRepository.FindOne(map[string]interface{}{"companyId": cmd.CompanyId, "orgId": cmd.OrgId, "batchNumber": cmd.BatchNumber}); err == nil && item != nil { | ||
435 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "批次号重复") | ||
436 | + // } | ||
437 | + //} | ||
438 | + | ||
439 | + _, workshop, err := factory.FastPgWorkshop(transactionContext, cmd.WorkshopId) | ||
352 | if err != nil { | 440 | if err != nil { |
353 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 441 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
354 | } | 442 | } |
355 | - if productPlan == nil { | ||
356 | - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateProductPlanCommand.ProductPlanId))) | ||
357 | - } | ||
358 | - if err := productPlan.Update(tool_funs.SimpleStructToMap(updateProductPlanCommand)); err != nil { | 443 | + productPlan.Workshop = workshop.CloneSample() |
444 | + | ||
445 | + if err := productPlan.Update(tool_funs.SimpleStructToMap(cmd)); err != nil { | ||
359 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 446 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
360 | } | 447 | } |
361 | - if productPlan, err := productPlanRepository.Save(productPlan); err != nil { | 448 | + if productPlan, err = productPlanRepository.Save(productPlan); err != nil { |
362 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 449 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
363 | - } else { | ||
364 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
365 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
366 | - } | ||
367 | - return productPlan, nil | ||
368 | } | 450 | } |
451 | + | ||
452 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
453 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
454 | + } | ||
455 | + | ||
456 | + result := &dto.ProductPlanDto{} | ||
457 | + return result.LoadDto(productPlan, cmd.OrgId), nil | ||
369 | } | 458 | } |
370 | 459 | ||
371 | // 搜索生产计划服务列表 | 460 | // 搜索生产计划服务列表 |
1 | +package dto | ||
2 | + | ||
3 | +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
4 | + | ||
5 | +type MaterialUnitConversionDto struct { | ||
6 | + // 单位换算ID | ||
7 | + UnitConversionId int `json:"unitConversionId,omitempty"` | ||
8 | + // 物料名称 | ||
9 | + MaterialName string `json:"materialName,omitempty"` | ||
10 | + // 转换前单位数量 | ||
11 | + FromUnitQuantity *domain.UnitQuantity `json:"fromUnitQuantity,omitempty"` | ||
12 | + // 转换后单位数量 | ||
13 | + ToUnitQuantity *domain.UnitQuantity `json:"toUnitQuantity,omitempty"` | ||
14 | +} | ||
15 | + | ||
16 | +func (d *MaterialUnitConversionDto) LoadDto(m *domain.UnitConversion) *MaterialUnitConversionDto { | ||
17 | + d.UnitConversionId = m.UnitConversionId | ||
18 | + d.MaterialName = m.Material.MaterialName | ||
19 | + d.FromUnitQuantity = m.FromUnitQuantity | ||
20 | + d.ToUnitQuantity = m.ToUnitQuantity | ||
21 | + return d | ||
22 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | +) | ||
9 | + | ||
10 | +type SearchMaterialsQuery struct { | ||
11 | + // 当前公司 | ||
12 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
13 | + // 当前登录的组织 | ||
14 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"` | ||
15 | + // 车间ID | ||
16 | + WorkshopId int `cname:"车间ID" json: workshopId,omitempty"` | ||
17 | + // 生产线ID | ||
18 | + LineId int `cname:"生产线ID" json:"lineId,omitempty"` | ||
19 | + // 工段ID | ||
20 | + SectionId int `json:"sectionId,omitempty"` | ||
21 | +} | ||
22 | + | ||
23 | +func (listProductGroupQuery *SearchMaterialsQuery) Valid(validation *validation.Validation) { | ||
24 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
25 | +} | ||
26 | + | ||
27 | +func (listProductGroupQuery *SearchMaterialsQuery) ValidateQuery() error { | ||
28 | + valid := validation.Validation{} | ||
29 | + b, err := valid.Valid(listProductGroupQuery) | ||
30 | + if err != nil { | ||
31 | + return err | ||
32 | + } | ||
33 | + if !b { | ||
34 | + elem := reflect.TypeOf(listProductGroupQuery).Elem() | ||
35 | + for _, validErr := range valid.Errors { | ||
36 | + field, isExist := elem.FieldByName(validErr.Field) | ||
37 | + if isExist { | ||
38 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
39 | + } else { | ||
40 | + return fmt.Errorf(validErr.Message) | ||
41 | + } | ||
42 | + } | ||
43 | + } | ||
44 | + return nil | ||
45 | +} |
@@ -307,6 +307,42 @@ func (unitConversionService *UnitConversionService) SearchUnitConversion(operate | @@ -307,6 +307,42 @@ func (unitConversionService *UnitConversionService) SearchUnitConversion(operate | ||
307 | return count, result, nil | 307 | return count, result, nil |
308 | } | 308 | } |
309 | 309 | ||
310 | +// 返回单位换算服务列表 | ||
311 | +func (unitConversionService *UnitConversionService) SearchMaterial(operateInfo *domain.OperateInfo, listUnitConversionQuery *query.SearchMaterialsQuery) (int64, interface{}, error) { | ||
312 | + if err := listUnitConversionQuery.ValidateQuery(); err != nil { | ||
313 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
314 | + } | ||
315 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
316 | + if err != nil { | ||
317 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
318 | + } | ||
319 | + if err := transactionContext.StartTransaction(); err != nil { | ||
320 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
321 | + } | ||
322 | + defer func() { | ||
323 | + transactionContext.RollbackTransaction() | ||
324 | + }() | ||
325 | + unitConversionRepository, _, _ := factory.FastPgUnitConversion(transactionContext, 0) | ||
326 | + count, unitConversions, err := unitConversionRepository.Find(utils.ObjectToMap(listUnitConversionQuery)) | ||
327 | + if err != nil { | ||
328 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
329 | + } | ||
330 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
331 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
332 | + } | ||
333 | + | ||
334 | + var result = make([]*dto.MaterialUnitConversionDto, 0) | ||
335 | + for i := range unitConversions { | ||
336 | + item := unitConversions[i] | ||
337 | + newItem := &dto.MaterialUnitConversionDto{} | ||
338 | + newItem.LoadDto(item) | ||
339 | + result = append(result, newItem) | ||
340 | + } | ||
341 | + return count, map[string]interface{}{ | ||
342 | + "materials": result, | ||
343 | + }, nil | ||
344 | +} | ||
345 | + | ||
310 | func NewUnitConversionService(options map[string]interface{}) *UnitConversionService { | 346 | func NewUnitConversionService(options map[string]interface{}) *UnitConversionService { |
311 | newUnitConversionService := &UnitConversionService{} | 347 | newUnitConversionService := &UnitConversionService{} |
312 | return newUnitConversionService | 348 | return newUnitConversionService |
@@ -326,6 +326,38 @@ func (workshopService *WorkshopService) SelectorWorkshop(operateInfo *domain.Ope | @@ -326,6 +326,38 @@ func (workshopService *WorkshopService) SelectorWorkshop(operateInfo *domain.Ope | ||
326 | 326 | ||
327 | } | 327 | } |
328 | 328 | ||
329 | +// 车间工段列表 | ||
330 | +func (workshopService *WorkshopService) SelectorWorkshopSection(operateInfo *domain.OperateInfo, getWorkshopQuery *query.GetWorkshopQuery) (interface{}, error) { | ||
331 | + if err := getWorkshopQuery.ValidateQuery(); err != nil { | ||
332 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
333 | + } | ||
334 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
335 | + if err != nil { | ||
336 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
337 | + } | ||
338 | + if err := transactionContext.StartTransaction(); err != nil { | ||
339 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
340 | + } | ||
341 | + defer func() { | ||
342 | + transactionContext.RollbackTransaction() | ||
343 | + }() | ||
344 | + | ||
345 | + var workshop *domain.Workshop | ||
346 | + _, workshop, err = factory.FastPgWorkshop(transactionContext, getWorkshopQuery.WorkshopId) | ||
347 | + if err != nil { | ||
348 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
349 | + } | ||
350 | + | ||
351 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
352 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
353 | + } | ||
354 | + sections := workshop.AllProductSections(domain.All) | ||
355 | + return map[string]interface{}{ | ||
356 | + "count": len(sections), | ||
357 | + "sections": sections, | ||
358 | + }, nil | ||
359 | +} | ||
360 | + | ||
329 | func NewWorkshopService(options map[string]interface{}) *WorkshopService { | 361 | func NewWorkshopService(options map[string]interface{}) *WorkshopService { |
330 | newWorkshopService := &WorkshopService{} | 362 | newWorkshopService := &WorkshopService{} |
331 | return newWorkshopService | 363 | return newWorkshopService |
pkg/constant/mqtt.go
0 → 100644
1 | +package constant | ||
2 | + | ||
3 | +import "os" | ||
4 | + | ||
5 | +//设备商提供的测试地址 | ||
6 | +var MQTT_HOST = "175.24.122.87" | ||
7 | +//内网测试地址 | ||
8 | +//var MQTT_HOST = "192.168.100.222" | ||
9 | +var MQTT_PORT = "1883" | ||
10 | + | ||
11 | +var MQTT_USER = "" | ||
12 | + | ||
13 | +var MQTT_PASSWORD = "" | ||
14 | + | ||
15 | +func init(){ | ||
16 | + if os.Getenv("MQTT_HOST") != "" { | ||
17 | + MQTT_HOST = os.Getenv("MQTT_HOST") | ||
18 | + } | ||
19 | + if os.Getenv("MQTT_PORT") != "" { | ||
20 | + MQTT_PORT = os.Getenv("MQTT_PORT") | ||
21 | + } | ||
22 | + if os.Getenv("MQTT_USER") != "" { | ||
23 | + MQTT_USER = os.Getenv("MQTT_USER") | ||
24 | + } | ||
25 | + if os.Getenv("MQTT_PASSWORD") != "" { | ||
26 | + MQTT_PASSWORD = os.Getenv("MQTT_PASSWORD") | ||
27 | + } | ||
28 | +} |
1 | package domain | 1 | package domain |
2 | 2 | ||
3 | +import "fmt" | ||
4 | + | ||
3 | // 生产线 | 5 | // 生产线 |
4 | type ProductLine struct { | 6 | type ProductLine struct { |
5 | // 生产线ID | 7 | // 生产线ID |
@@ -12,6 +14,17 @@ type ProductLine struct { | @@ -12,6 +14,17 @@ type ProductLine struct { | ||
12 | Removed int `json:"removed,omitempty"` | 14 | Removed int `json:"removed,omitempty"` |
13 | } | 15 | } |
14 | 16 | ||
17 | +// 查询生产线 | ||
18 | +func (productLine *ProductLine) FindSection(sectionId int) (*ProductSection, error) { | ||
19 | + for i := range productLine.ProductSections { | ||
20 | + item := productLine.ProductSections[i] | ||
21 | + if item.SectionId == sectionId { | ||
22 | + return item, nil | ||
23 | + } | ||
24 | + } | ||
25 | + return nil, fmt.Errorf("工段不存在") | ||
26 | +} | ||
27 | + | ||
15 | func (productLine *ProductLine) GetProductSections(removed int) []*ProductSection { | 28 | func (productLine *ProductLine) GetProductSections(removed int) []*ProductSection { |
16 | var result = make([]*ProductSection, 0) | 29 | var result = make([]*ProductSection, 0) |
17 | for i := range productLine.ProductSections { | 30 | for i := range productLine.ProductSections { |
1 | package domain | 1 | package domain |
2 | 2 | ||
3 | -import "time" | 3 | +import ( |
4 | + "errors" | ||
5 | + "time" | ||
6 | +) | ||
4 | 7 | ||
5 | const ( | 8 | const ( |
6 | PlanOnline = 1 // 计划上线 | 9 | PlanOnline = 1 // 计划上线 |
@@ -60,119 +63,47 @@ func (productPlan *ProductPlan) Identify() interface{} { | @@ -60,119 +63,47 @@ func (productPlan *ProductPlan) Identify() interface{} { | ||
60 | } | 63 | } |
61 | 64 | ||
62 | func (productPlan *ProductPlan) Update(data map[string]interface{}) error { | 65 | func (productPlan *ProductPlan) Update(data map[string]interface{}) error { |
63 | - //if productPlanId, ok := data["productPlanId"]; ok { | ||
64 | - // productPlan.ProductPlanId = productPlanId.(int) | ||
65 | - //} | ||
66 | - //if companyId, ok := data["companyId"]; ok { | ||
67 | - // productPlan.CompanyId = companyId.(int) | ||
68 | - //} | ||
69 | - //if orgId, ok := data["orgId"]; ok { | ||
70 | - // productPlan.OrgId = orgId.(int) | ||
71 | - //} | ||
72 | //if batchNumber, ok := data["batchNumber"]; ok { | 66 | //if batchNumber, ok := data["batchNumber"]; ok { |
73 | // productPlan.BatchNumber = batchNumber.(string) | 67 | // productPlan.BatchNumber = batchNumber.(string) |
74 | //} | 68 | //} |
75 | - //if productDate, ok := data["productDate"]; ok { | ||
76 | - // productPlan.ProductDate = productDate.(time.Time) | ||
77 | - //} | ||
78 | - //if companyId, ok := data["companyId"]; ok { | ||
79 | - // productPlan.Workshop.CompanyId = companyId.(int) | ||
80 | - //} | ||
81 | - //if orgId, ok := data["orgId"]; ok { | ||
82 | - // productPlan.Workshop.OrgId = orgId.(int) | ||
83 | - //} | ||
84 | - //if workshopId, ok := data["workshopId"]; ok { | ||
85 | - // productPlan.Workshop.WorkshopId = workshopId.(int) | ||
86 | - //} | ||
87 | - //if workshopName, ok := data["workshopName"]; ok { | ||
88 | - // productPlan.Workshop.WorkshopName = workshopName.(string) | ||
89 | - //} | ||
90 | - //if userId, ok := data["userId"]; ok { | ||
91 | - // productPlan.Workshop.Principal.UserId = userId.(int) | ||
92 | - //} | ||
93 | - //if userName, ok := data["userName"]; ok { | ||
94 | - // productPlan.Workshop.Principal.UserName = userName.(string) | ||
95 | - //} | ||
96 | - //if employeeType, ok := data["employeeType"]; ok { | ||
97 | - // productPlan.Workshop.Principal.EmployeeType = employeeType.(int) | ||
98 | - //} | ||
99 | - //if icCardNumber, ok := data["icCardNumber"]; ok { | ||
100 | - // productPlan.Workshop.Principal.IcCardNumber = icCardNumber.(string) | ||
101 | - //} | ||
102 | - //if avatar, ok := data["avatar"]; ok { | ||
103 | - // productPlan.Workshop.Principal.Avatar = avatar.(string) | ||
104 | - //} | ||
105 | - //if phone, ok := data["phone"]; ok { | ||
106 | - // productPlan.Workshop.Principal.Phone = phone.(string) | ||
107 | - //} | ||
108 | - //if productLines, ok := data["productLines"]; ok { | ||
109 | - // productPlan.Workshop.ProductLines = productLines.(array) | ||
110 | - //} | ||
111 | - //if createdAt, ok := data["createdAt"]; ok { | ||
112 | - // productPlan.Workshop.CreatedAt = createdAt.(time.Time) | ||
113 | - //} | ||
114 | - //if updatedAt, ok := data["updatedAt"]; ok { | ||
115 | - // productPlan.Workshop.UpdatedAt = updatedAt.(time.Time) | ||
116 | - //} | ||
117 | - //if deletedAt, ok := data["deletedAt"]; ok { | ||
118 | - // productPlan.Workshop.DeletedAt = deletedAt.(time.Time) | ||
119 | - //} | ||
120 | - //if workOn, ok := data["workOn"]; ok { | ||
121 | - // productPlan.WorkOn = workOn.(int) | ||
122 | - //} | ||
123 | - //if machine, ok := data["machine"]; ok { | ||
124 | - // productPlan.Machine = machine.(string) | ||
125 | - //} | ||
126 | - //if planProductName, ok := data["planProductName"]; ok { | ||
127 | - // productPlan.PlanProductName = planProductName.(string) | ||
128 | - //} | ||
129 | - //if quantity, ok := data["quantity"]; ok { | ||
130 | - // productPlan.PlanDevoted.Quantity = quantity.(float64) | ||
131 | - //} | ||
132 | - //if unit, ok := data["unit"]; ok { | ||
133 | - // productPlan.PlanDevoted.Unit = unit.(string) | ||
134 | - //} | ||
135 | - //if unitWeight, ok := data["unitWeight"]; ok { | ||
136 | - // productPlan.PlanDevoted.UnitWeight = unitWeight.(float64) | ||
137 | - //} | ||
138 | - //if weight, ok := data["weight"]; ok { | ||
139 | - // productPlan.PlanDevoted.Weight = weight.(float64) | ||
140 | - //} | ||
141 | - //if planStatus, ok := data["planStatus"]; ok { | ||
142 | - // productPlan.PlanStatus = planStatus.(int) | ||
143 | - //} | ||
144 | - //if workStationId, ok := data["workStationId"]; ok { | ||
145 | - // productPlan.WorkStation.WorkStationId = workStationId.(string) | ||
146 | - //} | ||
147 | - //if workshopId, ok := data["workshopId"]; ok { | ||
148 | - // productPlan.WorkStation.WorkshopId = workshopId.(int) | ||
149 | - //} | ||
150 | - //if workshopName, ok := data["workshopName"]; ok { | ||
151 | - // productPlan.WorkStation.WorkshopName = workshopName.(string) | ||
152 | - //} | ||
153 | - //if lineId, ok := data["lineId"]; ok { | ||
154 | - // productPlan.WorkStation.LineId = lineId.(int) | ||
155 | - //} | ||
156 | - //if lineName, ok := data["lineName"]; ok { | ||
157 | - // productPlan.WorkStation.LineName = lineName.(string) | ||
158 | - //} | ||
159 | - //if sectionId, ok := data["sectionId"]; ok { | ||
160 | - // productPlan.WorkStation.SectionId = sectionId.(int) | ||
161 | - //} | ||
162 | - //if sectionName, ok := data["sectionName"]; ok { | ||
163 | - // productPlan.WorkStation.SectionName = sectionName.(string) | ||
164 | - //} | ||
165 | - //if remark, ok := data["remark"]; ok { | ||
166 | - // productPlan.Remark = remark.(string) | ||
167 | - //} | ||
168 | - //if createdAt, ok := data["createdAt"]; ok { | ||
169 | - // productPlan.CreatedAt = createdAt.(time.Time) | ||
170 | - //} | ||
171 | - //if updatedAt, ok := data["updatedAt"]; ok { | ||
172 | - // productPlan.UpdatedAt = updatedAt.(time.Time) | ||
173 | - //} | ||
174 | - //if deletedAt, ok := data["deletedAt"]; ok { | ||
175 | - // productPlan.DeletedAt = deletedAt.(time.Time) | ||
176 | - //} | 69 | + if productDate, ok := data["productDateTime"]; ok { |
70 | + productPlan.ProductDate = productDate.(time.Time) | ||
71 | + } | ||
72 | + if workOn, ok := data["workOn"]; ok { | ||
73 | + productPlan.WorkOn = workOn.(int) | ||
74 | + } | ||
75 | + if machine, ok := data["machine"]; ok { | ||
76 | + productPlan.Machine = machine.(string) | ||
77 | + } | ||
78 | + if planProductName, ok := data["planProductName"]; ok { | ||
79 | + productPlan.PlanProductName = planProductName.(string) | ||
80 | + } | ||
81 | + if quantity, ok := data["quantity"]; ok { | ||
82 | + productPlan.PlanDevoted.Quantity = quantity.(float64) | ||
83 | + } | ||
84 | + if unit, ok := data["unit"]; ok { | ||
85 | + productPlan.PlanDevoted.Unit = unit.(string) | ||
86 | + } | ||
87 | + if weight, ok := data["weight"]; ok { | ||
88 | + productPlan.PlanDevoted.Weight = weight.(float64) | ||
89 | + } | ||
90 | + if remark, ok := data["remark"]; ok { | ||
91 | + productPlan.Remark = remark.(string) | ||
92 | + } | ||
93 | + productPlan.UpdatedAt = time.Now() | ||
94 | + return nil | ||
95 | +} | ||
96 | + | ||
97 | +func (productPlan *ProductPlan) ChangeStatus(status int) error { | ||
98 | + if productPlan.PlanStatus == status && status == PlanOnline { | ||
99 | + return errors.New("计划已经上线") | ||
100 | + } | ||
101 | + if productPlan.PlanStatus == status && status == PlanOffline { | ||
102 | + return errors.New("计划已经下线") | ||
103 | + } | ||
104 | + if !(status == PlanOnline || status == PlanOffline) { | ||
105 | + return errors.New("计划状态有误") | ||
106 | + } | ||
107 | + productPlan.PlanStatus = status | ||
177 | return nil | 108 | return nil |
178 | } | 109 | } |
@@ -9,3 +9,16 @@ type ProductSection struct { | @@ -9,3 +9,16 @@ type ProductSection struct { | ||
9 | // 已删除标识 1:正常 2:已删除 | 9 | // 已删除标识 1:正常 2:已删除 |
10 | Removed int `json:"removed,omitempty"` | 10 | Removed int `json:"removed,omitempty"` |
11 | } | 11 | } |
12 | + | ||
13 | +func (m *ProductSection) CloneSample() *ProductSection { | ||
14 | + return &ProductSection{ | ||
15 | + SectionId: m.SectionId, | ||
16 | + SectionName: m.SectionName, | ||
17 | + } | ||
18 | +} | ||
19 | + | ||
20 | +type ProductSections []*ProductSection | ||
21 | + | ||
22 | +func (ms ProductSections) Len() int { return len(ms) } | ||
23 | +func (ms ProductSections) Less(i, j int) bool { return ms[i].SectionId < ms[j].SectionId } | ||
24 | +func (ms ProductSections) Swap(i, j int) { ms[i], ms[j] = ms[j], ms[i] } |
@@ -31,6 +31,6 @@ func NewWorkStation(w *Workshop, l *ProductLine, s *ProductSection) *WorkStation | @@ -31,6 +31,6 @@ func NewWorkStation(w *Workshop, l *ProductLine, s *ProductSection) *WorkStation | ||
31 | LineName: l.LineName, | 31 | LineName: l.LineName, |
32 | SectionId: s.SectionId, | 32 | SectionId: s.SectionId, |
33 | SectionName: s.SectionName, | 33 | SectionName: s.SectionName, |
34 | - Principal: w.Principal, | 34 | + //Principal: w.Principal, |
35 | } | 35 | } |
36 | } | 36 | } |
@@ -2,10 +2,13 @@ package domain | @@ -2,10 +2,13 @@ package domain | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "sort" | ||
5 | "time" | 6 | "time" |
6 | ) | 7 | ) |
7 | 8 | ||
8 | const ( | 9 | const ( |
10 | + // 所有 | ||
11 | + All = 0 | ||
9 | // 未删除 | 12 | // 未删除 |
10 | NotDeleted = 1 | 13 | NotDeleted = 1 |
11 | // 已删除 | 14 | // 已删除 |
@@ -220,6 +223,36 @@ func (workshop *Workshop) GetProductLines(removed int) []*ProductLine { | @@ -220,6 +223,36 @@ func (workshop *Workshop) GetProductLines(removed int) []*ProductLine { | ||
220 | return result | 223 | return result |
221 | } | 224 | } |
222 | 225 | ||
226 | +func (workshop *Workshop) AllProductSections(removed int) []*ProductSection { | ||
227 | + var result ProductSections = make([]*ProductSection, 0) | ||
228 | + lines := workshop.GetProductLines(removed) | ||
229 | + for i := range lines { | ||
230 | + for j := range lines[i].ProductSections { | ||
231 | + section := lines[i].ProductSections[j] | ||
232 | + if removed > 0 && section.Removed != removed { | ||
233 | + continue | ||
234 | + } | ||
235 | + result = append(result, section.CloneSample()) | ||
236 | + } | ||
237 | + } | ||
238 | + | ||
239 | + sort.Stable(result) | ||
240 | + return result | ||
241 | +} | ||
242 | + | ||
243 | +// 查询生产线 | ||
244 | +func (workshop *Workshop) FindSectionById(sectionId int) (*ProductLine, *ProductSection, error) { | ||
245 | + lines := workshop.GetProductLines(0) | ||
246 | + for k := range lines { | ||
247 | + line := lines[k] | ||
248 | + section, _ := line.FindSection(sectionId) | ||
249 | + if section != nil { | ||
250 | + return line, section, nil | ||
251 | + } | ||
252 | + } | ||
253 | + return nil, nil, fmt.Errorf("工段不存在") | ||
254 | +} | ||
255 | + | ||
223 | func (workshop *Workshop) CloneSample() *Workshop { | 256 | func (workshop *Workshop) CloneSample() *Workshop { |
224 | return &Workshop{ | 257 | return &Workshop{ |
225 | WorkshopId: workshop.WorkshopId, | 258 | WorkshopId: workshop.WorkshopId, |
pkg/infrastructure/mqtt/produce_client.go
0 → 100644
1 | +package mqtt | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + pahomqtt "github.com/eclipse/paho.mqtt.golang" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | ||
7 | + "time" | ||
8 | +) | ||
9 | + | ||
10 | +type ProduceClient struct { | ||
11 | + client pahomqtt.Client | ||
12 | +} | ||
13 | + | ||
14 | +func NewProduceClient() *ProduceClient { | ||
15 | + return &ProduceClient{} | ||
16 | +} | ||
17 | + | ||
18 | +func (produceClient *ProduceClient) options() *pahomqtt.ClientOptions { | ||
19 | + opts := pahomqtt.NewClientOptions().AddBroker(fmt.Sprintf("tcp://%v:%v", constant.MQTT_HOST, constant.MQTT_PORT)) | ||
20 | + opts.SetUsername(constant.MQTT_USER) | ||
21 | + opts.SetPassword(constant.MQTT_PASSWORD) | ||
22 | + opts.SetKeepAlive(2 * time.Second) | ||
23 | + opts.SetPingTimeout(1 * time.Second) | ||
24 | + return opts | ||
25 | +} | ||
26 | + | ||
27 | +func (produceClient *ProduceClient) connect(){ | ||
28 | + opts := produceClient.options() | ||
29 | + produceClient.client = pahomqtt.NewClient(opts) | ||
30 | + token := produceClient.client.Connect() | ||
31 | + token.Wait() | ||
32 | +} | ||
33 | + | ||
34 | +func (produceClient *ProduceClient) Publish(topic string,data interface{}) error { | ||
35 | + produceClient.connect() | ||
36 | + token := produceClient.client.Publish(topic,0,false,data) | ||
37 | + token.Wait() | ||
38 | + return token.Error() | ||
39 | +} |
pkg/infrastructure/mqtt/subscribe_client.go
0 → 100644
1 | +package mqtt | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + pahomqtt "github.com/eclipse/paho.mqtt.golang" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | ||
7 | + "time" | ||
8 | +) | ||
9 | + | ||
10 | +type SubscribeClient struct { | ||
11 | + topic string | ||
12 | + handler pahomqtt.MessageHandler | ||
13 | + client pahomqtt.Client | ||
14 | +} | ||
15 | + | ||
16 | +type MessageHandler pahomqtt.MessageHandler | ||
17 | + | ||
18 | +func NewSubscribeClient() *SubscribeClient { | ||
19 | + return &SubscribeClient{} | ||
20 | +} | ||
21 | + | ||
22 | +func (subscribeClient *SubscribeClient) options() *pahomqtt.ClientOptions { | ||
23 | + opts := pahomqtt.NewClientOptions().AddBroker(fmt.Sprintf("tcp://%v:%v", constant.MQTT_HOST, constant.MQTT_PORT)) | ||
24 | + opts.SetUsername(constant.MQTT_USER) | ||
25 | + opts.SetPassword(constant.MQTT_PASSWORD) | ||
26 | + opts.SetKeepAlive(2 * time.Second) | ||
27 | + opts.SetPingTimeout(1 * time.Second) | ||
28 | + return opts | ||
29 | +} | ||
30 | + | ||
31 | +func (subscribeClient *SubscribeClient) Connect() *SubscribeClient{ | ||
32 | + opts := subscribeClient.options() | ||
33 | + fmt.Println("start connect......") | ||
34 | + opts.OnConnectionLost = func(c pahomqtt.Client, err error) { | ||
35 | + fmt.Println("Connect error:", err) | ||
36 | + for { | ||
37 | + fmt.Println("reconnect server") | ||
38 | + token := subscribeClient.client.Connect() | ||
39 | + token.Wait() | ||
40 | + fmt.Println("server Connect status:",subscribeClient.client.IsConnectionOpen()) | ||
41 | + if subscribeClient.client.IsConnectionOpen() { | ||
42 | + break | ||
43 | + } | ||
44 | + time.Sleep(3 * time.Second) | ||
45 | + } | ||
46 | + } | ||
47 | + opts.OnConnect = func(c pahomqtt.Client) { | ||
48 | + c.Subscribe(subscribeClient.topic,0,subscribeClient.handler) | ||
49 | + } | ||
50 | + subscribeClient.client = pahomqtt.NewClient(opts) | ||
51 | + token := subscribeClient.client.Connect() | ||
52 | + token.Wait() | ||
53 | + return subscribeClient | ||
54 | +} | ||
55 | + | ||
56 | +func (subscribeClient *SubscribeClient) Subscribe(topic string, messageHandler pahomqtt.MessageHandler){ | ||
57 | + subscribeClient.topic = topic | ||
58 | + subscribeClient.handler = messageHandler | ||
59 | + token := subscribeClient.client.Subscribe(topic,0,messageHandler) | ||
60 | + token.Wait() | ||
61 | + token.Done() | ||
62 | +} | ||
63 | + | ||
64 | +func StartSubscribe(topic string,handler MessageHandler){ | ||
65 | + defer func() { | ||
66 | + if err := recover();err != nil { | ||
67 | + fmt.Println(err) | ||
68 | + StartSubscribe(topic,handler) | ||
69 | + } | ||
70 | + }() | ||
71 | + fmt.Println("start subscribe...") | ||
72 | + NewSubscribeClient().Connect().Subscribe(topic,pahomqtt.MessageHandler(handler)) | ||
73 | +} |
@@ -148,7 +148,7 @@ func (repository *DeviceRepository) FindOne(queryOptions map[string]interface{}) | @@ -148,7 +148,7 @@ func (repository *DeviceRepository) FindOne(queryOptions map[string]interface{}) | ||
148 | } | 148 | } |
149 | if err := query.First(); err != nil { | 149 | if err := query.First(); err != nil { |
150 | if err.Error() == "pg: no rows in result set" { | 150 | if err.Error() == "pg: no rows in result set" { |
151 | - return nil, fmt.Errorf("没有此资源") | 151 | + return nil, domain.ErrorNotFound |
152 | } else { | 152 | } else { |
153 | return nil, err | 153 | return nil, err |
154 | } | 154 | } |
@@ -153,7 +153,7 @@ func (repository *ProductAttendanceRecordRepository) FindOne(queryOptions map[st | @@ -153,7 +153,7 @@ func (repository *ProductAttendanceRecordRepository) FindOne(queryOptions map[st | ||
153 | } | 153 | } |
154 | if err := query.First(); err != nil { | 154 | if err := query.First(); err != nil { |
155 | if err.Error() == "pg: no rows in result set" { | 155 | if err.Error() == "pg: no rows in result set" { |
156 | - return nil, fmt.Errorf("没有此资源") | 156 | + return nil, domain.ErrorNotFound |
157 | } else { | 157 | } else { |
158 | return nil, err | 158 | return nil, err |
159 | } | 159 | } |
@@ -138,7 +138,7 @@ func (repository *ProductCalendarRepository) FindOne(queryOptions map[string]int | @@ -138,7 +138,7 @@ func (repository *ProductCalendarRepository) FindOne(queryOptions map[string]int | ||
138 | } | 138 | } |
139 | if err := query.First(); err != nil { | 139 | if err := query.First(); err != nil { |
140 | if err.Error() == "pg: no rows in result set" { | 140 | if err.Error() == "pg: no rows in result set" { |
141 | - return nil, fmt.Errorf("没有此资源") | 141 | + return nil, domain.ErrorNotFound |
142 | } else { | 142 | } else { |
143 | return nil, err | 143 | return nil, err |
144 | } | 144 | } |
@@ -133,7 +133,7 @@ func (repository *ProductGroupRepository) FindOne(queryOptions map[string]interf | @@ -133,7 +133,7 @@ func (repository *ProductGroupRepository) FindOne(queryOptions map[string]interf | ||
133 | } | 133 | } |
134 | if err := query.First(); err != nil { | 134 | if err := query.First(); err != nil { |
135 | if err.Error() == "pg: no rows in result set" { | 135 | if err.Error() == "pg: no rows in result set" { |
136 | - return nil, fmt.Errorf("没有此资源") | 136 | + return nil, domain.ErrorNotFound |
137 | } else { | 137 | } else { |
138 | return nil, err | 138 | return nil, err |
139 | } | 139 | } |
@@ -166,7 +166,10 @@ func (repository *ProductGroupRepository) Find(queryOptions map[string]interface | @@ -166,7 +166,10 @@ func (repository *ProductGroupRepository) Find(queryOptions map[string]interface | ||
166 | if v, ok := queryOptions["groupName"]; ok && len(v.(string)) > 0 { | 166 | if v, ok := queryOptions["groupName"]; ok && len(v.(string)) > 0 { |
167 | query.Where(fmt.Sprintf(`group_name like '%%%v%%'`, v)) | 167 | query.Where(fmt.Sprintf(`group_name like '%%%v%%'`, v)) |
168 | } | 168 | } |
169 | - query.SetOffsetAndLimit(20) | 169 | + query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId") |
170 | + query.SetWhereByQueryOption("work_station->>'lineId'='?'", "lineId") | ||
171 | + query.SetWhereByQueryOption("work_station->>'sectionId'='?'", "sectionId") | ||
172 | + query.SetOffsetAndLimit(domain.MaxQueryRow) | ||
170 | query.SetOrderDirect("product_group_id", "DESC") | 173 | query.SetOrderDirect("product_group_id", "DESC") |
171 | if count, err := query.SelectAndCount(); err != nil { | 174 | if count, err := query.SelectAndCount(); err != nil { |
172 | return 0, productGroups, err | 175 | return 0, productGroups, err |
@@ -128,7 +128,7 @@ func (repository *ProductJobRepository) FindOne(queryOptions map[string]interfac | @@ -128,7 +128,7 @@ func (repository *ProductJobRepository) FindOne(queryOptions map[string]interfac | ||
128 | } | 128 | } |
129 | if err := query.First(); err != nil { | 129 | if err := query.First(); err != nil { |
130 | if err.Error() == "pg: no rows in result set" { | 130 | if err.Error() == "pg: no rows in result set" { |
131 | - return nil, fmt.Errorf("没有此资源") | 131 | + return nil, domain.ErrorNotFound |
132 | } else { | 132 | } else { |
133 | return nil, err | 133 | return nil, err |
134 | } | 134 | } |
@@ -156,7 +156,7 @@ func (repository *ProductPlanRepository) FindOne(queryOptions map[string]interfa | @@ -156,7 +156,7 @@ func (repository *ProductPlanRepository) FindOne(queryOptions map[string]interfa | ||
156 | } | 156 | } |
157 | if err := query.First(); err != nil { | 157 | if err := query.First(); err != nil { |
158 | if err.Error() == "pg: no rows in result set" { | 158 | if err.Error() == "pg: no rows in result set" { |
159 | - return nil, fmt.Errorf("没有此资源") | 159 | + return nil, domain.ErrorNotFound |
160 | } else { | 160 | } else { |
161 | return nil, err | 161 | return nil, err |
162 | } | 162 | } |
@@ -172,7 +172,18 @@ func (repository *ProductPlanRepository) Find(queryOptions map[string]interface{ | @@ -172,7 +172,18 @@ func (repository *ProductPlanRepository) Find(queryOptions map[string]interface{ | ||
172 | var productPlanModels []*models.ProductPlan | 172 | var productPlanModels []*models.ProductPlan |
173 | productPlans := make([]*domain.ProductPlan, 0) | 173 | productPlans := make([]*domain.ProductPlan, 0) |
174 | query := sqlbuilder.BuildQuery(tx.Model(&productPlanModels), queryOptions) | 174 | query := sqlbuilder.BuildQuery(tx.Model(&productPlanModels), queryOptions) |
175 | - query.SetOffsetAndLimit(20) | 175 | + query.SetWhereByQueryOption("company_id = ?", "companyId") |
176 | + query.SetWhereByQueryOption("org_id = ?", "orgId") | ||
177 | + query.SetWhereByQueryOption("batch_number=?", "batchNumber") | ||
178 | + | ||
179 | + if v, ok := queryOptions["batchNumber"]; ok && len(v.(string)) > 0 { | ||
180 | + query.Where(fmt.Sprintf(`batch_number like '%%%v%%'`, v)) | ||
181 | + } | ||
182 | + if v, ok := queryOptions["workshopName"]; ok && len(v.(string)) > 0 { | ||
183 | + query.Where(fmt.Sprintf(`workshop->>'workshopName' like '%%%v%%'`, v)) | ||
184 | + } | ||
185 | + query.SetWhereByQueryOption("plan_status=?", "planStatus") | ||
186 | + query.SetOffsetAndLimit(domain.MaxQueryRow) | ||
176 | query.SetOrderDirect("product_plan_id", "DESC") | 187 | query.SetOrderDirect("product_plan_id", "DESC") |
177 | if count, err := query.SelectAndCount(); err != nil { | 188 | if count, err := query.SelectAndCount(); err != nil { |
178 | return 0, productPlans, err | 189 | return 0, productPlans, err |
@@ -133,7 +133,7 @@ func (repository *ProductRecordRepository) FindOne(queryOptions map[string]inter | @@ -133,7 +133,7 @@ func (repository *ProductRecordRepository) FindOne(queryOptions map[string]inter | ||
133 | } | 133 | } |
134 | if err := query.First(); err != nil { | 134 | if err := query.First(); err != nil { |
135 | if err.Error() == "pg: no rows in result set" { | 135 | if err.Error() == "pg: no rows in result set" { |
136 | - return nil, fmt.Errorf("没有此资源") | 136 | + return nil, domain.ErrorNotFound |
137 | } else { | 137 | } else { |
138 | return nil, err | 138 | return nil, err |
139 | } | 139 | } |
@@ -149,7 +149,7 @@ func (repository *ProductRecordRepository) Find(queryOptions map[string]interfac | @@ -149,7 +149,7 @@ func (repository *ProductRecordRepository) Find(queryOptions map[string]interfac | ||
149 | var productRecordModels []*models.ProductRecord | 149 | var productRecordModels []*models.ProductRecord |
150 | productRecords := make([]*domain.ProductRecord, 0) | 150 | productRecords := make([]*domain.ProductRecord, 0) |
151 | query := sqlbuilder.BuildQuery(tx.Model(&productRecordModels), queryOptions) | 151 | query := sqlbuilder.BuildQuery(tx.Model(&productRecordModels), queryOptions) |
152 | - query.SetOffsetAndLimit(20) | 152 | + query.SetOffsetAndLimit(domain.MaxQueryRow) |
153 | query.SetOrderDirect("product_record_id", "DESC") | 153 | query.SetOrderDirect("product_record_id", "DESC") |
154 | if count, err := query.SelectAndCount(); err != nil { | 154 | if count, err := query.SelectAndCount(); err != nil { |
155 | return 0, productRecords, err | 155 | return 0, productRecords, err |
@@ -130,7 +130,7 @@ func (repository *ProductRepository) FindOne(queryOptions map[string]interface{} | @@ -130,7 +130,7 @@ func (repository *ProductRepository) FindOne(queryOptions map[string]interface{} | ||
130 | } | 130 | } |
131 | if err := query.First(); err != nil { | 131 | if err := query.First(); err != nil { |
132 | if err.Error() == "pg: no rows in result set" { | 132 | if err.Error() == "pg: no rows in result set" { |
133 | - return nil, fmt.Errorf("没有此资源") | 133 | + return nil, domain.ErrorNotFound |
134 | } else { | 134 | } else { |
135 | return nil, err | 135 | return nil, err |
136 | } | 136 | } |
@@ -157,7 +157,7 @@ func (repository *ProductRepository) Find(queryOptions map[string]interface{}) ( | @@ -157,7 +157,7 @@ func (repository *ProductRepository) Find(queryOptions map[string]interface{}) ( | ||
157 | if v, ok := queryOptions["productCategory"]; ok && len(v.(string)) > 0 { | 157 | if v, ok := queryOptions["productCategory"]; ok && len(v.(string)) > 0 { |
158 | query.Where(fmt.Sprintf(`product_category like '%%%v%%'`, v)) | 158 | query.Where(fmt.Sprintf(`product_category like '%%%v%%'`, v)) |
159 | } | 159 | } |
160 | - query.SetOffsetAndLimit(20) | 160 | + query.SetOffsetAndLimit(domain.MaxQueryRow) |
161 | query.SetOrderDirect("product_id", "DESC") | 161 | query.SetOrderDirect("product_id", "DESC") |
162 | if count, err := query.SelectAndCount(); err != nil { | 162 | if count, err := query.SelectAndCount(); err != nil { |
163 | return 0, products, err | 163 | return 0, products, err |
@@ -128,7 +128,7 @@ func (repository *UnitConversionRepository) FindOne(queryOptions map[string]inte | @@ -128,7 +128,7 @@ func (repository *UnitConversionRepository) FindOne(queryOptions map[string]inte | ||
128 | } | 128 | } |
129 | if err := query.First(); err != nil { | 129 | if err := query.First(); err != nil { |
130 | if err.Error() == "pg: no rows in result set" { | 130 | if err.Error() == "pg: no rows in result set" { |
131 | - return nil, fmt.Errorf("没有此资源") | 131 | + return nil, domain.ErrorNotFound |
132 | } else { | 132 | } else { |
133 | return nil, err | 133 | return nil, err |
134 | } | 134 | } |
@@ -146,6 +146,9 @@ func (repository *UnitConversionRepository) Find(queryOptions map[string]interfa | @@ -146,6 +146,9 @@ func (repository *UnitConversionRepository) Find(queryOptions map[string]interfa | ||
146 | query := sqlbuilder.BuildQuery(tx.Model(&unitConversionModels), queryOptions) | 146 | query := sqlbuilder.BuildQuery(tx.Model(&unitConversionModels), queryOptions) |
147 | query.SetWhereByQueryOption("company_id = ?", "companyId") | 147 | query.SetWhereByQueryOption("company_id = ?", "companyId") |
148 | query.SetWhereByQueryOption("org_id = ?", "orgId") | 148 | query.SetWhereByQueryOption("org_id = ?", "orgId") |
149 | + query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId") | ||
150 | + query.SetWhereByQueryOption("work_station->>'lineId'='?'", "lineId") | ||
151 | + query.SetWhereByQueryOption("work_station->>'sectionId'='?'", "sectionId") | ||
149 | if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int)) > 0 { | 152 | if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int)) > 0 { |
150 | query.Where(`org_id in (?)`, pg.In(v)) | 153 | query.Where(`org_id in (?)`, pg.In(v)) |
151 | } | 154 | } |
@@ -121,7 +121,7 @@ func (repository *WorkshopRepository) FindOne(queryOptions map[string]interface{ | @@ -121,7 +121,7 @@ func (repository *WorkshopRepository) FindOne(queryOptions map[string]interface{ | ||
121 | } | 121 | } |
122 | if err := query.First(); err != nil { | 122 | if err := query.First(); err != nil { |
123 | if err.Error() == "pg: no rows in result set" { | 123 | if err.Error() == "pg: no rows in result set" { |
124 | - return nil, fmt.Errorf("没有此资源") | 124 | + return nil, domain.ErrorNotFound |
125 | } else { | 125 | } else { |
126 | return nil, err | 126 | return nil, err |
127 | } | 127 | } |
@@ -78,3 +78,14 @@ func (controller *ProductGroupController) SearchProductGroup() { | @@ -78,3 +78,14 @@ func (controller *ProductGroupController) SearchProductGroup() { | ||
78 | total, data, err := productGroupService.SearchProductGroup(ParseOperateInfo(controller.BaseController), cmd) | 78 | total, data, err := productGroupService.SearchProductGroup(ParseOperateInfo(controller.BaseController), cmd) |
79 | ResponseGrid(controller.BaseController, total, data, err) | 79 | ResponseGrid(controller.BaseController, total, data, err) |
80 | } | 80 | } |
81 | + | ||
82 | +func (controller *ProductGroupController) SearchProductGroupEmployees() { | ||
83 | + productGroupService := service.NewProductGroupService(nil) | ||
84 | + cmd := &query.SearchProductGroupEmployeesQuery{} | ||
85 | + Must(controller.Unmarshal(cmd)) | ||
86 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
87 | + cmd.OrgId = operateInfo.OrgId | ||
88 | + cmd.CompanyId = operateInfo.CompanyId | ||
89 | + _, data, err := productGroupService.SearchProductGroupEmployees(operateInfo, cmd) | ||
90 | + controller.Response(data, err) | ||
91 | +} |
@@ -86,6 +86,14 @@ func (controller *ProductPlanController) SetOnline() { | @@ -86,6 +86,14 @@ func (controller *ProductPlanController) SetOnline() { | ||
86 | controller.Response(data, err) | 86 | controller.Response(data, err) |
87 | } | 87 | } |
88 | 88 | ||
89 | +func (controller *ProductPlanController) SetOffline() { | ||
90 | + productPlanService := service.NewProductPlanService(nil) | ||
91 | + setOnlineCommand := &command.SetOfflineCommand{} | ||
92 | + Must(controller.Unmarshal(setOnlineCommand)) | ||
93 | + data, err := productPlanService.SetOffline(setOnlineCommand) | ||
94 | + controller.Response(data, err) | ||
95 | +} | ||
96 | + | ||
89 | func (controller *ProductPlanController) Switch() { | 97 | func (controller *ProductPlanController) Switch() { |
90 | productPlanService := service.NewProductPlanService(nil) | 98 | productPlanService := service.NewProductPlanService(nil) |
91 | switchCommand := &command.SwitchCommand{} | 99 | switchCommand := &command.SwitchCommand{} |
@@ -78,3 +78,14 @@ func (controller *UnitConversionController) SearchUnitConversion() { | @@ -78,3 +78,14 @@ func (controller *UnitConversionController) SearchUnitConversion() { | ||
78 | total, data, err := unitConversionService.SearchUnitConversion(ParseOperateInfo(controller.BaseController), cmd) | 78 | total, data, err := unitConversionService.SearchUnitConversion(ParseOperateInfo(controller.BaseController), cmd) |
79 | ResponseGrid(controller.BaseController, total, data, err) | 79 | ResponseGrid(controller.BaseController, total, data, err) |
80 | } | 80 | } |
81 | + | ||
82 | +func (controller *UnitConversionController) SearchMaterial() { | ||
83 | + unitConversionService := service.NewUnitConversionService(nil) | ||
84 | + cmd := &query.SearchMaterialsQuery{} | ||
85 | + Must(controller.Unmarshal(cmd)) | ||
86 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
87 | + cmd.OrgId = operateInfo.OrgId | ||
88 | + cmd.CompanyId = operateInfo.CompanyId | ||
89 | + _, data, err := unitConversionService.SearchMaterial(ParseOperateInfo(controller.BaseController), cmd) | ||
90 | + controller.Response(data, err) | ||
91 | +} |
@@ -74,3 +74,11 @@ func (controller *WorkshopController) SelectorWorkshop() { | @@ -74,3 +74,11 @@ func (controller *WorkshopController) SelectorWorkshop() { | ||
74 | data, err := workshopService.SearchWorkshop(ParseOperateInfo(controller.BaseController), listWorkshopQuery) | 74 | data, err := workshopService.SearchWorkshop(ParseOperateInfo(controller.BaseController), listWorkshopQuery) |
75 | controller.Response(data, err) | 75 | controller.Response(data, err) |
76 | } | 76 | } |
77 | + | ||
78 | +func (controller *WorkshopController) SelectorWorkshopSection() { | ||
79 | + workshopService := service.NewWorkshopService(nil) | ||
80 | + getWorkshopQuery := &query.GetWorkshopQuery{} | ||
81 | + Must(controller.Unmarshal(getWorkshopQuery)) | ||
82 | + data, err := workshopService.SelectorWorkshopSection(ParseOperateInfo(controller.BaseController), getWorkshopQuery) | ||
83 | + controller.Response(data, err) | ||
84 | +} |
@@ -13,4 +13,5 @@ func init() { | @@ -13,4 +13,5 @@ func init() { | ||
13 | web.Router("/product-groups/batch-remove", &controllers.ProductGroupController{}, "Post:BatchRemoveProductGroup") | 13 | web.Router("/product-groups/batch-remove", &controllers.ProductGroupController{}, "Post:BatchRemoveProductGroup") |
14 | web.Router("/product-groups/", &controllers.ProductGroupController{}, "Get:ListProductGroup") | 14 | web.Router("/product-groups/", &controllers.ProductGroupController{}, "Get:ListProductGroup") |
15 | web.Router("/product-groups/search", &controllers.ProductGroupController{}, "Post:SearchProductGroup") | 15 | web.Router("/product-groups/search", &controllers.ProductGroupController{}, "Post:SearchProductGroup") |
16 | + web.Router("/product-groups/employees", &controllers.ProductGroupController{}, "Post:SearchProductGroupEmployees") | ||
16 | } | 17 | } |
@@ -14,7 +14,8 @@ func init() { | @@ -14,7 +14,8 @@ func init() { | ||
14 | web.Router("/product-plans/receive-material", &controllers.ProductPlanController{}, "Post:ReceiveMaterial") | 14 | web.Router("/product-plans/receive-material", &controllers.ProductPlanController{}, "Post:ReceiveMaterial") |
15 | web.Router("/product-plans/return-material", &controllers.ProductPlanController{}, "Post:ReturnMaterial") | 15 | web.Router("/product-plans/return-material", &controllers.ProductPlanController{}, "Post:ReturnMaterial") |
16 | web.Router("/product-plans/set-online", &controllers.ProductPlanController{}, "Post:SetOnline") | 16 | web.Router("/product-plans/set-online", &controllers.ProductPlanController{}, "Post:SetOnline") |
17 | - web.Router("/product-plans/switch", &controllers.ProductPlanController{}, "Post:Switch") | 17 | + web.Router("/product-plans/set-offline", &controllers.ProductPlanController{}, "Post:SetOffline") |
18 | + web.Router("/product-plans/exchange", &controllers.ProductPlanController{}, "Post:Switch") | ||
18 | web.Router("/product-plans/submit-product-record", &controllers.ProductPlanController{}, "Post:SubmitProductRecord") | 19 | web.Router("/product-plans/submit-product-record", &controllers.ProductPlanController{}, "Post:SubmitProductRecord") |
19 | web.Router("/product-plans/search", &controllers.ProductPlanController{}, "Post:SearchProductPlan") | 20 | web.Router("/product-plans/search", &controllers.ProductPlanController{}, "Post:SearchProductPlan") |
20 | } | 21 | } |
@@ -13,4 +13,6 @@ func init() { | @@ -13,4 +13,6 @@ func init() { | ||
13 | web.Router("/unit-conversions/batch-remove", &controllers.UnitConversionController{}, "Post:BatchRemoveUnitConversion") | 13 | web.Router("/unit-conversions/batch-remove", &controllers.UnitConversionController{}, "Post:BatchRemoveUnitConversion") |
14 | web.Router("/unit-conversions/", &controllers.UnitConversionController{}, "Get:ListUnitConversion") | 14 | web.Router("/unit-conversions/", &controllers.UnitConversionController{}, "Get:ListUnitConversion") |
15 | web.Router("/unit-conversions/search", &controllers.UnitConversionController{}, "Post:SearchUnitConversion") | 15 | web.Router("/unit-conversions/search", &controllers.UnitConversionController{}, "Post:SearchUnitConversion") |
16 | + | ||
17 | + web.Router("/unit-conversions/materials", &controllers.UnitConversionController{}, "Post:SearchMaterial") | ||
16 | } | 18 | } |
@@ -13,4 +13,5 @@ func init() { | @@ -13,4 +13,5 @@ func init() { | ||
13 | web.Router("/workshops/", &controllers.WorkshopController{}, "Get:ListWorkshop") | 13 | web.Router("/workshops/", &controllers.WorkshopController{}, "Get:ListWorkshop") |
14 | web.Router("/workshops/search", &controllers.WorkshopController{}, "Post:SearchWorkshop") | 14 | web.Router("/workshops/search", &controllers.WorkshopController{}, "Post:SearchWorkshop") |
15 | web.Router("/workshops/selector", &controllers.WorkshopController{}, "Post:SelectorWorkshop") | 15 | web.Router("/workshops/selector", &controllers.WorkshopController{}, "Post:SelectorWorkshop") |
16 | + web.Router("/workshops/sections-selector", &controllers.WorkshopController{}, "Post:SelectorWorkshopSection") | ||
16 | } | 17 | } |
pkg/port/mqtt/mqtt.go
0 → 100644
1 | +package mqtt | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + pahomqtt "github.com/eclipse/paho.mqtt.golang" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/mqtt" | ||
7 | + "strconv" | ||
8 | + "time" | ||
9 | +) | ||
10 | + | ||
11 | +func Start(){ | ||
12 | + mqtt.StartSubscribe("test", func(client pahomqtt.Client, message pahomqtt.Message) { | ||
13 | + fmt.Println(time.Now(),"Topic:"+message.Topic()+" MessageId:"+ strconv.Itoa(int(message.MessageID()))+" Message:"+ string(message.Payload())) | ||
14 | + }) | ||
15 | +} |
-
请 注册 或 登录 后发表评论