作者 tangxvhui

Merge branch 'test'

正在显示 33 个修改的文件 包含 665 行增加151 行删除
... ... @@ -60,6 +60,8 @@ spec:
value: "debug"
- name: LOG_FILE
value: "true"
- name: ENV_MOD
value: "prd"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
... ...
... ... @@ -60,6 +60,8 @@ spec:
value: "debug"
- name: LOG_FILE
value: "true"
- name: ENV_MOD
value: "test"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
... ...
package main
import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"time"
"github.com/beego/beego/v2/server/web"
... ... @@ -27,7 +28,13 @@ func startNodeTask() {
go func() {
nodeTaskService := serviceTask.NewNodeTaskService()
for {
timer := time.NewTimer(time.Second * 60)
var duration time.Duration
if constant.Env == "prd" {
duration = time.Minute * 5
} else {
duration = time.Minute * 1
}
timer := time.NewTimer(duration)
<-timer.C
if err := nodeTaskService.SendEvaluationNode(); err != nil {
log.Logger.Error(err.Error())
... ...
... ... @@ -17,6 +17,7 @@ type EvaluationProjectAdapter struct {
}
func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients []*domain.User) {
adapter.RecipientList = make([]*UserAdapter, 0)
for i := range recipients {
adapter.RecipientList = append(adapter.RecipientList, &UserAdapter{
Id: recipients[i].Id,
... ... @@ -26,6 +27,7 @@ func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients []
}
func (adapter *EvaluationProjectAdapter) TransformPmpAdapter(pms []*domain.User) {
adapter.PmpList = make([]*UserAdapter, 0)
for i := range pms {
adapter.PmpList = append(adapter.PmpList, &UserAdapter{
Id: pms[i].Id,
... ... @@ -46,6 +48,8 @@ func TransformProjectListAdapter(projects []*domain.EvaluationProject, users []*
epa := &EvaluationProjectAdapter{}
epa.EvaluationProject = project
epa.PmpList = make([]*UserAdapter, 0)
projectAdapters = append(projectAdapters, epa)
for j := range project.PmpIds {
... ...
... ... @@ -176,7 +176,8 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
}
now := time.Now().Local()
nowO := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻
year, month, day := now.Date()
nowO := time.Date(year, month, day, 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻
for i := range tasks {
task := tasks[i]
... ... @@ -185,18 +186,20 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
// 重新计算
if task.NextSentAt == nil {
// 环节起始和截止本地时间
startLocal := task.TimeStart
endLocal := task.TimeEnd
startLocal := task.TimeStart.Local()
sYear, sMonth, sDay := startLocal.Date()
startLocal = time.Date(sYear, sMonth, sDay, 0, 0, 0, 0, time.Local) // 开始时间以0点开始计算
endLocal := task.TimeEnd.Local()
// 在当前时间之前,则计算下一个周期时间
if startLocal.Before(now) {
if startLocal.Before(nowO) {
nextTime := utils.NextTime(nowO, startLocal, task.KpiCycle)
task.NextSentAt = &nextTime
} else {
task.NextSentAt = startLocal
task.NextSentAt = &startLocal
}
// 如果超出截至时间,则周期置空
if task.NextSentAt.After(endLocal.Local()) {
if task.NextSentAt.After(endLocal) {
task.NextSentAt = nil
}
} else {
... ... @@ -435,6 +438,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
}()
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
if err != nil {
... ... @@ -456,10 +460,9 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
now := time.Now().Local()
nowO := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻
year, month, day := now.Date()
nowO := time.Date(year, month, day, 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻
for i := range project.Template.LinkNodes {
node := project.Template.LinkNodes[i]
... ... @@ -479,18 +482,20 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
}
// 环节起始和截止本地时间
startLocal := node.TimeStart
endLocal := node.TimeEnd
startLocal := task.TimeStart.Local()
sYear, sMonth, sDay := startLocal.Date()
startLocal = time.Date(sYear, sMonth, sDay, 0, 0, 0, 0, time.Local) // 开始时间以0点开始计算
endLocal := task.TimeEnd.Local()
// 在当前时间之前,则计算下一个周期时间
if startLocal.Before(now) {
if startLocal.Before(nowO) {
nextTime := utils.NextTime(nowO, startLocal, node.KpiCycle)
task.NextSentAt = &nextTime
} else {
task.NextSentAt = startLocal
task.NextSentAt = &startLocal
}
// 如果超出截至时间,则周期置空
if task.NextSentAt.After(endLocal.Local()) {
if task.NextSentAt.After(endLocal) {
task.NextSentAt = nil
}
... ...
... ... @@ -218,6 +218,7 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i
if v, ok := userNameMap[ras[i].CreatorId]; ok {
ras[i].CreatorName = v
}
}
if err := transactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -160,3 +160,11 @@ func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.Staf
}
return repository.NewStaffAssessTaskRepository(transactionContext)
}
func CreateStaffAssessContentTempRepository(options map[string]interface{}) domain.StaffAssessContentTempRepository {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewStaffAssessContentTempRepository(transactionContext)
}
... ...
... ... @@ -87,7 +87,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
maxTime := task.TimeEnd.Local()
// 当前周起始时间和截止时间
var cycleTimeStart = task.NextSentAt
var cycleTimeStart = task.NextSentAt.Local()
var cycleTimeEnd time.Time
// 下个周期起始时间
... ...
package query
type ListAssessContentCycleDay struct {
CompanyId int `json:"companyId"`
OperaterId int `json:"operaterId"`
CycleId int `json:"cycleId,string"`
BeginDay string `json:"beginDay"`
TargetUserName string `json:"targetUserName"`
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
}
... ...
package query
type ListAssessCycleDay struct {
CompanyId int `json:"companyId"`
CycleId int `json:"cycleId,string"`
}
... ...
... ... @@ -480,6 +480,7 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application.
//获取员工信息
_, userList, err := userRepo.Find(map[string]interface{}{
"ids": selfUserId,
"status": 1,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息"+err.Error())
... ... @@ -690,12 +691,17 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU
// 保存某个员工360邀请的人员
func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (map[string]interface{}, error) {
inviteSameSuperId := []int{}
userIdMap := map[int]struct{}{} //过滤重复的id
InviteDiffSuperId := []int{}
for _, v := range param.InviteDiffSuper {
id, err := strconv.Atoi(v)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误")
}
if _, ok := userIdMap[id]; ok {
continue
}
userIdMap[id] = struct{}{}
InviteDiffSuperId = append(InviteDiffSuperId, id)
}
for _, v := range param.InviteSameSuper {
... ... @@ -703,6 +709,10 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误")
}
if _, ok := userIdMap[id]; ok {
continue
}
userIdMap[id] = struct{}{}
inviteSameSuperId = append(inviteSameSuperId, id)
}
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -781,6 +791,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
if len(inviteSameSuperId) > 0 {
_, userList, err := userRepo.Find(map[string]interface{}{
"ids": inviteSameSuperId,
"status": 1,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
... ... @@ -798,6 +809,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
if len(InviteDiffSuperId) > 0 {
_, userList, err := userRepo.Find(map[string]interface{}{
"ids": InviteDiffSuperId,
"status": 1,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
... ... @@ -1136,6 +1148,7 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI
"companyId": param.CompanyId,
"name": param.InviteUserName,
"limit": 20,
"status": 1,
}
if param.PageSize > 0 {
condition["limit"] = param.PageSize
... ... @@ -1713,12 +1726,11 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
continue
}
v.Value = item.Value
//填入评估值描述
reteResult, err := v.Rule.ScoreOrRating(&v.Value)
//转换填入的评估值
err = v.TransformValue()
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
v.ReteResult = reteResult
for ii := range v.Remark {
for _, vvv := range item.Remark {
if v.Remark[ii].Title == vvv.Title {
... ... @@ -1727,7 +1739,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
}
}
}
}
//保存信息
for i := range assessContentList {
... ... @@ -1863,6 +1874,7 @@ loop:
if len(chargeUserIds) > 0 {
_, chargeUserList, err = userRepo.Find(map[string]interface{}{
"ids": chargeUserIds,
"status": 1, //正常的用户
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error())
... ...
package service
import (
"time"
"github.com/linmadan/egglib-go/core/application"
"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/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
//调试用,手动调用CreateStaffAssessTask
... ... @@ -31,14 +34,77 @@ func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateS
}
//保存员工绩效评估填写过程中即写即存的内容
func (srv StaffAssessServeice) SaveAssessContentTemp(param *command.SaveAssessInfoCommand) error {
func (srv StaffAssessServeice) SaveAssessContentTemp(param *command.SaveAssessInfoCommand) (map[string]interface{}, error) {
return nil
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()
}()
//获取旧的临时数据内容
contentTempRepo := factory.CreateStaffAssessContentTempRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取评估填写的内容
// assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessData, err := assessRepo.FindOne(map[string]interface{}{
"id": param.AssessId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())
}
// staffAssessId
_, contentTempList, err := contentTempRepo.Find(map[string]interface{}{
"staffAssessId": param.AssessId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取临时保存的内容"+err.Error())
}
nowTime := time.Now()
if len(contentTempList) == 0 {
//获取评估模板
assessContentList, err := srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估模板,"+err.Error())
}
//转填入临时的数据
for _, v := range assessContentList {
item := &domain.StaffAssessContentTemp{
Id: 0,
StaffAssessId: v.StaffAssessId,
SortBy: v.SortBy,
Category: v.Category,
Name: v.Name,
Remark: v.Remark,
Value: "",
CreatedAt: nowTime,
UpdatedAt: nowTime,
}
contentTempList = append(contentTempList, item)
}
}
//更新assessContentTemp
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
}
//获取员工绩效评估填写内容
//临时数据存在时就获取临时数据
//不存在就获取实际保存的数据
func (srv StaffAssessServeice) GetAssessContentTemp(param *command.SaveAssessInfoCommand) (*adapter.AssessInfoResp, error) {
//将临时保存的数据填入模板中
return nil, nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
)
//员工绩效-项目管理
//获取已被执行的周期列表
func (srv StaffAssessServeice) ListAllAssessCycle(companyid int) (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()
}()
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
cycleList, err := assessDao.AllAssessCycleList(companyid)
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 := map[string]interface{}{
"list": cycleList,
}
return result, nil
}
//获取周期内的考核日期
func (srv StaffAssessServeice) ListAllAssessCycleDay(param *query.ListAssessCycleDay) (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()
}()
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
cycleDayList, err := assessDao.AllAssessCycleDayList(param.CompanyId, param.CycleId)
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 := map[string]interface{}{
"list": cycleDayList,
}
return result, nil
}
//根据周期id和日期获取 员工填写评估内容
// 有过滤查看权限
func (srv StaffAssessServeice) ListAllAssessContentCycleDay(param *query.ListAssessContentCycleDay) (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()
}()
// assessDao := dao.NewStaffAssessDao(map[string]interface{}{
// "transactionContext": transactionContext,
// })
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"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/user/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
type UserService struct{}
... ... @@ -26,6 +27,7 @@ func (service *UserService) ListUsers(listUserQuery *query.ListUserQuery) (inter
count, list, err := userRepo.Find(map[string]interface{}{
"companyId": listUserQuery.CompanyId,
"name": listUserQuery.Name,
"status": domain.UserStatusEnable,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -11,8 +11,15 @@ var AdminJwtExpiresIn = int64(3600 * 24 * 7)
var AdminJWTSecretKey = "sg-storage"
// Env 判断当前环境变量
var Env = "dev"
func init() {
if os.Getenv("LOG_LEVEL") != "" {
LOG_LEVEL = os.Getenv("LOG_LEVEL")
}
if os.Getenv("ENV_MOD") != "" {
Env = os.Getenv("ENV_MOD")
}
}
... ...
package domain
import (
"errors"
"fmt"
"strconv"
"time"
)
... ... @@ -58,54 +55,54 @@ type EvaluationRule struct {
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
}
// 根据评估填写的值,得出等级名称
// 如果 评估方式是评分,对评估填写的值的小数点后的位数进行处理,
// value 根据评估填写的值
func (rule *EvaluationRule) ScoreOrRating(value *string) (string, error) {
switch rule.Type {
case EvaluationTypeRating:
return rule.RatingValue(value)
case EvaluationTypeScore:
return rule.ScoreValue(value)
}
return "", errors.New("rule.Type 错误")
}
//根据评估填写的值,得出等级名称,
func (rule *EvaluationRule) ScoreValue(value *string) (string, error) {
valueFloat, err := strconv.ParseFloat(*value, 64)
if err != nil {
return "", errors.New("评分填写的值错误")
}
if valueFloat < rule.Score.Min || valueFloat > rule.Score.Max {
return "", fmt.Errorf("评分填写的值超出限制,>=%f且<=%f", rule.Score.Min, rule.Score.Max)
}
//保留小数处理
fStr := fmt.Sprintf("%%.%df", rule.Score.DecimalPlaces)
valueStr := fmt.Sprintf(fStr, valueFloat)
*value = valueStr
if rule.Score.IntervalState == 0 {
// 未开启按分数子区间匹配等级
return "", nil
}
valueDescrip := ""
for _, v := range rule.Score.Levels {
if valueFloat >= v.Start && valueFloat <= v.End {
valueDescrip = v.Name
}
}
return valueDescrip, nil
}
//根据评估填写的值,得出等级名称,
func (rule *EvaluationRule) RatingValue(value *string) (string, error) {
for _, v := range rule.Rating.Levels {
if v.Code == *value {
return v.Name, nil
}
}
return "", errors.New("评估填写的值错误")
}
// // 根据评估填写的值,得出等级名称和填写的值量化值
// // 如果 评估方式是评分,对评估填写的值的小数点后的位数进行处理,
// // value 根据评估填写的值
// func (rule *EvaluationRule) ScoreOrRating(value *string) (string, error) {
// switch rule.Type {
// case EvaluationTypeRating:
// return rule.RatingValue(value)
// case EvaluationTypeScore:
// return rule.ScoreValue(value)
// }
// return "", errors.New("rule.Type 错误")
// }
// //根据评估填写的值,得出等级名称和填写的值量化值
// func (rule *EvaluationRule) ScoreValue(value *string) (string, error) {
// valueFloat, err := strconv.ParseFloat(*value, 64)
// if err != nil {
// return "", errors.New("评分填写的值错误")
// }
// if valueFloat < rule.Score.Min || valueFloat > rule.Score.Max {
// return "", fmt.Errorf("评分填写的值超出限制,>=%f且<=%f", rule.Score.Min, rule.Score.Max)
// }
// //保留小数处理
// fStr := fmt.Sprintf("%%.%df", rule.Score.DecimalPlaces)
// valueStr := fmt.Sprintf(fStr, valueFloat)
// *value = valueStr
// if rule.Score.IntervalState == 0 {
// // 未开启按分数子区间匹配等级
// return "", nil
// }
// valueDescrip := ""
// for _, v := range rule.Score.Levels {
// if valueFloat >= v.Start && valueFloat <= v.End {
// valueDescrip = v.Name
// }
// }
// return valueDescrip, nil
// }
// //根据评估填写的值,得出等级名称,
// func (rule *EvaluationRule) RatingValue(value *string) (string, error) {
// for _, v := range rule.Rating.Levels {
// if v.Code == *value {
// return v.Name, nil
// }
// }
// return "", errors.New("评估填写的值错误")
// }
// GenerateSysRule 当前公司下的生成默认规则
func GenerateSysRule(companyId int64) *EvaluationRule {
... ...
package domain
import "time"
import (
"errors"
"fmt"
"strconv"
"time"
)
//填写的评估内容
type StaffAssessContent struct {
... ... @@ -13,6 +18,8 @@ type StaffAssessContent struct {
PromptText string `json:"promptText"` //提示项正文
Remark []AssessContemtRemark `json:"remark"` //填写的反馈
Value string `json:"value"` //评估填写的值
ScoreValue float64 `json:"scoreValue"` // 填写值按规则Rule转换为相应的量化值
LevelValue string `json:"levelValue"` // 填写值按规则Rule转换为相应的等级值
ReteResult string `json:"reteResult"` //评估的结果
Rule EvaluationRule `json:"rule"` //评估的选项规则
Weight int `json:"weight" ` //"权重"
... ... @@ -28,6 +35,63 @@ type AssessContemtRemark struct {
RemarkText string `json:"remarkText"` // comment:"填写文本内容"
}
//TransformValue
//根据规则 rule 转换评填写的值
func (content *StaffAssessContent) TransformValue() error {
switch content.Rule.Type {
case EvaluationTypeRating:
return content.ratingValue()
case EvaluationTypeScore:
return content.scoreValue()
}
return nil
}
// 规则是评级方式
func (content *StaffAssessContent) ratingValue() error {
levels := content.Rule.Rating.Levels
for _, v := range levels {
if v.Code != content.Value {
continue
}
content.LevelValue = v.Code
content.ScoreValue = v.QuantizedValue
content.ReteResult = v.Name
return nil
}
return errors.New("评级填写的值错误")
}
// 规则是评分方式
func (content *StaffAssessContent) scoreValue() error {
valueFloat, err := strconv.ParseFloat(content.Value, 64)
if err != nil {
return errors.New("评分填写的值错误")
}
rule := &content.Rule
if valueFloat < rule.Score.Min || valueFloat > rule.Score.Max {
return fmt.Errorf("评分填写的值超出限制,>=%f且<=%f", rule.Score.Min, rule.Score.Max)
}
//保留小数处理
fStr := fmt.Sprintf("%%.%df", rule.Score.DecimalPlaces)
valueStr := fmt.Sprintf(fStr, valueFloat)
content.Value = valueStr
if rule.Score.IntervalState == 0 {
// 未开启按分数子区间匹配等级
return nil
}
for _, v := range rule.Score.Levels {
if valueFloat < v.Start || valueFloat > v.End {
continue
}
content.LevelValue = v.Code
content.ScoreValue = valueFloat
content.ReteResult = v.Name
return nil
}
return errors.New("评分填写的值错误")
}
type StaffAssessContentRepository interface {
Save(param *StaffAssessContent) (*StaffAssessContent, error)
Remove(id int) error
... ...
... ... @@ -13,7 +13,6 @@ type StaffAssessContentTemp struct {
Value string `json:"value"` //评估填写的值
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
DeletedAt *time.Time `json:"deletedAt"`
}
type StaffAssessContentTempRepository interface {
... ...
... ... @@ -24,7 +24,7 @@ const (
UserTypeCommon int = 1
UserTypeManager int = 2
UserStatusEnable int = 1
UserStatusEnable int = 1 // 正常用户 2禁用用户
)
type UserRepository interface {
... ...
package dao
import (
"fmt"
"strconv"
"github.com/go-pg/pg/v10"
... ... @@ -99,5 +100,226 @@ func (d *StaffAssessDao) CountAssessTaskMe(executorId int, companyId int) (int,
result := 0
_, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
return result, err
}
//获取所以已经执行的评估周期
type AssessCycle struct {
CycleId string `json:"cycleId"` //周期id
CompanyId string `json:"companyId"`
CycleName string `json:"cycleName"` //周期名称
}
//获取所以已经执行的评估周期
func (d *StaffAssessDao) AllAssessCycleList(companyId int) ([]AssessCycle, error) {
sqlStr := `select
distinct
staff_assess_task.cycle_id ,
staff_assess_task.company_id ,
staff_assess_task.cycle_name
from staff_assess_task
where staff_assess_task.company_id = ?`
tx := d.transactionContext.PgTx
condition := []interface{}{
companyId,
}
result := []AssessCycle{}
_, err := tx.QueryOne(&result, sqlStr, condition...)
return result, err
}
//获取评估周期中的绩效考核日期
type AssessCycleDay struct {
BeginDay string `json:"beginDay"`
CycleId string `json:"cycleId"`
CompanyId string `json:"companyId"`
}
//获取评估周期中的绩效考核日期
func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]AssessCycleDay, error) {
sqlStr := `select distinct staff_assess_task.begin_day ,
staff_assess_task.cycle_id ,
staff_assess_task.company_id
from staff_assess_task
where staff_assess_task.cycle_id = ?
and company_id =? `
tx := d.transactionContext.PgTx
condition := []interface{}{
cycleId, companyId,
}
result := []AssessCycleDay{}
_, err := tx.QueryOne(&result, sqlStr, condition...)
return result, err
}
//获取员工填写评估内容
type UserAssessContent struct {
TargetUserId string `json:"targetUserId"` //被评估人的id
TargetUserName string `json:"targetUserName"` //被评估人的名称
BeginDay string `json:"beginDay"` //评估的日期
EvaluationProjectId string `json:"evaluationProjectId"` //项目id
Value string `json:"value"` //评估填写的值
SortBy int `json:"sortBy"` //评估项顺序
Category string `json:"category"` //评估项分类
ContentName string `json:"contentName"` //评估项名称
Weight int `json:"weight"` //权重
}
type SearchConditin1 struct {
CompanyId int //公司id
CycleId int //周期id
BeginDay string //评估的日期
TargetUserName string //被评估人的名称
Limit int //分页
Offset int //分页
OperaterId int //用户的id是谁在搜索数据
Hrbp int //
}
//根据周期的id和日期获取员工填写的评估内容
//companyId int 公司id
//cycleId int, 评估周期id
//userId int, 用户id,谁要查看数据
//beginDay string, 周期中执行项目的时间
//hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
//limit int, 分页条数
//offset int 分页偏移
func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserAssessContent, error) {
sqlStr := ` select
t_staff_assess_1.target_user_id,t_staff_assess_1.target_user_name,t_staff_assess_1.begin_day,
staff_assess_content.value ,staff_assess_content.sort_by ,
staff_assess_content.category ,staff_assess_content."name" as content_name ,
staff_assess_content.weight
from t_staff_assess_1
left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
`
condition := []interface{}{}
if len(param.TargetUserName) > 0 {
sqlStr += ` where t_staff_assess_1.target_user_name like ? `
condition = append(condition, param.TargetUserName)
}
//加入排序
sqlStr += ` order by convert_to(t_staff_assess_1.target_user_name,'GBK'),staff_assess_content.sort_by `
//获取前置sql语句
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset)
sqlStr = sqlStr0 + sqlStr
tx := d.transactionContext.PgTx
var result []UserAssessContent
_, err := tx.QueryOne(&result, sqlStr, condition...)
return result, err
}
//根据周期的id和日期获取员工填写的评估内容,数量统计
//companyId int 公司id
//cycleId int, 评估周期id
//userId int, 用户id,谁要查看数据
//beginDay string, 周期中执行项目的时间
//hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
//limit int, 分页条数
//offset int 分页偏移
func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) ([]UserAssessContent, error) {
sqlStr := ` select
t_staff_assess_1.target_user_id,t_staff_assess_1.target_user_name,t_staff_assess_1.begin_day,
staff_assess_content.value ,staff_assess_content.sort_by ,
staff_assess_content.category ,staff_assess_content."name" as content_name ,
staff_assess_content.weight
from t_staff_assess_1
left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
`
condition := []interface{}{}
if len(param.TargetUserName) > 0 {
sqlStr += ` where t_staff_assess_1.target_user_name like ? `
condition = append(condition, param.TargetUserName)
}
//加入排序
sqlStr += ` order by convert_to(t_staff_assess_1.target_user_name,'GBK'),staff_assess_content.sort_by `
//获取前置sql语句
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset)
sqlStr = sqlStr0 + sqlStr
tx := d.transactionContext.PgTx
var result []UserAssessContent
_, err := tx.QueryOne(&result, sqlStr, condition...)
return result, err
}
//生成的sql 根据用户的查看权限 ,获取可查看的评估任务,
//companyId int 公司id
//cycleId int, 评估周期id
//userId int, 用户id,谁要查看数据
//beginDay string, 周期中执行项目的时间
//hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
//limit int, 分页条数
//offset int 分页偏移
func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int) string {
sqlstr := `
with t_user_department as (
select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
where "user".company_id= %d
),
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
where evaluation_project.cycle_id =%d
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,
staff_assess.target_user->>'userName' as target_user_name,
to_char(staff_assess.begin_time,'YYYY-MM-DD') as begin_day,
staff_assess.evaluation_project_id
from staff_assess
where staff_assess.cycle_id = %d
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,
t_staff_assess_0.target_user_name,
t_staff_assess_0.begin_day
from t_staff_assess_0
join t_project_3 on t_staff_assess_0.evaluation_project_id = t_project_3.project_id
) union (select t_staff_assess_0.assess_id,
t_staff_assess_0.target_user_id,
t_staff_assess_0.target_user_name,
t_staff_assess_0.begin_day
from t_staff_assess_0
join t_user_1 on t_staff_assess_0.target_user_id=t_user_1.user_id
)
limit %d offset %d
)
`
params := []interface{}{
companyId, userId, cycleId, hrbp, cycleId, userId, cycleId, beginDay, limit, offset,
}
sqlstr = fmt.Sprintf(sqlstr, params...)
return sqlstr
}
... ...
... ... @@ -14,8 +14,8 @@ type EvaluationProject struct {
CycleId int64 `comment:"周期ID"`
CreatorId int64 `comment:"创建人ID"`
State int `comment:"状态(0待完成配置、1待启用、2启用、3停用)" pg:",use_zero"`
HrBp int `comment:"HR角色权限"`
Pmp int `comment:"PM角色权限"`
HrBp int `comment:"HR角色权限" pg:",use_zero"`
Pmp int `comment:"PM角色权限" pg:",use_zero"`
PmpIds []string `comment:"项目管理员ID"`
Recipients []string `comment:"被评估人ID"`
Template *domain.EvaluationTemplate `comment:"评估模板"`
... ...
... ... @@ -12,16 +12,16 @@ type StaffAssess struct {
Id int `pg:",pk"` //id
CompanyId int `comment:"公司id"` //公司id
EvaluationProjectId int `comment:"对应的项目id"` //对应的项目id
EvaluationProjectName string
EvaluationProjectName string `comment:"对应的项目名称"`
CycleId int64 `comment:"对应的周期id"` //对应的周期id
CycleName string
StaffAssessTaskId int
CycleName string `comment:"对应的周期名称"`
StaffAssessTaskId int `comment:"评估任务的id"`
TargetUser domain.StaffDesc `comment:"被评估的目标用户"` //被评估的目标用户
TargetDepartment []domain.StaffDepartment `comment:"被评估的用户所在的部门"` //被评估的用户所在的部门
Executor domain.StaffDesc `comment:"填写评估的用户"` //填写评估的用户
Types string `comment:"填写评估对应的类型"` //填写评估对应的类型
LinkNodeId int `comment:"评估环节id"`
LinkNodeName string
LinkNodeName string `comment:"评估环节名称"`
Status string `comment:"评估的填写状态"` //评估的填写状态
BeginTime time.Time `comment:"开始时间"` //开始时间
EndTime time.Time `comment:"截止时间"` //截止时间
... ...
... ... @@ -14,13 +14,15 @@ type StaffAssessContent struct {
SortBy int //排序
Category string //类别
Name string //名称
ScoreValue float64 // 填写值按规则Rule转换为相应的量化值
LevelValue string // 填写值按规则Rule转换为相应的等级值
PromptTitle string //问题标题
PromptText string //提示项正文
Value string //评估填写的值
ReteResult string //评估的结果
Rule domain.EvaluationRule
Remark []domain.AssessContemtRemark
Weight int //权重
Weight int `pg:",use_zero"` //权重
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time
... ...
... ... @@ -8,20 +8,14 @@ import (
// 填写的评估内容
type StaffAssessContentTemp struct {
tableName struct{} `pg:"staff_assess_content_temp" comment:"填写的评估项"`
tableName struct{} `pg:"staff_assess_content_temp" comment:"临时填写的评估项"`
Id int `pg:",pk"` //id
StaffAssessId int //用户需要的评估项id
SortBy int //排序
Category string //类别
Name string //名称
PromptTitle string //问题标题
PromptText string //提示项正文
Value string //评估填写的值
ReteResult string //评估的结果
Rule domain.EvaluationRule
Remark []domain.AssessContemtRemark
Weight int //权重
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time
StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id
SortBy int `json:"sortBy"` //排序
Category string `json:"category"` //类别
Name string `json:"name"` //名称
Remark []domain.AssessContemtRemark `json:"remark"` //填写的反馈
Value string `json:"value"` //评估填写的值
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
}
... ...
... ... @@ -21,9 +21,6 @@ func NewNodeTaskRepository(transactionContext *pgTransaction.TransactionContext)
}
func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.NodeTask {
timeStart := m.TimeStart.Local()
timeEnd := m.TimeEnd.Local()
nextSentAt := m.NextSentAt.Local()
return domain.NodeTask{
Id: m.Id,
CompanyId: m.CompanyId,
... ... @@ -34,10 +31,10 @@ func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.Nod
NodeName: m.NodeName,
NodeDescribe: m.NodeDescribe,
NodeSort: m.NodeSort,
TimeStart: &timeStart,
TimeEnd: &timeEnd,
TimeStart: m.TimeStart,
TimeEnd: m.TimeEnd,
KpiCycle: m.KpiCycle,
NextSentAt: &nextSentAt,
NextSentAt: m.NextSentAt,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
... ...
... ... @@ -32,6 +32,8 @@ func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAsses
PromptText: d.PromptText,
Remark: d.Remark,
Value: d.Value,
ScoreValue: d.ScoreValue,
LevelValue: d.LevelValue,
ReteResult: d.ReteResult,
Rule: d.Rule,
Weight: d.Weight,
... ... @@ -48,15 +50,17 @@ func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*d
SortBy: d.SortBy,
Category: d.Category,
Name: d.Name,
ScoreValue: d.ScoreValue,
LevelValue: d.LevelValue,
PromptTitle: d.PromptTitle,
PromptText: d.PromptText,
Remark: d.Remark,
Value: d.Value,
ReteResult: d.ReteResult,
Rule: d.Rule,
Remark: d.Remark,
Weight: d.Weight,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
Weight: d.Weight,
DeletedAt: nil,
}
tx := repo.transactionContext.PgTx
... ...
... ... @@ -3,7 +3,6 @@ package repository
import (
"errors"
"fmt"
"time"
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
... ... @@ -15,49 +14,37 @@ type StaffAssessContentTempRepository struct {
transactionContext *pgTransaction.TransactionContext
}
// var _ domain.StaffAssessContentRepository = (*StaffAssessContentTempRepository)(nil)
var _ domain.StaffAssessContentTempRepository = (*StaffAssessContentTempRepository)(nil)
func NewStaffAssessContentTempRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessContentTempRepository {
return &StaffAssessContentTempRepository{transactionContext: transactionContext}
}
func (repo *StaffAssessContentTempRepository) TransformToDomain(d *models.StaffAssessContent) *domain.StaffAssessContent {
return &domain.StaffAssessContent{
func (repo *StaffAssessContentTempRepository) TransformToDomain(d *models.StaffAssessContentTemp) *domain.StaffAssessContentTemp {
return &domain.StaffAssessContentTemp{
Id: d.Id,
StaffAssessId: d.StaffAssessId,
SortBy: d.SortBy,
Category: d.Category,
Name: d.Name,
PromptTitle: d.PromptTitle,
PromptText: d.PromptText,
Remark: d.Remark,
Value: d.Value,
ReteResult: d.ReteResult,
Rule: d.Rule,
Weight: d.Weight,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: nil,
}
}
func (repo *StaffAssessContentTempRepository) Save(d *domain.StaffAssessContent) (*domain.StaffAssessContent, error) {
saveModel := models.StaffAssessContent{
func (repo *StaffAssessContentTempRepository) Save(d *domain.StaffAssessContentTemp) (*domain.StaffAssessContentTemp, error) {
saveModel := models.StaffAssessContentTemp{
Id: d.Id,
StaffAssessId: d.StaffAssessId,
SortBy: d.SortBy,
Category: d.Category,
Name: d.Name,
PromptTitle: d.PromptTitle,
PromptText: d.PromptText,
Remark: d.Remark,
Value: d.Value,
ReteResult: d.ReteResult,
Rule: d.Rule,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
Weight: d.Weight,
DeletedAt: nil,
}
tx := repo.transactionContext.PgTx
var err error
... ... @@ -78,19 +65,15 @@ func (repo *StaffAssessContentTempRepository) Save(d *domain.StaffAssessContent)
func (repo *StaffAssessContentTempRepository) Remove(id int) error {
tx := repo.transactionContext.PgTx
nowTime := time.Now()
_, err := tx.Model(&models.StaffAssessContent{}).
Where("id=?", id).
Set("deleted_at=?", nowTime).
Update()
_, err := tx.Model(&models.StaffAssessContentTemp{}).
Where("id=?", id).Delete()
return err
}
func (repo *StaffAssessContentTempRepository) FindOne(queryOptions map[string]interface{}) (*domain.StaffAssessContent, error) {
func (repo *StaffAssessContentTempRepository) FindOne(queryOptions map[string]interface{}) (*domain.StaffAssessContentTemp, error) {
tx := repo.transactionContext.PgTx
m := new(models.StaffAssessContent)
m := new(models.StaffAssessContentTemp)
query := tx.Model(m)
query.Where("deleted_at isnull")
if id, ok := queryOptions["id"]; ok {
query.Where("id=?", id)
}
... ... @@ -105,20 +88,13 @@ func (repo *StaffAssessContentTempRepository) FindOne(queryOptions map[string]in
return u, nil
}
func (repo *StaffAssessContentTempRepository) Find(queryOptions map[string]interface{}) (int, []*domain.StaffAssessContent, error) {
func (repo *StaffAssessContentTempRepository) Find(queryOptions map[string]interface{}) (int, []*domain.StaffAssessContentTemp, error) {
tx := repo.transactionContext.PgTx
var m []*models.StaffAssessContent
query := tx.Model(&m).
Where("deleted_at isnull")
var m []*models.StaffAssessContentTemp
query := tx.Model(&m)
if companyId, ok := queryOptions["companyId"]; ok {
query.Where("company_id = ?", companyId)
}
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
}
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
}
if v, ok := queryOptions["staffAssessId"]; ok {
query.Where("staff_assess_id=?", v)
}
... ... @@ -126,7 +102,7 @@ func (repo *StaffAssessContentTempRepository) Find(queryOptions map[string]inter
if err != nil {
return 0, nil, err
}
var arrays []*domain.StaffAssessContent
var arrays []*domain.StaffAssessContentTemp
for _, v := range m {
d := repo.TransformToDomain(v)
arrays = append(arrays, d)
... ...
... ... @@ -63,8 +63,8 @@ func (repo *StaffAssessRepository) Save(d *domain.StaffAssess) (*domain.StaffAss
Status: string(d.Status),
BeginTime: d.BeginTime,
EndTime: d.EndTime,
CreatedAt: d.EndTime,
UpdatedAt: d.CreatedAt,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
}
tx := repo.transactionContext.PgTx
... ...
... ... @@ -34,8 +34,8 @@ func (repo *StaffAssessTaskRepository) TransformToDomain(d *models.StaffAssessTa
EndTime: d.EndTime,
StepList: d.StepList,
ExecutorId: d.ExecutorId,
CreatedAt: d.EndTime,
UpdatedAt: d.CreatedAt,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
}
}
... ... @@ -53,8 +53,8 @@ func (repo *StaffAssessTaskRepository) Save(d *domain.StaffAssessTask) (*domain.
StepList: d.StepList,
BeginTime: d.BeginTime,
EndTime: d.EndTime,
CreatedAt: d.EndTime,
UpdatedAt: d.CreatedAt,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
}
tx := repo.transactionContext.PgTx
... ...
... ... @@ -119,6 +119,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["status"]; ok {
query.Where("status=?", v)
}
if v, ok := queryOptions["name"].(string); ok && len(v) > 0 {
query.Where("name like ?", fmt.Sprintf("%%%v%%", v))
}
... ...
... ... @@ -279,3 +279,35 @@ func (c *StaffAssessController) ListTargetUserMeSupperAssess() {
data, err := srv.ListTargetUserAssess(paramReq)
c.Response(data, err)
}
//获取周期列表
func (c *StaffAssessController) ListAssessCycle() {
srv := service.NewStaffAssessServeice()
// paramReq := &query.ListTargetUserAssessQuery{}
// 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)
data, err := srv.ListAllAssessCycle(int(userReq.CompanyId))
c.Response(data, err)
}
//获取周期里的考核日期
func (c *StaffAssessController) ListAssessCycleDay() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListAssessCycleDay{}
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.ListAllAssessCycleDay(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -13,6 +13,8 @@ func init() {
web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表
web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述
web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务
web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表
web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期
)
// /v1/staff-assess/self/me/list
assessNS := web.NewNamespace("/v1/staff-assess",
... ...
... ... @@ -37,7 +37,7 @@ func ValidateCommand(commandType interface{}) error {
}
// NextTime 0点时刻为标准计算
func NextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time {
func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time {
year, month, day := start.Date()
// 起始时间0点时刻
start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
... ... @@ -141,7 +141,7 @@ func SubMonth(t1, t2 time.Time) (month int) {
}
// NextTimeInc 0点时刻为标准计算
func NextTimeInc(start *time.Time, kpiCycle int) time.Time {
func NextTimeInc(start time.Time, kpiCycle int) time.Time {
year, month, day := start.Date()
// 起始时间0点时刻
start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
... ...