作者 tangxvhui

修复一些问题

@@ -5,23 +5,23 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" @@ -5,23 +5,23 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
5 //评估内容详情 5 //评估内容详情
6 type AssessInfoResp struct { 6 type AssessInfoResp struct {
7 AssessId int `json:"assessId"` 7 AssessId int `json:"assessId"`
8 - CycleId int64 `json:"cycleId,string"` //周期id  
9 - CycleName string `json:"cycleName"` //周期名称  
10 - EvaluationProjectId int `json:"evaluationProjectId"` //项目id  
11 - EvaluationProjectName string `json:"evaluationProjectName"` //项目名称  
12 - LinkNodeId int `json:"linkNodeId,string"` //评估环节id  
13 - LinkNodeName string `json:"linkNodeName"` //评估环节名称  
14 - BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05  
15 - EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05  
16 - Status string `json:"status"` //完成状态  
17 - TargetUserId int `json:"targetUserId,string"` //目标用户  
18 - TargetUserName string `json:"targetUserName"` //目标用户名称  
19 - CompanyId int `json:"companyId,string,"` //公司id  
20 - CompanyLogo string `json:"companyLogo,string,"` //公司logo  
21 - CompanyName string `json:"companyName"` //公司名称  
22 - SupperUser string `json:"superUser"` //目标用户的上级  
23 - DutyTime string `json:"dutyTime"` //入职时间 //  
24 - AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容 8 + CycleId int64 `json:"cycleId,string"` //周期id
  9 + CycleName string `json:"cycleName"` //周期名称
  10 + EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id
  11 + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
  12 + LinkNodeId int `json:"linkNodeId,string"` //评估环节id
  13 + LinkNodeName string `json:"linkNodeName"` //评估环节名称
  14 + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
  15 + EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
  16 + Status string `json:"status"` //完成状态
  17 + TargetUserId int `json:"targetUserId,string"` //目标用户
  18 + TargetUserName string `json:"targetUserName"` //目标用户名称
  19 + CompanyId int `json:"companyId,string,"` //公司id
  20 + CompanyLogo string `json:"companyLogo,string,"` //公司logo
  21 + CompanyName string `json:"companyName"` //公司名称
  22 + SupperUser string `json:"superUser"` //目标用户的上级
  23 + DutyTime string `json:"dutyTime"` //入职时间 //
  24 + AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
25 } 25 }
26 26
27 // 周期内的每日自评小结 27 // 周期内的每日自评小结
@@ -906,20 +906,20 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada @@ -906,20 +906,20 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
906 return &adapter.AssessInfoResp{}, nil 906 return &adapter.AssessInfoResp{}, nil
907 } 907 }
908 assessData := assessList[0] 908 assessData := assessList[0]
909 - assessContentList := []*domain.StaffAssessContent{}  
910 - if assessData.Status == domain.StaffAssessCompleted {  
911 - //已完成  
912 - assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{  
913 - "transactionContext": transactionContext,  
914 - })  
915 - _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{  
916 - "staffAssessId": assessData.Id,  
917 - })  
918 - if err != nil {  
919 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())  
920 - }  
921 - } else if assessData.Status == domain.StaffAssessUncompleted {  
922 - //未完成 909 + var assessContentList []*domain.StaffAssessContent
  910 +
  911 + //已完成
  912 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  913 + "transactionContext": transactionContext,
  914 + })
  915 + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
  916 + "staffAssessId": assessData.Id,
  917 + })
  918 + if err != nil {
  919 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  920 + }
  921 + if len(assessContentList) == 0 {
  922 + // 未完成
923 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData) 923 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
924 if err != nil { 924 if err != nil {
925 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 925 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
@@ -1048,17 +1048,17 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1048,17 +1048,17 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1048 "transactionContext": transactionContext, 1048 "transactionContext": transactionContext,
1049 }) 1049 })
1050 //待更新的评估填写信息 1050 //待更新的评估填写信息
1051 - assessContentList := []*domain.StaffAssessContent{}  
1052 - if assessData.Status == domain.StaffAssessCompleted {  
1053 - //已完成  
1054 - _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{  
1055 - "staffAssessId": assessData.Id,  
1056 - })  
1057 - if err != nil {  
1058 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())  
1059 - }  
1060 - } else if assessData.Status == domain.StaffAssessUncompleted {  
1061 - //未完成 1051 + var assessContentList []*domain.StaffAssessContent
  1052 + //已完成
  1053 + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
  1054 + "staffAssessId": assessData.Id,
  1055 + })
  1056 + if err != nil {
  1057 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  1058 + }
  1059 +
  1060 + if len(assessContentList) == 0 {
  1061 + // 未完成
1062 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData) 1062 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
1063 if err != nil { 1063 if err != nil {
1064 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 1064 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
@@ -1102,19 +1102,14 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1102,19 +1102,14 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1102 } 1102 }
1103 } 1103 }
1104 //保存信息 1104 //保存信息
1105 - hasValue := false //评估是否有填写值 1105 +
1106 for i := range assessContentList { 1106 for i := range assessContentList {
1107 _, err = assessContentRepo.Save(assessContentList[i]) 1107 _, err = assessContentRepo.Save(assessContentList[i])
1108 if err != nil { 1108 if err != nil {
1109 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估填写内容"+err.Error()) 1109 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估填写内容"+err.Error())
1110 } 1110 }
1111 - if len(assessContentList[i].Value) > 0 {  
1112 - hasValue = true  
1113 - }  
1114 - }  
1115 - if hasValue {  
1116 - assessData.Status = domain.StaffAssessCompleted  
1117 } 1111 }
  1112 + assessData.Status = domain.StaffAssessCompleted
1118 assessData.UpdatedAt = time.Now() 1113 assessData.UpdatedAt = time.Now()
1119 _, err = assessReps.Save(assessData) 1114 _, err = assessReps.Save(assessData)
1120 if err != nil { 1115 if err != nil {
@@ -37,6 +37,9 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ @@ -37,6 +37,9 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ
37 if param.PageSize > 0 { 37 if param.PageSize > 0 {
38 limit = param.PageSize 38 limit = param.PageSize
39 } 39 }
  40 + if param.PageNumber <= 0 {
  41 + param.PageNumber = 1
  42 + }
40 offset = (param.PageNumber - 1) * param.PageSize 43 offset = (param.PageNumber - 1) * param.PageSize
41 44
42 assessCycleList, cnt, err := staffAssessDao.SearchExecutorAssessBeforeNow(param.UserId, param.CompanyId, limit, offset) 45 assessCycleList, cnt, err := staffAssessDao.SearchExecutorAssessBeforeNow(param.UserId, param.CompanyId, limit, offset)
@@ -1217,24 +1220,24 @@ func (srv StaffAssessServeice) getStaffAssessBeforeEdit(param *query.AssessInfoQ @@ -1217,24 +1220,24 @@ func (srv StaffAssessServeice) getStaffAssessBeforeEdit(param *query.AssessInfoQ
1217 return &adapter.AssessInfoResp{}, nil 1220 return &adapter.AssessInfoResp{}, nil
1218 } 1221 }
1219 assessData := assessList[0] 1222 assessData := assessList[0]
1220 - assessContentList := []*domain.StaffAssessContent{}  
1221 - if assessData.Status == domain.StaffAssessCompleted {  
1222 - //已完成  
1223 - assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{  
1224 - "transactionContext": transactionContext,  
1225 - })  
1226 - _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{  
1227 - "staffAssessId": assessData.Id,  
1228 - })  
1229 - if err != nil {  
1230 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())  
1231 - }  
1232 - } else if assessData.Status == domain.StaffAssessUncompleted { 1223 + var assessContentList []*domain.StaffAssessContent
  1224 + //已完成
  1225 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  1226 + "transactionContext": transactionContext,
  1227 + })
  1228 + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
  1229 + "staffAssessId": assessData.Id,
  1230 + })
  1231 + if err != nil {
  1232 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  1233 + }
  1234 + if len(assessContentList) == 0 {
1233 //未完成 1235 //未完成
1234 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData) 1236 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
1235 if err != nil { 1237 if err != nil {
1236 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 1238 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
1237 } 1239 }
  1240 +
1238 } 1241 }
1239 // 恢复缓存数据 1242 // 恢复缓存数据
1240 srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList) 1243 srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
@@ -1306,7 +1306,7 @@ func (d *StaffAssessDao) SearchExecutorAssessBeforeNow(executorId int, companyId @@ -1306,7 +1306,7 @@ func (d *StaffAssessDao) SearchExecutorAssessBeforeNow(executorId int, companyId
1306 and staff_assess.deleted_at isnull 1306 and staff_assess.deleted_at isnull
1307 and staff_assess_task.deleted_at isnull 1307 and staff_assess_task.deleted_at isnull
1308 and ( 1308 and (
1309 - staff_assess.end_time < now() or staff_assess.status ='completed' 1309 + staff_assess.end_time < now()
1310 ) 1310 )
1311 and staff_assess.executor ->> 'userId'='?' 1311 and staff_assess.executor ->> 'userId'='?'
1312 order by begin_day desc 1312 order by begin_day desc
@@ -1325,7 +1325,7 @@ func (d *StaffAssessDao) SearchExecutorAssessBeforeNow(executorId int, companyId @@ -1325,7 +1325,7 @@ func (d *StaffAssessDao) SearchExecutorAssessBeforeNow(executorId int, companyId
1325 WHERE staff_assess.company_id=? 1325 WHERE staff_assess.company_id=?
1326 and staff_assess.deleted_at isnull 1326 and staff_assess.deleted_at isnull
1327 and ( 1327 and (
1328 - staff_assess.end_time < now() or staff_assess.status ='completed' 1328 + staff_assess.end_time < now()
1329 ) 1329 )
1330 and staff_assess_task.deleted_at isnull 1330 and staff_assess_task.deleted_at isnull
1331 and staff_assess.executor ->> 'userId'='?' 1331 and staff_assess.executor ->> 'userId'='?'
@@ -1362,7 +1362,7 @@ func (d *StaffAssessDao) SearchExecutorAssessAfterNow(executorId int, companyId @@ -1362,7 +1362,7 @@ func (d *StaffAssessDao) SearchExecutorAssessAfterNow(executorId int, companyId
1362 WHERE staff_assess.company_id=? 1362 WHERE staff_assess.company_id=?
1363 and staff_assess.deleted_at isnull 1363 and staff_assess.deleted_at isnull
1364 and ( 1364 and (
1365 - staff_assess.end_time >= now() and staff_assess.status ='uncompleted' 1365 + staff_assess.end_time >= now()
1366 ) 1366 )
1367 and staff_assess_task.deleted_at isnull 1367 and staff_assess_task.deleted_at isnull
1368 and staff_assess.executor ->> 'userId'='?' 1368 and staff_assess.executor ->> 'userId'='?'
@@ -299,21 +299,37 @@ func (d *StaffAssessDao) ListTargetUserNoInvite(companyId int, cycleId int, begi @@ -299,21 +299,37 @@ func (d *StaffAssessDao) ListTargetUserNoInvite(companyId int, cycleId int, begi
299 } 299 }
300 300
301 type UserSelfStaffAssess struct { 301 type UserSelfStaffAssess struct {
302 - CycleId string ``  
303 - AssessId string ``  
304 - TargetUserId string ``  
305 - TargetUserName string `` 302 + CycleId string `pg:"cycle_id"`
  303 + AssessId string `pg:"assess_id"`
  304 + TargetUserId string `pg:"target_user_id"`
  305 + TargetUserName string `pg:"target_user_name"`
  306 + EvaluationProjectId string `pg:"evaluation_project_id"`
  307 + EvaluationProjectName string `pg:"evaluation_project_name"`
  308 + CompanyId string `pg:"company_id"`
  309 + BeginDay string `pg:"begin_day"`
  310 +}
  311 +
  312 +type SearchConditin3 struct {
  313 + CompanyId int //公司id
  314 + CycleId int //周期id
  315 + BeginDay string //评估的日期
  316 + TargetUserName string //被评估人的名称
  317 + Limit int //分页
  318 + Offset int //分页
  319 + OperaterId int //用户的id是谁在搜索数据
  320 + Hrbp int //
  321 + Status string // 评估完成状态
306 } 322 }
307 323
308 // 根据周期的id和日期获取员工评估的评估任务。有进行查看权限过滤 324 // 根据周期的id和日期获取员工评估的评估任务。有进行查看权限过滤
309 -// companyId int 公司id  
310 -// cycleId int, 评估周期id 325 +// companyId int 公司id ,必填
  326 +// cycleId int, 评估周期id, 必填
311 // userId int, 用户id,谁要查看数据 327 // userId int, 用户id,谁要查看数据
312 // beginDay string, 周期中执行项目的时间 328 // beginDay string, 周期中执行项目的时间
313 // hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否 329 // hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
314 // limit int, 分页条数 330 // limit int, 分页条数
315 // offset int 分页偏移 331 // offset int 分页偏移
316 -func (d *StaffAssessDao) SearchUserSelfStaffAssess(param SearchConditin1) ([]UserAssessContent, error) { 332 +func (d *StaffAssessDao) SearchUserSelfStaffAssess(param SearchConditin3) ([]UserSelfStaffAssess, error) {
317 withSql := d.catchProjectIdByPermission(param.CompanyId, param.CycleId, param.OperaterId, param.Hrbp) 333 withSql := d.catchProjectIdByPermission(param.CompanyId, param.CycleId, param.OperaterId, param.Hrbp)
318 sqlStr := `select 334 sqlStr := `select
319 staff_assess.cycle_id , 335 staff_assess.cycle_id ,
@@ -323,9 +339,9 @@ func (d *StaffAssessDao) SearchUserSelfStaffAssess(param SearchConditin1) ([]Use @@ -323,9 +339,9 @@ func (d *StaffAssessDao) SearchUserSelfStaffAssess(param SearchConditin1) ([]Use
323 staff_assess.evaluation_project_id , 339 staff_assess.evaluation_project_id ,
324 staff_assess.evaluation_project_name , 340 staff_assess.evaluation_project_name ,
325 staff_assess.company_id , 341 staff_assess.company_id ,
326 - staff_assess.begin_time 342 + to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD') as begin_day
327 from staff_assess 343 from staff_assess
328 - join evaluation_project on staff_assess.evaluation_project_id =evaluation_project.id 344 + join t_project_4 on staff_assess.evaluation_project_id =t_project_4.project_id
329 where 1=1 345 where 1=1
330 and staff_assess.cycle_id =? 346 and staff_assess.cycle_id =?
331 and staff_assess.deleted_at isnull 347 and staff_assess.deleted_at isnull
@@ -339,19 +355,53 @@ func (d *StaffAssessDao) SearchUserSelfStaffAssess(param SearchConditin1) ([]Use @@ -339,19 +355,53 @@ func (d *StaffAssessDao) SearchUserSelfStaffAssess(param SearchConditin1) ([]Use
339 condition = append(condition, "%"+param.TargetUserName+"%") 355 condition = append(condition, "%"+param.TargetUserName+"%")
340 sqlStr += ` and staff_assess.target_user ->>'userName' like ? ` 356 sqlStr += ` and staff_assess.target_user ->>'userName' like ? `
341 } 357 }
342 - if len(param.TargetUserId) > 0 {  
343 - condition = append(condition, pg.In(param.TargetUserId))  
344 - sqlStr += ` and staff_assess.target_user ->>'userId' in (?) ` 358 + if len(param.Status) > 0 {
  359 + condition = append(condition, param.Status)
  360 + sqlStr += ` and staff_assess.status=? `
345 } 361 }
346 condition = append(condition, param.Limit, param.Offset) 362 condition = append(condition, param.Limit, param.Offset)
347 sqlStr += ` order by convert_to(staff_assess.target_user ->>'userName','GBK') limit ? offset ? ` 363 sqlStr += ` order by convert_to(staff_assess.target_user ->>'userName','GBK') limit ? offset ? `
348 364
349 sqlStr2 := withSql + withSql 365 sqlStr2 := withSql + withSql
350 - // and to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')='2023-03-29'  
351 - _ = sqlStr2  
352 - // and staff_assess.cycle_id =1639084510698016768  
353 - // -- and staff_assess.target_user ->>'userName' like '%陈%'  
354 - // -- and staff_assess.target_user ->>'userId' in ('')  
355 - // order by convert_to(staff_assess.target_user ->>'userName','GBK')  
356 - return nil, nil 366 + tx := d.transactionContext.PgTx
  367 + var result []UserSelfStaffAssess
  368 + _, err := tx.Query(&result, sqlStr2, condition...)
  369 + return result, err
  370 +}
  371 +
  372 +// 根据周期的id和日期获取员工评估的评估任务数量。有进行查看权限过滤
  373 +// companyId int 公司id
  374 +// cycleId int, 评估周期id
  375 +// userId int, 用户id,谁要查看数据
  376 +// beginDay string, 周期中执行项目的时间
  377 +// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
  378 +func (d *StaffAssessDao) CountUserSelfStaffAssess(param SearchConditin3) (int, error) {
  379 + withSql := d.catchProjectIdByPermission(param.CompanyId, param.CycleId, param.OperaterId, param.Hrbp)
  380 + sqlStr := `select
  381 + count(*)
  382 + from staff_assess
  383 + join t_project_4 on staff_assess.evaluation_project_id =t_project_4.project_id
  384 + where 1=1
  385 + and staff_assess.cycle_id =?
  386 + and staff_assess.deleted_at isnull
  387 + `
  388 + condition := []interface{}{param.CycleId}
  389 + if len(param.BeginDay) > 0 {
  390 + condition = append(condition, param.BeginDay)
  391 + sqlStr += ` and to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')=? `
  392 + }
  393 + if len(param.TargetUserName) > 0 {
  394 + condition = append(condition, "%"+param.TargetUserName+"%")
  395 + sqlStr += ` and staff_assess.target_user ->>'userName' like ? `
  396 + }
  397 + if len(param.Status) > 0 {
  398 + condition = append(condition, param.Status)
  399 + sqlStr += ` and staff_assess.status=? `
  400 + }
  401 +
  402 + sqlStr2 := withSql + withSql
  403 + tx := d.transactionContext.PgTx
  404 + var result int
  405 + _, err := tx.Query(pg.Scan(&result), sqlStr2, condition...)
  406 + return result, err
357 } 407 }