...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils/xtime"
|
|
|
)
|
|
|
|
|
|
// TODO 检查任务里程碑反馈, 记录异常情况
|
...
|
...
|
@@ -33,39 +34,47 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { |
|
|
return nil
|
|
|
}
|
|
|
taskData := taskDataList[0]
|
|
|
|
|
|
//userDao := dao.NewUserDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
// 反馈异常,里程碑异常, 辅导异常
|
|
|
// 检查反馈异常
|
|
|
if param.IsRemarkAnomaly() {
|
|
|
taskData.Anomaly += 1
|
|
|
// err = isAssessFlag(transactionContext, taskData)
|
|
|
// if err != nil {
|
|
|
// return err
|
|
|
// }
|
|
|
err = isAssessFlag(transactionContext, taskData, param)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
} else {
|
|
|
taskData.Anomaly = 0
|
|
|
err = isNotAssessFlag(transactionContext, taskData, param)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
// 检查里程碑异常
|
|
|
if param.IsTaskStageAnomaly() {
|
|
|
taskData.WarnFlag = domain.TaskWarn
|
|
|
err := isWarnFlag(transactionContext, taskData)
|
|
|
err := isWarnFlag(transactionContext, taskData, param)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
} else {
|
|
|
} else if param.TaskStageCheck.Id > 0 {
|
|
|
taskData.WarnFlag = domain.TaskWarnNull
|
|
|
err := isNotWarnFlag(transactionContext, taskData, param)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
// 检查辅导异常
|
|
|
if param.IsAssistAnomaly() {
|
|
|
taskData.AssistFlag += 1
|
|
|
err = isAssistFlag(transactionContext, taskData)
|
|
|
err = isAssistFlag(transactionContext, taskData, param)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
} else {
|
|
|
taskData.AssistFlag = 0
|
|
|
err = isNotAssistFlag(transactionContext, taskData, param)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
// 保存任务数据
|
|
|
err = taskRepo.Save(taskData)
|
...
|
...
|
@@ -79,8 +88,31 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 取消里程碑异常
|
|
|
func isNotWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
"isLast": 1,
|
|
|
"category": 2,
|
|
|
"limit": 1,
|
|
|
"taskId": taskData.Id,
|
|
|
"taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskRecord.TaskStageCheck.Id),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("查询里程碑异常的数据:%s", err)
|
|
|
}
|
|
|
if len(oldAnomaly) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
oldAnomaly[0].IsLast = 2
|
|
|
err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
return fmt.Errorf("取消里程碑异常:%s", err)
|
|
|
}
|
|
|
|
|
|
// 处理里程碑异常的情况
|
|
|
func isWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task) error {
|
|
|
func isWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
...
|
...
|
@@ -88,39 +120,146 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom |
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
"isLast": 1,
|
|
|
"category": 2,
|
|
|
"limit": 1,
|
|
|
"taskId": taskData.Id,
|
|
|
"taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskRecord.TaskStageCheck.Id),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("查询里程碑异常的数据:%s", err)
|
|
|
}
|
|
|
|
|
|
anomalyDataTmp := domain.TaskAnomaly{
|
|
|
Id: taskData.Id,
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
CompanyId: taskData.CompanyId,
|
|
|
TaskId: taskData.Id,
|
|
|
TaskRecordId: taskRecord.Id,
|
|
|
Category: 1,
|
|
|
CurrentStage: taskData.CurrentStage,
|
|
|
LastStage: taskData.LastStage,
|
|
|
TaskStageCheck: taskRecord.TaskStageCheck,
|
|
|
AssessFlag: 0,
|
|
|
WarnFlag: int(taskData.WarnFlag),
|
|
|
AssistFlag: 0,
|
|
|
IsLast: 1,
|
|
|
TaskLevel: taskData.LevelName,
|
|
|
TaskName: taskData.Name,
|
|
|
TaskAlias: taskData.Alias,
|
|
|
TaskSortBy: taskData.SortBy,
|
|
|
TaskEndTime: taskData.EndTime,
|
|
|
RecordBegin: taskRecord.CreatedAt.Unix(),
|
|
|
NoticeWho: []map[string]string{},
|
|
|
Marks: map[string]string{
|
|
|
"a": "", "b": "", "c": "", "d": "",
|
|
|
},
|
|
|
}
|
|
|
if len(oldAnomaly) > 0 {
|
|
|
anomalyDataTmp.WarnFlag = oldAnomaly[0].WarnFlag + 1
|
|
|
anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
|
|
oldAnomaly[0].IsLast = 2
|
|
|
err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("更新里程碑异常记录:%s", err)
|
|
|
}
|
|
|
}
|
|
|
// 异常就通知自己和上级
|
|
|
//获取任务Leader的数据
|
|
|
_, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
}
|
|
|
if len(useList) == 0 {
|
|
|
var userParentId int64
|
|
|
if len(useList) > 0 {
|
|
|
anomalyDataTmp.SetNoticeWho(useList[0])
|
|
|
userParentId = useList[0].ParentId
|
|
|
}
|
|
|
|
|
|
if userParentId > 0 {
|
|
|
// 获取上级用户的数据
|
|
|
_, useList2, err := userRepo.Find(map[string]interface{}{"id": userParentId, "limit": 1})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("获取任务Leader的上级:%s", err)
|
|
|
}
|
|
|
if len(useList2) > 0 {
|
|
|
anomalyDataTmp.SetNoticeWho(useList2[0])
|
|
|
}
|
|
|
}
|
|
|
err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("保存里程碑异常记录:%s", err)
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 取消辅导异常的情况
|
|
|
func isNotAssistFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
"isLast": 1,
|
|
|
"category": 3,
|
|
|
"limit": 1,
|
|
|
"taskId": taskData.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("查询辅导异常的数据:%s", err)
|
|
|
}
|
|
|
if len(oldAnomaly) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{"isLast": 1, "category": 2, "limit": 1})
|
|
|
oldAnomaly[0].IsLast = 2
|
|
|
err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
return fmt.Errorf("取消辅导异常:%s", err)
|
|
|
}
|
|
|
|
|
|
// 处理辅导异常的情况
|
|
|
func isAssistFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
"isLast": 1,
|
|
|
"category": 3,
|
|
|
"limit": 1,
|
|
|
"taskId": taskData.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("查询反馈异常的数据:%s", err)
|
|
|
return fmt.Errorf("查询辅导异常的数据:%s", err)
|
|
|
}
|
|
|
// 异常就通知自己和上级
|
|
|
// 辅导异常通知该条任务负责人的上级;辅导异常超过N天,通知任务负责人的上上级
|
|
|
anomalyDataTmp := domain.TaskAnomaly{
|
|
|
Id: taskData.Id,
|
|
|
CreatedAt: taskData.CreatedAt,
|
|
|
UpdatedAt: taskData.UpdatedAt,
|
|
|
CompanyId: taskData.CompanyId,
|
|
|
TaskId: taskData.Id,
|
|
|
Category: 1,
|
|
|
CurrentStage: taskData.CurrentStage,
|
|
|
LastStage: taskData.LastStage,
|
|
|
AssessFlag: 0,
|
|
|
WarnFlag: int(taskData.WarnFlag),
|
|
|
AssistFlag: 0,
|
|
|
IsLast: 1,
|
|
|
TaskLevel: taskData.LevelName,
|
|
|
TaskName: taskData.Name,
|
|
|
TaskAlias: taskData.Alias,
|
|
|
TaskSortBy: taskData.SortBy,
|
|
|
TaskEndTime: taskData.EndTime,
|
|
|
RecordBegin: time.Now().Unix(),
|
|
|
NoticeWho: []int64{taskData.Leader.Id, useList[0].ParentId},
|
|
|
Id: taskData.Id,
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
CompanyId: taskData.CompanyId,
|
|
|
TaskId: taskData.Id,
|
|
|
Category: 3,
|
|
|
CurrentStage: taskData.CurrentStage,
|
|
|
LastStage: taskData.LastStage,
|
|
|
TaskStageCheck: taskRecord.TaskStageCheck,
|
|
|
AssessFlag: 0,
|
|
|
WarnFlag: 0,
|
|
|
AssistFlag: taskData.AssistFlag,
|
|
|
IsLast: 1,
|
|
|
TaskLevel: taskData.LevelName,
|
|
|
TaskName: taskData.Name,
|
|
|
TaskAlias: taskData.Alias,
|
|
|
TaskSortBy: taskData.SortBy,
|
|
|
TaskEndTime: taskData.EndTime,
|
|
|
RecordBegin: taskRecord.CreatedAt.Unix(),
|
|
|
NoticeWho: []map[string]string{},
|
|
|
Marks: map[string]string{
|
|
|
"a": "", "b": "", "c": "", "d": "",
|
|
|
},
|
...
|
...
|
@@ -128,76 +267,119 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom |
|
|
|
|
|
if len(oldAnomaly) > 0 {
|
|
|
anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
|
|
anomalyDataTmp.WarnFlag = oldAnomaly[0].WarnFlag + 1
|
|
|
oldAnomaly[0].IsLast = 2
|
|
|
err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("更新里程碑异常记录:%s", err)
|
|
|
}
|
|
|
}
|
|
|
//获取任务Leader的数据
|
|
|
_, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
}
|
|
|
var userParentId int64
|
|
|
if len(useList) > 0 {
|
|
|
userParentId = useList[0].ParentId
|
|
|
}
|
|
|
if userParentId > 0 {
|
|
|
//通知任务负责人的上级
|
|
|
_, useList2, err := userRepo.Find(map[string]interface{}{"id": userParentId, "limit": 1})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
}
|
|
|
var userParentId2 int64
|
|
|
if len(useList2) > 0 {
|
|
|
anomalyDataTmp.SetNoticeWho(useList2[0])
|
|
|
userParentId2 = useList2[0].ParentId
|
|
|
}
|
|
|
// 辅导异常超过N天,通知任务负责人的上上级
|
|
|
if taskData.AssistFlag >= taskData.AssistFlagMax && userParentId2 > 0 {
|
|
|
_, useList3, err := userRepo.Find(map[string]interface{}{"id": userParentId, "limit": 1})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
}
|
|
|
if len(useList3) > 0 {
|
|
|
anomalyDataTmp.SetNoticeWho(useList3[0])
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("保存里程碑异常记录:%s", err)
|
|
|
}
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
// 处理辅导异常的情况
|
|
|
func isAssistFlag(transactionContext application.TransactionContext, taskData *domain.Task) error {
|
|
|
// 取消反馈异常的情况
|
|
|
func isNotAssessFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
"isLast": 1,
|
|
|
"category": 3,
|
|
|
"limit": 1,
|
|
|
"taskId": taskData.Id,
|
|
|
})
|
|
|
//获取任务Leader的数据
|
|
|
_, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
return fmt.Errorf("查询辅导异常的数据:%s", err)
|
|
|
}
|
|
|
if len(useList) == 0 {
|
|
|
if len(oldAnomaly) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{"isLast": 1, "category": 3, "limit": 1})
|
|
|
oldAnomaly[0].IsLast = 2
|
|
|
err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
return fmt.Errorf("取消辅导异常:%s", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
// 处理反馈异常的情况
|
|
|
func isAssessFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
"isLast": 1,
|
|
|
"category": 2,
|
|
|
"limit": 1,
|
|
|
"taskId": taskData.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("查询反馈异常的数据:%s", err)
|
|
|
}
|
|
|
// 辅导异常通知该条任务负责人的上级;辅导异常超过3天,通知任务负责人的上上级
|
|
|
//
|
|
|
anomalyDataTmp := domain.TaskAnomaly{
|
|
|
Id: taskData.Id,
|
|
|
CreatedAt: taskData.CreatedAt,
|
|
|
UpdatedAt: taskData.UpdatedAt,
|
|
|
CompanyId: taskData.CompanyId,
|
|
|
TaskId: taskData.Id,
|
|
|
Category: 3,
|
|
|
CurrentStage: taskData.CurrentStage,
|
|
|
LastStage: taskData.LastStage,
|
|
|
AssessFlag: 0,
|
|
|
WarnFlag: 0,
|
|
|
AssistFlag: taskData.AssistFlag,
|
|
|
IsLast: 1,
|
|
|
TaskLevel: taskData.LevelName,
|
|
|
TaskName: taskData.Name,
|
|
|
TaskAlias: taskData.Alias,
|
|
|
TaskSortBy: taskData.SortBy,
|
|
|
TaskEndTime: taskData.EndTime,
|
|
|
RecordBegin: time.Now().Unix(),
|
|
|
NoticeWho: []int64{useList[0].ParentId},
|
|
|
Id: taskData.Id,
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
CompanyId: taskData.CompanyId,
|
|
|
TaskId: taskData.Id,
|
|
|
Category: 3,
|
|
|
CurrentStage: taskData.CurrentStage,
|
|
|
LastStage: taskData.LastStage,
|
|
|
TaskStageCheck: taskRecord.TaskStageCheck,
|
|
|
AssessFlag: taskData.Anomaly,
|
|
|
WarnFlag: 0,
|
|
|
AssistFlag: 0,
|
|
|
IsLast: 1,
|
|
|
TaskLevel: taskData.LevelName,
|
|
|
TaskName: taskData.Name,
|
|
|
TaskAlias: taskData.Alias,
|
|
|
TaskSortBy: taskData.SortBy,
|
|
|
TaskEndTime: taskData.EndTime,
|
|
|
RecordBegin: taskRecord.CreatedAt.Unix(),
|
|
|
NoticeWho: []map[string]string{},
|
|
|
Marks: map[string]string{
|
|
|
"a": "", "b": "", "c": "", "d": "",
|
|
|
},
|
|
|
}
|
|
|
if taskData.AssistFlag >= taskData.AssistFlagMax {
|
|
|
//通知任务负责人的上上级
|
|
|
_, useList2, err := userRepo.Find(map[string]interface{}{"id": useList[0].ParentId, "limit": 1})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
}
|
|
|
if len(useList2) > 0 {
|
|
|
anomalyDataTmp.NoticeWho = append(anomalyDataTmp.NoticeWho, useList2[0].Id)
|
|
|
}
|
|
|
}
|
|
|
if len(oldAnomaly) > 0 {
|
|
|
anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
|
|
oldAnomaly[0].IsLast = 2
|
...
|
...
|
@@ -206,6 +388,27 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d |
|
|
return fmt.Errorf("更新里程碑异常记录:%s", err)
|
|
|
}
|
|
|
}
|
|
|
// 2天未反馈通知被评估人自己;3天通知上级
|
|
|
// 获取任务Leader的数据
|
|
|
_, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
}
|
|
|
var userParentId int64
|
|
|
if len(useList) > 0 {
|
|
|
anomalyDataTmp.SetNoticeWho(useList[0])
|
|
|
userParentId = useList[0].ParentId
|
|
|
}
|
|
|
anomalyDay := xtime.SubDayAbs(time.Now(), time.Unix(anomalyDataTmp.RecordBegin, 0))
|
|
|
if anomalyDay > 3 && userParentId > 0 {
|
|
|
_, useList2, err := userRepo.Find(map[string]interface{}{"id": userParentId, "limit": 1})
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
}
|
|
|
if len(useList2) > 0 {
|
|
|
anomalyDataTmp.SetNoticeWho(useList2[0])
|
|
|
}
|
|
|
}
|
|
|
err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("保存里程碑异常记录:%s", err)
|
...
|
...
|
@@ -213,8 +416,3 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d |
|
|
return nil
|
|
|
|
|
|
} |
|
|
|
|
|
// 处理反馈异常的情况
|
|
|
func isAssessFlag(transactionContext application.TransactionContext, taskData *domain.Task) error {
|
|
|
return nil
|
|
|
} |
...
|
...
|
|