作者 tangxvhui

修复一些问题

@@ -12,6 +12,7 @@ type AssessTaskDescResp struct { @@ -12,6 +12,7 @@ type AssessTaskDescResp struct {
12 12
13 type AssessTaskStep struct { 13 type AssessTaskStep struct {
14 SortBy int `json:"sortBy"` //排序 14 SortBy int `json:"sortBy"` //排序
  15 + LinkNodeId int `json:"linkNodeId"` //流程id
15 LinkNodeName string `json:"linkNodeName"` //流程名称 16 LinkNodeName string `json:"linkNodeName"` //流程名称
16 BeginTime string `json:"beginTime"` //开始时间时间 17 BeginTime string `json:"beginTime"` //开始时间时间
17 EndTime string `json:"endTime"` //结束时间 18 EndTime string `json:"endTime"` //结束时间
@@ -2,6 +2,7 @@ package service @@ -2,6 +2,7 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "sort"
5 "strconv" 6 "strconv"
6 "time" 7 "time"
7 8
@@ -118,6 +119,7 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) @@ -118,6 +119,7 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery)
118 stepItem := adapter.AssessTaskStep{ 119 stepItem := adapter.AssessTaskStep{
119 SortBy: v.SortBy, 120 SortBy: v.SortBy,
120 LinkNodeName: v.LinkNodeName, 121 LinkNodeName: v.LinkNodeName,
  122 + LinkNodeId: v.LinkNodeId,
121 BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"), 123 BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
122 EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), 124 EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
123 LinkNodeType: v.LinkNodeType, 125 LinkNodeType: v.LinkNodeType,
@@ -206,7 +208,10 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) @@ -206,7 +208,10 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery)
206 } 208 }
207 } 209 }
208 } 210 }
209 - result.StepList = append(result.StepList, stepItem) 211 + //未参与的,不算在个人的评估环节里
  212 + if stepItem.Status != "" {
  213 + result.StepList = append(result.StepList, stepItem)
  214 + }
210 } 215 }
211 if err := transactionContext.CommitTransaction(); err != nil { 216 if err := transactionContext.CommitTransaction(); err != nil {
212 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 217 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -230,7 +235,7 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) @@ -230,7 +235,7 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery)
230 staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ 235 staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
231 "transactionContext": transactionContext, 236 "transactionContext": transactionContext,
232 }) 237 })
233 - var limit int = 20 238 + var limit int = 100
234 var offset int = 0 239 var offset int = 0
235 if param.PageSize > 0 { 240 if param.PageSize > 0 {
236 limit = param.PageSize 241 limit = param.PageSize
@@ -241,8 +246,9 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) @@ -241,8 +246,9 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery)
241 "companyId": param.CompanyId, 246 "companyId": param.CompanyId,
242 "typesList": []string{string(domain.AssessSelf)}, 247 "typesList": []string{string(domain.AssessSelf)},
243 "limit": limit, 248 "limit": limit,
244 - "status": string(domain.StaffAssessCompleted), 249 + "endTime": time.Now(), //获取历史记录
245 } 250 }
  251 + // "status": string(domain.StaffAssessCompleted),
246 if offset > 0 { 252 if offset > 0 {
247 condition["offset"] = offset 253 condition["offset"] = offset
248 } 254 }
@@ -333,16 +339,6 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) @@ -333,16 +339,6 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery)
333 339
334 // 根据项目评估的配置,创建员工的评估任务 340 // 根据项目评估的配置,创建员工的评估任务
335 func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext application.TransactionContext, param *command.CreateStaffAssessTask) (map[string]interface{}, error) { 341 func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext application.TransactionContext, param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
336 - // transactionContext, err := factory.CreateTransactionContext(nil)  
337 - // if err != nil {  
338 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
339 - // }  
340 - // if err := transactionContext.StartTransaction(); err != nil {  
341 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
342 - // }  
343 - // defer func() {  
344 - // _ = transactionContext.RollbackTransaction()  
345 - // }()  
346 log.Logger.Debug("CreateStaffAssessTask 获取参数", map[string]interface{}{ 342 log.Logger.Debug("CreateStaffAssessTask 获取参数", map[string]interface{}{
347 "param": param, 343 "param": param,
348 }) 344 })
@@ -358,30 +354,64 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat @@ -358,30 +354,64 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
358 return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime) 354 return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
359 } 355 }
360 nowTime := time.Now() 356 nowTime := time.Now()
361 - //建立评估任务  
362 - assessTaskData := &domain.StaffAssessTask{  
363 - Id: 0,  
364 - CompanyId: param.CompanyId,  
365 - EvaluationProjectId: param.EvaluationProjectId,  
366 - EvaluationProjectName: param.EvaluationProjectName,  
367 - CycleId: param.CycleId,  
368 - CycleName: param.CycleName,  
369 - BeginTime: taskBeginTime,  
370 - EndTime: taskEndTime,  
371 - StepList: []domain.AssessTaskStep{},  
372 - ExecutorId: nil,  
373 - CreatedAt: nowTime,  
374 - UpdatedAt: nowTime,  
375 - DeletedAt: nil,  
376 - BeginDay: taskBeginTime.Local().Format("2006-01-02"),  
377 - }  
378 - // }  
379 357
380 - //填充评估环节 358 + _, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
  359 + "evaluationProjectId": param.EvaluationProjectId,
  360 + "beginDay": taskBeginTime.Local().Format("2006-01-02"),
  361 + })
  362 + if err != nil {
  363 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期同项目已存在的评估任务"+err.Error())
  364 + }
  365 + var assessTaskData *domain.StaffAssessTask
  366 + //更新旧数据或者新建数据
  367 + if len(assassessTaskList) > 0 {
  368 + assessTaskData = assassessTaskList[0]
  369 + assessTaskData.UpdatedAt = nowTime
  370 + } else {
  371 + //建立新的评估任务
  372 + assessTaskData = &domain.StaffAssessTask{
  373 + Id: 0,
  374 + CompanyId: param.CompanyId,
  375 + EvaluationProjectId: param.EvaluationProjectId,
  376 + EvaluationProjectName: param.EvaluationProjectName,
  377 + CycleId: param.CycleId,
  378 + CycleName: param.CycleName,
  379 + BeginTime: taskBeginTime,
  380 + EndTime: taskEndTime,
  381 + StepList: []domain.AssessTaskStep{},
  382 + ExecutorId: []int{},
  383 + CreatedAt: nowTime,
  384 + UpdatedAt: nowTime,
  385 + DeletedAt: nil,
  386 + BeginDay: taskBeginTime.Local().Format("2006-01-02"),
  387 + }
  388 + }
  389 + executorIds := []int{} //提取评估的参与人id
  390 + executorIdMap := map[int]struct{}{} //过滤重复的用户
  391 + //从入参中提取参与人
  392 + for _, v := range param.ExecutorId {
  393 + if _, ok := executorIdMap[v]; ok {
  394 + continue
  395 + }
  396 + executorIdMap[v] = struct{}{}
  397 + executorIds = append(executorIds, v)
  398 + }
  399 + //就数据中提取参与人
  400 + for _, v := range assessTaskData.ExecutorId {
  401 + if _, ok := executorIdMap[v]; ok {
  402 + continue
  403 + }
  404 + executorIdMap[v] = struct{}{}
  405 + executorIds = append(executorIds, v)
  406 + }
  407 + //填入新的参与人id
  408 + assessTaskData.ExecutorId = executorIds
  409 + //填充新的评估环节
  410 +loop:
381 for _, v := range param.StepList { 411 for _, v := range param.StepList {
382 for _, vv := range assessTaskData.StepList { 412 for _, vv := range assessTaskData.StepList {
383 - if vv.LinkNodeType == v.LinkNodeType {  
384 - continue 413 + if vv.LinkNodeId == v.LinkNodeId {
  414 + continue loop
385 } 415 }
386 } 416 }
387 stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) 417 stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
@@ -402,44 +432,15 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat @@ -402,44 +432,15 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
402 } 432 }
403 assessTaskData.StepList = append(assessTaskData.StepList, step) 433 assessTaskData.StepList = append(assessTaskData.StepList, step)
404 } 434 }
405 - //评估的参与人  
406 - executorIds := []int{}  
407 - executorIdMap := map[int]struct{}{} //过滤重复的用户  
408 - for _, v := range param.ExecutorId {  
409 - if _, ok := executorIdMap[v]; ok {  
410 - continue  
411 - }  
412 - executorIdMap[v] = struct{}{}  
413 - executorIds = append(executorIds, v)  
414 - }  
415 - assessTaskData.ExecutorId = executorIds 435 + //排序流程环节
  436 + stepList := domain.SortTaskStep(assessTaskData.StepList)
  437 + sort.Sort(stepList)
  438 + assessTaskData.StepList = stepList
  439 + //添加员工的节点任务
416 assessList, err := srv.createStaffAssess(transactionContext, assessTaskData) 440 assessList, err := srv.createStaffAssess(transactionContext, assessTaskData)
417 if err != nil { 441 if err != nil {
418 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error()) 442 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
419 } 443 }
420 - // var assessTaskData *domain.StaffAssessTask  
421 - _, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{  
422 - "evaluationProjectId": param.EvaluationProjectId,  
423 - "beginDay": taskBeginTime.Local().Format("2006-01-02"),  
424 - })  
425 - if err != nil {  
426 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error())  
427 - }  
428 -  
429 - if len(assassessTaskList) > 0 {  
430 - //过滤就数据  
431 - assessTaskData.Id = assassessTaskList[0].Id  
432 - for _, v := range assassessTaskList[0].ExecutorId {  
433 - if _, ok := executorIdMap[v]; ok {  
434 - continue  
435 - }  
436 - executorIdMap[v] = struct{}{}  
437 - executorIds = append(executorIds, v)  
438 - }  
439 - assessTaskData.ExecutorId = executorIds  
440 - assessTaskData.StepList = append(assassessTaskList[0].StepList, assessTaskData.StepList...)  
441 -  
442 - }  
443 _, err = assessTaskRepo.Save(assessTaskData) 444 _, err = assessTaskRepo.Save(assessTaskData)
444 if err != nil { 445 if err != nil {
445 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) 446 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
@@ -455,10 +456,6 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat @@ -455,10 +456,6 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
455 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error()) 456 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
456 } 457 }
457 } 458 }
458 -  
459 - // if err := transactionContext.CommitTransaction(); err != nil {  
460 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
461 - // }  
462 return map[string]interface{}{ 459 return map[string]interface{}{
463 "assessTaskId": assessTaskData.Id, 460 "assessTaskId": assessTaskData.Id,
464 }, nil 461 }, nil
@@ -564,7 +561,6 @@ func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAsse @@ -564,7 +561,6 @@ func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAsse
564 userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess { 561 userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess {
565 result := []domain.StaffAssess{} 562 result := []domain.StaffAssess{}
566 for _, usr := range userList { 563 for _, usr := range userList {
567 -  
568 assessTemp.TargetUser = domain.StaffDesc{ 564 assessTemp.TargetUser = domain.StaffDesc{
569 UserId: int(usr.Id), 565 UserId: int(usr.Id),
570 Account: usr.Account, 566 Account: usr.Account,
@@ -588,7 +584,7 @@ func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAsse @@ -588,7 +584,7 @@ func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAsse
588 return result 584 return result
589 } 585 }
590 586
591 -// 构建员工上级评估 587 +// 构建员工上级评估
592 func (srv StaffAssessServeice) createStaffAssessSupper( 588 func (srv StaffAssessServeice) createStaffAssessSupper(
593 transactionContext application.TransactionContext, 589 transactionContext application.TransactionContext,
594 assessTemp domain.StaffAssess, 590 assessTemp domain.StaffAssess,
@@ -608,6 +604,7 @@ func (srv StaffAssessServeice) createStaffAssessSupper( @@ -608,6 +604,7 @@ func (srv StaffAssessServeice) createStaffAssessSupper(
608 if len(vv2.ChargeUserIds) == 0 { 604 if len(vv2.ChargeUserIds) == 0 {
609 continue 605 continue
610 } 606 }
  607 + //获取部门的主管
611 _, chargeUserList, err := userRepo.Find(map[string]interface{}{ 608 _, chargeUserList, err := userRepo.Find(map[string]interface{}{
612 "ids": vv2.ChargeUserIds, 609 "ids": vv2.ChargeUserIds,
613 "limit": 40, 610 "limit": 40,
@@ -728,7 +725,6 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -728,7 +725,6 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
728 defer func() { 725 defer func() {
729 _ = transactionContext.RollbackTransaction() 726 _ = transactionContext.RollbackTransaction()
730 }() 727 }()
731 -  
732 assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ 728 assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
733 "transactionContext": transactionContext, 729 "transactionContext": transactionContext,
734 }) 730 })
@@ -761,6 +757,12 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -761,6 +757,12 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
761 if inviteNode == nil { 757 if inviteNode == nil {
762 return nil, application.ThrowError(application.ARG_ERROR, "评估任务没有邀请评估的环节") 758 return nil, application.ThrowError(application.ARG_ERROR, "评估任务没有邀请评估的环节")
763 } 759 }
  760 + //检查节点的结束时间
  761 + endTimeInt := inviteNode.EndTime.Unix()
  762 + if endTimeInt < time.Now().Unix() {
  763 + e := fmt.Sprintf("该环节已在%s截止", inviteNode.EndTime.Local().Format("2006-01-02 15:04:05"))
  764 + return nil, application.ThrowError(application.BUSINESS_ERROR, e)
  765 + }
764 766
765 targetUser, err := userRepo.FindOne(map[string]interface{}{ 767 targetUser, err := userRepo.FindOne(map[string]interface{}{
766 "id": param.TargetUserId, 768 "id": param.TargetUserId,
@@ -1651,6 +1653,13 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1651,6 +1653,13 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1651 if err != nil { 1653 if err != nil {
1652 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) 1654 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
1653 } 1655 }
  1656 +
  1657 + //检查截止时间
  1658 + endTimeInt := assessData.EndTime.Unix()
  1659 + if endTimeInt < time.Now().Unix() {
  1660 + return nil, application.ThrowError(application.BUSINESS_ERROR, "当前环节已过截止时间,提交后无法修改内容")
  1661 + }
  1662 +
1654 assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{ 1663 assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
1655 "transactionContext": transactionContext, 1664 "transactionContext": transactionContext,
1656 }) 1665 })
@@ -1658,7 +1667,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1658,7 +1667,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1658 assessContentList := []*domain.StaffAssessContent{} 1667 assessContentList := []*domain.StaffAssessContent{}
1659 if assessData.Status == domain.StaffAssessCompleted { 1668 if assessData.Status == domain.StaffAssessCompleted {
1660 //已完成 1669 //已完成
1661 -  
1662 _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{ 1670 _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
1663 "staffAssessId": assessData.Id, 1671 "staffAssessId": assessData.Id,
1664 }) 1672 })
@@ -6,6 +6,7 @@ import ( @@ -6,6 +6,7 @@ import (
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" 6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
7 ) 7 )
8 8
  9 +//调试用,手动调用CreateStaffAssessTask
9 func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) { 10 func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
10 transactionContext, err := factory.CreateTransactionContext(nil) 11 transactionContext, err := factory.CreateTransactionContext(nil)
11 if err != nil { 12 if err != nil {
@@ -10,7 +10,7 @@ type StaffAssessTask struct { @@ -10,7 +10,7 @@ type StaffAssessTask struct {
10 EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 10 EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
11 CycleId int64 `json:"cycleId"` //对应的周期id 11 CycleId int64 `json:"cycleId"` //对应的周期id
12 CycleName string `json:"cycleName"` //对应周期的名称 12 CycleName string `json:"cycleName"` //对应周期的名称
13 - BeginDay string `json:"beginDay"` //绩效考核日期 13 + BeginDay string `json:"beginDay"` //绩效考核日期 ,2006-01-02
14 BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 14 BeginTime time.Time `json:"beginTime"` //绩效考核开始时间
15 EndTime time.Time `json:"endTime"` //绩效考核截止时间 15 EndTime time.Time `json:"endTime"` //绩效考核截止时间
16 StepList []AssessTaskStep `json:"stepList"` //考评的流程 16 StepList []AssessTaskStep `json:"stepList"` //考评的流程
@@ -30,6 +30,12 @@ type AssessTaskStep struct { @@ -30,6 +30,12 @@ type AssessTaskStep struct {
30 EndTime time.Time `json:"endTime"` //绩效考核截止时间 30 EndTime time.Time `json:"endTime"` //绩效考核截止时间
31 } 31 }
32 32
  33 +type SortTaskStep []AssessTaskStep
  34 +
  35 +func (a SortTaskStep) Len() int { return len(a) }
  36 +func (a SortTaskStep) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
  37 +func (a SortTaskStep) Less(i, j int) bool { return a[i].SortBy < a[j].SortBy }
  38 +
33 type StaffAssessTaskRepository interface { 39 type StaffAssessTaskRepository interface {
34 Save(param *StaffAssessTask) (*StaffAssessTask, error) 40 Save(param *StaffAssessTask) (*StaffAssessTask, error)
35 Remove(id int) error 41 Remove(id int) error
@@ -56,7 +56,7 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask @@ -56,7 +56,7 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask
56 return result, err 56 return result, err
57 } 57 }
58 58
59 -// 搜索 executorId 参与的评估任务 59 +// 根据评估的人执行人id,搜索 executorId参与的评估任务
60 func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) { 60 func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) {
61 61
62 if limit < 0 { 62 if limit < 0 {
@@ -70,6 +70,7 @@ func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit @@ -70,6 +70,7 @@ func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit
70 JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id" 70 JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
71 WHERE staff_assess.company_id=? 71 WHERE staff_assess.company_id=?
72 and staff_assess.executor->>'userId'='?' 72 and staff_assess.executor->>'userId'='?'
  73 + order by staff_assess_task.id desc
73 limit ? offset ? 74 limit ? offset ?
74 ` 75 `
75 tx := d.transactionContext.PgTx 76 tx := d.transactionContext.PgTx
@@ -147,12 +147,15 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -147,12 +147,15 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
147 if v, ok := queryOptions["id"]; ok { 147 if v, ok := queryOptions["id"]; ok {
148 query.Where("id=?", v) 148 query.Where("id=?", v)
149 } 149 }
150 - if v, ok := queryOptions["typesList"].([]string); ok && len(v) > 0 { 150 + if v, ok := queryOptions["typesList"].([]string); ok {
151 query.Where("types in(?)", pg.In(v)) 151 query.Where("types in(?)", pg.In(v))
152 } 152 }
153 - if v, ok := queryOptions["status"].(string); ok && len(v) > 0 { 153 + if v, ok := queryOptions["status"].(string); ok {
154 query.Where("status=?", v) 154 query.Where("status=?", v)
155 } 155 }
  156 + if v, ok := queryOptions["endTime"]; ok {
  157 + query.Where("end_time<=?", v)
  158 + }
156 count, err := query.SelectAndCount() 159 count, err := query.SelectAndCount()
157 if err != nil { 160 if err != nil {
158 return 0, nil, err 161 return 0, nil, err