...
|
...
|
@@ -657,7 +657,7 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
|
|
}
|
|
|
if len(recordList) == 0 {
|
|
|
result := map[string]interface{}{
|
|
|
"have": true,
|
|
|
"have": false,
|
|
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
"beginDay": today,
|
|
|
}
|
...
|
...
|
@@ -952,7 +952,7 @@ func (srv TaskService) TaskAnomalyInfo(param *command.GetTaskAnomalyCommand) (*a |
|
|
|
|
|
// 任务列表中,对异常记录的操作标记
|
|
|
// 按照任务id 实则操作标记
|
|
|
func (srv TaskService) MarkTaskAnomalyByTask(param command.MarkTaskAnomalyCommand) (map[string]interface{}, error) {
|
|
|
func (srv TaskService) MarkTaskAnomalyByTask(param *command.MarkTaskAnomalyCommand) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -963,8 +963,88 @@ func (srv TaskService) MarkTaskAnomalyByTask(param command.MarkTaskAnomalyComman |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, taskList, err := taskRepo.Find(map[string]interface{}{"id": param.Id, "limit": 1})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(taskList) == 0 {
|
|
|
return map[string]interface{}{
|
|
|
"have": false,
|
|
|
}, nil
|
|
|
}
|
|
|
taskData := taskList[0]
|
|
|
_, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"isLast": 1, "companyId": param.CompanyId, "taskId": taskData.Id})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(anomalyList) == 0 {
|
|
|
return map[string]interface{}{
|
|
|
"have": false,
|
|
|
}, nil
|
|
|
}
|
|
|
for _, val := range anomalyList {
|
|
|
switch param.MarkType {
|
|
|
case "a":
|
|
|
val.MarkA()
|
|
|
case "b":
|
|
|
val.MarkB()
|
|
|
case "c":
|
|
|
val.MarkC()
|
|
|
case "d":
|
|
|
val.MarkD()
|
|
|
}
|
|
|
err = taskAnomalyRepo.Save(val)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
// 检查今天是否有任务有没有对应的每日评估
|
|
|
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,
|
|
|
"beginDay": today,
|
|
|
"typesList": []string{string(domain.AssessSelf)},
|
|
|
"limit": 1,
|
|
|
})
|
|
|
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,
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
result := map[string]interface{}{
|
|
|
"have": true,
|
|
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
"beginDay": today,
|
|
|
"taskRecordId": recordList[0].Id,
|
|
|
}
|
|
|
return result, nil
|
|
|
} |
...
|
...
|
|