...
|
...
|
@@ -612,18 +612,6 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
|
|
if err != nil {
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// c :找上级 ,
|
|
|
if !(param.MarkType == "a" || param.MarkType == "b") {
|
|
|
rst := map[string]interface{}{
|
|
|
"have": false,
|
|
|
"cycleId": "0",
|
|
|
"beginDay": "",
|
|
|
"taskRecordId": "0",
|
|
|
"userId": "0",
|
|
|
}
|
|
|
return rst, nil
|
|
|
}
|
|
|
|
|
|
taskId := anomalyData.TaskId
|
|
|
|
|
|
// 检查是否有任务相关连的最新每日评估
|
...
|
...
|
@@ -639,13 +627,9 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
|
|
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})
|
|
|
// 获取员工的评估
|
|
|
today := time.Now().Format("2006-01-02")
|
|
|
|
|
|
_, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
"companyId": param.CompanyId,
|
|
|
"executorId": taskData.Leader.Id,
|
...
|
...
|
@@ -656,45 +640,62 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
|
|
|
}
|
|
|
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": false,
|
|
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
"beginDay": today,
|
|
|
"taskRecordId": "0",
|
|
|
"userId": strconv.Itoa(assessList[0].Executor.UserId),
|
|
|
|
|
|
var taskRecordId int
|
|
|
var cycleId int
|
|
|
var executorId int
|
|
|
if len(assessList) > 0 {
|
|
|
_, 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())
|
|
|
}
|
|
|
return result, nil
|
|
|
if len(recordList) > 0 {
|
|
|
taskRecordId = recordList[0].Id
|
|
|
}
|
|
|
|
|
|
cycleId = int(assessList[0].CycleId)
|
|
|
executorId = assessList[0].Executor.UserId
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if assessList[0].Executor.UserId != param.UserId {
|
|
|
result := map[string]interface{}{
|
|
|
"have": false,
|
|
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
"beginDay": today,
|
|
|
"taskRecordId": strconv.Itoa(recordList[0].Id),
|
|
|
"userId": strconv.Itoa(assessList[0].Executor.UserId),
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// if len(assessList) == 0 || taskRecordId == 0 {
|
|
|
// result := map[string]interface{}{
|
|
|
// "have": false,
|
|
|
// "cycleId": strconv.Itoa(cycleId),
|
|
|
// "beginDay": today,
|
|
|
// "taskRecordId": strconv.Itoa(taskRecordId),
|
|
|
// "userId": strconv.Itoa(executorId),
|
|
|
// }
|
|
|
// return result, nil
|
|
|
// }
|
|
|
|
|
|
// if assessList[0].Executor.UserId != param.UserId {
|
|
|
// result := map[string]interface{}{
|
|
|
// "have": false,
|
|
|
// "cycleId": strconv.Itoa(cycleId),
|
|
|
// "beginDay": today,
|
|
|
// "taskRecordId": strconv.Itoa(taskRecordId),
|
|
|
// "userId": strconv.Itoa(executorId),
|
|
|
// }
|
|
|
// return result, nil
|
|
|
// }
|
|
|
result := map[string]interface{}{
|
|
|
"have": true,
|
|
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
"cycleId": strconv.Itoa(cycleId),
|
|
|
"beginDay": today,
|
|
|
"taskRecordId": strconv.Itoa(recordList[0].Id),
|
|
|
"userId": strconv.Itoa(assessList[0].Executor.UserId),
|
|
|
"taskRecordId": strconv.Itoa(taskRecordId),
|
|
|
"userId": strconv.Itoa(executorId),
|
|
|
}
|
|
|
result = map[string]interface{}{
|
|
|
"have": true,
|
|
|
"cycleId": "1669227421016002560",
|
|
|
"beginDay": "2023-06-28",
|
|
|
"taskRecordId": "1673722975515316224",
|
|
|
"userId": "3422174102828544",
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
...
|
...
|
@@ -1067,50 +1068,60 @@ func (srv TaskService) MarkTaskAnomalyByTask(param *command.MarkTaskAnomalyComma |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
|
|
|
}
|
|
|
if len(assessList) == 0 {
|
|
|
return map[string]interface{}{
|
|
|
"have": false,
|
|
|
"cycleId": "0",
|
|
|
"beginDay": "",
|
|
|
"taskRecordId": "0",
|
|
|
"userId": "0",
|
|
|
}, nil
|
|
|
|
|
|
var taskRecordId int
|
|
|
var cycleId int
|
|
|
var executorId int
|
|
|
if len(assessList) > 0 {
|
|
|
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 {
|
|
|
taskRecordId = recordList[0].Id
|
|
|
}
|
|
|
|
|
|
cycleId = int(assessList[0].CycleId)
|
|
|
executorId = assessList[0].Executor.UserId
|
|
|
}
|
|
|
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 err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(recordList) == 0 {
|
|
|
if len(assessList) == 0 || taskRecordId == 0 {
|
|
|
result := map[string]interface{}{
|
|
|
"have": false,
|
|
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
"cycleId": strconv.Itoa(cycleId),
|
|
|
"beginDay": today,
|
|
|
"taskRecordId": "0",
|
|
|
"userId": "0",
|
|
|
"taskRecordId": strconv.Itoa(taskRecordId),
|
|
|
"userId": strconv.Itoa(executorId),
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if assessList[0].Executor.UserId != param.UserId {
|
|
|
result := map[string]interface{}{
|
|
|
"have": false,
|
|
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
"cycleId": strconv.Itoa(cycleId),
|
|
|
"beginDay": today,
|
|
|
"taskRecordId": recordList[0].Id,
|
|
|
"userId": strconv.Itoa(assessList[0].Executor.UserId),
|
|
|
"taskRecordId": strconv.Itoa(taskRecordId),
|
|
|
"userId": strconv.Itoa(executorId),
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
result := map[string]interface{}{
|
|
|
"have": true,
|
|
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
"cycleId": strconv.Itoa(cycleId),
|
|
|
"beginDay": today,
|
|
|
"taskRecordId": recordList[0].Id,
|
|
|
"userId": strconv.Itoa(assessList[0].Executor.UserId),
|
|
|
"taskRecordId": strconv.Itoa(taskRecordId),
|
|
|
"userId": strconv.Itoa(executorId),
|
|
|
}
|
|
|
result = map[string]interface{}{
|
|
|
"have": true,
|
|
|
"cycleId": "1669227421016002560",
|
|
|
"beginDay": "2023-06-28",
|
|
|
"taskRecordId": "1673722975515316224",
|
|
|
"userId": "3422174102828544",
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
...
|
...
|
|