作者 庄敏学

合并分支 'test' 到 'master'

Test



查看合并请求 !10
... ... @@ -185,18 +185,18 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
// 重新计算
if task.NextSentAt == nil {
// 环节起始和截止本地时间
startLocal := task.TimeStart.Local()
endLocal := task.TimeEnd.Local()
startLocal := task.TimeStart
endLocal := task.TimeEnd
// 在当前时间之前,则计算下一个周期时间
if startLocal.Before(now) {
nextTime := utils.NextTime(nowO, startLocal, task.KpiCycle)
task.NextSentAt = &nextTime
} else {
task.NextSentAt = &startLocal
task.NextSentAt = startLocal
}
// 如果超出截至时间,则周期置空
if task.NextSentAt.After(endLocal) {
if task.NextSentAt.After(endLocal.Local()) {
task.NextSentAt = nil
}
} else {
... ... @@ -468,18 +468,18 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
}
// 环节起始和截止本地时间
startLocal := node.TimeStart.Local()
endLocal := node.TimeEnd.Local()
startLocal := node.TimeStart
endLocal := node.TimeEnd
// 在当前时间之前,则计算下一个周期时间
if startLocal.Before(now) {
nextTime := utils.NextTime(nowO, startLocal, node.KpiCycle)
task.NextSentAt = &nextTime
} else {
task.NextSentAt = &startLocal
task.NextSentAt = startLocal
}
// 如果超出截至时间,则周期置空
if task.NextSentAt.After(endLocal) {
if task.NextSentAt.After(endLocal.Local()) {
task.NextSentAt = nil
}
... ...
... ... @@ -87,7 +87,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
maxTime := task.TimeEnd.Local()
// 当前周起始时间和截止时间
var cycleTimeStart = task.NextSentAt.Local()
var cycleTimeStart = task.NextSentAt
var cycleTimeEnd time.Time
// 下个周期起始时间
... ...
... ... @@ -154,13 +154,14 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery)
}
if len(assessInviteData) > 0 {
stepItem.Status = string(domain.StaffAssessCompleted)
} else {
stepItem.Status = string(domain.StaffAssessUncompleted)
}
//待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
if len(assessInviteData) > 5 {
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
} else {
stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
stepItem.Status = string(domain.StaffAssessUncompleted)
}
case domain.LinkNodeAllAssessment:
//我评估别人,被邀请评估
... ... @@ -352,21 +353,7 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
}
nowTime := time.Now()
_, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
"evaluationProjectId": param.EvaluationProjectId,
"beginDay": taskBeginTime.Local().Format("2006-01-02"),
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期同项目已存在的评估任务"+err.Error())
}
var assessTaskData *domain.StaffAssessTask
//更新旧数据或者新建数据
if len(assassessTaskList) > 0 {
assessTaskData = assassessTaskList[0]
assessTaskData.UpdatedAt = nowTime
} else {
//建立新的评估任务
assessTaskData = &domain.StaffAssessTask{
assessTaskData := &domain.StaffAssessTask{
Id: 0,
CompanyId: param.CompanyId,
EvaluationProjectId: param.EvaluationProjectId,
... ... @@ -382,7 +369,6 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
DeletedAt: nil,
BeginDay: taskBeginTime.Local().Format("2006-01-02"),
}
}
executorIds := []int{} //提取评估的参与人id
executorIdMap := map[int]struct{}{} //过滤重复的用户
//从入参中提取参与人
... ... @@ -393,24 +379,8 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
executorIdMap[v] = struct{}{}
executorIds = append(executorIds, v)
}
//就数据中提取参与人
for _, v := range assessTaskData.ExecutorId {
if _, ok := executorIdMap[v]; ok {
continue
}
executorIdMap[v] = struct{}{}
executorIds = append(executorIds, v)
}
//填入新的参与人id
assessTaskData.ExecutorId = executorIds
//填充新的评估环节
loop:
for _, v := range param.StepList {
for _, vv := range assessTaskData.StepList {
if vv.LinkNodeId == v.LinkNodeId {
continue loop
}
}
stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime)
... ... @@ -429,20 +399,45 @@ loop:
}
assessTaskData.StepList = append(assessTaskData.StepList, step)
}
//排序流程环节
stepList := domain.SortTaskStep(assessTaskData.StepList)
sort.Sort(stepList)
assessTaskData.StepList = stepList
//添加员工的节点任务
assessList, err := srv.createStaffAssess(transactionContext, assessTaskData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
}
//合并项目评估的新旧数据
_, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
"evaluationProjectId": param.EvaluationProjectId,
"beginDay": taskBeginTime.Local().Format("2006-01-02"),
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期同项目已存在的评估任务"+err.Error())
}
if len(assassessTaskList) > 0 {
//就数据中提取参与人
for _, v := range assessTaskData.ExecutorId {
if _, ok := executorIdMap[v]; ok {
continue
}
executorIdMap[v] = struct{}{}
executorIds = append(executorIds, v)
}
assassessTaskList[0].UpdatedAt = time.Now()
assassessTaskList[0].ExecutorId = executorIds
//更新步骤
assassessTaskList[0].StepList = append(assassessTaskList[0].StepList, assessTaskData.StepList...)
assessTaskData = assassessTaskList[0]
//排序流程环节
stepList := domain.SortTaskStep(assessTaskData.StepList)
sort.Sort(stepList)
}
_, err = assessTaskRepo.Save(assessTaskData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
}
//保存 员工的评估任务
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ... @@ -453,6 +448,9 @@ loop:
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
}
}
//处理生成的项目评估
return map[string]interface{}{
"assessTaskId": assessTaskData.Id,
}, nil
... ... @@ -460,7 +458,6 @@ loop:
// 添加节点任务
func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) {
selfUserId := []int{} //评估的参与人
userIdMap := map[int]struct{}{} //过滤重复的用户
for _, v := range param.ExecutorId {
... ... @@ -588,44 +585,39 @@ func (srv StaffAssessServeice) createStaffAssessSupper(
userList []*domain.User, userDepartmentMap map[int64][]*domain.Department,
) ([]domain.StaffAssess, error) {
var assessList []domain.StaffAssess
// 获取员工的上级用户
userRepo := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
for _, v := range userList {
departmentList, ok := userDepartmentMap[v.Id]
if !ok {
continue
}
for _, vv2 := range departmentList {
if len(vv2.ChargeUserIds) == 0 {
continue
}
//获取部门的主管
_, chargeUserList, err := userRepo.Find(map[string]interface{}{
"ids": vv2.ChargeUserIds,
"limit": 40,
})
//获取上级
chargeUserList, err := srv.getStaffSuper(transactionContext, *v)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取部门主管信息"+err.Error())
return nil, err
}
for _, vvv3 := range chargeUserList {
assessTemp.TargetDepartment = []domain.StaffDepartment{
{DepartmentId: int(vv2.Id), DepartmentName: vv2.Name},
if len(chargeUserList) == 0 {
continue
}
for _, v2 := range chargeUserList {
assessTemp.TargetUser = domain.StaffDesc{
UserId: int(v.Id),
Account: v.Account,
UserName: v.Name,
}
assessTemp.Executor = domain.StaffDesc{
UserId: int(vvv3.Id),
Account: vvv3.Account,
UserName: vvv3.Name,
UserId: int(v2.Id),
Account: v2.Account,
UserName: v2.Name,
}
assessList = append(assessList, assessTemp)
targetDepartment := []domain.StaffDepartment{}
if departmentList, ok := userDepartmentMap[v.Id]; ok {
for _, department := range departmentList {
targetDepartment = append(targetDepartment, domain.StaffDepartment{
DepartmentId: int(department.Id),
DepartmentName: department.Name,
})
}
}
assessTemp.TargetDepartment = targetDepartment
assessList = append(assessList, assessTemp)
}
}
return assessList, nil
}
... ... @@ -1592,36 +1584,37 @@ func (srv *StaffAssessServeice) getStaffDescrip(transactionContext application.T
log.Logger.Error("获取公司信息," + err.Error())
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error())
}
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// //查找员工的部门
// var departmentList []*domain.Department
// if len(userData.DepartmentId) > 0 {
// }
var supperUserList []*domain.User
if len(userData.DepartmentId) > 0 {
_, departmentList, err := departmentRepo.Find(map[string]interface{}{
"ids": userData.DepartmentId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
}
var chargeUserIds []int64
for _, v := range departmentList {
chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
}
if len(chargeUserIds) > 0 {
_, supperUserList, err = userRepo.Find(map[string]interface{}{
"ids": chargeUserIds,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
}
}
}
// var supperUserList []*domain.User
// if len(userData.DepartmentId) > 0 {
// _, departmentList, err := departmentRepo.Find(map[string]interface{}{
// "ids": userData.DepartmentId,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
// }
// var chargeUserIds []int64
// for _, v := range departmentList {
// chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
// }
// if len(chargeUserIds) > 0 {
// _, supperUserList, err = userRepo.Find(map[string]interface{}{
// "ids": chargeUserIds,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
// }
// }
// }
supperUserList, _ := srv.getStaffSuper(transactionContext, *userData)
userInfo := adapter.StaffInfo{
UserName: userData.Name,
CompanyName: companyData.Name,
... ... @@ -1703,12 +1696,14 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
continue
}
v.Value = item.Value
if len(item.Value) > 0 {
//填入评估值描述
reteResult, err := v.Rule.ScoreOrRating(&v.Value)
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 {
... ... @@ -1719,7 +1714,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
}
}
//保存信息
for i := range assessContentList {
_, err = assessContentRepo.Save(assessContentList[i])
... ... @@ -1774,7 +1768,7 @@ func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserA
}
//获取员工的上级是谁 ,TODO
func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]domain.User, error) {
func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ... @@ -1793,6 +1787,29 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran
}
}
if len(departmemtList) == 0 {
//找不到员工的部门
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
companyData, err := companyRepo.FindOne(map[string]interface{}{
"id": targetUser.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的公司"+err.Error())
}
//公司作为最顶级
departmemtList = append(departmemtList, &domain.Department{
Id: 0,
CompanyId: companyData.Id,
Level: 0,
Name: companyData.Name,
ParentId: 0,
ChargeUserIds: companyData.ChargeUserIds,
Path: "",
CreatedAt: time.Time{},
UpdatedAt: time.Time{},
DeletedAt: &time.Time{},
})
}
//获取部门管理员
... ... @@ -1836,14 +1853,5 @@ loop:
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error())
}
}
if len(chargeUserList) == 0 {
//如果都找不到数据
}
// _, chargeUserList, err := userRepo.Find(map[string]interface{}{
// "ids": chargeUserIds,
// })
return nil, nil
return chargeUserList, nil
}
... ...
... ... @@ -17,11 +17,6 @@ const (
LinkNodeAllAssessment int = 3 // 环节-360°评估
LinkNodeSuperiorAssessment int = 4 // 环节-上级评估
LinkNodeViewResult int = 5 // 环节-绩效结果查看
//LinkNodeAssessment int = 1 // 环节-评估(自评、360°评估、上级评估)
//LinkNodeAllInvite int = 2 // 环节-360°邀请
//LinkNodeViewResult int = 3 // 环节-绩效结果查看
)
type EntryItem struct {
... ... @@ -42,17 +37,7 @@ type NodeContent struct {
EntryItems []*EntryItem `json:"entryItems" comment:"填写项"`
}
//// NodeAllInvite 360°邀请
//type NodeAllInvite struct {
// ParentDifferentIds []string `json:"parentDifferentIds" comment:"不同上级同事ID"`
// ParentSameIds []string `json:"parentSameIds" comment:"相同上级同事ID"`
//}
//// NodeKpiResult 绩效结果查看
//type NodeKpiResult struct {
//}
// 评估流程、环节
// LinkNode 评估流程、环节
type LinkNode struct {
Id int64 `json:"id,string" comment:"环节ID"`
Type int `json:"type" comment:"环节类型"`
... ... @@ -64,7 +49,7 @@ type LinkNode struct {
KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"`
}
// 评估模板
// EvaluationTemplate 评估模板
type EvaluationTemplate struct {
Id int64 `json:"id,string" comment:"ID"`
Name string `json:"name" comment:"名称"`
... ... @@ -78,14 +63,6 @@ type EvaluationTemplate struct {
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
}
//type EvaluationLink struct {
// NodeSelfAssessment *LinkNode `json:"nodeSelfAssessment" comment:"填写反馈自评"`
// NodeAllInvite *LinkNode `json:"nodeAllInvite" comment:"360°邀请"`
// NodeAllAssessment *LinkNode `json:"nodeAllAssessment" comment:"360°评估"`
// NodeSuperiorAssessment *LinkNode `json:"nodeSuperiorAssessment" comment:"上级评估"`
// NodeViewResult *LinkNode `json:"nodeViewResult" comment:"绩效结果查看"`
//}
type EvaluationTemplateRepository interface {
Insert(template *EvaluationTemplate) (*EvaluationTemplate, error)
Remove(template *EvaluationTemplate) (*EvaluationTemplate, error)
... ...
... ... @@ -30,8 +30,8 @@ func (repo *EvaluationCycleRepository) TransformToDomain(m *models.EvaluationCyc
CompanyId: m.CompanyId,
CreatorId: m.CreatorId,
KpiCycle: m.KpiCycle,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
}
}
... ...
... ... @@ -27,8 +27,8 @@ func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.Evalu
TemplateCreatedAt: m.TemplateCreatedAt,
Template: m.Template,
CycleId: m.CycleId,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
}
}
... ...
... ... @@ -36,8 +36,8 @@ func (repo *EvaluationProjectRepository) TransformToDomain(m *models.EvaluationP
Template: m.Template,
BeginTime: m.BeginTime,
EndTime: m.EndTime,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
}
}
... ...
... ... @@ -31,8 +31,8 @@ func (repo *EvaluationRuleRepository) TransformToDomain(m *models.EvaluationRule
SysType: m.SysType,
Rating: m.Rating,
Score: m.Score,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
CreatedAt: m.CreatedAt.Local(), // PG库为UTC需要转成本地时间
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
}
}
... ...
... ... @@ -29,8 +29,8 @@ func (repo *EvaluationTemplateRepository) TransformToDomain(m *models.Evaluation
CreatorId: m.CreatorId,
State: m.State,
LinkNodes: m.LinkNodes,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
}
}
... ...
... ... @@ -21,6 +21,9 @@ 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,
... ... @@ -31,12 +34,12 @@ func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.Nod
NodeName: m.NodeName,
NodeDescribe: m.NodeDescribe,
NodeSort: m.NodeSort,
TimeStart: m.TimeStart,
TimeEnd: m.TimeEnd,
TimeStart: &timeStart,
TimeEnd: &timeEnd,
KpiCycle: m.KpiCycle,
NextSentAt: m.NextSentAt,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
NextSentAt: &nextSentAt,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
}
}
... ...
... ... @@ -27,8 +27,8 @@ func (repo *RoleRepository) TransformToDomain(m *models.Role) domain.Role {
Type: m.Type,
Description: m.Description,
CompanyId: m.CompanyId,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
}
}
... ...
... ... @@ -26,8 +26,8 @@ func (repo *RoleUserRepository) TransformToDomain(m *models.RoleUser) domain.Rol
RoleId: m.RoleId,
UserId: m.UserId,
CompanyId: m.CompanyId,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
}
}
... ...
... ... @@ -39,8 +39,8 @@ func (repo *StaffAssessRepository) TransformToDomain(d *models.StaffAssess) *dom
Status: domain.StaffAssessStatus(d.Status),
BeginTime: d.BeginTime,
EndTime: d.EndTime,
CreatedAt: d.EndTime,
UpdatedAt: d.CreatedAt,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
}
}
... ...
... ... @@ -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)
... ...