作者 tangxvhui

更新

package query
// 查询评估的执行人
type ListExecutorQuery struct {
CycleId int `json:"cycleId"` //周期id
BeginDay string `json:"beginDay"` //日期 2006-01-02
Types string `json:"types"` // 评估类型 自评:self;上级:super;360评估:invite
CompanyId int `json:"-"`
}
... ...
... ... @@ -1278,6 +1278,59 @@ func (srv StaffAssessServeice) getStaffAssessBeforeEdit(param *query.AssessInfoQ
}
// 获取未完成评估任务的执行人员名单
func (srv StaffAssessServeice) ListExcutorUncompleted() error {
return nil
func (srv StaffAssessServeice) ListExcutorUncompleted(param *query.ListExecutorQuery) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
condition := map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"companyId": param.CompanyId,
"status": string(domain.StaffAssessUncompleted),
"typesList": []string{""},
}
switch param.Types {
case "self":
condition["typesList"] = []string{string(domain.AssessSelf)}
case "super":
condition["typesList"] = []string{string(domain.AssessSuper)}
case "invite":
condition["typesList"] = []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}
}
_, assessList, err := assessReps.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())
}
userList := []map[string]string{}
userMap := map[int]struct{}{} //过滤重复的用户id
for _, val := range assessList {
if _, ok := userMap[val.TargetUser.UserId]; ok {
continue
} else {
userMap[val.TargetUser.UserId] = struct{}{}
}
u := map[string]string{
"userId": strconv.Itoa(val.TargetUser.UserId),
"userName": val.TargetUser.UserName,
}
userList = append(userList, u)
}
result := map[string]interface{}{
"userList": userList,
}
return result, nil
}
... ...
... ... @@ -137,7 +137,6 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if v, ok := queryOptions["targetUserIds"]; ok {
query.Where(`staff_assess.target_user->>'userId' in(?)`, pg.In(v))
}
if v, ok := queryOptions["targetUserName"].(string); ok {
query.Where(`staff_assess.target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v))
}
... ...
... ... @@ -355,3 +355,18 @@ func (c *StaffAssessController) GetStaffAsessSelfCountLevel() {
data, err := srv.GetStaffAsessSelfCountLevel(paramReq)
c.Response(data, err)
}
func (c *StaffAssessController) ListExcutorUncompleted() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListExecutorQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.ListExcutorUncompleted(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -36,6 +36,7 @@ func init() {
web.NSCtrlPost("/summary/export-indicator", (*controllers.StaffAssessController).ExportPerformanceIndicator), //员工绩效-综合管理-绩效导出指标
web.NSCtrlPost("/target_user/self/cycle", (*controllers.StaffAssessController).ListTargetUserSelfCycle), //获取员工自评的周期下拉列表
web.NSCtrlPost("/target_user/self/summary", (*controllers.StaffAssessController).GetStaffAsessSelfCountLevel), //获取员工每日自评小结
web.NSCtrlPost("/list/executor/uncompleted", (*controllers.StaffAssessController).ListExcutorUncompleted), //获取周期内对应日期的未完成填写评估的人员
)
//v2 改版
assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task",
... ...