|
@@ -15,7 +15,7 @@ import ( |
|
@@ -15,7 +15,7 @@ import ( |
15
|
//产能管理
|
15
|
//产能管理
|
16
|
|
16
|
|
17
|
// 产能管理 页面上手动创建员工生产记录
|
17
|
// 产能管理 页面上手动创建员工生产记录
|
18
|
-func (productRecordService *ProductRecordService) CreateProductCapacities(operateInfo *domain.OperateInfo, param *command.SaveEmployeeProductRecordCmd) (map[string]interface{}, error) {
|
18
|
+func (productRecordService *ProductRecordService) SaveProductCapacities(operateInfo *domain.OperateInfo, param *command.SaveProductRecordCmd) (map[string]interface{}, error) {
|
19
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
19
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
20
|
if err != nil {
|
20
|
if err != nil {
|
21
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
21
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -81,8 +81,21 @@ func (productRecordService *ProductRecordService) CreateProductCapacities(operat |
|
@@ -81,8 +81,21 @@ func (productRecordService *ProductRecordService) CreateProductCapacities(operat |
81
|
productRecordRepo, _ := factory.CreateProductRecordRepository(map[string]interface{}{
|
81
|
productRecordRepo, _ := factory.CreateProductRecordRepository(map[string]interface{}{
|
82
|
"transactionContext": transactionContext,
|
82
|
"transactionContext": transactionContext,
|
83
|
})
|
83
|
})
|
|
|
84
|
+
|
84
|
nowTime := time.Now()
|
85
|
nowTime := time.Now()
|
|
|
86
|
+ if param.ProductRecordId > 0 {
|
|
|
87
|
+ productRecord, err := productRecordRepo.FindOne(map[string]interface{}{
|
|
|
88
|
+ "productRecordId": param.ProductRecordId,
|
|
|
89
|
+ })
|
|
|
90
|
+ if err != nil {
|
|
|
91
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取生产记录数据失败"+err.Error())
|
|
|
92
|
+ }
|
|
|
93
|
+ if productRecord.ProductRecordInfo.ApproveStatus != domain.ProductRecordNotApprove {
|
|
|
94
|
+ return nil, application.ThrowError(application.ARG_ERROR, "生产记录不可再被编辑")
|
|
|
95
|
+ }
|
|
|
96
|
+ }
|
85
|
epRecord := &domain.ProductRecord{
|
97
|
epRecord := &domain.ProductRecord{
|
|
|
98
|
+ ProductRecordId: param.ProductRecordId,
|
86
|
UpdatedAt: nowTime,
|
99
|
UpdatedAt: nowTime,
|
87
|
OrgId: operateInfo.OrgId,
|
100
|
OrgId: operateInfo.OrgId,
|
88
|
CompanyId: operateInfo.CompanyId,
|
101
|
CompanyId: operateInfo.CompanyId,
|
|
@@ -112,7 +125,6 @@ func (productRecordService *ProductRecordService) CreateProductCapacities(operat |
|
@@ -112,7 +125,6 @@ func (productRecordService *ProductRecordService) CreateProductCapacities(operat |
112
|
epRecord.ProductRecordInfo.ApproveStatus = domain.ProductRecordApproved
|
125
|
epRecord.ProductRecordInfo.ApproveStatus = domain.ProductRecordApproved
|
113
|
epRecord.ProductRecordInfo.ApproveUser = user
|
126
|
epRecord.ProductRecordInfo.ApproveUser = user
|
114
|
}
|
127
|
}
|
115
|
- // epRecord.ParticipateType = param.ParticipateType //参与类型
|
|
|
116
|
_, err = productRecordRepo.Save(epRecord)
|
128
|
_, err = productRecordRepo.Save(epRecord)
|
117
|
if err != nil {
|
129
|
if err != nil {
|
118
|
return nil, application.ThrowError(application.ARG_ERROR, "保存员工生产记录失败"+err.Error())
|
130
|
return nil, application.ThrowError(application.ARG_ERROR, "保存员工生产记录失败"+err.Error())
|
|
@@ -161,7 +173,7 @@ func (productRecordService *ProductRecordService) ListProductCapacities(operateI |
|
@@ -161,7 +173,7 @@ func (productRecordService *ProductRecordService) ListProductCapacities(operateI |
161
|
condition["limit"] = limit
|
173
|
condition["limit"] = limit
|
162
|
}
|
174
|
}
|
163
|
if offset >= 0 {
|
175
|
if offset >= 0 {
|
164
|
- condition["offset"] = limit
|
176
|
+ condition["offset"] = offset
|
165
|
}
|
177
|
}
|
166
|
count, productRecords, err := productRecordRepo.Find(condition)
|
178
|
count, productRecords, err := productRecordRepo.Find(condition)
|
167
|
if err != nil {
|
179
|
if err != nil {
|