作者 tangxvhui

Merge branch 'test'

正在显示 29 个修改的文件 包含 1184 行增加223 行删除
不能预览此文件类型
  1 +package adapter
  2 +
  3 +type AssessCycleDayResp struct {
  4 + CycleId int `json:"cycleId"`
  5 + CycleName string `json:"cycleName"`
  6 + BeginDay string `json:"beginDay"`
  7 +}
  1 +package adapter
  2 +
  3 +type AssessCycleDescResp struct {
  4 + CycleId int `json:"cycleId"`
  5 + CycleName string `json:"cycleName"` //周期名称
  6 + BeginDay string `json:"beginDay"` //开始的日期
  7 + StepList []AssessTaskStep `json:"stepList"` //考评流程
  8 +}
  9 +
  10 +type AssessCycleStep struct {
  11 + SortBy int `json:"sortBy"` //排序
  12 + LinkNodeId int `json:"linkNodeId"` //流程id
  13 + LinkNodeName string `json:"linkNodeName"` //流程名称
  14 + BeginTime string `json:"beginTime"` //开始时间时间
  15 + EndTime string `json:"endTime"` //结束时间
  16 + LinkNodeType int `json:"linkNodeType"` //流程类型
  17 + Desc string `json:"desc"` //情况描述
  18 + Status string `json:"status"` //流程是否完成 "":未参加,"uncompleted":未完成,"completed":完成
  19 +}
@@ -4,6 +4,8 @@ type ListInviteUserAssessResp struct { @@ -4,6 +4,8 @@ type ListInviteUserAssessResp struct {
4 LinkNodeName string `json:"linkNodeName"` 4 LinkNodeName string `json:"linkNodeName"`
5 LinkNodeId int `json:"linkNodeId"` 5 LinkNodeId int `json:"linkNodeId"`
6 LintNodeDesc string `json:"lintNodeDesc"` 6 LintNodeDesc string `json:"lintNodeDesc"`
  7 + BeginDay string `json:"beginDay"`
  8 + CycleId int `json:"cycleId"`
7 TableHeader []ListTableHeader `json:"tableHeader"` 9 TableHeader []ListTableHeader `json:"tableHeader"`
8 List []map[string]string `json:"list"` 10 List []map[string]string `json:"list"`
9 Total int `json:"total"` 11 Total int `json:"total"`
1 package adapter 1 package adapter
2 2
3 type ListSupperAssessResp struct { 3 type ListSupperAssessResp struct {
4 - AssessId int `json:"assessId"` //  
5 - UsrId int `json:"userId,string"` 4 + AssessId int `json:"assessId"` //
  5 + CycleId int `json:"cycleId"` //周期id
  6 + BeginDay string `json:"beginDay"` //开始的日期
  7 + UserId int `json:"userId,string"` //用户id
6 UserName string `json:"userName"` //用户名称 8 UserName string `json:"userName"` //用户名称
7 EndTime string `json:"endTime"` //截止时间 9 EndTime string `json:"endTime"` //截止时间
8 InviteTotal int `json:"inviteTota"` //邀请总数 10 InviteTotal int `json:"inviteTota"` //邀请总数
9 InviteCompleted int `json:"inviteCompleted"` //邀请未完成 11 InviteCompleted int `json:"inviteCompleted"` //邀请未完成
10 - Status string `json:"status"`  
11 - Department string `json:"department"` //部门  
12 - Position string `json:"position"` //职位  
13 - DutyTime string `json:"dutyTime"` //入职时间 12 + Status string `json:"status"` //评估任务是否填写完成
  13 + Department string `json:"department"` //部门
  14 + Position string `json:"position"` //职位
  15 + DutyTime string `json:"dutyTime"` //入职时间
14 } 16 }
@@ -5,3 +5,11 @@ type AssessTaskDescQuery struct { @@ -5,3 +5,11 @@ type AssessTaskDescQuery struct {
5 UserId int `json:"userId"` //当前登录人的id 5 UserId int `json:"userId"` //当前登录人的id
6 CompanyId int `json:"companyId"` //当前登录的公司 6 CompanyId int `json:"companyId"` //当前登录的公司
7 } 7 }
  8 +
  9 +//获取我的项目周期进度描述
  10 +type AssessTaskDescV2Query struct {
  11 + CycleId int `json:"cycleId"`
  12 + BeginDay string `json:"beginDay"`
  13 + UserId int `json:"userId"` //当前登录人的id
  14 + CompanyId int `json:"companyId"` //当前登录的公司
  15 +}
  1 +package query
  2 +
  3 +// 根据周期和日期,获取员工的自评内容
  4 +type GetExecutorSelfAssessQuery struct {
  5 + CompanyId int `json:"companyId"` //
  6 + TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填
  7 + CycleId int `json:"cycleId"` //评估周期id 必填
  8 + BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
  9 +}
  1 +package query
  2 +
  3 +// 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值
  4 +type ListExecutorAssessQuery struct {
  5 + PageNumber int `json:"pageNumber"`
  6 + PageSize int `json:"pageSize"`
  7 + UserName string `json:"userName"` //查询条件 员工的名称
  8 + CompanyId int `json:"companyId"` //
  9 + ExecutorId int `json:"executorId,string"` //评估的执行人,必填
  10 + CycleId int `json:"cycleId"` //评估周期id 必填
  11 + BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
  12 +}
  1 +package query
  2 +
  3 +//根据周期和日期,获取员工邀请评估的人员
  4 +type ListInviteUserQuery struct {
  5 + CompanyId int `json:"companyId"` //对公司
  6 + TargetUserId int `json:"targetUserId,string"` //被评估的员工id
  7 + CycleId int `json:"CycleId"` //评估任务的周期id
  8 + BeginDay string `json:"beginDay"` //日期
  9 +}
1 package query 1 package query
2 2
  3 +// 获取我的项目周期列表
3 type SearchAssessMeQuery struct { 4 type SearchAssessMeQuery struct {
4 UserId int `json:"userId"` // 当前登录人的用户id 5 UserId int `json:"userId"` // 当前登录人的用户id
5 CompanyId int `json:"companyId"` //当前登录人的公司Id 6 CompanyId int `json:"companyId"` //当前登录人的公司Id
1 package service 1 package service
2 2
3 import ( 3 import (
4 - "time"  
5 -  
6 "github.com/linmadan/egglib-go/core/application" 4 "github.com/linmadan/egglib-go/core/application"
7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 5 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
8 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"  
9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" 6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
10 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"  
11 ) 7 )
12 8
13 //调试用,手动调用CreateStaffAssessTask 9 //调试用,手动调用CreateStaffAssessTask
@@ -32,79 +28,3 @@ func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateS @@ -32,79 +28,3 @@ func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateS
32 } 28 }
33 return data, nil 29 return data, nil
34 } 30 }
35 -  
36 -//保存员工绩效评估填写过程中即写即存的内容  
37 -func (srv StaffAssessServeice) SaveAssessContentTemp(param *command.SaveAssessInfoCommand) (map[string]interface{}, error) {  
38 -  
39 - transactionContext, err := factory.CreateTransactionContext(nil)  
40 - if err != nil {  
41 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
42 - }  
43 - if err := transactionContext.StartTransaction(); err != nil {  
44 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
45 - }  
46 - defer func() {  
47 - _ = transactionContext.RollbackTransaction()  
48 - }()  
49 - //获取旧的临时数据内容  
50 - contentTempRepo := factory.CreateStaffAssessContentTempRepository(map[string]interface{}{  
51 - "transactionContext": transactionContext,  
52 - })  
53 - //获取评估填写的内容  
54 - // assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{  
55 - // "transactionContext": transactionContext,  
56 - // })  
57 - assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{  
58 - "transactionContext": transactionContext,  
59 - })  
60 - assessData, err := assessRepo.FindOne(map[string]interface{}{  
61 - "id": param.AssessId,  
62 - })  
63 - if err != nil {  
64 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())  
65 - }  
66 -  
67 - // staffAssessId  
68 - _, contentTempList, err := contentTempRepo.Find(map[string]interface{}{  
69 - "staffAssessId": param.AssessId,  
70 - })  
71 - if err != nil {  
72 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取临时保存的内容"+err.Error())  
73 - }  
74 - nowTime := time.Now()  
75 - if len(contentTempList) == 0 {  
76 - //获取评估模板  
77 - assessContentList, err := srv.getAssessSelfInfoUncompleted(transactionContext, assessData)  
78 - if err != nil {  
79 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估模板,"+err.Error())  
80 - }  
81 - //转填入临时的数据  
82 - for _, v := range assessContentList {  
83 - item := &domain.StaffAssessContentTemp{  
84 - Id: 0,  
85 - StaffAssessId: v.StaffAssessId,  
86 - SortBy: v.SortBy,  
87 - Category: v.Category,  
88 - Name: v.Name,  
89 - Remark: v.Remark,  
90 - Value: "",  
91 - CreatedAt: nowTime,  
92 - UpdatedAt: nowTime,  
93 - }  
94 - contentTempList = append(contentTempList, item)  
95 - }  
96 - }  
97 - //更新assessContentTemp  
98 - if err := transactionContext.CommitTransaction(); err != nil {  
99 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
100 - }  
101 - return nil, nil  
102 -}  
103 -  
104 -//获取员工绩效评估填写内容  
105 -//临时数据存在时就获取临时数据  
106 -//不存在就获取实际保存的数据  
107 -func (srv StaffAssessServeice) GetAssessContentTemp(param *command.SaveAssessInfoCommand) (*adapter.AssessInfoResp, error) {  
108 - //将临时保存的数据填入模板中  
109 - return nil, nil  
110 -}  
@@ -172,6 +172,7 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs @@ -172,6 +172,7 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs
172 } 172 }
173 changeableRows[v.TargetUserId]["targetUserName"] = v.TargetUserName 173 changeableRows[v.TargetUserId]["targetUserName"] = v.TargetUserName
174 changeableRows[v.TargetUserId]["targetUserId"] = v.TargetUserId 174 changeableRows[v.TargetUserId]["targetUserId"] = v.TargetUserId
  175 + changeableRows[v.TargetUserId]["assessId"] = v.AssessId
175 if v.ContentId > 0 { 176 if v.ContentId > 0 {
176 name := fmt.Sprintf("%s-%s", v.Category, v.ContentName) 177 name := fmt.Sprintf("%s-%s", v.Category, v.ContentName)
177 key := fmt.Sprintf("k%d", i) 178 key := fmt.Sprintf("k%d", i)
@@ -262,6 +263,7 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy @@ -262,6 +263,7 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy
262 CycleId: param.CycleId, 263 CycleId: param.CycleId,
263 BeginDay: param.BeginDay, 264 BeginDay: param.BeginDay,
264 TargetUserName: param.TargetUserName, 265 TargetUserName: param.TargetUserName,
  266 + TargetUserId: param.TargetUserId,
265 Limit: 5000, 267 Limit: 5000,
266 Offset: 0, 268 Offset: 0,
267 OperaterId: param.OperaterId, 269 OperaterId: param.OperaterId,
  1 +package service
  2 +
  3 +import (
  4 + "fmt"
  5 + "strconv"
  6 +
  7 + "github.com/linmadan/egglib-go/core/application"
  8 + "github.com/linmadan/egglib-go/utils/tool_funs"
  9 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  10 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
  11 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
  12 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  13 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
  14 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
  15 +)
  16 +
  17 +//获取我的项目周期列表
  18 +func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
  19 + transactionContext, err := factory.CreateTransactionContext(nil)
  20 + if err != nil {
  21 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  22 + }
  23 + if err := transactionContext.StartTransaction(); err != nil {
  24 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  25 + }
  26 + defer func() {
  27 + _ = transactionContext.RollbackTransaction()
  28 + }()
  29 +
  30 + staffAssessTaskRepo := dao.NewStaffAssessDao(map[string]interface{}{
  31 + "transactionContext": transactionContext,
  32 + })
  33 + var limit int = 200
  34 + var offset int = 0
  35 + if param.PageSize > 0 {
  36 + limit = param.PageSize
  37 + }
  38 + offset = (param.PageNumber - 1) * param.PageSize
  39 + assessCycleList, err := staffAssessTaskRepo.SearchAssessCycleMe(param.UserId, param.CompanyId, limit, offset)
  40 + if err != nil {
  41 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error())
  42 + }
  43 + cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId)
  44 + if err != nil {
  45 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error())
  46 + }
  47 +
  48 + if err := transactionContext.CommitTransaction(); err != nil {
  49 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  50 + }
  51 + listData := make([]adapter.AssessCycleDayResp, 0, len(assessCycleList))
  52 + var temp adapter.AssessCycleDayResp
  53 + for _, v := range assessCycleList {
  54 + temp = adapter.AssessCycleDayResp{
  55 + CycleId: v.CycleId,
  56 + CycleName: v.CycleName,
  57 + BeginDay: v.BeginDay,
  58 + }
  59 + listData = append(listData, temp)
  60 + }
  61 + return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
  62 +}
  63 +
  64 +//获取我的项目周期进度描述
  65 +func (srv StaffAssessServeice) AssessTaskDescV2(param *query.AssessTaskDescV2Query) (*adapter.AssessCycleDescResp, error) {
  66 + transactionContext, err := factory.CreateTransactionContext(nil)
  67 + if err != nil {
  68 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  69 + }
  70 + if err := transactionContext.StartTransaction(); err != nil {
  71 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  72 + }
  73 + defer func() {
  74 + _ = transactionContext.RollbackTransaction()
  75 + }()
  76 + // 获取评估任务
  77 + staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  78 + "transactionContext": transactionContext,
  79 + })
  80 + //获取个人参与的评估流程
  81 + staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  82 + "transactionContext": transactionContext,
  83 + })
  84 +
  85 + _, assessTaskList, err := staffAssessTaskRepo.Find(map[string]interface{}{
  86 + "beginDay": param.BeginDay,
  87 + "cycleId": param.CycleId,
  88 + "companyId": param.CompanyId,
  89 + "limit": 1,
  90 + })
  91 + if err != nil {
  92 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
  93 + }
  94 + if len(assessTaskList) == 0 {
  95 + return &adapter.AssessCycleDescResp{}, nil
  96 + }
  97 + assessTaskDataAny := assessTaskList[0]
  98 + //返回的数据结果
  99 + result := adapter.AssessCycleDescResp{
  100 + CycleId: int(assessTaskDataAny.CycleId),
  101 + CycleName: assessTaskDataAny.CycleName,
  102 + BeginDay: assessTaskDataAny.BeginDay,
  103 + StepList: []adapter.AssessTaskStep{},
  104 + }
  105 +
  106 + for _, v := range assessTaskDataAny.StepList {
  107 + stepItem := adapter.AssessTaskStep{
  108 + SortBy: v.SortBy,
  109 + LinkNodeName: v.LinkNodeName,
  110 + LinkNodeId: v.LinkNodeId,
  111 + BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
  112 + EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
  113 + LinkNodeType: v.LinkNodeType,
  114 + Desc: fmt.Sprintf("截止日期:%s", v.EndTime.Local().Format("2006-01-02 15:04:05")),
  115 + Status: "",
  116 + }
  117 + switch v.LinkNodeType {
  118 + case domain.LinkNodeSelfAssessment:
  119 + //个人自评完成情况
  120 + _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
  121 + "cycleId": assessTaskDataAny.CycleId,
  122 + "beginDay": assessTaskDataAny.BeginDay,
  123 + "executorId": param.UserId, //我作为执行人
  124 + "typesList": []string{string(domain.AssessSelf)},
  125 + })
  126 + if err != nil {
  127 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  128 + }
  129 + if len(assessSelfData) > 0 {
  130 + stepItem.Status = string(assessSelfData[0].Status)
  131 + }
  132 + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
  133 + case domain.LinkNodeAllInvite:
  134 + //邀请别人评估自己
  135 + _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
  136 + "cycleId": assessTaskDataAny.CycleId,
  137 + "beginDay": assessTaskDataAny.BeginDay,
  138 + "targetUserId": param.UserId, //我被作为目标
  139 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  140 + "limit": 5,
  141 + })
  142 + if err != nil {
  143 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  144 + }
  145 + if len(assessInviteData) > 0 {
  146 + stepItem.Status = string(domain.StaffAssessCompleted)
  147 + } else {
  148 + stepItem.Status = string(domain.StaffAssessUncompleted)
  149 + }
  150 + //待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
  151 + if len(assessInviteData) > 5 {
  152 + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
  153 + } else {
  154 + stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
  155 + }
  156 + case domain.LinkNodeAllAssessment:
  157 + //我评估别人,被邀请评估
  158 + _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
  159 + "cycleId": assessTaskDataAny.CycleId,
  160 + "beginDay": assessTaskDataAny.BeginDay,
  161 + "executorId": param.UserId, //我作为执行人
  162 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  163 + })
  164 + if err != nil {
  165 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  166 + }
  167 + if len(assessInviteList) > 0 {
  168 + stepItem.Status = string(domain.StaffAssessCompleted)
  169 + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
  170 + for _, v := range assessInviteList {
  171 + if v.Status == domain.StaffAssessUncompleted {
  172 + stepItem.Status = string(domain.StaffAssessUncompleted)
  173 + break
  174 + }
  175 + }
  176 + }
  177 + case domain.LinkNodeSuperiorAssessment:
  178 + //我评估别人,上级评估
  179 + cnnt, _, err := staffAssessRepo.Find(map[string]interface{}{
  180 + "cycleId": assessTaskDataAny.CycleId,
  181 + "beginDay": assessTaskDataAny.BeginDay,
  182 + "executorId": param.UserId,
  183 + "typesList": []string{string(domain.AssessSuper)},
  184 + "status": domain.StaffAssessUncompleted,
  185 + "limit": 1,
  186 + })
  187 + if err != nil {
  188 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取未完成的评估环节"+err.Error())
  189 + }
  190 + cnnt2, _, err := staffAssessRepo.Find(map[string]interface{}{
  191 + "cycleId": assessTaskDataAny.CycleId,
  192 + "beginDay": assessTaskDataAny.BeginDay,
  193 + "executorId": param.UserId,
  194 + "typesList": []string{string(domain.AssessSuper)},
  195 + "status": domain.StaffAssessCompleted,
  196 + "limit": 1,
  197 + })
  198 + if err != nil {
  199 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取已完成的评估环节"+err.Error())
  200 + }
  201 + if (cnnt + cnnt2) > 0 {
  202 + stepItem.Status = string(domain.StaffAssessCompleted)
  203 + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
  204 + uncompletedNum := cnnt
  205 + if uncompletedNum > 0 {
  206 + stepItem.Status = string(domain.StaffAssessUncompleted)
  207 + stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
  208 + }
  209 + }
  210 + }
  211 + result.StepList = append(result.StepList, stepItem)
  212 + }
  213 + if err := transactionContext.CommitTransaction(); err != nil {
  214 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  215 + }
  216 + return &result, nil
  217 +}
  218 +
  219 +//根据周期获取,我的自评任务添加的邀请人
  220 +func (srv StaffAssessServeice) ListAssessInviteUserV2(param *query.ListInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
  221 + transactionContext, err := factory.CreateTransactionContext(nil)
  222 + if err != nil {
  223 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  224 + }
  225 + if err := transactionContext.StartTransaction(); err != nil {
  226 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  227 + }
  228 + defer func() {
  229 + _ = transactionContext.RollbackTransaction()
  230 + }()
  231 +
  232 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  233 + "transactionContext": transactionContext,
  234 + })
  235 +
  236 + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  237 + "transactionContext": transactionContext,
  238 + })
  239 + _, myAssessTask, err := assessTaskRepo.Find(map[string]interface{}{
  240 + "cycleId": param.CycleId,
  241 + "beginDay": param.BeginDay,
  242 + "executorId": param.TargetUserId,
  243 + "limit": 1,
  244 + })
  245 + if err != nil {
  246 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "我的自评任务不存在,"+err.Error())
  247 + }
  248 +
  249 + if len(myAssessTask) == 0 {
  250 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "未参与本次的自评")
  251 + }
  252 +
  253 + assessTaskData := myAssessTask[0]
  254 +
  255 + _, assessList, err := assessReps.Find(map[string]interface{}{
  256 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  257 + "staffAssessTaskId": assessTaskData.Id,
  258 + "targetUserId": param.TargetUserId,
  259 + })
  260 + if err != nil {
  261 + return nil, application.ThrowError(application.ARG_ERROR, "获取个人邀请列表"+err.Error())
  262 + }
  263 + if err := transactionContext.CommitTransaction(); err != nil {
  264 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  265 + }
  266 +
  267 + result := adapter.AssessInviteUserResp{
  268 + AssessTaskId: assessTaskData.Id,
  269 + InviteDiffSuper: []domain.StaffDesc{},
  270 + InviteSameSuper: []domain.StaffDesc{},
  271 + }
  272 + for _, v := range assessTaskData.StepList {
  273 + if v.LinkNodeType != domain.LinkNodeAllInvite {
  274 + continue
  275 + }
  276 + result.LinkNodeId = v.LinkNodeId
  277 + result.LinkNodeName = v.LinkNodeName
  278 + result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
  279 + result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
  280 + break
  281 + }
  282 + for _, v := range assessList {
  283 + if v.Types == domain.AssessInviteDiffSuper {
  284 + result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
  285 + }
  286 + if v.Types == domain.AssessInviteSameSuper {
  287 + result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
  288 + }
  289 + }
  290 + return &result, nil
  291 +}
  292 +
  293 +// 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值
  294 +func (srv StaffAssessServeice) ListExecutorInviteAssessV2(param *query.ListExecutorAssessQuery) (
  295 + *adapter.ListInviteUserAssessResp, error) {
  296 + transactionContext, err := factory.CreateTransactionContext(nil)
  297 + if err != nil {
  298 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  299 + }
  300 + if err := transactionContext.StartTransaction(); err != nil {
  301 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  302 + }
  303 + defer func() {
  304 + _ = transactionContext.RollbackTransaction()
  305 + }()
  306 + //获取对应的评估任务
  307 + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  308 + "transactionContext": transactionContext,
  309 + })
  310 +
  311 + //获取 executorId 对应的360评估任务 用户
  312 + condition := map[string]interface{}{
  313 + "beginDay": param.BeginDay,
  314 + "cycleId": param.CycleId,
  315 + "executorId": param.ExecutorId,
  316 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  317 + "limit": 20,
  318 + }
  319 + if len(param.UserName) > 0 {
  320 + condition["targetUserName"] = param.UserName
  321 + }
  322 + if param.PageSize > 0 {
  323 + condition["limit"] = param.PageSize
  324 + }
  325 + offset := (param.PageNumber - 1) * param.PageSize
  326 + if offset > 0 {
  327 + condition["offset"] = offset
  328 + }
  329 +
  330 + cnt, assessList, err := assessRepo.Find(condition)
  331 + if err != nil {
  332 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  333 + }
  334 + var assessContentList []*domain.StaffAssessContent
  335 + projectIdMap := map[int]struct{}{}
  336 + //获取评估用的所有评估项
  337 + for i := range assessList {
  338 + if _, ok := projectIdMap[assessList[i].EvaluationProjectId]; ok {
  339 + continue
  340 + }
  341 + projectIdMap[assessList[i].EvaluationProjectId] = struct{}{}
  342 + assessContentListTemp, err := srv.getAssessSelfInfoUncompleted(transactionContext, assessList[i])
  343 + if err != nil {
  344 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())
  345 + }
  346 + assessContentList = append(assessContentList, assessContentListTemp...)
  347 + }
  348 + //可变的表格列
  349 + changeableHeader := []adapter.ListTableHeader{}
  350 + //列名与字段对应
  351 + keyMap := map[string]string{}
  352 + for i, v := range assessContentList {
  353 + name := fmt.Sprintf("%s-%s", v.Category, v.Name)
  354 + key := fmt.Sprintf("k%d", i)
  355 + if _, ok := keyMap[name]; ok {
  356 + continue
  357 + }
  358 + keyMap[name] = key
  359 + changeableHeader = append(changeableHeader, adapter.ListTableHeader{
  360 + Key: key,
  361 + Name: name,
  362 + })
  363 + }
  364 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  365 + "transactionContext": transactionContext,
  366 + })
  367 + // 获取已经填报的内容
  368 + changeableRows := map[int]map[string]string{}
  369 + for _, v := range assessList {
  370 + _, contentList, err := assessContentRepo.Find(map[string]interface{}{
  371 + "staffAssessId": v.Id,
  372 + })
  373 + if err != nil {
  374 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估内容"+err.Error())
  375 + }
  376 + row := map[string]string{}
  377 + for _, vv := range contentList {
  378 + name := fmt.Sprintf("%s-%s", vv.Category, vv.Name)
  379 + if kk, ok := keyMap[name]; ok {
  380 + row[kk] = vv.Value
  381 + }
  382 + }
  383 + changeableRows[v.TargetUser.UserId] = row
  384 + }
  385 +
  386 + //获取360邀请评估完成情况
  387 + //我评估别人,被邀请评估
  388 + cnnt, _, err := assessRepo.Find(map[string]interface{}{
  389 + "beginDay": param.BeginDay,
  390 + "cycleId": param.CycleId,
  391 + "executorId": param.ExecutorId,
  392 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  393 + "status": domain.StaffAssessUncompleted,
  394 + "limit": 1,
  395 + })
  396 + if err != nil {
  397 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  398 + }
  399 +
  400 + if err := transactionContext.CommitTransaction(); err != nil {
  401 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  402 + }
  403 +
  404 + //评估填写数据行转列
  405 + tableHeader := []adapter.ListTableHeader{
  406 + {Key: "userName", Name: "姓名"},
  407 + {Key: "status", Name: "状态"},
  408 + {Key: "types", Name: "360°评估关系"},
  409 + {Key: "endTime", Name: "360°评估截止日期"},
  410 + }
  411 + tableHeader = append(tableHeader, changeableHeader...)
  412 + listData := []map[string]string{}
  413 + for _, v := range assessList {
  414 + m := map[string]string{
  415 + "userName": v.TargetUser.UserName,
  416 + "userId": strconv.Itoa(v.TargetUser.UserId),
  417 + "status": string(v.Status),
  418 + "cycleId": strconv.FormatInt(v.CycleId, 10),
  419 + "beginDay": v.BeginTime.Local().Format("2006-01-02"),
  420 + "types": string(v.Types),
  421 + "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
  422 + "assessId": strconv.Itoa(v.Id),
  423 + }
  424 + switch v.Status {
  425 + case domain.StaffAssessCompleted:
  426 + m["status"] = "已经完成"
  427 + case domain.StaffAssessUncompleted:
  428 + m["status"] = "未完成"
  429 + }
  430 + switch v.Types {
  431 + case domain.AssessInviteDiffSuper:
  432 + m["types"] = "不同上级同事"
  433 + case domain.AssessInviteSameSuper:
  434 + m["types"] = "相同上级同事"
  435 + }
  436 + if row, ok := changeableRows[v.TargetUser.UserId]; ok {
  437 + for k, v := range row {
  438 + m[k] = v
  439 + }
  440 + } else {
  441 + for _, v := range changeableHeader {
  442 + m[v.Key] = ""
  443 + }
  444 + }
  445 + listData = append(listData, m)
  446 + }
  447 + result := adapter.ListInviteUserAssessResp{
  448 + TableHeader: tableHeader,
  449 + List: listData,
  450 + Total: cnt,
  451 + }
  452 +
  453 + if len(assessList) > 0 {
  454 + result.BeginDay = assessList[0].BeginTime.Local().Format("2006-01-02")
  455 + result.CycleId = int(assessList[0].CycleId)
  456 + result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", assessList[0].EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
  457 + }
  458 +
  459 + return &result, nil
  460 +}
  461 +
  462 +//根据周期和日期获取我需要执行的上级评估成员列表
  463 +func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecutorAssessQuery) (map[string]interface{}, error) {
  464 + transactionContext, err := factory.CreateTransactionContext(nil)
  465 + if err != nil {
  466 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  467 + }
  468 + if err := transactionContext.StartTransaction(); err != nil {
  469 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  470 + }
  471 + defer func() {
  472 + _ = transactionContext.RollbackTransaction()
  473 + }()
  474 + //获取对应的评估任务
  475 + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  476 + "transactionContext": transactionContext,
  477 + })
  478 +
  479 + limit := 20
  480 + if param.PageSize > 0 {
  481 + limit = param.PageSize
  482 + }
  483 + condition := map[string]interface{}{
  484 + "beginDay": param.BeginDay,
  485 + "cycleId": param.CycleId,
  486 + "executorId": param.ExecutorId,
  487 + "typesList": []string{string(domain.AssessSuper)},
  488 + "limit": limit,
  489 + }
  490 + if len(param.UserName) > 0 {
  491 + condition["targetUserName"] = param.UserName
  492 + }
  493 + offset := (param.PageNumber - 1) * param.PageSize
  494 + if offset > 0 {
  495 + condition["offset"] = offset
  496 + }
  497 + //获取 executorId 对应的上级评估列表
  498 + cnt, assessList, err := assessRepo.Find(condition)
  499 + if err != nil {
  500 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  501 + }
  502 + //获取目标用户
  503 + userIds := []int{}
  504 + for _, v := range assessList {
  505 + userIds = append(userIds, v.TargetUser.UserId)
  506 + }
  507 + //获取员工信息
  508 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  509 + "transactionContext": transactionContext,
  510 + })
  511 + var targetUserList []*domain.User
  512 + if len(userIds) > 0 {
  513 + _, targetUserList, _ = userRepo.Find(map[string]interface{}{
  514 + "ids": userIds,
  515 + })
  516 + }
  517 + //获取职位信息
  518 + positionRepo := factory.CreatePositionRepository(map[string]interface{}{
  519 + "transactionContext": transactionContext,
  520 + })
  521 + //获取员工的职位
  522 + userPositionMap := map[int64][]*domain.Position{}
  523 + for _, v := range targetUserList {
  524 + if len(v.PositionId) == 0 {
  525 + continue
  526 + }
  527 + _, positionList, _ := positionRepo.Find(map[string]interface{}{
  528 + "ids": v.PositionId,
  529 + })
  530 + userPositionMap[v.Id] = positionList
  531 + }
  532 + //获取目标员工邀请的人完成360评估的数量
  533 + var inviteCompletedCount []dao.CountData
  534 + d := dao.NewStaffAssessDao(map[string]interface{}{
  535 + "transactionContext": transactionContext,
  536 + })
  537 + if len(userIds) > 0 {
  538 + inviteCompletedCount, err = d.CountTargetUserInviteAssess1(userIds, param.CycleId, param.BeginDay)
  539 + if err != nil {
  540 + log.Logger.Error("获取员工邀请的人完成情况" + err.Error())
  541 + }
  542 + }
  543 +
  544 + //我评估别人,被邀请评估
  545 + cnnt, _, err := assessRepo.Find(map[string]interface{}{
  546 + "beginDay": param.BeginDay,
  547 + "cycleId": param.CycleId,
  548 + "executorId": param.ExecutorId,
  549 + "typesList": []string{string(domain.AssessSuper)},
  550 + "status": string(domain.StaffAssessUncompleted),
  551 + "limit": 1,
  552 + })
  553 + if err != nil {
  554 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  555 + }
  556 + if err := transactionContext.CommitTransaction(); err != nil {
  557 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  558 + }
  559 +
  560 + resultList := []adapter.ListSupperAssessResp{}
  561 + for _, v := range assessList {
  562 + item := adapter.ListSupperAssessResp{
  563 + AssessId: v.Id,
  564 + CycleId: int(v.CycleId),
  565 + BeginDay: v.BeginTime.Local().Format("2006-01-02"),
  566 + UserId: v.TargetUser.UserId,
  567 + UserName: v.TargetUser.UserName,
  568 + EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
  569 + InviteCompleted: 0,
  570 + Status: string(v.Status),
  571 + InviteTotal: 5,
  572 + Department: "",
  573 + Position: "",
  574 + DutyTime: "",
  575 + }
  576 + //填入部门
  577 + for _, vv := range v.TargetDepartment {
  578 + item.Department += vv.DepartmentName + " "
  579 + }
  580 + for _, vv := range targetUserList {
  581 + if vv.Id != int64(v.TargetUser.UserId) {
  582 + continue
  583 + }
  584 + //填入入职时间
  585 + item.DutyTime = vv.CreatedAt.Local().Format("2006-01-02 15:04:05")
  586 + //填入职位
  587 + for _, vvv := range userPositionMap[vv.Id] {
  588 + item.Position += vvv.Name + " "
  589 + }
  590 + break
  591 + }
  592 + //
  593 + for _, vv := range inviteCompletedCount {
  594 + if v.TargetUser.UserId == vv.TargetUserId {
  595 + item.InviteCompleted = vv.InviteCompleted
  596 + item.InviteTotal = vv.InviteTotal
  597 + break
  598 + }
  599 + }
  600 + resultList = append(resultList, item)
  601 + }
  602 + result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList)
  603 + result["lintNodeDesc"] = ""
  604 + if len(assessList) > 0 {
  605 + result["cycleId"] = assessList[0].CycleId
  606 + result["beginDay"] = assessList[0].BeginTime.Local().Format("2006-01-02")
  607 + result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", assessList[0].EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
  608 + }
  609 + return result, nil
  610 +}
  611 +
  612 +//根据周期和日期,获取员工的自评内容
  613 +func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfAssessQuery) (*adapter.AssessInfoResp, error) {
  614 + transactionContext, err := factory.CreateTransactionContext(nil)
  615 + if err != nil {
  616 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  617 + }
  618 + if err := transactionContext.StartTransaction(); err != nil {
  619 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  620 + }
  621 + defer func() {
  622 + _ = transactionContext.RollbackTransaction()
  623 + }()
  624 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  625 + "transactionContext": transactionContext,
  626 + })
  627 + // 获取员工的评估
  628 + _, assessList, err := assessReps.Find(map[string]interface{}{
  629 + "companyId": param.CompanyId,
  630 + "executorId": param.TargetUserId,
  631 + "cycleId": param.CycleId,
  632 + "beginDay": param.BeginDay,
  633 + "typesList": []string{string(domain.AssessSelf)},
  634 + "limit": 1,
  635 + })
  636 + if err != nil {
  637 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
  638 + }
  639 + if len(assessList) == 0 {
  640 + return nil, application.ThrowError(application.BUSINESS_ERROR, "不存在员工的自评内容")
  641 + }
  642 + assessData := assessList[0]
  643 +
  644 + assessContentList := []*domain.StaffAssessContent{}
  645 + if assessData.Status == domain.StaffAssessCompleted {
  646 + //已完成
  647 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  648 + "transactionContext": transactionContext,
  649 + })
  650 + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
  651 + "staffAssessId": assessData.Id,
  652 + })
  653 + if err != nil {
  654 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  655 + }
  656 + } else if assessData.Status == domain.StaffAssessUncompleted {
  657 + //未完成
  658 + assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
  659 + if err != nil {
  660 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  661 + }
  662 + }
  663 +
  664 + //获取员工描述
  665 + staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
  666 + if err := transactionContext.CommitTransaction(); err != nil {
  667 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  668 + }
  669 + result := adapter.AssessInfoResp{
  670 + AssessId: assessData.Id,
  671 + CycleId: assessData.CycleId,
  672 + CycleName: assessData.CycleName,
  673 + LinkNodeId: assessData.LinkNodeId,
  674 + LinkNodeName: assessData.LinkNodeName,
  675 + EvaluationProjectId: assessData.EvaluationProjectId,
  676 + EvaluationProjectName: assessData.EvaluationProjectName,
  677 + BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
  678 + EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
  679 + Status: string(assessData.Status),
  680 + TargetUserId: assessData.TargetUser.UserId,
  681 + TargetUserName: assessData.TargetUser.UserName,
  682 + CompanyId: assessData.CompanyId,
  683 + CompanyName: "",
  684 + SupperUser: "",
  685 + DutyTime: "",
  686 + AssessContent: assessContentList,
  687 + }
  688 + if staffDesc != nil {
  689 + result.CompanyName = staffDesc.CompanyName
  690 + result.SupperUser = staffDesc.SupperUserName
  691 + result.DutyTime = staffDesc.DutyTime
  692 + }
  693 + return &result, nil
  694 +}
@@ -19,6 +19,11 @@ const ( @@ -19,6 +19,11 @@ const (
19 LinkNodeViewResult int = 5 // 环节-绩效结果查看 19 LinkNodeViewResult int = 5 // 环节-绩效结果查看
20 ) 20 )
21 21
  22 +const (
  23 + NodeRequiredYes int = 1 // 必填项-必填(默认)
  24 + NodeRequiredNo int = 2 // 必填项-非必填
  25 +)
  26 +
22 type EntryItem struct { 27 type EntryItem struct {
23 Title string `json:"title" comment:"填写标题"` 28 Title string `json:"title" comment:"填写标题"`
24 HintText string `json:"hintText" comment:"文本内容提示"` 29 HintText string `json:"hintText" comment:"文本内容提示"`
@@ -31,10 +36,11 @@ type NodeContent struct { @@ -31,10 +36,11 @@ type NodeContent struct {
31 Name string `json:"name" comment:"名称"` 36 Name string `json:"name" comment:"名称"`
32 RuleId int64 `json:"ruleId,string" comment:"评估规则ID"` 37 RuleId int64 `json:"ruleId,string" comment:"评估规则ID"`
33 Rule *EvaluationRule `json:"rule" comment:"评估规则对象"` 38 Rule *EvaluationRule `json:"rule" comment:"评估规则对象"`
34 - Weight int `json:"weight" comment:"权重"` 39 + Weight float64 `json:"weight" comment:"权重"`
35 PromptTitle string `json:"promptTitle" comment:"提示项标题"` 40 PromptTitle string `json:"promptTitle" comment:"提示项标题"`
36 PromptText string `json:"promptText" comment:"提示项正文"` 41 PromptText string `json:"promptText" comment:"提示项正文"`
37 EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` 42 EntryItems []*EntryItem `json:"entryItems" comment:"填写项"`
  43 + Required int `json:"required" comment:"必填项"`
38 } 44 }
39 45
40 // LinkNode 评估流程、环节 46 // LinkNode 评估流程、环节
1 -package domain  
2 -  
3 -import (  
4 - "errors"  
5 - "fmt"  
6 - "strconv"  
7 - "time"  
8 -)  
9 -  
10 -//填写的评估内容  
11 -type StaffAssessContent struct {  
12 - Id int `json:"id"` //id  
13 - StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id  
14 - SortBy int `json:"sortBy"` //排序  
15 - Category string `json:"category"` //类别  
16 - Name string `json:"name"` //名称  
17 - PromptTitle string `json:"promptTitle"` //提示项标题  
18 - PromptText string `json:"promptText"` //提示项正文  
19 - Remark []AssessContemtRemark `json:"remark"` //填写的反馈  
20 - Value string `json:"value"` //评估填写的值  
21 - ScoreValue float64 `json:"scoreValue"` // 填写值按规则Rule转换为相应的量化值  
22 - LevelValue string `json:"levelValue"` // 填写值按规则Rule转换为相应的等级值  
23 - ReteResult string `json:"reteResult"` //评估的结果  
24 - Rule EvaluationRule `json:"rule"` //评估的选项规则  
25 - Weight int `json:"weight" ` //"权重"  
26 - CreatedAt time.Time `json:"createdAt"` //数据创建时间  
27 - UpdatedAt time.Time `json:"updatedAt"` //数据更新时间  
28 - DeletedAt *time.Time `json:"deletedAt"`  
29 -}  
30 -  
31 -type AssessContemtRemark struct {  
32 - Title string `json:"title"` //comment:"填写标题"  
33 - HintText string `json:"hintText"` // comment:"文本内容提示"  
34 - Definition string `json:"definition"` //comment:"定义"  
35 - RemarkText string `json:"remarkText"` // comment:"填写文本内容"  
36 -}  
37 -  
38 -//TransformValue  
39 -//根据规则 rule 转换评填写的值  
40 -func (content *StaffAssessContent) TransformValue() error {  
41 - switch content.Rule.Type {  
42 - case EvaluationTypeRating:  
43 - return content.ratingValue()  
44 - case EvaluationTypeScore:  
45 - return content.scoreValue()  
46 - }  
47 - return nil  
48 -}  
49 -  
50 -// 规则是评级方式  
51 -func (content *StaffAssessContent) ratingValue() error {  
52 - levels := content.Rule.Rating.Levels  
53 - for _, v := range levels {  
54 - if v.Code != content.Value {  
55 - continue  
56 - }  
57 - content.LevelValue = v.Code  
58 - content.ScoreValue = v.QuantizedValue  
59 - content.ReteResult = v.Name  
60 - return nil  
61 - }  
62 - return errors.New("评级填写的值错误")  
63 -}  
64 -  
65 -// 规则是评分方式  
66 -func (content *StaffAssessContent) scoreValue() error {  
67 - valueFloat, err := strconv.ParseFloat(content.Value, 64)  
68 - if err != nil {  
69 - return errors.New("评分填写的值错误")  
70 - }  
71 - rule := &content.Rule  
72 - if valueFloat < rule.Score.Min || valueFloat > rule.Score.Max {  
73 - return fmt.Errorf("评分填写的值超出限制,>=%f且<=%f", rule.Score.Min, rule.Score.Max)  
74 - }  
75 - //保留小数处理  
76 - fStr := fmt.Sprintf("%%.%df", rule.Score.DecimalPlaces)  
77 - valueStr := fmt.Sprintf(fStr, valueFloat)  
78 - content.Value = valueStr  
79 - if rule.Score.IntervalState == 0 {  
80 - // 未开启按分数子区间匹配等级  
81 - return nil  
82 - }  
83 - for _, v := range rule.Score.Levels {  
84 - if valueFloat < v.Start || valueFloat > v.End {  
85 - continue  
86 - }  
87 - content.LevelValue = v.Code  
88 - content.ScoreValue = valueFloat  
89 - content.ReteResult = v.Name  
90 - return nil  
91 - }  
92 - return errors.New("评分填写的值错误")  
93 -}  
94 -  
95 -type StaffAssessContentRepository interface {  
96 - Save(param *StaffAssessContent) (*StaffAssessContent, error)  
97 - Remove(id int) error  
98 - FindOne(queryOptions map[string]interface{}) (*StaffAssessContent, error)  
99 - Find(queryOptions map[string]interface{}) (int, []*StaffAssessContent, error)  
100 -} 1 +package domain
  2 +
  3 +import (
  4 + "errors"
  5 + "fmt"
  6 + "strconv"
  7 + "time"
  8 +)
  9 +
  10 +//填写的评估内容
  11 +type StaffAssessContent struct {
  12 + Id int `json:"id"` //id
  13 + StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id
  14 + SortBy int `json:"sortBy"` //排序
  15 + Category string `json:"category"` //类别
  16 + Name string `json:"name"` //名称
  17 + PromptTitle string `json:"promptTitle"` //提示项标题
  18 + PromptText string `json:"promptText"` //提示项正文
  19 + Remark []AssessContemtRemark `json:"remark"` //填写的反馈
  20 + Value string `json:"value"` //评估填写的值
  21 + ScoreValue float64 `json:"scoreValue"` // 填写值按规则Rule转换为相应的量化值
  22 + LevelValue string `json:"levelValue"` // 填写值按规则Rule转换为相应的等级值
  23 + ReteResult string `json:"reteResult"` //评估的结果
  24 + Rule EvaluationRule `json:"rule"` //评估的选项规则
  25 + Weight float64 `json:"weight" ` //"权重"
  26 + Required int `json:"required"` // 必填项
  27 + CreatedAt time.Time `json:"createdAt"` //数据创建时间
  28 + UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
  29 + DeletedAt *time.Time `json:"deletedAt"`
  30 +}
  31 +
  32 +type AssessContemtRemark struct {
  33 + Title string `json:"title"` //comment:"填写标题"
  34 + HintText string `json:"hintText"` // comment:"文本内容提示"
  35 + Definition string `json:"definition"` //comment:"定义"
  36 + RemarkText string `json:"remarkText"` // comment:"填写文本内容"
  37 +}
  38 +
  39 +//TransformValue
  40 +//根据规则 rule 转换评填写的值
  41 +func (content *StaffAssessContent) TransformValue() error {
  42 + switch content.Rule.Type {
  43 + case EvaluationTypeRating:
  44 + return content.ratingValue()
  45 + case EvaluationTypeScore:
  46 + return content.scoreValue()
  47 + }
  48 + return nil
  49 +}
  50 +
  51 +// 规则是评级方式
  52 +func (content *StaffAssessContent) ratingValue() error {
  53 + levels := content.Rule.Rating.Levels
  54 + for _, v := range levels {
  55 + if v.Code != content.Value {
  56 + continue
  57 + }
  58 + content.LevelValue = v.Code
  59 + content.ScoreValue = v.QuantizedValue
  60 + content.ReteResult = v.Name
  61 + return nil
  62 + }
  63 + return errors.New("评级填写的值错误")
  64 +}
  65 +
  66 +// 规则是评分方式
  67 +func (content *StaffAssessContent) scoreValue() error {
  68 + valueFloat, err := strconv.ParseFloat(content.Value, 64)
  69 + if err != nil {
  70 + return errors.New("评分填写的值错误")
  71 + }
  72 + rule := &content.Rule
  73 + if valueFloat < rule.Score.Min || valueFloat > rule.Score.Max {
  74 + return fmt.Errorf("评分填写的值超出限制,>=%f且<=%f", rule.Score.Min, rule.Score.Max)
  75 + }
  76 + //保留小数处理
  77 + fStr := fmt.Sprintf("%%.%df", rule.Score.DecimalPlaces)
  78 + valueStr := fmt.Sprintf(fStr, valueFloat)
  79 + content.Value = valueStr
  80 + if rule.Score.IntervalState == 0 {
  81 + // 未开启按分数子区间匹配等级
  82 + return nil
  83 + }
  84 + for _, v := range rule.Score.Levels {
  85 + if valueFloat < v.Start || valueFloat > v.End {
  86 + continue
  87 + }
  88 + content.LevelValue = v.Code
  89 + content.ScoreValue = valueFloat
  90 + content.ReteResult = v.Name
  91 + return nil
  92 + }
  93 + return errors.New("评分填写的值错误")
  94 +}
  95 +
  96 +type StaffAssessContentRepository interface {
  97 + Save(param *StaffAssessContent) (*StaffAssessContent, error)
  98 + Remove(id int) error
  99 + FindOne(queryOptions map[string]interface{}) (*StaffAssessContent, error)
  100 + Find(queryOptions map[string]interface{}) (int, []*StaffAssessContent, error)
  101 +}
@@ -57,6 +57,34 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask @@ -57,6 +57,34 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask
57 return result, err 57 return result, err
58 } 58 }
59 59
  60 +func (d *StaffAssessDao) CountTargetUserInviteAssess1(userIds []int, cycleId int, beginDay string) ([]CountData, error) {
  61 + sqlStr := `SELECT
  62 + staff_assess.target_user->>'userId' as target_user_id,
  63 + count(staff_assess."id") AS invite_total,
  64 + sum(
  65 + case WHEN staff_assess.status='completed' THEN 1
  66 + ELSE 0 END
  67 + ) as invite_completed
  68 + FROM staff_assess
  69 + WHERE staff_assess.target_user->>'userId' IN(?)
  70 + AND staff_assess.types IN ('invite_same_super','invite_diff_super')
  71 + and to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD') = ?
  72 + and staff_assess.cycle_id =?
  73 + GROUP BY target_user_id`
  74 + userIdStr := []string{}
  75 + for _, v := range userIds {
  76 + str := strconv.Itoa(v)
  77 + userIdStr = append(userIdStr, str)
  78 + }
  79 + condition := []interface{}{
  80 + pg.In(userIdStr), beginDay, cycleId,
  81 + }
  82 + tx := d.transactionContext.PgTx
  83 + result := []CountData{}
  84 + _, err := tx.Query(&result, sqlStr, condition...)
  85 + return result, err
  86 +}
  87 +
60 // 根据评估的人执行人id,搜索 executorId参与的评估任务 88 // 根据评估的人执行人id,搜索 executorId参与的评估任务
61 func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) { 89 func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) {
62 90
@@ -131,7 +159,8 @@ func (d *StaffAssessDao) AllAssessCycleList(companyId int) ([]AssessCycle, error @@ -131,7 +159,8 @@ func (d *StaffAssessDao) AllAssessCycleList(companyId int) ([]AssessCycle, error
131 //获取评估周期中的绩效考核日期 159 //获取评估周期中的绩效考核日期
132 type AssessCycleDay struct { 160 type AssessCycleDay struct {
133 BeginDay string `json:"beginDay"` 161 BeginDay string `json:"beginDay"`
134 - CycleId string `json:"cycleId"` 162 + CycleId int `json:"cycleId"`
  163 + CycleName string `json:"cycleName"`
135 CompanyId string `json:"companyId"` 164 CompanyId string `json:"companyId"`
136 } 165 }
137 166
@@ -139,6 +168,7 @@ type AssessCycleDay struct { @@ -139,6 +168,7 @@ type AssessCycleDay struct {
139 func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]AssessCycleDay, error) { 168 func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]AssessCycleDay, error) {
140 sqlStr := `select distinct staff_assess_task.begin_day , 169 sqlStr := `select distinct staff_assess_task.begin_day ,
141 staff_assess_task.cycle_id , 170 staff_assess_task.cycle_id ,
  171 + staff_assess_task.cycle_name,
142 staff_assess_task.company_id 172 staff_assess_task.company_id
143 from staff_assess_task 173 from staff_assess_task
144 where staff_assess_task.cycle_id = ? 174 where staff_assess_task.cycle_id = ?
@@ -378,3 +408,57 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa @@ -378,3 +408,57 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa
378 _, err := tx.Query(&result, sqlStr, condition...) 408 _, err := tx.Query(&result, sqlStr, condition...)
379 return result, err 409 return result, err
380 } 410 }
  411 +
  412 +type AssessCycleDayMe struct {
  413 + BeginDay string `json:"beginDay"`
  414 + CycleId int `json:"cycleId"`
  415 + CycleName string `json:"cycleName"`
  416 +}
  417 +
  418 +// 根据评估的人执行人id,搜索 executorId参与的评估周期
  419 +func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDayMe, error) {
  420 + if limit < 0 {
  421 + limit = 20
  422 + }
  423 + if offset < 0 {
  424 + offset = 0
  425 + }
  426 + sqlStr := `
  427 + SELECT
  428 + staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day
  429 + FROM staff_assess_task
  430 + JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
  431 + WHERE staff_assess.company_id=?
  432 + and staff_assess_task.deleted_at isnull
  433 + and staff_assess.executor->>'userId'='?'
  434 + group by staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day
  435 + order by staff_assess_task.begin_day desc
  436 + limit ? offset ?
  437 + `
  438 + tx := d.transactionContext.PgTx
  439 + condition := []interface{}{
  440 + companyId, executorId, limit, offset,
  441 + }
  442 + result := []AssessCycleDayMe{}
  443 + _, err := tx.Query(&result, sqlStr, condition...)
  444 + return result, err
  445 +}
  446 +
  447 +// 根据评估的人执行人id,统计executorId参与的评估周期
  448 +func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, error) {
  449 + sqlStr := `
  450 + select count(DISTINCT (staff_assess_task.cycle_id,staff_assess_task.begin_day )) as cnt
  451 + FROM staff_assess_task
  452 + JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
  453 + WHERE staff_assess.company_id=?
  454 + and staff_assess_task.deleted_at isnull
  455 + and staff_assess.executor->>'userId'='?'
  456 + `
  457 + tx := d.transactionContext.PgTx
  458 + condition := []interface{}{
  459 + companyId, executorId,
  460 + }
  461 + var result int
  462 + _, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
  463 + return result, err
  464 +}
1 -package models  
2 -  
3 -import (  
4 - "time"  
5 -  
6 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"  
7 -)  
8 -  
9 -// 填写的评估内容  
10 -type StaffAssessContent struct {  
11 - tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"`  
12 - Id int `pg:",pk"` //id  
13 - StaffAssessId int //用户需要的评估项id  
14 - SortBy int //排序  
15 - Category string //类别  
16 - Name string //名称  
17 - ScoreValue float64 // 填写值按规则Rule转换为相应的量化值  
18 - LevelValue string // 填写值按规则Rule转换为相应的等级值  
19 - PromptTitle string //问题标题  
20 - PromptText string //提示项正文  
21 - Value string //评估填写的值  
22 - ReteResult string //评估的结果  
23 - Rule domain.EvaluationRule  
24 - Remark []domain.AssessContemtRemark  
25 - Weight int `pg:",use_zero"` //权重  
26 - CreatedAt time.Time //数据创建时间  
27 - UpdatedAt time.Time //数据更新时间  
28 - DeletedAt *time.Time  
29 -} 1 +package models
  2 +
  3 +import (
  4 + "time"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  7 +)
  8 +
  9 +// 填写的评估内容
  10 +type StaffAssessContent struct {
  11 + tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"`
  12 + Id int `pg:",pk"` //id
  13 + StaffAssessId int //用户需要的评估项id
  14 + SortBy int //排序
  15 + Category string //类别
  16 + Name string //名称
  17 + ScoreValue float64 // 填写值按规则Rule转换为相应的量化值
  18 + LevelValue string // 填写值按规则Rule转换为相应的等级值
  19 + PromptTitle string //问题标题
  20 + PromptText string //提示项正文
  21 + Value string //评估填写的值
  22 + ReteResult string //评估的结果
  23 + Rule domain.EvaluationRule
  24 + Remark []domain.AssessContemtRemark
  25 + Weight float64 `pg:",use_zero"` //权重
  26 + Required int //必填项
  27 + CreatedAt time.Time //数据创建时间
  28 + UpdatedAt time.Time //数据更新时间
  29 + DeletedAt *time.Time
  30 +}
@@ -21,6 +21,17 @@ func NewEvaluationCycleTemplateRepository(transactionContext *pgTransaction.Tran @@ -21,6 +21,17 @@ func NewEvaluationCycleTemplateRepository(transactionContext *pgTransaction.Tran
21 } 21 }
22 22
23 func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.EvaluationCycleTemplate) domain.EvaluationCycleTemplate { 23 func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.EvaluationCycleTemplate) domain.EvaluationCycleTemplate {
  24 + // 历史旧数据,默认输出转成1
  25 + if m.Template != nil {
  26 + for i := range m.Template.LinkNodes {
  27 + node := m.Template.LinkNodes[i]
  28 + for j := range node.NodeContents {
  29 + if node.NodeContents[j].Required == 0 {
  30 + node.NodeContents[j].Required = domain.NodeRequiredYes
  31 + }
  32 + }
  33 + }
  34 + }
24 return domain.EvaluationCycleTemplate{ 35 return domain.EvaluationCycleTemplate{
25 Id: m.Id, 36 Id: m.Id,
26 Name: m.Name, 37 Name: m.Name,
@@ -21,6 +21,18 @@ func NewEvaluationProjectRepository(transactionContext *pgTransaction.Transactio @@ -21,6 +21,18 @@ func NewEvaluationProjectRepository(transactionContext *pgTransaction.Transactio
21 } 21 }
22 22
23 func (repo *EvaluationProjectRepository) TransformToDomain(m *models.EvaluationProject) domain.EvaluationProject { 23 func (repo *EvaluationProjectRepository) TransformToDomain(m *models.EvaluationProject) domain.EvaluationProject {
  24 + // 历史旧数据,默认输出转成1
  25 + if m.Template != nil {
  26 + for i := range m.Template.LinkNodes {
  27 + node := m.Template.LinkNodes[i]
  28 + for j := range node.NodeContents {
  29 + if node.NodeContents[j].Required == 0 {
  30 + node.NodeContents[j].Required = domain.NodeRequiredYes
  31 + }
  32 + }
  33 + }
  34 + }
  35 +
24 return domain.EvaluationProject{ 36 return domain.EvaluationProject{
25 Id: m.Id, 37 Id: m.Id,
26 Name: m.Name, 38 Name: m.Name,
@@ -21,6 +21,15 @@ func NewEvaluationTemplateRepository(transactionContext *pgTransaction.Transacti @@ -21,6 +21,15 @@ func NewEvaluationTemplateRepository(transactionContext *pgTransaction.Transacti
21 } 21 }
22 22
23 func (repo *EvaluationTemplateRepository) TransformToDomain(m *models.EvaluationTemplate) domain.EvaluationTemplate { 23 func (repo *EvaluationTemplateRepository) TransformToDomain(m *models.EvaluationTemplate) domain.EvaluationTemplate {
  24 + // 历史旧数据,默认输出转成1
  25 + for i := range m.LinkNodes {
  26 + node := m.LinkNodes[i]
  27 + for j := range node.NodeContents {
  28 + if node.NodeContents[j].Required == 0 {
  29 + node.NodeContents[j].Required = domain.NodeRequiredYes
  30 + }
  31 + }
  32 + }
24 return domain.EvaluationTemplate{ 33 return domain.EvaluationTemplate{
25 Id: m.Id, 34 Id: m.Id,
26 Name: m.Name, 35 Name: m.Name,
@@ -37,6 +37,7 @@ func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAsses @@ -37,6 +37,7 @@ func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAsses
37 ReteResult: d.ReteResult, 37 ReteResult: d.ReteResult,
38 Rule: d.Rule, 38 Rule: d.Rule,
39 Weight: d.Weight, 39 Weight: d.Weight,
  40 + Required: d.Required,
40 CreatedAt: d.CreatedAt, 41 CreatedAt: d.CreatedAt,
41 UpdatedAt: d.UpdatedAt, 42 UpdatedAt: d.UpdatedAt,
42 DeletedAt: nil, 43 DeletedAt: nil,
@@ -59,6 +60,7 @@ func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*d @@ -59,6 +60,7 @@ func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*d
59 Rule: d.Rule, 60 Rule: d.Rule,
60 Remark: d.Remark, 61 Remark: d.Remark,
61 Weight: d.Weight, 62 Weight: d.Weight,
  63 + Required: d.Required,
62 CreatedAt: d.CreatedAt, 64 CreatedAt: d.CreatedAt,
63 UpdatedAt: d.UpdatedAt, 65 UpdatedAt: d.UpdatedAt,
64 DeletedAt: nil, 66 DeletedAt: nil,
@@ -144,6 +144,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -144,6 +144,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
144 if v, ok := queryOptions["staffAssessTaskId"]; ok { 144 if v, ok := queryOptions["staffAssessTaskId"]; ok {
145 query.Where(`staff_assess_task_id=?`, v) 145 query.Where(`staff_assess_task_id=?`, v)
146 } 146 }
  147 +
147 if v, ok := queryOptions["id"]; ok { 148 if v, ok := queryOptions["id"]; ok {
148 query.Where("id=?", v) 149 query.Where("id=?", v)
149 } 150 }
@@ -156,6 +157,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -156,6 +157,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
156 if v, ok := queryOptions["endTime"]; ok { 157 if v, ok := queryOptions["endTime"]; ok {
157 query.Where("end_time<=?", v) 158 query.Where("end_time<=?", v)
158 } 159 }
  160 + if v, ok := queryOptions["beginDay"]; ok {
  161 + query.Where("to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')= ? ", v)
  162 + }
  163 +
159 count, err := query.SelectAndCount() 164 count, err := query.SelectAndCount()
160 if err != nil { 165 if err != nil {
161 return 0, nil, err 166 return 0, nil, err
@@ -120,12 +120,18 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) @@ -120,12 +120,18 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
120 if v, ok := queryOptions["beginDay"]; ok { 120 if v, ok := queryOptions["beginDay"]; ok {
121 query.Where("begin_day=?", v) 121 query.Where("begin_day=?", v)
122 } 122 }
  123 + if v, ok := queryOptions["cycleId"]; ok {
  124 + query.Where("cycle_id=?", v)
  125 + }
123 if v, ok := queryOptions["executorId"].(int); ok && v > 0 { 126 if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
124 query.Where(`executor_id @>'[?]'`, v) 127 query.Where(`executor_id @>'[?]'`, v)
125 } 128 }
126 if v, ok := queryOptions["evaluationProjectId"]; ok { 129 if v, ok := queryOptions["evaluationProjectId"]; ok {
127 query.Where("evaluation_project_id=?", v) 130 query.Where("evaluation_project_id=?", v)
128 } 131 }
  132 + if v, ok := queryOptions["ids"]; ok {
  133 + query.Where("id in (?) ", pg.In(v))
  134 + }
129 count, err := query.SelectAndCount() 135 count, err := query.SelectAndCount()
130 if err != nil { 136 if err != nil {
131 return 0, nil, err 137 return 0, nil, err
1 package controllers 1 package controllers
2 2
3 import ( 3 import (
  4 + "strconv"
  5 + "strings"
  6 +
4 "github.com/linmadan/egglib-go/core/application" 7 "github.com/linmadan/egglib-go/core/application"
5 "github.com/linmadan/egglib-go/utils/tool_funs" 8 "github.com/linmadan/egglib-go/utils/tool_funs"
6 "github.com/linmadan/egglib-go/web/beego" 9 "github.com/linmadan/egglib-go/web/beego"
@@ -8,8 +11,6 @@ import ( @@ -8,8 +11,6 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
10 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" 13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
11 - "strconv"  
12 - "strings"  
13 ) 14 )
14 15
15 type ImportController struct { 16 type ImportController struct {
@@ -95,7 +96,7 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf @@ -95,7 +96,7 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf
95 nc.RuleId = ruleId // 规则ID 96 nc.RuleId = ruleId // 规则ID
96 sIndex := strings.Index(module.Weight, "%") // 权重 97 sIndex := strings.Index(module.Weight, "%") // 权重
97 if sIndex != -1 { 98 if sIndex != -1 {
98 - iWeight, _ := strconv.Atoi(module.Weight[:sIndex]) 99 + iWeight, _ := strconv.ParseFloat(module.Weight[:sIndex], 64)
99 nc.Weight = iWeight 100 nc.Weight = iWeight
100 } else { 101 } else {
101 nc.Weight = 0 102 nc.Weight = 0
@@ -119,6 +120,8 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf @@ -119,6 +120,8 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf
119 }) 120 })
120 } 121 }
121 122
  123 + // 必填项
  124 + nc.Required = domain.NodeRequiredYes
122 nodeContents = append(nodeContents, nc) 125 nodeContents = append(nodeContents, nc)
123 } 126 }
124 } 127 }
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "github.com/linmadan/egglib-go/web/beego"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
  9 +)
  10 +
  11 +type StaffAssessControllerV2 struct {
  12 + beego.BaseController
  13 +}
  14 +
  15 +// 获取我的绩效任务列表
  16 +func (c *StaffAssessControllerV2) SearchAssessTaskMe() {
  17 + srv := service.NewStaffAssessServeice()
  18 + paramReq := &query.SearchAssessMeQuery{}
  19 + err := c.BindJSON(paramReq)
  20 + if err != nil {
  21 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  22 + c.Response(nil, e)
  23 + return
  24 + }
  25 + userReq := middlewares.GetUser(c.Ctx)
  26 + paramReq.CompanyId = int(userReq.CompanyId)
  27 + paramReq.UserId = int(userReq.UserId)
  28 +
  29 + data, err := srv.SearchAssessTaskMeV2(paramReq)
  30 + c.Response(data, err)
  31 +}
  32 +
  33 +// 获取我的绩效任务各环节完成情况
  34 +func (c *StaffAssessControllerV2) AssessTaskMeDesc() {
  35 + srv := service.NewStaffAssessServeice()
  36 + paramReq := &query.AssessTaskDescV2Query{}
  37 + err := c.BindJSON(paramReq)
  38 + if err != nil {
  39 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  40 + c.Response(nil, e)
  41 + return
  42 + }
  43 + userReq := middlewares.GetUser(c.Ctx)
  44 + paramReq.CompanyId = int(userReq.CompanyId)
  45 + paramReq.UserId = int(userReq.UserId)
  46 + data, err := srv.AssessTaskDescV2(paramReq)
  47 + c.Response(data, err)
  48 +}
  49 +
  50 +// 获取我要执行360评估,用户列表和评估填写的值
  51 +func (c *StaffAssessControllerV2) ListMeInviteUserAssess() {
  52 + srv := service.NewStaffAssessServeice()
  53 + paramReq := &query.ListExecutorAssessQuery{}
  54 + err := c.BindJSON(paramReq)
  55 + if err != nil {
  56 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  57 + c.Response(nil, e)
  58 + return
  59 + }
  60 + //获取当前用户信息
  61 + userReq := middlewares.GetUser(c.Ctx)
  62 + paramReq.CompanyId = int(userReq.CompanyId)
  63 + paramReq.ExecutorId = int(userReq.UserId)
  64 + data, err := srv.ListExecutorInviteAssessV2(paramReq)
  65 + c.Response(data, err)
  66 +}
  67 +
  68 +// 获取我要执行的上级评估成员列表
  69 +func (c *StaffAssessControllerV2) ListMeSupperAssess() {
  70 + srv := service.NewStaffAssessServeice()
  71 + paramReq := &query.ListExecutorAssessQuery{}
  72 + err := c.BindJSON(paramReq)
  73 + if err != nil {
  74 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  75 + c.Response(nil, e)
  76 + return
  77 + }
  78 + // 获取当前用户信息
  79 + userReq := middlewares.GetUser(c.Ctx)
  80 + paramReq.CompanyId = int(userReq.CompanyId)
  81 + paramReq.ExecutorId = int(userReq.UserId)
  82 + data, err := srv.ListExecutorSupperAssessV2(paramReq)
  83 + c.Response(data, err)
  84 +}
  85 +
  86 +// 获取我邀请的人
  87 +func (c *StaffAssessControllerV2) GetAssessMeInviteUser() {
  88 + srv := service.NewStaffAssessServeice()
  89 + paramReq := &query.ListInviteUserQuery{}
  90 + err := c.BindJSON(paramReq)
  91 + if err != nil {
  92 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  93 + c.Response(nil, e)
  94 + return
  95 + }
  96 + userReq := middlewares.GetUser(c.Ctx)
  97 + paramReq.CompanyId = int(userReq.CompanyId)
  98 + paramReq.TargetUserId = int(userReq.UserId)
  99 + data, err := srv.ListAssessInviteUserV2(paramReq)
  100 + c.Response(data, err)
  101 +}
  102 +
  103 +// 获取员工自评详情
  104 +func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() {
  105 + srv := service.NewStaffAssessServeice()
  106 + paramReq := &query.GetExecutorSelfAssessQuery{}
  107 + err := c.BindJSON(paramReq)
  108 + if err != nil {
  109 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  110 + c.Response(nil, e)
  111 + return
  112 + }
  113 + // paramReq.CompanyId = 1
  114 + userReq := middlewares.GetUser(c.Ctx)
  115 + paramReq.CompanyId = int(userReq.CompanyId)
  116 + data, err := srv.GetAssessSelfInfoV2(paramReq)
  117 + c.Response(data, err)
  118 +}
@@ -10,9 +10,9 @@ import ( @@ -10,9 +10,9 @@ import (
10 func init() { 10 func init() {
11 assessTaskNS := web.NewNamespace("/v1/staff-assess-task", 11 assessTaskNS := web.NewNamespace("/v1/staff-assess-task",
12 web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()), 12 web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
13 - web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表  
14 - web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述  
15 - web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务 13 + web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表
  14 + web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述
  15 + //web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务
16 web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表 16 web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表
17 web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期 17 web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期
18 web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表 18 web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表
@@ -33,8 +33,24 @@ func init() { @@ -33,8 +33,24 @@ func init() {
33 web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表 33 web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表
34 web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我的上级评估的列表 34 web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我的上级评估的列表
35 web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情 35 web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
  36 + )
  37 + //v2 改版
  38 + assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task",
  39 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  40 + web.NSCtrlPost("/search/me", (*controllers.StaffAssessControllerV2).SearchAssessTaskMe), //获取我参与过的评估项目列表
  41 + web.NSCtrlPost("/desc/me", (*controllers.StaffAssessControllerV2).AssessTaskMeDesc),
  42 + )
36 43
  44 + assessV2NS := web.NewNamespace("/v2/staff-assess",
  45 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  46 + web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessControllerV2).ListMeInviteUserAssess), //我要执行的360评估的用户列表
  47 + web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessControllerV2).ListMeSupperAssess), //我要执行的360评估的用户列表
  48 + web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessControllerV2).GetAssessMeInviteUser), //获取邀请的员工
  49 + web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessControllerV2).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
37 ) 50 )
  51 +
38 web.AddNamespace(assessTaskNS) 52 web.AddNamespace(assessTaskNS)
39 web.AddNamespace(assessNS) 53 web.AddNamespace(assessNS)
  54 + web.AddNamespace(assessTaskV2NS)
  55 + web.AddNamespace(assessV2NS)
40 } 56 }
  1 +ALTER TABLE public.staff_assess_content ADD required int8 NULL DEFAULT 1;
  1 +ALTER TABLE public.staff_assess_content ALTER COLUMN weight TYPE float8 USING weight::float8;