|
@@ -657,7 +657,7 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
|
@@ -657,7 +657,7 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m |
657
|
}
|
657
|
}
|
658
|
if len(recordList) == 0 {
|
658
|
if len(recordList) == 0 {
|
659
|
result := map[string]interface{}{
|
659
|
result := map[string]interface{}{
|
660
|
- "have": true,
|
660
|
+ "have": false,
|
661
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
661
|
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
662
|
"beginDay": today,
|
662
|
"beginDay": today,
|
663
|
}
|
663
|
}
|
|
@@ -952,7 +952,7 @@ func (srv TaskService) TaskAnomalyInfo(param *command.GetTaskAnomalyCommand) (*a |
|
@@ -952,7 +952,7 @@ func (srv TaskService) TaskAnomalyInfo(param *command.GetTaskAnomalyCommand) (*a |
952
|
|
952
|
|
953
|
// 任务列表中,对异常记录的操作标记
|
953
|
// 任务列表中,对异常记录的操作标记
|
954
|
// 按照任务id 实则操作标记
|
954
|
// 按照任务id 实则操作标记
|
955
|
-func (srv TaskService) MarkTaskAnomalyByTask(param command.MarkTaskAnomalyCommand) (map[string]interface{}, error) {
|
955
|
+func (srv TaskService) MarkTaskAnomalyByTask(param *command.MarkTaskAnomalyCommand) (map[string]interface{}, error) {
|
956
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
956
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
957
|
if err != nil {
|
957
|
if err != nil {
|
958
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
958
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -963,8 +963,88 @@ func (srv TaskService) MarkTaskAnomalyByTask(param command.MarkTaskAnomalyComman |
|
@@ -963,8 +963,88 @@ func (srv TaskService) MarkTaskAnomalyByTask(param command.MarkTaskAnomalyComman |
963
|
defer func() {
|
963
|
defer func() {
|
964
|
_ = transactionContext.RollbackTransaction()
|
964
|
_ = transactionContext.RollbackTransaction()
|
965
|
}()
|
965
|
}()
|
|
|
966
|
+
|
|
|
967
|
+ taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
968
|
+ "transactionContext": transactionContext,
|
|
|
969
|
+ })
|
|
|
970
|
+ taskRepo := factory.CreateTaskRepository(map[string]interface{}{
|
|
|
971
|
+ "transactionContext": transactionContext,
|
|
|
972
|
+ })
|
|
|
973
|
+ _, taskList, err := taskRepo.Find(map[string]interface{}{"id": param.Id, "limit": 1})
|
|
|
974
|
+ if err != nil {
|
|
|
975
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
976
|
+ }
|
|
|
977
|
+ if len(taskList) == 0 {
|
|
|
978
|
+ return map[string]interface{}{
|
|
|
979
|
+ "have": false,
|
|
|
980
|
+ }, nil
|
|
|
981
|
+ }
|
|
|
982
|
+ taskData := taskList[0]
|
|
|
983
|
+ _, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"isLast": 1, "companyId": param.CompanyId, "taskId": taskData.Id})
|
|
|
984
|
+ if err != nil {
|
|
|
985
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
986
|
+ }
|
|
|
987
|
+ if len(anomalyList) == 0 {
|
|
|
988
|
+ return map[string]interface{}{
|
|
|
989
|
+ "have": false,
|
|
|
990
|
+ }, nil
|
|
|
991
|
+ }
|
|
|
992
|
+ for _, val := range anomalyList {
|
|
|
993
|
+ switch param.MarkType {
|
|
|
994
|
+ case "a":
|
|
|
995
|
+ val.MarkA()
|
|
|
996
|
+ case "b":
|
|
|
997
|
+ val.MarkB()
|
|
|
998
|
+ case "c":
|
|
|
999
|
+ val.MarkC()
|
|
|
1000
|
+ case "d":
|
|
|
1001
|
+ val.MarkD()
|
|
|
1002
|
+ }
|
|
|
1003
|
+ err = taskAnomalyRepo.Save(val)
|
|
|
1004
|
+ if err != nil {
|
|
|
1005
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1006
|
+ }
|
|
|
1007
|
+ }
|
|
|
1008
|
+ // 检查今天是否有任务有没有对应的每日评估
|
|
|
1009
|
+ assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
1010
|
+ // 获取员工的评估
|
|
|
1011
|
+ today := time.Now().Format("2006-01-02")
|
|
|
1012
|
+ _, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
1013
|
+ "companyId": param.CompanyId,
|
|
|
1014
|
+ "executorId": taskData.Leader.Id,
|
|
|
1015
|
+ "beginDay": today,
|
|
|
1016
|
+ "typesList": []string{string(domain.AssessSelf)},
|
|
|
1017
|
+ "limit": 1,
|
|
|
1018
|
+ })
|
|
|
1019
|
+ if err != nil {
|
|
|
1020
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
|
|
|
1021
|
+ }
|
|
|
1022
|
+ if len(assessList) == 0 {
|
|
|
1023
|
+ return map[string]interface{}{
|
|
|
1024
|
+ "have": false,
|
|
|
1025
|
+ }, nil
|
|
|
1026
|
+ }
|
|
|
1027
|
+ taskRecordReps := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
1028
|
+ _, recordList, err := taskRecordReps.Find(map[string]interface{}{"staffAssessId": assessList[0].Id, "taskId": taskData.Id})
|
|
|
1029
|
+ if err != nil {
|
|
|
1030
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的评估"+err.Error())
|
|
|
1031
|
+ }
|
|
|
1032
|
+ if len(recordList) == 0 {
|
|
|
1033
|
+ result := map[string]interface{}{
|
|
|
1034
|
+ "have": false,
|
|
|
1035
|
+ "cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
1036
|
+ "beginDay": today,
|
|
|
1037
|
+ }
|
|
|
1038
|
+ return result, nil
|
|
|
1039
|
+ }
|
966
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1040
|
if err := transactionContext.CommitTransaction(); err != nil {
|
967
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1041
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
968
|
}
|
1042
|
}
|
969
|
- return nil, nil
|
1043
|
+ result := map[string]interface{}{
|
|
|
1044
|
+ "have": true,
|
|
|
1045
|
+ "cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
|
|
|
1046
|
+ "beginDay": today,
|
|
|
1047
|
+ "taskRecordId": recordList[0].Id,
|
|
|
1048
|
+ }
|
|
|
1049
|
+ return result, nil
|
970
|
} |
1050
|
} |