作者 tangxvhui

暂存

... ... @@ -4,4 +4,5 @@ type AssessCycleDayResp struct {
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"`
BeginDay string `json:"beginDay"`
AssessTaskId []int `json:"assessTaskId"`
}
... ...
package query
//个人的获取周期任务完成情况描述
type AssessCycleDescQuery struct {
CycleId int `json:"cycleId"` //评估任务的id
BeginDay string `json:"beginDay"` //开始时间 2022-01-02
AssessTaskId []int `json:"assessTaskId"` //评估任务的id
UserId int `json:"userId"` //当前登录人的id
CompanyId int `json:"companyId"` //当前登录的公司
}
... ...
package query
type ListExecutorInviteAssessQuery struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
UserName string `json:"userName"` //查询条件 员工的名称
CompanyId int `json:"companyId"` //
ExecutorId int `json:"executorId,string"` //评估的执行人,必填
CycleId int `json:"cycleId"` //评估任务id 必填
BeginDay string `json:"beginDay"`
}
... ...
... ... @@ -54,6 +54,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu
CycleId: v.CycleId,
CycleName: v.CycleName,
BeginDay: v.BeginDay,
AssessTaskId: v.AssessTaskId,
}
listData = append(listData, temp)
}
... ... @@ -80,22 +81,31 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskDataAny, err := staffAssessTaskRepo.FindOne(map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"limit": 1,
if len(param.AssessTaskId) == 0 {
return &adapter.AssessCycleDescResp{}, nil
}
_, assessTaskList, err := staffAssessTaskRepo.Find(map[string]interface{}{
"ids": param.AssessTaskId,
"companyId": param.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
}
_, myAssessTask, err := staffAssessTaskRepo.Find(map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"executorId": param.UserId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "我的评估任务不存在,"+err.Error())
if len(assessTaskList) == 0 {
return &adapter.AssessCycleDescResp{}, nil
}
assessTaskDataAny := assessTaskList[0]
var myAssessTask *domain.StaffAssessTask
for _, v := range assessTaskList {
if myAssessTask != nil {
break
}
for _, vv := range v.ExecutorId {
if param.UserId == vv {
myAssessTask = v
break
}
}
}
//返回的数据结果
result := adapter.AssessCycleDescResp{
... ... @@ -118,10 +128,10 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
}
switch v.LinkNodeType {
case domain.LinkNodeSelfAssessment:
if len(myAssessTask) > 0 {
if myAssessTask != nil {
//个人自评完成情况
_, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": myAssessTask[0].Id,
"staffAssessTaskId": myAssessTask.Id,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSelf)},
})
... ... @@ -134,10 +144,10 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
}
case domain.LinkNodeAllInvite:
if len(myAssessTask) > 0 {
if myAssessTask != nil {
//邀请别人评估自己
_, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": myAssessTask[0].Id,
"staffAssessTaskId": myAssessTask.Id,
"targetUserId": param.UserId, //我被作为目标
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"limit": 5,
... ... @@ -160,8 +170,7 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
case domain.LinkNodeAllAssessment:
//我评估别人,被邀请评估
_, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
//TODO
"executorId": param.UserId, //我作为执行人
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
})
... ... @@ -180,24 +189,32 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
}
case domain.LinkNodeSuperiorAssessment:
//我评估别人,上级评估
_, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{
cnnt, _, err := staffAssessRepo.Find(map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSuper)},
"status": domain.StaffAssessUncompleted,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取未完成的评估环节"+err.Error())
}
if len(assessSupperList) > 0 {
cnnt2, _, err := staffAssessRepo.Find(map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSuper)},
"status": domain.StaffAssessCompleted,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取已完成的评估环节"+err.Error())
}
if cnnt+cnnt2 > 0 {
stepItem.Status = string(domain.StaffAssessCompleted)
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
uncompletedNum := 0
for _, v := range assessSupperList {
if v.Status == domain.StaffAssessUncompleted {
uncompletedNum += 1
}
}
uncompletedNum := cnnt
if uncompletedNum > 0 {
stepItem.Status = string(domain.StaffAssessUncompleted)
stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
... ... @@ -287,7 +304,7 @@ func (srv StaffAssessServeice) ListAssessInviteUser(param query.ListAssessInvite
}
// 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值
func (srv StaffAssessServeice) ListExecutorInviteAssessDay(param *query.ListInviteUserAssessQuery) (
func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExecutorInviteAssessQuery) (
*adapter.ListInviteUserAssessResp, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -306,10 +323,10 @@ func (srv StaffAssessServeice) ListExecutorInviteAssessDay(param *query.ListInvi
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取 executorId 对应的360评估任务 用户
condition := map[string]interface{}{
"staffAssessTaskId": param.AssessTaskId,
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"limit": 20,
... ... @@ -372,17 +389,22 @@ func (srv StaffAssessServeice) ListExecutorInviteAssessDay(param *query.ListInvi
//获取360邀请评估完成情况
//我评估别人,被邀请评估
cnnt, _, err := assessRepo.Find(map[string]interface{}{
"staffAssessTaskId": param.AssessTaskId,
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"status": domain.StaffAssessUncompleted,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{
"id": param.AssessTaskId,
_, myAssessTaskData, err := assessTaskRepo.Find(map[string]interface{}{
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())
... ... @@ -415,7 +437,6 @@ func (srv StaffAssessServeice) ListExecutorInviteAssessDay(param *query.ListInvi
case domain.StaffAssessUncompleted:
m["status"] = "未完成"
}
switch v.Types {
case domain.AssessInviteDiffSuper:
m["types"] = "不同上级同事"
... ... @@ -438,12 +459,19 @@ func (srv StaffAssessServeice) ListExecutorInviteAssessDay(param *query.ListInvi
List: listData,
Total: cnt,
}
for _, v := range assessTaskData.StepList {
if len(myAssessTaskData) > 0 {
for _, v := range myAssessTaskData[0].StepList {
if v.LinkNodeType == domain.LinkNodeAllAssessment {
result.LinkNodeId = v.LinkNodeId
result.LinkNodeName = v.LinkNodeName
result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
}
}
}
return &result, nil
}
func (srv StaffAssessServeice) ListExecutorSupperAssessDay() (map[string]interface{}, error) {
return nil, nil
}
... ...
... ... @@ -381,8 +381,15 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa
return result, err
}
type AssessCycleDayMe struct {
BeginDay string `json:"beginDay"`
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"`
AssessTaskId []int `json:"assessTaskId"`
}
// 根据评估的人执行人id,搜索 executorId参与的评估周期
func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDay, error) {
func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDayMe, error) {
if limit < 0 {
limit = 20
}
... ... @@ -390,19 +397,23 @@ func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limi
offset = 0
}
sqlStr := `
SELECT DISTINCT staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day
SELECT
jsonb_agg (staff_assess_task.id) as assess_task_id,
staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day
FROM staff_assess_task
JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
WHERE staff_assess.company_id=?
and staff_assess_task.deleted_at isnull
and staff_assess.executor->>'userId'='?'
group by staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day
order by staff_assess_task.begin_day desc
limit ? offset ?
`
tx := d.transactionContext.PgTx
condition := []interface{}{
companyId, executorId, limit, offset,
}
result := []AssessCycleDay{}
result := []AssessCycleDayMe{}
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
... ... @@ -410,7 +421,7 @@ func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limi
// 根据评估的人执行人id,统计executorId参与的评估周期
func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, error) {
sqlStr := `
select count(DISTINCT (staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day )) as cnt
select count(DISTINCT (staff_assess_task.cycle_id,staff_assess_task.begin_day )) as cnt
FROM staff_assess_task
JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
WHERE staff_assess.company_id=?
... ...
... ... @@ -144,6 +144,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if v, ok := queryOptions["staffAssessTaskId"]; ok {
query.Where(`staff_assess_task_id=?`, v)
}
if v, ok := queryOptions["id"]; ok {
query.Where("id=?", v)
}
... ...
... ... @@ -129,6 +129,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
if v, ok := queryOptions["evaluationProjectId"]; ok {
query.Where("evaluation_project_id=?", v)
}
if v, ok := queryOptions["ids"]; ok {
query.Where("id in (?) ", pg.In(v))
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...