作者 Your Name

暂存

... ... @@ -120,3 +120,27 @@ func CreateEvaluationProjectRepository(options map[string]interface{}) domain.Ev
}
return repository.NewEvaluationProjectRepository(transactionContext)
}
func CreateStaffAssessRepository(options map[string]interface{}) domain.StaffAssessRepository {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewStaffAssessRepository(transactionContext)
}
func CreateStaffAssessContentRepository(options map[string]interface{}) domain.StaffAssessContentRepository {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewStaffAssessContentRepository(transactionContext)
}
func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.StaffAssessContentRepository {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewStaffAssessContentRepository(transactionContext)
}
... ...
package adapter
type AssessSelfList struct {
AssessId int `json:"assessId"` //用户执行的评估项id
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //开始时间 2006-01-02 15:04:05
CycleId int `json:"cycleId"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
}
type StaffInfo struct {
UserName string `json:"userName"` //员工名称
CompanyName string `json:"companyName"` //公司名称
SupperUserName string `json:"supperUserName"` //上级名称
DutyTime string `json:"dutyTime"` //上岗时间
}
... ...
package adapter
type AssessTaskDescResp struct {
AssessTaskId int `json:"assessTaskId"` //
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
CycleName string `json:"cycleName"` //周期名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
StepList []AssessTaskStep `json:"stepList"` // 考评流程
}
type AssessTaskStep struct {
SortBy int `json:"sortBy"` //排序
LinkNodeName string `json:"linkNodeName"` //流程名称
BeginTime string `json:"beginTime"` //开始时间时间
EndTime string `json:"endTime"` //结束时间
LinkNodeType string `json:"linkNodeType"` //流程类型
Desc string `json:"desc"` //情况描述
Status int `json:"status"` //流程是否完成
}
... ...
package adapter
type SearchAssessMeResp struct {
AssessTaskId int `json:"assessTaskId"`
BeginTime string `json:"beginTime"`
EndTime string `json:"endTime"`
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"`
EvaluationProjectId int `json:"evaluationProjectId"`
EvaluationProjectName string `json:"evaluationProjectName"`
}
... ...
package query
type AssessTaskDescQuery struct {
AssessTaskId int
}
... ...
package query
type SearchAssessMeQuery struct {
UserId int // 当前登录人的用户id
CompanyId int //当前登录人的公司Id
CurrentTime string // 日期 2006-01-02
}
... ...
package service
import (
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
)
type StaffAssessServeice struct {
}
// 获取我参与过的评估项目列表
func (srv StaffAssessServeice) SearchAssessMe(param *query.SearchAssessMeQuery) (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()
}()
cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
currentTime, err := time.ParseInLocation("2006-01-02", param.CurrentTime, time.Local)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "时间条件填写错误")
}
//获取param.CurrentTime 对应的周期
_, cycleList, err := cycleRepo.Find(map[string]interface{}{
"companyId": param.CompanyId,
"timeStart": currentTime,
"timeEnd": currentTime,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error())
}
if len(cycleList) == 0 {
listData := []adapter.SearchAssessMeResp{}
return tool_funs.SimpleWrapGridMap(0, listData), nil
}
//更具周期和param.UserId 获取评估项目列表
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var cnt int64
var listData []adapter.SearchAssessMeResp
return tool_funs.SimpleWrapGridMap(cnt, listData), nil
}
// 获取项目评估进度描述
func (srv StaffAssessServeice) AssessTaskDesc(param query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, 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()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
}
// 获取自评反馈列表
func (srv StaffAssessServeice) AssessSelfList(param query.AssessTaskDescQuery) (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()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var cnt int64
var listData []adapter.AssessSelfList
var userInfo adapter.StaffInfo
result := tool_funs.SimpleWrapGridMap(cnt, listData)
result["userInfo"] = userInfo
return result, nil
}
... ...
... ... @@ -3,13 +3,14 @@ package repository
import (
"errors"
"fmt"
"time"
"github.com/go-pg/pg/v10"
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
"time"
)
type EvaluationCycleRepository struct {
... ... @@ -133,6 +134,16 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{})
query.Offset(v)
}
if v, ok := queryOptions["timeStart"]; ok {
t := v.(time.Time)
query.Where("time_start<=?", t)
}
if v, ok := queryOptions["timeEnd"]; ok {
t := v.(time.Time)
query.Where("time_end>=?", t)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
... ... @@ -17,7 +17,7 @@ type StaffAssessContentRepository struct {
var _ domain.StaffAssessContentRepository = (*StaffAssessContentRepository)(nil)
func NewStaffEvaluationRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessContentRepository {
func NewStaffAssessContentRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessContentRepository {
return &StaffAssessContentRepository{transactionContext: transactionContext}
}
... ...