作者 庄敏学
正在显示 34 个修改的文件 包含 382 行增加77 行删除
... ... @@ -8,6 +8,7 @@ COPY ./go.mod go.mod
COPY ./go.sum go.sum
COPY ./main.go main.go
COPY ./key key
COPY ./templates templates
RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
ENV GO111MODULE on
ENV GOPROXY https://goproxy.io
... ...
package main
import (
"time"
"github.com/beego/beego/v2/server/web"
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task"
serviceTask "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
_ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer"
"time"
)
func main() {
... ... @@ -17,14 +17,14 @@ func main() {
// for k, v := range methods {
// fmt.Printf("%s => %v \n", k, v)
// }
go consumer.Run()
// go consumer.Run()
web.Run()
}
// 定时任务-间隔发送评估环节
func startNodeTask() {
go func() {
nodeTaskService := service.NewNodeTaskService()
nodeTaskService := serviceTask.NewNodeTaskService()
for {
timer := time.NewTimer(time.Second * 60)
<-timer.C
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"github.com/beego/beego/v2/core/validation"
"unicode/utf8"
)
type CreateCycleCommand struct {
... ... @@ -23,7 +24,7 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) {
validation.SetError("creatorId", "创建人ID无效")
return
}
if len(in.Name) > 40 {
if utf8.RuneCountInString(in.Name) > 40 {
validation.SetError("name", "名称最大长度40个字符")
return
}
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"github.com/beego/beego/v2/core/validation"
"unicode/utf8"
)
type UpdateCycleCommand struct {
... ... @@ -15,7 +16,7 @@ type UpdateCycleCommand struct {
}
func (in *UpdateCycleCommand) Valid(validation *validation.Validation) {
if len(in.Name) > 40 {
if utf8.RuneCountInString(in.Name) > 40 {
validation.SetError("name", "角色名称最大长度40个字符")
return
}
... ...
... ... @@ -328,7 +328,7 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf
}
func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface{}, error) {
transactionContext, err := factory.StartTransaction()
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
}
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"github.com/beego/beego/v2/core/validation"
"unicode/utf8"
)
type CreateProjectCommand struct {
... ... @@ -24,7 +25,7 @@ func (in *CreateProjectCommand) Valid(validation *validation.Validation) {
validation.SetError("creatorId", "创建人ID无效")
return
}
if len(in.Name) > 40 {
if utf8.RuneCountInString(in.Name) > 40 {
validation.SetError("name", "项目名称最大长度40个字符")
return
}
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"github.com/beego/beego/v2/core/validation"
"unicode/utf8"
)
type UpdateProjectCommand struct {
... ... @@ -36,7 +37,7 @@ type CheckRecipientCommand struct {
}
func (in *UpdateProjectCommand) Valid(validation *validation.Validation) {
if len(in.Name) > 40 {
if utf8.RuneCountInString(in.Name) > 40 {
validation.SetError("name", "项目名称最大长度40个字符")
return
}
... ...
... ... @@ -301,7 +301,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in
}
func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (interface{}, error) {
transactionContext, err := factory.StartTransaction()
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
}
... ...
... ... @@ -3,6 +3,7 @@ package command
import (
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"unicode/utf8"
)
type CreateRuleCommand struct {
... ... @@ -25,12 +26,12 @@ func (in *CreateRuleCommand) Valid(validation *validation.Validation) {
return
}
if len(in.Name) > 40 {
if utf8.RuneCountInString(in.Name) > 40 {
validation.SetError("name", "名称最大长度40个字符")
return
}
if len(in.Remark) > 100 {
if utf8.RuneCountInString(in.Remark) > 100 {
validation.SetError("remark", "备注不能超过100个字符")
return
}
... ...
... ... @@ -3,6 +3,7 @@ package command
import (
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"unicode/utf8"
)
type UpdateRuleCommand struct {
... ... @@ -21,12 +22,12 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) {
return
}
if len(in.Name) > 40 {
if utf8.RuneCountInString(in.Name) > 40 {
validation.SetError("name", "名称最大长度40个字符")
return
}
if len(in.Remark) > 100 {
if utf8.RuneCountInString(in.Remark) > 100 {
validation.SetError("remark", "备注不能超过100个字符")
return
}
... ...
... ... @@ -51,6 +51,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac
CompanyId: in.CompanyId,
CreatorId: in.CreatorId,
Type: in.Type,
SysType: domain.EvaluationSysTypeCommon,
Rating: in.Rating,
Score: in.Score,
}
... ... @@ -147,6 +148,10 @@ func (rs *EvaluationRuleService) Remove(in *command.DeleteRuleCommand) (interfac
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if rule.SysType == domain.EvaluationSysTypeSystem {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "系统默认规则不可删除")
}
if _, err := ruleRepository.Remove(rule); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -175,7 +180,7 @@ func (rs *EvaluationRuleService) Remove(in *command.DeleteRuleCommand) (interfac
//}
func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (interface{}, error) {
transactionContext, err := factory.StartTransaction()
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
}
... ... @@ -192,12 +197,31 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i
ras := make([]*adapter.RuleAdapter, 0)
creatorIds := make([]int64, 0)
var havaSystemType = false
for i := range rules {
ra := &adapter.RuleAdapter{}
ra.EvaluationRule = rules[i]
ras = append(ras, ra)
creatorIds = append(creatorIds, rules[i].CreatorId)
if rules[i].SysType == domain.EvaluationSysTypeSystem {
havaSystemType = true
break
}
}
// 如果不存在系统默认就生成一个
if !havaSystemType {
newRule := domain.GenerateSysRule(in.CompanyId)
rule, err := ruleRepository.Insert(newRule)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
ra := &adapter.RuleAdapter{}
ra.EvaluationRule = rule
ras = append(ras, ra)
}
_, users, _ := userRepository.Find(map[string]interface{}{"ids": creatorIds, "limit": len(creatorIds)})
userNameMap := map[int64]string{}
if users != nil {
... ... @@ -214,7 +238,7 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i
}
func (rs *EvaluationRuleService) ListCreator(in *command.QueryCreatorCommand) (interface{}, error) {
transactionContext, err := factory.StartTransaction()
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
}
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"github.com/beego/beego/v2/core/validation"
"unicode/utf8"
)
type CreateTemplateCommand struct {
... ... @@ -21,12 +22,13 @@ func (in *CreateTemplateCommand) Valid(validation *validation.Validation) {
return
}
if len(in.Name) > 40 {
// 这个才是真正计算字符串文字长度的 utf8.RuneCountInString(in.Name)
if utf8.RuneCountInString(in.Name) > 40 {
validation.SetError("name", "模板名称最大长度40个字符")
return
}
if len(in.Describe) > 100 {
if utf8.RuneCountInString(in.Describe) > 100 {
validation.SetError("describe", "备注最大长度100个字符")
return
}
... ...
... ... @@ -20,15 +20,15 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) {
return
}
if len(in.Name) > 40 {
validation.SetError("name", "模板名称最大长度40个字符")
return
}
if len(in.Describe) > 100 {
validation.SetError("describe", "备注最大长度100个字符")
return
}
//if len(in.Name) > 40 {
// validation.SetError("name", "模板名称最大长度40个字符")
// return
//}
//
//if len(in.Describe) > 100 {
// validation.SetError("describe", "备注最大长度100个字符")
// return
//}
if len(in.LinkNodes) == 0 {
validation.SetError("linkNodes", "评估模板流程不能为空")
... ...
... ... @@ -186,7 +186,7 @@ func (rs *EvaluationTemplateService) Remove(in *command.DeleteTemplateCommand) (
}
func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (interface{}, error) {
transactionContext, err := factory.StartTransaction()
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
}
... ...
package command
import "github.com/beego/beego/v2/core/validation"
import (
"github.com/beego/beego/v2/core/validation"
"unicode/utf8"
)
type CreateRoleCommand struct {
CompanyId int64 `cname:"公司ID" json:"companyId"`
... ... @@ -14,7 +17,7 @@ func (in *CreateRoleCommand) Valid(validation *validation.Validation) {
return
}
if len(in.Name) > 30 {
if utf8.RuneCountInString(in.Name) > 30 {
validation.SetError("name", "角色名称最大长度30个字符")
return
}
... ...
package command
import "github.com/beego/beego/v2/core/validation"
import (
"github.com/beego/beego/v2/core/validation"
"unicode/utf8"
)
type UpdateRoleCommand struct {
CompanyId int64 `cname:"公司ID" json:"companyId"`
... ... @@ -14,7 +17,7 @@ func (in *UpdateRoleCommand) Valid(validation *validation.Validation) {
validation.SetError("companyId", "公司ID无效")
}
if len(in.Name) > 30 {
if utf8.RuneCountInString(in.Name) > 30 {
validation.SetError("name", "角色名称最大长度30个字符")
return
}
... ...
... ... @@ -141,7 +141,7 @@ func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error
}
func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) {
transactionContext, err := factory.StartTransaction()
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
}
... ...
... ... @@ -95,7 +95,7 @@ func (rs *RoleUserService) Remove(in *command.UserRoleDeleteCommand) (interface{
}
func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface{}, error) {
transactionContext, err := factory.StartTransaction()
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
}
... ...
... ... @@ -5,22 +5,22 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
//评估内容详情
type AssessInfoResp struct {
AssessId int `json:"assessId"`
CycleId int64 `json:"cycleId"` //周期id
CycleId int64 `json:"cycleId,string"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
LinkNodeId int `json:"linkNodeId"`
LinkNodeId int `json:"linkNodeId,string"`
LinkNodeName string `json:"linkNodeName"`
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
Status string `json:"status"` //完成状态
TargetUserId int `json:"targetUser"` //目标用户
TargetUserName string `json:"targetUserName"` //目标用户名称
CompanyId int `json:"companyId,string,"` //
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间 //
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
Status string `json:"status"` //完成状态
TargetUserId int `json:"targetUserId,string"` //目标用户
TargetUserName string `json:"targetUserName"` //目标用户名称
CompanyId int `json:"companyId,string,"` //
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间 //
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
}
type AssessContent struct {
... ...
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 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
StepList []AssessTaskStep `json:"stepList"` // 考评流程
AssessTaskId int `json:"assessTaskId"` //
EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
CycleName string `json:"cycleName"` //周期名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
StepList []AssessTaskStep `json:"stepList"` // 考评流程
}
type AssessTaskStep struct {
... ...
... ... @@ -2,7 +2,7 @@ package adapter
type ListSupperAssessResp struct {
AssessId int `json:"assessId"` //
UsrId int `json:"userId"`
UsrId int `json:"userId,string"`
UserName string `json:"userName"` //用户名称
EndTime string `json:"endTime"` //截止时间
InviteTotal int `json:"inviteTota"` //邀请总数
... ...
... ... @@ -2,8 +2,8 @@ package query
//获取员工自评填写详情
type AssessSelfInfoQuery struct {
AssessTaskId int `json:"assessTaskId"` //assessTaskId 的id
TargetUserId int `json:"targetUserId"` //被评估的人id
CompanyId int `json:"companyId"` //公司id
AssessTaskId int `json:"assessTaskId"` //assessTaskId 的id
TargetUserId int `json:"targetUserId,string"` //被评估的人id
CompanyId int `json:"companyId"` //公司id
}
... ...
... ... @@ -3,7 +3,7 @@ package query
//获取员工 被评估的列表
type ListTargetUserAssessQuery struct {
AssessTaskId int `json:"assessTaskId"`
TargetUserId int `json:"targetUserId"`
TargetUserId int `json:"targetUserId,string"`
CompanyId int `json:"companyId"`
Types []string `json:"tyspes"`
}
... ...
... ... @@ -164,10 +164,12 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
if len(assessInviteData) > 0 {
stepItem.Status = string(domain.StaffAssessCompleted)
}
//待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
if len(assessInviteData) > 5 {
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
stepItem.Status = string(domain.StaffAssessCompleted)
} else {
stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
stepItem.Status = string(domain.StaffAssessUncompleted)
... ... @@ -345,7 +347,7 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery)
// 根据项目评估的配置,创建员工的评估任务
func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext application.TransactionContext, param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
// transactionContext, err := factory.CreateTransactionContext(nil)
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
... ... @@ -1300,6 +1302,19 @@ func (srv StaffAssessServeice) ListExecutorInviteAssess(param *query.ListInviteU
"endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
"assessId": strconv.Itoa(v.Id),
}
switch v.Status {
case domain.StaffAssessCompleted:
m["status"] = "已经完成"
case domain.StaffAssessUncompleted:
m["status"] = "未完成"
}
switch v.Types {
case domain.AssessInviteDiffSuper:
m["typs"] = "不同上级同事"
case domain.AssessInviteSameSuper:
m["types"] = "相同上级同事"
}
if row, ok := changeableRows[v.TargetUser.UserId]; ok {
for k, v := range row {
m[k] = v
... ... @@ -1405,7 +1420,25 @@ func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperA
log.Logger.Error("获取员工邀请的人完成情况" + err.Error())
}
}
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{
"id": param.AssessTaskId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())
}
//我评估别人,被邀请评估
cnnt, _, err := assessRepo.Find(map[string]interface{}{
"staffAssessTaskId": param.AssessTaskId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessSuper)},
"status": string(domain.StaffAssessUncompleted),
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -1450,7 +1483,18 @@ func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperA
}
resultList = append(resultList, item)
}
return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList)
result["linkNodeName"] = ""
result["linkNodeId"] = ""
result["lintNodeDesc"] = ""
for _, v := range assessTaskData.StepList {
if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {
result["linkNodeName"] = v.LinkNodeName
result["linkNodeId"] = fmt.Sprintf("%d", v.LinkNodeId)
result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
}
}
return result, nil
}
// 根据staffAssessId 获取评估的填写信息
... ... @@ -1665,6 +1709,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
}
}
}
//保存信息
for i := range assessContentList {
_, err = assessContentRepo.Save(assessContentList[i])
... ... @@ -1672,6 +1717,12 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估填写内容"+err.Error())
}
}
assessData.Status = domain.StaffAssessCompleted
assessData.UpdatedAt = time.Now()
_, err = assessReps.Save(assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -1700,6 +1751,7 @@ func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserA
"assessTaskId": param.AssessTaskId,
"companyId": param.CompanyId,
"targetUserId": param.TargetUserId,
"typesList": param.Types,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
... ...
... ... @@ -9,6 +9,11 @@ const (
EvaluationTypeScore int = 1 // 评估方式-评分
)
const (
EvaluationSysTypeCommon int = 0 // 系统类型-系统添加
EvaluationSysTypeSystem int = 1 // 系统类型-系统预制(不可删除、编辑)
)
type Rating struct {
Levels []*RatingLevel `json:"levels" comment:"配置等级"`
}
... ... @@ -42,6 +47,7 @@ type EvaluationRule struct {
CompanyId int64 `json:"companyId,string" comment:"公司ID"`
CreatorId int64 `json:"creatorId,string" comment:"创建人ID"`
Type int `json:"type" comment:"评估方式(0评级、1评分)"`
SysType int `json:"sysType" comment:"系统类型(0普通、1系统固定)" pg:",use_zero"`
Rating Rating `json:"rating" comment:"评级"`
Score Score `json:"score" comment:"评分"`
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
... ... @@ -49,6 +55,58 @@ type EvaluationRule struct {
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
}
// GenerateSysRule 当前公司下的生成默认规则
func GenerateSysRule(companyId int64) *EvaluationRule {
levels := make([]*RatingLevel, 0)
levels = append(levels, &RatingLevel{
Code: "S",
Name: "SS",
Color: 1,
QuantizedValue: 90,
})
levels = append(levels, &RatingLevel{
Code: "A",
Name: "AA",
Color: 2,
QuantizedValue: 80,
})
levels = append(levels, &RatingLevel{
Code: "B",
Name: "BB",
Color: 3,
QuantizedValue: 70,
})
levels = append(levels, &RatingLevel{
Code: "C",
Name: "CC",
Color: 4,
QuantizedValue: 60,
})
levels = append(levels, &RatingLevel{
Code: "D",
Name: "DD",
Color: 5,
QuantizedValue: 50,
})
newRule := &EvaluationRule{
Id: 0,
Name: "评级(默认)",
Remark: "",
CompanyId: companyId,
CreatorId: 0,
Type: EvaluationTypeRating,
SysType: EvaluationSysTypeSystem,
Rating: Rating{
Levels: levels,
},
Score: Score{},
}
return newRule
}
type EvaluationRuleRepository interface {
Insert(rule *EvaluationRule) (*EvaluationRule, error)
Remove(rule *EvaluationRule) (*EvaluationRule, error)
... ...
... ... @@ -40,7 +40,7 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask
WHERE staff_assess.target_user->>'userId' IN(?)
AND staff_assess.types IN ('invite_same_super','invite_diff_super')
AND staff_assess.staff_assess_task_id = ?
GROUP BY userId`
GROUP BY target_user_id`
userIdList := []string{}
for _, v := range userIds {
... ...
... ... @@ -13,6 +13,7 @@ type EvaluationRule struct {
CompanyId int64 `comment:"公司ID"`
CreatorId int64 `comment:"创建人ID"`
Type int `comment:"评估方式(0评级、1评分)" pg:",use_zero"`
SysType int `comment:"系统类型(0普通、1系统固定)" pg:",use_zero"`
Rating domain.Rating `comment:"评级"`
Score domain.Score `comment:"评分"`
CreatedAt time.Time `comment:"创建时间"`
... ...
... ... @@ -28,6 +28,7 @@ func (repo *EvaluationRuleRepository) TransformToDomain(m *models.EvaluationRule
CompanyId: m.CompanyId,
CreatorId: m.CreatorId,
Type: m.Type,
SysType: m.SysType,
Rating: m.Rating,
Score: m.Score,
CreatedAt: m.CreatedAt,
... ... @@ -44,6 +45,7 @@ func (repo *EvaluationRuleRepository) TransformToModel(d *domain.EvaluationRule)
CompanyId: d.CompanyId,
CreatorId: d.CreatorId,
Type: d.Type,
SysType: d.SysType,
Rating: d.Rating,
Score: d.Score,
CreatedAt: d.CreatedAt,
... ... @@ -143,6 +145,10 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{})
query.Where("type = ?", v)
}
if v, ok := queryOptions["sysType"]; ok && v.(int) >= 0 {
query.Where("sys_type = ?", v)
}
if v, ok := queryOptions["limit"].(int64); ok {
query.Limit(int(v))
}
... ...
... ... @@ -2,9 +2,14 @@ package controllers
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"github.com/linmadan/egglib-go/web/beego"
"github.com/xuri/excelize/v2"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
"strconv"
"strings"
)
type ImportController struct {
... ... @@ -37,8 +42,82 @@ func (controller *ImportController) Import() {
switch formType {
case "PerformanceDimension":
dimensions, _ := domain.LoadPerformanceDimensions(rows)
controller.Response(dimensions, nil)
list := controller.parseTemplateNodeContent(dimensions)
controller.Response(tool_funs.SimpleWrapGridMap(int64(len(list)), list), nil)
default:
controller.Response(nil, application.ThrowError(application.ARG_ERROR, "请确认您导入的表单类型"))
}
}
func (controller *ImportController) parseTemplateNodeContent(data []*domain.PerformanceDimension) []*domain.NodeContent {
nodeContents := make([]*domain.NodeContent, 0)
transactionContext, err := factory.StartTransaction()
if err != nil {
return nodeContents
}
defer func() {
transactionContext.RollbackTransaction()
}()
// 获取当前公司下的默认规则
ua := middlewares.GetUser(controller.Ctx)
ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext})
_, rules, err := ruleRepository.Find(map[string]interface{}{"companyId": ua.CompanyId, "sysType": domain.EvaluationSysTypeSystem, "limit": 1})
if err != nil {
return nodeContents
}
var ruleId = int64(0)
if len(rules) == 0 {
newRule := domain.GenerateSysRule(ua.CompanyId) // 生成一个系统默认规则
if rule, err := ruleRepository.Insert(newRule); err != nil {
return nodeContents
} else {
ruleId = rule.Id
}
if err := transactionContext.CommitTransaction(); err != nil {
return nodeContents
}
} else {
ruleId = rules[0].Id
}
for i := range data {
dimension := data[i]
for i2 := range dimension.PerformanceModule {
nc := &domain.NodeContent{}
nc.Category = dimension.Name // 类别
module := dimension.PerformanceModule[i2]
nc.Name = module.ModuleName // 名称
nc.RuleId = ruleId // 规则ID
sIndex := strings.Index(module.Weight, "%") // 权重
if sIndex != -1 {
iWeight, _ := strconv.Atoi(module.Weight[:sIndex])
nc.Weight = iWeight
} else {
nc.Weight = 0
}
nc.PromptTitle = "" // 提示项标题
nc.PromptText = module.Standard // 提示项内容
nc.EntryItems = make([]*domain.EntryItem, 0) // 输入项
for i3 := range module.Target {
target := module.Target[i3]
nc.EntryItems = append(nc.EntryItems, &domain.EntryItem{
Title: target.Task, // 输入型标题
HintText: "", // 输入项提示文本
})
}
// 没有任何输入项时,默认1个
if len(nc.EntryItems) == 0 {
nc.EntryItems = append(nc.EntryItems, &domain.EntryItem{
Title: "填写反馈",
HintText: "",
})
}
nodeContents = append(nodeContents, nc)
}
}
return nodeContents
}
... ...
... ... @@ -115,7 +115,7 @@ func (c *StaffAssessController) GetAssessMeInviteUser() {
c.Response(data, err)
}
// 保我邀请的员工
// 保我邀请的员工
func (c *StaffAssessController) SaveAssessMeInviteUser() {
srv := service.NewStaffAssessServeice()
paramReq := &command.SaveAssessInvite{}
... ... @@ -128,6 +128,8 @@ func (c *StaffAssessController) SaveAssessMeInviteUser() {
//TODO 获取当前用户信息
// paramReq.CompanyId = 1
// paramReq.UserId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.SaveAssessInviteUser(paramReq)
c.Response(data, err)
}
... ... @@ -256,3 +258,21 @@ func (c *StaffAssessController) ListTargetUserInviteAssess() {
data, err := srv.ListTargetUserAssess(paramReq)
c.Response(data, err)
}
func (c *StaffAssessController) ListTargetUserMeSupperAssess() {
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
}
// paramReq.CompanyId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.Types = []string{string(domain.AssessSuper)}
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.ListTargetUserAssess(paramReq)
c.Response(data, err)
}
... ...
package controllers
import (
"io/ioutil"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/web/beego"
)
type TemplateImplController struct {
beego.BaseController
}
func (controller *TemplateImplController) TemplateQuestion() {
fileBytes, err := ioutil.ReadFile("./templates/tpl_template_question.xlsx")
if err != nil {
controller.Response(nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未读取到模板文件"))
return
}
controller.WriteExcel(fileBytes, "评估导入模板.xlsx")
}
func (controller *TemplateImplController) WriteExcel(fileBytes []byte, fileName string) {
controller.Ctx.Output.Header("Content-Disposition", "attachment;filename="+fileName)
controller.Ctx.Output.Header("Content-Description", "FileTransfer")
controller.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
controller.Ctx.Output.Header("Content-Transfer-Encoding", "binary")
controller.Ctx.Output.Header("Expires", "0")
_, _ = controller.Ctx.ResponseWriter.Write(fileBytes)
}
func (controller *TemplateImplController) WriteBinary(fileBytes []byte, fileName string) {
controller.Ctx.Output.Header("Content-Disposition", "attachment;filename="+fileName)
controller.Ctx.Output.Header("Content-Description", "FileTransfer")
controller.Ctx.Output.Header("Content-Type", "application/octet-stream")
controller.Ctx.Output.Header("Content-Transfer-Encoding", "binary")
controller.Ctx.Output.Header("Expires", "0")
_, _ = controller.Ctx.ResponseWriter.Write(fileBytes)
}
... ...
... ... @@ -17,17 +17,18 @@ func init() {
// /v1/staff-assess/self/me/list
assessNS := web.NewNamespace("/v1/staff-assess",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情
web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessMeInviteUser), //获取邀请的员工
web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工
web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工
web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表
web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表
web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情
web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情
web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工评估的详情
web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情
web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessMeInviteUser), //获取邀请的员工
web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工
web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工
web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表
web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表
web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情
web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情
web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表
web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我的上级评估的列表
web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
)
web.AddNamespace(assessTaskNS)
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"
)
func init() {
web.Router("/templates/tpl_template_question.xlsx", &controllers.TemplateImplController{}, "Get:TemplateQuestion")
}
... ...
不能预览此文件类型