...
|
...
|
@@ -564,13 +564,13 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
|
}
|
|
|
|
|
|
// 对异常记录的操作标记
|
|
|
func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (map[string]string, error) {
|
|
|
func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
...
|
...
|
@@ -583,10 +583,12 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
|
|
})
|
|
|
_, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"id": param.Id, "companyId": param.CompanyId, "limit": 1})
|
|
|
if err != nil {
|
|
|
return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(anomalyList) == 0 {
|
|
|
return map[string]string{}, nil
|
|
|
return map[string]interface{}{
|
|
|
"have": false,
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
anomalyData := anomalyList[0]
|
...
|
...
|
@@ -603,10 +605,11 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
|
|
}
|
|
|
err = taskAnomalyRepo.Save(anomalyData)
|
|
|
if err != nil {
|
|
|
return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// c :找上级 ,
|
|
|
if !(param.MarkType == "a" || param.MarkType == "b") {
|
|
|
return map[string]string{}, nil
|
|
|
return map[string]interface{}{"have": false}, nil
|
|
|
}
|
|
|
|
|
|
taskId := anomalyData.TaskId
|
...
|
...
|
@@ -618,10 +621,14 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
|
|
"limit": 1,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(taskList) == 0 {
|
|
|
return map[string]string{}, nil
|
|
|
return map[string]interface{}{"have": false}, nil
|
|
|
}
|
|
|
taskData := taskList[0]
|
|
|
if taskData.Leader.Id != int64(param.UserId) {
|
|
|
return map[string]interface{}{}, nil
|
|
|
}
|
|
|
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
// 获取员工的评估
|
...
|
...
|
@@ -629,7 +636,7 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
|
|
|
|
|
_, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
"companyId": param.CompanyId,
|
|
|
"executorId": taskList[0].Leader.Id,
|
|
|
"executorId": taskData.Leader.Id,
|
|
|
"beginDay": today,
|
|
|
"typesList": []string{string(domain.AssessSelf)},
|
|
|
"limit": 1,
|
...
|
...
|
@@ -637,11 +644,34 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
|
|
|
}
|
|
|
_ = assessList
|
|
|
if len(assessList) == 0 {
|
|
|
return map[string]interface{}{
|
|
|
"have": false,
|
|
|
}, nil
|
|
|
}
|
|
|
taskRecordReps := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
_, recordList, err := taskRecordReps.Find(map[string]interface{}{"staffAssessId": assessList[0].Id, "taskId": taskData.Id})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的评估"+err.Error())
|
|
|
}
|
|
|
if len(recordList) == 0 {
|
|
|
result := map[string]interface{}{
|
|
|
"have": true,
|
|
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
"beginDay": today,
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return map[string]string{}, nil
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return map[string]string{}, nil
|
|
|
result := map[string]interface{}{
|
|
|
"have": true,
|
|
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
"beginDay": today,
|
|
|
"taskRecordId": recordList[0].Id,
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 我的下级负责任务,异常列表 数据结构变体
|
...
|
...
|
|