Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-manufacture into dev # Conflicts: # pkg/infrastructure/dao/material_k3cloud_dao.go # pkg/port/beego/routers/test_router.go
正在显示
84 个修改的文件
包含
3706 行增加
和
187 行删除
1 | -#project | ||
1 | +# 生产制造项目说明 | ||
2 | + | ||
3 | +## 1.数据导入导出模块 | ||
4 | + | ||
5 | +### 1.1.Excel导入流程 | ||
6 | + | ||
7 | +- 原型说明 | ||
8 | + | ||
9 | +选择模板下载、文件上传 | ||
10 | +![](https://doc-press.fjmaimaimai.com/team/frontend/plugins/data-transfer-upload.png) | ||
11 | + | ||
12 | +导入数据检验有错,显示具体错误 | ||
13 | +![](https://timeless-world.oss-cn-shenzhen.aliyuncs.com/opportunity/dev_online/20220225/object/1645791913_Rz2JJkkx6xEXtAFdXDH5eH6NTjfhtjxf.jpg) | ||
14 | + | ||
15 | +- [导入接口文档地址](https://doc-press.fjmaimaimai.com/team/frontend/plugins/business/import.html) | ||
16 | + | ||
17 | + | ||
18 | +``` | ||
19 | +POST/v1/web/file-import | ||
20 | + | ||
21 | +Content-Type multipart/form-data | ||
22 | + | ||
23 | +params: | ||
24 | + | ||
25 | +file 文件 | ||
26 | +code 对应导入模块的编码 | ||
27 | +``` | ||
28 | + | ||
29 | +- ``对接步骤``以导入公司用户模块为例 | ||
30 | + | ||
31 | +1.定义接口导入的``code``为``ADMIN_SYSTEM-MANAGE_BASE_USER`` | ||
32 | +2.根据接口解析导入文件的数据 | ||
33 | +3.调用基础库解析数据并传到后台 | ||
34 | +```go | ||
35 | + | ||
36 | +// 1.解析列 | ||
37 | +excelImport := excel.NewExcelImport() | ||
38 | +excelImport.RowBegin = 3 //第二行开始读取 | ||
39 | +excelImport.DataFields = []excel.DataField{ | ||
40 | + {EnName: "userCode", CnName: "*用户编码"}, | ||
41 | + {EnName: "userName", CnName: "*用户姓名"}, | ||
42 | + {EnName: "org", CnName: "*组织机构"}, | ||
43 | + {EnName: "department", CnName: "*所属部门"}, | ||
44 | + {EnName: "enableStatus", CnName: "*用户状态"}, | ||
45 | + {EnName: "phone", CnName: "*手机号"}, | ||
46 | + {EnName: "employeeType", CnName: "*员工类型"}, | ||
47 | + {EnName: "icCardNumber", CnName: "IC卡号"}, | ||
48 | + {EnName: "email", CnName: "邮箱"}, | ||
49 | +} | ||
50 | +excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader) | ||
51 | +if err != nil { | ||
52 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
53 | +} | ||
54 | +users := make([]allied_creation_user.BatchAddUserItem, 0) | ||
55 | +for _, v := range excelData { | ||
56 | + if srv.fieldValueAllEmpty(v) { | ||
57 | + continue | ||
58 | + } | ||
59 | + item := allied_creation_user.BatchAddUserItem{ | ||
60 | + CompanyId: importDataCommand.Operator.CompanyId, | ||
61 | + UserType: domain.UserTypeEmployee, | ||
62 | + UserCode: strings.TrimSpace(v["userCode"]), | ||
63 | + Org: strings.TrimSpace(v["org"]), | ||
64 | + Department: strings.TrimSpace(v["department"]), | ||
65 | + UserName: strings.TrimSpace(v["userName"]), | ||
66 | + Phone: strings.TrimSpace(v["phone"]), | ||
67 | + Email: strings.TrimSpace(v["email"]), | ||
68 | + EnableStatus: strings.TrimSpace(v["enableStatus"]), | ||
69 | + EmployeeType: strings.TrimSpace(v["employeeType"]), | ||
70 | + IcCardNumber: strings.TrimSpace(v["icCardNumber"]), | ||
71 | + } | ||
72 | + users = append(users, item) | ||
73 | +} | ||
74 | +// 2.向后台服务发起批量添加请求 | ||
75 | +userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator) | ||
76 | +result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{ | ||
77 | + Users: users, | ||
78 | + Password: initPassword, | ||
79 | +}) | ||
80 | +``` | ||
81 | + | ||
82 | +```go | ||
83 | +``` | ||
84 | + | ||
85 | +### 2.2 Excel导出流程 | ||
86 | + | ||
87 | +- 功能原型说明 | ||
88 | + | ||
89 | +实现可以自定义选择列进行导出,以及选择导出格式,导出格式有 ``xlsx``\\``csv``,功能如下图所示: | ||
90 | + | ||
91 | +![](https://timeless-world.oss-cn-shenzhen.aliyuncs.com/opportunity/dev_online/20220225/object/1645789890_JbTa22EtANsD3fm2nJ4aH6FJkHzXaHJB.png) | ||
92 | + | ||
93 | +- 前后端交互说明 | ||
94 | + | ||
95 | +``接口定义`` | ||
96 | + | ||
97 | +导出接口 | ||
98 | +```shell | ||
99 | +POST /v1/web/file-export | ||
100 | + | ||
101 | +// request 请求参数 | ||
102 | +{ | ||
103 | + // 业务编码 | ||
104 | + "code":"string" | ||
105 | + // 选择的导出的列 | ||
106 | + "fields":[] | ||
107 | + // 导出文件格式 | ||
108 | + "format":"xlsx" | ||
109 | + // 业务查询条件 | ||
110 | + "where":{} | ||
111 | +} | ||
112 | +``` | ||
113 | + | ||
114 | +导出列查询接口 | ||
115 | + | ||
116 | +```shell | ||
117 | +GET/v1/web/file-export/fields/:code | ||
118 | + | ||
119 | +// response 应答数据 | ||
120 | +{ | ||
121 | + "fields":[ | ||
122 | + { | ||
123 | + "enName":"字段键名", | ||
124 | + "cnName":"字段展示名称", | ||
125 | + "selected":true // 默认勾选 | ||
126 | + } | ||
127 | + ] | ||
128 | +} | ||
129 | +``` | ||
130 | + | ||
131 | +- 交互流程 | ||
132 | + | ||
133 | +1.前台根据 ``导出列查询接口`` 获取可以导出的列; | ||
134 | +2.勾选需要导出的列、文件格式,调用 ``导出接口`` 向后台发起导出数据请求; | ||
135 | + | ||
136 | + | ||
137 | +#### 2.2.1 后端导出实现 | ||
138 | + | ||
139 | +1. 导出数据实现接口 | ||
140 | + | ||
141 | +``` | ||
142 | +type ExcelMaker interface { | ||
143 | + DataFieldList() []DataField //字段元数据列表 | ||
144 | + CellValue(index int, enName string) (value interface{}) //获取单元格字段值 | ||
145 | + DataListLen() int //数据列表大小 | ||
146 | + TableTitle() []string //列表顶部自定义内容 | ||
147 | +} | ||
148 | +``` | ||
149 | + | ||
150 | +如下所示 | ||
151 | +```go | ||
152 | +//ExportCooperationUserData 导出共创用户数据 | ||
153 | +type ExportCooperationUserData struct { | ||
154 | + SourceData []allied_creation_user.UserDetail //具体数据 | ||
155 | + SelectedField []string | ||
156 | +} | ||
157 | + | ||
158 | +var _ excel.ExcelMaker = (*ExportCooperationUserData)(nil) | ||
159 | + | ||
160 | +func (data ExportCooperationUserData) AllFields() []DataFieldOptions { | ||
161 | + return []DataFieldOptions{ | ||
162 | + {EnName: "UserCode", CnName: "用户编码"}, | ||
163 | + {EnName: "UserName", CnName: "用户姓名"}, | ||
164 | + {EnName: "Phone", CnName: "手机号"}, | ||
165 | + {EnName: "CooperationCompany", CnName: "共创公司"}, | ||
166 | + {EnName: "CooperationDeadline", CnName: "共创到期"}, | ||
167 | + {EnName: "EnableStatus", CnName: "状态"}, | ||
168 | + } | ||
169 | +} | ||
170 | + | ||
171 | +func (data ExportCooperationUserData) DataFieldList() []excel.DataField { | ||
172 | + fields := []excel.DataField{} | ||
173 | + allFields := data.AllFields() | ||
174 | + for _, value2 := range allFields { | ||
175 | + if len(data.SelectedField) == 0 || value2.IsDefault { | ||
176 | + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName}) | ||
177 | + continue | ||
178 | + } | ||
179 | + for _, value3 := range data.SelectedField { | ||
180 | + if value2.EnName == value3 { | ||
181 | + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName}) | ||
182 | + } | ||
183 | + } | ||
184 | + } | ||
185 | + return fields | ||
186 | +} | ||
187 | + | ||
188 | +func (data ExportCooperationUserData) CellValue(index int, enName string) (value interface{}) { | ||
189 | + if index > data.DataListLen() { | ||
190 | + return "" | ||
191 | + } | ||
192 | + switch enName { | ||
193 | + case "UserCode": | ||
194 | + return data.SourceData[index].UserCode | ||
195 | + case "UserName": | ||
196 | + return data.SourceData[index].UserInfo.UserName | ||
197 | + case "CooperationCompany": | ||
198 | + return data.SourceData[index].CooperationInfo.CooperationCompany | ||
199 | + case "CooperationDeadline": | ||
200 | + if data.SourceData[index].CooperationInfo.CooperationDeadline.IsZero() || data.SourceData[index].CooperationInfo.CooperationDeadline.Unix() == 0 { | ||
201 | + return "" | ||
202 | + } | ||
203 | + return data.SourceData[index].CooperationInfo.CooperationDeadline.Format("2006-01-02") | ||
204 | + case "Phone": | ||
205 | + return data.SourceData[index].UserInfo.Phone | ||
206 | + case "Email": | ||
207 | + return data.SourceData[index].UserInfo.Email | ||
208 | + case "EnableStatus": | ||
209 | + status := data.SourceData[index].EnableStatus | ||
210 | + statusName := "" | ||
211 | + // 状态(1:启用 2:禁用 3:注销) | ||
212 | + switch status { | ||
213 | + case 1: | ||
214 | + statusName = "启用" | ||
215 | + case 2: | ||
216 | + statusName = "禁用" | ||
217 | + case 3: | ||
218 | + statusName = "注销" | ||
219 | + } | ||
220 | + return statusName | ||
221 | + } | ||
222 | + return nil | ||
223 | +} | ||
224 | + | ||
225 | +func (data ExportCooperationUserData) DataListLen() int { | ||
226 | + return len(data.SourceData) | ||
227 | +} | ||
228 | + | ||
229 | +func (data ExportCooperationUserData) TableTitle() []string { | ||
230 | + return nil | ||
231 | +} | ||
232 | +``` | ||
233 | + | ||
234 | +2. 返回文件 | ||
235 | + | ||
236 | +```go | ||
237 | +//返回文件 | ||
238 | +excelTool := excel.NewExcelExport() | ||
239 | +err = excelTool.ExportData(data, "") | ||
240 | +controller.responseExcelByFile(controller.Ctx, excelTool, filename) | ||
241 | + | ||
242 | + | ||
243 | +func (controller *ExcelDataController) responseExcelByFile(ctx *context.Context, excelExport *excel.ExcelExport, fileName string) error { | ||
244 | + ctx.Output.Header("Content-Disposition", "attachment; filename="+fileName) | ||
245 | + ctx.Output.Header("Content-Description", "File Transfer") | ||
246 | + ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") | ||
247 | + ctx.Output.Header("Content-Transfer-Encoding", "binary") | ||
248 | + ctx.Output.Header("Expires", "0") | ||
249 | + ctx.Output.Header("Cache-Control", "must-revalidate") | ||
250 | + ctx.Output.Header("Pragma", "public") | ||
251 | + //跳过保存文件,直接写入ctx.ResponseWriter | ||
252 | + excelExport.ExcelFile.Write(ctx.ResponseWriter) | ||
253 | + return nil | ||
254 | +} | ||
255 | +``` |
1 | -----BEGIN RSA PRIVATE KEY----- | 1 | -----BEGIN RSA PRIVATE KEY----- |
2 | -MIIEpQIBAAKCAQEAy0OxRf+NheQG9epxbrudwnrzqVgqK5zCuRAkLUgaSMATVXEA | ||
3 | -iDzJN39om+Q49MmtEk4pXGzKUyzkFJG96PA8tJq0E+bSDtSK3n+2mjZb6pChmgHw | ||
4 | -KEX7T8ZVLqJBSrfrI4Z2BJDNEC+3wvVW3zpog1RlfKgft6NYUzNLUqE5Mxzq7lpD | ||
5 | -eRsq+FhzM1sOeEb2dAmUlDDs+7HcR3Kj0ttKeg+hKqIottQ/H6Tq4c8deEQGnO0+ | ||
6 | -RN3CygyETbYmLuWttI/sUltulWJALIuU81Yr6uCOq5MSt2WsU8CTuhRwGXSvcQCO | ||
7 | -FLYppYktoMDOGIBQffmJc/DdT1d35fvdpKbm+QIDAQABAoIBAQC8X7+qX2uI6gqJ | ||
8 | -XPxC4x0RX2DxUAPE50KOv6bHUEsLoPZJ+K/Fko/oHuuTja47Lax3inhKb4gSDUhS | ||
9 | -x754YivgNH8u8ns5wz/vc+yGflowyFj7oVAwAqslA2luDnD0Df6crcAx+wAQQCjN | ||
10 | -RRF9T2QMUeq73BOI3Ji+gosLyN55vms2KadrwpPQwYN7qhdrerE7vPqCZeswzs1/ | ||
11 | -A5M9PVGBG+simNea5kv+tVJUdLi6ckGAB5KabyhpG779ckwzV/aZy3wIj4SvUvCd | ||
12 | -bewH0xPHx5TqnMOXtzHgktClmL7hIYxy9sL14Dn0KVHbyolQ7IqmJtjXYqG84Fmx | ||
13 | -AfyDfeABAoGBAPP820tKElrfTuZ+Z19kJBTp6I5iax2Ph10glUHLlLqJ82clI/Gl | ||
14 | -CbMtnGmD72HfnJei82xqoVLsUkN9Sp+TSNJALh4N8rHkAtwq5kWToiAWZydwxVsp | ||
15 | -x5OWEN3+QFIdjVW6fhg6jZSK5HHIqMdZOVvbfKP+Cv9fWWzlS7/WVTlJAoGBANVF | ||
16 | -kol+KojM4DEASrw0s1mfPr0XvUFvKJ2TgVGR3HxAk4r0e0WwJdSfwGiB/ePcc6g5 | ||
17 | -D5dxBe8W5g3+V0DaC0f1DDNXg2MjYWoByWrurbm14FRnpMnx/UfZLo7rq8T9YrUT | ||
18 | -Bd/y0/JasndN27bIfd60n233IYMqhV2+wBwqD3AxAoGAE2/wdHYJMk4Z9gjZ6WKL | ||
19 | -8VKVIUq759X4XbXrzhsO1TGKP4xY6bZRKIIYtNs65dwvmHD13Yw9H+MNxqyjlkTg | ||
20 | -h0dvpRtNW1ij1bBhOefCAbZnL2AviMyyRpKs81J/A0uxZ8P8qad4gf3ypxHqSD9W | ||
21 | -b3fz3QivDZsl/6Pgvf6wOWkCgYEA1Cv9x5lj2WrxEu62axyG3P9nHBm055cdsf5g | ||
22 | -JfVVg6t+3TuyM7c1O52efpnsKrdTvKTf1QrVG3INdxh0V4lUtcac16sVhBhbvml+ | ||
23 | -p0pCPMIrJe1ibKG5F7SB9B+TaEuo2nnNW2mp367JY5VqoyI8zsWk4nJ8vZAc1BGD | ||
24 | -78EMUNECgYEAtV0pta3GuHKOLX1HMRsUsYuWjLqAbahnciF6MnjNWSonEK3VjMhI | ||
25 | -g+krP/9sWoC3cFOG+4s96ubjDTWImvQvCrPaENdvlNwgp035bn51eFRv00QchM2H | ||
26 | -VCS9Nhoqj5BIHl1G7Q13+tYTzjUWtteG902nWDVhgSlNLJf1rbTn34g= | 2 | +MIIEpAIBAAKCAQEA45R02HLq/QHraf7VBf6QO4ca1StnmvztF5BLVU7txhKe9FD4 |
3 | +CLUhwharlUlPPjYFdqm9pFxynUqt15djEPhGVUEFeBpf931pVuPugNmZ/AVj0p8y | ||
4 | +06eTNLphkrzCdBzISUN5E3PKglz3efIzq6ZK8vbns/XSQA9NRzAPTboe0KC0Flj4 | ||
5 | +YPP1X69aJiBOGClsAjG1EXQ6gxepBiL1Fq3GtpKHrQPFHffUXEkPZJz09x6RxpuU | ||
6 | +CrtxUKdO6eKg89COo3xLXVpOZu94+csBAgvXqmADp/XCQELZRMTTEA4OIyz7yXoK | ||
7 | +nmqceoHaeSv4nzDDMwzITFvWmZHDPHLuZwNSZwIDAQABAoIBAQDGPKf3b0rQLt7g | ||
8 | +irEGsrLyl4JBE7kA4bao4vEsEz+9XLUHfoxAEX+hcFvwA1a6ixYBQmRGCp1v9AAw | ||
9 | +HteVjZ6+XpAkCV102NJsdMlphaLDS/KjIjeE9KCeuoeJ6VC9EeFJKDQMRL2vBsov | ||
10 | +eFGYAJeiwn4cXVHSqUGYc/2wqCJ1eRHJkvprDqIeZU8ND3uQ5Gz/5azezf8hBu2P | ||
11 | +MUDseX1PzdvvElidxpHR1KsZTvGVFMMFWRcSDfQYSIB8EevMKQS2YwU9kmiCI3s3 | ||
12 | +qDEAc/Usj64oRLh3Wwh9V0H26zpn/XyQ5pzYmWtCGUpifGuAAQeFKc1jPN6fJy6a | ||
13 | +WwLprqV5AoGBAP0k7btOXE5+hmMGcuiu3vWg0X3EOQf7MtMlsrMbqrzS4HbaaMqP | ||
14 | +BW4hrQOLl8zB9vOYt0TuK0/+ONLlCgYiodqA8FkC7TUHcTyHUEIE3+QTrI23CY6z | ||
15 | +AbJgnHew4jKhRvbLFHkrrIMWgRIDlIwk7HFwHLpU9tw2SsHMz6hWQjY1AoGBAOYl | ||
16 | +suq/hyYHlI6ggbzkFjchlRxBFEOm8GOa6LLjuP0sxbaFXXfFUtw4YhO0WL8X9JSm | ||
17 | +Qtsb4HVQPZMGlrY5rale4FOXBnSovt0LuPR3gX9OaK9T9x4X+gabQrlGIlcS2QRM | ||
18 | +AvwPGlWptLLmQOgWdcZ5xOGEWdXDhIFrAK6khEmrAoGBAJDRM39YEM6G63JzGgGr | ||
19 | +KLn0SmRcgRPjzOumQVjdlwt2yBq2UASxVTXv5f6FOU5WGGS7FP1GE1kr4m4jwVxJ | ||
20 | +K7bI1LbXScRwgYNTFcLu7vaXmrtn3vvXxDy7sEd41a6JPQOqoge/yG0lzqjzi2Ox | ||
21 | +K+KpdIXUXXUVSicceB+hWTeRAoGAIVuXejT2hsmUe7PB+jnpCmagsS6xnDinIRjD | ||
22 | +36HoHzINGi5sZL7CCs9VT9vU/SWguqb6i72XpAlUU2oiEBl+FU1+ID+EnQYUW/+l | ||
23 | ++DEWIPihbcAy0jbRc4GvgyEqOwqtT9UgnZ4myAHIAiIjiEAxI+pkYfeH+dbT7tou | ||
24 | +iCGqVu8CgYBOF/1Ek3ex23CryLuMHg8wp0VHSSuksnurMWkg/H8qBT7NjWhVNRCi | ||
25 | +mrjy2oCSI6TKPwVZQo15LeOuhXkfYFig667sBvo59Nz+QBQhh6NGwrSiZuYlf3F/ | ||
26 | +8mgDIjspJm4R9kFRAZZcsuHH6hHAge5Lik/yRyztxI9Vlpok6e1bEw== | ||
27 | -----END RSA PRIVATE KEY----- | 27 | -----END RSA PRIVATE KEY----- |
1 | -----BEGIN CERTIFICATE----- | 1 | -----BEGIN CERTIFICATE----- |
2 | -MIIGazCCBVOgAwIBAgIQZBwijHoFToh2kjGwQ1E6bjANBgkqhkiG9w0BAQsFADBc | ||
3 | -MQswCQYDVQQGEwJDTjEaMBgGA1UEChMRV29UcnVzIENBIExpbWl0ZWQxMTAvBgNV | ||
4 | -BAMMKFdvVHJ1cyBPViBTZXJ2ZXIgQ0EgIFtSdW4gYnkgdGhlIElzc3Vlcl0wHhcN | ||
5 | -MjEwMjA0MDAwMDAwWhcNMjIwMzA2MjM1OTU5WjCB0TELMAkGA1UEBhMCQ04xDzAN | ||
6 | -BgNVBBETBjM1MDAxNTESMBAGA1UEBwwJ56aP5bee5biCMU8wTQYDVQQJDEbpqazl | ||
7 | -sL7ljLrmuZbph4zot68yN+WPtzEj5qW85LqU5qW8NTEw44CBNTEx5a6k77yI6Ieq | ||
8 | -6LS46K+V6aqM5Yy65YaF77yJMTAwLgYDVQQKDCfnpo/lu7rkubDkubDkubDkv6Hm | ||
9 | -ga/np5HmioDmnInpmZDlhazlj7gxGjAYBgNVBAMMESouZmptYWltYWltYWkuY29t | ||
10 | -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy0OxRf+NheQG9epxbrud | ||
11 | -wnrzqVgqK5zCuRAkLUgaSMATVXEAiDzJN39om+Q49MmtEk4pXGzKUyzkFJG96PA8 | ||
12 | -tJq0E+bSDtSK3n+2mjZb6pChmgHwKEX7T8ZVLqJBSrfrI4Z2BJDNEC+3wvVW3zpo | ||
13 | -g1RlfKgft6NYUzNLUqE5Mxzq7lpDeRsq+FhzM1sOeEb2dAmUlDDs+7HcR3Kj0ttK | ||
14 | -eg+hKqIottQ/H6Tq4c8deEQGnO0+RN3CygyETbYmLuWttI/sUltulWJALIuU81Yr | ||
15 | -6uCOq5MSt2WsU8CTuhRwGXSvcQCOFLYppYktoMDOGIBQffmJc/DdT1d35fvdpKbm | ||
16 | -+QIDAQABo4ICsTCCAq0wHwYDVR0jBBgwFoAUDUmPFTN7wE+2+zo4Cfw0Fdpg3RQw | ||
17 | -HQYDVR0OBBYEFMGZEgzwtp+UhpTAS9nmSxlo9tIlMA4GA1UdDwEB/wQEAwIFoDAM | ||
18 | -BgNVHRMBAf8EAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBJBgNV | ||
19 | -HSAEQjBAMDQGCysGAQQBsjEBAgIWMCUwIwYIKwYBBQUHAgEWF2h0dHBzOi8vc2Vj | ||
20 | -dGlnby5jb20vQ1BTMAgGBmeBDAECAjA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8v | ||
21 | -Y3JsLmNybG9jc3AuY24vV29UcnVzT1ZTZXJ2ZXJDQV8yLmNybDBsBggrBgEFBQcB | ||
22 | -AQRgMF4wOAYIKwYBBQUHMAKGLGh0dHA6Ly9haWEuY3Jsb2NzcC5jbi9Xb1RydXNP | ||
23 | -VlNlcnZlckNBXzIuY3J0MCIGCCsGAQUFBzABhhZodHRwOi8vb2NzcC5jcmxvY3Nw | ||
24 | -LmNuMIIBBQYKKwYBBAHWeQIEAgSB9gSB8wDxAHcARqVV63X6kSAwtaKJafTzfREs | ||
25 | -QXS+/Um4havy/HD+bUcAAAF3brV9qAAABAMASDBGAiEAjrXS+1JJW9jag/XfW+kY | ||
26 | -oL4sGGDNvcZgV35E0EcGQVACIQCjQh8k5oSFtqo7Qrbx2k3OISjfPSYRXNNsG4Ba | ||
27 | -MyDmRwB2AN+lXqtogk8fbK3uuF9OPlrqzaISpGpejjsSwCBEXCpzAAABd261fdAA | ||
28 | -AAQDAEcwRQIgcPQQJ3rkCFaQPKwT3rtfQkr0taPzw0KW7yqu+MtmBH0CIQChKeMk | ||
29 | -v7Xs0z7J47lM6HTPOU+xXL2riC69LC1KCOS6GTAtBgNVHREEJjAkghEqLmZqbWFp | ||
30 | -bWFpbWFpLmNvbYIPZmptYWltYWltYWkuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQBn | ||
31 | -+jDy7sZS0gZzwMR4hnZHWqFYcJR3wnk77xr+5Yu2ifhlxaLHE3rEY3xTR9LsPwfW | ||
32 | -pdg2McinPCI6vs009NYIpeTiHzVDPzKu2BaUfKj+EHLwZQGfXkNhp3cpqZMiTkr/ | ||
33 | -YNqf25GXsBa+spwzyHh9MBXXCfWRfdHX7JlH5zyoLNztTp8unxaRYldjghHDA3Q7 | ||
34 | -8Fyz6OncY3I4U4KKBSq2/TTxveDW6NxTTuJTPOg3/qSIkwdOBLuIzuhxmF4D9wpl | ||
35 | -LMHmne2CilVeg73/GAzQt/w7FzmdvaHPAOVYWzdaTNALiXJxbi7EyO8q/uNK0GqY | ||
36 | -hljMsnA1hApG+/2sOP/P | 2 | +MIIGeTCCBWGgAwIBAgIRAI8zZs95ViIzW/6yB+17fngwDQYJKoZIhvcNAQELBQAw |
3 | +XDELMAkGA1UEBhMCQ04xGjAYBgNVBAoTEVdvVHJ1cyBDQSBMaW1pdGVkMTEwLwYD | ||
4 | +VQQDDChXb1RydXMgT1YgU2VydmVyIENBICBbUnVuIGJ5IHRoZSBJc3N1ZXJdMB4X | ||
5 | +DTIyMDIxMDAwMDAwMFoXDTIzMDMxMjIzNTk1OVowZjELMAkGA1UEBhMCQ04xEjAQ | ||
6 | +BgNVBAgMCeemj+W7uuecgTEnMCUGA1UECgwe5aSp6IGU5L+h5oGv56eR5oqA5pyJ | ||
7 | +6ZmQ5YWs5Y+4MRowGAYDVQQDDBEqLmZqbWFpbWFpbWFpLmNvbTCCASIwDQYJKoZI | ||
8 | +hvcNAQEBBQADggEPADCCAQoCggEBAOOUdNhy6v0B62n+1QX+kDuHGtUrZ5r87ReQ | ||
9 | +S1VO7cYSnvRQ+Ai1IcIWq5VJTz42BXapvaRccp1KrdeXYxD4RlVBBXgaX/d9aVbj | ||
10 | +7oDZmfwFY9KfMtOnkzS6YZK8wnQcyElDeRNzyoJc93nyM6umSvL257P10kAPTUcw | ||
11 | +D026HtCgtBZY+GDz9V+vWiYgThgpbAIxtRF0OoMXqQYi9RatxraSh60DxR331FxJ | ||
12 | +D2Sc9PcekcablAq7cVCnTunioPPQjqN8S11aTmbvePnLAQIL16pgA6f1wkBC2UTE | ||
13 | +0xAODiMs+8l6Cp5qnHqB2nkr+J8wwzMMyExb1pmRwzxy7mcDUmcCAwEAAaOCAyow | ||
14 | +ggMmMB8GA1UdIwQYMBaAFA1JjxUze8BPtvs6OAn8NBXaYN0UMB0GA1UdDgQWBBSd | ||
15 | +7Jpt75ZS1gDF9uvt6jq/wsM6pTAOBgNVHQ8BAf8EBAMCBaAwDAYDVR0TAQH/BAIw | ||
16 | +ADAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwSQYDVR0gBEIwQDA0Bgsr | ||
17 | +BgEEAbIxAQICFjAlMCMGCCsGAQUFBwIBFhdodHRwczovL3NlY3RpZ28uY29tL0NQ | ||
18 | +UzAIBgZngQwBAgIwPQYDVR0fBDYwNDAyoDCgLoYsaHR0cDovL2NybC5jcmxvY3Nw | ||
19 | +LmNuL1dvVHJ1c09WU2VydmVyQ0FfMi5jcmwwbAYIKwYBBQUHAQEEYDBeMDgGCCsG | ||
20 | +AQUFBzAChixodHRwOi8vYWlhLmNybG9jc3AuY24vV29UcnVzT1ZTZXJ2ZXJDQV8y | ||
21 | +LmNydDAiBggrBgEFBQcwAYYWaHR0cDovL29jc3AuY3Jsb2NzcC5jbjCCAX4GCisG | ||
22 | +AQQB1nkCBAIEggFuBIIBagFoAHYArfe++nz/EMiLnT2cHj4YarRnKV3PsQwkyoWG | ||
23 | +NOvcgooAAAF+4S03XgAABAMARzBFAiEAqR1sq52hM4f5aS3cvFX0eMSDkBy0Ezbf | ||
24 | +8O6DPg7404sCIC+acfUKRvt4A89tcgvdK8TiAvFb1zaaN5608wtyLUcRAHcAejKM | ||
25 | +VNi3LbYg6jjgUh7phBZwMhOFTTvSK8E6V6NS61IAAAF+4S03HAAABAMASDBGAiEA | ||
26 | +7OiNg/IGkzMm3/NDw+oZuqDAYgigaq9Bsh67gyRDw9oCIQCexK1Oo74f6IMRebPU | ||
27 | +Z2/U6DyiOh6bUu/qJJyyhjBHrgB1AOg+0No+9QY1MudXKLyJa8kD08vREWvs62nh | ||
28 | +d31tBr1uAAABfuEtNwMAAAQDAEYwRAIgWcr/D/Ygi5WOeoRdpg93smwz6snU9vxL | ||
29 | +I0CLiufIfKECIAFvFv9PMrHTyC05TIGfWfkVHqGZoPjPKRUtZyoWlMGaMC0GA1Ud | ||
30 | +EQQmMCSCESouZmptYWltYWltYWkuY29tgg9mam1haW1haW1haS5jb20wDQYJKoZI | ||
31 | +hvcNAQELBQADggEBAHhfZLmBvIDl9kQvKZf2IrFUNbd9/yLWnrCoKOaQejVVOGkZ | ||
32 | +BmFpn2ZXGCfuCZUqhZQLc9xL49fkmBACQJa358pLUcrMRweZPPRPW53uGWH6N3IA | ||
33 | +cAShUscFU9LBZ7ynbK9OG58E1O9/taJVQGd7YmjhEyA7A3oTtxjedk1ZPz1Hue/w | ||
34 | +au5wfAg9Tl4ds8/rPTCACSYTd1HXhR9OuqDcinTdtwJrzKp3NKWpQjPvgpNcaJPA | ||
35 | +j8JHnggP3GDe4xGNyt6CmNuZpWVm23CT7pFYwqQYTLqKB5yFRK4PUZ3PPKz49gQv | ||
36 | +hkln6/8l93Jt5oRolk4kq6A/D64jwlNwa7EPlz8= | ||
37 | -----END CERTIFICATE----- | 37 | -----END CERTIFICATE----- |
38 | -----BEGIN CERTIFICATE----- | 38 | -----BEGIN CERTIFICATE----- |
39 | MIIF4TCCA8mgAwIBAgIQHQgpVDhMv3SvabmRFpvwLTANBgkqhkiG9w0BAQwFADCB | 39 | MIIF4TCCA8mgAwIBAgIQHQgpVDhMv3SvabmRFpvwLTANBgkqhkiG9w0BAQwFADCB |
deploy/k8s/test/.gitkeep
0 → 100644
1 | +apiVersion: v1 | ||
2 | +kind: Service | ||
3 | +metadata: | ||
4 | + name: allied-creation-manufacture | ||
5 | + namespace: mmm-suplus-test | ||
6 | + labels: | ||
7 | + k8s-app: allied-creation-manufacture | ||
8 | +spec: | ||
9 | + ports: | ||
10 | + - name: "http" | ||
11 | + port: 80 | ||
12 | + targetPort: 8082 | ||
13 | + selector: | ||
14 | + k8s-app: allied-creation-manufacture | ||
15 | +--- | ||
16 | +apiVersion: extensions/v1beta1 | ||
17 | +kind: Deployment | ||
18 | +metadata: | ||
19 | + name: allied-creation-manufacture | ||
20 | + namespace: mmm-suplus-test | ||
21 | + labels: | ||
22 | + k8s-app: allied-creation-manufacture | ||
23 | +spec: | ||
24 | + replicas: 1 | ||
25 | + template: | ||
26 | + metadata: | ||
27 | + labels: | ||
28 | + k8s-app: allied-creation-manufacture | ||
29 | + spec: | ||
30 | + affinity: | ||
31 | + nodeAffinity: | ||
32 | + preferredDuringSchedulingIgnoredDuringExecution: | ||
33 | + - preference: {} | ||
34 | + weight: 100 | ||
35 | + requiredDuringSchedulingIgnoredDuringExecution: | ||
36 | + nodeSelectorTerms: | ||
37 | + - matchExpressions: | ||
38 | + - key: kubernetes.io/hostname | ||
39 | + operator: In | ||
40 | + values: | ||
41 | + - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
42 | + - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | + containers: | ||
46 | + - name: allied-creation-manufacture | ||
47 | + image: 192.168.0.243:5000/mmm/allied-creation-manufacture:dev | ||
48 | + imagePullPolicy: Always | ||
49 | + ports: | ||
50 | + - containerPort: 8082 | ||
51 | + env: | ||
52 | + - name: POSTGRESQL_DB_NAME | ||
53 | + valueFrom: | ||
54 | + configMapKeyRef: | ||
55 | + name: suplus-config | ||
56 | + key: postgresqlalliedcreation.dbname | ||
57 | + - name: POSTGRESQL_USER | ||
58 | + valueFrom: | ||
59 | + configMapKeyRef: | ||
60 | + name: suplus-config | ||
61 | + key: postgresql.user | ||
62 | + - name: POSTGRESQL_PASSWORD | ||
63 | + valueFrom: | ||
64 | + configMapKeyRef: | ||
65 | + name: suplus-config | ||
66 | + key: postgresql.password | ||
67 | + - name: POSTGRESQL_HOST | ||
68 | + valueFrom: | ||
69 | + configMapKeyRef: | ||
70 | + name: suplus-config | ||
71 | + key: postgresql.host | ||
72 | + - name: POSTGRESQL_PORT | ||
73 | + valueFrom: | ||
74 | + configMapKeyRef: | ||
75 | + name: suplus-config | ||
76 | + key: postgresql.port | ||
77 | + - name: REDIS_HOST | ||
78 | + valueFrom: | ||
79 | + configMapKeyRef: | ||
80 | + name: suplus-config | ||
81 | + key: redis.ip | ||
82 | + - name: REDIS_PORT | ||
83 | + valueFrom: | ||
84 | + configMapKeyRef: | ||
85 | + name: suplus-config | ||
86 | + key: redis.port | ||
87 | + - name: REDIS_AUTH | ||
88 | + value: "" | ||
89 | + - name: LOG_LEVEL | ||
90 | + value: "debug" | ||
91 | + - name: ERROR_BASE_CODE | ||
92 | + value: "1" | ||
93 | + - name: ERROR_BASE_CODE_MULTIPLE | ||
94 | + value: "2000" | ||
95 | + - name: ENABLE_KAFKA_LOG | ||
96 | + value: "true" | ||
97 | + - name: HTTP_PORT | ||
98 | + value: "8082" | ||
99 | + - name: SERVICE_ENV | ||
100 | + value: "dev" | ||
101 | + - name: SUPLUS_ADMIN_BASE_HOST | ||
102 | + value: "http://suplus-admin-base-dev.fjmaimaimai.com" | ||
103 | + - name: ALLIED_CREATION_GATEWAY_HOST | ||
104 | + value: "https://allied-creation-gateway-test.fjmaimaimai.com" | ||
105 | + - name: ALLIED_CREATION_USER_HOST | ||
106 | + value: "https://allied-creation-user-test.fjmaimaimai.com" | ||
107 | + - name: ALLIED_CREATION_COOPERATION_HOST | ||
108 | + value: "https://allied-creation-cooperation-test.fjmaimaimai.com" | ||
109 | + - name: ALLIED_CREATION_BASIC_HOST | ||
110 | + value: "https://allied-creation-basic-test.fjmaimaimai.com" | ||
111 | + - name: ALLIED_CREATION_MANUFACTURE_HOST | ||
112 | + value: "http://allied-creation-manufacture-test.fjmaimaimai.com" | ||
113 | + - name: SMS_SERVE_HOST | ||
114 | + value: "https://sms.fjmaimaimai.com:9897" | ||
115 | + - name: SUPLUS_SALE_APP | ||
116 | + value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com" | ||
117 | + - name: MANUFACTURE_DEFAULT_COMPANYID | ||
118 | + value: "23" | ||
119 | + - name: MANUFACTURE_DEFAULT_ORGID | ||
120 | + value: "487" |
deploy/k8s/test/install.sh
0 → 100644
1 | +#!/bin/bash | ||
2 | +export PATH=/root/local/bin:$PATH | ||
3 | +kubectl -n mmm-suplus-test get pods | grep -q allied-creation-manufacture | ||
4 | +if [ "$?" == "1" ];then | ||
5 | + kubectl create -f /tmp/test/allied-creation-manufacture/allied-creation-manufacture.yaml --record | ||
6 | + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-manufacture | ||
7 | + if [ "$?" == "0" ];then | ||
8 | + echo "allied-creation-manufacture service install success!" | ||
9 | + else | ||
10 | + echo "allied-creation-manufacture service install fail!" | ||
11 | + fi | ||
12 | + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-manufacture | ||
13 | + if [ "$?" == "0" ];then | ||
14 | + echo "allied-creation-manufacture deployment install success!" | ||
15 | + else | ||
16 | + echo "allied-creation-manufacture deployment install fail!" | ||
17 | + fi | ||
18 | +else | ||
19 | + kubectl delete -f /tmp/test/allied-creation-manufacture/allied-creation-manufacture.yaml | ||
20 | + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-manufacture | ||
21 | + while [ "$?" == "0" ] | ||
22 | + do | ||
23 | + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-manufacture | ||
24 | + done | ||
25 | + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-manufacture | ||
26 | + while [ "$?" == "0" ] | ||
27 | + do | ||
28 | + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-manufacture | ||
29 | + done | ||
30 | + kubectl create -f /tmp/test/allied-creation-manufacture/allied-creation-manufacture.yaml --record | ||
31 | + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-manufacture | ||
32 | + if [ "$?" == "0" ];then | ||
33 | + echo "allied-creation-manufacture service update success!" | ||
34 | + else | ||
35 | + echo "allied-creation-manufacture service update fail!" | ||
36 | + fi | ||
37 | + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-manufacture | ||
38 | + if [ "$?" == "0" ];then | ||
39 | + echo "allied-creation-manufacture deployment update success!" | ||
40 | + else | ||
41 | + echo "allied-creation-manufacture deployment update fail!" | ||
42 | + fi | ||
43 | +fi |
@@ -13,6 +13,7 @@ require ( | @@ -13,6 +13,7 @@ require ( | ||
13 | github.com/go-redis/redis v6.15.7+incompatible | 13 | github.com/go-redis/redis v6.15.7+incompatible |
14 | github.com/google/go-querystring v1.1.0 // indirect | 14 | github.com/google/go-querystring v1.1.0 // indirect |
15 | github.com/google/uuid v1.3.0 | 15 | github.com/google/uuid v1.3.0 |
16 | + github.com/hibiken/asynq v0.21.0 | ||
16 | github.com/imkira/go-interpol v1.1.0 // indirect | 17 | github.com/imkira/go-interpol v1.1.0 // indirect |
17 | github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 | 18 | github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 |
18 | github.com/moul/http2curl v1.0.0 // indirect | 19 | github.com/moul/http2curl v1.0.0 // indirect |
@@ -20,6 +21,7 @@ require ( | @@ -20,6 +21,7 @@ require ( | ||
20 | github.com/onsi/ginkgo v1.15.2 | 21 | github.com/onsi/ginkgo v1.15.2 |
21 | github.com/onsi/gomega v1.11.0 | 22 | github.com/onsi/gomega v1.11.0 |
22 | github.com/sergi/go-diff v1.2.0 // indirect | 23 | github.com/sergi/go-diff v1.2.0 // indirect |
24 | + github.com/shopspring/decimal v1.2.0 | ||
23 | github.com/smartystreets/goconvey v1.7.2 // indirect | 25 | github.com/smartystreets/goconvey v1.7.2 // indirect |
24 | github.com/stretchr/testify v1.7.0 | 26 | github.com/stretchr/testify v1.7.0 |
25 | github.com/tidwall/gjson v1.13.0 | 27 | github.com/tidwall/gjson v1.13.0 |
@@ -61,6 +61,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c | @@ -61,6 +61,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c | ||
61 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | 61 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
62 | github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= | 62 | github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= |
63 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= | 63 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= |
64 | +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= | ||
65 | +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= | ||
64 | github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | 66 | github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= |
65 | github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= | 67 | github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= |
66 | github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= | 68 | github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= |
@@ -112,6 +114,8 @@ github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8w | @@ -112,6 +114,8 @@ github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8w | ||
112 | github.com/go-redis/redis v6.15.7+incompatible h1:3skhDh95XQMpnqeqNftPkQD9jL9e5e36z/1SUm6dy1U= | 114 | github.com/go-redis/redis v6.15.7+incompatible h1:3skhDh95XQMpnqeqNftPkQD9jL9e5e36z/1SUm6dy1U= |
113 | github.com/go-redis/redis v6.15.7+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= | 115 | github.com/go-redis/redis v6.15.7+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= |
114 | github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg= | 116 | github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg= |
117 | +github.com/go-redis/redis/v8 v8.11.2 h1:WqlSpAwz8mxDSMCvbyz1Mkiqe0LE5OY4j3lgkvu1Ts0= | ||
118 | +github.com/go-redis/redis/v8 v8.11.2/go.mod h1:DLomh7y2e3ggQXQLd1YgmvIfecPJoFl7WU5SOQ/r06M= | ||
115 | github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= | 119 | github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= |
116 | github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= | 120 | github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= |
117 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= | 121 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= |
@@ -154,8 +158,9 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ | @@ -154,8 +158,9 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ | ||
154 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | 158 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |
155 | github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | 159 | github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |
156 | github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | 160 | github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |
157 | -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= | ||
158 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | 161 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |
162 | +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= | ||
163 | +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||
159 | github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= | 164 | github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= |
160 | github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= | 165 | github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= |
161 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= | 166 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= |
@@ -163,6 +168,7 @@ github.com/google/gops v0.3.7/go.mod h1:bj0cwMmX1X4XIJFTjR99R5sCxNssNJ8HebFNvoQl | @@ -163,6 +168,7 @@ github.com/google/gops v0.3.7/go.mod h1:bj0cwMmX1X4XIJFTjR99R5sCxNssNJ8HebFNvoQl | ||
163 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= | 168 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= |
164 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 169 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
165 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 170 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
171 | +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||
166 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= | 172 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= |
167 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 173 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
168 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= | 174 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= |
@@ -180,6 +186,8 @@ github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1 | @@ -180,6 +186,8 @@ github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1 | ||
180 | github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= | 186 | github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= |
181 | github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= | 187 | github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= |
182 | github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= | 188 | github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= |
189 | +github.com/hibiken/asynq v0.21.0 h1:uH9XogJhjq/S39E0/DEPWLZQ6hHJ73UiblZTe4RzHwA= | ||
190 | +github.com/hibiken/asynq v0.21.0/go.mod h1:tyc63ojaW8SJ5SBm8mvI4DDONsguP5HE85EEl4Qr5Ig= | ||
183 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= | 191 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= |
184 | github.com/iancoleman/strcase v0.1.2/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= | 192 | github.com/iancoleman/strcase v0.1.2/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= |
185 | github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk= | 193 | github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk= |
@@ -266,6 +274,7 @@ github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ | @@ -266,6 +274,7 @@ github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ | ||
266 | github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= | 274 | github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= |
267 | github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= | 275 | github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= |
268 | github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= | 276 | github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= |
277 | +github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg= | ||
269 | github.com/onsi/ginkgo v1.15.2 h1:l77YT15o814C2qVL47NOyjV/6RbaP7kKdrvZnxQ3Org= | 278 | github.com/onsi/ginkgo v1.15.2 h1:l77YT15o814C2qVL47NOyjV/6RbaP7kKdrvZnxQ3Org= |
270 | github.com/onsi/ginkgo v1.15.2/go.mod h1:Dd6YFfwBW84ETqqtL0CPyPXillHgY6XhQH3uuCCTr/o= | 279 | github.com/onsi/ginkgo v1.15.2/go.mod h1:Dd6YFfwBW84ETqqtL0CPyPXillHgY6XhQH3uuCCTr/o= |
271 | github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= | 280 | github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= |
@@ -273,6 +282,7 @@ github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa | @@ -273,6 +282,7 @@ github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa | ||
273 | github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= | 282 | github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= |
274 | github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= | 283 | github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= |
275 | github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= | 284 | github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= |
285 | +github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= | ||
276 | github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug= | 286 | github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug= |
277 | github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg= | 287 | github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg= |
278 | github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= | 288 | github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= |
@@ -314,6 +324,8 @@ github.com/richardlehane/mscfb v1.0.3 h1:rD8TBkYWkObWO0oLDFCbwMeZ4KoalxQy+QgniCj | @@ -314,6 +324,8 @@ github.com/richardlehane/mscfb v1.0.3 h1:rD8TBkYWkObWO0oLDFCbwMeZ4KoalxQy+QgniCj | ||
314 | github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= | 324 | github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= |
315 | github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9M9xC1o= | 325 | github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9M9xC1o= |
316 | github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= | 326 | github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= |
327 | +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= | ||
328 | +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= | ||
317 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= | 329 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= |
318 | github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= | 330 | github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= |
319 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= | 331 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= |
@@ -325,6 +337,8 @@ github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI | @@ -325,6 +337,8 @@ github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI | ||
325 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg= | 337 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg= |
326 | github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= | 338 | github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= |
327 | github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= | 339 | github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= |
340 | +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= | ||
341 | +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= | ||
328 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= | 342 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= |
329 | github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= | 343 | github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= |
330 | github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s= | 344 | github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s= |
@@ -340,6 +354,8 @@ github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3 | @@ -340,6 +354,8 @@ github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3 | ||
340 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= | 354 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= |
341 | github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= | 355 | github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= |
342 | github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= | 356 | github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= |
357 | +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= | ||
358 | +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= | ||
343 | github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= | 359 | github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= |
344 | github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= | 360 | github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= |
345 | github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE= | 361 | github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE= |
@@ -432,6 +448,8 @@ go.opentelemetry.io/otel/trace v0.19.0/go.mod h1:4IXiNextNOpPnRlI4ryK69mn5iC84bj | @@ -432,6 +448,8 @@ go.opentelemetry.io/otel/trace v0.19.0/go.mod h1:4IXiNextNOpPnRlI4ryK69mn5iC84bj | ||
432 | go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= | 448 | go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= |
433 | go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0= | 449 | go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0= |
434 | go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA= | 450 | go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA= |
451 | +go.uber.org/goleak v0.10.0 h1:G3eWbSNIskeRqtsN/1uI5B+eP73y3JUuBsv9AZjehb4= | ||
452 | +go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI= | ||
435 | go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= | 453 | go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= |
436 | go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= | 454 | go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= |
437 | go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= | 455 | go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= |
@@ -540,6 +558,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | @@ -540,6 +558,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
540 | golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= | 558 | golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= |
541 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | 559 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
542 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | 560 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
561 | +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||
562 | +golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= | ||
543 | golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | 563 | golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
544 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | 564 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
545 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | 565 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
@@ -2,13 +2,14 @@ package main | @@ -2,13 +2,14 @@ package main | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/mqtt" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/task" | ||
5 | 7 | ||
6 | "github.com/beego/beego/v2/server/web" | 8 | "github.com/beego/beego/v2/server/web" |
7 | "github.com/linmadan/egglib-go/log/logrus" | 9 | "github.com/linmadan/egglib-go/log/logrus" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" |
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" |
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" |
11 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/mqtt" | ||
12 | 13 | ||
13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/crontab" | 14 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/crontab" |
14 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | 15 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" |
@@ -19,9 +20,6 @@ import ( | @@ -19,9 +20,6 @@ import ( | ||
19 | ) | 20 | ) |
20 | 21 | ||
21 | func main() { | 22 | func main() { |
22 | - log.Logger.Info("server start ....") | ||
23 | - log.Logger.Info(fmt.Sprintf("ENABLE_KAFKA_LOG:%v", constant.ENABLE_KAFKA_LOG)) | ||
24 | - | ||
25 | if constant.ENABLE_KAFKA_LOG { | 23 | if constant.ENABLE_KAFKA_LOG { |
26 | w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false) | 24 | w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false) |
27 | log.Logger.AddHook(w) | 25 | log.Logger.AddHook(w) |
@@ -33,10 +31,15 @@ func main() { | @@ -33,10 +31,15 @@ func main() { | ||
33 | }) | 31 | }) |
34 | log.Logger.AddHook(bw) | 32 | log.Logger.AddHook(bw) |
35 | redis.InitRedis() | 33 | redis.InitRedis() |
34 | + log.Logger.Debug("server start ....") | ||
35 | + log.Logger.Debug(fmt.Sprintf("ENABLE_KAFKA_LOG:%v", constant.ENABLE_KAFKA_LOG)) | ||
36 | + | ||
36 | go mqtt.Start() | 37 | go mqtt.Start() |
38 | + go task.Run() | ||
37 | cron := crontab.NewCrontabService(nil) | 39 | cron := crontab.NewCrontabService(nil) |
38 | cron.StartCrontabTask() | 40 | cron.StartCrontabTask() |
39 | defer cron.StopCrontabTask() | 41 | defer cron.StopCrontabTask() |
40 | log.Logger.Info("server start!") | 42 | log.Logger.Info("server start!") |
41 | web.Run() | 43 | web.Run() |
44 | + log.Logger.Info("server stop!") | ||
42 | } | 45 | } |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | +) | ||
10 | + | ||
11 | +type WorkerAttendanceReportCommand struct { | ||
12 | + *domain.DeviceZkTeco | ||
13 | +} | ||
14 | + | ||
15 | +func (removeProductRecordCommand *WorkerAttendanceReportCommand) Valid(validation *validation.Validation) { | ||
16 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
17 | +} | ||
18 | + | ||
19 | +func (removeProductRecordCommand *WorkerAttendanceReportCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(removeProductRecordCommand) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + elem := reflect.TypeOf(removeProductRecordCommand).Elem() | ||
27 | + for _, validErr := range valid.Errors { | ||
28 | + field, isExist := elem.FieldByName(validErr.Field) | ||
29 | + if isExist { | ||
30 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
31 | + } else { | ||
32 | + return fmt.Errorf(validErr.Message) | ||
33 | + } | ||
34 | + } | ||
35 | + } | ||
36 | + return nil | ||
37 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | +) | ||
10 | + | ||
11 | +type WorkshopWorkTimeRecordStaticsCommand struct { | ||
12 | + *domain.ProductAttendanceRecord | ||
13 | +} | ||
14 | + | ||
15 | +// Type is a string value that indicates the type of the task. | ||
16 | +//func (t *ProductRecordStaticsCommand) Type() string | ||
17 | + | ||
18 | +// Payload is the data needed for task execution. | ||
19 | +//func (t *ProductRecordStaticsCommand) Payload() []byte | ||
20 | + | ||
21 | +func (removeProductRecordCommand *WorkshopWorkTimeRecordStaticsCommand) Valid(validation *validation.Validation) { | ||
22 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
23 | +} | ||
24 | + | ||
25 | +func (removeProductRecordCommand *WorkshopWorkTimeRecordStaticsCommand) ValidateCommand() error { | ||
26 | + valid := validation.Validation{} | ||
27 | + b, err := valid.Valid(removeProductRecordCommand) | ||
28 | + if err != nil { | ||
29 | + return err | ||
30 | + } | ||
31 | + if !b { | ||
32 | + elem := reflect.TypeOf(removeProductRecordCommand).Elem() | ||
33 | + for _, validErr := range valid.Errors { | ||
34 | + field, isExist := elem.FieldByName(validErr.Field) | ||
35 | + if isExist { | ||
36 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
37 | + } else { | ||
38 | + return fmt.Errorf(validErr.Message) | ||
39 | + } | ||
40 | + } | ||
41 | + } | ||
42 | + return nil | ||
43 | +} |
@@ -2,6 +2,7 @@ package dto | @@ -2,6 +2,7 @@ package dto | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
5 | + "time" | ||
5 | ) | 6 | ) |
6 | 7 | ||
7 | type AttendanceRecordDto struct { | 8 | type AttendanceRecordDto struct { |
@@ -15,7 +16,10 @@ type AttendanceRecordDto struct { | @@ -15,7 +16,10 @@ type AttendanceRecordDto struct { | ||
15 | AttendanceType int `json:"attendanceType,omitempty"` | 16 | AttendanceType int `json:"attendanceType,omitempty"` |
16 | // 生产工人 | 17 | // 生产工人 |
17 | ProductWorker *domain.User `json:"productWorker,omitempty"` | 18 | ProductWorker *domain.User `json:"productWorker,omitempty"` |
18 | - *domain.ProductAttendanceRecordExt | 19 | + // 审核人 |
20 | + ApproveUser *domain.User `json:"approveUser"` | ||
21 | + //*domain.ProductAttendanceRecordExt | ||
22 | + ApproveAt string `json:"approveAt"` | ||
19 | // 工作位置 | 23 | // 工作位置 |
20 | *domain.WorkStation | 24 | *domain.WorkStation |
21 | // 签到 | 25 | // 签到 |
@@ -54,7 +58,20 @@ func (d *AttendanceRecordDto) LoadDto(m *domain.ProductAttendanceRecord, orgId i | @@ -54,7 +58,20 @@ func (d *AttendanceRecordDto) LoadDto(m *domain.ProductAttendanceRecord, orgId i | ||
54 | d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | 58 | d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) |
55 | if m.Ext != nil { | 59 | if m.Ext != nil { |
56 | d.OrgName = m.Ext.OrgName | 60 | d.OrgName = m.Ext.OrgName |
57 | - d.ProductAttendanceRecordExt = m.Ext.AttendanceExt | 61 | + //d.ProductAttendanceRecordExt = m.Ext.AttendanceExt |
62 | + //if | ||
63 | + if m.Ext.AttendanceExt != nil { | ||
64 | + if m.Ext.AttendanceExt.ApproveUserId > 0 { | ||
65 | + d.ApproveUser = &domain.User{ | ||
66 | + UserId: m.Ext.AttendanceExt.ApproveUserId, | ||
67 | + UserName: m.Ext.AttendanceExt.ApproveUserName, | ||
68 | + } | ||
69 | + } | ||
70 | + if m.Ext.AttendanceExt.ApproveAt > 0 { | ||
71 | + t := time.Unix(m.Ext.AttendanceExt.ApproveAt, 0) | ||
72 | + d.ApproveAt = t.Format("2006-01-02 15:04:05") | ||
73 | + } | ||
74 | + } | ||
58 | } | 75 | } |
59 | return d | 76 | return d |
60 | } | 77 | } |
1 | +package dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | +) | ||
6 | + | ||
7 | +type EmployeeAttendanceRecordDto struct { | ||
8 | + // 考勤记录ID | ||
9 | + ProductAttendanceId int `json:"productAttendanceId"` | ||
10 | + // 签到日期 | ||
11 | + SignDate string `json:"signDate"` | ||
12 | + // 工作位置 | ||
13 | + *domain.WorkStation | ||
14 | + // 生产工人 | ||
15 | + ProductWorker *domain.User `json:"productWorker,omitempty"` | ||
16 | + // 考勤类型 1.正常 2.支援 | ||
17 | + AttendanceType int `json:"attendanceType,omitempty"` | ||
18 | + //*domain.ProductAttendanceRecordExt | ||
19 | + // 考勤状态 1.未审核 2:已审核 4.自动审核 | ||
20 | + AttendanceStatus int `json:"attendanceStatus"` | ||
21 | + // 考勤类型 1.正常 2.支援 | ||
22 | + AttendanceTypeDescription string `json:"attendanceTypeDescription,omitempty"` | ||
23 | + // 员工类型描述 1:固定 2:派遣 3.临时 | ||
24 | + EmployeeTypeDescription string `json:"employeeTypeDescription,omitempty"` | ||
25 | + // 考勤状态 1.未审核 2:已审核 4.自动审核 | ||
26 | + AttendanceStatusDescription string `json:"attendanceStatusDescription"` | ||
27 | + // 工时 | ||
28 | + WorkTime float64 `json:"workTime"` | ||
29 | + // 组织名称 | ||
30 | + OrgName string `json:"orgName"` | ||
31 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
32 | + AuthFlag bool `json:"authFlag"` | ||
33 | +} | ||
34 | + | ||
35 | +func (d *EmployeeAttendanceRecordDto) LoadDto(m *domain.ProductAttendanceRecord, orgId int) *EmployeeAttendanceRecordDto { | ||
36 | + d.ProductAttendanceId = m.ProductAttendanceId | ||
37 | + d.AttendanceType = m.AttendanceType | ||
38 | + d.ProductWorker = m.ProductWorker | ||
39 | + d.WorkStation = m.WorkStation | ||
40 | + if !m.SignIn.IsZero() { | ||
41 | + //d.SignIn = m.SignIn.Format("15:04:05") | ||
42 | + d.SignDate = m.SignIn.Format("2006-01-02") | ||
43 | + } | ||
44 | + d.WorkTime = m.WorkTimeAfter | ||
45 | + //d.WorkTimeAfter = m.WorkTimeAfter | ||
46 | + d.AttendanceStatus = m.AttendanceStatus | ||
47 | + d.AttendanceTypeDescription = domain.ParticipateTypeDescription(m.AttendanceType) | ||
48 | + d.EmployeeTypeDescription = domain.EmployeeTypeDescription(m.ProductWorker.EmployeeType) | ||
49 | + d.AttendanceStatusDescription = domain.AttendanceStatusDescription(m.AttendanceStatus) | ||
50 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
51 | + if m.Ext != nil { | ||
52 | + d.OrgName = m.Ext.OrgName | ||
53 | + //d.ProductAttendanceRecordExt = m.Ext.AttendanceExt | ||
54 | + } | ||
55 | + return d | ||
56 | +} |
1 | +package dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | +) | ||
6 | + | ||
7 | +type WorkshopWorkTimeRecordDto struct { | ||
8 | + // 车间工时记录ID | ||
9 | + WorkshopWorkTimeRecordId int `json:"workshopWorkTimeRecordId"` | ||
10 | + // 工作位置 | ||
11 | + *domain.WorkStation | ||
12 | + // 签到日期 | ||
13 | + //SignDate string `json:"signDate"` | ||
14 | + // 记录信息 | ||
15 | + *domain.WorkshopWorkTimeRecordInfo | ||
16 | + // 记录日期 | ||
17 | + RecordDate string `json:"recordDate"` | ||
18 | + // 组织名称 | ||
19 | + OrgName string `json:"orgName"` | ||
20 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
21 | + AuthFlag bool `json:"authFlag"` | ||
22 | +} | ||
23 | + | ||
24 | +func (d *WorkshopWorkTimeRecordDto) LoadDto(m *domain.WorkshopWorkTimeRecord, orgId int) *WorkshopWorkTimeRecordDto { | ||
25 | + d.WorkshopWorkTimeRecordId = m.WorkshopWorkTimeRecordId | ||
26 | + d.WorkStation = m.WorkStation | ||
27 | + d.WorkshopWorkTimeRecordInfo = m.WorkshopWorkTimeRecordInfo | ||
28 | + d.WorkStation = m.WorkStation | ||
29 | + d.RecordDate = m.RecordDate.Format("2006-01-02") | ||
30 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
31 | + if m.Ext != nil { | ||
32 | + d.OrgName = m.Ext.OrgName | ||
33 | + //d.ProductAttendanceRecordExt = m.Ext.AttendanceExt | ||
34 | + } | ||
35 | + return d | ||
36 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | + "time" | ||
10 | + | ||
11 | + "github.com/beego/beego/v2/core/validation" | ||
12 | +) | ||
13 | + | ||
14 | +type SearchEmployeeAttendanceQuery struct { | ||
15 | + // 查询偏离量 | ||
16 | + Offset int `cname:"查询偏离量" json:"offset"` | ||
17 | + // 查询限制 | ||
18 | + Limit int `cname:"查询限制" json:"limit"` | ||
19 | + // 当前公司 | ||
20 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
21 | + // 当前登录的组织 | ||
22 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty" ` | ||
23 | + // 匹配多个组织 | ||
24 | + InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty" ` | ||
25 | + // 页码 | ||
26 | + PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | ||
27 | + // 页数 | ||
28 | + PageSize int `cname:"页数" json:"pageSize,omitempty"` | ||
29 | + // 车间名称 | ||
30 | + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"` | ||
31 | + // 生产线名称 | ||
32 | + LineName string `cname:"生产线名称" json:"lineName,omitempty"` | ||
33 | + // 工段名称 | ||
34 | + SectionName string `cname:"工段名称" json:"sectionName,omitempty"` | ||
35 | + // 姓名 | ||
36 | + UserName string `cname:"姓名" json:"userName,omitempty"` | ||
37 | + // 考勤状态 1.未审核 2:已审核 3.自动审核 | ||
38 | + AttendanceStatus int `cname:"考勤状态 1.未审核 2:已审核 3.自动审核" json:"attendanceStatus,omitempty"` | ||
39 | + // 员工类型 1:固定 2:派遣 3.临时 | ||
40 | + EmployeeType int `cname:"1:固定 2:派遣 3.临时" json:"employeeType,omitempty"` | ||
41 | + // 开始时间 | ||
42 | + BeginTime string `cname:"开始时间" json:"beginTime"` | ||
43 | + // 结束时间 | ||
44 | + EndTime string `cname:"结束时间" json:"endTime"` | ||
45 | + | ||
46 | + // 开始时间 | ||
47 | + SignBeginTime time.Time `cname:"开始时间" json:"signBeginTime"` | ||
48 | + // 结束时间 | ||
49 | + SignEndTime time.Time `cname:"结束时间" json:"signEndTime"` | ||
50 | +} | ||
51 | + | ||
52 | +func (cmd *SearchEmployeeAttendanceQuery) Valid(validation *validation.Validation) { | ||
53 | + cmd.Offset, cmd.Limit = domain.Pagination(cmd.PageNumber, cmd.PageSize) | ||
54 | + var err error | ||
55 | + if len(cmd.BeginTime) > 0 { | ||
56 | + if cmd.SignBeginTime, err = time.Parse("2006-01-02 15:04:05", cmd.BeginTime); err != nil { | ||
57 | + log.Logger.Error(err.Error()) | ||
58 | + validation.Error("开始时间有误") | ||
59 | + return | ||
60 | + } | ||
61 | + } | ||
62 | + if len(cmd.EndTime) > 0 { | ||
63 | + if cmd.SignEndTime, err = time.Parse("2006-01-02 15:04:05", cmd.EndTime); err != nil { | ||
64 | + log.Logger.Error(err.Error()) | ||
65 | + validation.Error("结束时间有误") | ||
66 | + return | ||
67 | + } | ||
68 | + } | ||
69 | + cmd.AttendanceStatus = 6 // 审核 + 自动审核 | ||
70 | +} | ||
71 | + | ||
72 | +func (cmd *SearchEmployeeAttendanceQuery) ValidateQuery() error { | ||
73 | + valid := validation.Validation{} | ||
74 | + b, err := valid.Valid(cmd) | ||
75 | + if err != nil { | ||
76 | + return err | ||
77 | + } | ||
78 | + if !b { | ||
79 | + elem := reflect.TypeOf(cmd).Elem() | ||
80 | + for _, validErr := range valid.Errors { | ||
81 | + field, isExist := elem.FieldByName(validErr.Field) | ||
82 | + if isExist { | ||
83 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
84 | + } else { | ||
85 | + return fmt.Errorf(validErr.Message) | ||
86 | + } | ||
87 | + } | ||
88 | + } | ||
89 | + return nil | ||
90 | +} |
@@ -44,14 +44,16 @@ func (attendanceService *AttendanceService) ApproveAttendance(cmd *command.Appro | @@ -44,14 +44,16 @@ func (attendanceService *AttendanceService) ApproveAttendance(cmd *command.Appro | ||
44 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 44 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
45 | } | 45 | } |
46 | 46 | ||
47 | - if err = attendance.Approve(user, cmd.WorkTimeAfter); err != nil { | 47 | + if err = attendance.Approve(user, cmd.WorkTimeAfter, domain.AttendanceApproved); err != nil { |
48 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 48 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
49 | } | 49 | } |
50 | 50 | ||
51 | if _, err := productAttendanceRecordRepository.Save(attendance); err != nil { | 51 | if _, err := productAttendanceRecordRepository.Save(attendance); err != nil { |
52 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 52 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
53 | } | 53 | } |
54 | - | 54 | + if err := domainService.SendWorkshopWorkTimeStaticJob(attendance); err != nil { |
55 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
56 | + } | ||
55 | if err := transactionContext.CommitTransaction(); err != nil { | 57 | if err := transactionContext.CommitTransaction(); err != nil { |
56 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 58 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
57 | } | 59 | } |
@@ -117,6 +119,7 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain | @@ -117,6 +119,7 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain | ||
117 | ProductGroupId: productGroup.ProductGroupId, | 119 | ProductGroupId: productGroup.ProductGroupId, |
118 | }), | 120 | }), |
119 | } | 121 | } |
122 | + newAttendance.WorkTimeBefore = newAttendance.ComputeWorkTimeBefore() | ||
120 | var attendanceRepository domain.ProductAttendanceRecordRepository | 123 | var attendanceRepository domain.ProductAttendanceRecordRepository |
121 | 124 | ||
122 | attendanceRepository, _, _ = factory.FastPgAttendance(transactionContext, 0) | 125 | attendanceRepository, _, _ = factory.FastPgAttendance(transactionContext, 0) |
@@ -310,6 +313,74 @@ func (attendanceService *AttendanceService) SearchAttendance(operateInfo *domain | @@ -310,6 +313,74 @@ func (attendanceService *AttendanceService) SearchAttendance(operateInfo *domain | ||
310 | return count, result, nil | 313 | return count, result, nil |
311 | } | 314 | } |
312 | 315 | ||
316 | +// 员工工时统计 | ||
317 | +func (attendanceService *AttendanceService) SearchEmployeeAttendanceStatics(operateInfo *domain.OperateInfo, cmd *query.SearchEmployeeAttendanceQuery) (int64, interface{}, error) { | ||
318 | + if err := cmd.ValidateQuery(); err != nil { | ||
319 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
320 | + } | ||
321 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
322 | + if err != nil { | ||
323 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
324 | + } | ||
325 | + if err := transactionContext.StartTransaction(); err != nil { | ||
326 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
327 | + } | ||
328 | + defer func() { | ||
329 | + transactionContext.RollbackTransaction() | ||
330 | + }() | ||
331 | + var attendanceRepository domain.ProductAttendanceRecordRepository | ||
332 | + attendanceRepository, _, _ = factory.FastPgAttendance(transactionContext, 0) | ||
333 | + | ||
334 | + queryOptions := utils.ObjectToMap(cmd) | ||
335 | + count, attendances, err := attendanceRepository.Find(queryOptions) | ||
336 | + if err != nil { | ||
337 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
338 | + } | ||
339 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
340 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
341 | + } | ||
342 | + var result = make([]*dto.EmployeeAttendanceRecordDto, 0) | ||
343 | + for i := range attendances { | ||
344 | + newItem := &dto.EmployeeAttendanceRecordDto{} | ||
345 | + result = append(result, newItem.LoadDto(attendances[i], operateInfo.OrgId)) | ||
346 | + } | ||
347 | + return count, result, nil | ||
348 | +} | ||
349 | + | ||
350 | +// 车间工时统计 | ||
351 | +func (attendanceService *AttendanceService) SearchWorkshopWorkTimeStatics(operateInfo *domain.OperateInfo, cmd *query.SearchEmployeeAttendanceQuery) (int64, interface{}, error) { | ||
352 | + if err := cmd.ValidateQuery(); err != nil { | ||
353 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
354 | + } | ||
355 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
356 | + if err != nil { | ||
357 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
358 | + } | ||
359 | + if err := transactionContext.StartTransaction(); err != nil { | ||
360 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
361 | + } | ||
362 | + defer func() { | ||
363 | + transactionContext.RollbackTransaction() | ||
364 | + }() | ||
365 | + var attendanceRepository domain.WorkshopWorkTimeRecordRepository | ||
366 | + attendanceRepository, _, _ = factory.FastPgWorkshopWorkTimeRecord(transactionContext, 0) | ||
367 | + | ||
368 | + queryOptions := utils.ObjectToMap(cmd) | ||
369 | + count, attendances, err := attendanceRepository.Find(queryOptions) | ||
370 | + if err != nil { | ||
371 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
372 | + } | ||
373 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
374 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
375 | + } | ||
376 | + var result = make([]*dto.WorkshopWorkTimeRecordDto, 0) | ||
377 | + for i := range attendances { | ||
378 | + newItem := &dto.WorkshopWorkTimeRecordDto{} | ||
379 | + result = append(result, newItem.LoadDto(attendances[i], operateInfo.OrgId)) | ||
380 | + } | ||
381 | + return count, result, nil | ||
382 | +} | ||
383 | + | ||
313 | func NewAttendanceService(options map[string]interface{}) *AttendanceService { | 384 | func NewAttendanceService(options map[string]interface{}) *AttendanceService { |
314 | newAttendanceService := &AttendanceService{} | 385 | newAttendanceService := &AttendanceService{} |
315 | return newAttendanceService | 386 | return newAttendanceService |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/attendance/command" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
10 | +) | ||
11 | + | ||
12 | +func (attendanceService *AttendanceService) WorkerAttendanceReport(cmd *command.WorkerAttendanceReportCommand) (interface{}, error) { | ||
13 | + if err := cmd.ValidateCommand(); err != nil { | ||
14 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
15 | + } | ||
16 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
17 | + if err != nil { | ||
18 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
19 | + } | ||
20 | + if err := transactionContext.StartTransaction(); err != nil { | ||
21 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
22 | + } | ||
23 | + defer func() { | ||
24 | + transactionContext.RollbackTransaction() | ||
25 | + }() | ||
26 | + | ||
27 | + //svr, _ := domainService.NewPGWorkshopWorkTimeStaticService(transactionContext.(*pgTransaction.TransactionContext)) | ||
28 | + //if _, err := svr.WorkshopWorkTimeStatic(cmd.ProductAttendanceRecord); err != nil { | ||
29 | + // log.Logger.Error(err.Error()) | ||
30 | + // return nil, err | ||
31 | + //} | ||
32 | + attendanceReportService, _ := domainService.NewPGWorkerAttendanceReportService(transactionContext.(*pgTransaction.TransactionContext)) | ||
33 | + if _, err := attendanceReportService.Report(constant.MANUFACTURE_DEFAULT_COMPANYID, constant.MANUFACTURE_DEFAULT_COMPANYID, cmd.DeviceZkTeco); err != nil { | ||
34 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
35 | + } | ||
36 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
37 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
38 | + } | ||
39 | + return struct{}{}, nil | ||
40 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/attendance/command" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
10 | +) | ||
11 | + | ||
12 | +// 审核工时 | ||
13 | +func (attendanceService *AttendanceService) WorkshopWorkTimeRecordStatics(cmd *command.WorkshopWorkTimeRecordStaticsCommand) (interface{}, error) { | ||
14 | + if err := cmd.ValidateCommand(); err != nil { | ||
15 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
16 | + } | ||
17 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
18 | + if err != nil { | ||
19 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
20 | + } | ||
21 | + if err := transactionContext.StartTransaction(); err != nil { | ||
22 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
23 | + } | ||
24 | + defer func() { | ||
25 | + transactionContext.RollbackTransaction() | ||
26 | + }() | ||
27 | + | ||
28 | + svr, _ := domainService.NewPGWorkshopWorkTimeStaticService(transactionContext.(*pgTransaction.TransactionContext)) | ||
29 | + if _, err := svr.WorkshopWorkTimeStatic(cmd.ProductAttendanceRecord); err != nil { | ||
30 | + log.Logger.Error(err.Error()) | ||
31 | + return nil, err | ||
32 | + } | ||
33 | + | ||
34 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
35 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
36 | + } | ||
37 | + return struct{}{}, nil | ||
38 | +} |
@@ -36,6 +36,15 @@ func (crontabService *CrontabService) initTask() { | @@ -36,6 +36,15 @@ func (crontabService *CrontabService) initTask() { | ||
36 | return srv.PullPrdMoNewest() | 36 | return srv.PullPrdMoNewest() |
37 | }) | 37 | }) |
38 | task.AddTask("PullPrdMoK3cloud", PullPrdMoK3cloud) | 38 | task.AddTask("PullPrdMoK3cloud", PullPrdMoK3cloud) |
39 | + | ||
40 | + autoApproveAttendanceRecord := task.NewTask("autoApproveAttendanceRecord", "0 */2 * * * *", AutoApproveProductAttendanceRecord) | ||
41 | + task.AddTask("autoApproveAttendanceRecord", autoApproveAttendanceRecord) | ||
42 | + | ||
43 | + autoApproveRecord := task.NewTask("autoApproveRecord", "0 */2 * * * *", AutoApproveProductRecord) | ||
44 | + task.AddTask("autoApproveRecord", autoApproveRecord) | ||
45 | + | ||
46 | + autoFlushDeviceDailyRunningRecord := task.NewTask("autoFlushDeviceDailyRunningRecord", "0 */1 * * * *", AutoFlushDeviceDailyRunningRecord) | ||
47 | + task.AddTask("autoFlushDeviceDailyRunningRecord", autoFlushDeviceDailyRunningRecord) | ||
39 | } | 48 | } |
40 | 49 | ||
41 | func (crontabService *CrontabService) StartCrontabTask() { | 50 | func (crontabService *CrontabService) StartCrontabTask() { |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
12 | +) | ||
13 | + | ||
14 | +// 定时审核生产考勤记录 | ||
15 | +func AutoApproveProductAttendanceRecord(ctx context.Context) error { | ||
16 | + defer func() { | ||
17 | + if r := recover(); r != nil { | ||
18 | + log.Logger.Error(fmt.Sprintf("%v", r)) | ||
19 | + } | ||
20 | + }() | ||
21 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if err := transactionContext.StartTransaction(); err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + defer func() { | ||
29 | + if err != nil { | ||
30 | + log.Logger.Error("【定时审核生产考勤记录】 失败:" + err.Error()) | ||
31 | + } | ||
32 | + transactionContext.RollbackTransaction() | ||
33 | + }() | ||
34 | + | ||
35 | + attendanceRecordDao, _ := dao.NewAttendanceRecordDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
36 | + var records []*domain.ProductAttendanceRecord | ||
37 | + _, records, err = attendanceRecordDao.RecentUnApprovedAttendanceRecord(24, 2) | ||
38 | + if err != nil { | ||
39 | + return err | ||
40 | + } | ||
41 | + | ||
42 | + approveAttendanceRecordsService, _ := domainService.NewPGApproveAttendanceRecordsService(transactionContext.(*pgTransaction.TransactionContext)) | ||
43 | + | ||
44 | + if _, err = approveAttendanceRecordsService.BatchApproveAttendanceRecords(nil, records, 0, 0, domain.AttendanceAutoApproved); err != nil { | ||
45 | + return err | ||
46 | + } | ||
47 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
48 | + return err | ||
49 | + } | ||
50 | + return nil | ||
51 | +} |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
12 | +) | ||
13 | + | ||
14 | +// 定时审核生产记录 | ||
15 | +func AutoApproveProductRecord(ctx context.Context) error { | ||
16 | + defer func() { | ||
17 | + if r := recover(); r != nil { | ||
18 | + log.Logger.Error(fmt.Sprintf("%v", r)) | ||
19 | + } | ||
20 | + }() | ||
21 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if err := transactionContext.StartTransaction(); err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + defer func() { | ||
29 | + if err != nil { | ||
30 | + log.Logger.Error("【定时审核生产考勤记录】 失败:" + err.Error()) | ||
31 | + } | ||
32 | + transactionContext.RollbackTransaction() | ||
33 | + }() | ||
34 | + | ||
35 | + attendanceRecordDao, _ := dao.NewProductRecordDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
36 | + var records []*domain.ProductRecord | ||
37 | + _, records, err = attendanceRecordDao.RecentUnApprovedProductRecord(24, 2, domain.RecordTypeSecondLevelWeigh) | ||
38 | + if err != nil { | ||
39 | + return err | ||
40 | + } | ||
41 | + | ||
42 | + approveAttendanceRecordsService, _ := domainService.NewPGProductRecordService(transactionContext.(*pgTransaction.TransactionContext)) | ||
43 | + | ||
44 | + if _, err = approveAttendanceRecordsService.BatchApprove(records, 0, 0, domain.AttendanceAutoApproved); err != nil { | ||
45 | + return err | ||
46 | + } | ||
47 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
48 | + return err | ||
49 | + } | ||
50 | + return nil | ||
51 | +} |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
9 | + "time" | ||
10 | +) | ||
11 | + | ||
12 | +// 定时刷新设备每日运行记录 | ||
13 | +func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error { | ||
14 | + defer func() { | ||
15 | + if r := recover(); r != nil { | ||
16 | + log.Logger.Error(fmt.Sprintf("%v", r)) | ||
17 | + } | ||
18 | + }() | ||
19 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
20 | + if err != nil { | ||
21 | + return err | ||
22 | + } | ||
23 | + if err := transactionContext.StartTransaction(); err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + defer func() { | ||
27 | + if err != nil { | ||
28 | + log.Logger.Error("【定时刷新设备每日运行记录】 失败:" + err.Error()) | ||
29 | + } | ||
30 | + transactionContext.RollbackTransaction() | ||
31 | + }() | ||
32 | + | ||
33 | + log.Logger.Debug("【定时刷新设备每日运行记录】 启动") | ||
34 | + deviceDailyRunningRecordRepository, _, _ := factory.FastPgDeviceDailyRunningRecord(transactionContext, 0) | ||
35 | + // 获取redis里当天的记录 | ||
36 | + span := time.Duration(20) | ||
37 | + t := time.Now().Add(-time.Minute * span) | ||
38 | + records, err := redis.GetDeviceDailyAllRecord(t) | ||
39 | + if err != nil { | ||
40 | + log.Logger.Error(err.Error()) | ||
41 | + return err | ||
42 | + } | ||
43 | + | ||
44 | + for _, v := range records { | ||
45 | + if v.UpdatedAt.Add(time.Minute * 5).Before(time.Now()) { | ||
46 | + log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt)) | ||
47 | + continue | ||
48 | + } | ||
49 | + | ||
50 | + // 更新设备效率 OEE = tu * pu * qu | ||
51 | + | ||
52 | + if _, err := deviceDailyRunningRecordRepository.Save(v); err != nil { | ||
53 | + log.Logger.Error(err.Error()) | ||
54 | + continue | ||
55 | + } else { | ||
56 | + log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 刷新记录 %v", v)) | ||
57 | + } | ||
58 | + } | ||
59 | + | ||
60 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
61 | + return err | ||
62 | + } | ||
63 | + return nil | ||
64 | +} |
@@ -22,11 +22,11 @@ type CreateDeviceCommand struct { | @@ -22,11 +22,11 @@ type CreateDeviceCommand struct { | ||
22 | // 设备类型 | 22 | // 设备类型 |
23 | DeviceType string `cname:"设备类型" json:"deviceType" valid:"Required"` | 23 | DeviceType string `cname:"设备类型" json:"deviceType" valid:"Required"` |
24 | // 车间ID | 24 | // 车间ID |
25 | - WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 25 | + WorkshopId int `cname:"车间ID" json:"workshopId"` |
26 | // 生产线ID | 26 | // 生产线ID |
27 | - LineId int `cname:"生产线ID" json:"lineId" valid:"Required"` | 27 | + LineId int `cname:"生产线ID" json:"lineId"` |
28 | // 工段ID | 28 | // 工段ID |
29 | - SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` | 29 | + SectionId int `cname:"工段ID" json:"sectionId"` |
30 | // 品牌 | 30 | // 品牌 |
31 | Brand string `cname:"品牌" json:"brand"` | 31 | Brand string `cname:"品牌" json:"brand"` |
32 | // 设备状态 1:正常 2:封存 3:报废 | 32 | // 设备状态 1:正常 2:封存 3:报废 |
@@ -20,13 +20,13 @@ type UpdateDeviceCommand struct { | @@ -20,13 +20,13 @@ type UpdateDeviceCommand struct { | ||
20 | // 设备类型 | 20 | // 设备类型 |
21 | DeviceType string `cname:"设备类型" json:"deviceType" valid:"Required"` | 21 | DeviceType string `cname:"设备类型" json:"deviceType" valid:"Required"` |
22 | // 车间ID | 22 | // 车间ID |
23 | - WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 23 | + WorkshopId int `cname:"车间ID" json:"workshopId"` |
24 | // 生产线ID | 24 | // 生产线ID |
25 | - LineId int `cname:"生产线ID" json:"lineId" valid:"Required"` | 25 | + LineId int `cname:"生产线ID" json:"lineId" ` |
26 | // 工段ID | 26 | // 工段ID |
27 | - SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` | 27 | + SectionId int `cname:"工段ID" json:"sectionId"` |
28 | // 品牌 | 28 | // 品牌 |
29 | - Brand string `cname:"品牌" json:"brand" valid:"Required"` | 29 | + Brand string `cname:"品牌" json:"brand"` |
30 | // 设备状态 1:正常 2:封存 3:报废 | 30 | // 设备状态 1:正常 2:封存 3:报废 |
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:低 |
1 | package dto | 1 | package dto |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "fmt" | ||
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
5 | ) | 6 | ) |
6 | 7 | ||
@@ -24,7 +25,7 @@ type DeviceDto struct { | @@ -24,7 +25,7 @@ type DeviceDto struct { | ||
24 | // 所属位置 | 25 | // 所属位置 |
25 | *domain.WorkStation | 26 | *domain.WorkStation |
26 | // 生产单个产品的时间(单位:秒) | 27 | // 生产单个产品的时间(单位:秒) |
27 | - UnitProductionSecTime int `json:"unitProductionSecTime"` | 28 | + UnitProductionSecTime string `json:"unitProductionSecTime"` |
28 | 29 | ||
29 | // 组织名称 | 30 | // 组织名称 |
30 | OrgName string `json:"orgName"` | 31 | OrgName string `json:"orgName"` |
@@ -36,6 +37,7 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | @@ -36,6 +37,7 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | ||
36 | d.DeviceId = m.DeviceId | 37 | d.DeviceId = m.DeviceId |
37 | d.DeviceCode = m.DeviceCode | 38 | d.DeviceCode = m.DeviceCode |
38 | d.DeviceName = m.DeviceName | 39 | d.DeviceName = m.DeviceName |
40 | + d.DeviceModel = m.DeviceModel | ||
39 | d.DeviceType = m.DeviceType | 41 | d.DeviceType = m.DeviceType |
40 | d.Brand = m.Brand | 42 | d.Brand = m.Brand |
41 | d.DeviceStatus = m.DeviceStatus | 43 | d.DeviceStatus = m.DeviceStatus |
@@ -46,7 +48,9 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | @@ -46,7 +48,9 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | ||
46 | d.OrgName = m.Ext.OrgName | 48 | d.OrgName = m.Ext.OrgName |
47 | } | 49 | } |
48 | if m.Ext != nil && m.Ext.DeviceExt != nil { | 50 | if m.Ext != nil && m.Ext.DeviceExt != nil { |
49 | - d.UnitProductionSecTime = m.Ext.DeviceExt.UnitProductionSecTime | 51 | + if m.Ext.DeviceExt.UnitProductionSecTime > 0 { |
52 | + d.UnitProductionSecTime = fmt.Sprintf("%v", m.Ext.DeviceExt.UnitProductionSecTime) | ||
53 | + } | ||
50 | } | 54 | } |
51 | return d | 55 | return d |
52 | } | 56 | } |
@@ -38,10 +38,13 @@ func (deviceService *DeviceService) CreateDevice(operateInfo *domain.OperateInfo | @@ -38,10 +38,13 @@ func (deviceService *DeviceService) CreateDevice(operateInfo *domain.OperateInfo | ||
38 | }() | 38 | }() |
39 | 39 | ||
40 | var workStation *domain.WorkStation | 40 | var workStation *domain.WorkStation |
41 | - _, workStation, err = factory.FastPgWorkstation(transactionContext, cmd.WorkshopId, cmd.LineId, cmd.SectionId) | 41 | + if cmd.WorkshopId != 0 { |
42 | + _, workshop, err := factory.FastPgWorkshop(transactionContext, cmd.WorkshopId) //, cmd.LineId, cmd.SectionId | ||
42 | if err != nil { | 43 | if err != nil { |
43 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 44 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
44 | } | 45 | } |
46 | + workStation, _ = workshop.FindWorkStationOrNil(cmd.WorkshopId, cmd.LineId, cmd.SectionId) | ||
47 | + } | ||
45 | 48 | ||
46 | var userService = domainService.NewUserService() | 49 | var userService = domainService.NewUserService() |
47 | var org *domain.Org | 50 | var org *domain.Org |
@@ -272,10 +275,17 @@ func (deviceService *DeviceService) UpdateDevice(cmd *command.UpdateDeviceComman | @@ -272,10 +275,17 @@ func (deviceService *DeviceService) UpdateDevice(cmd *command.UpdateDeviceComman | ||
272 | } | 275 | } |
273 | 276 | ||
274 | var workStation *domain.WorkStation | 277 | var workStation *domain.WorkStation |
275 | - _, workStation, err = factory.FastPgWorkstation(transactionContext, cmd.WorkshopId, cmd.LineId, cmd.SectionId, factory.WithSetPrincipal()) | 278 | + //_, workStation, err = factory.FastPgWorkstation(transactionContext, cmd.WorkshopId, cmd.LineId, cmd.SectionId, factory.WithSetPrincipal()) |
279 | + //if err != nil { | ||
280 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
281 | + //} | ||
282 | + if cmd.WorkshopId != 0 { | ||
283 | + _, workshop, err := factory.FastPgWorkshop(transactionContext, cmd.WorkshopId) //, cmd.LineId, cmd.SectionId | ||
276 | if err != nil { | 284 | if err != nil { |
277 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 285 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
278 | } | 286 | } |
287 | + workStation, _ = workshop.FindWorkStationOrNil(cmd.WorkshopId, cmd.LineId, cmd.SectionId) | ||
288 | + } | ||
279 | device.WorkStation = workStation | 289 | device.WorkStation = workStation |
280 | 290 | ||
281 | if cmd.DeviceCode != device.DeviceCode { | 291 | if cmd.DeviceCode != device.DeviceCode { |
@@ -340,7 +350,9 @@ func (deviceService *DeviceService) SearchDevice(operateInfo *domain.OperateInfo | @@ -340,7 +350,9 @@ func (deviceService *DeviceService) SearchDevice(operateInfo *domain.OperateInfo | ||
340 | for i := range devices { | 350 | for i := range devices { |
341 | item := devices[i] | 351 | item := devices[i] |
342 | newJobDto := &dto.DeviceDto{} | 352 | newJobDto := &dto.DeviceDto{} |
343 | - item.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | 353 | + if item.WorkStation != nil && item.WorkStation.WorkshopId > 0 { |
354 | + newJobDto.WorkStation = workshops.FindWorkStationOrNil(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | ||
355 | + } | ||
344 | newJobDto.LoadDto(item, operateInfo.OrgId) | 356 | newJobDto.LoadDto(item, operateInfo.OrgId) |
345 | result = append(result, newJobDto) | 357 | result = append(result, newJobDto) |
346 | } | 358 | } |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type CreateDeviceCollectionCommand struct { | ||
12 | + // 数据采集ID | ||
13 | + DeviceCollectionId int64 `cname:"数据采集ID" json:"deviceCollectionId,string" valid:"Required"` | ||
14 | + // 车间名 | ||
15 | + WorkShopName string `cname:"车间名" json:"workShopName" valid:"Required"` | ||
16 | + // 启动状态 1-启动 0-停止 | ||
17 | + StartupStatus int64 `cname:"启动状态 1-启动 0-停止" json:"startupStatus,string" valid:"Required"` | ||
18 | + // 设备名 | ||
19 | + DeviceSn string `cname:"设备名" json:"deviceSn" valid:"Required"` | ||
20 | + // 通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障 | ||
21 | + ComStatus int64 `cname:"通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障" json:"comStatus,string" valid:"Required"` | ||
22 | + // 设备数据值 | ||
23 | + Values string `cname:"设备数据值" json:"values" valid:"Required"` | ||
24 | +} | ||
25 | + | ||
26 | +func (createDeviceCollectionCommand *CreateDeviceCollectionCommand) Valid(validation *validation.Validation) { | ||
27 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
28 | +} | ||
29 | + | ||
30 | +func (createDeviceCollectionCommand *CreateDeviceCollectionCommand) ValidateCommand() error { | ||
31 | + valid := validation.Validation{} | ||
32 | + b, err := valid.Valid(createDeviceCollectionCommand) | ||
33 | + if err != nil { | ||
34 | + return err | ||
35 | + } | ||
36 | + if !b { | ||
37 | + elem := reflect.TypeOf(createDeviceCollectionCommand).Elem() | ||
38 | + for _, validErr := range valid.Errors { | ||
39 | + field, isExist := elem.FieldByName(validErr.Field) | ||
40 | + if isExist { | ||
41 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
42 | + } else { | ||
43 | + return fmt.Errorf(validErr.Message) | ||
44 | + } | ||
45 | + } | ||
46 | + } | ||
47 | + return nil | ||
48 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type RemoveDeviceCollectionCommand struct { | ||
12 | + // 数据采集ID | ||
13 | + DeviceCollectionId int64 `cname:"数据采集ID" json:"deviceCollectionId,string" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (removeDeviceCollectionCommand *RemoveDeviceCollectionCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (removeDeviceCollectionCommand *RemoveDeviceCollectionCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(removeDeviceCollectionCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(removeDeviceCollectionCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type UpdateDeviceCollectionCommand struct { | ||
12 | + // 数据采集ID | ||
13 | + DeviceCollectionId int64 `cname:"数据采集ID" json:"deviceCollectionId,string" valid:"Required"` | ||
14 | + // 车间名 | ||
15 | + WorkShopName string `cname:"车间名" json:"workShopName" valid:"Required"` | ||
16 | + // 启动状态 1-启动 0-停止 | ||
17 | + StartupStatus int64 `cname:"启动状态 1-启动 0-停止" json:"startupStatus,string" valid:"Required"` | ||
18 | + // 设备名 | ||
19 | + DeviceSn string `cname:"设备名" json:"deviceSn" valid:"Required"` | ||
20 | + // 通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障 | ||
21 | + ComStatus int64 `cname:"通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障" json:"comStatus,string" valid:"Required"` | ||
22 | + // 设备数据值 | ||
23 | + Values string `cname:"设备数据值" json:"values" valid:"Required"` | ||
24 | +} | ||
25 | + | ||
26 | +func (updateDeviceCollectionCommand *UpdateDeviceCollectionCommand) Valid(validation *validation.Validation) { | ||
27 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
28 | +} | ||
29 | + | ||
30 | +func (updateDeviceCollectionCommand *UpdateDeviceCollectionCommand) ValidateCommand() error { | ||
31 | + valid := validation.Validation{} | ||
32 | + b, err := valid.Valid(updateDeviceCollectionCommand) | ||
33 | + if err != nil { | ||
34 | + return err | ||
35 | + } | ||
36 | + if !b { | ||
37 | + elem := reflect.TypeOf(updateDeviceCollectionCommand).Elem() | ||
38 | + for _, validErr := range valid.Errors { | ||
39 | + field, isExist := elem.FieldByName(validErr.Field) | ||
40 | + if isExist { | ||
41 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
42 | + } else { | ||
43 | + return fmt.Errorf(validErr.Message) | ||
44 | + } | ||
45 | + } | ||
46 | + } | ||
47 | + return nil | ||
48 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type GetDeviceCollectionQuery struct { | ||
12 | + // 数据采集ID | ||
13 | + DeviceCollectionId int64 `cname:"数据采集ID" json:"deviceCollectionId,string" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (getDeviceCollectionQuery *GetDeviceCollectionQuery) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (getDeviceCollectionQuery *GetDeviceCollectionQuery) ValidateQuery() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(getDeviceCollectionQuery) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(getDeviceCollectionQuery).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type ListDeviceCollectionQuery struct { | ||
12 | + // 查询偏离量 | ||
13 | + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | ||
14 | + // 查询限制 | ||
15 | + Limit int `cname:"查询限制" json:"limit" valid:"Required"` | ||
16 | +} | ||
17 | + | ||
18 | +func (listDeviceCollectionQuery *ListDeviceCollectionQuery) Valid(validation *validation.Validation) { | ||
19 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
20 | +} | ||
21 | + | ||
22 | +func (listDeviceCollectionQuery *ListDeviceCollectionQuery) ValidateQuery() error { | ||
23 | + valid := validation.Validation{} | ||
24 | + b, err := valid.Valid(listDeviceCollectionQuery) | ||
25 | + if err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + if !b { | ||
29 | + elem := reflect.TypeOf(listDeviceCollectionQuery).Elem() | ||
30 | + for _, validErr := range valid.Errors { | ||
31 | + field, isExist := elem.FieldByName(validErr.Field) | ||
32 | + if isExist { | ||
33 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
34 | + } else { | ||
35 | + return fmt.Errorf(validErr.Message) | ||
36 | + } | ||
37 | + } | ||
38 | + } | ||
39 | + return nil | ||
40 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/linmadan/egglib-go/core/application" | ||
6 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/deviceCollection/command" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/deviceCollection/query" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
11 | +) | ||
12 | + | ||
13 | +type DeviceCollectionService struct { | ||
14 | +} | ||
15 | + | ||
16 | +// 创建 | ||
17 | +func (deviceCollectionService *DeviceCollectionService) CreateDeviceCollection(createDeviceCollectionCommand *command.CreateDeviceCollectionCommand) (interface{}, error) { | ||
18 | + if err := createDeviceCollectionCommand.ValidateCommand(); err != nil { | ||
19 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
20 | + } | ||
21 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
22 | + if err != nil { | ||
23 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
24 | + } | ||
25 | + if err := transactionContext.StartTransaction(); err != nil { | ||
26 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
27 | + } | ||
28 | + defer func() { | ||
29 | + transactionContext.RollbackTransaction() | ||
30 | + }() | ||
31 | + newDeviceCollection := &domain.DeviceCollection{ | ||
32 | + DeviceCollectionId: createDeviceCollectionCommand.DeviceCollectionId, | ||
33 | + WorkShopName: createDeviceCollectionCommand.WorkShopName, | ||
34 | + StartupStatus: createDeviceCollectionCommand.StartupStatus, | ||
35 | + DeviceSn: createDeviceCollectionCommand.DeviceSn, | ||
36 | + ComStatus: createDeviceCollectionCommand.ComStatus, | ||
37 | + Values: createDeviceCollectionCommand.Values, | ||
38 | + } | ||
39 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
40 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
41 | + "transactionContext": transactionContext, | ||
42 | + }); err != nil { | ||
43 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
44 | + } else { | ||
45 | + deviceCollectionRepository = value | ||
46 | + } | ||
47 | + if deviceCollection, err := deviceCollectionRepository.Save(newDeviceCollection); err != nil { | ||
48 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
49 | + } else { | ||
50 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
51 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
52 | + } | ||
53 | + return deviceCollection, nil | ||
54 | + } | ||
55 | +} | ||
56 | + | ||
57 | +// 返回 | ||
58 | +func (deviceCollectionService *DeviceCollectionService) GetDeviceCollection(getDeviceCollectionQuery *query.GetDeviceCollectionQuery) (interface{}, error) { | ||
59 | + if err := getDeviceCollectionQuery.ValidateQuery(); err != nil { | ||
60 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
61 | + } | ||
62 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
63 | + if err != nil { | ||
64 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
65 | + } | ||
66 | + if err := transactionContext.StartTransaction(); err != nil { | ||
67 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
68 | + } | ||
69 | + defer func() { | ||
70 | + transactionContext.RollbackTransaction() | ||
71 | + }() | ||
72 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
73 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
74 | + "transactionContext": transactionContext, | ||
75 | + }); err != nil { | ||
76 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
77 | + } else { | ||
78 | + deviceCollectionRepository = value | ||
79 | + } | ||
80 | + deviceCollection, err := deviceCollectionRepository.FindOne(map[string]interface{}{"deviceCollectionId": getDeviceCollectionQuery.DeviceCollectionId}) | ||
81 | + if err != nil { | ||
82 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
83 | + } | ||
84 | + if deviceCollection == nil { | ||
85 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getDeviceCollectionQuery.DeviceCollectionId))) | ||
86 | + } else { | ||
87 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
88 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
89 | + } | ||
90 | + return deviceCollection, nil | ||
91 | + } | ||
92 | +} | ||
93 | + | ||
94 | +// 返回列表 | ||
95 | +func (deviceCollectionService *DeviceCollectionService) ListDeviceCollection(listDeviceCollectionQuery *query.ListDeviceCollectionQuery) (interface{}, error) { | ||
96 | + if err := listDeviceCollectionQuery.ValidateQuery(); err != nil { | ||
97 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
98 | + } | ||
99 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
100 | + if err != nil { | ||
101 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
102 | + } | ||
103 | + if err := transactionContext.StartTransaction(); err != nil { | ||
104 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
105 | + } | ||
106 | + defer func() { | ||
107 | + transactionContext.RollbackTransaction() | ||
108 | + }() | ||
109 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
110 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
111 | + "transactionContext": transactionContext, | ||
112 | + }); err != nil { | ||
113 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
114 | + } else { | ||
115 | + deviceCollectionRepository = value | ||
116 | + } | ||
117 | + if count, deviceCollections, err := deviceCollectionRepository.Find(tool_funs.SimpleStructToMap(listDeviceCollectionQuery)); err != nil { | ||
118 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
119 | + } else { | ||
120 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
121 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
122 | + } | ||
123 | + return map[string]interface{}{ | ||
124 | + "count": count, | ||
125 | + "deviceCollections": deviceCollections, | ||
126 | + }, nil | ||
127 | + } | ||
128 | +} | ||
129 | + | ||
130 | +// 移除 | ||
131 | +func (deviceCollectionService *DeviceCollectionService) RemoveDeviceCollection(removeDeviceCollectionCommand *command.RemoveDeviceCollectionCommand) (interface{}, error) { | ||
132 | + if err := removeDeviceCollectionCommand.ValidateCommand(); err != nil { | ||
133 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
134 | + } | ||
135 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
136 | + if err != nil { | ||
137 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
138 | + } | ||
139 | + if err := transactionContext.StartTransaction(); err != nil { | ||
140 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
141 | + } | ||
142 | + defer func() { | ||
143 | + transactionContext.RollbackTransaction() | ||
144 | + }() | ||
145 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
146 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
147 | + "transactionContext": transactionContext, | ||
148 | + }); err != nil { | ||
149 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
150 | + } else { | ||
151 | + deviceCollectionRepository = value | ||
152 | + } | ||
153 | + deviceCollection, err := deviceCollectionRepository.FindOne(map[string]interface{}{"deviceCollectionId": removeDeviceCollectionCommand.DeviceCollectionId}) | ||
154 | + if err != nil { | ||
155 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
156 | + } | ||
157 | + if deviceCollection == nil { | ||
158 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeDeviceCollectionCommand.DeviceCollectionId))) | ||
159 | + } | ||
160 | + if deviceCollection, err := deviceCollectionRepository.Remove(deviceCollection); err != nil { | ||
161 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
162 | + } else { | ||
163 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
164 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
165 | + } | ||
166 | + return deviceCollection, nil | ||
167 | + } | ||
168 | +} | ||
169 | + | ||
170 | +// 更新 | ||
171 | +func (deviceCollectionService *DeviceCollectionService) UpdateDeviceCollection(updateDeviceCollectionCommand *command.UpdateDeviceCollectionCommand) (interface{}, error) { | ||
172 | + if err := updateDeviceCollectionCommand.ValidateCommand(); err != nil { | ||
173 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
174 | + } | ||
175 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
176 | + if err != nil { | ||
177 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
178 | + } | ||
179 | + if err := transactionContext.StartTransaction(); err != nil { | ||
180 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
181 | + } | ||
182 | + defer func() { | ||
183 | + transactionContext.RollbackTransaction() | ||
184 | + }() | ||
185 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
186 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
187 | + "transactionContext": transactionContext, | ||
188 | + }); err != nil { | ||
189 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
190 | + } else { | ||
191 | + deviceCollectionRepository = value | ||
192 | + } | ||
193 | + deviceCollection, err := deviceCollectionRepository.FindOne(map[string]interface{}{"deviceCollectionId": updateDeviceCollectionCommand.DeviceCollectionId}) | ||
194 | + if err != nil { | ||
195 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
196 | + } | ||
197 | + if deviceCollection == nil { | ||
198 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDeviceCollectionCommand.DeviceCollectionId))) | ||
199 | + } | ||
200 | + if err := deviceCollection.Update(tool_funs.SimpleStructToMap(updateDeviceCollectionCommand)); err != nil { | ||
201 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
202 | + } | ||
203 | + if deviceCollection, err := deviceCollectionRepository.Save(deviceCollection); err != nil { | ||
204 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
205 | + } else { | ||
206 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
207 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
208 | + } | ||
209 | + return deviceCollection, nil | ||
210 | + } | ||
211 | +} | ||
212 | + | ||
213 | +func NewDeviceCollectionService(options map[string]interface{}) *DeviceCollectionService { | ||
214 | + newDeviceCollectionService := &DeviceCollectionService{} | ||
215 | + return newDeviceCollectionService | ||
216 | +} |
@@ -140,7 +140,7 @@ func FastPgProductGroup(transactionContext application.TransactionContext, id in | @@ -140,7 +140,7 @@ func FastPgProductGroup(transactionContext application.TransactionContext, id in | ||
140 | rep = value | 140 | rep = value |
141 | } | 141 | } |
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{}{"productGroupId": 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 | } |
@@ -169,7 +169,7 @@ func FastPgProduct(transactionContext application.TransactionContext, id int, op | @@ -169,7 +169,7 @@ func FastPgProduct(transactionContext application.TransactionContext, id int, op | ||
169 | rep = value | 169 | rep = value |
170 | } | 170 | } |
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{}{"productId": 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 | } |
@@ -195,7 +195,7 @@ func FastPgDevice(transactionContext application.TransactionContext, id int, opt | @@ -195,7 +195,7 @@ func FastPgDevice(transactionContext application.TransactionContext, id int, opt | ||
195 | rep = value | 195 | rep = value |
196 | } | 196 | } |
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{}{"deviceId": 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 | } |
@@ -221,7 +221,7 @@ func FastPgProductCalendar(transactionContext application.TransactionContext, id | @@ -221,7 +221,7 @@ func FastPgProductCalendar(transactionContext application.TransactionContext, id | ||
221 | rep = value | 221 | rep = value |
222 | } | 222 | } |
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{}{"productCalendar": 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 | } |
@@ -247,7 +247,7 @@ func FastPgUnitConversion(transactionContext application.TransactionContext, id | @@ -247,7 +247,7 @@ func FastPgUnitConversion(transactionContext application.TransactionContext, id | ||
247 | rep = value | 247 | rep = value |
248 | } | 248 | } |
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{}{"unitConversionId": 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 | } |
@@ -283,6 +283,32 @@ func FastPgProductPlan(transactionContext application.TransactionContext, id int | @@ -283,6 +283,32 @@ func FastPgProductPlan(transactionContext application.TransactionContext, id int | ||
283 | return rep, mod, err | 283 | return rep, mod, err |
284 | } | 284 | } |
285 | 285 | ||
286 | +// FastPgProductPlan 快速返回生产计划对象 | ||
287 | +// | ||
288 | +// transactionContext 事务 | ||
289 | +// id 对象唯一标识 | ||
290 | +func FastPgProductPlanDispatchRecord(transactionContext application.TransactionContext, id int, options ...option) (domain.ProductPlanDispatchRecordRepository, *domain.ProductPlanDispatchRecord, error) { | ||
291 | + var rep domain.ProductPlanDispatchRecordRepository | ||
292 | + var mod *domain.ProductPlanDispatchRecord | ||
293 | + var err error | ||
294 | + if value, err := CreateProductPlanDispatchRecordRepository(map[string]interface{}{ | ||
295 | + "transactionContext": transactionContext, | ||
296 | + }); err != nil { | ||
297 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
298 | + } else { | ||
299 | + rep = value | ||
300 | + } | ||
301 | + if id > 0 { | ||
302 | + if mod, err = rep.FindOne(map[string]interface{}{"productPlanDispatchRecordId": id}); err != nil { | ||
303 | + if err == domain.ErrorNotFound { | ||
304 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该生产计划调度记录不存在") | ||
305 | + } | ||
306 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
307 | + } | ||
308 | + } | ||
309 | + return rep, mod, err | ||
310 | +} | ||
311 | + | ||
286 | // FastPgAttendance 快速返回考勤记录 | 312 | // FastPgAttendance 快速返回考勤记录 |
287 | // | 313 | // |
288 | // transactionContext 事务 | 314 | // transactionContext 事务 |
@@ -309,6 +335,84 @@ func FastPgAttendance(transactionContext application.TransactionContext, id int, | @@ -309,6 +335,84 @@ func FastPgAttendance(transactionContext application.TransactionContext, id int, | ||
309 | return rep, mod, err | 335 | return rep, mod, err |
310 | } | 336 | } |
311 | 337 | ||
338 | +// FastPgProductRecord 快速返回生产记录 | ||
339 | +// | ||
340 | +// transactionContext 事务 | ||
341 | +// id 对象唯一标识 | ||
342 | +func FastPgProductRecord(transactionContext application.TransactionContext, id int, options ...option) (domain.ProductRecordRepository, *domain.ProductRecord, error) { | ||
343 | + var rep domain.ProductRecordRepository | ||
344 | + var mod *domain.ProductRecord | ||
345 | + var err error | ||
346 | + if value, err := CreateProductRecordRepository(map[string]interface{}{ | ||
347 | + "transactionContext": transactionContext, | ||
348 | + }); err != nil { | ||
349 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
350 | + } else { | ||
351 | + rep = value | ||
352 | + } | ||
353 | + if id > 0 { | ||
354 | + if mod, err = rep.FindOne(map[string]interface{}{"productRecordId": id}); err != nil { | ||
355 | + if err == domain.ErrorNotFound { | ||
356 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该记录不存在") | ||
357 | + } | ||
358 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
359 | + } | ||
360 | + } | ||
361 | + return rep, mod, err | ||
362 | +} | ||
363 | + | ||
364 | +// FastPgWorkshopWorkTimeRecord 快速返回生产记录 | ||
365 | +// | ||
366 | +// transactionContext 事务 | ||
367 | +// id 对象唯一标识 | ||
368 | +func FastPgWorkshopWorkTimeRecord(transactionContext application.TransactionContext, id int, options ...option) (domain.WorkshopWorkTimeRecordRepository, *domain.WorkshopWorkTimeRecord, error) { | ||
369 | + var rep domain.WorkshopWorkTimeRecordRepository | ||
370 | + var mod *domain.WorkshopWorkTimeRecord | ||
371 | + var err error | ||
372 | + if value, err := CreateWorkshopWorkTimeRecordRepository(map[string]interface{}{ | ||
373 | + "transactionContext": transactionContext, | ||
374 | + }); err != nil { | ||
375 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
376 | + } else { | ||
377 | + rep = value | ||
378 | + } | ||
379 | + if id > 0 { | ||
380 | + if mod, err = rep.FindOne(map[string]interface{}{"workshopWorkTimeRecordId": id}); err != nil { | ||
381 | + if err == domain.ErrorNotFound { | ||
382 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该记录不存在") | ||
383 | + } | ||
384 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
385 | + } | ||
386 | + } | ||
387 | + return rep, mod, err | ||
388 | +} | ||
389 | + | ||
390 | +// FastPgDeviceDailyRunningRecord 快速返回设备每日运行记录 | ||
391 | +// | ||
392 | +// transactionContext 事务 | ||
393 | +// id 对象唯一标识 | ||
394 | +func FastPgDeviceDailyRunningRecord(transactionContext application.TransactionContext, id int, options ...option) (domain.DeviceDailyRunningRecordRepository, *domain.DeviceDailyRunningRecord, error) { | ||
395 | + var rep domain.DeviceDailyRunningRecordRepository | ||
396 | + var mod *domain.DeviceDailyRunningRecord | ||
397 | + var err error | ||
398 | + if value, err := CreateDeviceDailyRunningRecordRepository(map[string]interface{}{ | ||
399 | + "transactionContext": transactionContext, | ||
400 | + }); err != nil { | ||
401 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
402 | + } else { | ||
403 | + rep = value | ||
404 | + } | ||
405 | + if id > 0 { | ||
406 | + if mod, err = rep.FindOne(map[string]interface{}{"deviceDailyRunningRecordId": id}); err != nil { | ||
407 | + if err == domain.ErrorNotFound { | ||
408 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该记录不存在") | ||
409 | + } | ||
410 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
411 | + } | ||
412 | + } | ||
413 | + return rep, mod, err | ||
414 | +} | ||
415 | + | ||
312 | /***** 2.配置 *****/ | 416 | /***** 2.配置 *****/ |
313 | 417 | ||
314 | type FastOptions struct { | 418 | type FastOptions struct { |
@@ -85,3 +85,59 @@ func CreateWorkshopRepository(options map[string]interface{}) (domain.WorkshopRe | @@ -85,3 +85,59 @@ func CreateWorkshopRepository(options map[string]interface{}) (domain.WorkshopRe | ||
85 | } | 85 | } |
86 | return repository.NewWorkshopRepository(transactionContext) | 86 | return repository.NewWorkshopRepository(transactionContext) |
87 | } | 87 | } |
88 | + | ||
89 | +func CreateEmployeeProductRecordRepository(options map[string]interface{}) (domain.EmployeeProductRecordRepository, error) { | ||
90 | + var transactionContext *pg.TransactionContext | ||
91 | + if value, ok := options["transactionContext"]; ok { | ||
92 | + transactionContext = value.(*pg.TransactionContext) | ||
93 | + } | ||
94 | + return repository.NewEmployeeProductRecordRepository(transactionContext) | ||
95 | +} | ||
96 | + | ||
97 | +func CreateWorkshopProductRecordRepository(options map[string]interface{}) (domain.WorkshopProductRecordRepository, error) { | ||
98 | + var transactionContext *pg.TransactionContext | ||
99 | + if value, ok := options["transactionContext"]; ok { | ||
100 | + transactionContext = value.(*pg.TransactionContext) | ||
101 | + } | ||
102 | + return repository.NewWorkshopProductRecordRepository(transactionContext) | ||
103 | +} | ||
104 | + | ||
105 | +func CreateWorkshopWorkTimeRecordRepository(options map[string]interface{}) (domain.WorkshopWorkTimeRecordRepository, error) { | ||
106 | + var transactionContext *pg.TransactionContext | ||
107 | + if value, ok := options["transactionContext"]; ok { | ||
108 | + transactionContext = value.(*pg.TransactionContext) | ||
109 | + } | ||
110 | + return repository.NewWorkshopWorkTimeRecordRepository(transactionContext) | ||
111 | +} | ||
112 | + | ||
113 | +func CreateProductPlanDispatchRecordRepository(options map[string]interface{}) (domain.ProductPlanDispatchRecordRepository, error) { | ||
114 | + var transactionContext *pg.TransactionContext | ||
115 | + if value, ok := options["transactionContext"]; ok { | ||
116 | + transactionContext = value.(*pg.TransactionContext) | ||
117 | + } | ||
118 | + return repository.NewProductPlanDispatchRecordRepository(transactionContext) | ||
119 | +} | ||
120 | + | ||
121 | +func CreateDeviceCollectionRepository(options map[string]interface{}) (domain.DeviceCollectionRepository, error) { | ||
122 | + var transactionContext *pg.TransactionContext | ||
123 | + if value, ok := options["transactionContext"]; ok { | ||
124 | + transactionContext = value.(*pg.TransactionContext) | ||
125 | + } | ||
126 | + return repository.NewDeviceCollectionRepository(transactionContext) | ||
127 | +} | ||
128 | + | ||
129 | +func CreateDeviceRunningRecordRepository(options map[string]interface{}) (domain.DeviceRunningRecordRepository, error) { | ||
130 | + var transactionContext *pg.TransactionContext | ||
131 | + if value, ok := options["transactionContext"]; ok { | ||
132 | + transactionContext = value.(*pg.TransactionContext) | ||
133 | + } | ||
134 | + return repository.NewDeviceRunningRecordRepository(transactionContext) | ||
135 | +} | ||
136 | + | ||
137 | +func CreateDeviceDailyRunningRecordRepository(options map[string]interface{}) (domain.DeviceDailyRunningRecordRepository, error) { | ||
138 | + var transactionContext *pg.TransactionContext | ||
139 | + if value, ok := options["transactionContext"]; ok { | ||
140 | + transactionContext = value.(*pg.TransactionContext) | ||
141 | + } | ||
142 | + return repository.NewDeviceDailyRunningRecordRepository(transactionContext) | ||
143 | +} |
@@ -23,7 +23,7 @@ type CreateProductCalendarCommand struct { | @@ -23,7 +23,7 @@ type CreateProductCalendarCommand struct { | ||
23 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 23 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
24 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` | 24 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` |
25 | // 日历选择 | 25 | // 日历选择 |
26 | - CalendarSelected []string `cname:"日历选择" json:"calendarSelected" valid:"Required"` | 26 | + CalendarSelected []int `cname:"日历选择" json:"calendarSelected" valid:"Required"` |
27 | // 上岗时间 | 27 | // 上岗时间 |
28 | InWorkAt string `cname:"上岗时间" json:"inWorkAt" valid:"Required"` | 28 | InWorkAt string `cname:"上岗时间" json:"inWorkAt" valid:"Required"` |
29 | // 下岗时间 | 29 | // 下岗时间 |
@@ -2,7 +2,7 @@ package dto | @@ -2,7 +2,7 @@ package dto | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
5 | - "strings" | 5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" |
6 | ) | 6 | ) |
7 | 7 | ||
8 | type ProductCalendarDto struct { | 8 | type ProductCalendarDto struct { |
@@ -17,7 +17,7 @@ type ProductCalendarDto struct { | @@ -17,7 +17,7 @@ type ProductCalendarDto struct { | ||
17 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 17 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
18 | WorkOn int `json:"workOn,omitempty"` | 18 | WorkOn int `json:"workOn,omitempty"` |
19 | // 日历选择 | 19 | // 日历选择 |
20 | - CalendarSelected []string `json:"calendarSelected,omitempty"` | 20 | + CalendarSelected []int `json:"calendarSelected,omitempty"` |
21 | // 上岗时间 | 21 | // 上岗时间 |
22 | InWorkAt string `json:"inWorkAt,omitempty"` | 22 | InWorkAt string `json:"inWorkAt,omitempty"` |
23 | // 下岗时间 | 23 | // 下岗时间 |
@@ -27,7 +27,7 @@ type ProductCalendarDto struct { | @@ -27,7 +27,7 @@ type ProductCalendarDto struct { | ||
27 | // 工时 (单位 h) | 27 | // 工时 (单位 h) |
28 | WorkTime float64 `json:"workTime,omitempty"` | 28 | WorkTime float64 `json:"workTime,omitempty"` |
29 | // 已选择日历 | 29 | // 已选择日历 |
30 | - CalendarSelectedString string `json:"calendarSelectedString,omitempty"` | 30 | + //CalendarSelectedString string `json:"calendarSelectedString,omitempty"` |
31 | // 组织名称 | 31 | // 组织名称 |
32 | OrgName string `json:"orgName"` | 32 | OrgName string `json:"orgName"` |
33 | // 权限标识 (当前登录组织匹配为true,否则false) | 33 | // 权限标识 (当前登录组织匹配为true,否则false) |
@@ -38,12 +38,12 @@ func (d *ProductCalendarDto) LoadDto(m *domain.ProductCalendar, orgId int) *Prod | @@ -38,12 +38,12 @@ func (d *ProductCalendarDto) LoadDto(m *domain.ProductCalendar, orgId int) *Prod | ||
38 | d.ProductCalendarId = m.ProductCalendarId | 38 | d.ProductCalendarId = m.ProductCalendarId |
39 | d.WorkStation = m.WorkStation | 39 | d.WorkStation = m.WorkStation |
40 | d.WorkOn = m.WorkOn | 40 | d.WorkOn = m.WorkOn |
41 | - d.CalendarSelected = m.CalendarSelected | 41 | + d.CalendarSelected = utils.ToArrayInt(m.CalendarSelected) |
42 | d.InWorkAt = m.InWorkAt | 42 | d.InWorkAt = m.InWorkAt |
43 | d.OutWorkAt = m.OutWorkAt | 43 | d.OutWorkAt = m.OutWorkAt |
44 | d.BreakTime = m.BreakTime | 44 | d.BreakTime = m.BreakTime |
45 | d.WorkTime = m.WorkTime | 45 | d.WorkTime = m.WorkTime |
46 | - d.CalendarSelectedString = strings.Join(m.CalendarSelected, "/") | 46 | + //d.CalendarSelectedString = strings.Join(m.CalendarSelected, "/") |
47 | d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | 47 | d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) |
48 | if m.Ext != nil { | 48 | if m.Ext != nil { |
49 | d.OrgName = m.Ext.OrgName | 49 | d.OrgName = m.Ext.OrgName |
@@ -66,7 +66,7 @@ func (productCalendarService *ProductCalendarService) CreateProductCalendar(oper | @@ -66,7 +66,7 @@ func (productCalendarService *ProductCalendarService) CreateProductCalendar(oper | ||
66 | OrgId: cmd.OrgId, | 66 | OrgId: cmd.OrgId, |
67 | WorkStation: workStation, | 67 | WorkStation: workStation, |
68 | WorkOn: cmd.WorkOn, | 68 | WorkOn: cmd.WorkOn, |
69 | - CalendarSelected: cmd.CalendarSelected, | 69 | + CalendarSelected: utils.ToArrayString(cmd.CalendarSelected), |
70 | InWorkAt: cmd.InWorkAt, | 70 | InWorkAt: cmd.InWorkAt, |
71 | OutWorkAt: cmd.OutWorkAt, | 71 | OutWorkAt: cmd.OutWorkAt, |
72 | BreakTime: cmd.BreakTime, | 72 | BreakTime: cmd.BreakTime, |
@@ -85,7 +85,10 @@ func (productCalendarService *ProductCalendarService) CreateProductCalendar(oper | @@ -85,7 +85,10 @@ func (productCalendarService *ProductCalendarService) CreateProductCalendar(oper | ||
85 | if err := transactionContext.CommitTransaction(); err != nil { | 85 | if err := transactionContext.CommitTransaction(); err != nil { |
86 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 86 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
87 | } | 87 | } |
88 | - return productCalendar, nil | 88 | + |
89 | + result := &dto.ProductCalendarDto{} | ||
90 | + result.LoadDto(productCalendar, 0) | ||
91 | + return result, nil | ||
89 | } | 92 | } |
90 | } | 93 | } |
91 | 94 | ||
@@ -317,13 +320,16 @@ func (productCalendarService *ProductCalendarService) UpdateProductCalendar(cmd | @@ -317,13 +320,16 @@ func (productCalendarService *ProductCalendarService) UpdateProductCalendar(cmd | ||
317 | if err := transactionContext.CommitTransaction(); err != nil { | 320 | if err := transactionContext.CommitTransaction(); err != nil { |
318 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 321 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
319 | } | 322 | } |
320 | - return productCalendar, nil | 323 | + |
324 | + result := &dto.ProductCalendarDto{} | ||
325 | + result.LoadDto(productCalendar, 0) | ||
326 | + return result, nil | ||
321 | } | 327 | } |
322 | } | 328 | } |
323 | 329 | ||
324 | // 返回工厂日历服务列表 | 330 | // 返回工厂日历服务列表 |
325 | -func (productCalendarService *ProductCalendarService) SearchProductCalendar(operateInfo *domain.OperateInfo, listProductCalendarQuery *query.SearchProductCalendarQuery) (int64, interface{}, error) { | ||
326 | - if err := listProductCalendarQuery.ValidateQuery(); err != nil { | 331 | +func (productCalendarService *ProductCalendarService) SearchProductCalendar(operateInfo *domain.OperateInfo, cmd *query.SearchProductCalendarQuery) (int64, interface{}, error) { |
332 | + if err := cmd.ValidateQuery(); err != nil { | ||
327 | return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 333 | return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
328 | } | 334 | } |
329 | transactionContext, err := factory.CreateTransactionContext(nil) | 335 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -339,7 +345,12 @@ func (productCalendarService *ProductCalendarService) SearchProductCalendar(oper | @@ -339,7 +345,12 @@ func (productCalendarService *ProductCalendarService) SearchProductCalendar(oper | ||
339 | var productCalendarRepository domain.ProductCalendarRepository | 345 | var productCalendarRepository domain.ProductCalendarRepository |
340 | productCalendarRepository, _, _ = factory.FastPgProductCalendar(transactionContext, 0) | 346 | productCalendarRepository, _, _ = factory.FastPgProductCalendar(transactionContext, 0) |
341 | 347 | ||
342 | - count, productCalendars, err := productCalendarRepository.Find(utils.ObjectToMap(listProductCalendarQuery)) | 348 | + workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId) |
349 | + queryOptions := utils.ObjectToMap(cmd) | ||
350 | + delete(queryOptions, "workshopName") | ||
351 | + queryOptions = workshops.FindByNameWithQuery(queryOptions, cmd.WorkshopName, "", "") | ||
352 | + | ||
353 | + count, productCalendars, err := productCalendarRepository.Find(queryOptions) | ||
343 | if err != nil { | 354 | if err != nil { |
344 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 355 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
345 | } | 356 | } |
@@ -352,6 +363,7 @@ func (productCalendarService *ProductCalendarService) SearchProductCalendar(oper | @@ -352,6 +363,7 @@ func (productCalendarService *ProductCalendarService) SearchProductCalendar(oper | ||
352 | item := productCalendars[i] | 363 | item := productCalendars[i] |
353 | newJobDto := &dto.ProductCalendarDto{} | 364 | newJobDto := &dto.ProductCalendarDto{} |
354 | newJobDto.LoadDto(item, operateInfo.OrgId) | 365 | newJobDto.LoadDto(item, operateInfo.OrgId) |
366 | + newJobDto.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | ||
355 | result = append(result, newJobDto) | 367 | result = append(result, newJobDto) |
356 | } | 368 | } |
357 | 369 |
@@ -25,7 +25,7 @@ type CreateProductGroupCommand struct { | @@ -25,7 +25,7 @@ type CreateProductGroupCommand struct { | ||
25 | // 班组长Id | 25 | // 班组长Id |
26 | GroupLeaderId int `cname:"班组长" json:"groupLeaderId,omitempty"` | 26 | GroupLeaderId int `cname:"班组长" json:"groupLeaderId,omitempty"` |
27 | // 帮组成员列表 | 27 | // 帮组成员列表 |
28 | - GroupMembers []int `cname:"帮组成员列表" json:"groupMembers" valid:"Required"` | 28 | + GroupMembers []int `cname:"帮组成员列表" json:"groupMembers"` |
29 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 29 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
30 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` | 30 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` |
31 | } | 31 | } |
@@ -22,7 +22,7 @@ type UpdateProductGroupCommand struct { | @@ -22,7 +22,7 @@ type UpdateProductGroupCommand struct { | ||
22 | // 班组长Id | 22 | // 班组长Id |
23 | GroupLeaderId int `cname:"班组长" json:"groupLeaderId,omitempty"` | 23 | GroupLeaderId int `cname:"班组长" json:"groupLeaderId,omitempty"` |
24 | // 帮组成员列表 | 24 | // 帮组成员列表 |
25 | - GroupMembers []int `cname:"帮组成员列表" json:"groupMembers" valid:"Required"` | 25 | + GroupMembers []int `cname:"帮组成员列表" json:"groupMembers"` |
26 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 26 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
27 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` | 27 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` |
28 | } | 28 | } |
@@ -16,9 +16,9 @@ type ProductGroupDto struct { | @@ -16,9 +16,9 @@ type ProductGroupDto struct { | ||
16 | // 班组名称 | 16 | // 班组名称 |
17 | GroupName string `json:"groupName,omitempty"` | 17 | GroupName string `json:"groupName,omitempty"` |
18 | // 班组长 | 18 | // 班组长 |
19 | - GroupLeader string `json:"groupLeader,omitempty"` | 19 | + GroupLeader string `json:"groupLeader"` |
20 | // 帮组成员列表 | 20 | // 帮组成员列表 |
21 | - GroupMembers string `json:"groupMembers,omitempty"` | 21 | + GroupMembers string `json:"groupMembers"` |
22 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 22 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
23 | WorkOn int `json:"workOn,omitempty"` | 23 | WorkOn int `json:"workOn,omitempty"` |
24 | // 工作位置 | 24 | // 工作位置 |
@@ -32,7 +32,9 @@ type ProductGroupDto struct { | @@ -32,7 +32,9 @@ type ProductGroupDto struct { | ||
32 | func (d *ProductGroupDto) LoadDto(m *domain.ProductGroup, orgId int) *ProductGroupDto { | 32 | func (d *ProductGroupDto) LoadDto(m *domain.ProductGroup, orgId int) *ProductGroupDto { |
33 | d.ProductGroupId = m.ProductGroupId | 33 | d.ProductGroupId = m.ProductGroupId |
34 | d.GroupName = m.GroupName | 34 | d.GroupName = m.GroupName |
35 | + if m.GroupLeader != nil { | ||
35 | d.GroupLeader = m.GroupLeader.UserName | 36 | d.GroupLeader = m.GroupLeader.UserName |
37 | + } | ||
36 | var members []string | 38 | var members []string |
37 | for i := range m.GroupMembers { | 39 | for i := range m.GroupMembers { |
38 | members = append(members, m.GroupMembers[i].UserName) | 40 | members = append(members, m.GroupMembers[i].UserName) |
@@ -2,6 +2,7 @@ package dto | @@ -2,6 +2,7 @@ package dto | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils/converter" | ||
5 | "strings" | 6 | "strings" |
6 | ) | 7 | ) |
7 | 8 | ||
@@ -11,12 +12,15 @@ type ProductGroupEmployeesDto struct { | @@ -11,12 +12,15 @@ type ProductGroupEmployeesDto struct { | ||
11 | UserId int `json:"userId,omitempty"` | 12 | UserId int `json:"userId,omitempty"` |
12 | // 用户姓名 | 13 | // 用户姓名 |
13 | UserName string `json:"userName,omitempty"` | 14 | UserName string `json:"userName,omitempty"` |
15 | + // 生产小组ID | ||
16 | + ProductGroupId int `json:"productGroupId,omitempty"` | ||
14 | // 班组名称 | 17 | // 班组名称 |
15 | GroupName string `json:"groupName,omitempty"` | 18 | GroupName string `json:"groupName,omitempty"` |
16 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 19 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
17 | WorkOnDescription string `json:"workOn,omitempty"` | 20 | WorkOnDescription string `json:"workOn,omitempty"` |
18 | // 工作位置键值 (车间ID+'.'+生产线ID+'.'+工段ID) | 21 | // 工作位置键值 (车间ID+'.'+生产线ID+'.'+工段ID) |
19 | //WorkStationId string `json:"workStationId,omitempty"` | 22 | //WorkStationId string `json:"workStationId,omitempty"` |
23 | + UserNamePinyin string `json:"pinyin"` | ||
20 | } | 24 | } |
21 | 25 | ||
22 | func NewProductGroupEmployeesDto(group *domain.ProductGroup) []*ProductGroupEmployeesDto { | 26 | func NewProductGroupEmployeesDto(group *domain.ProductGroup) []*ProductGroupEmployeesDto { |
@@ -34,10 +38,14 @@ func NewGroupEmployee(group *domain.ProductGroup, u *domain.User) *ProductGroupE | @@ -34,10 +38,14 @@ func NewGroupEmployee(group *domain.ProductGroup, u *domain.User) *ProductGroupE | ||
34 | item := &ProductGroupEmployeesDto{} | 38 | item := &ProductGroupEmployeesDto{} |
35 | item.UserId = u.UserId | 39 | item.UserId = u.UserId |
36 | item.UserName = u.UserName | 40 | item.UserName = u.UserName |
41 | + item.ProductGroupId = group.ProductGroupId | ||
37 | item.GroupName = group.GroupName | 42 | item.GroupName = group.GroupName |
38 | workOns := domain.WorkOnDescription(group.WorkOn) | 43 | workOns := domain.WorkOnDescription(group.WorkOn) |
39 | item.WorkOnDescription = strings.Join(workOns, ",") | 44 | item.WorkOnDescription = strings.Join(workOns, ",") |
40 | //item.WorkStationId = group.WorkStation.WorkStationId | 45 | //item.WorkStationId = group.WorkStation.WorkStationId |
46 | + if len(item.UserName) > 0 { | ||
47 | + item.UserNamePinyin = converter.ToPinYin(item.UserName, "") | ||
48 | + } | ||
41 | return item | 49 | return item |
42 | } | 50 | } |
43 | 51 | ||
@@ -63,9 +71,37 @@ func (d *ProductGroupEmployeesDtos) LoadDto(groups ...*domain.ProductGroup) { | @@ -63,9 +71,37 @@ func (d *ProductGroupEmployeesDtos) LoadDto(groups ...*domain.ProductGroup) { | ||
63 | } | 71 | } |
64 | } | 72 | } |
65 | 73 | ||
74 | +func (d *ProductGroupEmployeesDtos) LoadDtoV2(list ...*domain.ProductAttendanceRecord) { | ||
75 | + var mapUser = make(map[int]int) | ||
76 | + for _, v := range list { | ||
77 | + item := &ProductGroupEmployeesDto{} | ||
78 | + item.UserId = v.ProductWorker.UserId | ||
79 | + item.UserName = v.ProductWorker.UserName | ||
80 | + item.ProductGroupId = 0 | ||
81 | + item.GroupName = "" | ||
82 | + if len(item.UserName) > 0 { | ||
83 | + item.UserNamePinyin = converter.ToPinYin(item.UserName, "") | ||
84 | + } | ||
85 | + if _, ok := mapUser[item.UserId]; ok { | ||
86 | + continue | ||
87 | + } else { | ||
88 | + mapUser[item.UserId] = item.UserId | ||
89 | + } | ||
90 | + d.Append(item) | ||
91 | + } | ||
92 | +} | ||
93 | + | ||
66 | func NewProductGroupEmployeesDtos() *ProductGroupEmployeesDtos { | 94 | func NewProductGroupEmployeesDtos() *ProductGroupEmployeesDtos { |
67 | return &ProductGroupEmployeesDtos{ | 95 | return &ProductGroupEmployeesDtos{ |
68 | Result: make([]*ProductGroupEmployeesDto, 0), | 96 | Result: make([]*ProductGroupEmployeesDto, 0), |
69 | MapResult: make(map[int]*ProductGroupEmployeesDto), | 97 | MapResult: make(map[int]*ProductGroupEmployeesDto), |
70 | } | 98 | } |
71 | } | 99 | } |
100 | + | ||
101 | +func (ms *ProductGroupEmployeesDtos) Len() int { return len(ms.Result) } | ||
102 | +func (ms *ProductGroupEmployeesDtos) Less(i, j int) bool { | ||
103 | + return ms.Result[i].UserNamePinyin < ms.Result[j].UserNamePinyin | ||
104 | +} | ||
105 | +func (ms *ProductGroupEmployeesDtos) Swap(i, j int) { | ||
106 | + ms.Result[i], ms.Result[j] = ms.Result[j], ms.Result[i] | ||
107 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | +) | ||
9 | + | ||
10 | +type GetSignInEmployeeQuery 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 | + // IC卡号 | ||
24 | + IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"` | ||
25 | +} | ||
26 | + | ||
27 | +func (listProductGroupQuery *GetSignInEmployeeQuery) Valid(validation *validation.Validation) { | ||
28 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
29 | +} | ||
30 | + | ||
31 | +func (listProductGroupQuery *GetSignInEmployeeQuery) ValidateQuery() error { | ||
32 | + valid := validation.Validation{} | ||
33 | + b, err := valid.Valid(listProductGroupQuery) | ||
34 | + if err != nil { | ||
35 | + return err | ||
36 | + } | ||
37 | + if !b { | ||
38 | + elem := reflect.TypeOf(listProductGroupQuery).Elem() | ||
39 | + for _, validErr := range valid.Errors { | ||
40 | + field, isExist := elem.FieldByName(validErr.Field) | ||
41 | + if isExist { | ||
42 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
43 | + } else { | ||
44 | + return fmt.Errorf(validErr.Message) | ||
45 | + } | ||
46 | + } | ||
47 | + } | ||
48 | + return nil | ||
49 | +} |
@@ -11,6 +11,7 @@ import ( | @@ -11,6 +11,7 @@ import ( | ||
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" |
13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" |
14 | + "sort" | ||
14 | "time" | 15 | "time" |
15 | ) | 16 | ) |
16 | 17 | ||
@@ -44,16 +45,20 @@ func (productGroupService *ProductGroupService) CreateProductGroup(operateInfo * | @@ -44,16 +45,20 @@ func (productGroupService *ProductGroupService) CreateProductGroup(operateInfo * | ||
44 | } | 45 | } |
45 | 46 | ||
46 | var leader *domain.User | 47 | var leader *domain.User |
47 | - var members []*domain.User | 48 | + var members = make([]*domain.User, 0) |
48 | userService := domainService.NewUserService() | 49 | userService := domainService.NewUserService() |
50 | + if cmd.GroupLeaderId > 0 { | ||
49 | leader, err = userService.User(cmd.GroupLeaderId) | 51 | leader, err = userService.User(cmd.GroupLeaderId) |
50 | if err != nil { | 52 | if err != nil { |
51 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 53 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
52 | } | 54 | } |
55 | + } | ||
56 | + if len(cmd.GroupMembers) > 0 { | ||
53 | members, err = userService.Users(cmd.GroupMembers) | 57 | members, err = userService.Users(cmd.GroupMembers) |
54 | if err != nil { | 58 | if err != nil { |
55 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 59 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
56 | } | 60 | } |
61 | + } | ||
57 | 62 | ||
58 | var org *domain.Org | 63 | var org *domain.Org |
59 | org, err = userService.Organization(operateInfo.OrgId) | 64 | org, err = userService.Organization(operateInfo.OrgId) |
@@ -129,6 +134,9 @@ func (productGroupService *ProductGroupService) GetProductGroup(getProductGroupQ | @@ -129,6 +134,9 @@ func (productGroupService *ProductGroupService) GetProductGroup(getProductGroupQ | ||
129 | if err := transactionContext.CommitTransaction(); err != nil { | 134 | if err := transactionContext.CommitTransaction(); err != nil { |
130 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 135 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
131 | } | 136 | } |
137 | + //if productGroup.GroupLeader==nil{ | ||
138 | + // productGroup.GroupLeader = &domain.User{} | ||
139 | + //} | ||
132 | return productGroup, nil | 140 | return productGroup, nil |
133 | } | 141 | } |
134 | 142 | ||
@@ -291,16 +299,20 @@ func (productGroupService *ProductGroupService) UpdateProductGroup(cmd *command. | @@ -291,16 +299,20 @@ func (productGroupService *ProductGroupService) UpdateProductGroup(cmd *command. | ||
291 | } | 299 | } |
292 | 300 | ||
293 | var leader *domain.User | 301 | var leader *domain.User |
294 | - var members []*domain.User | 302 | + var members = make([]*domain.User, 0) |
295 | userService := domainService.NewUserService() | 303 | userService := domainService.NewUserService() |
304 | + if cmd.GroupLeaderId > 0 { | ||
296 | leader, err = userService.User(cmd.GroupLeaderId) | 305 | leader, err = userService.User(cmd.GroupLeaderId) |
297 | if err != nil { | 306 | if err != nil { |
298 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 307 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
299 | } | 308 | } |
309 | + } | ||
310 | + if len(cmd.GroupMembers) > 0 { | ||
300 | members, err = userService.Users(cmd.GroupMembers) | 311 | members, err = userService.Users(cmd.GroupMembers) |
301 | if err != nil { | 312 | if err != nil { |
302 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 313 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
303 | } | 314 | } |
315 | + } | ||
304 | productGroup.GroupLeader = leader | 316 | productGroup.GroupLeader = leader |
305 | productGroup.GroupMembers = members | 317 | productGroup.GroupMembers = members |
306 | productGroup.WorkOn = cmd.WorkOn | 318 | productGroup.WorkOn = cmd.WorkOn |
@@ -358,7 +370,7 @@ func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo * | @@ -358,7 +370,7 @@ func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo * | ||
358 | item := productGroups[i] | 370 | item := productGroups[i] |
359 | newItem := &dto.ProductGroupDto{} | 371 | newItem := &dto.ProductGroupDto{} |
360 | newItem.LoadDto(productGroups[i], operateInfo.OrgId) | 372 | newItem.LoadDto(productGroups[i], operateInfo.OrgId) |
361 | - item.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | 373 | + newItem.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) |
362 | results = append(results, newItem) | 374 | results = append(results, newItem) |
363 | } | 375 | } |
364 | if err := transactionContext.CommitTransaction(); err != nil { | 376 | if err := transactionContext.CommitTransaction(); err != nil { |
@@ -383,9 +395,7 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | @@ -383,9 +395,7 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | ||
383 | transactionContext.RollbackTransaction() | 395 | transactionContext.RollbackTransaction() |
384 | }() | 396 | }() |
385 | 397 | ||
386 | - //workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId) | ||
387 | queryOptions := utils.ObjectToMap(cmd) | 398 | queryOptions := utils.ObjectToMap(cmd) |
388 | - //queryOptions = workshops.FindByNameWithQuery(queryOptions, cmd.WorkshopName, cmd.LineName, "") | ||
389 | 399 | ||
390 | var productGroupRepository domain.ProductGroupRepository | 400 | var productGroupRepository domain.ProductGroupRepository |
391 | productGroupRepository, _, _ = factory.FastPgProductGroup(transactionContext, 0) | 401 | productGroupRepository, _, _ = factory.FastPgProductGroup(transactionContext, 0) |
@@ -401,6 +411,42 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | @@ -401,6 +411,42 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | ||
401 | items := dto.NewProductGroupEmployeesDto(item) | 411 | items := dto.NewProductGroupEmployeesDto(item) |
402 | results.Append(items...) | 412 | results.Append(items...) |
403 | } | 413 | } |
414 | + sort.Stable(results) | ||
415 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
416 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
417 | + } | ||
418 | + return int64(len(results.Result)), map[string]interface{}{ | ||
419 | + "employees": results.Result, | ||
420 | + }, nil | ||
421 | +} | ||
422 | + | ||
423 | +// 返回在当前工段上打卡的所有用户 | ||
424 | +func (productGroupService *ProductGroupService) SearchProductGroupEmployeesV2(operateInfo *domain.OperateInfo, cmd *query.SearchProductGroupEmployeesQuery) (int64, interface{}, error) { | ||
425 | + if err := cmd.ValidateQuery(); err != nil { | ||
426 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
427 | + } | ||
428 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
429 | + if err != nil { | ||
430 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
431 | + } | ||
432 | + if err := transactionContext.StartTransaction(); err != nil { | ||
433 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
434 | + } | ||
435 | + defer func() { | ||
436 | + transactionContext.RollbackTransaction() | ||
437 | + }() | ||
438 | + | ||
439 | + queryOptions := utils.ObjectToMap(cmd) | ||
440 | + queryOptions["signBeginTime"] = utils.GetZeroTime(time.Now()) | ||
441 | + var attendanceRecordRepository domain.ProductAttendanceRecordRepository | ||
442 | + attendanceRecordRepository, _, _ = factory.FastPgAttendance(transactionContext, 0) | ||
443 | + _, productGroups, err := attendanceRecordRepository.Find(queryOptions) | ||
444 | + if err != nil { | ||
445 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
446 | + } | ||
447 | + var results = dto.NewProductGroupEmployeesDtos() | ||
448 | + results.LoadDtoV2(productGroups...) | ||
449 | + sort.Stable(results) | ||
404 | if err := transactionContext.CommitTransaction(); err != nil { | 450 | if err := transactionContext.CommitTransaction(); err != nil { |
405 | return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 451 | return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
406 | } | 452 | } |
@@ -409,6 +455,37 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | @@ -409,6 +455,37 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | ||
409 | }, nil | 455 | }, nil |
410 | } | 456 | } |
411 | 457 | ||
458 | +// 返回生产班组服务列表 | ||
459 | +func (productGroupService *ProductGroupService) GetSignEmployee(cmd *query.GetSignInEmployeeQuery) (interface{}, error) { | ||
460 | + if err := cmd.ValidateQuery(); err != nil { | ||
461 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
462 | + } | ||
463 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
464 | + if err != nil { | ||
465 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
466 | + } | ||
467 | + if err := transactionContext.StartTransaction(); err != nil { | ||
468 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
469 | + } | ||
470 | + defer func() { | ||
471 | + transactionContext.RollbackTransaction() | ||
472 | + }() | ||
473 | + | ||
474 | + var userService = domainService.NewUserService() | ||
475 | + | ||
476 | + worker, err := userService.UserByICCode(cmd.CompanyId, cmd.OrgId, cmd.IcCardNumber) | ||
477 | + if err != nil || worker == nil || worker.UserId == 0 { | ||
478 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户不存在") | ||
479 | + } | ||
480 | + | ||
481 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
482 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
483 | + } | ||
484 | + return map[string]interface{}{ | ||
485 | + "employee": worker, | ||
486 | + }, nil | ||
487 | +} | ||
488 | + | ||
412 | func NewProductGroupService(options map[string]interface{}) *ProductGroupService { | 489 | func NewProductGroupService(options map[string]interface{}) *ProductGroupService { |
413 | newProductGroupService := &ProductGroupService{} | 490 | newProductGroupService := &ProductGroupService{} |
414 | return newProductGroupService | 491 | return newProductGroupService |
@@ -97,7 +97,7 @@ func (productJobService *ProductJobService) GetProductJob(getProductJobQuery *qu | @@ -97,7 +97,7 @@ func (productJobService *ProductJobService) GetProductJob(getProductJobQuery *qu | ||
97 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 97 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
98 | } | 98 | } |
99 | productJob.WorkStation, _ = workshop.FindWorkStation(productJob.WorkStation.WorkshopId, productJob.WorkStation.LineId, productJob.WorkStation.SectionId) | 99 | productJob.WorkStation, _ = workshop.FindWorkStation(productJob.WorkStation.WorkshopId, productJob.WorkStation.LineId, productJob.WorkStation.SectionId) |
100 | - | 100 | + productJob.WorkStation.Principal = workshop.Principal |
101 | newJobDto := &dto.ProductJobDto{} | 101 | newJobDto := &dto.ProductJobDto{} |
102 | newJobDto.LoadDto(productJob, 0) | 102 | newJobDto.LoadDto(productJob, 0) |
103 | 103 | ||
@@ -335,9 +335,11 @@ func (productJobService *ProductJobService) SearchProductJob(operateInfo *domain | @@ -335,9 +335,11 @@ func (productJobService *ProductJobService) SearchProductJob(operateInfo *domain | ||
335 | var result = make([]*dto.ProductJobDto, 0) | 335 | var result = make([]*dto.ProductJobDto, 0) |
336 | for i := range productJobs { | 336 | for i := range productJobs { |
337 | item := productJobs[i] | 337 | item := productJobs[i] |
338 | - item.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | 338 | + |
339 | newJobDto := &dto.ProductJobDto{} | 339 | newJobDto := &dto.ProductJobDto{} |
340 | newJobDto.LoadDto(item, operateInfo.OrgId) | 340 | newJobDto.LoadDto(item, operateInfo.OrgId) |
341 | + newJobDto.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId, 1) | ||
342 | + //newJobDto.WorkStation.Principal = item.WorkStation.Principal | ||
341 | result = append(result, newJobDto) | 343 | result = append(result, newJobDto) |
342 | } | 344 | } |
343 | return count, result, nil | 345 | return count, result, nil |
@@ -17,7 +17,7 @@ type CreateProductPlanCommand struct { | @@ -17,7 +17,7 @@ type CreateProductPlanCommand struct { | ||
17 | // 车间ID | 17 | // 车间ID |
18 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 18 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` |
19 | // 批号 | 19 | // 批号 |
20 | - BatchNumber string `cname:"批号" json:"batchNumber" valid:"Required"` | 20 | + BatchNumber string `cname:"批号" json:"batchNumber"` |
21 | // 生产日期 | 21 | // 生产日期 |
22 | ProductDate string `cname:"生产日期" json:"productDate" valid:"Required"` | 22 | ProductDate string `cname:"生产日期" json:"productDate" valid:"Required"` |
23 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 23 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
@@ -28,17 +28,14 @@ type CreateProductPlanCommand struct { | @@ -28,17 +28,14 @@ type CreateProductPlanCommand struct { | ||
28 | //PlanProductName string `cname:"计划的产品名称" json:"planProductName"` | 28 | //PlanProductName string `cname:"计划的产品名称" json:"planProductName"` |
29 | // 产品ID | 29 | // 产品ID |
30 | ProductId int `cname:"产品ID" json:"productId" valid:"Required"` | 30 | ProductId int `cname:"产品ID" json:"productId" valid:"Required"` |
31 | + // 投入量规格 默认份 | ||
32 | + DevotedUnit string `cname:"投入量规格" json:"devotedUnit" ` | ||
31 | // 数量(保留两位小数) | 33 | // 数量(保留两位小数) |
32 | Quantity float64 `cname:"数量(保留两位小数)" json:"quantity" valid:"Required"` | 34 | Quantity float64 `cname:"数量(保留两位小数)" json:"quantity" valid:"Required"` |
33 | - // 单位 | ||
34 | - //Unit string `cname:"单位" json:"unit" ` | ||
35 | - // 单份重量(原材料) | ||
36 | - //nitWeight float64 `cname:"单份重量(原材料)" json:"unitWeight" valid:"Required"` | ||
37 | // 重量 | 35 | // 重量 |
38 | Weight float64 `cname:"重量" json:"weight" valid:"Required"` | 36 | Weight float64 `cname:"重量" json:"weight" valid:"Required"` |
39 | // 备注 | 37 | // 备注 |
40 | Remark string `cname:"备注" json:"remark"` | 38 | Remark string `cname:"备注" json:"remark"` |
41 | - | ||
42 | // 生产日期 | 39 | // 生产日期 |
43 | ProductDateTime time.Time `cname:"生产日期" json:"-" ` | 40 | ProductDateTime time.Time `cname:"生产日期" json:"-" ` |
44 | } | 41 | } |
@@ -49,8 +46,8 @@ func (createProductPlanCommand *CreateProductPlanCommand) Valid(validation *vali | @@ -49,8 +46,8 @@ func (createProductPlanCommand *CreateProductPlanCommand) Valid(validation *vali | ||
49 | validation.Error(err.Error()) | 46 | validation.Error(err.Error()) |
50 | return | 47 | return |
51 | } | 48 | } |
52 | - if t, err := time.Parse("2006/01/02", createProductPlanCommand.ProductDate); err != nil { | ||
53 | - validation.Error("时间格式有误 2006/01/02") | 49 | + if t, err := time.Parse("2006-01-02", createProductPlanCommand.ProductDate); err != nil { |
50 | + validation.Error("时间格式有误" + createProductPlanCommand.ProductDate) | ||
54 | return | 51 | return |
55 | } else { | 52 | } else { |
56 | createProductPlanCommand.ProductDateTime = t | 53 | createProductPlanCommand.ProductDateTime = t |
@@ -9,8 +9,26 @@ import ( | @@ -9,8 +9,26 @@ import ( | ||
9 | ) | 9 | ) |
10 | 10 | ||
11 | type ReceiveMaterialCommand struct { | 11 | type ReceiveMaterialCommand struct { |
12 | + // 企业id | ||
13 | + CompanyId int `cname:"企业id" json:"companyId" valid:"Required"` | ||
14 | + // 组织ID | ||
15 | + OrgId int `cname:"组织ID" json:"orgId" valid:"Required"` | ||
12 | // 生产计划ID | 16 | // 生产计划ID |
13 | - ProductPlanId int `cname:"生产计划ID" json:"productPlanId" valid:"Required"` | 17 | + ProductPlanId int `cname:"生产计划" json:"productPlanId" valid:"Required"` |
18 | + // 车间ID | ||
19 | + WorkshopId int `cname:"车间" json:"workshopId" valid:"Required"` | ||
20 | + // 生产线ID | ||
21 | + LineId int `cname:"生产线" json:"lineId" valid:"Required"` | ||
22 | + // 工段ID | ||
23 | + SectionId int `cname:"工段" json:"sectionId" valid:"Required"` | ||
24 | + // 生产小组ID | ||
25 | + ProductGroupId int `cname:"生产小组" json:"productGroupId"` | ||
26 | + // 员工Id 用户唯一标识 | ||
27 | + EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` | ||
28 | + // 物料ID | ||
29 | + UnitConversionId int `cname:"物料ID" json:"unitConversionId" valid:"Required"` | ||
30 | + // 重量 | ||
31 | + Weigh float64 `cname:"重量" json:"weigh" valid:"Required"` | ||
14 | } | 32 | } |
15 | 33 | ||
16 | func (receiveMaterialCommand *ReceiveMaterialCommand) Valid(validation *validation.Validation) { | 34 | func (receiveMaterialCommand *ReceiveMaterialCommand) Valid(validation *validation.Validation) { |
@@ -9,8 +9,26 @@ import ( | @@ -9,8 +9,26 @@ import ( | ||
9 | ) | 9 | ) |
10 | 10 | ||
11 | type ReturnMaterialCommand struct { | 11 | type ReturnMaterialCommand struct { |
12 | + // 企业id | ||
13 | + CompanyId int `cname:"企业id" json:"companyId" valid:"Required"` | ||
14 | + // 组织ID | ||
15 | + OrgId int `cname:"组织ID" json:"orgId" valid:"Required"` | ||
12 | // 生产计划ID | 16 | // 生产计划ID |
13 | - ProductPlanId int `cname:"生产计划ID" json:"productPlanId" valid:"Required"` | 17 | + ProductPlanId int `cname:"生产计划" json:"productPlanId" valid:"Required"` |
18 | + // 车间ID | ||
19 | + WorkshopId int `cname:"车间" json:"workshopId" valid:"Required"` | ||
20 | + // 生产线ID | ||
21 | + LineId int `cname:"生产线" json:"lineId" valid:"Required"` | ||
22 | + // 工段ID | ||
23 | + SectionId int `cname:"工段" json:"sectionId" valid:"Required"` | ||
24 | + // 生产小组ID | ||
25 | + ProductGroupId int `cname:"生产小组" json:"productGroupId"` | ||
26 | + // 员工Id 用户唯一标识 | ||
27 | + EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` | ||
28 | + // 物料ID | ||
29 | + UnitConversionId int `cname:"物料ID" json:"unitConversionId" valid:"Required"` | ||
30 | + // 重量 | ||
31 | + Weigh float64 `cname:"重量" json:"weigh" valid:"Required"` | ||
14 | } | 32 | } |
15 | 33 | ||
16 | func (returnMaterialCommand *ReturnMaterialCommand) Valid(validation *validation.Validation) { | 34 | func (returnMaterialCommand *ReturnMaterialCommand) Valid(validation *validation.Validation) { |
@@ -10,7 +10,7 @@ import ( | @@ -10,7 +10,7 @@ import ( | ||
10 | 10 | ||
11 | type SetOfflineCommand struct { | 11 | type SetOfflineCommand struct { |
12 | // 生产计划ID | 12 | // 生产计划ID |
13 | - ProductPlanId int `cname:"生产计划ID" json:"productPlanId" valid:"Required"` | 13 | + ProductPlanId int `cname:"生产计划ID" json:"productPlanDispatchRecordId" valid:"Required"` |
14 | } | 14 | } |
15 | 15 | ||
16 | func (setOfflineCommand *SetOfflineCommand) Valid(validation *validation.Validation) { | 16 | func (setOfflineCommand *SetOfflineCommand) Valid(validation *validation.Validation) { |
@@ -12,9 +12,9 @@ type SetOnlineCommand struct { | @@ -12,9 +12,9 @@ type SetOnlineCommand struct { | ||
12 | // 生产计划ID | 12 | // 生产计划ID |
13 | ProductPlanId int `cname:"生产计划ID" json:"productPlanId" valid:"Required"` | 13 | ProductPlanId int `cname:"生产计划ID" json:"productPlanId" valid:"Required"` |
14 | // 车间ID | 14 | // 车间ID |
15 | - WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 15 | + WorkshopId int `cname:"车间ID" json:"workshopId" ` |
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 | } |
@@ -9,8 +9,26 @@ import ( | @@ -9,8 +9,26 @@ import ( | ||
9 | ) | 9 | ) |
10 | 10 | ||
11 | type SubmitProductRecordCommand struct { | 11 | type SubmitProductRecordCommand struct { |
12 | + // 企业id | ||
13 | + CompanyId int `cname:"企业id" json:"companyId" valid:"Required"` | ||
14 | + // 组织ID | ||
15 | + OrgId int `cname:"组织ID" json:"orgId" valid:"Required"` | ||
12 | // 生产计划ID | 16 | // 生产计划ID |
13 | - ProductPlanId int `cname:"生产计划ID" json:"productPlanId" valid:"Required"` | 17 | + ProductPlanId int `cname:"生产计划" json:"productPlanId" valid:"Required"` |
18 | + // 车间ID | ||
19 | + WorkshopId int `cname:"车间" json:"workshopId" valid:"Required"` | ||
20 | + // 生产线ID | ||
21 | + LineId int `cname:"生产线" json:"lineId" valid:"Required"` | ||
22 | + // 工段ID | ||
23 | + SectionId int `cname:"工段" json:"sectionId" valid:"Required"` | ||
24 | + // 生产小组ID | ||
25 | + ProductGroupId int `cname:"生产小组" json:"productGroupId"` | ||
26 | + // 员工Id 用户唯一标识 | ||
27 | + EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` | ||
28 | + // 物料ID | ||
29 | + UnitConversionId int `cname:"物料ID" json:"unitConversionId"` | ||
30 | + // 重量 | ||
31 | + Weigh float64 `cname:"重量" json:"weigh" valid:"Required"` | ||
14 | } | 32 | } |
15 | 33 | ||
16 | func (submitProductRecordCommand *SubmitProductRecordCommand) Valid(validation *validation.Validation) { | 34 | func (submitProductRecordCommand *SubmitProductRecordCommand) Valid(validation *validation.Validation) { |
@@ -9,10 +9,10 @@ import ( | @@ -9,10 +9,10 @@ import ( | ||
9 | ) | 9 | ) |
10 | 10 | ||
11 | type SwitchCommand struct { | 11 | type SwitchCommand struct { |
12 | - // 下线计划ID | ||
13 | - FromProductPlanId int `cname:"下线计划ID" json:"fromProductPlanId,omitempty"` | ||
14 | - // 上线计划ID | ||
15 | - ToProductPlanId int `cname:"上线计划ID" json:"toProductPlanId,omitempty"` | 12 | + // 已上线计划ID |
13 | + FromProductPlanDispatchRecordId int `cname:"已上线计划ID" json:"productPlanDispatchRecordId,omitempty" valid:"Required"` | ||
14 | + // 计划ID | ||
15 | + ToProductPlanId int `cname:"计划ID" json:"productPlanId,omitempty" valid:"Required"` | ||
16 | } | 16 | } |
17 | 17 | ||
18 | func (switchCommand *SwitchCommand) Valid(validation *validation.Validation) { | 18 | func (switchCommand *SwitchCommand) Valid(validation *validation.Validation) { |
@@ -19,7 +19,7 @@ type UpdateProductPlanCommand struct { | @@ -19,7 +19,7 @@ type UpdateProductPlanCommand struct { | ||
19 | // 车间ID | 19 | // 车间ID |
20 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 20 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` |
21 | // 批号 | 21 | // 批号 |
22 | - BatchNumber string `cname:"批号" json:"batchNumber" valid:"Required"` | 22 | + BatchNumber string `cname:"批号" json:"batchNumber"` |
23 | // 生产日期 | 23 | // 生产日期 |
24 | ProductDate string `cname:"生产日期" json:"productDate" valid:"Required"` | 24 | ProductDate string `cname:"生产日期" json:"productDate" valid:"Required"` |
25 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 25 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
@@ -30,6 +30,8 @@ type UpdateProductPlanCommand struct { | @@ -30,6 +30,8 @@ type UpdateProductPlanCommand struct { | ||
30 | PlanProductName string `cname:"计划的产品名称" json:"planProductName"` | 30 | PlanProductName string `cname:"计划的产品名称" json:"planProductName"` |
31 | // 产品ID | 31 | // 产品ID |
32 | ProductId int `cname:"产品ID" json:"productId" valid:"Required"` | 32 | ProductId int `cname:"产品ID" json:"productId" valid:"Required"` |
33 | + // 投入量规格 默认份 | ||
34 | + DevotedUnit string `cname:"投入量规格" json:"devotedUnit" ` | ||
33 | // 数量(保留两位小数) | 35 | // 数量(保留两位小数) |
34 | Quantity float64 `cname:"数量(保留两位小数)" json:"quantity" valid:"Required"` | 36 | Quantity float64 `cname:"数量(保留两位小数)" json:"quantity" valid:"Required"` |
35 | // 单位 | 37 | // 单位 |
@@ -39,7 +41,7 @@ type UpdateProductPlanCommand struct { | @@ -39,7 +41,7 @@ type UpdateProductPlanCommand struct { | ||
39 | // 重量 | 41 | // 重量 |
40 | Weight float64 `cname:"重量" json:"weight"` | 42 | Weight float64 `cname:"重量" json:"weight"` |
41 | // 备注 | 43 | // 备注 |
42 | - Remark string `cname:"备注" json:"remark" valid:"Required"` | 44 | + Remark string `cname:"备注" json:"remark"` |
43 | // 生产日期 | 45 | // 生产日期 |
44 | ProductDateTime time.Time `cname:"生产日期" json:"productDateTime" ` | 46 | ProductDateTime time.Time `cname:"生产日期" json:"productDateTime" ` |
45 | } | 47 | } |
@@ -49,8 +51,8 @@ func (updateProductPlanCommand *UpdateProductPlanCommand) Valid(validation *vali | @@ -49,8 +51,8 @@ func (updateProductPlanCommand *UpdateProductPlanCommand) Valid(validation *vali | ||
49 | validation.Error(err.Error()) | 51 | validation.Error(err.Error()) |
50 | return | 52 | return |
51 | } | 53 | } |
52 | - if t, err := time.Parse("2006/01/02", updateProductPlanCommand.ProductDate); err != nil { | ||
53 | - validation.Error("时间格式有误 2006/01/02") | 54 | + if t, err := time.Parse("2006-01-02", updateProductPlanCommand.ProductDate); err != nil { |
55 | + validation.Error("时间格式有误") | ||
54 | return | 56 | return |
55 | } else { | 57 | } else { |
56 | updateProductPlanCommand.ProductDateTime = t | 58 | updateProductPlanCommand.ProductDateTime = t |
1 | +package dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | + "strings" | ||
6 | +) | ||
7 | + | ||
8 | +type ProductPlanDispatchRecordDto struct { | ||
9 | + // 生产计划ID | ||
10 | + ProductPlanId int `json:"productPlanDispatchRecordId,omitempty"` | ||
11 | + // 批号 | ||
12 | + BatchNumber string `json:"batchNumber,omitempty"` | ||
13 | + // 生产日期 | ||
14 | + ProductDate string `json:"productDate,omitempty"` | ||
15 | + // 车间 | ||
16 | + //*domain.Workshop | ||
17 | + *domain.WorkStation | ||
18 | + // 上班班次 1:全天 2:白班 4:中班 8:夜班 | ||
19 | + WorkOn int `json:"workOn,omitempty"` | ||
20 | + // 上班班次描述 | ||
21 | + WorkOnDescription string `json:"workOnDescription"` | ||
22 | + // 机台 (A、B、C、D 区分机器大小) | ||
23 | + Machine string `json:"machine,omitempty"` | ||
24 | + // 计划的产品名称 | ||
25 | + PlanProductName string `json:"planProductName,omitempty"` | ||
26 | + // 计划投入 | ||
27 | + *domain.UnitQuantity | ||
28 | + // 计划状态 (1:上线 2:下线 默认下线) | ||
29 | + PlanDispatchStatus int `json:"planDispatchStatus,omitempty"` | ||
30 | + // 工作位置 | ||
31 | + //WorkStation *WorkStation `json:"workStation,omitempty"` | ||
32 | + // 总产能 | ||
33 | + //TotalProduct float64 `json:"totalProduct"` | ||
34 | + // 备注 | ||
35 | + Remark string `json:"remark,omitempty"` | ||
36 | + // 组织名称 | ||
37 | + OrgName string `json:"orgName"` | ||
38 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
39 | + AuthFlag bool `json:"authFlag"` | ||
40 | +} | ||
41 | + | ||
42 | +func (d *ProductPlanDispatchRecordDto) LoadDto(m *domain.ProductPlanDispatchRecord, orgId int) *ProductPlanDispatchRecordDto { | ||
43 | + d.ProductPlanId = m.ProductPlanDispatchRecordId | ||
44 | + d.BatchNumber = m.BatchNumber | ||
45 | + d.ProductDate = m.ProductDate.Format("2006/01/02") | ||
46 | + d.WorkStation = m.WorkStation | ||
47 | + d.WorkOn = m.PlanDispatchRecordExt.WorkOn | ||
48 | + d.PlanProductName = m.PlanDispatchRecordExt.PlanProductName | ||
49 | + //d.UnitQuantity = m.PlanDevoted | ||
50 | + d.PlanDispatchStatus = m.PlanDispatchStatus | ||
51 | + //d.TotalProduct = 0 | ||
52 | + d.Machine = m.PlanDispatchRecordExt.Machine | ||
53 | + d.Remark = m.PlanDispatchRecordExt.Remark | ||
54 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
55 | + if m.Ext != nil { | ||
56 | + d.OrgName = m.Ext.OrgName | ||
57 | + } | ||
58 | + workOnDesc := domain.WorkOnDescription(m.PlanDispatchRecordExt.WorkOn) | ||
59 | + d.WorkOnDescription = strings.Join(workOnDesc, ",") | ||
60 | + return d | ||
61 | +} |
@@ -23,9 +23,13 @@ type ProductPlanDto struct { | @@ -23,9 +23,13 @@ type ProductPlanDto struct { | ||
23 | // 上班班次描述 | 23 | // 上班班次描述 |
24 | WorkOnDescription string `json:"workOnDescription"` | 24 | WorkOnDescription string `json:"workOnDescription"` |
25 | // 机台 (A、B、C、D 区分机器大小) | 25 | // 机台 (A、B、C、D 区分机器大小) |
26 | - Machine string `json:"machine,omitempty"` | 26 | + Machine string `json:"machine"` |
27 | + // 产品ID | ||
28 | + ProductId int `json:"productId,omitempty"` | ||
27 | // 计划的产品名称 | 29 | // 计划的产品名称 |
28 | PlanProductName string `json:"planProductName,omitempty"` | 30 | PlanProductName string `json:"planProductName,omitempty"` |
31 | + // 投入量规格 默认份 | ||
32 | + DevotedUnit string `json:"devotedUnit" ` | ||
29 | // 计划投入 | 33 | // 计划投入 |
30 | *domain.UnitQuantity | 34 | *domain.UnitQuantity |
31 | // 计划状态 (1:上线 2:下线 默认下线) | 35 | // 计划状态 (1:上线 2:下线 默认下线) |
@@ -45,12 +49,19 @@ type ProductPlanDto struct { | @@ -45,12 +49,19 @@ type ProductPlanDto struct { | ||
45 | func (d *ProductPlanDto) LoadDto(m *domain.ProductPlan, orgId int) *ProductPlanDto { | 49 | func (d *ProductPlanDto) LoadDto(m *domain.ProductPlan, orgId int) *ProductPlanDto { |
46 | d.ProductPlanId = m.ProductPlanId | 50 | d.ProductPlanId = m.ProductPlanId |
47 | d.BatchNumber = m.BatchNumber | 51 | d.BatchNumber = m.BatchNumber |
48 | - d.ProductDate = m.ProductDate.Format("2006/01/02") | 52 | + d.ProductDate = m.ProductDate.Format("2006-01-02") |
49 | d.WorkshopId = m.Workshop.WorkshopId | 53 | d.WorkshopId = m.Workshop.WorkshopId |
50 | d.WorkshopName = m.Workshop.WorkshopName | 54 | d.WorkshopName = m.Workshop.WorkshopName |
51 | d.WorkOn = m.WorkOn | 55 | d.WorkOn = m.WorkOn |
56 | + | ||
57 | + d.Machine = m.Machine | ||
52 | d.PlanProductName = m.PlanProductName | 58 | d.PlanProductName = m.PlanProductName |
53 | d.UnitQuantity = m.PlanDevoted | 59 | d.UnitQuantity = m.PlanDevoted |
60 | + d.DevotedUnit = "份" | ||
61 | + if m.Ext.ProductPlanExt != nil { | ||
62 | + d.DevotedUnit = m.Ext.ProductPlanExt.DevotedUnit | ||
63 | + d.ProductId = m.Ext.ProductPlanExt.ProductId | ||
64 | + } | ||
54 | d.PlanStatus = m.PlanStatus | 65 | d.PlanStatus = m.PlanStatus |
55 | d.TotalProduct = 0 | 66 | d.TotalProduct = 0 |
56 | d.Remark = m.Remark | 67 | d.Remark = m.Remark |
@@ -28,6 +28,8 @@ type SearchProductPlanQuery struct { | @@ -28,6 +28,8 @@ type SearchProductPlanQuery struct { | ||
28 | BatchNumber string `cname:"批号" json:"batchNumber"` | 28 | BatchNumber string `cname:"批号" json:"batchNumber"` |
29 | // 车间名称 | 29 | // 车间名称 |
30 | WorkshopName string `cname:"车间名称" json:"workshopName"` | 30 | WorkshopName string `cname:"车间名称" json:"workshopName"` |
31 | + // 车间ID | ||
32 | + WorkshopId string `cname:"车间ID" json:"workshopId"` | ||
31 | } | 33 | } |
32 | 34 | ||
33 | func (cmd *SearchProductPlanQuery) Valid(validation *validation.Validation) { | 35 | func (cmd *SearchProductPlanQuery) Valid(validation *validation.Validation) { |
@@ -3,6 +3,7 @@ package service | @@ -3,6 +3,7 @@ package service | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | "github.com/linmadan/egglib-go/core/application" | 5 | "github.com/linmadan/egglib-go/core/application" |
6 | + "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | "github.com/linmadan/egglib-go/utils/tool_funs" | 7 | "github.com/linmadan/egglib-go/utils/tool_funs" |
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/command" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/command" |
@@ -10,7 +11,9 @@ import ( | @@ -10,7 +11,9 @@ import ( | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/query" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/query" |
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" |
14 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | 15 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" |
16 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
14 | "time" | 17 | "time" |
15 | ) | 18 | ) |
16 | 19 | ||
@@ -59,6 +62,16 @@ func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.Cre | @@ -59,6 +62,16 @@ func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.Cre | ||
59 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 62 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
60 | } | 63 | } |
61 | 64 | ||
65 | + if len(cmd.BatchNumber) == 0 { | ||
66 | + generator := redis.NewPlanBatchCodeCache(cmd.CompanyId) | ||
67 | + code, err := redis.GenCode(generator) | ||
68 | + if err != nil { | ||
69 | + log.Logger.Error(err.Error()) | ||
70 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "服务器异常") | ||
71 | + } | ||
72 | + cmd.BatchNumber = code | ||
73 | + } | ||
74 | + | ||
62 | newProductPlan := &domain.ProductPlan{ | 75 | newProductPlan := &domain.ProductPlan{ |
63 | CompanyId: cmd.CompanyId, | 76 | CompanyId: cmd.CompanyId, |
64 | OrgId: cmd.OrgId, | 77 | OrgId: cmd.OrgId, |
@@ -84,8 +97,10 @@ func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.Cre | @@ -84,8 +97,10 @@ func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.Cre | ||
84 | ProductCode: product.ProductCode, | 97 | ProductCode: product.ProductCode, |
85 | ProductName: product.ProductName, | 98 | ProductName: product.ProductName, |
86 | //ProductSpec: product.ProductSpec, | 99 | //ProductSpec: product.ProductSpec, |
100 | + DevotedUnit: cmd.DevotedUnit, | ||
87 | }), | 101 | }), |
88 | } | 102 | } |
103 | + | ||
89 | if cmd.Weight > 0 { | 104 | if cmd.Weight > 0 { |
90 | newProductPlan.PlanDevoted.Weight = cmd.Weight | 105 | newProductPlan.PlanDevoted.Weight = cmd.Weight |
91 | } | 106 | } |
@@ -259,7 +274,7 @@ func (productPlanService *ProductPlanService) UpdateProductPlan(cmd *command.Upd | @@ -259,7 +274,7 @@ func (productPlanService *ProductPlanService) UpdateProductPlan(cmd *command.Upd | ||
259 | ProductId: product.ProductId, | 274 | ProductId: product.ProductId, |
260 | ProductCode: product.ProductCode, | 275 | ProductCode: product.ProductCode, |
261 | ProductName: product.ProductName, | 276 | ProductName: product.ProductName, |
262 | - //ProductSpec: product.ProductSpec, | 277 | + DevotedUnit: cmd.DevotedUnit, |
263 | }) | 278 | }) |
264 | productPlan.PlanDevoted.UnitWeight = product.ProductSpec.UnitWeight | 279 | productPlan.PlanDevoted.UnitWeight = product.ProductSpec.UnitWeight |
265 | cmd.PlanProductName = product.ProductName | 280 | cmd.PlanProductName = product.ProductName |
@@ -339,9 +354,9 @@ func (productPlanService *ProductPlanService) SetOffline(setOfflineCommand *comm | @@ -339,9 +354,9 @@ func (productPlanService *ProductPlanService) SetOffline(setOfflineCommand *comm | ||
339 | transactionContext.RollbackTransaction() | 354 | transactionContext.RollbackTransaction() |
340 | }() | 355 | }() |
341 | 356 | ||
342 | - var productPlanRepository domain.ProductPlanRepository | ||
343 | - var productPlan *domain.ProductPlan | ||
344 | - productPlanRepository, productPlan, _ = factory.FastPgProductPlan(transactionContext, setOfflineCommand.ProductPlanId) | 357 | + var productPlanRepository domain.ProductPlanDispatchRecordRepository |
358 | + var productPlan *domain.ProductPlanDispatchRecord | ||
359 | + productPlanRepository, productPlan, _ = factory.FastPgProductPlanDispatchRecord(transactionContext, setOfflineCommand.ProductPlanId) | ||
345 | 360 | ||
346 | if err = productPlan.ChangeStatus(domain.PlanOffline); err != nil { | 361 | if err = productPlan.ChangeStatus(domain.PlanOffline); err != nil { |
347 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 362 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -372,45 +387,33 @@ func (productPlanService *ProductPlanService) SetOnline(cmd *command.SetOnlineCo | @@ -372,45 +387,33 @@ func (productPlanService *ProductPlanService) SetOnline(cmd *command.SetOnlineCo | ||
372 | defer func() { | 387 | defer func() { |
373 | transactionContext.RollbackTransaction() | 388 | transactionContext.RollbackTransaction() |
374 | }() | 389 | }() |
375 | - var productPlanRepository domain.ProductPlanRepository | ||
376 | - var productPlan *domain.ProductPlan | ||
377 | 390 | ||
378 | - productPlanRepository, productPlan, err = factory.FastPgProductPlan(transactionContext, cmd.ProductPlanId) | ||
379 | - if err != nil { | ||
380 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
381 | - } | ||
382 | - | ||
383 | - if err = productPlan.ChangeStatus(domain.PlanOnline); err != nil { | ||
384 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
385 | - } | ||
386 | - | ||
387 | - var workshop *domain.Workshop | ||
388 | - _, workshop, err = factory.FastPgWorkshop(transactionContext, cmd.WorkshopId) | ||
389 | - if err != nil { | ||
390 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
391 | - } | 391 | + var productPlan *domain.ProductPlan |
392 | 392 | ||
393 | - line, section, err := workshop.FindSectionById(cmd.SectionId) | 393 | + _, productPlan, err = factory.FastPgProductPlan(transactionContext, cmd.ProductPlanId) |
394 | if err != nil { | 394 | if err != nil { |
395 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 395 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
396 | } | 396 | } |
397 | 397 | ||
398 | + cmd.WorkshopId = productPlan.Workshop.WorkshopId | ||
398 | var workStation *domain.WorkStation | 399 | var workStation *domain.WorkStation |
399 | - workStation, err = workshop.FindWorkStation(workshop.WorkshopId, line.LineId, section.SectionId) | 400 | + _, workStation, err = factory.FastPgWorkstation(transactionContext, cmd.WorkshopId, cmd.LineId, cmd.SectionId) |
400 | if err != nil { | 401 | if err != nil { |
401 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 402 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
402 | } | 403 | } |
403 | 404 | ||
404 | - productPlan.WorkStation = workStation | 405 | + var productPlanDispatch *domain.ProductPlanDispatchRecord |
406 | + productPlanDispatch = domain.NewProductPlanDispatchRecord(productPlan, workStation) | ||
405 | 407 | ||
406 | - if productPlan, err = productPlanRepository.Save(productPlan); err != nil { | 408 | + var productPlanDispatchRepository, _, _ = factory.FastPgProductPlanDispatchRecord(transactionContext, 0) |
409 | + if productPlanDispatch, err = productPlanDispatchRepository.Save(productPlanDispatch); err != nil { | ||
407 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 410 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
408 | } | 411 | } |
409 | 412 | ||
410 | if err := transactionContext.CommitTransaction(); err != nil { | 413 | if err := transactionContext.CommitTransaction(); err != nil { |
411 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 414 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
412 | } | 415 | } |
413 | - return productPlan, nil | 416 | + return productPlanDispatch, nil |
414 | } | 417 | } |
415 | 418 | ||
416 | // 换单 | 419 | // 换单 |
@@ -428,9 +431,10 @@ func (productPlanService *ProductPlanService) Exchange(switchCommand *command.Sw | @@ -428,9 +431,10 @@ func (productPlanService *ProductPlanService) Exchange(switchCommand *command.Sw | ||
428 | defer func() { | 431 | defer func() { |
429 | transactionContext.RollbackTransaction() | 432 | transactionContext.RollbackTransaction() |
430 | }() | 433 | }() |
431 | - var fromPlan, toPlan *domain.ProductPlan | ||
432 | - var productPlanRepository domain.ProductPlanRepository | ||
433 | - productPlanRepository, fromPlan, err = factory.FastPgProductPlan(transactionContext, switchCommand.FromProductPlanId) | 434 | + var fromPlan *domain.ProductPlanDispatchRecord |
435 | + var toPlan *domain.ProductPlan | ||
436 | + var productPlanDispatchRecordRepository domain.ProductPlanDispatchRecordRepository | ||
437 | + productPlanDispatchRecordRepository, fromPlan, err = factory.FastPgProductPlanDispatchRecord(transactionContext, switchCommand.FromProductPlanDispatchRecordId) | ||
434 | if err != nil { | 438 | if err != nil { |
435 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 439 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
436 | } | 440 | } |
@@ -443,22 +447,18 @@ func (productPlanService *ProductPlanService) Exchange(switchCommand *command.Sw | @@ -443,22 +447,18 @@ func (productPlanService *ProductPlanService) Exchange(switchCommand *command.Sw | ||
443 | if err = fromPlan.ChangeStatus(domain.PlanOffline); err != nil { | 447 | if err = fromPlan.ChangeStatus(domain.PlanOffline); err != nil { |
444 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 448 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
445 | } | 449 | } |
446 | - if _, err = productPlanRepository.Save(fromPlan); err != nil { | ||
447 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
448 | - } | ||
449 | 450 | ||
450 | - var workStation *domain.WorkStation | ||
451 | - fromWorkStation := fromPlan.WorkStation | ||
452 | - _, workStation, err = factory.FastPgWorkstation(transactionContext, fromWorkStation.WorkshopId, fromWorkStation.LineId, fromWorkStation.SectionId) | ||
453 | - if err != nil { | ||
454 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 451 | + // 新的上线、如果存在一条同一个批次、工段的调度记录 则不做更新 |
452 | + if fromPlan.PlanDispatchRecordExt.ProductPlanId == toPlan.ProductPlanId && fromPlan.ProductDate == toPlan.ProductDate { | ||
453 | + log.Logger.Info("换单的批次与当前批次一致,跳过") | ||
454 | + return struct{}{}, nil | ||
455 | } | 455 | } |
456 | - // 计划上线 | ||
457 | - toPlan.WorkStation = workStation | ||
458 | - if err = toPlan.ChangeStatus(domain.PlanOnline); err != nil { | 456 | + |
457 | + if _, err = productPlanDispatchRecordRepository.Save(fromPlan); err != nil { | ||
459 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 458 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
460 | } | 459 | } |
461 | - if _, err = productPlanRepository.Save(toPlan); err != nil { | 460 | + toProductPlanDispatchRecord := domain.NewProductPlanDispatchRecord(toPlan, fromPlan.WorkStation) |
461 | + if _, err = productPlanDispatchRecordRepository.Save(toProductPlanDispatchRecord); err != nil { | ||
462 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 462 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
463 | } | 463 | } |
464 | 464 | ||
@@ -483,10 +483,17 @@ func (productPlanService *ProductPlanService) ReceiveMaterial(receiveMaterialCom | @@ -483,10 +483,17 @@ func (productPlanService *ProductPlanService) ReceiveMaterial(receiveMaterialCom | ||
483 | defer func() { | 483 | defer func() { |
484 | transactionContext.RollbackTransaction() | 484 | transactionContext.RollbackTransaction() |
485 | }() | 485 | }() |
486 | + | ||
487 | + productRecordService, _ := domainService.NewPGProductRecordService(transactionContext.(*pg.TransactionContext)) | ||
488 | + | ||
489 | + _, err = productRecordService.SubmitProductRecord(domain.RecordTypeReceiveMaterial, tool_funs.SimpleStructToMap(receiveMaterialCommand)) | ||
490 | + if err != nil { | ||
491 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
492 | + } | ||
486 | if err := transactionContext.CommitTransaction(); err != nil { | 493 | if err := transactionContext.CommitTransaction(); err != nil { |
487 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 494 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
488 | } | 495 | } |
489 | - return nil, nil | 496 | + return struct{}{}, nil |
490 | } | 497 | } |
491 | 498 | ||
492 | // 退料 | 499 | // 退料 |
@@ -504,10 +511,18 @@ func (productPlanService *ProductPlanService) ReturnMaterial(returnMaterialComma | @@ -504,10 +511,18 @@ func (productPlanService *ProductPlanService) ReturnMaterial(returnMaterialComma | ||
504 | defer func() { | 511 | defer func() { |
505 | transactionContext.RollbackTransaction() | 512 | transactionContext.RollbackTransaction() |
506 | }() | 513 | }() |
514 | + | ||
515 | + productRecordService, _ := domainService.NewPGProductRecordService(transactionContext.(*pg.TransactionContext)) | ||
516 | + | ||
517 | + _, err = productRecordService.SubmitProductRecord(domain.RecordTypeReturnMaterial, tool_funs.SimpleStructToMap(returnMaterialCommand)) | ||
518 | + if err != nil { | ||
519 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
520 | + } | ||
521 | + | ||
507 | if err := transactionContext.CommitTransaction(); err != nil { | 522 | if err := transactionContext.CommitTransaction(); err != nil { |
508 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 523 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
509 | } | 524 | } |
510 | - return nil, nil | 525 | + return struct{}{}, nil |
511 | } | 526 | } |
512 | 527 | ||
513 | // 提交成品记录 (成品 二级品) | 528 | // 提交成品记录 (成品 二级品) |
@@ -525,10 +540,59 @@ func (productPlanService *ProductPlanService) SubmitProductRecord(submitProductR | @@ -525,10 +540,59 @@ func (productPlanService *ProductPlanService) SubmitProductRecord(submitProductR | ||
525 | defer func() { | 540 | defer func() { |
526 | transactionContext.RollbackTransaction() | 541 | transactionContext.RollbackTransaction() |
527 | }() | 542 | }() |
543 | + | ||
544 | + productRecordService, _ := domainService.NewPGProductRecordService(transactionContext.(*pg.TransactionContext)) | ||
545 | + | ||
546 | + _, err = productRecordService.SubmitProductRecord(domain.RecordTypeSecondLevelWeigh, tool_funs.SimpleStructToMap(submitProductRecordCommand)) | ||
547 | + if err != nil { | ||
548 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
549 | + } | ||
528 | if err := transactionContext.CommitTransaction(); err != nil { | 550 | if err := transactionContext.CommitTransaction(); err != nil { |
529 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 551 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
530 | } | 552 | } |
531 | - return nil, nil | 553 | + return struct{}{}, nil |
554 | +} | ||
555 | + | ||
556 | +// 搜索生产上线计划记录 | ||
557 | +func (productPlanService *ProductPlanService) SearchProductPlanOnlineDispatchRecord(operateInfo *domain.OperateInfo, cmd *query.SearchProductPlanQuery) (int64, interface{}, error) { | ||
558 | + if err := cmd.ValidateQuery(); err != nil { | ||
559 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
560 | + } | ||
561 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
562 | + if err != nil { | ||
563 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
564 | + } | ||
565 | + if err := transactionContext.StartTransaction(); err != nil { | ||
566 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
567 | + } | ||
568 | + defer func() { | ||
569 | + transactionContext.RollbackTransaction() | ||
570 | + }() | ||
571 | + var productPlanRepository domain.ProductPlanDispatchRecordRepository | ||
572 | + if value, err := factory.CreateProductPlanDispatchRecordRepository(map[string]interface{}{ | ||
573 | + "transactionContext": transactionContext, | ||
574 | + }); err != nil { | ||
575 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
576 | + } else { | ||
577 | + productPlanRepository = value | ||
578 | + } | ||
579 | + queryOptions := utils.ObjectToMap(cmd) | ||
580 | + queryOptions["planDispatchStatus"] = 1 | ||
581 | + count, productPlans, err := productPlanRepository.Find(queryOptions) | ||
582 | + if err != nil { | ||
583 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
584 | + } | ||
585 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
586 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
587 | + } | ||
588 | + var result = make([]*dto.ProductPlanDispatchRecordDto, 0) | ||
589 | + for i := range productPlans { | ||
590 | + item := productPlans[i] | ||
591 | + newItem := &dto.ProductPlanDispatchRecordDto{} | ||
592 | + newItem.LoadDto(item, operateInfo.OrgId) | ||
593 | + result = append(result, newItem) | ||
594 | + } | ||
595 | + return count, result, nil | ||
532 | } | 596 | } |
533 | 597 | ||
534 | func NewProductPlanService(options map[string]interface{}) *ProductPlanService { | 598 | func NewProductPlanService(options map[string]interface{}) *ProductPlanService { |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type ApproveProductRecordCommand struct { | ||
12 | + // 生产记录ID | ||
13 | + ProductRecordId int `cname:"生产记录ID" json:"productRecordId" valid:"Required"` | ||
14 | + // 审核人 | ||
15 | + ApproveUserId int `cname:"审核人" json:"approveUserId" valid:"Required"` | ||
16 | + // 审核后重量 | ||
17 | + WeighAfter float64 `cname:"审核后重量" json:"weighAfter" valid:"Required"` | ||
18 | + // 审核时间 | ||
19 | + //ApproveAt string `cname:"审核时间" json:"approveAt" valid:"Required"` | ||
20 | +} | ||
21 | + | ||
22 | +func (approveProductRecordCommand *ApproveProductRecordCommand) Valid(validation *validation.Validation) { | ||
23 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
24 | +} | ||
25 | + | ||
26 | +func (approveProductRecordCommand *ApproveProductRecordCommand) ValidateCommand() error { | ||
27 | + valid := validation.Validation{} | ||
28 | + b, err := valid.Valid(approveProductRecordCommand) | ||
29 | + if err != nil { | ||
30 | + return err | ||
31 | + } | ||
32 | + if !b { | ||
33 | + elem := reflect.TypeOf(approveProductRecordCommand).Elem() | ||
34 | + for _, validErr := range valid.Errors { | ||
35 | + field, isExist := elem.FieldByName(validErr.Field) | ||
36 | + if isExist { | ||
37 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
38 | + } else { | ||
39 | + return fmt.Errorf(validErr.Message) | ||
40 | + } | ||
41 | + } | ||
42 | + } | ||
43 | + return nil | ||
44 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type CreateProductRecordCommand struct { | ||
12 | + // 生产记录ID | ||
13 | + ProductRecordId int `cname:"生产记录ID" json:"productRecordId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (createProductRecordCommand *CreateProductRecordCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (createProductRecordCommand *CreateProductRecordCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(createProductRecordCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(createProductRecordCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | +) | ||
10 | + | ||
11 | +type ProductRecordStaticsCommand struct { | ||
12 | + *domain.ProductRecord | ||
13 | +} | ||
14 | + | ||
15 | +// Type is a string value that indicates the type of the task. | ||
16 | +//func (t *ProductRecordStaticsCommand) Type() string | ||
17 | + | ||
18 | +// Payload is the data needed for task execution. | ||
19 | +//func (t *ProductRecordStaticsCommand) Payload() []byte | ||
20 | + | ||
21 | +func (removeProductRecordCommand *ProductRecordStaticsCommand) Valid(validation *validation.Validation) { | ||
22 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
23 | +} | ||
24 | + | ||
25 | +func (removeProductRecordCommand *ProductRecordStaticsCommand) ValidateCommand() error { | ||
26 | + valid := validation.Validation{} | ||
27 | + b, err := valid.Valid(removeProductRecordCommand) | ||
28 | + if err != nil { | ||
29 | + return err | ||
30 | + } | ||
31 | + if !b { | ||
32 | + elem := reflect.TypeOf(removeProductRecordCommand).Elem() | ||
33 | + for _, validErr := range valid.Errors { | ||
34 | + field, isExist := elem.FieldByName(validErr.Field) | ||
35 | + if isExist { | ||
36 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
37 | + } else { | ||
38 | + return fmt.Errorf(validErr.Message) | ||
39 | + } | ||
40 | + } | ||
41 | + } | ||
42 | + return nil | ||
43 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type RemoveProductRecordCommand struct { | ||
12 | + // 生产记录ID | ||
13 | + ProductRecordId int `cname:"生产记录ID" json:"productRecordId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (removeProductRecordCommand *RemoveProductRecordCommand) Valid(validation *validation.Validation) { | ||
17 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (removeProductRecordCommand *RemoveProductRecordCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(removeProductRecordCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(removeProductRecordCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type UpdateProductRecordCommand struct { | ||
12 | + // 生产记录ID | ||
13 | + ProductRecordId int `cname:"生产记录ID" json:"productRecordId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (updateProductRecordCommand *UpdateProductRecordCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (updateProductRecordCommand *UpdateProductRecordCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(updateProductRecordCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(updateProductRecordCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package dto | ||
2 | + | ||
3 | +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
4 | + | ||
5 | +type EmployeeProductRecordDto struct { | ||
6 | + // 员工产能记录ID | ||
7 | + EmployeeProductRecordId int `json:"productRecordId"` | ||
8 | + // 生产工人 | ||
9 | + ProductWorker *domain.User `json:"productWorker,omitempty"` | ||
10 | + *domain.WorkStation | ||
11 | + // 上班班次 1:全天 2:白班 4:中班 8:夜班 | ||
12 | + WorkOn int `json:"workOn"` | ||
13 | + // 生产日期 | ||
14 | + //ProductDate string `json:"productDate"` | ||
15 | + // 计划的产品名称 | ||
16 | + PlanProductName string `json:"planProductName,omitempty"` | ||
17 | + // 批号 | ||
18 | + BatchNumber string `json:"batchNumber,omitempty"` | ||
19 | + // 参与类型 1:正常 2:支援 | ||
20 | + ParticipateType int `json:"participateType"` | ||
21 | + // 产能 | ||
22 | + ProductWeigh float64 `json:"productWeigh"` | ||
23 | + // 二级品产能 | ||
24 | + SecondLevelWeigh float64 `json:"secondLevelWeigh"` | ||
25 | + // 创建时间 | ||
26 | + CreatedAt string `json:"createdAt,omitempty"` | ||
27 | + // 组织名称 | ||
28 | + OrgName string `json:"orgName"` | ||
29 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
30 | + AuthFlag bool `json:"authFlag"` | ||
31 | + // 合格率 百分比 | ||
32 | + QualificationRate int `json:"qualificationRate"` | ||
33 | + // 考勤类型 1.正常 2.支援 | ||
34 | + ParticipateTypeDescription string `json:"participateTypeDescription"` | ||
35 | + // 员工类型描述 1:固定 2:派遣 3.临时 | ||
36 | + EmployeeTypeDescription string `json:"employeeTypeDescription"` | ||
37 | + // 上班班次 1:全天 2:白班 4:中班 8:夜班 | ||
38 | + WorkOnDescription string `json:"workOnDescription,omitempty"` | ||
39 | +} | ||
40 | + | ||
41 | +func (d *EmployeeProductRecordDto) LoadDto(m *domain.EmployeeProductRecord, orgId int) *EmployeeProductRecordDto { | ||
42 | + d.EmployeeProductRecordId = m.EmployeeProductRecordId | ||
43 | + d.ProductWorker = m.ProductWorker | ||
44 | + d.WorkStation = m.WorkStation | ||
45 | + d.WorkOn = m.WorkOn | ||
46 | + | ||
47 | + d.PlanProductName = m.ProductRecordInfo.PlanProductName | ||
48 | + d.BatchNumber = m.ProductRecordInfo.BatchNumber | ||
49 | + d.ParticipateType = m.ParticipateType | ||
50 | + d.ProductWeigh = m.RealProductWeigh() | ||
51 | + d.SecondLevelWeigh = m.SecondLevelWeigh | ||
52 | + d.QualificationRate = m.QualificationRate() | ||
53 | + d.CreatedAt = m.CreatedAt.Format("2006-01-02") | ||
54 | + d.ParticipateTypeDescription = domain.ParticipateTypeDescription(m.ParticipateType) | ||
55 | + d.EmployeeTypeDescription = domain.EmployeeTypeDescription(m.ProductWorker.EmployeeType) | ||
56 | + d.WorkOnDescription = domain.WorkOnDescriptions(m.WorkOn) | ||
57 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
58 | + if m.Ext != nil { | ||
59 | + d.OrgName = m.Ext.OrgName | ||
60 | + } | ||
61 | + return d | ||
62 | +} |
1 | +package dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | + "time" | ||
6 | +) | ||
7 | + | ||
8 | +// 二级品记录 | ||
9 | +type ProductLevelTwoRecord struct { | ||
10 | + // 生产记录ID | ||
11 | + ProductRecordId int `json:"productRecordId,omitempty"` | ||
12 | + // 生产工人 | ||
13 | + ProductWorker *domain.User `json:"productWorker,omitempty"` | ||
14 | + *domain.WorkStation | ||
15 | + // 上班班次 1:全天 2:白班 4:中班 8:夜班 | ||
16 | + WorkOn int `json:"workOn"` | ||
17 | + // 产能 - 审核前 | ||
18 | + WeighBefore float64 `json:"weighBefore"` | ||
19 | + // 产能-审核后 | ||
20 | + WeighAfter float64 `json:"weighAfter"` | ||
21 | + // 审核状态 1:未审核 2:已审核 | ||
22 | + ApproveStatus int `json:"approveStatus"` | ||
23 | + // 审核人 | ||
24 | + ApproveUser *domain.User `json:"approveUser"` | ||
25 | + // 审核时间 | ||
26 | + ApproveAt string `json:"approveAt"` | ||
27 | + // 计划的产品名称 | ||
28 | + PlanProductName string `json:"planProductName,omitempty"` | ||
29 | + // 批号 | ||
30 | + BatchNumber string `json:"batchNumber,omitempty"` | ||
31 | + | ||
32 | + // 创建日期 | ||
33 | + CreatedDate string `json:"createdDate,omitempty"` | ||
34 | + // 创建时间 | ||
35 | + CreatedAt string `json:"createdAt,omitempty"` | ||
36 | + // 组织名称 | ||
37 | + OrgName string `json:"orgName"` | ||
38 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
39 | + AuthFlag bool `json:"authFlag"` | ||
40 | +} | ||
41 | + | ||
42 | +func (d *ProductLevelTwoRecord) LoadDto(m *domain.ProductRecord, orgId int) *ProductLevelTwoRecord { | ||
43 | + d.ProductRecordId = m.ProductRecordId | ||
44 | + d.ProductWorker = m.ProductWorker | ||
45 | + d.WorkStation = m.WorkStation | ||
46 | + d.WeighBefore = m.ProductRecordInfo.WeighBefore | ||
47 | + d.WeighAfter = m.ProductRecordInfo.WeighAfter | ||
48 | + d.ApproveStatus = m.ProductRecordInfo.ApproveStatus | ||
49 | + if m.ProductRecordInfo.ApproveAt > 0 { | ||
50 | + d.ApproveAt = time.Unix(m.ProductRecordInfo.ApproveAt, 0).Format("2006-01-02 15:04:05") | ||
51 | + d.ApproveUser = m.ProductRecordInfo.ApproveUser | ||
52 | + } | ||
53 | + d.PlanProductName = m.ProductRecordInfo.PlanProductName | ||
54 | + d.BatchNumber = m.ProductRecordInfo.BatchNumber | ||
55 | + d.CreatedDate = m.CreatedAt.Format("2006-01-02") | ||
56 | + d.CreatedAt = m.CreatedAt.Format("2006-01-02 15:04:05") | ||
57 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
58 | + if m.Ext != nil { | ||
59 | + d.OrgName = m.Ext.OrgName | ||
60 | + } | ||
61 | + return d | ||
62 | +} |
1 | +package dto | ||
2 | + | ||
3 | +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
4 | + | ||
5 | +type WorkshopProductRecordDto struct { | ||
6 | + // 员工产能记录ID | ||
7 | + WorkshopProductRecordId int `json:"productRecordId"` | ||
8 | + // 生产工人 | ||
9 | + //ProductWorker *domain.User `json:"productWorker,omitempty"` | ||
10 | + *domain.WorkStation | ||
11 | + // 生产日期 | ||
12 | + //ProductDate string `json:"productDate"` | ||
13 | + // 计划的产品名称 | ||
14 | + PlanProductName string `json:"planProductName,omitempty"` | ||
15 | + // 批号 | ||
16 | + BatchNumber string `json:"batchNumber,omitempty"` | ||
17 | + // 参与类型 1:正常 2:支援 | ||
18 | + //ParticipateType int `json:"participateType"` | ||
19 | + // 投入量 | ||
20 | + DevotedProductWeigh float64 `json:"devotedProductWeigh"` | ||
21 | + // 产能 | ||
22 | + ProductWeigh float64 `json:"productWeigh"` | ||
23 | + // 二级品产能 | ||
24 | + SecondLevelWeigh float64 `json:"secondLevelWeigh"` | ||
25 | + // 创建时间 | ||
26 | + CreatedAt string `json:"createdAt,omitempty"` | ||
27 | + // 组织名称 | ||
28 | + OrgName string `json:"orgName"` | ||
29 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
30 | + AuthFlag bool `json:"authFlag"` | ||
31 | + // 合格率 百分比 | ||
32 | + QualificationRate int `json:"qualificationRate"` | ||
33 | +} | ||
34 | + | ||
35 | +func (d *WorkshopProductRecordDto) LoadDto(m *domain.WorkshopProductRecord, orgId int) *WorkshopProductRecordDto { | ||
36 | + d.WorkshopProductRecordId = m.WorkshopProductRecordId | ||
37 | + //d.ProductWorker = m.ProductWorker | ||
38 | + d.WorkStation = m.WorkStation | ||
39 | + d.PlanProductName = m.ProductRecordInfo.PlanProductName | ||
40 | + d.BatchNumber = m.ProductRecordInfo.BatchNumber | ||
41 | + //d.ParticipateType = m.ParticipateType | ||
42 | + d.DevotedProductWeigh = m.DevotedProductWeigh() | ||
43 | + d.ProductWeigh = m.RealProductWeigh() | ||
44 | + d.SecondLevelWeigh = m.SecondLevelWeigh | ||
45 | + d.QualificationRate = m.QualificationRate() | ||
46 | + d.CreatedAt = m.ProductDate | ||
47 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
48 | + if m.Ext != nil { | ||
49 | + d.OrgName = m.Ext.OrgName | ||
50 | + } | ||
51 | + return d | ||
52 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type GetProductRecordQuery struct { | ||
12 | + // 生产记录ID | ||
13 | + ProductRecordId int `cname:"生产记录ID" json:"productRecordId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (getProductRecordQuery *GetProductRecordQuery) Valid(validation *validation.Validation) { | ||
17 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (getProductRecordQuery *GetProductRecordQuery) ValidateQuery() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(getProductRecordQuery) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(getProductRecordQuery).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type ListProductRecordQuery struct { | ||
12 | + // 查询偏离量 | ||
13 | + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | ||
14 | + // 查询限制 | ||
15 | + Limit int `cname:"查询限制" json:"limit" valid:"Required"` | ||
16 | +} | ||
17 | + | ||
18 | +func (listProductRecordQuery *ListProductRecordQuery) Valid(validation *validation.Validation) { | ||
19 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
20 | +} | ||
21 | + | ||
22 | +func (listProductRecordQuery *ListProductRecordQuery) ValidateQuery() error { | ||
23 | + valid := validation.Validation{} | ||
24 | + b, err := valid.Valid(listProductRecordQuery) | ||
25 | + if err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + if !b { | ||
29 | + elem := reflect.TypeOf(listProductRecordQuery).Elem() | ||
30 | + for _, validErr := range valid.Errors { | ||
31 | + field, isExist := elem.FieldByName(validErr.Field) | ||
32 | + if isExist { | ||
33 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
34 | + } else { | ||
35 | + return fmt.Errorf(validErr.Message) | ||
36 | + } | ||
37 | + } | ||
38 | + } | ||
39 | + return nil | ||
40 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | + "time" | ||
10 | + | ||
11 | + "github.com/beego/beego/v2/core/validation" | ||
12 | +) | ||
13 | + | ||
14 | +type SearchEmployeeProductRecordQuery struct { | ||
15 | + // 查询偏离量 | ||
16 | + Offset int `cname:"查询偏离量" json:"offset"` | ||
17 | + // 查询限制 | ||
18 | + Limit int `cname:"查询限制" json:"limit"` | ||
19 | + // 当前公司 | ||
20 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
21 | + // 当前登录的组织 | ||
22 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"` | ||
23 | + // 匹配多个组织 | ||
24 | + InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty"` | ||
25 | + // 页码 | ||
26 | + PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | ||
27 | + // 页数 | ||
28 | + PageSize int `cname:"页数" json:"pageSize,omitempty"` | ||
29 | + // 车间名称 | ||
30 | + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"` | ||
31 | + // 生产线名称 | ||
32 | + LineName string `cname:"生产线名称" json:"lineName,omitempty"` | ||
33 | + // 工段名称 | ||
34 | + SectionName string `cname:"工段名称" json:"sectionName,omitempty"` | ||
35 | + // 姓名 | ||
36 | + UserName string `cname:"姓名" json:"userName"` | ||
37 | + // 员工类型 1:固定 2:派遣 3.临时 | ||
38 | + EmployeeType int `cname:"员工类型 1:固定 2:派遣 3.临时" json:"employeeType"` | ||
39 | + // 开始时间 | ||
40 | + BeginTime string `cname:"开始时间" json:"beginTime"` | ||
41 | + // 结束时间 | ||
42 | + EndTime string `cname:"结束时间" json:"endTime"` | ||
43 | + | ||
44 | + // 开始时间 | ||
45 | + ProductBeginTime time.Time `cname:"开始时间" json:"productBeginTime"` | ||
46 | + // 结束时间 | ||
47 | + ProductEndTime time.Time `cname:"结束时间" json:"productEndTime"` | ||
48 | +} | ||
49 | + | ||
50 | +func (cmd *SearchEmployeeProductRecordQuery) Valid(validation *validation.Validation) { | ||
51 | + cmd.Offset, cmd.Limit = domain.Pagination(cmd.PageNumber, cmd.PageSize) | ||
52 | + var err error | ||
53 | + if len(cmd.BeginTime) > 0 { | ||
54 | + if cmd.ProductBeginTime, err = time.Parse("2006-01-02 15:04:05", cmd.BeginTime); err != nil { | ||
55 | + log.Logger.Error(err.Error()) | ||
56 | + validation.Error("开始时间有误") | ||
57 | + return | ||
58 | + } | ||
59 | + } | ||
60 | + if len(cmd.EndTime) > 0 { | ||
61 | + if cmd.ProductEndTime, err = time.Parse("2006-01-02 15:04:05", cmd.EndTime); err != nil { | ||
62 | + log.Logger.Error(err.Error()) | ||
63 | + validation.Error("结束时间有误") | ||
64 | + return | ||
65 | + } | ||
66 | + } | ||
67 | +} | ||
68 | + | ||
69 | +func (cmd *SearchEmployeeProductRecordQuery) ValidateQuery() error { | ||
70 | + valid := validation.Validation{} | ||
71 | + b, err := valid.Valid(cmd) | ||
72 | + if err != nil { | ||
73 | + return err | ||
74 | + } | ||
75 | + if !b { | ||
76 | + elem := reflect.TypeOf(cmd).Elem() | ||
77 | + for _, validErr := range valid.Errors { | ||
78 | + field, isExist := elem.FieldByName(validErr.Field) | ||
79 | + if isExist { | ||
80 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
81 | + } else { | ||
82 | + return fmt.Errorf(validErr.Message) | ||
83 | + } | ||
84 | + } | ||
85 | + } | ||
86 | + return nil | ||
87 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | + "time" | ||
10 | + | ||
11 | + "github.com/beego/beego/v2/core/validation" | ||
12 | +) | ||
13 | + | ||
14 | +type SearchProductRecordQuery struct { | ||
15 | + // 查询偏离量 | ||
16 | + Offset int `cname:"查询偏离量" json:"offset"` | ||
17 | + // 查询限制 | ||
18 | + Limit int `cname:"查询限制" json:"limit"` | ||
19 | + // 当前公司 | ||
20 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
21 | + // 当前登录的组织 | ||
22 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"` | ||
23 | + // 匹配多个组织 | ||
24 | + InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty"` | ||
25 | + // 页码 | ||
26 | + PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | ||
27 | + // 页数 | ||
28 | + PageSize int `cname:"页数" json:"pageSize,omitempty"` | ||
29 | + // 车间名称 | ||
30 | + WorkshopName string `cname:"车间名称" json:"workshopName"` | ||
31 | + // 批号 | ||
32 | + BatchNumber string `cname:"批号" json:"batchNumber"` | ||
33 | + // 姓名 | ||
34 | + UserName string `cname:"姓名" json:"userName"` | ||
35 | + // 生产记录类型:1:领料 2:退料 4:称重 8:二级品称重 | ||
36 | + ProductRecordType int `cname:"生产记录类型:1:领料 2:退料 4:称重 8:二级品称重"` | ||
37 | + // 生产线名称 | ||
38 | + LineName string `cname:"生产线名称" json:"lineName,omitempty"` | ||
39 | + // 工段名称 | ||
40 | + SectionName string `cname:"工段名称" json:"sectionName,omitempty"` | ||
41 | + // 员工类型 1:固定 2:派遣 3.临时 | ||
42 | + EmployeeType int `cname:"员工类型 1:固定 2:派遣 3.临时" json:"employeeType"` | ||
43 | + // 开始时间 | ||
44 | + BeginTime string `cname:"开始时间" json:"beginTime"` | ||
45 | + // 结束时间 | ||
46 | + EndTime string `cname:"结束时间" json:"endTime"` | ||
47 | + | ||
48 | + // 开始时间 | ||
49 | + ProductBeginTime time.Time `cname:"开始时间" json:"productBeginTime"` | ||
50 | + // 结束时间 | ||
51 | + ProductEndTime time.Time `cname:"结束时间" json:"productEndTime"` | ||
52 | +} | ||
53 | + | ||
54 | +func (cmd *SearchProductRecordQuery) Valid(validation *validation.Validation) { | ||
55 | + cmd.Offset, cmd.Limit = domain.Pagination(cmd.PageNumber, cmd.PageSize) | ||
56 | + | ||
57 | + var err error | ||
58 | + if len(cmd.BeginTime) > 0 { | ||
59 | + if cmd.ProductBeginTime, err = time.Parse("2006-01-02 15:04:05", cmd.BeginTime); err != nil { | ||
60 | + log.Logger.Error(err.Error()) | ||
61 | + validation.Error("开始时间有误") | ||
62 | + return | ||
63 | + } | ||
64 | + } | ||
65 | + if len(cmd.EndTime) > 0 { | ||
66 | + if cmd.ProductEndTime, err = time.Parse("2006-01-02 15:04:05", cmd.EndTime); err != nil { | ||
67 | + log.Logger.Error(err.Error()) | ||
68 | + validation.Error("结束时间有误") | ||
69 | + return | ||
70 | + } | ||
71 | + } | ||
72 | +} | ||
73 | + | ||
74 | +func (cmd *SearchProductRecordQuery) ValidateQuery() error { | ||
75 | + valid := validation.Validation{} | ||
76 | + b, err := valid.Valid(cmd) | ||
77 | + if err != nil { | ||
78 | + return err | ||
79 | + } | ||
80 | + if !b { | ||
81 | + elem := reflect.TypeOf(cmd).Elem() | ||
82 | + for _, validErr := range valid.Errors { | ||
83 | + field, isExist := elem.FieldByName(validErr.Field) | ||
84 | + if isExist { | ||
85 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
86 | + } else { | ||
87 | + return fmt.Errorf(validErr.Message) | ||
88 | + } | ||
89 | + } | ||
90 | + } | ||
91 | + return nil | ||
92 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | + "time" | ||
10 | + | ||
11 | + "github.com/beego/beego/v2/core/validation" | ||
12 | +) | ||
13 | + | ||
14 | +type SearchWorkshopProductRecordQuery struct { | ||
15 | + // 查询偏离量 | ||
16 | + Offset int `cname:"查询偏离量" json:"offset"` | ||
17 | + // 查询限制 | ||
18 | + Limit int `cname:"查询限制" json:"limit"` | ||
19 | + // 当前公司 | ||
20 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
21 | + // 当前登录的组织 | ||
22 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"` | ||
23 | + // 匹配多个组织 | ||
24 | + InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty"` | ||
25 | + // 页码 | ||
26 | + PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | ||
27 | + // 页数 | ||
28 | + PageSize int `cname:"页数" json:"pageSize,omitempty"` | ||
29 | + // 品名 | ||
30 | + PlanProductName string `cname:"品名" json:"planProductName,omitempty"` | ||
31 | + // 工段名称 | ||
32 | + SectionName string `cname:"工段名称" json:"sectionName,omitempty"` | ||
33 | + // 开始时间 | ||
34 | + BeginTime string `cname:"开始时间" json:"beginTime"` | ||
35 | + // 结束时间 | ||
36 | + EndTime string `cname:"结束时间" json:"endTime"` | ||
37 | + | ||
38 | + // 开始时间 | ||
39 | + ProductBeginTime time.Time `cname:"开始时间" json:"productBeginTime"` | ||
40 | + // 结束时间 | ||
41 | + ProductEndTime time.Time `cname:"结束时间" json:"productEndTime"` | ||
42 | +} | ||
43 | + | ||
44 | +func (cmd *SearchWorkshopProductRecordQuery) Valid(validation *validation.Validation) { | ||
45 | + cmd.Offset, cmd.Limit = domain.Pagination(cmd.PageNumber, cmd.PageSize) | ||
46 | + var err error | ||
47 | + if len(cmd.BeginTime) > 0 { | ||
48 | + if cmd.ProductBeginTime, err = time.Parse("2006-01-02 15:04:05", cmd.BeginTime); err != nil { | ||
49 | + log.Logger.Error(err.Error()) | ||
50 | + validation.Error("开始时间有误") | ||
51 | + return | ||
52 | + } | ||
53 | + } | ||
54 | + if len(cmd.EndTime) > 0 { | ||
55 | + if cmd.ProductEndTime, err = time.Parse("2006-01-02 15:04:05", cmd.EndTime); err != nil { | ||
56 | + log.Logger.Error(err.Error()) | ||
57 | + validation.Error("结束时间有误") | ||
58 | + return | ||
59 | + } | ||
60 | + } | ||
61 | +} | ||
62 | + | ||
63 | +func (cmd *SearchWorkshopProductRecordQuery) ValidateQuery() error { | ||
64 | + valid := validation.Validation{} | ||
65 | + b, err := valid.Valid(cmd) | ||
66 | + if err != nil { | ||
67 | + return err | ||
68 | + } | ||
69 | + if !b { | ||
70 | + elem := reflect.TypeOf(cmd).Elem() | ||
71 | + for _, validErr := range valid.Errors { | ||
72 | + field, isExist := elem.FieldByName(validErr.Field) | ||
73 | + if isExist { | ||
74 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
75 | + } else { | ||
76 | + return fmt.Errorf(validErr.Message) | ||
77 | + } | ||
78 | + } | ||
79 | + } | ||
80 | + return nil | ||
81 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/linmadan/egglib-go/core/application" | ||
6 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productRecord/command" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productRecord/dto" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productRecord/query" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
14 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
15 | + "time" | ||
16 | +) | ||
17 | + | ||
18 | +// 生产记录服务 | ||
19 | +type ProductRecordService struct { | ||
20 | +} | ||
21 | + | ||
22 | +// 生产记录审核 | ||
23 | +func (productRecordService *ProductRecordService) ApproveProductRecord(cmd *command.ApproveProductRecordCommand) (interface{}, error) { | ||
24 | + if err := cmd.ValidateCommand(); err != nil { | ||
25 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
26 | + } | ||
27 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
28 | + if err != nil { | ||
29 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
30 | + } | ||
31 | + if err := transactionContext.StartTransaction(); err != nil { | ||
32 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
33 | + } | ||
34 | + defer func() { | ||
35 | + transactionContext.RollbackTransaction() | ||
36 | + }() | ||
37 | + | ||
38 | + svr, err := domainService.NewPGProductRecordService(transactionContext.(*pgTransaction.TransactionContext)) | ||
39 | + if _, err = svr.Approve(cmd.ProductRecordId, cmd.ApproveUserId, cmd.WeighAfter, time.Now()); err != nil { | ||
40 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
41 | + } | ||
42 | + | ||
43 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
44 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
45 | + } | ||
46 | + return struct{}{}, nil | ||
47 | +} | ||
48 | + | ||
49 | +// 创建生产记录服务 | ||
50 | +func (productRecordService *ProductRecordService) CreateProductRecord(createProductRecordCommand *command.CreateProductRecordCommand) (interface{}, error) { | ||
51 | + if err := createProductRecordCommand.ValidateCommand(); err != nil { | ||
52 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
53 | + } | ||
54 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
55 | + if err != nil { | ||
56 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
57 | + } | ||
58 | + if err := transactionContext.StartTransaction(); err != nil { | ||
59 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
60 | + } | ||
61 | + defer func() { | ||
62 | + transactionContext.RollbackTransaction() | ||
63 | + }() | ||
64 | + newProductRecord := &domain.ProductRecord{ | ||
65 | + ProductRecordId: createProductRecordCommand.ProductRecordId, | ||
66 | + } | ||
67 | + var productRecordRepository domain.ProductRecordRepository | ||
68 | + if value, err := factory.CreateProductRecordRepository(map[string]interface{}{ | ||
69 | + "transactionContext": transactionContext, | ||
70 | + }); err != nil { | ||
71 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
72 | + } else { | ||
73 | + productRecordRepository = value | ||
74 | + } | ||
75 | + if productRecord, err := productRecordRepository.Save(newProductRecord); err != nil { | ||
76 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
77 | + } else { | ||
78 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
79 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
80 | + } | ||
81 | + return productRecord, nil | ||
82 | + } | ||
83 | +} | ||
84 | + | ||
85 | +// 返回生产记录服务 | ||
86 | +func (productRecordService *ProductRecordService) GetProductRecord(getProductRecordQuery *query.GetProductRecordQuery) (interface{}, error) { | ||
87 | + if err := getProductRecordQuery.ValidateQuery(); err != nil { | ||
88 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
89 | + } | ||
90 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
91 | + if err != nil { | ||
92 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
93 | + } | ||
94 | + if err := transactionContext.StartTransaction(); err != nil { | ||
95 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
96 | + } | ||
97 | + defer func() { | ||
98 | + transactionContext.RollbackTransaction() | ||
99 | + }() | ||
100 | + var productRecordRepository domain.ProductRecordRepository | ||
101 | + if value, err := factory.CreateProductRecordRepository(map[string]interface{}{ | ||
102 | + "transactionContext": transactionContext, | ||
103 | + }); err != nil { | ||
104 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
105 | + } else { | ||
106 | + productRecordRepository = value | ||
107 | + } | ||
108 | + productRecord, err := productRecordRepository.FindOne(map[string]interface{}{"productRecordId": getProductRecordQuery.ProductRecordId}) | ||
109 | + if err != nil { | ||
110 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
111 | + } | ||
112 | + if productRecord == nil { | ||
113 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getProductRecordQuery.ProductRecordId))) | ||
114 | + } else { | ||
115 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
116 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
117 | + } | ||
118 | + var result = &dto.ProductLevelTwoRecord{} | ||
119 | + return result.LoadDto(productRecord, productRecord.OrgId), nil | ||
120 | + } | ||
121 | +} | ||
122 | + | ||
123 | +// 返回生产记录服务列表 | ||
124 | +func (productRecordService *ProductRecordService) ListProductRecord(listProductRecordQuery *query.ListProductRecordQuery) (interface{}, error) { | ||
125 | + if err := listProductRecordQuery.ValidateQuery(); err != nil { | ||
126 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
127 | + } | ||
128 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
129 | + if err != nil { | ||
130 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
131 | + } | ||
132 | + if err := transactionContext.StartTransaction(); err != nil { | ||
133 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
134 | + } | ||
135 | + defer func() { | ||
136 | + transactionContext.RollbackTransaction() | ||
137 | + }() | ||
138 | + var productRecordRepository domain.ProductRecordRepository | ||
139 | + if value, err := factory.CreateProductRecordRepository(map[string]interface{}{ | ||
140 | + "transactionContext": transactionContext, | ||
141 | + }); err != nil { | ||
142 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
143 | + } else { | ||
144 | + productRecordRepository = value | ||
145 | + } | ||
146 | + if count, productRecords, err := productRecordRepository.Find(tool_funs.SimpleStructToMap(listProductRecordQuery)); err != nil { | ||
147 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
148 | + } else { | ||
149 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
150 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
151 | + } | ||
152 | + return map[string]interface{}{ | ||
153 | + "count": count, | ||
154 | + "productRecords": productRecords, | ||
155 | + }, nil | ||
156 | + } | ||
157 | +} | ||
158 | + | ||
159 | +// 移除生产记录服务 | ||
160 | +func (productRecordService *ProductRecordService) RemoveProductRecord(removeProductRecordCommand *command.RemoveProductRecordCommand) (interface{}, error) { | ||
161 | + if err := removeProductRecordCommand.ValidateCommand(); err != nil { | ||
162 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
163 | + } | ||
164 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
165 | + if err != nil { | ||
166 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
167 | + } | ||
168 | + if err := transactionContext.StartTransaction(); err != nil { | ||
169 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
170 | + } | ||
171 | + defer func() { | ||
172 | + transactionContext.RollbackTransaction() | ||
173 | + }() | ||
174 | + var productRecordRepository domain.ProductRecordRepository | ||
175 | + if value, err := factory.CreateProductRecordRepository(map[string]interface{}{ | ||
176 | + "transactionContext": transactionContext, | ||
177 | + }); err != nil { | ||
178 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
179 | + } else { | ||
180 | + productRecordRepository = value | ||
181 | + } | ||
182 | + productRecord, err := productRecordRepository.FindOne(map[string]interface{}{"productRecordId": removeProductRecordCommand.ProductRecordId}) | ||
183 | + if err != nil { | ||
184 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
185 | + } | ||
186 | + if productRecord == nil { | ||
187 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeProductRecordCommand.ProductRecordId))) | ||
188 | + } | ||
189 | + if productRecord, err := productRecordRepository.Remove(productRecord); err != nil { | ||
190 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
191 | + } else { | ||
192 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
193 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
194 | + } | ||
195 | + return productRecord, nil | ||
196 | + } | ||
197 | +} | ||
198 | + | ||
199 | +// 更新生产记录服务 | ||
200 | +func (productRecordService *ProductRecordService) UpdateProductRecord(updateProductRecordCommand *command.UpdateProductRecordCommand) (interface{}, error) { | ||
201 | + if err := updateProductRecordCommand.ValidateCommand(); err != nil { | ||
202 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
203 | + } | ||
204 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
205 | + if err != nil { | ||
206 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
207 | + } | ||
208 | + if err := transactionContext.StartTransaction(); err != nil { | ||
209 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
210 | + } | ||
211 | + defer func() { | ||
212 | + transactionContext.RollbackTransaction() | ||
213 | + }() | ||
214 | + var productRecordRepository domain.ProductRecordRepository | ||
215 | + if value, err := factory.CreateProductRecordRepository(map[string]interface{}{ | ||
216 | + "transactionContext": transactionContext, | ||
217 | + }); err != nil { | ||
218 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
219 | + } else { | ||
220 | + productRecordRepository = value | ||
221 | + } | ||
222 | + productRecord, err := productRecordRepository.FindOne(map[string]interface{}{"productRecordId": updateProductRecordCommand.ProductRecordId}) | ||
223 | + if err != nil { | ||
224 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
225 | + } | ||
226 | + if productRecord == nil { | ||
227 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateProductRecordCommand.ProductRecordId))) | ||
228 | + } | ||
229 | + if err := productRecord.Update(tool_funs.SimpleStructToMap(updateProductRecordCommand)); err != nil { | ||
230 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
231 | + } | ||
232 | + if productRecord, err := productRecordRepository.Save(productRecord); err != nil { | ||
233 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
234 | + } else { | ||
235 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
236 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
237 | + } | ||
238 | + return productRecord, nil | ||
239 | + } | ||
240 | +} | ||
241 | + | ||
242 | +// 返回生产记录服务列表 | ||
243 | +func (productRecordService *ProductRecordService) SearchProductRecord(operateInfo *domain.OperateInfo, listProductRecordQuery *query.SearchProductRecordQuery) (int64, interface{}, error) { | ||
244 | + if err := listProductRecordQuery.ValidateQuery(); err != nil { | ||
245 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
246 | + } | ||
247 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
248 | + if err != nil { | ||
249 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
250 | + } | ||
251 | + if err := transactionContext.StartTransaction(); err != nil { | ||
252 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
253 | + } | ||
254 | + defer func() { | ||
255 | + transactionContext.RollbackTransaction() | ||
256 | + }() | ||
257 | + var productRecordRepository domain.ProductRecordRepository | ||
258 | + productRecordRepository, _, _ = factory.FastPgProductRecord(transactionContext, 0) | ||
259 | + | ||
260 | + count, productRecords, err := productRecordRepository.Find(utils.ObjectToMap(listProductRecordQuery)) | ||
261 | + if err != nil { | ||
262 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
263 | + } | ||
264 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
265 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
266 | + } | ||
267 | + var result = make([]*dto.ProductLevelTwoRecord, 0) | ||
268 | + for i := range productRecords { | ||
269 | + item := productRecords[i] | ||
270 | + newItem := &dto.ProductLevelTwoRecord{} | ||
271 | + newItem.LoadDto(item, operateInfo.OrgId) | ||
272 | + result = append(result, newItem) | ||
273 | + } | ||
274 | + return count, result, nil | ||
275 | +} | ||
276 | + | ||
277 | +// 生产记录统计 | ||
278 | +func (productRecordService *ProductRecordService) ProductRecordStatics(cmd *command.ProductRecordStaticsCommand) (interface{}, error) { | ||
279 | + if err := cmd.ValidateCommand(); err != nil { | ||
280 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
281 | + } | ||
282 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
283 | + if err != nil { | ||
284 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
285 | + } | ||
286 | + if err := transactionContext.StartTransaction(); err != nil { | ||
287 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
288 | + } | ||
289 | + defer func() { | ||
290 | + transactionContext.RollbackTransaction() | ||
291 | + }() | ||
292 | + var _ domain.ProductRecordRepository | ||
293 | + var productRecord *domain.ProductRecord = cmd.ProductRecord | ||
294 | + //_,productRecord,err = factory.FastPgProductRecord(transactionContext,cmd.ProductRecordId) | ||
295 | + //if err!=nil{ | ||
296 | + // log.Logger.Error(err.Error()) | ||
297 | + // return nil, nil | ||
298 | + //} | ||
299 | + // | ||
300 | + if productRecord == nil { | ||
301 | + return nil, nil | ||
302 | + } | ||
303 | + svr, _ := domainService.NewPGProductRecordService(transactionContext.(*pgTransaction.TransactionContext)) | ||
304 | + if _, err = svr.EmployeeProductStatics(productRecord); err != nil { | ||
305 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
306 | + } | ||
307 | + if _, err = svr.WorkshopProductStatics(productRecord); err != nil { | ||
308 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
309 | + } | ||
310 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
311 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
312 | + } | ||
313 | + | ||
314 | + return nil, nil | ||
315 | +} | ||
316 | + | ||
317 | +func NewProductRecordService(options map[string]interface{}) *ProductRecordService { | ||
318 | + newProductRecordService := &ProductRecordService{} | ||
319 | + return newProductRecordService | ||
320 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productRecord/dto" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productRecord/query" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
12 | +) | ||
13 | + | ||
14 | +// 返回员工生产记录服务列表 | ||
15 | +func (productRecordService *ProductRecordService) SearchEmployeeProductRecord(operateInfo *domain.OperateInfo, listProductRecordQuery *query.SearchEmployeeProductRecordQuery) (int64, interface{}, error) { | ||
16 | + if err := listProductRecordQuery.ValidateQuery(); err != nil { | ||
17 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
18 | + } | ||
19 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
20 | + if err != nil { | ||
21 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
22 | + } | ||
23 | + if err := transactionContext.StartTransaction(); err != nil { | ||
24 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
25 | + } | ||
26 | + defer func() { | ||
27 | + transactionContext.RollbackTransaction() | ||
28 | + }() | ||
29 | + //var productRecordRepository domain.ProductRecordRepository | ||
30 | + //productRecordRepository,_,_ = factory.FastPgProductRecord(transactionContext,0) | ||
31 | + | ||
32 | + productRecordRepository, _ := dao.NewEmployeeProductRecordDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
33 | + options := utils.ObjectToMap(listProductRecordQuery) | ||
34 | + count, productRecords, err := productRecordRepository.SearchEmployeeProductRecord(options) | ||
35 | + if err != nil { | ||
36 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
37 | + } | ||
38 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
39 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
40 | + } | ||
41 | + var result = make([]*dto.EmployeeProductRecordDto, 0) | ||
42 | + for i := range productRecords { | ||
43 | + item := productRecords[i] | ||
44 | + newItem := &dto.EmployeeProductRecordDto{} | ||
45 | + newItem.LoadDto(item, operateInfo.OrgId) | ||
46 | + result = append(result, newItem) | ||
47 | + } | ||
48 | + return count, result, nil | ||
49 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productRecord/dto" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productRecord/query" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
12 | +) | ||
13 | + | ||
14 | +// 返回员工生产记录服务列表 | ||
15 | +func (productRecordService *ProductRecordService) SearchWorkshopProductRecord(operateInfo *domain.OperateInfo, listProductRecordQuery *query.SearchWorkshopProductRecordQuery) (int64, interface{}, error) { | ||
16 | + if err := listProductRecordQuery.ValidateQuery(); err != nil { | ||
17 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
18 | + } | ||
19 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
20 | + if err != nil { | ||
21 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
22 | + } | ||
23 | + if err := transactionContext.StartTransaction(); err != nil { | ||
24 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
25 | + } | ||
26 | + defer func() { | ||
27 | + transactionContext.RollbackTransaction() | ||
28 | + }() | ||
29 | + //var productRecordRepository domain.ProductRecordRepository | ||
30 | + //productRecordRepository,_,_ = factory.FastPgProductRecord(transactionContext,0) | ||
31 | + | ||
32 | + productRecordRepository, _ := dao.NewWorkshopProductRecordDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
33 | + options := utils.ObjectToMap(listProductRecordQuery) | ||
34 | + count, productRecords, err := productRecordRepository.SearchWorkshopProductRecord(options) | ||
35 | + if err != nil { | ||
36 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
37 | + } | ||
38 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
39 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
40 | + } | ||
41 | + var result = make([]*dto.WorkshopProductRecordDto, 0) | ||
42 | + for i := range productRecords { | ||
43 | + item := productRecords[i] | ||
44 | + newItem := &dto.WorkshopProductRecordDto{} | ||
45 | + newItem.LoadDto(item, operateInfo.OrgId) | ||
46 | + result = append(result, newItem) | ||
47 | + } | ||
48 | + return count, result, nil | ||
49 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type CommonStatisticsQuery struct { | ||
12 | + Action string `cname:"查询类别" json:"actionType" valid:"Required"` | ||
13 | + QueryOptions map[string]interface{} `json:"queryOptions"` | ||
14 | +} | ||
15 | + | ||
16 | +func (checkUndertakerQuery *CommonStatisticsQuery) Valid(validation *validation.Validation) { | ||
17 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (checkUndertakerQuery *CommonStatisticsQuery) ValidateQuery() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(checkUndertakerQuery) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(checkUndertakerQuery).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/statistics/query" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
9 | +) | ||
10 | + | ||
11 | +// CommonStatisticsService 通用的统计服务 | ||
12 | +type CommonStatisticsService struct { | ||
13 | +} | ||
14 | + | ||
15 | +// CommonStatisticsService 通用的统计服务 | ||
16 | +func (svr *CommonStatisticsService) CommonStatisticsService(cmd *query.CommonStatisticsQuery) (interface{}, error) { | ||
17 | + if err := cmd.ValidateQuery(); err != nil { | ||
18 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
19 | + } | ||
20 | + var err error | ||
21 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
22 | + if err != nil { | ||
23 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
24 | + } | ||
25 | + if err := transactionContext.StartTransaction(); err != nil { | ||
26 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
27 | + } | ||
28 | + defer func() { | ||
29 | + _ = transactionContext.RollbackTransaction() | ||
30 | + }() | ||
31 | + | ||
32 | + statisticsService, _ := domainService.NewPGCommonStatisticsService(transactionContext.(*pg.TransactionContext)) | ||
33 | + response, err := statisticsService.CommonStatistics(cmd.Action, cmd.QueryOptions) | ||
34 | + if err != nil { | ||
35 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
36 | + } | ||
37 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
38 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
39 | + } | ||
40 | + return response, nil | ||
41 | +} | ||
42 | + | ||
43 | +func NewCommonStatisticsService(options map[string]interface{}) *CommonStatisticsService { | ||
44 | + newProductSectionService := &CommonStatisticsService{} | ||
45 | + return newProductSectionService | ||
46 | +} |
1 | package syncdata | 1 | package syncdata |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
4 | "strconv" | 6 | "strconv" |
5 | "strings" | 7 | "strings" |
6 | "time" | 8 | "time" |
@@ -181,8 +183,15 @@ func (srv *PullDataK3CloudService) PullMaterial(timeFilter time.Time) error { | @@ -181,8 +183,15 @@ func (srv *PullDataK3CloudService) PullMaterial(timeFilter time.Time) error { | ||
181 | if err != nil { | 183 | if err != nil { |
182 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 184 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
183 | } | 185 | } |
186 | + | ||
187 | + var userService = domainService.NewUserService() | ||
188 | + org, err := userService.Organization(constant.MANUFACTURE_DEFAULT_ORGID) | ||
189 | + if err != nil { | ||
190 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
191 | + } | ||
192 | + | ||
184 | //MaterialK3cloud表数据到Proudct表 | 193 | //MaterialK3cloud表数据到Proudct表 |
185 | - err = materialDao.SyncDataProudct(nowTime.Unix()) | 194 | + err = materialDao.SyncDataProudct(nowTime.Unix(), org.OrgName) |
186 | if err != nil { | 195 | if err != nil { |
187 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 196 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
188 | } | 197 | } |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type WorkshopDataConsumeCommand struct { | ||
13 | + *domain.DeviceCollection | ||
14 | + // 企业id | ||
15 | + CompanyId int `cname:"企业id" json:"companyId" valid:"Required"` | ||
16 | + // 组织ID | ||
17 | + OrgId int `cname:"组织ID" json:"orgId" valid:"Required"` | ||
18 | +} | ||
19 | + | ||
20 | +func (updateWorkshopCommand *WorkshopDataConsumeCommand) Valid(validation *validation.Validation) { | ||
21 | + | ||
22 | +} | ||
23 | + | ||
24 | +func (updateWorkshopCommand *WorkshopDataConsumeCommand) ValidateCommand() error { | ||
25 | + valid := validation.Validation{} | ||
26 | + b, err := valid.Valid(updateWorkshopCommand) | ||
27 | + if err != nil { | ||
28 | + return err | ||
29 | + } | ||
30 | + if !b { | ||
31 | + elem := reflect.TypeOf(updateWorkshopCommand).Elem() | ||
32 | + for _, validErr := range valid.Errors { | ||
33 | + field, isExist := elem.FieldByName(validErr.Field) | ||
34 | + if isExist { | ||
35 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
36 | + } else { | ||
37 | + return fmt.Errorf(validErr.Message) | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | + return nil | ||
42 | +} |
@@ -98,6 +98,13 @@ func (workshopService *WorkshopService) GetWorkshop(getWorkshopQuery *query.GetW | @@ -98,6 +98,13 @@ func (workshopService *WorkshopService) GetWorkshop(getWorkshopQuery *query.GetW | ||
98 | if err != nil { | 98 | if err != nil { |
99 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 99 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
100 | } | 100 | } |
101 | + userService := domainService.NewUserService() | ||
102 | + if workshop.Principal.UserId > 0 { | ||
103 | + u, _ := userService.User(workshop.Principal.UserId) | ||
104 | + if u != nil { | ||
105 | + workshop.Principal = u | ||
106 | + } | ||
107 | + } | ||
101 | if workshop == nil { | 108 | if workshop == nil { |
102 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getWorkshopQuery.WorkshopId))) | 109 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getWorkshopQuery.WorkshopId))) |
103 | } else { | 110 | } else { |
@@ -175,7 +182,7 @@ func (workshopService *WorkshopService) RemoveWorkshop(removeWorkshopCommand *co | @@ -175,7 +182,7 @@ func (workshopService *WorkshopService) RemoveWorkshop(removeWorkshopCommand *co | ||
175 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeWorkshopCommand.WorkshopId))) | 182 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeWorkshopCommand.WorkshopId))) |
176 | } | 183 | } |
177 | if !workshop.CanRemove() { | 184 | if !workshop.CanRemove() { |
178 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当车间下存在线别") | 185 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前车间下存在线别,不可删除") |
179 | } | 186 | } |
180 | if workshop, err := workshopRepository.Remove(workshop); err != nil { | 187 | if workshop, err := workshopRepository.Remove(workshop); err != nil { |
181 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 188 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/workshop/command" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
10 | +) | ||
11 | + | ||
12 | +func (workshopService *WorkshopService) WorkshopConsume(cmd *command.WorkshopDataConsumeCommand) (interface{}, error) { | ||
13 | + if err := cmd.ValidateCommand(); err != nil { | ||
14 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
15 | + } | ||
16 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
17 | + if err != nil { | ||
18 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
19 | + } | ||
20 | + if err := transactionContext.StartTransaction(); err != nil { | ||
21 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
22 | + } | ||
23 | + defer func() { | ||
24 | + transactionContext.RollbackTransaction() | ||
25 | + }() | ||
26 | + | ||
27 | + consumeService, _ := domainService.NewPGWorkshopDataConsumeService(transactionContext.(*pg.TransactionContext)) | ||
28 | + if _, err := consumeService.Consume(cmd.CompanyId, cmd.OrgId, cmd.DeviceCollection); err != nil { | ||
29 | + log.Logger.Error(err.Error()) | ||
30 | + return nil, err | ||
31 | + } | ||
32 | + | ||
33 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
34 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
35 | + } | ||
36 | + return struct{}{}, nil | ||
37 | +} |
pkg/constant/manufacture.go
0 → 100644
1 | +package constant | ||
2 | + | ||
3 | +import ( | ||
4 | + "os" | ||
5 | + "strconv" | ||
6 | +) | ||
7 | + | ||
8 | +var ( | ||
9 | + // 生产制造 - 称重系统 - 默认公司 | ||
10 | + MANUFACTURE_DEFAULT_COMPANYID = 1 | ||
11 | + // 生产制造 - 称重系统 - 默认组织 | ||
12 | + MANUFACTURE_DEFAULT_ORGID = 1 | ||
13 | +) | ||
14 | + | ||
15 | +func init() { | ||
16 | + if os.Getenv("MANUFACTURE_DEFAULT_COMPANYID") != "" { | ||
17 | + MANUFACTURE_DEFAULT_COMPANYID, _ = strconv.Atoi(os.Getenv("MANUFACTURE_DEFAULT_COMPANYID")) | ||
18 | + } | ||
19 | + if os.Getenv("MANUFACTURE_DEFAULT_ORGID") != "" { | ||
20 | + MANUFACTURE_DEFAULT_ORGID, _ = strconv.Atoi(os.Getenv("MANUFACTURE_DEFAULT_ORGID")) | ||
21 | + } | ||
22 | +} |
@@ -2,17 +2,21 @@ package constant | @@ -2,17 +2,21 @@ package constant | ||
2 | 2 | ||
3 | import "os" | 3 | import "os" |
4 | 4 | ||
5 | +var MQTT_TOPIC = "/MQTT" | ||
6 | + | ||
5 | //设备商提供的测试地址 | 7 | //设备商提供的测试地址 |
6 | var MQTT_HOST = "175.24.122.87" | 8 | var MQTT_HOST = "175.24.122.87" |
7 | -//内网测试地址 | ||
8 | -//var MQTT_HOST = "192.168.100.222" | ||
9 | var MQTT_PORT = "1883" | 9 | var MQTT_PORT = "1883" |
10 | +var MQTT_USER = "user111" | ||
11 | +var MQTT_PASSWORD = "user111" | ||
10 | 12 | ||
11 | -var MQTT_USER = "" | ||
12 | - | ||
13 | -var MQTT_PASSWORD = "" | 13 | +//内网测试地址 |
14 | +//var MQTT_HOST = "192.168.100.222" | ||
15 | +//var MQTT_PORT = "1883" | ||
16 | +//var MQTT_USER = "admin" | ||
17 | +//var MQTT_PASSWORD = "123456" | ||
14 | 18 | ||
15 | -func init(){ | 19 | +func init() { |
16 | if os.Getenv("MQTT_HOST") != "" { | 20 | if os.Getenv("MQTT_HOST") != "" { |
17 | MQTT_HOST = os.Getenv("MQTT_HOST") | 21 | MQTT_HOST = os.Getenv("MQTT_HOST") |
18 | } | 22 | } |
@@ -10,6 +10,12 @@ var ( | @@ -10,6 +10,12 @@ var ( | ||
10 | DISABLE_REPOSITORY_CACHE = false | 10 | DISABLE_REPOSITORY_CACHE = false |
11 | // 缓存过期时间 单位秒 | 11 | // 缓存过期时间 单位秒 |
12 | REPOSITORY_CACHE_EXPIRE = 30 * 60 | 12 | REPOSITORY_CACHE_EXPIRE = 30 * 60 |
13 | + | ||
14 | + REDIS_ADDRESS = "" | ||
15 | + // redis 考勤机打卡消息队列 | ||
16 | + REDIS_ZKTECO_KEY = "allied-creation-zkteco" | ||
17 | + // redis 车间数据消息队列 | ||
18 | + REDIS_WORKSHOP_KEY = "allied-creation-workshop" | ||
13 | ) | 19 | ) |
14 | 20 | ||
15 | func init() { | 21 | func init() { |
@@ -29,4 +35,5 @@ func init() { | @@ -29,4 +35,5 @@ func init() { | ||
29 | if os.Getenv("DISABLE_REPOSITORY_CACHE") != "" { | 35 | if os.Getenv("DISABLE_REPOSITORY_CACHE") != "" { |
30 | DISABLE_REPOSITORY_CACHE = true | 36 | DISABLE_REPOSITORY_CACHE = true |
31 | } | 37 | } |
38 | + REDIS_ADDRESS = REDIS_HOST + ":" + REDIS_PORT | ||
32 | } | 39 | } |
@@ -103,9 +103,9 @@ func (device *Device) Update(data map[string]interface{}) error { | @@ -103,9 +103,9 @@ 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 | } |
107 | + if device.Ext != nil && device.Ext.DeviceExt == nil { | ||
108 | + device.Ext.DeviceExt = &DeviceExt{} | ||
109 | } | 109 | } |
110 | if orgName, ok := data["orgName"]; ok { | 110 | if orgName, ok := data["orgName"]; ok { |
111 | device.Ext.OrgName = orgName.(string) | 111 | device.Ext.OrgName = orgName.(string) |
@@ -127,6 +127,16 @@ func (device *Device) Valid() error { | @@ -127,6 +127,16 @@ func (device *Device) Valid() error { | ||
127 | return nil | 127 | return nil |
128 | } | 128 | } |
129 | 129 | ||
130 | +// 标记为生产设备 | ||
131 | +func (device *Device) MarkAsProductDevice() bool { | ||
132 | + if device.Ext.DeviceExt.IsProductDevice == 1 { | ||
133 | + return false | ||
134 | + } | ||
135 | + device.Ext.DeviceExt.IsProductDevice = 1 | ||
136 | + device.UpdatedAt = time.Now() | ||
137 | + return true | ||
138 | +} | ||
139 | + | ||
130 | // 导入设备数据体 | 140 | // 导入设备数据体 |
131 | type ImportDeviceItem struct { | 141 | type ImportDeviceItem struct { |
132 | // 设备编号 | 142 | // 设备编号 |
@@ -183,3 +193,13 @@ func (item *ImportDeviceItem) Valid() error { | @@ -183,3 +193,13 @@ func (item *ImportDeviceItem) Valid() error { | ||
183 | } | 193 | } |
184 | return nil | 194 | return nil |
185 | } | 195 | } |
196 | + | ||
197 | +type Devices []*Device | ||
198 | + | ||
199 | +func (devices Devices) ToMap() map[string]*Device { | ||
200 | + var resp = make(map[string]*Device) | ||
201 | + for _, v := range devices { | ||
202 | + resp[v.DeviceCode] = v | ||
203 | + } | ||
204 | + return resp | ||
205 | +} |
pkg/domain/device_collection.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +// 设备采集数据 | ||
10 | +type DeviceCollection struct { | ||
11 | + // 数据采集ID | ||
12 | + DeviceCollectionId int64 `json:"deviceCollectionId,string"` | ||
13 | + // 车间名 | ||
14 | + WorkShopName string `json:"workShopName"` | ||
15 | + // 采集时间 | ||
16 | + CollectionTime time.Time `json:"collectionTime"` | ||
17 | + // 设备名 | ||
18 | + DeviceSn string `json:"deviceSn"` | ||
19 | + // 设备类型 | ||
20 | + DeviceType string `json:"deviceType"` | ||
21 | + // 启动状态 1-启动 0-停止 | ||
22 | + StartupStatus int64 `json:"startupStatus"` | ||
23 | + // 通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障 | ||
24 | + ComStatus int64 `json:"comStatus"` | ||
25 | + // 设备数据值 | ||
26 | + Values interface{} `json:"values"` | ||
27 | +} | ||
28 | + | ||
29 | +var ( | ||
30 | + // 包馅机 | ||
31 | + DeviceTypeBaoXianJi = "BXJ" | ||
32 | + // 打浆机 | ||
33 | + DeviceTypeDaJiangJi = "DJJ" | ||
34 | + // 面包屑机 | ||
35 | + DeviceTypeMianBaoXieJi = "MBXJ" | ||
36 | + // 油炸机 | ||
37 | + DeviceTypeYouZhaJi = "YZJ" | ||
38 | + // 串串机 | ||
39 | + DeviceTypeChuanChuanJi = "CCJ" | ||
40 | + // 速冻线 | ||
41 | + DeviceTypeSuDongXian = "SDX" | ||
42 | + // 封口机 | ||
43 | + DeviceTypeFengKouJi = "FKJ" | ||
44 | + // 封箱机 | ||
45 | + DeviceTypeFengXiangJi = "FXJ" | ||
46 | +) | ||
47 | + | ||
48 | +type DeviceCollectionRepository interface { | ||
49 | + Save(deviceCollection *DeviceCollection) (*DeviceCollection, error) | ||
50 | + Remove(deviceCollection *DeviceCollection) (*DeviceCollection, error) | ||
51 | + FindOne(queryOptions map[string]interface{}) (*DeviceCollection, error) | ||
52 | + Find(queryOptions map[string]interface{}) (int64, []*DeviceCollection, error) | ||
53 | +} | ||
54 | + | ||
55 | +func (deviceCollection *DeviceCollection) Identify() interface{} { | ||
56 | + if deviceCollection.DeviceCollectionId == 0 { | ||
57 | + return nil | ||
58 | + } | ||
59 | + return deviceCollection.DeviceCollectionId | ||
60 | +} | ||
61 | + | ||
62 | +func (deviceCollection *DeviceCollection) Update(data map[string]interface{}) error { | ||
63 | + if workShopName, ok := data["workShopName"]; ok { | ||
64 | + deviceCollection.WorkShopName = workShopName.(string) | ||
65 | + } | ||
66 | + if deviceSn, ok := data["deviceSn"]; ok { | ||
67 | + deviceCollection.DeviceSn = deviceSn.(string) | ||
68 | + } | ||
69 | + if deviceType, ok := data["deviceType"]; ok { | ||
70 | + deviceCollection.DeviceSn = deviceType.(string) | ||
71 | + } | ||
72 | + if startupStatus, ok := data["startupStatus"]; ok { | ||
73 | + deviceCollection.StartupStatus = startupStatus.(int64) | ||
74 | + } | ||
75 | + if comStatus, ok := data["comStatus"]; ok { | ||
76 | + deviceCollection.ComStatus = comStatus.(int64) | ||
77 | + } | ||
78 | + if values, ok := data["values"]; ok { | ||
79 | + deviceCollection.Values = values | ||
80 | + } | ||
81 | + return nil | ||
82 | +} | ||
83 | + | ||
84 | +func TaskDeviceCollection() string { | ||
85 | + return fmt.Sprintf("%v:task:device-collection:report", constant.CACHE_PREFIX) | ||
86 | +} |
pkg/domain/device_collection_machine.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +// 包馅机 | ||
4 | +type DeviceBaoXianJi struct { | ||
5 | + InterSpeed int64 `json:"InterSpeed"` // 内包材速度:内包材运行速率 | ||
6 | + ExterSpeed int64 `json:"ExterSpeed"` // 外包材速度:内包材运行速率 | ||
7 | + KnifeSpeed int64 `json:"KnifeSpeed"` // 切刀速度:切刀运行速率 | ||
8 | + TransSpeed int64 `json:"TransSpeed"` // 输送速度:输送带运行速率 | ||
9 | + Count int64 `json:"Count"` // 生产计数:生产统计数量 | ||
10 | +} | ||
11 | + | ||
12 | +// 油炸机 | ||
13 | +type DeviceYouZhaJi struct { | ||
14 | + FrontTemp float64 `json:"FontTemp"` // 炸机前段温度:炸机前段当前温度 | ||
15 | + BackTemp float64 `json:"BackTemp"` // 炸机后段温度:炸机后段当前温度 | ||
16 | + TankTemp float64 `json:"TankTemp"` // 储油罐温度 :储油罐当前温度 | ||
17 | + TubeTemp float64 `json:"TubeTemp"` // 管路温度:管路当前温度 | ||
18 | +} | ||
19 | + | ||
20 | +// 串串机 | ||
21 | +type DeviceChuanChuanJi struct { | ||
22 | + Count int64 `json:"Count"` // 生产计数:生产统计数量 | ||
23 | + Year string `json:"Year"` // 年 | ||
24 | + Month string `json:"Month"` // 月 | ||
25 | + Day string `json:"Day"` // 日 | ||
26 | + ProductType string `json:"ProductType"` // 产品类型:当前产品种类 | ||
27 | +} | ||
28 | + | ||
29 | +// 速冻线 | ||
30 | +type DeviceSuDongXian struct { | ||
31 | + CurrTemp float64 `json:"CurrTemp"` // 当前温度:当前温度 | ||
32 | +} | ||
33 | + | ||
34 | +// 封口机 | ||
35 | +type DeviceFengKouJi struct { | ||
36 | + Count int64 `json:"Count"` // 生产计数:生产统计数量 | ||
37 | + Year string `json:"Year"` // 年 | ||
38 | + Month string `json:"Month"` // 月 | ||
39 | + Day string `json:"Day"` // 日 | ||
40 | + ProductType string `json:"ProductType"` // 产品类型:当前产品种类 | ||
41 | +} | ||
42 | + | ||
43 | +// 封箱机 | ||
44 | +type DeviceFengXiangJi struct { | ||
45 | + Count int64 `json:"Count"` // 生产计数:生产统计数量 | ||
46 | + Year string `json:"Year"` // 年 | ||
47 | + Month string `json:"Month"` // 月 | ||
48 | + Day string `json:"Day"` // 日 | ||
49 | + ProductType string `json:"ProductType"` // 产品类型:当前产品种类 | ||
50 | +} |
-
请 注册 或 登录 后发表评论