|
@@ -582,30 +582,108 @@ func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessConten |
|
@@ -582,30 +582,108 @@ func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessConten |
582
|
|
582
|
|
583
|
// 根据周期id和日期获取 员工填写评估内容;项目管理-成员列表
|
583
|
// 根据周期id和日期获取 员工填写评估内容;项目管理-成员列表
|
584
|
// 有过滤查看权限
|
584
|
// 有过滤查看权限
|
585
|
-// func (srv StaffAssessServeice) ListUserAssessContentCycleDayV2(param *query.ListAssessContentCycleDay) (*adapter.ListUserAssessContent, error) {
|
|
|
586
|
-// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
587
|
-// if err != nil {
|
|
|
588
|
-// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
589
|
-// }
|
|
|
590
|
-// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
591
|
-// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
592
|
-// }
|
|
|
593
|
-// defer func() {
|
|
|
594
|
-// _ = transactionContext.RollbackTransaction()
|
|
|
595
|
-// }()
|
|
|
596
|
-// hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperaterId)
|
|
|
597
|
-// if err != nil {
|
|
|
598
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
599
|
-// }
|
585
|
+func (srv StaffAssessServeice) ListUserAssessContentCycleDayV2(param *query.ListAssessContentCycleDay) (*adapter.ListUserAssessContent, error) {
|
|
|
586
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
587
|
+ if err != nil {
|
|
|
588
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
589
|
+ }
|
|
|
590
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
591
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
592
|
+ }
|
|
|
593
|
+ defer func() {
|
|
|
594
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
595
|
+ }()
|
|
|
596
|
+ hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperaterId)
|
|
|
597
|
+ if err != nil {
|
|
|
598
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
599
|
+ }
|
|
|
600
|
+
|
|
|
601
|
+ assessDao := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
602
|
+ "transactionContext": transactionContext,
|
|
|
603
|
+ })
|
600
|
|
604
|
|
601
|
-// assessDao := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
602
|
-// "transactionContext": transactionContext,
|
|
|
603
|
-// })
|
605
|
+ limit := param.PageSize
|
|
|
606
|
+ offset := (param.PageNumber - 1) * limit
|
|
|
607
|
+ if offset < 0 {
|
|
|
608
|
+ offset = 0
|
|
|
609
|
+ }
|
|
|
610
|
+ // 总数----------
|
|
|
611
|
+ cnt, err := assessDao.CountUserSelfStaffAssess(dao.SearchConditin3{
|
|
|
612
|
+ CompanyId: param.CompanyId,
|
|
|
613
|
+ CycleId: param.CycleId,
|
|
|
614
|
+ BeginDay: param.BeginDay,
|
|
|
615
|
+ TargetUserName: param.TargetUserName,
|
|
|
616
|
+ OperaterId: param.OperaterId,
|
|
|
617
|
+ Hrbp: hrbp,
|
|
|
618
|
+ Status: "",
|
|
|
619
|
+ })
|
|
|
620
|
+ if err != nil {
|
|
|
621
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计总数"+err.Error())
|
|
|
622
|
+ }
|
|
|
623
|
+ contentList, err := assessDao.SearchUserAssessContentV2(dao.SearchConditin3{
|
|
|
624
|
+ CompanyId: param.CompanyId,
|
|
|
625
|
+ CycleId: param.CycleId,
|
|
|
626
|
+ BeginDay: param.BeginDay,
|
|
|
627
|
+ TargetUserName: param.TargetUserName,
|
|
|
628
|
+ Limit: limit,
|
|
|
629
|
+ Offset: offset,
|
|
|
630
|
+ OperaterId: param.OperaterId,
|
|
|
631
|
+ Hrbp: hrbp,
|
|
|
632
|
+ })
|
|
|
633
|
+ if err != nil {
|
|
|
634
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取数据列表"+err.Error())
|
|
|
635
|
+ }
|
|
|
636
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
637
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
638
|
+ }
|
|
|
639
|
+ log.Logger.Debug(fmt.Sprintf("获取到的数据列表%d", len(contentList)))
|
|
|
640
|
+ //可变的表格列
|
|
|
641
|
+ changeableHeader := []adapter.ListTableHeader{
|
|
|
642
|
+ {Key: "targetUserName", Name: "姓名"}, //固定列
|
|
|
643
|
+ }
|
|
|
644
|
+ //过滤重复的列
|
|
|
645
|
+ headerMap := map[string]string{}
|
|
|
646
|
+ // 获取已经填报的内容
|
|
|
647
|
+ changeableRows := map[string]map[string]interface{}{}
|
|
|
648
|
+ tableSort := []string{} //确定列表行数据的顺序
|
|
|
649
|
+ for i, v := range contentList {
|
|
|
650
|
+ if _, ok := changeableRows[v.TargetUserId]; !ok {
|
|
|
651
|
+ changeableRows[v.TargetUserId] = map[string]interface{}{}
|
|
|
652
|
+ tableSort = append(tableSort, v.TargetUserId)
|
|
|
653
|
+ }
|
|
|
654
|
+ changeableRows[v.TargetUserId]["targetUserName"] = v.TargetUserName
|
|
|
655
|
+ changeableRows[v.TargetUserId]["targetUserId"] = v.TargetUserId
|
|
|
656
|
+ changeableRows[v.TargetUserId]["assessId"] = v.AssessId
|
|
|
657
|
+ changeableRows[v.TargetUserId]["cycleId"] = v.CycleId
|
|
|
658
|
+ changeableRows[v.TargetUserId]["beginDay"] = v.BeginDay
|
|
|
659
|
+ if v.ContentId > 0 {
|
|
|
660
|
+ name := fmt.Sprintf("%s-%s", v.Category, v.ContentName)
|
|
|
661
|
+ key := fmt.Sprintf("k%d", i)
|
|
|
662
|
+ if _, ok := headerMap[name]; !ok {
|
|
|
663
|
+ changeableHeader = append(changeableHeader, adapter.ListTableHeader{
|
|
|
664
|
+ Key: key, Name: name,
|
|
|
665
|
+ })
|
|
|
666
|
+ headerMap[name] = key
|
|
|
667
|
+ }
|
|
|
668
|
+ key = headerMap[name]
|
|
|
669
|
+ changeableRows[v.TargetUserId][key] = v.Value
|
|
|
670
|
+ }
|
|
|
671
|
+ }
|
|
|
672
|
+ list := []map[string]interface{}{}
|
|
|
673
|
+ for _, v := range tableSort {
|
|
|
674
|
+ for _, v2 := range changeableHeader {
|
|
|
675
|
+ if _, ok := changeableRows[v][v2.Key]; ok {
|
|
|
676
|
+ continue
|
|
|
677
|
+ }
|
|
|
678
|
+ changeableRows[v][v2.Key] = ""
|
|
|
679
|
+ }
|
|
|
680
|
+ list = append(list, changeableRows[v])
|
|
|
681
|
+ }
|
|
|
682
|
+ result := adapter.ListUserAssessContent{
|
|
|
683
|
+ TableHeader: changeableHeader,
|
|
|
684
|
+ Total: cnt,
|
|
|
685
|
+ List: list,
|
|
|
686
|
+ }
|
604
|
|
687
|
|
605
|
-// limit := param.PageSize
|
|
|
606
|
-// offset := (param.PageNumber - 1) * limit
|
|
|
607
|
-// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
608
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
609
|
-// }
|
|
|
610
|
-// return nil, nil
|
|
|
611
|
-// } |
688
|
+ return &result, nil
|
|
|
689
|
+} |