作者 tangxvhui

修复一些问题

... ... @@ -5,23 +5,23 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
//评估内容详情
type AssessInfoResp struct {
AssessId int `json:"assessId"`
CycleId int64 `json:"cycleId,string"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
LinkNodeId int `json:"linkNodeId,string"` //评估环节id
LinkNodeName string `json:"linkNodeName"` //评估环节名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
Status string `json:"status"` //完成状态
TargetUserId int `json:"targetUserId,string"` //目标用户
TargetUserName string `json:"targetUserName"` //目标用户名称
CompanyId int `json:"companyId,string,"` //公司id
CompanyLogo string `json:"companyLogo,string,"` //公司logo
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间 //
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
CycleId int64 `json:"cycleId,string"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
LinkNodeId int `json:"linkNodeId,string"` //评估环节id
LinkNodeName string `json:"linkNodeName"` //评估环节名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
Status string `json:"status"` //完成状态
TargetUserId int `json:"targetUserId,string"` //目标用户
TargetUserName string `json:"targetUserName"` //目标用户名称
CompanyId int `json:"companyId,string,"` //公司id
CompanyLogo string `json:"companyLogo,string,"` //公司logo
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间 //
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
}
// 周期内的每日自评小结
... ...
... ... @@ -906,20 +906,20 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
return &adapter.AssessInfoResp{}, nil
}
assessData := assessList[0]
assessContentList := []*domain.StaffAssessContent{}
if assessData.Status == domain.StaffAssessCompleted {
//已完成
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
"staffAssessId": assessData.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
} else if assessData.Status == domain.StaffAssessUncompleted {
//未完成
var assessContentList []*domain.StaffAssessContent
//已完成
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
"staffAssessId": assessData.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
if len(assessContentList) == 0 {
// 未完成
assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
... ... @@ -1048,17 +1048,17 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
"transactionContext": transactionContext,
})
//待更新的评估填写信息
assessContentList := []*domain.StaffAssessContent{}
if assessData.Status == domain.StaffAssessCompleted {
//已完成
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
"staffAssessId": assessData.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
} else if assessData.Status == domain.StaffAssessUncompleted {
//未完成
var assessContentList []*domain.StaffAssessContent
//已完成
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
"staffAssessId": assessData.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
if len(assessContentList) == 0 {
// 未完成
assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
... ... @@ -1102,19 +1102,14 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
}
}
//保存信息
hasValue := false //评估是否有填写值
for i := range assessContentList {
_, err = assessContentRepo.Save(assessContentList[i])
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估填写内容"+err.Error())
}
if len(assessContentList[i].Value) > 0 {
hasValue = true
}
}
if hasValue {
assessData.Status = domain.StaffAssessCompleted
}
assessData.Status = domain.StaffAssessCompleted
assessData.UpdatedAt = time.Now()
_, err = assessReps.Save(assessData)
if err != nil {
... ...
... ... @@ -37,6 +37,9 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ
if param.PageSize > 0 {
limit = param.PageSize
}
if param.PageNumber <= 0 {
param.PageNumber = 1
}
offset = (param.PageNumber - 1) * param.PageSize
assessCycleList, cnt, err := staffAssessDao.SearchExecutorAssessBeforeNow(param.UserId, param.CompanyId, limit, offset)
... ... @@ -1217,24 +1220,24 @@ func (srv StaffAssessServeice) getStaffAssessBeforeEdit(param *query.AssessInfoQ
return &adapter.AssessInfoResp{}, nil
}
assessData := assessList[0]
assessContentList := []*domain.StaffAssessContent{}
if assessData.Status == domain.StaffAssessCompleted {
//已完成
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
"staffAssessId": assessData.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
} else if assessData.Status == domain.StaffAssessUncompleted {
var assessContentList []*domain.StaffAssessContent
//已完成
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
"staffAssessId": assessData.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
if len(assessContentList) == 0 {
//未完成
assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
}
// 恢复缓存数据
srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
... ...
... ... @@ -1306,7 +1306,7 @@ func (d *StaffAssessDao) SearchExecutorAssessBeforeNow(executorId int, companyId
and staff_assess.deleted_at isnull
and staff_assess_task.deleted_at isnull
and (
staff_assess.end_time < now() or staff_assess.status ='completed'
staff_assess.end_time < now()
)
and staff_assess.executor ->> 'userId'='?'
order by begin_day desc
... ... @@ -1325,7 +1325,7 @@ func (d *StaffAssessDao) SearchExecutorAssessBeforeNow(executorId int, companyId
WHERE staff_assess.company_id=?
and staff_assess.deleted_at isnull
and (
staff_assess.end_time < now() or staff_assess.status ='completed'
staff_assess.end_time < now()
)
and staff_assess_task.deleted_at isnull
and staff_assess.executor ->> 'userId'='?'
... ... @@ -1362,7 +1362,7 @@ func (d *StaffAssessDao) SearchExecutorAssessAfterNow(executorId int, companyId
WHERE staff_assess.company_id=?
and staff_assess.deleted_at isnull
and (
staff_assess.end_time >= now() and staff_assess.status ='uncompleted'
staff_assess.end_time >= now()
)
and staff_assess_task.deleted_at isnull
and staff_assess.executor ->> 'userId'='?'
... ...
... ... @@ -299,21 +299,37 @@ func (d *StaffAssessDao) ListTargetUserNoInvite(companyId int, cycleId int, begi
}
type UserSelfStaffAssess struct {
CycleId string ``
AssessId string ``
TargetUserId string ``
TargetUserName string ``
CycleId string `pg:"cycle_id"`
AssessId string `pg:"assess_id"`
TargetUserId string `pg:"target_user_id"`
TargetUserName string `pg:"target_user_name"`
EvaluationProjectId string `pg:"evaluation_project_id"`
EvaluationProjectName string `pg:"evaluation_project_name"`
CompanyId string `pg:"company_id"`
BeginDay string `pg:"begin_day"`
}
type SearchConditin3 struct {
CompanyId int //公司id
CycleId int //周期id
BeginDay string //评估的日期
TargetUserName string //被评估人的名称
Limit int //分页
Offset int //分页
OperaterId int //用户的id是谁在搜索数据
Hrbp int //
Status string // 评估完成状态
}
// 根据周期的id和日期获取员工评估的评估任务。有进行查看权限过滤
// companyId int 公司id
// cycleId int, 评估周期id
// companyId int 公司id ,必填
// cycleId int, 评估周期id, 必填
// userId int, 用户id,谁要查看数据
// beginDay string, 周期中执行项目的时间
// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
// limit int, 分页条数
// offset int 分页偏移
func (d *StaffAssessDao) SearchUserSelfStaffAssess(param SearchConditin1) ([]UserAssessContent, error) {
func (d *StaffAssessDao) SearchUserSelfStaffAssess(param SearchConditin3) ([]UserSelfStaffAssess, error) {
withSql := d.catchProjectIdByPermission(param.CompanyId, param.CycleId, param.OperaterId, param.Hrbp)
sqlStr := `select
staff_assess.cycle_id ,
... ... @@ -323,9 +339,9 @@ func (d *StaffAssessDao) SearchUserSelfStaffAssess(param SearchConditin1) ([]Use
staff_assess.evaluation_project_id ,
staff_assess.evaluation_project_name ,
staff_assess.company_id ,
staff_assess.begin_time
to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD') as begin_day
from staff_assess
join evaluation_project on staff_assess.evaluation_project_id =evaluation_project.id
join t_project_4 on staff_assess.evaluation_project_id =t_project_4.project_id
where 1=1
and staff_assess.cycle_id =?
and staff_assess.deleted_at isnull
... ... @@ -339,19 +355,53 @@ func (d *StaffAssessDao) SearchUserSelfStaffAssess(param SearchConditin1) ([]Use
condition = append(condition, "%"+param.TargetUserName+"%")
sqlStr += ` and staff_assess.target_user ->>'userName' like ? `
}
if len(param.TargetUserId) > 0 {
condition = append(condition, pg.In(param.TargetUserId))
sqlStr += ` and staff_assess.target_user ->>'userId' in (?) `
if len(param.Status) > 0 {
condition = append(condition, param.Status)
sqlStr += ` and staff_assess.status=? `
}
condition = append(condition, param.Limit, param.Offset)
sqlStr += ` order by convert_to(staff_assess.target_user ->>'userName','GBK') limit ? offset ? `
sqlStr2 := withSql + withSql
// and to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')='2023-03-29'
_ = sqlStr2
// and staff_assess.cycle_id =1639084510698016768
// -- and staff_assess.target_user ->>'userName' like '%陈%'
// -- and staff_assess.target_user ->>'userId' in ('')
// order by convert_to(staff_assess.target_user ->>'userName','GBK')
return nil, nil
tx := d.transactionContext.PgTx
var result []UserSelfStaffAssess
_, err := tx.Query(&result, sqlStr2, condition...)
return result, err
}
// 根据周期的id和日期获取员工评估的评估任务数量。有进行查看权限过滤
// companyId int 公司id
// cycleId int, 评估周期id
// userId int, 用户id,谁要查看数据
// beginDay string, 周期中执行项目的时间
// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
func (d *StaffAssessDao) CountUserSelfStaffAssess(param SearchConditin3) (int, error) {
withSql := d.catchProjectIdByPermission(param.CompanyId, param.CycleId, param.OperaterId, param.Hrbp)
sqlStr := `select
count(*)
from staff_assess
join t_project_4 on staff_assess.evaluation_project_id =t_project_4.project_id
where 1=1
and staff_assess.cycle_id =?
and staff_assess.deleted_at isnull
`
condition := []interface{}{param.CycleId}
if len(param.BeginDay) > 0 {
condition = append(condition, param.BeginDay)
sqlStr += ` and to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')=? `
}
if len(param.TargetUserName) > 0 {
condition = append(condition, "%"+param.TargetUserName+"%")
sqlStr += ` and staff_assess.target_user ->>'userName' like ? `
}
if len(param.Status) > 0 {
condition = append(condition, param.Status)
sqlStr += ` and staff_assess.status=? `
}
sqlStr2 := withSql + withSql
tx := d.transactionContext.PgTx
var result int
_, err := tx.Query(pg.Scan(&result), sqlStr2, condition...)
return result, err
}
... ...