作者 郑周

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

# Conflicts:
#	pkg/port/beego/routers/staff_assess_router.go
不能预览此文件类型
package adapter
type AssessCycleDayResp struct {
CycleId int `json:"cycleId"`
CycleId string `json:"cycleId"`
CycleName string `json:"cycleName"`
BeginDay string `json:"beginDay"`
}
... ...
package query
// 获取我需要执行的上级评估成员列表
type ListSupperAssessQuery struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
... ...
... ... @@ -8,7 +8,7 @@ type AssessTaskDescQuery struct {
//获取我的项目周期进度描述
type AssessTaskDescV2Query struct {
CycleId int `json:"cycleId"`
CycleId int `json:"cycleId,string"`
BeginDay string `json:"beginDay"`
UserId int `json:"userId"` //当前登录人的id
CompanyId int `json:"companyId"` //当前登录的公司
... ...
... ... @@ -4,7 +4,7 @@ package query
type GetExecutorSelfAssessQuery struct {
CompanyId int `json:"companyId"` //
TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填
CycleId int `json:"cycleId"` //评估周期id 必填
CycleId int `json:"cycleId,string"` //评估周期id 必填
BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
AcquireCache int `json:"acquireCache"` // 0不获取缓存数据,1获取缓存数据
}
... ...
package query
//根据周期id和日期获取 员工填写评估内容
type ListAssessContentCycleDay struct {
CompanyId int `json:"companyId"`
OperaterId int `json:"operaterId"`
... ...
package query
//获取周期内的考核日期
type ListAssessCycleDay struct {
CompanyId int `json:"companyId"`
CycleId int `json:"cycleId,string"`
... ...
package query
// 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值
// 根据周期和日期获取我要执行的的评估,用户列表和评估填写的值
type ListExecutorAssessQuery 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 必填
CycleId int `json:"cycleId,string"` //评估周期id 必填
BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
}
... ...
... ... @@ -4,6 +4,6 @@ package query
type ListInviteUserQuery struct {
CompanyId int `json:"companyId"` //对公司
TargetUserId int `json:"targetUserId,string"` //被评估的员工id
CycleId int `json:"CycleId"` //评估任务的周期id
CycleId int `json:"CycleId,string"` //评估任务的周期id
BeginDay string `json:"beginDay"` //日期
}
... ...
package query
//获取我要执行的的360评估,用户列表和评估填写的值
type ListInviteUserAssessQuery struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
... ...
package query
//获取员工被其他人评估的列表
type ListTargetAssessQuery struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
CompanyId int `json:"companyId"` //
TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填
CycleId int `json:"cycleId,string"` //评估周期id 必填
BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
}
... ...
... ... @@ -279,30 +279,7 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery)
log.Logger.Error("获取用户信息," + err.Error())
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取用户信息,"+err.Error())
}
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// var supperUserList []*domain.User
// if len(userData.DepartmentId) > 0 {
// _, departmentList, err := departmentRepo.Find(map[string]interface{}{
// "ids": userData.DepartmentId,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
// }
// var chargeUserIds []int64
// for _, v := range departmentList {
// chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
// }
// if len(chargeUserIds) > 0 {
// _, supperUserList, err = userRepo.Find(map[string]interface{}{
// "ids": chargeUserIds,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
// }
// }
// }
supperUserList, _ := srv.getStaffSuper(transactionContext, *userData)
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -30,7 +30,7 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ
staffAssessTaskRepo := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
var limit int = 200
var limit int = 360
var offset int = 0
if param.PageSize > 0 {
limit = param.PageSize
... ... @@ -459,7 +459,7 @@ func (srv StaffAssessServeice) ListExecutorInviteAssessV2(param *query.ListExecu
return &result, nil
}
//根据周期和日期获取我需要执行的上级评估成员列表
// 根据周期和日期获取我需要执行的上级评估成员列表
func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecutorAssessQuery) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -609,7 +609,7 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
return result, nil
}
//根据周期和日期,获取员工的自评内容
// 根据周期和日期,获取员工的自评内容
func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfAssessQuery) (*adapter.AssessInfoResp, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -697,3 +697,45 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
}
return &result, nil
}
//根据周期和日期。获取360评估的列表,员工的被其他人评估
func (srv StaffAssessServeice) ListTargetUserInviteAssess(param *query.ListTargetAssessQuery) (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,
})
//获取员工的评估
cnt, assessList, err := assessReps.Find(map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"companyId": param.CompanyId,
"targetUserId": param.TargetUserId,
"typesList": []string{string(domain.AssessInviteSameSuper), string(domain.AssessInviteDiffSuper)},
})
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())
}
var resultList []map[string]interface{}
for _, v := range assessList {
item := map[string]interface{}{
"id": v.Id,
"targetUser": v.TargetUser,
"executor": v.Executor,
}
resultList = append(resultList, item)
}
return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
}
... ...
... ... @@ -12,6 +12,7 @@ type PerformanceApplicationForm struct {
Standard string //标准
Task string //任务、指标
Definition string //定义
Required string // 是否必填 是 否
}
type PerformanceDimension struct {
... ... @@ -24,6 +25,7 @@ type PerformanceModule struct {
Weight string `json:"weight"` //权重
Standard string `json:"standard"` //标准(结构化的成果描述)
Target []*PerformanceTarget `json:"performanceTarget"` //任务\指标
Required int `json:"required"` // 是否必填
}
type PerformanceTarget struct {
... ... @@ -34,6 +36,7 @@ type PerformanceTarget struct {
func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) {
formRows := make([]*PerformanceApplicationForm, 0)
var dimensionName, moduleName, taskName, weightName, standardName string
required := "是"
for key, item := range rows {
if key < 3 {
continue
... ... @@ -80,6 +83,11 @@ func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error)
}
}
form.Standard = standardName
//是否必填
if len(item) > 9 && item[9] != "" {
required = strings.TrimSpace(item[9])
}
form.Required = required
formRows = append(formRows, form)
}
dimensions := make([]*PerformanceDimension, 0)
... ... @@ -144,11 +152,16 @@ func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceM
if err != nil {
return modules, err
}
required, err := getRequired(item)
if err != nil {
return modules, err
}
module := &PerformanceModule{
ModuleName: moduleName,
Weight: weightName,
Standard: standardName,
Target: tasks,
Required: required,
}
modules = append(modules, module)
}
... ... @@ -201,6 +214,27 @@ func getStandard(items []*PerformanceApplicationForm) (string, error) {
return name, nil
}
// 获取是否必填
func getRequired(items []*PerformanceApplicationForm) (int, error) {
if len(items) <= 0 {
return NodeRequiredYes, nil
}
var name string
for _, item := range items {
if name == "" {
name = item.Required
}
if name != item.Required {
return NodeRequiredYes, errors.New(item.ModuleName + " 对应的是否必填不一致")
}
}
if name == "否" {
return NodeRequiredNo, nil
} else {
return NodeRequiredYes, nil
}
}
// 获取任务
func getTasks(items []*PerformanceApplicationForm) ([]*PerformanceTarget, error) {
tasks := make([]*PerformanceTarget, 0)
... ...
... ... @@ -297,16 +297,19 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
t_department as (
select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
),
-- 部门主管
t_user_1 as (
select t_user_department.user_id::text from t_user_department
join t_department on t_user_department.depart_id = t_department.depart_id
),
-- 如果是hrbp
t_project_1 as(
select evaluation_project.id as project_id
from evaluation_project
where evaluation_project.cycle_id =%d
and evaluation_project.hr_bp = %d
),
-- 如果的项目管理员
t_project_2 as(
select evaluation_project.id as project_id
from evaluation_project
... ... @@ -314,11 +317,13 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
and evaluation_project.pmp =1
and evaluation_project.pmp_ids @>'["%d"]'
),
-- 合并数据
t_project_3 as (
select t_project_2.project_id from t_project_2
union
select t_project_1.project_id from t_project_1
),
-- 初步过滤数据
t_staff_assess_0 as (
select staff_assess.id as assess_id,
staff_assess.target_user->>'userId' as target_user_id,
... ... @@ -330,6 +335,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s'
and staff_assess."types" ='self'
),
-- 根据查看权限过滤合并数据
t_staff_assess_1 as (
(select t_staff_assess_0.assess_id,
t_staff_assess_0.target_user_id,
... ... @@ -411,7 +417,7 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa
type AssessCycleDayMe struct {
BeginDay string `json:"beginDay"`
CycleId int `json:"cycleId"`
CycleId string `json:"cycleId"`
CycleName string `json:"cycleName"`
}
... ...
... ... @@ -121,7 +121,7 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf
}
// 必填项
nc.Required = domain.NodeRequiredYes
nc.Required = module.Required
nodeContents = append(nodeContents, nc)
}
}
... ...
... ... @@ -110,9 +110,42 @@ func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() {
c.Response(nil, e)
return
}
// paramReq.CompanyId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.GetAssessSelfInfoV2(paramReq)
c.Response(data, err)
}
// 获取当前登录员工自评详情
func (c *StaffAssessControllerV2) GetAssessSelfMeInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.GetExecutorSelfAssessQuery{}
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)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.GetAssessSelfInfoV2(paramReq)
c.Response(data, err)
}
// 被评估的员工的评估列表-360评估
func (c *StaffAssessControllerV2) ListTargetUserInviteAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListTargetAssessQuery{}
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.ListTargetUserInviteAssess(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -18,7 +18,7 @@ func init() {
web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表
web.NSCtrlPost("/cycle/day/content/export", (*controllers.StaffAssessController).ExportAssessContentCycleDay), //根据周期里的考核日期,导出员工填写评估内容列表
)
// /v1/staff-assess/self/me/list
assessNS := web.NewNamespace("/v1/staff-assess",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
... ... @@ -48,6 +48,7 @@ func init() {
web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessControllerV2).ListMeSupperAssess), //我要执行的360评估的用户列表
web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessControllerV2).GetAssessMeInviteUser), //获取邀请的员工
web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessControllerV2).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessControllerV2).GetAssessSelfMeInfo), //获取当前周期里我的自评反馈详情
)
web.AddNamespace(assessTaskNS)
... ...
不能预览此文件类型