1
|
package service
|
1
|
package service
|
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
|
|
4
|
+ "fmt"
|
4
|
"time"
|
5
|
"time"
|
5
|
|
6
|
|
6
|
"github.com/linmadan/egglib-go/core/application"
|
7
|
"github.com/linmadan/egglib-go/core/application"
|
|
@@ -266,19 +267,18 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev |
|
@@ -266,19 +267,18 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev |
266
|
Remark: "",
|
267
|
Remark: "",
|
267
|
}
|
268
|
}
|
268
|
value, ok := valueMap[v.Id]
|
269
|
value, ok := valueMap[v.Id]
|
269
|
- if !ok {
|
|
|
270
|
- continue
|
270
|
+ if ok {
|
|
|
271
|
+ item.Score = value.Score
|
|
|
272
|
+ item.Value = value.Value
|
|
|
273
|
+ item.Remark = value.Remark
|
271
|
}
|
274
|
}
|
272
|
- item.Score = value.Score
|
|
|
273
|
- item.Value = value.Value
|
|
|
274
|
- item.Remark = value.Remark
|
|
|
275
|
itemValues = append(itemValues, item)
|
275
|
itemValues = append(itemValues, item)
|
276
|
}
|
276
|
}
|
277
|
return itemValues
|
277
|
return itemValues
|
278
|
}
|
278
|
}
|
279
|
|
279
|
|
280
|
// 获取综合自评详情
|
280
|
// 获取综合自评详情
|
281
|
-func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvaluationInfo) (*adapter.EvaluationInfoAdapter, error) {
|
281
|
+func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvaluation) (*adapter.EvaluationInfoAdapter, error) {
|
282
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
282
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
283
|
if err != nil {
|
283
|
if err != nil {
|
284
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
284
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -301,7 +301,7 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
@@ -301,7 +301,7 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
301
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
301
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
302
|
"limit": 1,
|
302
|
"limit": 1,
|
303
|
"cycleId": param.CompanyId,
|
303
|
"cycleId": param.CompanyId,
|
304
|
- "executorId": param.ExecutorId,
|
304
|
+ "executorId": param.UserId,
|
305
|
"types": domain.EvaluationSelf,
|
305
|
"types": domain.EvaluationSelf,
|
306
|
})
|
306
|
})
|
307
|
if err != nil {
|
307
|
if err != nil {
|
|
@@ -326,12 +326,17 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
@@ -326,12 +326,17 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
326
|
if err != nil {
|
326
|
if err != nil {
|
327
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
327
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
328
|
}
|
328
|
}
|
329
|
-
|
329
|
+ result := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
330
|
if err := transactionContext.CommitTransaction(); err != nil {
|
330
|
if err := transactionContext.CommitTransaction(); err != nil {
|
331
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
331
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
332
|
}
|
332
|
}
|
333
|
|
333
|
|
334
|
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
334
|
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
|
|
335
|
+ result.EvaluationItems = itemValuesAdapter
|
|
|
336
|
+ return result, nil
|
|
|
337
|
+}
|
|
|
338
|
+
|
|
|
339
|
+func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) *adapter.EvaluationInfoAdapter {
|
335
|
result := adapter.EvaluationInfoAdapter{
|
340
|
result := adapter.EvaluationInfoAdapter{
|
336
|
SummaryEvaluationId: evaluationData.Id,
|
341
|
SummaryEvaluationId: evaluationData.Id,
|
337
|
CycleId: int(evaluationData.CycleId),
|
342
|
CycleId: int(evaluationData.CycleId),
|
|
@@ -343,10 +348,50 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
@@ -343,10 +348,50 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
343
|
EndTime: evaluationData.EndTime.Format("2006-01-02 15:04:05"),
|
348
|
EndTime: evaluationData.EndTime.Format("2006-01-02 15:04:05"),
|
344
|
TargetUserId: evaluationData.TargetUser.UserId,
|
349
|
TargetUserId: evaluationData.TargetUser.UserId,
|
345
|
TargetUserName: evaluationData.TargetUser.UserName,
|
350
|
TargetUserName: evaluationData.TargetUser.UserName,
|
|
|
351
|
+ CompanyLogo: "",
|
|
|
352
|
+ CompanyName: "",
|
|
|
353
|
+ SupperUser: "",
|
|
|
354
|
+ DutyTime: "",
|
346
|
Status: string(evaluationData.Status),
|
355
|
Status: string(evaluationData.Status),
|
347
|
- EvaluationItems: itemValuesAdapter,
|
356
|
+ EvaluationItems: []adapter.EvaluationItemAdapter{},
|
348
|
}
|
357
|
}
|
349
|
- return &result, nil
|
358
|
+ //获取用户信息
|
|
|
359
|
+ companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
360
|
+ "transactionContext": transactionContext,
|
|
|
361
|
+ })
|
|
|
362
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
363
|
+ "transactionContext": transactionContext,
|
|
|
364
|
+ })
|
|
|
365
|
+
|
|
|
366
|
+ companyData, err := companyRepo.FindOne(map[string]interface{}{
|
|
|
367
|
+ "id": evaluationData.CompanyId,
|
|
|
368
|
+ })
|
|
|
369
|
+
|
|
|
370
|
+ if err != nil {
|
|
|
371
|
+ return &result
|
|
|
372
|
+ }
|
|
|
373
|
+
|
|
|
374
|
+ userData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
375
|
+ "id": evaluationData.TargetUser.UserId,
|
|
|
376
|
+ })
|
|
|
377
|
+ if err != nil {
|
|
|
378
|
+ return &result
|
|
|
379
|
+ }
|
|
|
380
|
+ result.DutyTime = userData.EntryTime
|
|
|
381
|
+ result.CompanyLogo = companyData.Logo
|
|
|
382
|
+ result.CompanyName = companyData.Name
|
|
|
383
|
+
|
|
|
384
|
+ if userData.ParentId <= 0 {
|
|
|
385
|
+ return &result
|
|
|
386
|
+ }
|
|
|
387
|
+ pUserData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
388
|
+ "id": userData.ParentId,
|
|
|
389
|
+ })
|
|
|
390
|
+ if err != nil {
|
|
|
391
|
+ return &result
|
|
|
392
|
+ }
|
|
|
393
|
+ result.SupperUser = pUserData.Name
|
|
|
394
|
+ return &result
|
350
|
}
|
395
|
}
|
351
|
|
396
|
|
352
|
// 编辑综合自评详情
|
397
|
// 编辑综合自评详情
|
|
@@ -377,6 +422,10 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
|
@@ -377,6 +422,10 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
377
|
if err != nil {
|
422
|
if err != nil {
|
378
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
423
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
379
|
}
|
424
|
}
|
|
|
425
|
+ if evaluationData.Types != domain.EvaluationSelf {
|
|
|
426
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
427
|
+ }
|
|
|
428
|
+
|
380
|
if evaluationData.Executor.UserId != param.ExecutorId {
|
429
|
if evaluationData.Executor.UserId != param.ExecutorId {
|
381
|
|
430
|
|
382
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
431
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
@@ -388,6 +437,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
|
@@ -388,6 +437,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
388
|
|
437
|
|
389
|
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
438
|
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
390
|
"evaluationProjectId": evaluationData.EvaluationProjectId,
|
439
|
"evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
440
|
+ "nodeType": domain.LinkNodeSelfAssessment,
|
391
|
})
|
441
|
})
|
392
|
if err != nil {
|
442
|
if err != nil {
|
393
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
443
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -443,6 +493,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
|
@@ -443,6 +493,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
443
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
493
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
444
|
}
|
494
|
}
|
445
|
evaluationData.UpdatedAt = nowTime
|
495
|
evaluationData.UpdatedAt = nowTime
|
|
|
496
|
+ evaluationData.Status = domain.EvaluationCompleted
|
446
|
//保存填写值
|
497
|
//保存填写值
|
447
|
err = evaluationRepo.Save(evaluationData)
|
498
|
err = evaluationRepo.Save(evaluationData)
|
448
|
if err != nil {
|
499
|
if err != nil {
|
|
@@ -506,15 +557,23 @@ func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.Query |
|
@@ -506,15 +557,23 @@ func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.Query |
506
|
}
|
557
|
}
|
507
|
|
558
|
|
508
|
// 自评小结详情
|
559
|
// 自评小结详情
|
509
|
-func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluationInfo) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
510
|
-
|
560
|
+func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluation) (*adapter.EvaluationInfoAdapter, error) {
|
511
|
evaluationInfo, err := srv.GetEvaluationSelf(param)
|
561
|
evaluationInfo, err := srv.GetEvaluationSelf(param)
|
512
|
if err != nil {
|
562
|
if err != nil {
|
513
|
return nil, err
|
563
|
return nil, err
|
514
|
}
|
564
|
}
|
515
|
-
|
|
|
516
|
- _ = evaluationInfo
|
|
|
517
|
- //TODO 组装等级数量统计
|
565
|
+ levelCodeMap := map[int][]adapter.LevalCodeCount{}
|
|
|
566
|
+ for _, v := range evaluationInfo.EvaluationItems {
|
|
|
567
|
+ codes := v.Rule.GetLevelCodes()
|
|
|
568
|
+ levelCode := []adapter.LevalCodeCount{}
|
|
|
569
|
+ for _, v2 := range codes {
|
|
|
570
|
+ levelCode = append(levelCode, adapter.LevalCodeCount{
|
|
|
571
|
+ Code: v2,
|
|
|
572
|
+ Number: 0,
|
|
|
573
|
+ })
|
|
|
574
|
+ }
|
|
|
575
|
+ levelCodeMap[v.EvaluationItemId] = levelCode
|
|
|
576
|
+ }
|
518
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
577
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
519
|
if err != nil {
|
578
|
if err != nil {
|
520
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
579
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -526,8 +585,42 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que |
|
@@ -526,8 +585,42 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que |
526
|
_ = transactionContext.RollbackTransaction()
|
585
|
_ = transactionContext.RollbackTransaction()
|
527
|
}()
|
586
|
}()
|
528
|
|
587
|
|
|
|
588
|
+ //统计周期内,评估项等级的数量
|
|
|
589
|
+ assessDao := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
590
|
+ "transactionContext": transactionContext,
|
|
|
591
|
+ })
|
|
|
592
|
+ levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.UserId, domain.AssessSelf, param.CycleId)
|
|
|
593
|
+ if err != nil {
|
|
|
594
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
595
|
+ }
|
|
|
596
|
+
|
|
|
597
|
+ levelCodeCountMap := map[string]int{}
|
|
|
598
|
+ for _, v := range levelCodeCountList {
|
|
|
599
|
+ key := fmt.Sprintf("%s-%s-%s", v.Category, v.Name, v.LevelValue)
|
|
|
600
|
+ levelCodeCountMap[key] = v.Cnt
|
|
|
601
|
+ }
|
|
|
602
|
+
|
|
|
603
|
+ for i := range evaluationInfo.EvaluationItems {
|
|
|
604
|
+ itemId := evaluationInfo.EvaluationItems[i].EvaluationItemId
|
|
|
605
|
+ levelCodes, ok := levelCodeMap[itemId]
|
|
|
606
|
+ if !ok {
|
|
|
607
|
+ continue
|
|
|
608
|
+ }
|
|
|
609
|
+ evaluationInfo.EvaluationItems[i].LevelCount = levelCodes
|
|
|
610
|
+ for i2 := range levelCodes {
|
|
|
611
|
+ key := fmt.Sprintf("%s-%s-%s",
|
|
|
612
|
+ evaluationInfo.EvaluationItems[i].Category,
|
|
|
613
|
+ evaluationInfo.EvaluationItems[i].Name,
|
|
|
614
|
+ levelCodes[i2].Code,
|
|
|
615
|
+ )
|
|
|
616
|
+
|
|
|
617
|
+ if mVal, ok := levelCodeCountMap[key]; ok {
|
|
|
618
|
+ levelCodes[i2].Number = mVal
|
|
|
619
|
+ }
|
|
|
620
|
+ }
|
|
|
621
|
+ }
|
529
|
if err := transactionContext.CommitTransaction(); err != nil {
|
622
|
if err := transactionContext.CommitTransaction(); err != nil {
|
530
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
623
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
531
|
}
|
624
|
}
|
532
|
- return nil, nil
|
625
|
+ return evaluationInfo, nil
|
533
|
} |
626
|
} |