作者 郑周

Merge remote-tracking branch 'origin/test' into test

... ... @@ -5,22 +5,22 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
//评估内容详情
type AssessInfoResp struct {
AssessId int `json:"assessId"`
CycleId int64 `json:"cycleId"` //周期id
CycleId int64 `json:"cycleId,string"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
LinkNodeId int `json:"linkNodeId"`
LinkNodeId int `json:"linkNodeId,string"`
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:"targetUser"` //目标用户
TargetUserName string `json:"targetUserName"` //目标用户名称
CompanyId int `json:"companyId,string,"` //
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间 //
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
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,"` //
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间 //
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
}
type AssessContent struct {
... ...
package adapter
type AssessTaskDescResp struct {
AssessTaskId int `json:"assessTaskId"` //
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
CycleName string `json:"cycleName"` //周期名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
StepList []AssessTaskStep `json:"stepList"` // 考评流程
AssessTaskId int `json:"assessTaskId"` //
EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
CycleName string `json:"cycleName"` //周期名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
StepList []AssessTaskStep `json:"stepList"` // 考评流程
}
type AssessTaskStep struct {
... ...
... ... @@ -2,7 +2,7 @@ package adapter
type ListSupperAssessResp struct {
AssessId int `json:"assessId"` //
UsrId int `json:"userId"`
UsrId int `json:"userId,string"`
UserName string `json:"userName"` //用户名称
EndTime string `json:"endTime"` //截止时间
InviteTotal int `json:"inviteTota"` //邀请总数
... ...
... ... @@ -37,27 +37,40 @@ func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQue
defer func() {
_ = transactionContext.RollbackTransaction()
}()
staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
// staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
staffAssessTaskRepo := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
var limit int = 20
var limit int = 200
var offset int = 0
if param.PageSize > 0 {
limit = param.PageSize
}
offset = (param.PageNumber - 1) * param.PageSize
condition := map[string]interface{}{
"executorId": param.UserId,
"companyId": param.CompanyId,
"limit": limit,
}
if offset > 0 {
condition["offset"] = offset
assessTaskList, err := staffAssessTaskRepo.SearchAssessTaskMe(param.UserId, param.CompanyId, limit, offset)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估任务"+err.Error())
}
cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition)
cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估任务"+err.Error())
}
// condition := map[string]interface{}{
// "executorId": param.UserId,
// "companyId": param.CompanyId,
// "limit": limit,
// }
// if offset > 0 {
// condition["offset"] = offset
// }
// cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition)
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error())
// }
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -200,6 +213,7 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery)
}
}
if uncompletedNum > 0 {
stepItem.Status = string(domain.StaffAssessUncompleted)
stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
}
}
... ... @@ -356,10 +370,6 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
}
nowTime := time.Now()
// if len(assassessTaskList) > 0 {
// assessTaskData = assassessTaskList[0]
// assessTaskData.UpdatedAt = nowTime
// } else {
//建立评估任务
assessTaskData := &domain.StaffAssessTask{
Id: 0,
... ... @@ -551,11 +561,11 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application.
stepSelfTemp.LinkNodeId = v.LinkNodeId
stepSelfTemp.LinkNodeName = v.LinkNodeName
stepSelfTemp.Types = domain.AssessSuper
assessListTemp, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap)
assessListTemp2, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap)
if err != nil {
return nil, err
}
assessList = append(assessList, assessListTemp...)
assessList = append(assessList, assessListTemp2...)
}
}
return assessList, nil
... ... @@ -1655,6 +1665,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
}
}
}
//保存信息
for i := range assessContentList {
_, err = assessContentRepo.Save(assessContentList[i])
... ... @@ -1662,6 +1673,12 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估填写内容"+err.Error())
}
}
assessData.Status = domain.StaffAssessCompleted
assessData.UpdatedAt = time.Now()
_, err = assessReps.Save(assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
type StaffAssessDao struct {
... ... @@ -54,3 +55,46 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
// 搜索 executorId 参与的评估任务
func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) {
if limit < 0 {
limit = 20
}
if offset < 0 {
offset = 0
}
sqlStr := `SELECT DISTINCT staff_assess_task.* 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.executor->>'userId'='?'
limit ? offset ?
`
tx := d.transactionContext.PgTx
condition := []interface{}{
companyId, executorId, limit, offset,
}
result := []*domain.StaffAssessTask{}
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
// 搜索 executorId 参与的评估任务
func (d *StaffAssessDao) CountAssessTaskMe(executorId int, companyId int) (int, error) {
sqlStr := `SELECT count( DISTINCT staff_assess_task."id") 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.executor->>'userId'='?'
`
tx := d.transactionContext.PgTx
condition := []interface{}{
companyId, executorId,
}
result := 0
_, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
return result, err
}
... ...
... ... @@ -115,7 +115,7 @@ func (c *StaffAssessController) GetAssessMeInviteUser() {
c.Response(data, err)
}
// 保我邀请的员工
// 保我邀请的员工
func (c *StaffAssessController) SaveAssessMeInviteUser() {
srv := service.NewStaffAssessServeice()
paramReq := &command.SaveAssessInvite{}
... ... @@ -128,6 +128,8 @@ func (c *StaffAssessController) SaveAssessMeInviteUser() {
//TODO 获取当前用户信息
// paramReq.CompanyId = 1
// paramReq.UserId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.SaveAssessInviteUser(paramReq)
c.Response(data, err)
}
... ...