作者 郑周

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

... ... @@ -12,8 +12,12 @@ type AssessInfoResp struct {
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"` //
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"` //评估内容
}
... ...
... ... @@ -2,6 +2,7 @@ package adapter
import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
//获取评估的邀请人
type AssessInviteUserResp struct {
LinkNodeId int `json:"linkNodeId"`
LinkNodeName string `json:"linkNodeName"`
... ...
package adapter
type ListInviteUserAssessResp struct {
TableHeader []ListTableHeader
List []map[string]string
Total int
}
type ListTableHeader struct {
Key string
Name string
}
... ...
package adapter
type ListSupperAssessResp struct {
AssessId int `json:"assessId"` //
UserName string `json:"userName"` //用户名称
EndTime string `json:"endTime"` //截止时间
InviteTotal int `json:"inviteCompleted"` //邀请总数
InviteUncompleted int `json:"inviteUncompleted"` //邀请未完成
Department string `json:"department"` //部门
Position string `json:"position"` //职位
DutyTime string `json:"dutyTime"` //入职时间
}
... ...
package adapter
type SelectInviteUser struct {
UserId int `json:"userId,string"`
UserName string `json:"userName"` //
IsSupper bool `json:"isSupper"` // 是否,是直属上级
Types int `json:"types"` // 1:相同上级的同事 2:不相同上级的同事
}
... ...
package query
//获取评估任务详情
type AssessInfoQuery struct {
AssessTaskId int `json:"assessTaskId"` //StaffAssess 的id
TargetUserId int `json:"targetUserId"` //被评估的人id
CompanyId int `json:"companyId"` //公司id
AssessId int `json:"assessId"` //
CompanyId int `json:"companyId"` //
}
... ...
package query
//获取员工自评填写详情
type AssessSelfInfoQuery struct {
AssessTaskId int `json:"assessTaskId"` //StaffAssess 的id
TargetUserId int `json:"targetUserId"` //被评估的人id
CompanyId int `json:"companyId"` //公司id
}
... ...
package query
type ListSupperAssessQuery struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
UserName string `json:"userName"` //查询条件 员工的名称
CompanyId int `json:"companyId"` //
ExecutorId int `json:"executorId"` //评估的执行人
AssessTaskkId int `json:"assessTaskId"` //评估任务id
}
... ...
package query
type ListInviteUserAssessQuery struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
UserName string `json:"userName"` //查询条件 员工的名称
CompanyId int `json:"companyId"` //
ExecutorId int `json:"executorId"` //评估的执行人
AssessTaskkId int `json:"assessTaskId"` //评估任务id
}
... ...
package query
type SelectAssessInviteUser struct {
TargetUserId int `json:"targetUserId"` //被评估的员工userId
CompanyId int `json:"companyId"`
InviteUserName string `json:"inviteUserName"`
PageSize int `json:"pageSize"`
PageNumber int `json:"pageNumber"`
}
... ...
... ... @@ -829,7 +829,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
}
// 获取员工自评的评估内容详情
func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuery) (*adapter.AssessInfoResp, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -971,3 +971,271 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a
}
return contentList, nil
}
// 选择员工评估可邀请的用户
func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (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()
}()
//获取被评估的目标用户
userRepo := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
targetUser, err := userRepo.FindOne(map[string]interface{}{
"id": param.TargetUserId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
}
//获取被评估的目标用户的部门
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, targetUserDepartment, err := departmentRepo.Find(map[string]interface{}{
"ids": targetUser.DepartmentId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
}
//获取部门主管的id
targetUserCharge := map[int64]struct{}{}
for _, v := range targetUserDepartment {
for _, vv := range v.ChargeUserIds {
targetUserCharge[vv] = struct{}{}
}
}
//
targetUserDepartmentMap := map[int64]struct{}{}
for _, v := range targetUserDepartment {
targetUserDepartmentMap[v.Id] = struct{}{}
}
//查询员工数据
condition := map[string]interface{}{
"companyId": param.CompanyId,
"name": param.InviteUserName,
"limit": 20,
}
if param.PageSize > 0 {
condition["limit"] = param.PageSize
}
offset := (param.PageNumber - 1) * param.PageSize
if offset > 0 {
condition["offset"] = offset
}
cnt, userList, err := userRepo.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())
}
listData := []adapter.SelectInviteUser{}
for _, v := range userList {
item := adapter.SelectInviteUser{
UserId: int(v.Id),
UserName: v.Name,
IsSupper: false,
Types: 2, //默认是不同上级
}
if _, ok := targetUserCharge[v.Id]; ok {
item.IsSupper = true
}
for _, vv := range v.DepartmentId {
if _, ok := targetUserDepartmentMap[int64(vv)]; ok {
item.Types = 1 //设为相同上级
break
}
}
listData = append(listData, item)
}
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
}
// 获取我的360评估,用户列表和评估填写的值
func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserAssessQuery) (
*adapter.ListInviteUserAssessResp, 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()
}()
//获取对应的评估任务
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取 executorId 对应的360评估任务 用户
cnt, assessList, err := assessRepo.Find(map[string]interface{}{
"staffAssessTaskId": param.AssessTaskkId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
})
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())
}
//TODO 评估填写数据行转列
tableHeader := []adapter.ListTableHeader{
{Key: "userName", Name: "姓名"},
{Key: "status", Name: "状态"},
{Key: "types", Name: "360°评估关系"},
{Key: "endTime", Name: "360°评估截止日期"},
}
listData := []map[string]string{}
for _, v := range assessList {
m := map[string]string{
"userName": v.TargetUser.UserName,
"status": string(v.Status),
"types": string(v.Types),
"endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
}
listData = append(listData, m)
}
_ = tableHeader
result := adapter.ListInviteUserAssessResp{
TableHeader: tableHeader,
List: listData,
Total: cnt,
}
return &result, nil
}
// 获取上级评估成员列表
func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQuery) (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()
}()
//获取对应的评估任务
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取 executorId 对应的上级评估列表
cnt, assessList, err := assessRepo.Find(map[string]interface{}{
"staffAssessTaskId": param.AssessTaskkId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessSuper)},
})
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())
}
resultList := []adapter.ListSupperAssessResp{}
for _, v := range assessList {
item := adapter.ListSupperAssessResp{
AssessId: v.Id,
UserName: v.TargetUser.UserName,
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
InviteUncompleted: 0,
InviteTotal: 5,
Department: "",
Position: "",
DutyTime: "",
}
for _, vv := range v.TargetDepartment {
item.Department += vv.DepartmentName + " "
}
resultList = append(resultList, item)
}
return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
}
// 根据staffAssessId 获取评估的填写信息
func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, 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,
})
//获取员工的评估
_, assessList, err := assessReps.Find(map[string]interface{}{
"companyId": param.CompanyId,
"id": param.AssessId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
}
if len(assessList) == 0 {
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 {
//未完成
assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, 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())
}
result := adapter.AssessInfoResp{
AssessId: assessData.Id,
CycleId: assessData.CycleId,
CycleName: assessData.CycleName,
EvaluationProjectId: assessData.EvaluationProjectId,
EvaluationProjectName: assessData.EvaluationProjectName,
BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
Status: string(assessData.Status),
TargetUserId: assessData.TargetUser.UserId,
TargetUserName: assessData.TargetUser.UserName,
AssessContent: assessContentList,
}
return &result, nil
}
// 获取员工的某次评估任务的360评估记录录
// assessTaskId targetUserId
func (srv StaffAssessServeice) AssessInviteList() error {
return nil
}
... ...
... ... @@ -140,7 +140,9 @@ 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)
}
if v, ok := queryOptions["typesList"].([]string); ok && len(v) > 0 {
query.Where("types in(?)", pg.In(v))
}
... ...
package repository
import (
"fmt"
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
... ... @@ -114,6 +116,9 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d
if v, ok := queryOptions["account"]; ok {
query.Where("account like ?", v)
}
if v, ok := queryOptions["name"]; ok {
query.Where("name like ?", fmt.Sprintf("%%%v%%", v))
}
if v, ok := queryOptions["offset"]; ok {
query.Offset(v.(int))
}
... ...
... ... @@ -78,10 +78,10 @@ func (c *StaffAssessController) CreateStaffAssessTask() {
c.Response(data, err)
}
// 获取员工自评详情
func (c *StaffAssessController) GetAssessSelfInfo() {
// 获取当前登录员工自评详情
func (c *StaffAssessController) GetAssessSelfMeInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessInfoQuery{}
paramReq := &query.AssessSelfInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
... ... @@ -130,3 +130,84 @@ func (c *StaffAssessController) SaveAssessInviteUser() {
data, err := srv.SaveAssessInviteUser(paramReq)
c.Response(data, err)
}
// 员工邀请的人选择列表
func (c *StaffAssessController) SelectAssessInviteUser() {
srv := service.NewStaffAssessServeice()
paramReq := &query.SelectAssessInviteUser{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
//TODO 获取当前用户信息
paramReq.CompanyId = 1
paramReq.TargetUserId = 1
data, err := srv.SelectAssessInviteUser(paramReq)
c.Response(data, err)
}
// 获取我要执行360评估,用户列表和评估填写的值
func (c *StaffAssessController) ListInviteUserAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListInviteUserAssessQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
//TODO 获取当前用户信息
paramReq.CompanyId = 1
paramReq.ExecutorId = 1
data, err := srv.ListInviteUserAssess(paramReq)
c.Response(data, err)
}
// 获取上级评估成员列表
func (c *StaffAssessController) ListSupperAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListSupperAssessQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
//TODO 获取当前用户信息
paramReq.CompanyId = 1
paramReq.ExecutorId = 1
data, err := srv.ListSupperAssess(paramReq)
c.Response(data, err)
}
// 获取员工自评详情
func (c *StaffAssessController) GetAssessSelfInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessSelfInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
paramReq.CompanyId = 1
data, err := srv.GetAssessSelfInfo(paramReq)
c.Response(data, err)
}
// 获取评估内容详情
func (c *StaffAssessController) GetAssessInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
paramReq.CompanyId = 1
data, err := srv.GetAssessInfo(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -16,9 +16,12 @@ func init() {
assessNS := web.NewNamespace("/v1/staff-assess",
// web.NSBefore(filters.AllowCors(), middlewares.CheckToken()),
web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfInfo), //获取我的自评反馈详情
web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情
web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessInviteUser), //获取邀请的员工
web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessInviteUser), //保存邀请的员工
web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessInviteUser), //保存我邀请的员工
web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工
web.NSCtrlPost("/self/info", (*controllers.StaffAssessController).GetAssessSelfInfo), //获取我的自评反馈详情
web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //获取我的自评反馈详情
)
web.AddNamespace(assessTaskNS)
web.AddNamespace(assessNS)
... ...