作者 Your Name

Merge branch 'dev-tangxvhui'

@@ -128,3 +128,27 @@ func CreateEvaluationProjectRepository(options map[string]interface{}) domain.Ev @@ -128,3 +128,27 @@ func CreateEvaluationProjectRepository(options map[string]interface{}) domain.Ev
128 } 128 }
129 return repository.NewEvaluationProjectRepository(transactionContext) 129 return repository.NewEvaluationProjectRepository(transactionContext)
130 } 130 }
  131 +
  132 +func CreateStaffAssessRepository(options map[string]interface{}) domain.StaffAssessRepository {
  133 + var transactionContext *pg.TransactionContext
  134 + if value, ok := options["transactionContext"]; ok {
  135 + transactionContext = value.(*pg.TransactionContext)
  136 + }
  137 + return repository.NewStaffAssessRepository(transactionContext)
  138 +}
  139 +
  140 +func CreateStaffAssessContentRepository(options map[string]interface{}) domain.StaffAssessContentRepository {
  141 + var transactionContext *pg.TransactionContext
  142 + if value, ok := options["transactionContext"]; ok {
  143 + transactionContext = value.(*pg.TransactionContext)
  144 + }
  145 + return repository.NewStaffAssessContentRepository(transactionContext)
  146 +}
  147 +
  148 +func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.StaffAssessTaskRepository {
  149 + var transactionContext *pg.TransactionContext
  150 + if value, ok := options["transactionContext"]; ok {
  151 + transactionContext = value.(*pg.TransactionContext)
  152 + }
  153 + return repository.NewStaffAssessTaskRepository(transactionContext)
  154 +}
  1 +package adapter
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  4 +
  5 +//评估内容详情
  6 +type AssessInfoResp struct {
  7 + CycleId int64 `json:"cycleId"` //周期id
  8 + CycleName string `json:"cycleName"` //周期名称
  9 + EvaluationProjectId int `json:"evaluationProjectId"` //项目id
  10 + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
  11 + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
  12 + EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
  13 + Status string `json:"status"` //完成状态
  14 + TargetUserId int `json:"targetUser"` //
  15 + TargetUserName string `json:"targetUserName"` //
  16 + AssessContent []AssessContent `json:"assessContent"` //评估内容
  17 +}
  18 +
  19 +type AssessContent struct {
  20 + Category string `json:"category" comment:"类别"`
  21 + Name string `json:"name" comment:"名称"`
  22 + PromptTitle string `json:"promptTitle" comment:"提示项标题"`
  23 + PromptText string `json:"promptText" comment:"提示项正文"`
  24 + EntryItems []*domain.EntryItem `json:"entryItems" comment:"填写项"`
  25 +}
  1 +package adapter
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  4 +
  5 +type AssessInviteUserResp struct {
  6 + LinkNodeId int `json:"linkNodeId"`
  7 + LinkNodeName string `json:"linkNodeName"`
  8 + BeginTime string `json:"beginTime"`
  9 + EndTime string `json:"endTime"`
  10 + AssessTaskId int `json:"assessTaskId"`
  11 + InviteSameSuper []domain.StaffDesc `json:"inviteSameSuper"`
  12 + InviteDiffSuper []domain.StaffDesc `json:"inviteDiffSuper"`
  13 +}
  1 +package adapter
  2 +
  3 +type AssessSelfList struct {
  4 + AssessId int `json:"assessId"` //用户执行的评估项id
  5 + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
  6 + EndTime string `json:"endTime"` //开始时间 2006-01-02 15:04:05
  7 + CycleId int64 `json:"cycleId"` //周期id
  8 + CycleName string `json:"cycleName"` //周期名称
  9 + EvaluationProjectId int `json:"evaluationProjectId"` //项目id
  10 + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
  11 +}
  12 +
  13 +type StaffInfo struct {
  14 + UserName string `json:"userName"` //员工名称
  15 + CompanyName string `json:"companyName"` //公司名称
  16 + SupperUserName string `json:"supperUserName"` //上级名称
  17 + DutyTime string `json:"dutyTime"` //上岗时间
  18 +}
  1 +package adapter
  2 +
  3 +type AssessTaskDescResp struct {
  4 + AssessTaskId int `json:"assessTaskId"` //
  5 + EvaluationProjectId int `json:"evaluationProjectId"` //项目id
  6 + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
  7 + CycleName string `json:"cycleName"` //周期名称
  8 + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
  9 + EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
  10 + StepList []AssessTaskStep `json:"stepList"` // 考评流程
  11 +}
  12 +
  13 +type AssessTaskStep struct {
  14 + SortBy int `json:"sortBy"` //排序
  15 + LinkNodeName string `json:"linkNodeName"` //流程名称
  16 + BeginTime string `json:"beginTime"` //开始时间时间
  17 + EndTime string `json:"endTime"` //结束时间
  18 + LinkNodeType int `json:"linkNodeType"` //流程类型
  19 + Desc string `json:"desc"` //情况描述
  20 + Status string `json:"status"` //流程是否完成 "":未参加,"uncompleted":未完成,"completed":完成
  21 +}
  1 +package adapter
  2 +
  3 +type SearchAssessMeResp struct {
  4 + AssessTaskId int `json:"assessTaskId"`
  5 + BeginTime string `json:"beginTime"`
  6 + EndTime string `json:"endTime"`
  7 + CycleId int64 `json:"cycleId"`
  8 + CycleName string `json:"cycleName"`
  9 + EvaluationProjectId int `json:"evaluationProjectId"`
  10 + EvaluationProjectName string `json:"evaluationProjectName"`
  11 +}
  1 +package command
  2 +
  3 +type CreateStaffAssessTask struct {
  4 + CompanyId int `json:"companyId"` //公司id
  5 + EvaluationProjectId int `json:"evaluationProjectId"` //项目id
  6 + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
  7 + CycleId int64 `json:"cycleId"` //对应的周期id
  8 + CycleName string `json:"cycleName"` //对应周期的名称
  9 + BeginTime string `json:"beginTime"` //绩效考核开始时间
  10 + EndTime string `json:"endTime"` //绩效考核截止时间
  11 + StepList []AssessTaskStep `json:"steps"` //考评的流程
  12 + ExecutorId []int `json:"executorId"` //参与此次考评的人
  13 +}
  14 +
  15 +type AssessTaskStep struct {
  16 + SortBy int `json:"sortBy"` //排序
  17 + LinkNodeId int `json:"linkNodeId"` //考评的流程id
  18 + LinkNodeName string `json:"linkNodeName"` //流程名称
  19 + LinkNodeType int `json:"linkNodeType"` //流程类型 同evaluation_template.go->LinkNode.Type
  20 + BeginTime string `json:"beginTime"` //绩效考核开始时间
  21 + EndTime string `json:"endTime"` //绩效考核截止时间
  22 +}
  1 +package command
  2 +
  3 +type SaveAssessInvite struct {
  4 + InviteSameSuper []string `json:"inviteSameSuper"` //相同上级同事
  5 + InviteDiffSuper []string `json:"inviteDiffSuper"` //不同上级同事
  6 + AssessTaskId int `json:"assessTaskId"` //评估任务id
  7 + TargetUserId int `json:"targetUserId"` //被评估的员工id
  8 +}
  1 +package query
  2 +
  3 +type AssessInfoQuery struct {
  4 + AssessTaskId int `json:"assessTaskId"` //StaffAssess 的id
  5 + TargetUserId int `json:"targetUserId"` //被评估的人id
  6 + CompanyId int `json:"companyId"` //公司id
  7 +
  8 +}
  1 +package query
  2 +
  3 +type AssessSelfListQuery struct {
  4 + UserId int `json:"userId"` //用户id
  5 + CompanyId int `json:"companyId"` //公司Id
  6 + PageSize int `json:"pageSize"` //每页的记录数
  7 + PageNumber int `json:"pageNumber"` //页码
  8 +}
  1 +package query
  2 +
  3 +type AssessTaskDescQuery struct {
  4 + AssessTaskId int `json:"assessTaskId"` //评估任务的id
  5 + UserId int `json:"userId"` //当前登录人的id
  6 + CompanyId int `json:"companyId"` //当前登录的公司
  7 +}
  1 +package query
  2 +
  3 +type GetAssessInviteUserQuery struct {
  4 + CompanyId int `json:"companyId"` //对公司
  5 + UsrId int `json:"usrId"` //被评估的员工id
  6 + AssessTaskId int `json:"assessTaskId"` //评估任务的id
  7 +}
  1 +package query
  2 +
  3 +type SearchAssessMeQuery struct {
  4 + UserId int `json:"userId"` // 当前登录人的用户id
  5 + CompanyId int `json:"companyId"` //当前登录人的公司Id
  6 + PageSize int `json:"pageSize"` //每页的记录数
  7 + PageNumber int `json:"pageNumber"` //页码
  8 +}
  1 +package service
  2 +
  3 +import (
  4 + "fmt"
  5 + "strconv"
  6 + "time"
  7 +
  8 + "github.com/linmadan/egglib-go/core/application"
  9 + "github.com/linmadan/egglib-go/utils/tool_funs"
  10 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  11 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
  12 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
  13 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
  14 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  15 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
  16 +)
  17 +
  18 +// 员工评绩效评估
  19 +type StaffAssessServeice struct {
  20 +}
  21 +
  22 +func NewStaffAssessServeice() *StaffAssessServeice {
  23 + newService := &StaffAssessServeice{}
  24 + return newService
  25 +}
  26 +
  27 +// 获取我参与过的评估任务列表
  28 +func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
  29 + transactionContext, err := factory.CreateTransactionContext(nil)
  30 + if err != nil {
  31 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  32 + }
  33 + if err := transactionContext.StartTransaction(); err != nil {
  34 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  35 + }
  36 + defer func() {
  37 + _ = transactionContext.RollbackTransaction()
  38 + }()
  39 + staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  40 + "transactionContext": transactionContext,
  41 + })
  42 + var limit int = 20
  43 + var offset int = 0
  44 + if param.PageSize > 0 {
  45 + limit = param.PageSize
  46 + }
  47 + offset = (param.PageNumber - 1) * param.PageSize
  48 + condition := map[string]interface{}{
  49 + "executorId": param.UserId,
  50 + "companyId": param.CompanyId,
  51 + "limit": limit,
  52 + }
  53 + if offset > 0 {
  54 + condition["offset"] = offset
  55 + }
  56 + cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition)
  57 + if err != nil {
  58 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error())
  59 + }
  60 + if err := transactionContext.CommitTransaction(); err != nil {
  61 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  62 + }
  63 + listData := make([]adapter.SearchAssessMeResp, 0, len(assessTaskList))
  64 + var temp adapter.SearchAssessMeResp
  65 + for _, v := range assessTaskList {
  66 + temp = adapter.SearchAssessMeResp{
  67 + AssessTaskId: v.Id,
  68 + BeginTime: v.BeginTime.Format("2006-01-02 15:04:05"),
  69 + EndTime: v.EndTime.Format("2006-01-02 15:04:05"),
  70 + CycleId: v.CycleId,
  71 + CycleName: v.CycleName,
  72 + EvaluationProjectId: v.EvaluationProjectId,
  73 + EvaluationProjectName: v.EvaluationProjectName,
  74 + }
  75 + listData = append(listData, temp)
  76 + }
  77 + return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
  78 +}
  79 +
  80 +// 获取项目评估进度描述
  81 +func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, error) {
  82 + transactionContext, err := factory.CreateTransactionContext(nil)
  83 + if err != nil {
  84 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  85 + }
  86 + if err := transactionContext.StartTransaction(); err != nil {
  87 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  88 + }
  89 + defer func() {
  90 + _ = transactionContext.RollbackTransaction()
  91 + }()
  92 + // 获取评估任务
  93 + staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  94 + "transactionContext": transactionContext,
  95 + })
  96 + //获取个人参与的评估流程
  97 + staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  98 + "transactionContext": transactionContext,
  99 + })
  100 + assessTaskData, err := staffAssessTaskRepo.FindOne(map[string]interface{}{
  101 + "id": param.AssessTaskId,
  102 + })
  103 + if err != nil {
  104 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
  105 + }
  106 + //返回的数据结果
  107 + result := adapter.AssessTaskDescResp{
  108 + AssessTaskId: assessTaskData.Id,
  109 + EvaluationProjectId: assessTaskData.EvaluationProjectId,
  110 + EvaluationProjectName: assessTaskData.EvaluationProjectName,
  111 + CycleName: assessTaskData.CycleName,
  112 + BeginTime: assessTaskData.BeginTime.Local().Format("2006-01-02 15:04-05"),
  113 + EndTime: assessTaskData.EndTime.Local().Format("2006-01-02 15:04-05"),
  114 + StepList: []adapter.AssessTaskStep{},
  115 + }
  116 +
  117 + for _, v := range assessTaskData.StepList {
  118 + stepItem := adapter.AssessTaskStep{
  119 + SortBy: v.SortBy,
  120 + LinkNodeName: v.LinkNodeName,
  121 + BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
  122 + EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
  123 + LinkNodeType: v.LinkNodeType,
  124 + Desc: fmt.Sprintf("截止日期:%s", v.EndTime.Local().Format("2006-01-02 15:04:05")),
  125 + Status: "",
  126 + }
  127 + switch v.LinkNodeType {
  128 + case domain.LinkNodeSelfAssessment:
  129 + //个人自评完成情况
  130 + _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
  131 + "staffAssessTaskId": assessTaskData.Id,
  132 + "executorId": param.UserId,
  133 + "typesList": []string{string(domain.AssessSelf)},
  134 + })
  135 + if err != nil {
  136 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  137 + }
  138 + if len(assessSelfData) > 0 {
  139 + stepItem.Status = string(assessSelfData[0].Status)
  140 + }
  141 + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
  142 + case domain.LinkNodeAllInvite:
  143 + //邀请别人评估自己
  144 + _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
  145 + "staffAssessTaskId": assessTaskData.Id,
  146 + "targetUserId": param.UserId,
  147 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  148 + "limit": 5,
  149 + })
  150 + if err != nil {
  151 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  152 + }
  153 + //待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
  154 + if len(assessInviteData) > 5 {
  155 + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
  156 + stepItem.Status = string(domain.StaffAssessCompleted)
  157 + } else {
  158 + stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
  159 + stepItem.Status = string(domain.StaffAssessUncompleted)
  160 + }
  161 + case domain.LinkNodeAllAssessment:
  162 + //我评估别人,被邀请评估
  163 + _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
  164 + "staffAssessTaskId": assessTaskData.Id,
  165 + "executorId": param.UserId,
  166 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  167 + })
  168 + if err != nil {
  169 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  170 + }
  171 +
  172 + if len(assessInviteList) > 0 {
  173 + stepItem.Status = string(domain.StaffAssessCompleted)
  174 + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
  175 + for _, v := range assessInviteList {
  176 + if v.Status == domain.StaffAssessUncompleted {
  177 + stepItem.Status = string(domain.StaffAssessUncompleted)
  178 + break
  179 + }
  180 + }
  181 + }
  182 + case domain.LinkNodeSuperiorAssessment:
  183 + //我评估别人,上级评估
  184 + _, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{
  185 + "staffAssessTaskId": assessTaskData.Id,
  186 + "executorId": param.UserId,
  187 + "typesList": []string{string(domain.AssessSuper)},
  188 + })
  189 + if err != nil {
  190 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  191 + }
  192 + if len(assessSupperList) > 0 {
  193 + stepItem.Status = string(domain.StaffAssessCompleted)
  194 + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
  195 + uncompletedNum := 0
  196 + for _, v := range assessSupperList {
  197 + if v.Status == domain.StaffAssessUncompleted {
  198 + uncompletedNum += 1
  199 + }
  200 + }
  201 + if uncompletedNum > 0 {
  202 + stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
  203 + }
  204 + }
  205 + }
  206 + result.StepList = append(result.StepList, stepItem)
  207 + }
  208 + if err := transactionContext.CommitTransaction(); err != nil {
  209 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  210 + }
  211 + return &result, nil
  212 +}
  213 +
  214 +// 获取个人的自评反馈历史记录列表
  215 +func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) (map[string]interface{}, error) {
  216 + transactionContext, err := factory.CreateTransactionContext(nil)
  217 + if err != nil {
  218 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  219 + }
  220 + if err := transactionContext.StartTransaction(); err != nil {
  221 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  222 + }
  223 + defer func() {
  224 + _ = transactionContext.RollbackTransaction()
  225 + }()
  226 + //获取个人参与的评估流程
  227 + staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  228 + "transactionContext": transactionContext,
  229 + })
  230 + var limit int = 20
  231 + var offset int = 0
  232 + if param.PageSize > 0 {
  233 + limit = param.PageSize
  234 + }
  235 + offset = (param.PageNumber - 1) * param.PageSize
  236 + condition := map[string]interface{}{
  237 + "executorId": param.UserId,
  238 + "companyId": param.CompanyId,
  239 + "typesList": []string{string(domain.AssessSelf)},
  240 + "limit": limit,
  241 + "status": string(domain.StaffAssessCompleted),
  242 + }
  243 + if offset > 0 {
  244 + condition["offset"] = offset
  245 + }
  246 + //获取历史列表
  247 + cnt, assessList, err := staffAssessRepo.Find(condition)
  248 + if err != nil {
  249 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务列表,"+err.Error())
  250 + }
  251 +
  252 + //获取公司数据
  253 + companyRep := factory.CreateCompanyRepository(map[string]interface{}{
  254 + "transactionContext": transactionContext,
  255 + })
  256 +
  257 + companyData, err := companyRep.FindOne(map[string]interface{}{
  258 + "id": param.CompanyId,
  259 + })
  260 + if err != nil {
  261 + log.Logger.Error("获取公司信息," + err.Error())
  262 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error())
  263 + }
  264 +
  265 + //获取用户数据
  266 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  267 + "transactionContext": transactionContext,
  268 + })
  269 + userData, err := userRepo.FindOne(map[string]interface{}{
  270 + "id": param.UserId,
  271 + })
  272 + if err != nil {
  273 + log.Logger.Error("获取用户信息," + err.Error())
  274 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取用户信息,"+err.Error())
  275 + }
  276 + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
  277 + "transactionContext": transactionContext,
  278 + })
  279 + var supperUserList []*domain.User
  280 + if len(userData.DepartmentId) > 0 {
  281 + _, departmentList, err := departmentRepo.Find(map[string]interface{}{
  282 + "ids": userData.DepartmentId,
  283 + })
  284 + if err != nil {
  285 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
  286 + }
  287 + var chargeUserIds []int64
  288 + for _, v := range departmentList {
  289 + chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
  290 + }
  291 + if len(chargeUserIds) > 0 {
  292 + _, supperUserList, err = userRepo.Find(map[string]interface{}{
  293 + "ids": chargeUserIds,
  294 + })
  295 + if err != nil {
  296 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
  297 + }
  298 + }
  299 + }
  300 + if err := transactionContext.CommitTransaction(); err != nil {
  301 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  302 + }
  303 + listData := make([]adapter.AssessSelfList, 0, len(assessList))
  304 + var itemTemp adapter.AssessSelfList
  305 + for _, v := range assessList {
  306 + itemTemp = adapter.AssessSelfList{
  307 + AssessId: v.Id,
  308 + BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
  309 + EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
  310 + CycleId: v.CycleId,
  311 + CycleName: v.CycleName,
  312 + EvaluationProjectId: v.EvaluationProjectId,
  313 + EvaluationProjectName: v.EvaluationProjectName,
  314 + }
  315 + listData = append(listData, itemTemp)
  316 + }
  317 + userInfo := adapter.StaffInfo{
  318 + UserName: userData.Name,
  319 + CompanyName: companyData.Name,
  320 + SupperUserName: "",
  321 + DutyTime: userData.CreateAt.Local().Format("2006-01-02 15:04:05"),
  322 + }
  323 + for _, v := range supperUserList {
  324 + userInfo.SupperUserName = userInfo.SupperUserName + v.Name + ";"
  325 + }
  326 + result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
  327 + result["userInfo"] = userInfo
  328 + return result, nil
  329 +}
  330 +
  331 +// 更具项目评估的配置,创建员工的评估任务
  332 +func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
  333 +
  334 + transactionContext, err := factory.CreateTransactionContext(nil)
  335 + if err != nil {
  336 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  337 + }
  338 + if err := transactionContext.StartTransaction(); err != nil {
  339 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  340 + }
  341 + defer func() {
  342 + _ = transactionContext.RollbackTransaction()
  343 + }()
  344 +
  345 + taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
  346 + if err != nil {
  347 + return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime)
  348 + }
  349 + taskEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
  350 + if err != nil {
  351 + return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
  352 + }
  353 + nowTime := time.Now()
  354 + //建立评估任务
  355 + assessTask := domain.StaffAssessTask{
  356 + Id: 0,
  357 + CompanyId: param.CompanyId,
  358 + EvaluationProjectId: param.EvaluationProjectId,
  359 + EvaluationProjectName: param.EvaluationProjectName,
  360 + CycleId: param.CycleId,
  361 + CycleName: param.CycleName,
  362 + BeginTime: taskBeginTime,
  363 + EndTime: taskEndTime,
  364 + StepList: []domain.AssessTaskStep{},
  365 + ExecutorId: nil,
  366 + CreatedAt: nowTime,
  367 + UpdatedAt: nowTime,
  368 + DeletedAt: nil,
  369 + }
  370 + //填充评估环节
  371 + for _, v := range param.StepList {
  372 + stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
  373 + if err != nil {
  374 + return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime)
  375 + }
  376 + stepEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
  377 + if err != nil {
  378 + return nil, application.ThrowError(application.ARG_ERROR, "评估环节结束时间填写错误,"+param.EndTime)
  379 + }
  380 + step := domain.AssessTaskStep{
  381 + SortBy: v.SortBy,
  382 + LinkNodeId: v.LinkNodeId,
  383 + LinkNodeName: v.LinkNodeName,
  384 + LinkNodeType: v.LinkNodeType,
  385 + BeginTime: stepBeginTime,
  386 + EndTime: stepEndTime,
  387 + }
  388 + assessTask.StepList = append(assessTask.StepList, step)
  389 + }
  390 +
  391 + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  392 + "transactionContext": transactionContext,
  393 + })
  394 + _, err = assessTaskRepo.Save(&assessTask)
  395 + if err != nil {
  396 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
  397 + }
  398 +
  399 + assessList, err := srv.createStaffAssess(transactionContext, &assessTask)
  400 + if err != nil {
  401 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
  402 + }
  403 +
  404 + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  405 + "transactionContext": transactionContext,
  406 + })
  407 +
  408 + for i := range assessList {
  409 + _, err = assessRepo.Save(&assessList[i])
  410 + if err != nil {
  411 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
  412 + }
  413 + }
  414 + if err := transactionContext.CommitTransaction(); err != nil {
  415 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  416 + }
  417 + return map[string]interface{}{
  418 + "assessTaskId": assessTask.Id,
  419 + }, nil
  420 +}
  421 +
  422 +// 添加自评节点任务
  423 +func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) {
  424 + //评估的参与人
  425 + selfUserId := []int{}
  426 + userIdMap := map[int]struct{}{} //过滤重复的用户
  427 + for _, v := range param.ExecutorId {
  428 + if _, ok := userIdMap[v]; ok {
  429 + continue
  430 + }
  431 + selfUserId = append(selfUserId, v)
  432 + }
  433 + // 获取用户的信息
  434 + if len(selfUserId) == 0 {
  435 + return nil, application.ThrowError(application.ARG_ERROR, "未填写评估任务的执行人")
  436 + }
  437 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  438 + "transactionContext": transactionContext,
  439 + })
  440 + //获取员工信息
  441 + _, userList, err := userRepo.Find(map[string]interface{}{
  442 + "ids": selfUserId,
  443 + })
  444 + if err != nil {
  445 + return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息"+err.Error())
  446 + }
  447 + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
  448 + "transactionContext": transactionContext,
  449 + })
  450 + //获取用户的部门
  451 + userDepartmentMap := map[int64][]*domain.Department{}
  452 + for _, v := range userList {
  453 + _, departmemtList, err := departmentRepo.Find(map[string]interface{}{
  454 + "ids": v.DepartmentId,
  455 + })
  456 + if err != nil {
  457 + return nil, application.ThrowError(application.ARG_ERROR, "获取员工的部门信息"+err.Error())
  458 + }
  459 + userDepartmentMap[v.Id] = departmemtList
  460 + }
  461 + assessList := []domain.StaffAssess{}
  462 + //数据样板
  463 + stepSelfTemp := domain.StaffAssess{
  464 + Id: 0,
  465 + CompanyId: param.CompanyId,
  466 + EvaluationProjectId: param.EvaluationProjectId,
  467 + EvaluationProjectName: param.EvaluationProjectName,
  468 + CycleId: param.CycleId,
  469 + CycleName: param.CycleName,
  470 + StaffAssessTaskId: param.Id,
  471 + // TargetUser: domain.StaffDesc{},
  472 + // TargetDepartment: nil,
  473 + // Executor: domain.StaffDesc{},
  474 + Types: domain.AssessSelf,
  475 + // LinkNodeId: v.LinkNodeId,
  476 + Status: domain.StaffAssessUncompleted,
  477 + // BeginTime: time.Time{},
  478 + // EndTime: time.Time{},
  479 + CreatedAt: param.CreatedAt,
  480 + UpdatedAt: param.UpdatedAt,
  481 + DeletedAt: nil,
  482 + }
  483 + for _, v := range param.StepList {
  484 + if v.LinkNodeType == domain.LinkNodeSelfAssessment {
  485 + //员工自评
  486 + stepSelfTemp.BeginTime = v.BeginTime
  487 + stepSelfTemp.EndTime = v.EndTime
  488 + stepSelfTemp.LinkNodeId = v.LinkNodeId
  489 + stepSelfTemp.LinkNodeName = v.LinkNodeName
  490 + assessListTemp := srv.createStaffAssessSelf(stepSelfTemp, userList, userDepartmentMap)
  491 + assessList = append(assessList, assessListTemp...)
  492 + }
  493 + if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {
  494 + // TODO
  495 + stepSelfTemp.BeginTime = v.BeginTime
  496 + stepSelfTemp.EndTime = v.EndTime
  497 + stepSelfTemp.LinkNodeId = v.LinkNodeId
  498 + stepSelfTemp.LinkNodeName = v.LinkNodeName
  499 + assessListTemp, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap)
  500 + if err != nil {
  501 + return nil, err
  502 + }
  503 + assessList = append(assessList, assessListTemp...)
  504 + }
  505 + }
  506 + return assessList, nil
  507 +}
  508 +
  509 +// 构建员工自评
  510 +func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAssess,
  511 + userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess {
  512 + result := []domain.StaffAssess{}
  513 + for _, usr := range userList {
  514 + assessTemp.TargetUser = domain.StaffDesc{
  515 + UserId: int(usr.Id),
  516 + Account: usr.Account,
  517 + UserName: usr.Account,
  518 + }
  519 + assessTemp.Executor = domain.StaffDesc{
  520 + UserId: int(usr.Id),
  521 + Account: usr.Account,
  522 + UserName: usr.Account,
  523 + }
  524 + if depList, ok := userDepartmentMap[usr.Id]; ok {
  525 + for _, dep := range depList {
  526 + assessTemp.TargetDepartment = append(assessTemp.TargetDepartment, domain.StaffDepartment{
  527 + DepartmentId: int(dep.Id),
  528 + DepartmentName: dep.Name,
  529 + })
  530 + }
  531 + }
  532 + result = append(result, assessTemp)
  533 + }
  534 + return result
  535 +}
  536 +
  537 +// 构建员工上级评估
  538 +func (srv StaffAssessServeice) createStaffAssessSupper(
  539 + transactionContext application.TransactionContext,
  540 + assessTemp domain.StaffAssess,
  541 + userList []*domain.User, userDepartmentMap map[int64][]*domain.Department,
  542 +) ([]domain.StaffAssess, error) {
  543 +
  544 + // 获取员工的上级用户
  545 +
  546 + return nil, nil
  547 +}
  548 +
  549 +// 获取某个员工360邀请的人员
  550 +func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
  551 + transactionContext, err := factory.CreateTransactionContext(nil)
  552 + if err != nil {
  553 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  554 + }
  555 + if err := transactionContext.StartTransaction(); err != nil {
  556 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  557 + }
  558 + defer func() {
  559 + _ = transactionContext.RollbackTransaction()
  560 + }()
  561 +
  562 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  563 + "transactionContext": transactionContext,
  564 + })
  565 +
  566 + assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  567 + "transactionContext": transactionContext,
  568 + })
  569 + assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{
  570 + "id": param.AssessTaskId,
  571 + })
  572 + if err != nil {
  573 + return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
  574 + }
  575 + _, assessList, err := assessReps.Find(map[string]interface{}{
  576 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  577 + "staffAssessTaskId": param.AssessTaskId,
  578 + "targetUserId": param.UsrId,
  579 + })
  580 + if err != nil {
  581 + return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
  582 + }
  583 + if err := transactionContext.CommitTransaction(); err != nil {
  584 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  585 + }
  586 +
  587 + result := adapter.AssessInviteUserResp{
  588 + AssessTaskId: assessTaskData.Id,
  589 + }
  590 + for _, v := range assessTaskData.StepList {
  591 + if v.LinkNodeType != domain.LinkNodeAllInvite {
  592 + continue
  593 + }
  594 + result.LinkNodeId = v.LinkNodeId
  595 + result.LinkNodeName = v.LinkNodeName
  596 + result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
  597 + result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
  598 + break
  599 + }
  600 + for _, v := range assessList {
  601 + if v.Types == domain.AssessInviteDiffSuper {
  602 + result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
  603 + }
  604 + if v.Types == domain.AssessInviteSameSuper {
  605 + result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
  606 + }
  607 + }
  608 + return &result, nil
  609 +}
  610 +
  611 +// 获取某个员工360邀请的人员
  612 +func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (*adapter.AssessInviteUserResp, error) {
  613 + inviteSameSuperId := []int{}
  614 + InviteDiffSuperId := []int{}
  615 + for _, v := range param.InviteDiffSuper {
  616 + id, err := strconv.Atoi(v)
  617 + if err != nil {
  618 + return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误")
  619 + }
  620 + InviteDiffSuperId = append(InviteDiffSuperId, id)
  621 + }
  622 + for _, v := range param.InviteSameSuper {
  623 + id, err := strconv.Atoi(v)
  624 + if err != nil {
  625 + return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误")
  626 + }
  627 + inviteSameSuperId = append(inviteSameSuperId, id)
  628 + }
  629 + transactionContext, err := factory.CreateTransactionContext(nil)
  630 + if err != nil {
  631 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  632 + }
  633 + if err := transactionContext.StartTransaction(); err != nil {
  634 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  635 + }
  636 + defer func() {
  637 + _ = transactionContext.RollbackTransaction()
  638 + }()
  639 +
  640 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  641 + "transactionContext": transactionContext,
  642 + })
  643 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  644 + "transactionContext": transactionContext,
  645 + })
  646 + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
  647 + "transactionContext": transactionContext,
  648 + })
  649 +
  650 + assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  651 + "transactionContext": transactionContext,
  652 + })
  653 + assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{
  654 + "id": param.AssessTaskId,
  655 + })
  656 + if err != nil {
  657 + return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
  658 + }
  659 +
  660 + targetUser, err := userRepo.FindOne(map[string]interface{}{
  661 + "id": param.TargetUserId,
  662 + })
  663 + if err != nil {
  664 + return nil, application.ThrowError(application.ARG_ERROR, "获取被评估员工"+err.Error())
  665 + }
  666 + //被评估人的部门
  667 + var targetUserDepartment []domain.StaffDepartment
  668 + if len(targetUser.DepartmentId) > 0 {
  669 + _, departmentList, err := departmentRepo.Find(map[string]interface{}{
  670 + "ids": targetUser.DepartmentId,
  671 + })
  672 + if err != nil {
  673 + return nil, application.ThrowError(application.ARG_ERROR, "获取部门信息"+err.Error())
  674 + }
  675 + for _, v := range departmentList {
  676 + targetUserDepartment = append(targetUserDepartment, domain.StaffDepartment{
  677 + DepartmentId: int(v.Id),
  678 + DepartmentName: v.Name,
  679 + })
  680 + }
  681 + }
  682 + //邀请的相同上级的员工
  683 + var inviteSameSuper []domain.StaffDesc
  684 + if len(inviteSameSuperId) > 0 {
  685 + _, userList, err := userRepo.Find(map[string]interface{}{
  686 + "ids": inviteSameSuperId,
  687 + })
  688 + if err != nil {
  689 + return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
  690 + }
  691 + for _, v := range userList {
  692 + inviteSameSuper = append(inviteSameSuper, domain.StaffDesc{
  693 + UserId: int(v.Id),
  694 + UserName: v.Name,
  695 + Account: v.Account,
  696 + })
  697 + }
  698 + }
  699 + //邀请的不同上级的员工
  700 + var inviteDiffSuper []domain.StaffDesc
  701 + if len(InviteDiffSuperId) > 0 {
  702 + _, userList, err := userRepo.Find(map[string]interface{}{
  703 + "ids": InviteDiffSuperId,
  704 + })
  705 + if err != nil {
  706 + return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
  707 + }
  708 + for _, v := range userList {
  709 + inviteDiffSuper = append(inviteDiffSuper, domain.StaffDesc{
  710 + UserId: int(v.Id),
  711 + UserName: v.Name,
  712 + Account: v.Account,
  713 + })
  714 + }
  715 + }
  716 + _ = assessReps
  717 + _ = inviteSameSuper
  718 + _ = inviteDiffSuper
  719 + _ = targetUserDepartment
  720 + // _, assessList, err := assessReps.Find(map[string]interface{}{
  721 + // "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  722 + // "staffAssessTaskId": param.AssessTaskId,
  723 + // "targetUserId": param.TargetUserId,
  724 + // })
  725 + // if err != nil {
  726 + // return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
  727 + // }
  728 + // TODO
  729 +
  730 + if err := transactionContext.CommitTransaction(); err != nil {
  731 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  732 + }
  733 +
  734 + result := adapter.AssessInviteUserResp{
  735 + AssessTaskId: assessTaskData.Id,
  736 + }
  737 + // for _, v := range assessTaskData.StepList {
  738 + // if v.LinkNodeType != domain.LinkNodeAllInvite {
  739 + // continue
  740 + // }
  741 + // result.LinkNodeId = v.LinkNodeId
  742 + // result.LinkNodeName = v.LinkNodeName
  743 + // result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
  744 + // result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
  745 + // break
  746 + // }
  747 + // for _, v := range assessList {
  748 + // if v.Types == domain.AssessInviteDiffSuper {
  749 + // result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
  750 + // }
  751 + // if v.Types == domain.AssessInviteSameSuper {
  752 + // result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
  753 + // }
  754 + // }
  755 + return &result, nil
  756 +}
  757 +
  758 +// 获取员工自评的评估内容详情
  759 +func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
  760 + transactionContext, err := factory.CreateTransactionContext(nil)
  761 + if err != nil {
  762 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  763 + }
  764 + if err := transactionContext.StartTransaction(); err != nil {
  765 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  766 + }
  767 + defer func() {
  768 + _ = transactionContext.RollbackTransaction()
  769 + }()
  770 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  771 + "transactionContext": transactionContext,
  772 + })
  773 +
  774 + //获取员工的评估
  775 + _, assessList, err := assessReps.Find(map[string]interface{}{
  776 + "companyId": param.CompanyId,
  777 + "staffAssessTaskId": param.AssessTaskId,
  778 + "targetUserId": param.TargetUserId,
  779 + "typesList": []string{string(domain.AssessSelf)},
  780 + })
  781 + if err != nil {
  782 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
  783 + }
  784 + if len(assessList) == 0 {
  785 + return &adapter.AssessInfoResp{}, nil
  786 + }
  787 + assessData := assessList[0]
  788 + projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
  789 + "transactionContext": transactionContext,
  790 + })
  791 + projectData, err := projectRepo.FindOne(map[string]interface{}{
  792 + "id": assessData.EvaluationProjectId,
  793 + })
  794 + if err != nil {
  795 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估配置"+err.Error())
  796 + }
  797 + if projectData.Template == nil {
  798 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估配置模板")
  799 + }
  800 + var selfLinkNode *domain.LinkNode
  801 + for _, v := range projectData.Template.LinkNodes {
  802 + if v.Type == domain.LinkNodeSelfAssessment {
  803 + selfLinkNode = v
  804 + break
  805 + }
  806 + }
  807 + if selfLinkNode == nil {
  808 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估自评配置")
  809 + }
  810 + //获取员工评估的填写内容
  811 + // assessContentReps := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  812 + // "transactionContext": transactionContext,
  813 + // })
  814 + // _, assessContentList, err := assessContentReps.Find(map[string]interface{}{
  815 + // "staffAssessId": assessData.Id,
  816 + // })
  817 + // if err != nil {
  818 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估员工填写的内容"+err.Error())
  819 + // }
  820 + if err := transactionContext.CommitTransaction(); err != nil {
  821 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  822 + }
  823 +
  824 + result := adapter.AssessInfoResp{
  825 + CycleId: assessData.CycleId,
  826 + CycleName: assessData.CycleName,
  827 + EvaluationProjectId: assessData.EvaluationProjectId,
  828 + EvaluationProjectName: assessData.EvaluationProjectName,
  829 + BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
  830 + EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
  831 + Status: string(assessData.Status),
  832 + TargetUserId: assessData.TargetUser.UserId,
  833 + TargetUserName: assessData.TargetUser.UserName,
  834 + AssessContent: nil,
  835 + }
  836 + assessContent := make([]adapter.AssessContent, 0)
  837 + for _, v := range selfLinkNode.NodeContents {
  838 + assessContent = append(assessContent, adapter.AssessContent{
  839 + Category: v.Category,
  840 + Name: v.Name,
  841 + PromptTitle: v.PromptTitle,
  842 + PromptText: v.PromptText,
  843 + EntryItems: v.EntryItems,
  844 + })
  845 + }
  846 + result.AssessContent = assessContent
  847 + return &result, nil
  848 +}
@@ -21,20 +21,21 @@ const ( @@ -21,20 +21,21 @@ const (
21 StaffAssessCompleted StaffAssessStatus = "completed" //已完成 21 StaffAssessCompleted StaffAssessStatus = "completed" //已完成
22 ) 22 )
23 23
24 -// 记录用户需要的评估项 24 +// 记录用户需要的评估项
25 type StaffAssess struct { 25 type StaffAssess struct {
26 Id int `json:"id"` //id 26 Id int `json:"id"` //id
27 CompanyId int `json:"companyId"` //公司id 27 CompanyId int `json:"companyId"` //公司id
28 EvaluationProjectId int `json:"evaluationProjectId"` //对应的项目id 28 EvaluationProjectId int `json:"evaluationProjectId"` //对应的项目id
29 EvaluationProjectName string `json:"evaluationProjectName"` //对应的项目名称 29 EvaluationProjectName string `json:"evaluationProjectName"` //对应的项目名称
30 CycleId int64 `json:"cycleId"` //对应的周期id 30 CycleId int64 `json:"cycleId"` //对应的周期id
31 - CycleName int64 `json:"cycleName"` //对应的周期名称 31 + CycleName string `json:"cycleName"` //对应的周期名称
32 StaffAssessTaskId int `json:"staffAssessTaskId"` //执行评估的任务id 32 StaffAssessTaskId int `json:"staffAssessTaskId"` //执行评估的任务id
33 TargetUser StaffDesc `json:"targetUser"` //被评估的目标用户 33 TargetUser StaffDesc `json:"targetUser"` //被评估的目标用户
34 TargetDepartment []StaffDepartment `json:"targetDepartment"` //被评估的目标用户所在的部门 34 TargetDepartment []StaffDepartment `json:"targetDepartment"` //被评估的目标用户所在的部门
35 Executor StaffDesc `json:"executor"` //填写评估的用户 35 Executor StaffDesc `json:"executor"` //填写评估的用户
36 Types StaffAssessType `json:"types"` //填写评估对应的类型 36 Types StaffAssessType `json:"types"` //填写评估对应的类型
37 LinkNodeId int `json:"linkNodeId"` //评估环节对应的id,用于调取评估模板 37 LinkNodeId int `json:"linkNodeId"` //评估环节对应的id,用于调取评估模板
  38 + LinkNodeName string `json:"linkNodeName"` //评估环节对应的id,用于调取评估模板
38 Status StaffAssessStatus `json:"status"` //评估的填写状态 39 Status StaffAssessStatus `json:"status"` //评估的填写状态
39 BeginTime time.Time `json:"beginTime"` //开始时间 40 BeginTime time.Time `json:"beginTime"` //开始时间
40 EndTime time.Time `json:"endTime"` //截止时间 41 EndTime time.Time `json:"endTime"` //截止时间
@@ -17,6 +17,11 @@ type StaffAssessContent struct { @@ -17,6 +17,11 @@ type StaffAssessContent struct {
17 //TODO 17 //TODO
18 } 18 }
19 19
  20 +type AssessContemtRemark struct {
  21 + Title string `json:"title"` //comment:"填写标题"
  22 + RemarkText string `json:"hintText"` // comment:"填写文本内容"
  23 +}
  24 +
20 type StaffAssessContentRepository interface { 25 type StaffAssessContentRepository interface {
21 Save(param *StaffAssessContent) (*StaffAssessContent, error) 26 Save(param *StaffAssessContent) (*StaffAssessContent, error)
22 Remove(id int) error 27 Remove(id int) error
@@ -26,17 +26,20 @@ type StaffAssessTask struct { @@ -26,17 +26,20 @@ type StaffAssessTask struct {
26 BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 26 BeginTime time.Time `json:"beginTime"` //绩效考核开始时间
27 EndTime time.Time `json:"endTime"` //绩效考核截止时间 27 EndTime time.Time `json:"endTime"` //绩效考核截止时间
28 StepList []AssessTaskStep `json:"steps"` //考评的流程 28 StepList []AssessTaskStep `json:"steps"` //考评的流程
  29 + ExecutorId []int `json:"executorId"` //参与此次考评的人
29 CreatedAt time.Time `json:"createdAt"` //数据创建时间 30 CreatedAt time.Time `json:"createdAt"` //数据创建时间
30 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 31 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
31 - DeletedAt time.Time `json:"deletedAt"` //数据删除时间 32 + DeletedAt *time.Time `json:"deletedAt"` //数据删除时间
32 } 33 }
33 34
34 //考评的流程 35 //考评的流程
35 type AssessTaskStep struct { 36 type AssessTaskStep struct {
36 - SortBy int `json:"sortBy"` //排序  
37 - LinkNodeId int `json:"linkNodeId"` //考评的流程id  
38 - LinkNodeName string `json:"linkNodeName"` //流程名称  
39 - LinkNodeType int `json:"linkNodeType"` //流程类型 同evaluation_template.go->LinkNode.Type 37 + SortBy int `json:"sortBy"` //排序
  38 + LinkNodeId int `json:"linkNodeId"` //考评的流程id
  39 + LinkNodeName string `json:"linkNodeName"` //流程名称
  40 + LinkNodeType int `json:"linkNodeType"` //流程类型 同evaluation_template.go->LinkNode.Type
  41 + BeginTime time.Time `json:"beginTime"` //绩效考核开始时间
  42 + EndTime time.Time `json:"endTime"` //绩效考核截止时间
40 } 43 }
41 44
42 type StaffAssessTaskRepository interface { 45 type StaffAssessTaskRepository interface {
@@ -2,6 +2,7 @@ package pg @@ -2,6 +2,7 @@ package pg
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 +
5 "github.com/go-pg/pg/v10" 6 "github.com/go-pg/pg/v10"
6 "github.com/go-pg/pg/v10/orm" 7 "github.com/go-pg/pg/v10/orm"
7 "github.com/linmadan/egglib-go/persistent/pg/comment" 8 "github.com/linmadan/egglib-go/persistent/pg/comment"
@@ -39,6 +40,8 @@ func init() { @@ -39,6 +40,8 @@ func init() {
39 &models.EvaluationCycle{}, 40 &models.EvaluationCycle{},
40 &models.EvaluationCycleTemplate{}, 41 &models.EvaluationCycleTemplate{},
41 &models.EvaluationProject{}, 42 &models.EvaluationProject{},
  43 + &models.StaffAssess{},
  44 + &models.StaffAssessTask{},
42 } 45 }
43 for _, model := range tables { 46 for _, model := range tables {
44 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ 47 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
@@ -8,20 +8,24 @@ import ( @@ -8,20 +8,24 @@ import (
8 8
9 // 记录用户需要的评估项 9 // 记录用户需要的评估项
10 type StaffAssess struct { 10 type StaffAssess struct {
11 - tableName struct{} `pg:"staff_assess" comment:"记录用户需要的评估项"`  
12 - Id int `pg:",pk"` //id  
13 - CompanyId int `comment:"公司id"` //公司id  
14 - EvaluationProjectId int `comment:"对应的项目id"` //对应的项目id  
15 - CycleId int64 `comment:"对应的周期id"` //对应的周期id  
16 - TargetUser domain.StaffDesc `comment:"被评估的目标用户"` //被评估的目标用户  
17 - TargetDepartment []domain.StaffDepartment `comment:"被评估的用户所在的部门"` //被评估的用户所在的部门  
18 - Executor domain.StaffDesc `comment:"填写评估的用户"` //填写评估的用户  
19 - Types string `comment:"填写评估对应的类型"` //填写评估对应的类型  
20 - LinkNodeId int `comment:"评估环节id"`  
21 - Status string `comment:"评估的填写状态"` //评估的填写状态  
22 - BeginTime time.Time `comment:"开始时间"` //开始时间  
23 - EndTime time.Time `comment:"截止时间"` //截止时间  
24 - CreatedAt time.Time `comment:"数据创建时间"` //数据创建时间  
25 - UpdatedAt time.Time `comment:"数据更新时间"` //数据更新时间  
26 - DeletedAt *time.Time `comment:"数据删除时间"` //数据删除时间 11 + tableName struct{} `pg:"staff_assess" comment:"记录用户需要的评估项"`
  12 + Id int `pg:",pk"` //id
  13 + CompanyId int `comment:"公司id"` //公司id
  14 + EvaluationProjectId int `comment:"对应的项目id"` //对应的项目id
  15 + EvaluationProjectName string
  16 + CycleId int64 `comment:"对应的周期id"` //对应的周期id
  17 + CycleName string
  18 + StaffAssessTaskId int
  19 + TargetUser domain.StaffDesc `comment:"被评估的目标用户"` //被评估的目标用户
  20 + TargetDepartment []domain.StaffDepartment `comment:"被评估的用户所在的部门"` //被评估的用户所在的部门
  21 + Executor domain.StaffDesc `comment:"填写评估的用户"` //填写评估的用户
  22 + Types string `comment:"填写评估对应的类型"` //填写评估对应的类型
  23 + LinkNodeId int `comment:"评估环节id"`
  24 + LinkNodeName string
  25 + Status string `comment:"评估的填写状态"` //评估的填写状态
  26 + BeginTime time.Time `comment:"开始时间"` //开始时间
  27 + EndTime time.Time `comment:"截止时间"` //截止时间
  28 + CreatedAt time.Time `comment:"数据创建时间"` //数据创建时间
  29 + UpdatedAt time.Time `comment:"数据更新时间"` //数据更新时间
  30 + DeletedAt *time.Time `comment:"数据删除时间"` //数据删除时间
27 } 31 }
1 package models 1 package models
2 2
3 -import "time" 3 +import (
  4 + "time"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  7 +)
4 8
5 // 执行评估的任务列表 9 // 执行评估的任务列表
6 type StaffAssessTask struct { 10 type StaffAssessTask struct {
7 - tableName struct{} `pg:"staff_assess_task" comment:"执行评估的任务列表"`  
8 - Id int `pg:",pk"`  
9 - CompanyId int `` //公司id  
10 - EvaluationProjectId int `` //项目id  
11 - EvaluationProjectName string `` //项目名称  
12 - CycleId int64 //对应的周期id  
13 - CycleName string //对应周期的名称  
14 - BeginTime time.Time //开始时间  
15 - EndTime time.Time //截止时间  
16 - CreatedAt time.Time //数据创建时间  
17 - UpdatedAt time.Time //数据更新时间  
18 - DeletedAt time.Time //数据删除时间 11 + tableName struct{} `pg:"staff_assess_task" comment:"执行评估的任务列表"`
  12 + Id int `pg:",pk"`
  13 + CompanyId int `` //公司id
  14 + EvaluationProjectId int `` //项目id
  15 + EvaluationProjectName string `` //项目名称
  16 + CycleId int64 //对应的周期id
  17 + CycleName string //对应周期的名称
  18 + ExecutorId []int //参与考评的人
  19 + StepList []domain.AssessTaskStep `` //考评的流程
  20 + BeginTime time.Time //开始时间
  21 + EndTime time.Time //截止时间
  22 + CreatedAt time.Time //数据创建时间
  23 + UpdatedAt time.Time //数据更新时间
  24 + DeletedAt *time.Time //数据删除时间
19 } 25 }
@@ -91,9 +91,8 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) ( @@ -91,9 +91,8 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) (
91 91
92 func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Department, error) { 92 func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Department, error) {
93 tx := repo.transactionContext.PgTx 93 tx := repo.transactionContext.PgTx
94 - var dparmentModel []models.Department  
95 - query := tx.Model(&dparmentModel).  
96 - Limit(20) 94 + dparmentModel := []models.Department{}
  95 + query := tx.Model(&dparmentModel).Where("delete_at isnull")
97 if v, ok := queryOptions["id"]; ok { 96 if v, ok := queryOptions["id"]; ok {
98 query.Where("id=?", v) 97 query.Where("id=?", v)
99 } 98 }
@@ -3,13 +3,14 @@ package repository @@ -3,13 +3,14 @@ package repository
3 import ( 3 import (
4 "errors" 4 "errors"
5 "fmt" 5 "fmt"
  6 + "time"
  7 +
6 "github.com/go-pg/pg/v10" 8 "github.com/go-pg/pg/v10"
7 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" 9 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
8 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 10 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
10 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" 12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" 13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
12 - "time"  
13 ) 14 )
14 15
15 type EvaluationCycleRepository struct { 16 type EvaluationCycleRepository struct {
@@ -133,6 +134,16 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) @@ -133,6 +134,16 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{})
133 query.Offset(v) 134 query.Offset(v)
134 } 135 }
135 136
  137 + if v, ok := queryOptions["timeStart"]; ok {
  138 + t := v.(time.Time)
  139 + query.Where("time_start<=?", t)
  140 + }
  141 +
  142 + if v, ok := queryOptions["timeEnd"]; ok {
  143 + t := v.(time.Time)
  144 + query.Where("time_end>=?", t)
  145 + }
  146 +
136 count, err := query.SelectAndCount() 147 count, err := query.SelectAndCount()
137 if err != nil { 148 if err != nil {
138 return 0, nil, err 149 return 0, nil, err
@@ -17,7 +17,7 @@ type StaffAssessContentRepository struct { @@ -17,7 +17,7 @@ type StaffAssessContentRepository struct {
17 17
18 var _ domain.StaffAssessContentRepository = (*StaffAssessContentRepository)(nil) 18 var _ domain.StaffAssessContentRepository = (*StaffAssessContentRepository)(nil)
19 19
20 -func NewStaffEvaluationRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessContentRepository { 20 +func NewStaffAssessContentRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessContentRepository {
21 return &StaffAssessContentRepository{transactionContext: transactionContext} 21 return &StaffAssessContentRepository{transactionContext: transactionContext}
22 } 22 }
23 23
@@ -89,7 +89,9 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface @@ -89,7 +89,9 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface
89 if v, ok := queryOptions["offset"].(int); ok { 89 if v, ok := queryOptions["offset"].(int); ok {
90 query.Offset(v) 90 query.Offset(v)
91 } 91 }
92 - 92 + if v, ok := queryOptions["staffAssessId"]; ok {
  93 + query.Where("staff_assess_id=?", v)
  94 + }
93 count, err := query.SelectAndCount() 95 count, err := query.SelectAndCount()
94 if err != nil { 96 if err != nil {
95 return 0, nil, err 97 return 0, nil, err
@@ -23,39 +23,49 @@ func NewStaffAssessRepository(transactionContext *pgTransaction.TransactionConte @@ -23,39 +23,49 @@ func NewStaffAssessRepository(transactionContext *pgTransaction.TransactionConte
23 23
24 func (repo *StaffAssessRepository) TransformToDomain(d *models.StaffAssess) *domain.StaffAssess { 24 func (repo *StaffAssessRepository) TransformToDomain(d *models.StaffAssess) *domain.StaffAssess {
25 return &domain.StaffAssess{ 25 return &domain.StaffAssess{
26 - Id: d.Id,  
27 - CompanyId: d.CompanyId,  
28 - EvaluationProjectId: d.EvaluationProjectId,  
29 - CycleId: d.CycleId,  
30 - TargetUser: d.TargetUser,  
31 - TargetDepartment: d.TargetDepartment,  
32 - Executor: d.Executor,  
33 - Types: domain.StaffAssessType(d.Types),  
34 - Status: domain.StaffAssessStatus(d.Status),  
35 - BeginTime: d.BeginTime,  
36 - EndTime: d.EndTime,  
37 - CreatedAt: d.EndTime,  
38 - UpdatedAt: d.CreatedAt,  
39 - DeletedAt: d.DeletedAt, 26 + Id: d.Id,
  27 + CompanyId: d.CompanyId,
  28 + EvaluationProjectId: d.EvaluationProjectId,
  29 + EvaluationProjectName: d.EvaluationProjectName,
  30 + CycleId: d.CycleId,
  31 + CycleName: d.CycleName,
  32 + StaffAssessTaskId: d.StaffAssessTaskId,
  33 + TargetUser: d.TargetUser,
  34 + TargetDepartment: d.TargetDepartment,
  35 + Executor: d.Executor,
  36 + Types: domain.StaffAssessType(d.Types),
  37 + LinkNodeId: d.LinkNodeId,
  38 + LinkNodeName: d.LinkNodeName,
  39 + Status: domain.StaffAssessStatus(d.Status),
  40 + BeginTime: d.BeginTime,
  41 + EndTime: d.EndTime,
  42 + CreatedAt: d.EndTime,
  43 + UpdatedAt: d.CreatedAt,
  44 + DeletedAt: d.DeletedAt,
40 } 45 }
41 } 46 }
42 47
43 func (repo *StaffAssessRepository) Save(d *domain.StaffAssess) (*domain.StaffAssess, error) { 48 func (repo *StaffAssessRepository) Save(d *domain.StaffAssess) (*domain.StaffAssess, error) {
44 saveModel := models.StaffAssess{ 49 saveModel := models.StaffAssess{
45 - Id: d.Id,  
46 - CompanyId: d.CompanyId,  
47 - EvaluationProjectId: d.EvaluationProjectId,  
48 - CycleId: d.CycleId,  
49 - TargetUser: d.TargetUser,  
50 - TargetDepartment: d.TargetDepartment,  
51 - Executor: d.Executor,  
52 - Types: string(d.Types),  
53 - Status: string(d.Status),  
54 - BeginTime: d.BeginTime,  
55 - EndTime: d.EndTime,  
56 - CreatedAt: d.EndTime,  
57 - UpdatedAt: d.CreatedAt,  
58 - DeletedAt: d.DeletedAt, 50 + Id: d.Id,
  51 + CompanyId: d.CompanyId,
  52 + EvaluationProjectId: d.EvaluationProjectId,
  53 + EvaluationProjectName: d.EvaluationProjectName,
  54 + CycleId: d.CycleId,
  55 + CycleName: d.CycleName,
  56 + StaffAssessTaskId: d.StaffAssessTaskId,
  57 + TargetUser: d.TargetUser,
  58 + TargetDepartment: d.TargetDepartment,
  59 + Executor: d.Executor,
  60 + Types: string(d.Types),
  61 + LinkNodeId: d.LinkNodeId,
  62 + LinkNodeName: d.LinkNodeName,
  63 + Status: string(d.Status),
  64 + BeginTime: d.BeginTime,
  65 + EndTime: d.EndTime,
  66 + CreatedAt: d.EndTime,
  67 + UpdatedAt: d.CreatedAt,
  68 + DeletedAt: d.DeletedAt,
59 } 69 }
60 tx := repo.transactionContext.PgTx 70 tx := repo.transactionContext.PgTx
61 var err error 71 var err error
@@ -107,7 +117,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -107,7 +117,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
107 tx := repo.transactionContext.PgTx 117 tx := repo.transactionContext.PgTx
108 var m []*models.StaffAssess 118 var m []*models.StaffAssess
109 query := tx.Model(&m). 119 query := tx.Model(&m).
110 - Where("deleted_at isnull").Limit(20) 120 + Where("deleted_at isnull")
111 if companyId, ok := queryOptions["companyId"]; ok { 121 if companyId, ok := queryOptions["companyId"]; ok {
112 query.Where("company_id = ?", companyId) 122 query.Where("company_id = ?", companyId)
113 } 123 }
@@ -117,7 +127,26 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -117,7 +127,26 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
117 if v, ok := queryOptions["offset"].(int); ok { 127 if v, ok := queryOptions["offset"].(int); ok {
118 query.Offset(v) 128 query.Offset(v)
119 } 129 }
  130 + if v, ok := queryOptions["targetUserId"].(int); ok && v > 0 {
  131 + query.Where(`target_user->>'userId'='?'`, v)
  132 + }
  133 + if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
  134 + query.Where(`executor->>'userId'='?'`, v)
  135 + }
120 136
  137 + if v, ok := queryOptions["cycleId"].(int64); ok && v > 0 {
  138 + query.Where(`cycle_id=?`, v)
  139 + }
  140 + if v, ok := queryOptions["staffAssessTaskId"]; ok {
  141 + query.Where(`staff_assess_task_id=?`, v)
  142 + }
  143 +
  144 + if v, ok := queryOptions["typesList"].([]string); ok && len(v) > 0 {
  145 + query.Where("types in(?)", pg.Array(v))
  146 + }
  147 + if v, ok := queryOptions["status"].(string); ok && len(v) > 0 {
  148 + query.Where("status=?", v)
  149 + }
121 count, err := query.SelectAndCount() 150 count, err := query.SelectAndCount()
122 if err != nil { 151 if err != nil {
123 return 0, nil, err 152 return 0, nil, err
@@ -111,7 +111,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) @@ -111,7 +111,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
111 if v, ok := queryOptions["offset"].(int); ok { 111 if v, ok := queryOptions["offset"].(int); ok {
112 query.Offset(v) 112 query.Offset(v)
113 } 113 }
114 - 114 + if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
  115 + query.Where(`executorId @>[?]`, v)
  116 + }
115 count, err := query.SelectAndCount() 117 count, err := query.SelectAndCount()
116 if err != nil { 118 if err != nil {
117 return 0, nil, err 119 return 0, nil, err
@@ -73,7 +73,7 @@ func (repo *UserRepository) Remove(userId []int64) error { @@ -73,7 +73,7 @@ func (repo *UserRepository) Remove(userId []int64) error {
73 func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domain.User, error) { 73 func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domain.User, error) {
74 tx := repo.transactionContext.PgTx 74 tx := repo.transactionContext.PgTx
75 userModel := models.User{} 75 userModel := models.User{}
76 - query := tx.Model(&userModel) 76 + query := tx.Model(&userModel).Where("delete_at isnull")
77 if v, ok := queryOptions["id"]; ok { 77 if v, ok := queryOptions["id"]; ok {
78 query.Where("id=?", v) 78 query.Where("id=?", v)
79 } 79 }
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "github.com/linmadan/egglib-go/web/beego"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service"
  9 +)
  10 +
  11 +type StaffAssessController struct {
  12 + beego.BaseController
  13 +}
  14 +
  15 +// 获取我的绩效任务列表
  16 +func (c *StaffAssessController) SearchAssessTaskMe() {
  17 + srv := service.NewStaffAssessServeice()
  18 + paramReq := &query.SearchAssessMeQuery{}
  19 + err := c.BindJSON(paramReq)
  20 + if err != nil {
  21 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  22 + c.Response(nil, e)
  23 + return
  24 + }
  25 + //TODO 获取当前用户信息
  26 + data, err := srv.SearchAssessTaskMe(paramReq)
  27 + c.Response(data, err)
  28 +}
  29 +
  30 +// 获取我的绩效任务各环节完成情况
  31 +func (c *StaffAssessController) AssessTaskMeDesc() {
  32 + srv := service.NewStaffAssessServeice()
  33 + paramReq := &query.AssessTaskDescQuery{}
  34 + err := c.BindJSON(paramReq)
  35 + if err != nil {
  36 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  37 + c.Response(nil, e)
  38 + return
  39 + }
  40 + //TODO 获取当前用户信息
  41 + data, err := srv.AssessTaskDesc(paramReq)
  42 + c.Response(data, err)
  43 +}
  44 +
  45 +// 获取个人的自评反馈历史记录列表
  46 +func (c *StaffAssessController) AssessSelfMeList() {
  47 + srv := service.NewStaffAssessServeice()
  48 + paramReq := &query.AssessSelfListQuery{}
  49 + err := c.BindJSON(paramReq)
  50 + if err != nil {
  51 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  52 + c.Response(nil, e)
  53 + return
  54 + }
  55 + //TODO 获取当前用户信息
  56 + data, err := srv.AssessSelfList(paramReq)
  57 + c.Response(data, err)
  58 +}
  59 +
  60 +// 更具项目评估的配置,创建员工的评估任务,(调试用)
  61 +func (c *StaffAssessController) CreateStaffAssessTask() {
  62 + srv := service.NewStaffAssessServeice()
  63 + paramReq := &command.CreateStaffAssessTask{}
  64 + err := c.BindJSON(paramReq)
  65 + if err != nil {
  66 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  67 + c.Response(nil, e)
  68 + return
  69 + }
  70 + //服务调用,实际由定时任务触发
  71 + data, err := srv.CreateStaffAssessTask(paramReq)
  72 + c.Response(data, err)
  73 +}