正在显示
14 个修改的文件
包含
528 行增加
和
21 行删除
1 | +package command | ||
2 | + | ||
3 | +type SaveEmployeeProductRecordCmd struct { | ||
4 | + EmployeeProductRecordId int `json:"id"` | ||
5 | + // 车间ID | ||
6 | + WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | ||
7 | + // 生产线ID | ||
8 | + LineId int `cname:"生产线ID" json:"lineId" valid:"Required"` | ||
9 | + // 工段ID | ||
10 | + SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` | ||
11 | + //员工 | ||
12 | + WorkerId int `cname:"工人ID" json:"workerId" valid:"Required"` | ||
13 | + //产量重量 | ||
14 | + Weigh float64 `cname:"重量" json:"weigh" valid:"Required" ` | ||
15 | + //产品编码 | ||
16 | + ProductCode string `json:"productCode"` | ||
17 | + // 参与类型 1:正常 2:支援 | ||
18 | + ParticipateType int `json:"participateType"` | ||
19 | + //日期 | ||
20 | + RecordDate string `json:"recordDate"` | ||
21 | + //上班班次 1:全天 2:白班 4:中班 8:夜班 | ||
22 | + WorkOn int `json:"workOn"` | ||
23 | +} |
1 | +package dto | ||
2 | + | ||
3 | +//产能管理-列表 | ||
4 | +type ProductCapacitiesList struct { | ||
5 | + EmployeeProductRecordId int `json:"employeeProductRecordId"` | ||
6 | + WorkshopName string `json:"workshopName"` //车间名称 | ||
7 | + LineName string `json:"lineName"` //线别名称 | ||
8 | + SectionName string `json:"sectionName"` //工段 | ||
9 | + WorkerName string `json:"workerName"` // 用户姓名 | ||
10 | + EmployeeType int `json:"employeeType"` // 员工类型 1:固定 2:派遣 3.临时 | ||
11 | + ProductName string `json:"productName"` //品名 | ||
12 | + ParticipateType int `json:"participateType"` // 参与类型 1:正常 2:支援 | ||
13 | + ProductWeigh float64 `json:"productWeigh"` // 产能 | ||
14 | + CreatedAt string `json:"createdAt"` // 创建时间 | ||
15 | + ApproveStatus int `json:"approveStatus"` //0:未审核 1:已审核 2.自动审核 | ||
16 | +} | ||
17 | + | ||
18 | +//产能管理-列表-详情 | ||
19 | +type ProductCapacitiesInfo struct { | ||
20 | + EmployeeProductRecordId int `json:"id"` | ||
21 | + WorkshopId int ` json:"workshopId" ` // 车间ID | ||
22 | + WorkshopName string `json:"workshopName"` // | ||
23 | + LineId int `json:"lineId"` // 生产线ID | ||
24 | + LineName string `json:"lineName"` // | ||
25 | + SectionId int `json:"sectionId" ` // 工段ID | ||
26 | + SectionName string `json:"sectionName"` // | ||
27 | + WorkerId int `json:"workerId" ` //员工 | ||
28 | + WorkerName string `json:"workerName"` // | ||
29 | + Weigh float64 `json:"weigh"` //产量重量 | ||
30 | + ProductCode string `json:"productCode"` //产品编码 | ||
31 | + ProductName string `json:"productName"` //产品名称 | ||
32 | + ParticipateType int `json:"participateType"` //参与类型 1:正常 2:支援 | ||
33 | + RecordDate string `json:"recordDate"` //日期 | ||
34 | + WorkOn int `json:"workOn"` //上班班次 1:全天 2:白班 4:中班 8:夜班 | ||
35 | +} |
1 | +package query | ||
2 | + | ||
3 | +type ListProductCapacitiesQuery struct { | ||
4 | + PageNumber int `json:"pageNumber"` | ||
5 | + PageSize int `json:"pageSize"` | ||
6 | + CompanyId int `json:"companyId"` | ||
7 | + OrgId int `json:"orgId"` | ||
8 | + WorkshopName string `json:"workshopName"` | ||
9 | + LineName string `json:"lineName"` | ||
10 | + SectionName string `json:"sectionName"` | ||
11 | + ProductBeginTime string `json:"productBeginTime"` | ||
12 | + ProductEndTime string `json:"productEndTime"` | ||
13 | + WorkerName string `json:"workerName"` | ||
14 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | + | ||
6 | + "github.com/linmadan/egglib-go/core/application" | ||
7 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
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/dao" | ||
14 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
15 | +) | ||
16 | + | ||
17 | +//产能管理 | ||
18 | + | ||
19 | +// 产能管理 页面上手动创建员工生产记录 | ||
20 | +func (productRecordService *ProductRecordService) CreateProductCapacities(operateInfo *domain.OperateInfo, param *command.SaveEmployeeProductRecordCmd) (map[string]interface{}, 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 | + //日期 | ||
33 | + recordDate, err := time.ParseInLocation("2006-01-02", param.RecordDate, time.Local) | ||
34 | + if err != nil { | ||
35 | + return nil, application.ThrowError(application.ARG_ERROR, "日期格式错误") | ||
36 | + } | ||
37 | + //员工数据 | ||
38 | + var worker *domain.User | ||
39 | + userService := domainService.NewUserService() | ||
40 | + worker, err = userService.User(param.WorkerId) | ||
41 | + if err != nil { | ||
42 | + return nil, application.ThrowError(application.ARG_ERROR, "获取员工错误,"+err.Error()) | ||
43 | + } | ||
44 | + //操作人数据 | ||
45 | + var user *domain.User | ||
46 | + user, err = userService.User(operateInfo.UserId) | ||
47 | + if err != nil { | ||
48 | + return nil, application.ThrowError(application.ARG_ERROR, "获取操作人错误,"+err.Error()) | ||
49 | + } | ||
50 | + //组织数据 | ||
51 | + var org *domain.Org | ||
52 | + org, err = userService.Organization(operateInfo.OrgId) | ||
53 | + if err != nil { | ||
54 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
55 | + } | ||
56 | + //车间数据 | ||
57 | + workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{ | ||
58 | + "transactionContext": transactionContext, | ||
59 | + }) | ||
60 | + workshop, err := workshopRepo.FindOne(map[string]interface{}{"workshopId": param.WorkshopId}) | ||
61 | + if err != nil { | ||
62 | + return nil, application.ThrowError(application.ARG_ERROR, "获取车间数据失败"+err.Error()) | ||
63 | + } | ||
64 | + workstation, err := workshop.FindWorkStation(param.WorkshopId, param.LineId, param.SectionId) | ||
65 | + if err != nil { | ||
66 | + return nil, application.ThrowError(application.ARG_ERROR, "获取车间工段数据失败"+err.Error()) | ||
67 | + } | ||
68 | + | ||
69 | + //产品数据 | ||
70 | + productRepo, _ := factory.CreateProductRepository(map[string]interface{}{ | ||
71 | + "transactionContext": transactionContext, | ||
72 | + }) | ||
73 | + | ||
74 | + //获取产品 | ||
75 | + productData, err := productRepo.FindOne(map[string]interface{}{ | ||
76 | + "companyId": operateInfo.CompanyId, | ||
77 | + "orgId": operateInfo.OrgId, | ||
78 | + "productCode": param.ProductCode, | ||
79 | + }) | ||
80 | + if err != nil { | ||
81 | + return nil, application.ThrowError(application.ARG_ERROR, "获取产品数据失败"+err.Error()) | ||
82 | + } | ||
83 | + nowTime := time.Now() | ||
84 | + | ||
85 | + //员工生产记录 | ||
86 | + eProductRecordRepo, _ := factory.CreateEmployeeProductRecordRepository(map[string]interface{}{ | ||
87 | + "transactionContext": transactionContext, | ||
88 | + }) | ||
89 | + | ||
90 | + var epRecord *domain.EmployeeProductRecord | ||
91 | + if param.EmployeeProductRecordId != 0 { | ||
92 | + epRecord, err = eProductRecordRepo.FindOne(map[string]interface{}{ | ||
93 | + "employeeProductRecordId": param.EmployeeProductRecordId, | ||
94 | + }) | ||
95 | + if err != nil { | ||
96 | + return nil, application.ThrowError(application.ARG_ERROR, "获取员工生产记录数据失败"+err.Error()) | ||
97 | + } | ||
98 | + } else { | ||
99 | + epRecord = &domain.EmployeeProductRecord{ | ||
100 | + CreatedAt: nowTime, | ||
101 | + OrgId: operateInfo.OrgId, | ||
102 | + CompanyId: operateInfo.CompanyId, | ||
103 | + } | ||
104 | + } | ||
105 | + epRecord.UpdatedAt = time.Now() | ||
106 | + epRecord.ParticipateType = param.ParticipateType //参与类型 | ||
107 | + epRecord.WorkStation = workstation //车间工段 | ||
108 | + epRecord.ProductWorker = worker //员工 | ||
109 | + epRecord.WorkOn = param.WorkOn //上班班次 | ||
110 | + epRecord.CreatedAt = recordDate //日期 | ||
111 | + epRecord.Ext = &domain.Ext{ | ||
112 | + Operator: user, | ||
113 | + OrgName: org.OrgName, | ||
114 | + } | ||
115 | + epRecord.ProductWeigh = param.Weigh //重量 | ||
116 | + if epRecord.ProductRecordInfo == nil { | ||
117 | + epRecord.ProductRecordInfo = &domain.ProductRecordStaticInfo{} | ||
118 | + } | ||
119 | + epRecord.ProductRecordInfo.OutputWeight = param.Weigh //重量 | ||
120 | + epRecord.ProductRecordInfo.PlanProductName = productData.ProductName //产品名称 | ||
121 | + epRecord.ProductRecordInfo.PlanProductCode = productData.ProductCode //产品编码 | ||
122 | + epRecord.ProductRecordInfo.OutputWeight = param.Weigh //重量 | ||
123 | + _, err = eProductRecordRepo.Save(epRecord) | ||
124 | + if err != nil { | ||
125 | + return nil, application.ThrowError(application.ARG_ERROR, "保存员工生产记录失败"+err.Error()) | ||
126 | + } | ||
127 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
128 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
129 | + } | ||
130 | + return map[string]interface{}{ | ||
131 | + "employeeProductRecordId": epRecord.EmployeeProductRecordId, | ||
132 | + }, nil | ||
133 | +} | ||
134 | + | ||
135 | +// 产能管理 列表 | ||
136 | +func (productRecordService *ProductRecordService) ListProductCapacities(operateInfo *domain.OperateInfo, param *query.ListProductCapacitiesQuery) (int64, []dto.ProductCapacitiesList, error) { | ||
137 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
138 | + if err != nil { | ||
139 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
140 | + } | ||
141 | + if err := transactionContext.StartTransaction(); err != nil { | ||
142 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
143 | + } | ||
144 | + defer func() { | ||
145 | + transactionContext.RollbackTransaction() | ||
146 | + }() | ||
147 | + productRecordRepository, _ := dao.NewEmployeeProductRecordDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
148 | + productBeginTime, _ := time.ParseInLocation("2006-01-02", param.ProductBeginTime, time.Local) | ||
149 | + productEndTime, _ := time.ParseInLocation("2006-01-02", param.ProductEndTime, time.Local) | ||
150 | + condition := map[string]interface{}{ | ||
151 | + "companyId": param.CompanyId, | ||
152 | + "orgId": param.OrgId, | ||
153 | + "workerName": param.WorkerName, | ||
154 | + "workshopName": param.WorkshopName, | ||
155 | + "lineName": param.LineName, | ||
156 | + "sectionName": param.SectionName, | ||
157 | + "productBeginTime": productBeginTime, | ||
158 | + "productEndTime": productEndTime, | ||
159 | + } | ||
160 | + | ||
161 | + limit := param.PageSize | ||
162 | + offset := param.PageSize * (param.PageNumber - 1) | ||
163 | + if limit >= 0 { | ||
164 | + condition["limit"] = limit | ||
165 | + } | ||
166 | + if offset >= 0 { | ||
167 | + condition["offset"] = limit | ||
168 | + } | ||
169 | + count, productRecords, err := productRecordRepository.SearchEmployeeProductRecord(condition) | ||
170 | + if err != nil { | ||
171 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
172 | + } | ||
173 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
174 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
175 | + } | ||
176 | + | ||
177 | + var result = make([]dto.ProductCapacitiesList, 0) | ||
178 | + for _, v := range productRecords { | ||
179 | + item := dto.ProductCapacitiesList{ | ||
180 | + EmployeeProductRecordId: v.EmployeeProductRecordId, | ||
181 | + WorkshopName: v.WorkStation.WorkshopName, | ||
182 | + LineName: v.WorkStation.LineName, | ||
183 | + SectionName: v.WorkStation.SectionName, | ||
184 | + WorkerName: v.ProductWorker.UserName, | ||
185 | + EmployeeType: v.ProductWorker.EmployeeType, | ||
186 | + ProductName: v.ProductRecordInfo.PlanProductName, | ||
187 | + ParticipateType: v.ParticipateType, | ||
188 | + ProductWeigh: v.ProductRecordInfo.OutputWeight, | ||
189 | + CreatedAt: v.CreatedAt.Format("2006-01-02"), | ||
190 | + ApproveStatus: v.ApproveStatus, | ||
191 | + } | ||
192 | + result = append(result, item) | ||
193 | + } | ||
194 | + return count, result, nil | ||
195 | +} | ||
196 | + | ||
197 | +// 产能管理 列表-详情 | ||
198 | +func (productRecordService *ProductRecordService) GetProductCapacities(operateInfo *domain.OperateInfo, id int) (*dto.ProductCapacitiesInfo, error) { | ||
199 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
200 | + if err != nil { | ||
201 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
202 | + } | ||
203 | + if err := transactionContext.StartTransaction(); err != nil { | ||
204 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
205 | + } | ||
206 | + defer func() { | ||
207 | + transactionContext.RollbackTransaction() | ||
208 | + }() | ||
209 | + | ||
210 | + eProductRecordRepo, _ := factory.CreateEmployeeProductRecordRepository(map[string]interface{}{ | ||
211 | + "transactionContext": transactionContext, | ||
212 | + }) | ||
213 | + | ||
214 | + recordData, err := eProductRecordRepo.FindOne(map[string]interface{}{ | ||
215 | + "employeeProductRecordId": id, | ||
216 | + }) | ||
217 | + if err != nil { | ||
218 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
219 | + } | ||
220 | + | ||
221 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
222 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
223 | + } | ||
224 | + | ||
225 | + var result = dto.ProductCapacitiesInfo{ | ||
226 | + EmployeeProductRecordId: recordData.EmployeeProductRecordId, | ||
227 | + WorkshopId: recordData.WorkStation.WorkshopId, | ||
228 | + WorkshopName: recordData.WorkStation.WorkshopName, | ||
229 | + LineId: recordData.WorkStation.LineId, | ||
230 | + LineName: recordData.WorkStation.LineName, | ||
231 | + SectionId: recordData.WorkStation.SectionId, | ||
232 | + SectionName: recordData.WorkStation.SectionName, | ||
233 | + WorkerId: recordData.ProductWorker.UserId, | ||
234 | + WorkerName: recordData.ProductWorker.UserName, | ||
235 | + Weigh: recordData.ProductRecordInfo.OutputWeight, | ||
236 | + ProductCode: recordData.ProductRecordInfo.PlanProductCode, | ||
237 | + ProductName: recordData.ProductRecordInfo.PlanProductName, | ||
238 | + ParticipateType: recordData.ParticipateType, | ||
239 | + RecordDate: recordData.CreatedAt.Format("2006-01-02"), | ||
240 | + WorkOn: recordData.WorkOn, | ||
241 | + } | ||
242 | + | ||
243 | + return &result, nil | ||
244 | +} | ||
245 | + | ||
246 | +// 产能管理 列表-删除 | ||
247 | +func (productRecordService *ProductRecordService) DeleteProductCapacities(operateInfo *domain.OperateInfo, id int) (map[string]interface{}, error) { | ||
248 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
249 | + if err != nil { | ||
250 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
251 | + } | ||
252 | + if err := transactionContext.StartTransaction(); err != nil { | ||
253 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
254 | + } | ||
255 | + defer func() { | ||
256 | + transactionContext.RollbackTransaction() | ||
257 | + }() | ||
258 | + | ||
259 | + eProductRecordRepo, _ := factory.CreateEmployeeProductRecordRepository(map[string]interface{}{ | ||
260 | + "transactionContext": transactionContext, | ||
261 | + }) | ||
262 | + | ||
263 | + recordData, err := eProductRecordRepo.FindOne(map[string]interface{}{ | ||
264 | + "employeeProductRecordId": id, | ||
265 | + }) | ||
266 | + if err != nil { | ||
267 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
268 | + } | ||
269 | + _, err = eProductRecordRepo.Remove(recordData) | ||
270 | + if err != nil { | ||
271 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
272 | + } | ||
273 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
274 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
275 | + } | ||
276 | + | ||
277 | + return map[string]interface{}{ | ||
278 | + "employeeProductRecordId": recordData.EmployeeProductRecordId, | ||
279 | + }, nil | ||
280 | +} | ||
281 | + | ||
282 | +// 产能管理 列表-审核 | ||
283 | +func (productRecordService *ProductRecordService) ApproveProductCapacities(operateInfo *domain.OperateInfo, id int) (map[string]interface{}, error) { | ||
284 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
285 | + if err != nil { | ||
286 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
287 | + } | ||
288 | + if err := transactionContext.StartTransaction(); err != nil { | ||
289 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
290 | + } | ||
291 | + defer func() { | ||
292 | + transactionContext.RollbackTransaction() | ||
293 | + }() | ||
294 | + | ||
295 | + eProductRecordRepo, _ := factory.CreateEmployeeProductRecordRepository(map[string]interface{}{ | ||
296 | + "transactionContext": transactionContext, | ||
297 | + }) | ||
298 | + | ||
299 | + recordData, err := eProductRecordRepo.FindOne(map[string]interface{}{ | ||
300 | + "employeeProductRecordId": id, | ||
301 | + }) | ||
302 | + if err != nil { | ||
303 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
304 | + } | ||
305 | + | ||
306 | + userService := domainService.NewUserService() | ||
307 | + //操作人数据 | ||
308 | + var user *domain.User | ||
309 | + user, err = userService.User(operateInfo.UserId) | ||
310 | + if err != nil { | ||
311 | + return nil, application.ThrowError(application.ARG_ERROR, "获取操作人错误,"+err.Error()) | ||
312 | + } | ||
313 | + | ||
314 | + nowTime := time.Now() | ||
315 | + recordData.ApproveAt = &nowTime | ||
316 | + recordData.ApproveStatus = 1 | ||
317 | + recordData.ApproveUser = user | ||
318 | + _, err = eProductRecordRepo.Save(recordData) | ||
319 | + if err != nil { | ||
320 | + return nil, application.ThrowError(application.ARG_ERROR, "保存数据错误,"+err.Error()) | ||
321 | + } | ||
322 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
323 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
324 | + } | ||
325 | + return map[string]interface{}{ | ||
326 | + "employeeProductRecordId": recordData.EmployeeProductRecordId, | ||
327 | + }, nil | ||
328 | +} |
1 | package domain | 1 | package domain |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
5 | "time" | 4 | "time" |
5 | + | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
6 | ) | 7 | ) |
7 | 8 | ||
8 | const ( | 9 | const ( |
@@ -49,6 +50,10 @@ type EmployeeProductRecord struct { | @@ -49,6 +50,10 @@ type EmployeeProductRecord struct { | ||
49 | ProductRecordInfo *ProductRecordStaticInfo `json:"productRecordInfo"` | 50 | ProductRecordInfo *ProductRecordStaticInfo `json:"productRecordInfo"` |
50 | // 生产工人 | 51 | // 生产工人 |
51 | ProductWorker *User `comment:"生产工人"` | 52 | ProductWorker *User `comment:"生产工人"` |
53 | + | ||
54 | + ApproveStatus int `json:"approveStatus"` // 审核状态 0:未审核 1:已审核 2.自动审核 | ||
55 | + ApproveAt *time.Time `json:"approveAt"` // 审核时间 | ||
56 | + ApproveUser *User `json:"approveUser"` // 审核人 | ||
52 | } | 57 | } |
53 | 58 | ||
54 | type EmployeeProductRecordRepository interface { | 59 | type EmployeeProductRecordRepository interface { |
@@ -7,6 +7,8 @@ type ProductRecordStaticInfo struct { | @@ -7,6 +7,8 @@ type ProductRecordStaticInfo struct { | ||
7 | ProductDate string `json:"productDate"` | 7 | ProductDate string `json:"productDate"` |
8 | // 生产计划ID | 8 | // 生产计划ID |
9 | ProductPlanId int `json:"productPlanId,omitempty"` | 9 | ProductPlanId int `json:"productPlanId,omitempty"` |
10 | + | ||
11 | + PlanProductCode string `json:"planProductCode"` | ||
10 | // 计划的产品名称 | 12 | // 计划的产品名称 |
11 | PlanProductName string `json:"planProductName,omitempty"` | 13 | PlanProductName string `json:"planProductName,omitempty"` |
12 | // 批号 | 14 | // 批号 |
@@ -54,6 +54,7 @@ func init() { | @@ -54,6 +54,7 @@ func init() { | ||
54 | (*models.RewardStandard)(nil), | 54 | (*models.RewardStandard)(nil), |
55 | (*models.RewardRule)(nil), | 55 | (*models.RewardRule)(nil), |
56 | (*models.ProductTrouble)(nil), | 56 | (*models.ProductTrouble)(nil), |
57 | + (*models.RewardSummary)(nil), | ||
57 | } { | 58 | } { |
58 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ | 59 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ |
59 | Temp: false, | 60 | Temp: false, |
1 | package models | 1 | package models |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | "time" | 4 | "time" |
5 | + | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | ) | 7 | ) |
7 | 8 | ||
8 | type EmployeeProductRecord struct { | 9 | type EmployeeProductRecord struct { |
@@ -37,4 +38,8 @@ type EmployeeProductRecord struct { | @@ -37,4 +38,8 @@ type EmployeeProductRecord struct { | ||
37 | ProductRecordInfo *domain.ProductRecordStaticInfo `comment:"生产记录信息"` | 38 | ProductRecordInfo *domain.ProductRecordStaticInfo `comment:"生产记录信息"` |
38 | // 生产工人 | 39 | // 生产工人 |
39 | ProductWorker *domain.User `comment:"生产工人"` | 40 | ProductWorker *domain.User `comment:"生产工人"` |
41 | + | ||
42 | + ApproveStatus int `comment:"审核状态 0:未审核 1:已审核 2.自动审核"` // 审核状态 0:未审核 1:已审核 2.自动审核 | ||
43 | + ApproveAt *time.Time `comment:"审核时间"` // | ||
44 | + ApproveUser *domain.User `comment:"审核人"` // 审核人 | ||
40 | } | 45 | } |
@@ -8,23 +8,30 @@ import ( | @@ -8,23 +8,30 @@ import ( | ||
8 | 8 | ||
9 | // RewardSummary 功过奖惩明细 | 9 | // RewardSummary 功过奖惩明细 |
10 | type RewardSummary struct { | 10 | type RewardSummary struct { |
11 | - tableName string `pg:"manufacture.reward_summary,alias:reward_summary"` | ||
12 | - Id int `pg:"pk:id"` | ||
13 | - CompanyId int `` | ||
14 | - OrgId int `` | ||
15 | - RecordDate time.Time //日期 | ||
16 | - RecordDateStr string // | ||
17 | - WorkStation domain.WorkStation // 工作位置 | ||
18 | - Worker domain.User //员工 | ||
19 | - UpToStandard float64 //合格率 | ||
20 | - Yield float64 //产能 | ||
21 | - AccidentNum1 int //质量事故 次数 | ||
22 | - AccidentAmount1 float64 //质量事故 损失金额 | ||
23 | - AccidentNum2 int //安全事故 次数 | ||
24 | - AccidentAmount2 float64 //安全事故 损失金额 | ||
25 | - AccidentNum3 int //异物金属事故 次数 | ||
26 | - AccidentNum4 int //异物非金属事故 次数 | ||
27 | - CreatedAt time.Time // | ||
28 | - UpdatedAt time.Time // | ||
29 | - SummaryResult float64 //奖惩计算结果 | 11 | + tableName string `pg:"manufacture.reward_summary,alias:reward_summary"` |
12 | + Id int `pg:"pk:id"` | ||
13 | + CompanyId int `` | ||
14 | + OrgId int `` | ||
15 | + RecordDate time.Time //日期 | ||
16 | + RecordDateStr string // | ||
17 | + WorkStation domain.WorkStation // 工作位置 | ||
18 | + Worker domain.User //员工 | ||
19 | + UpToStandard float64 //合格率 | ||
20 | + UpToStandardResult int //合格率 功过评定结果 1`功` -1 `过` 0 `不奖不惩` | ||
21 | + Yield float64 //产能 | ||
22 | + YieldResult int //产能 功过评定结果 1`功` -1 `过` 0 `不奖不惩` | ||
23 | + AccidentNum1 int //质量事故 次数 | ||
24 | + AccidentAmount1 float64 //质量事故 损失金额 | ||
25 | + AccidentResult1 int //质量事故 功过评定结果 1`功` -1 `过` 0 `不奖不惩` | ||
26 | + AccidentNum2 int //安全事故 次数 | ||
27 | + AccidentAmount2 float64 //安全事故 损失金额 | ||
28 | + AccidentResult2 int //安全事故 功过评定结果 1`功` -1 `过` 0 `不奖不惩` | ||
29 | + AccidentNum3 int //异物金属事故 次数 | ||
30 | + AccidentResult3 int //异物金属事故 功过评定结果 1`功` -1 `过` 0 `不奖不惩` | ||
31 | + AccidentNum4 int //异物非金属事故 次数 | ||
32 | + AccidentResult4 int //异物非金属事故 功过评定结果 1`功` -1 `过` 0 `不奖不惩` | ||
33 | + SummaryResult float64 //奖惩金额计算结果(元) | ||
34 | + CreatedAt time.Time // | ||
35 | + UpdatedAt time.Time // | ||
36 | + | ||
30 | } | 37 | } |
@@ -22,5 +22,8 @@ func TransformToEmployeeProductRecordDomainModelFromPgModels(employeeProductReco | @@ -22,5 +22,8 @@ func TransformToEmployeeProductRecordDomainModelFromPgModels(employeeProductReco | ||
22 | Version: employeeProductRecordModel.Version, | 22 | Version: employeeProductRecordModel.Version, |
23 | ProductRecordInfo: employeeProductRecordModel.ProductRecordInfo, | 23 | ProductRecordInfo: employeeProductRecordModel.ProductRecordInfo, |
24 | ProductWorker: employeeProductRecordModel.ProductWorker, | 24 | ProductWorker: employeeProductRecordModel.ProductWorker, |
25 | + ApproveStatus: employeeProductRecordModel.ApproveStatus, | ||
26 | + ApproveAt: employeeProductRecordModel.ApproveAt, | ||
27 | + ApproveUser: employeeProductRecordModel.ApproveUser, | ||
25 | }, nil | 28 | }, nil |
26 | } | 29 | } |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + | ||
5 | "github.com/go-pg/pg/v10" | 6 | "github.com/go-pg/pg/v10" |
6 | 7 | ||
7 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" | 8 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" |
@@ -41,6 +42,9 @@ func (repository *EmployeeProductRecordRepository) Save(employeeProductRecord *d | @@ -41,6 +42,9 @@ func (repository *EmployeeProductRecordRepository) Save(employeeProductRecord *d | ||
41 | "version", | 42 | "version", |
42 | "product_record_info", | 43 | "product_record_info", |
43 | "product_worker", | 44 | "product_worker", |
45 | + "approve_status", | ||
46 | + "approve_at", | ||
47 | + "approve_user", | ||
44 | } | 48 | } |
45 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "employee_product_record_id", "deleted_at")) | 49 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "employee_product_record_id", "deleted_at")) |
46 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "employee_product_record_id", "deleted_at")) | 50 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "employee_product_record_id", "deleted_at")) |
@@ -66,6 +70,9 @@ func (repository *EmployeeProductRecordRepository) Save(employeeProductRecord *d | @@ -66,6 +70,9 @@ func (repository *EmployeeProductRecordRepository) Save(employeeProductRecord *d | ||
66 | &employeeProductRecord.Version, | 70 | &employeeProductRecord.Version, |
67 | &employeeProductRecord.ProductRecordInfo, | 71 | &employeeProductRecord.ProductRecordInfo, |
68 | &employeeProductRecord.ProductWorker, | 72 | &employeeProductRecord.ProductWorker, |
73 | + &employeeProductRecord.ApproveStatus, | ||
74 | + &employeeProductRecord.ApproveAt, | ||
75 | + &employeeProductRecord.ApproveUser, | ||
69 | ), | 76 | ), |
70 | fmt.Sprintf("INSERT INTO manufacture.employee_product_record (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), | 77 | fmt.Sprintf("INSERT INTO manufacture.employee_product_record (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), |
71 | //employeeProductRecord.EmployeeProductRecordId, | 78 | //employeeProductRecord.EmployeeProductRecordId, |
@@ -83,6 +90,9 @@ func (repository *EmployeeProductRecordRepository) Save(employeeProductRecord *d | @@ -83,6 +90,9 @@ func (repository *EmployeeProductRecordRepository) Save(employeeProductRecord *d | ||
83 | employeeProductRecord.Version, | 90 | employeeProductRecord.Version, |
84 | employeeProductRecord.ProductRecordInfo, | 91 | employeeProductRecord.ProductRecordInfo, |
85 | employeeProductRecord.ProductWorker, | 92 | employeeProductRecord.ProductWorker, |
93 | + employeeProductRecord.ApproveStatus, | ||
94 | + employeeProductRecord.ApproveAt, | ||
95 | + employeeProductRecord.ApproveUser, | ||
86 | ); err != nil { | 96 | ); err != nil { |
87 | return employeeProductRecord, err | 97 | return employeeProductRecord, err |
88 | } | 98 | } |
@@ -104,6 +114,9 @@ func (repository *EmployeeProductRecordRepository) Save(employeeProductRecord *d | @@ -104,6 +114,9 @@ func (repository *EmployeeProductRecordRepository) Save(employeeProductRecord *d | ||
104 | &employeeProductRecord.Version, | 114 | &employeeProductRecord.Version, |
105 | &employeeProductRecord.ProductRecordInfo, | 115 | &employeeProductRecord.ProductRecordInfo, |
106 | &employeeProductRecord.ProductWorker, | 116 | &employeeProductRecord.ProductWorker, |
117 | + &employeeProductRecord.ApproveStatus, | ||
118 | + &employeeProductRecord.ApproveAt, | ||
119 | + &employeeProductRecord.ApproveUser, | ||
107 | ), | 120 | ), |
108 | fmt.Sprintf("UPDATE manufacture.employee_product_record SET %s WHERE employee_product_record_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), | 121 | fmt.Sprintf("UPDATE manufacture.employee_product_record SET %s WHERE employee_product_record_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), |
109 | //employeeProductRecord.EmployeeProductRecordId, | 122 | //employeeProductRecord.EmployeeProductRecordId, |
@@ -121,6 +134,9 @@ func (repository *EmployeeProductRecordRepository) Save(employeeProductRecord *d | @@ -121,6 +134,9 @@ func (repository *EmployeeProductRecordRepository) Save(employeeProductRecord *d | ||
121 | employeeProductRecord.Version, | 134 | employeeProductRecord.Version, |
122 | employeeProductRecord.ProductRecordInfo, | 135 | employeeProductRecord.ProductRecordInfo, |
123 | employeeProductRecord.ProductWorker, | 136 | employeeProductRecord.ProductWorker, |
137 | + employeeProductRecord.ApproveStatus, | ||
138 | + employeeProductRecord.ApproveAt, | ||
139 | + employeeProductRecord.ApproveUser, | ||
124 | employeeProductRecord.Identify(), | 140 | employeeProductRecord.Identify(), |
125 | ); err != nil { | 141 | ); err != nil { |
126 | return employeeProductRecord, err | 142 | return employeeProductRecord, err |
@@ -128,3 +128,53 @@ func (controller *ProductRecordController) SearchWorkshopProductRecord() { | @@ -128,3 +128,53 @@ func (controller *ProductRecordController) SearchWorkshopProductRecord() { | ||
128 | total, data, err := productPlanService.SearchWorkshopProductRecord(ParseOperateInfo(controller.BaseController), cmd) | 128 | total, data, err := productPlanService.SearchWorkshopProductRecord(ParseOperateInfo(controller.BaseController), cmd) |
129 | ResponseGrid(controller.BaseController, total, data, err) | 129 | ResponseGrid(controller.BaseController, total, data, err) |
130 | } | 130 | } |
131 | + | ||
132 | +// 产能管理 添加产能 | ||
133 | +func (controller *ProductRecordController) CreateProductCapacities() { | ||
134 | + productRecordService := service.NewProductRecordService(nil) | ||
135 | + saveCommand := &command.SaveEmployeeProductRecordCmd{} | ||
136 | + controller.Unmarshal(saveCommand) | ||
137 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
138 | + data, err := productRecordService.CreateProductCapacities(operateInfo, saveCommand) | ||
139 | + controller.Response(data, err) | ||
140 | +} | ||
141 | + | ||
142 | +// 产能管理 产能列表 | ||
143 | +func (controller *ProductRecordController) ListProductCapacities() { | ||
144 | + productRecordService := service.NewProductRecordService(nil) | ||
145 | + listQury := &query.ListProductCapacitiesQuery{} | ||
146 | + controller.Unmarshal(listQury) | ||
147 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
148 | + listQury.CompanyId = operateInfo.CompanyId | ||
149 | + listQury.OrgId = operateInfo.OrgId | ||
150 | + total, data, err := productRecordService.ListProductCapacities(operateInfo, listQury) | ||
151 | + ResponseGrid(controller.BaseController, total, data, err) | ||
152 | +} | ||
153 | + | ||
154 | +// 产能管理 产能详情 | ||
155 | +func (controller *ProductRecordController) GetProductCapacities() { | ||
156 | + productRecordService := service.NewProductRecordService(nil) | ||
157 | + productRecordId, _ := controller.GetInt(":productRecordId") | ||
158 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
159 | + data, err := productRecordService.GetProductCapacities(operateInfo, productRecordId) | ||
160 | + controller.Response(data, err) | ||
161 | +} | ||
162 | + | ||
163 | +// 产能管理 删除产能 | ||
164 | +func (controller *ProductRecordController) DeleteProductCapacities() { | ||
165 | + productRecordService := service.NewProductRecordService(nil) | ||
166 | + productRecordId, _ := controller.GetInt(":productRecordId") | ||
167 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
168 | + data, err := productRecordService.DeleteProductCapacities(operateInfo, productRecordId) | ||
169 | + controller.Response(data, err) | ||
170 | +} | ||
171 | + | ||
172 | +// 产能管理 审核产能 | ||
173 | +func (controller *ProductRecordController) ApproveProductCapacities() { | ||
174 | + productRecordService := service.NewProductRecordService(nil) | ||
175 | + queryCommand := &query.GetProductCapacitiesQuery{} | ||
176 | + controller.Unmarshal(queryCommand) | ||
177 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
178 | + data, err := productRecordService.ApproveProductCapacities(operateInfo, queryCommand.EmployeeProductRecordId) | ||
179 | + controller.Response(data, err) | ||
180 | +} |
@@ -18,4 +18,17 @@ func init() { | @@ -18,4 +18,17 @@ func init() { | ||
18 | web.Router("/product-records/cancel", &controllers.ProductRecordController{}, "Post:CancelProductRecord") | 18 | web.Router("/product-records/cancel", &controllers.ProductRecordController{}, "Post:CancelProductRecord") |
19 | web.Router("/product-records/employee-productive/search", &controllers.ProductRecordController{}, "Post:SearchEmployeeProductRecord") | 19 | web.Router("/product-records/employee-productive/search", &controllers.ProductRecordController{}, "Post:SearchEmployeeProductRecord") |
20 | web.Router("/product-records/workshop-productive/search", &controllers.ProductRecordController{}, "Post:SearchWorkshopProductRecord") | 20 | web.Router("/product-records/workshop-productive/search", &controllers.ProductRecordController{}, "Post:SearchWorkshopProductRecord") |
21 | + | ||
22 | + //产能管理 列表 | ||
23 | + web.Router("/product-records/product-capacities/search", &controllers.ProductRecordController{}, "Post:ListProductCapacities") | ||
24 | + //产能管理 添加产能 | ||
25 | + web.Router("/product-records/product-capacities", &controllers.ProductRecordController{}, "Post:CreateProductCapacities") | ||
26 | + //产能管理 列表-产能详情 | ||
27 | + web.Router("/product-records/product-capacities/:productRecordId", &controllers.ProductRecordController{}, "Get:GetProductCapacities") | ||
28 | + //产能管理 列表 -删除产能 | ||
29 | + web.Router("/product-records/product-capacities/:productRecordId", &controllers.ProductRecordController{}, "Delete:DeleteProductCapacities") | ||
30 | + | ||
31 | + //产能管理 列表 -审核产能 | ||
32 | + web.Router("/product-records/product-capacities/approve", &controllers.ProductRecordController{}, "Post:ApproveProductCapacities") | ||
33 | + | ||
21 | } | 34 | } |
-
请 注册 或 登录 后发表评论