|
@@ -135,110 +135,169 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp |
|
@@ -135,110 +135,169 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp |
135
|
cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
135
|
cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
136
|
cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
|
136
|
cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
|
137
|
|
137
|
|
138
|
- _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template")
|
138
|
+ project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
|
139
|
if err != nil {
|
139
|
if err != nil {
|
140
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
140
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
141
|
}
|
141
|
}
|
142
|
|
142
|
|
143
|
- cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": in.CycleId})
|
|
|
144
|
- if err != nil {
|
|
|
145
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
146
|
- }
|
143
|
+ // 如果是已经启用的项目,只能编辑环节的截至时间
|
|
|
144
|
+ if project.State == domain.ProjectStateEnable {
|
|
|
145
|
+ end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local)
|
|
|
146
|
+ if err != nil {
|
|
|
147
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
148
|
+ }
|
147
|
|
149
|
|
148
|
- // 周期内的所有项目,员工不能重复被评估
|
|
|
149
|
- rids := map[string]bool{}
|
|
|
150
|
- for i := range projects {
|
|
|
151
|
- // 排除当前项目
|
|
|
152
|
- if in.Id != projects[i].Id {
|
|
|
153
|
- ids := projects[i].Recipients
|
|
|
154
|
- for j := range ids {
|
|
|
155
|
- rids[ids[j]] = true
|
150
|
+ cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": in.CycleId})
|
|
|
151
|
+ if err != nil {
|
|
|
152
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
153
|
+ }
|
|
|
154
|
+ maxTime := cycle.TimeEnd.Local()
|
|
|
155
|
+ if end.After(maxTime) {
|
|
|
156
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间")
|
|
|
157
|
+ }
|
|
|
158
|
+ if project.Template != nil {
|
|
|
159
|
+ for i := range project.Template.LinkNodes {
|
|
|
160
|
+ node := project.Template.LinkNodes[i]
|
|
|
161
|
+ node.TimeEnd = &end
|
156
|
}
|
162
|
}
|
157
|
}
|
163
|
}
|
158
|
- }
|
|
|
159
|
- repeatNum := 0
|
|
|
160
|
- for i := range in.Recipients {
|
|
|
161
|
- id := in.Recipients[i]
|
|
|
162
|
- if _, ok := rids[id]; ok {
|
|
|
163
|
- repeatNum++
|
164
|
+ // 项目起始截止时间(暂时环节中的时间未分开)
|
|
|
165
|
+ project.EndTime = end
|
|
|
166
|
+ project, err = projectRepository.Insert(project)
|
|
|
167
|
+ if err != nil {
|
|
|
168
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
164
|
}
|
169
|
}
|
165
|
- }
|
|
|
166
|
- if repeatNum > 0 {
|
|
|
167
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum))
|
|
|
168
|
- }
|
|
|
169
|
|
170
|
|
170
|
- project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
|
|
|
171
|
- if err != nil {
|
|
|
172
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
173
|
- }
|
171
|
+ // 查看任务过程,重新日计算任务截至期
|
|
|
172
|
+ taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
173
|
+ tasks, err := taskRepository.Find(map[string]interface{}{"projectId": in.Id})
|
|
|
174
|
+ if err != nil {
|
|
|
175
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
176
|
+ }
|
174
|
|
177
|
|
175
|
- cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true})
|
|
|
176
|
- if err != nil {
|
|
|
177
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
178
|
- }
|
178
|
+ now := time.Now().Local()
|
|
|
179
|
+ nowO := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻
|
|
|
180
|
+
|
|
|
181
|
+ for i := range tasks {
|
|
|
182
|
+ task := tasks[i]
|
|
|
183
|
+ task.TimeEnd = &end
|
|
|
184
|
+
|
|
|
185
|
+ // 重新计算
|
|
|
186
|
+ if task.NextSentAt == nil {
|
|
|
187
|
+ // 环节起始和截止本地时间
|
|
|
188
|
+ startLocal := task.TimeStart.Local()
|
|
|
189
|
+ endLocal := task.TimeEnd.Local()
|
|
|
190
|
+
|
|
|
191
|
+ // 在当前时间之前,则计算下一个周期时间
|
|
|
192
|
+ if startLocal.Before(now) {
|
|
|
193
|
+ nextTime := utils.NextTime(nowO, startLocal, task.KpiCycle)
|
|
|
194
|
+ task.NextSentAt = &nextTime
|
|
|
195
|
+ } else {
|
|
|
196
|
+ task.NextSentAt = &startLocal
|
|
|
197
|
+ }
|
|
|
198
|
+ // 如果超出截至时间,则周期置空
|
|
|
199
|
+ if task.NextSentAt.After(endLocal) {
|
|
|
200
|
+ task.NextSentAt = nil
|
|
|
201
|
+ }
|
|
|
202
|
+ } else {
|
|
|
203
|
+ // 新的截止时间在下一次发送周期任务之前,则结束
|
|
|
204
|
+ if end.Before(task.NextSentAt.Local()) {
|
|
|
205
|
+ task.NextSentAt = nil
|
|
|
206
|
+ } else {
|
|
|
207
|
+ // do nothing
|
|
|
208
|
+ }
|
|
|
209
|
+ }
|
|
|
210
|
+ }
|
179
|
|
211
|
|
180
|
- if cycleTemplate == nil || cycleTemplate.Template == nil {
|
|
|
181
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加模板")
|
|
|
182
|
- }
|
212
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
213
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
214
|
+ }
|
|
|
215
|
+ return project, nil
|
183
|
|
216
|
|
184
|
- if len(in.Recipients) == 0 {
|
|
|
185
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人")
|
|
|
186
|
- }
|
217
|
+ } else {
|
|
|
218
|
+ _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template")
|
|
|
219
|
+ if err != nil {
|
|
|
220
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
221
|
+ }
|
|
|
222
|
+ // 周期内的所有项目,员工不能重复被评估
|
|
|
223
|
+ rids := map[string]bool{}
|
|
|
224
|
+ for i := range projects {
|
|
|
225
|
+ // 排除当前项目
|
|
|
226
|
+ if in.Id != projects[i].Id {
|
|
|
227
|
+ ids := projects[i].Recipients
|
|
|
228
|
+ for j := range ids {
|
|
|
229
|
+ rids[ids[j]] = true
|
|
|
230
|
+ }
|
|
|
231
|
+ }
|
|
|
232
|
+ }
|
|
|
233
|
+ repeatNum := 0
|
|
|
234
|
+ for i := range in.Recipients {
|
|
|
235
|
+ id := in.Recipients[i]
|
|
|
236
|
+ if _, ok := rids[id]; ok {
|
|
|
237
|
+ repeatNum++
|
|
|
238
|
+ }
|
|
|
239
|
+ }
|
|
|
240
|
+ if repeatNum > 0 {
|
|
|
241
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum))
|
|
|
242
|
+ }
|
187
|
|
243
|
|
188
|
- start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local)
|
|
|
189
|
- if err != nil {
|
|
|
190
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
191
|
- }
|
|
|
192
|
- end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local)
|
|
|
193
|
- if err != nil {
|
|
|
194
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
195
|
- }
|
|
|
196
|
- kpiStart, err := time.ParseInLocation("2006-01-02 15:04:05", in.KpiResultStart, time.Local)
|
|
|
197
|
- if err != nil {
|
|
|
198
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
199
|
- }
|
244
|
+ cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true})
|
|
|
245
|
+ if err != nil {
|
|
|
246
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
247
|
+ }
|
|
|
248
|
+ if cycleTemplate == nil || cycleTemplate.Template == nil {
|
|
|
249
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加模板")
|
|
|
250
|
+ }
|
200
|
|
251
|
|
201
|
- minTime := cycle.TimeStart.Local()
|
|
|
202
|
- maxTime := cycle.TimeEnd.Local()
|
252
|
+ start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local)
|
|
|
253
|
+ if err != nil {
|
|
|
254
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
255
|
+ }
|
|
|
256
|
+ end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local)
|
|
|
257
|
+ if err != nil {
|
|
|
258
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
259
|
+ }
|
203
|
|
260
|
|
204
|
- if start.Before(minTime) {
|
|
|
205
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, "评估起始时间不能超出周期起始时间")
|
|
|
206
|
- }
|
261
|
+ cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": in.CycleId})
|
|
|
262
|
+ if err != nil {
|
|
|
263
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
264
|
+ }
|
|
|
265
|
+ minTime := cycle.TimeStart.Local()
|
|
|
266
|
+ maxTime := cycle.TimeEnd.Local()
|
207
|
|
267
|
|
208
|
- if end.After(maxTime) {
|
|
|
209
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间")
|
|
|
210
|
- }
|
268
|
+ if start.Before(minTime) {
|
|
|
269
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "评估起始时间不能超出周期起始时间")
|
|
|
270
|
+ }
|
211
|
|
271
|
|
212
|
- //// FIXME 启动时,需要激活定时任务
|
|
|
213
|
- //if in.Activate == 1 {
|
|
|
214
|
- // project.State = domain.ProjectStateEnable
|
|
|
215
|
- //} else {
|
|
|
216
|
- // project.State = domain.ProjectStateWaitActive
|
|
|
217
|
- //}
|
|
|
218
|
- project.State = domain.ProjectStateWaitActive
|
272
|
+ if end.After(maxTime) {
|
|
|
273
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间")
|
|
|
274
|
+ }
|
219
|
|
275
|
|
220
|
- project.Recipients = in.Recipients
|
|
|
221
|
- project.Template = cycleTemplate.Template
|
|
|
222
|
- for i := range project.Template.LinkNodes {
|
|
|
223
|
- node := project.Template.LinkNodes[i]
|
|
|
224
|
- node.KpiCycle = in.KpiCycle // 设置周期
|
|
|
225
|
- if node.Type == domain.LinkNodeViewResult {
|
|
|
226
|
- node.TimeStart = &kpiStart
|
|
|
227
|
- node.TimeEnd = &maxTime // 绩效查看时间跟随周期截止时间
|
|
|
228
|
- } else {
|
276
|
+ if project.State == domain.ProjectStateWaitConfig {
|
|
|
277
|
+ project.State = domain.ProjectStateWaitActive
|
|
|
278
|
+ }
|
|
|
279
|
+ project.Recipients = in.Recipients
|
|
|
280
|
+ project.Template = cycleTemplate.Template
|
|
|
281
|
+
|
|
|
282
|
+ // 项目起始截止时间(环节中的时间暂未分开计算)
|
|
|
283
|
+ project.BeginTime = start
|
|
|
284
|
+ project.EndTime = end
|
|
|
285
|
+ for i := range project.Template.LinkNodes {
|
|
|
286
|
+ node := project.Template.LinkNodes[i]
|
|
|
287
|
+ node.KpiCycle = in.KpiCycle // 设置周期
|
229
|
node.TimeStart = &start
|
288
|
node.TimeStart = &start
|
230
|
node.TimeEnd = &end
|
289
|
node.TimeEnd = &end
|
231
|
}
|
290
|
}
|
232
|
- }
|
|
|
233
|
|
291
|
|
234
|
- project, err = projectRepository.Insert(project)
|
|
|
235
|
- if err != nil {
|
|
|
236
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
237
|
- }
|
|
|
238
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
239
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
292
|
+ project, err = projectRepository.Insert(project)
|
|
|
293
|
+ if err != nil {
|
|
|
294
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
295
|
+ }
|
|
|
296
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
297
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
298
|
+ }
|
|
|
299
|
+ return project, nil
|
240
|
}
|
300
|
}
|
241
|
- return project, nil
|
|
|
242
|
}
|
301
|
}
|
243
|
|
302
|
|
244
|
func (rs *EvaluationProjectService) Get(in *command.GetProjectCommand) (interface{}, error) {
|
303
|
func (rs *EvaluationProjectService) Get(in *command.GetProjectCommand) (interface{}, error) {
|
|
@@ -285,6 +344,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in |
|
@@ -285,6 +344,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in |
285
|
}()
|
344
|
}()
|
286
|
|
345
|
|
287
|
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
|
346
|
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
347
|
+ taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
|
288
|
|
348
|
|
289
|
project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
|
349
|
project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
|
290
|
if err != nil {
|
350
|
if err != nil {
|
|
@@ -294,6 +354,17 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in |
|
@@ -294,6 +354,17 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in |
294
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
354
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
295
|
}
|
355
|
}
|
296
|
|
356
|
|
|
|
357
|
+ // 查看任务过程,移除项目关联的所有任务
|
|
|
358
|
+ tasks, err := taskRepository.Find(map[string]interface{}{"projectId": in.Id})
|
|
|
359
|
+ if err != nil {
|
|
|
360
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
361
|
+ }
|
|
|
362
|
+ for i := range tasks {
|
|
|
363
|
+ if _, err := taskRepository.Remove(tasks[i]); err != nil {
|
|
|
364
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
365
|
+ }
|
|
|
366
|
+ }
|
|
|
367
|
+
|
297
|
if err := transactionContext.CommitTransaction(); err != nil {
|
368
|
if err := transactionContext.CommitTransaction(); err != nil {
|
298
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
369
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
299
|
}
|
370
|
}
|
|
@@ -314,6 +385,8 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter |
|
@@ -314,6 +385,8 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter |
314
|
if err != nil {
|
385
|
if err != nil {
|
315
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
386
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
316
|
}
|
387
|
}
|
|
|
388
|
+
|
|
|
389
|
+ now := time.Now().Unix()
|
317
|
pmpUsers := make([]*domain.User, 0)
|
390
|
pmpUsers := make([]*domain.User, 0)
|
318
|
pmpUserIds := make([]int64, 0)
|
391
|
pmpUserIds := make([]int64, 0)
|
319
|
for i := range projects {
|
392
|
for i := range projects {
|
|
@@ -322,7 +395,13 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter |
|
@@ -322,7 +395,13 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter |
322
|
userId, _ := strconv.ParseInt(project.PmpIds[j], 10, 64)
|
395
|
userId, _ := strconv.ParseInt(project.PmpIds[j], 10, 64)
|
323
|
pmpUserIds = append(pmpUserIds, userId)
|
396
|
pmpUserIds = append(pmpUserIds, userId)
|
324
|
}
|
397
|
}
|
|
|
398
|
+
|
|
|
399
|
+ // 当前时间超过截至时间显示【已结束】
|
|
|
400
|
+ if now > project.EndTime.Unix() {
|
|
|
401
|
+ project.State = domain.ProjectStateDisable
|
|
|
402
|
+ }
|
325
|
}
|
403
|
}
|
|
|
404
|
+
|
326
|
if len(pmpUserIds) > 0 {
|
405
|
if len(pmpUserIds) > 0 {
|
327
|
userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
406
|
userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
328
|
_, users, _ := userRepository.Find(map[string]interface{}{"ids": pmpUserIds, "limit": len(pmpUserIds)})
|
407
|
_, users, _ := userRepository.Find(map[string]interface{}{"ids": pmpUserIds, "limit": len(pmpUserIds)})
|
|
@@ -342,29 +421,20 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) |
|
@@ -342,29 +421,20 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) |
342
|
}()
|
421
|
}()
|
343
|
|
422
|
|
344
|
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
|
423
|
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
|
345
|
- //cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
346
|
|
424
|
|
347
|
project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
|
425
|
project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
|
348
|
if err != nil {
|
426
|
if err != nil {
|
349
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
427
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
350
|
}
|
428
|
}
|
351
|
-
|
|
|
352
|
if project.Template == nil {
|
429
|
if project.Template == nil {
|
353
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加评估模板")
|
430
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加评估模板")
|
354
|
}
|
431
|
}
|
355
|
-
|
|
|
356
|
if len(project.Recipients) == 0 {
|
432
|
if len(project.Recipients) == 0 {
|
357
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人")
|
433
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人")
|
358
|
}
|
434
|
}
|
359
|
if project.State == domain.TemplateStateEnable {
|
435
|
if project.State == domain.TemplateStateEnable {
|
360
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动")
|
436
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动")
|
361
|
}
|
437
|
}
|
362
|
- //cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": project.CycleId})
|
|
|
363
|
- //if err != nil {
|
|
|
364
|
- // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
365
|
- //}
|
|
|
366
|
- //startMin := cycle.TimeStart
|
|
|
367
|
- //maxTime := cycle.TimeEnd
|
|
|
368
|
|
438
|
|
369
|
project.State = domain.TemplateStateEnable
|
439
|
project.State = domain.TemplateStateEnable
|
370
|
project, err = projectRepository.Insert(project)
|
440
|
project, err = projectRepository.Insert(project)
|
|
@@ -422,42 +492,6 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) |
|
@@ -422,42 +492,6 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) |
422
|
return project, nil
|
492
|
return project, nil
|
423
|
}
|
493
|
}
|
424
|
|
494
|
|
425
|
-//
|
|
|
426
|
-//// 0点时刻为标准计算
|
|
|
427
|
-//func (rs *EvaluationProjectService) nextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time {
|
|
|
428
|
-// // 起始时间0点时刻
|
|
|
429
|
-// start0 := time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
|
|
|
430
|
-//
|
|
|
431
|
-// var nextTime time.Time
|
|
|
432
|
-// switch kpiCycle {
|
|
|
433
|
-// case domain.KpiCycleDay:
|
|
|
434
|
-// nextTime = timeconv.AddDate(now0, 0, 0, 1) // 当前时间的下一天开始发送
|
|
|
435
|
-// break
|
|
|
436
|
-// case domain.KpiCycleWeek:
|
|
|
437
|
-// offsetSeconds := int64(now0.Sub(start0).Seconds())
|
|
|
438
|
-// offsetDay := offsetSeconds / (24 * 60 * 60)
|
|
|
439
|
-// cycleCount := int(offsetDay)/7 + 1
|
|
|
440
|
-// nextTime = timeconv.AddDate(start0, 0, 0, cycleCount*7)
|
|
|
441
|
-// break
|
|
|
442
|
-// case domain.KpiCycleOneMonth:
|
|
|
443
|
-// nextTime = timeconv.AddDate(start0, 0, 1, 0)
|
|
|
444
|
-// break
|
|
|
445
|
-// case domain.KpiCycleTwoMonth:
|
|
|
446
|
-// nextTime = timeconv.AddDate(start0, 0, 2, 0)
|
|
|
447
|
-// break
|
|
|
448
|
-// case domain.KpiCycleThreeMonth:
|
|
|
449
|
-// nextTime = timeconv.AddDate(start0, 0, 3, 0)
|
|
|
450
|
-// break
|
|
|
451
|
-// case domain.KpiCycleSixMonth:
|
|
|
452
|
-// nextTime = timeconv.AddDate(start0, 0, 6, 0)
|
|
|
453
|
-// break
|
|
|
454
|
-// case domain.KpiCycleYear:
|
|
|
455
|
-// nextTime = timeconv.AddDate(start0, 1, 0, 0)
|
|
|
456
|
-// break
|
|
|
457
|
-// }
|
|
|
458
|
-// return nextTime
|
|
|
459
|
-//}
|
|
|
460
|
-
|
|
|
461
|
func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) {
|
495
|
func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) {
|
462
|
transactionContext, err := factory.ValidateStartTransaction(in)
|
496
|
transactionContext, err := factory.ValidateStartTransaction(in)
|
463
|
if err != nil {
|
497
|
if err != nil {
|