|
@@ -1114,3 +1114,162 @@ func (srv TaskService) MarkTaskAnomalyByTask(param *command.MarkTaskAnomalyComma |
|
@@ -1114,3 +1114,162 @@ func (srv TaskService) MarkTaskAnomalyByTask(param *command.MarkTaskAnomalyComma |
1114
|
}
|
1114
|
}
|
1115
|
return result, nil
|
1115
|
return result, nil
|
1116
|
}
|
1116
|
}
|
|
|
1117
|
+
|
|
|
1118
|
+// 搜索和我有关的异常列表
|
|
|
1119
|
+func (srv TaskService) ListTaskAnomaly4(param *command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
|
|
|
1120
|
+ param.TaskName = strings.TrimSpace(param.TaskName)
|
|
|
1121
|
+ if len(param.TaskName) == 0 {
|
|
|
1122
|
+ return tool_funs.SimpleWrapGridMap(0, []adapter.TaskAnomalyItem{}), nil
|
|
|
1123
|
+ }
|
|
|
1124
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
1125
|
+ if err != nil {
|
|
|
1126
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1127
|
+ }
|
|
|
1128
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
1129
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1130
|
+ }
|
|
|
1131
|
+ defer func() {
|
|
|
1132
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
1133
|
+ }()
|
|
|
1134
|
+ taskAnomalyDao := dao.NewTaskAnomalyDao(map[string]interface{}{
|
|
|
1135
|
+ "transactionContext": transactionContext,
|
|
|
1136
|
+ })
|
|
|
1137
|
+ anomalyList, err := taskAnomalyDao.SearchForUser(param.UserId, param.CompanyId, param.TaskName)
|
|
|
1138
|
+ if err != nil {
|
|
|
1139
|
+ return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1140
|
+ }
|
|
|
1141
|
+
|
|
|
1142
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1143
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1144
|
+ }
|
|
|
1145
|
+
|
|
|
1146
|
+ listData := []adapter.TaskAnomalyItem{}
|
|
|
1147
|
+ for _, val := range anomalyList {
|
|
|
1148
|
+ item := adapter.TaskAnomalyItem{
|
|
|
1149
|
+ Id: val.Id,
|
|
|
1150
|
+ TaskId: val.TaskId,
|
|
|
1151
|
+ TaskRecordId: val.TaskRecordId,
|
|
|
1152
|
+ Category: val.Category,
|
|
|
1153
|
+ Leader: val.LeaderName,
|
|
|
1154
|
+ CurrentStage: adapter.TaskStage{
|
|
|
1155
|
+ Id: val.CurrentStage.Id,
|
|
|
1156
|
+ Name: val.CurrentStage.Name,
|
|
|
1157
|
+ StatusDescription: val.CurrentStage.StatusDescription(),
|
|
|
1158
|
+ SortBy: val.CurrentStage.SortBy,
|
|
|
1159
|
+ PlanCompletedAt: time.Unix(val.CurrentStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
1160
|
+ RealCompletedAt: "",
|
|
|
1161
|
+ },
|
|
|
1162
|
+ LastStage: adapter.TaskStage{
|
|
|
1163
|
+ Id: val.LastStage.Id,
|
|
|
1164
|
+ Name: val.LastStage.Name,
|
|
|
1165
|
+ StatusDescription: val.LastStage.StatusDescription(),
|
|
|
1166
|
+ SortBy: val.LastStage.SortBy,
|
|
|
1167
|
+ PlanCompletedAt: time.Unix(val.LastStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
1168
|
+ RealCompletedAt: "",
|
|
|
1169
|
+ },
|
|
|
1170
|
+ AssessFlag: val.AssessFlag,
|
|
|
1171
|
+ WarnFlag: val.WarnFlag,
|
|
|
1172
|
+ AssistFlag: val.AssistFlag,
|
|
|
1173
|
+ TaskLevel: val.LevelName,
|
|
|
1174
|
+ TaskName: val.TaskName,
|
|
|
1175
|
+ TaskAlias: val.TaskAlias,
|
|
|
1176
|
+ TaskEndTime: int64(val.TaskEndTime),
|
|
|
1177
|
+ TaskSortBy: val.TaskSortBy,
|
|
|
1178
|
+ CreatedAt: val.CreatedAt.Local().Format("2006-01-02"),
|
|
|
1179
|
+ RecordBegin: val.RecordBegin,
|
|
|
1180
|
+ MarkA: "",
|
|
|
1181
|
+ MarkB: "",
|
|
|
1182
|
+ MarkC: "",
|
|
|
1183
|
+ MarkD: "",
|
|
|
1184
|
+ AnomalyDesc2: map[string]string{},
|
|
|
1185
|
+ }
|
|
|
1186
|
+ if len(val.Marks) > 0 {
|
|
|
1187
|
+ item.MarkA = val.Marks["a"]
|
|
|
1188
|
+ item.MarkB = val.Marks["b"]
|
|
|
1189
|
+ item.MarkC = val.Marks["c"]
|
|
|
1190
|
+ item.MarkD = val.Marks["d"]
|
|
|
1191
|
+ }
|
|
|
1192
|
+ if val.CurrentStage.RealCompletedAt > 0 {
|
|
|
1193
|
+ item.CurrentStage.RealCompletedAt = time.Unix(val.CurrentStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
1194
|
+ }
|
|
|
1195
|
+ if val.LastStage.RealCompletedAt > 0 {
|
|
|
1196
|
+ item.LastStage.RealCompletedAt = time.Unix(val.LastStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
1197
|
+ }
|
|
|
1198
|
+ noticeWho := []string{}
|
|
|
1199
|
+ for _, val2 := range val.NoticeWho {
|
|
|
1200
|
+ if name, ok := val2["name"]; ok {
|
|
|
1201
|
+ noticeWho = append(noticeWho, name)
|
|
|
1202
|
+ }
|
|
|
1203
|
+ }
|
|
|
1204
|
+ switch val.Category {
|
|
|
1205
|
+ case domain.AnomalyCategoryType1:
|
|
|
1206
|
+ {
|
|
|
1207
|
+ //里程碑异常
|
|
|
1208
|
+ if val.TaskStageCheck.RealCompletedAt == 0 && val.TaskStageCheck.Id > 0 {
|
|
|
1209
|
+ //逾期未完成
|
|
|
1210
|
+ planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
1211
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, planCompletedAt)
|
|
|
1212
|
+ item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
|
|
|
1213
|
+ item.AnomalyDesc2 = map[string]string{
|
|
|
1214
|
+ "types": "10",
|
|
|
1215
|
+ "stageName": val.TaskStageCheck.Name,
|
|
|
1216
|
+ "interval": strconv.Itoa(subDay),
|
|
|
1217
|
+ "noticeWho": strings.Join(noticeWho, ","),
|
|
|
1218
|
+ }
|
|
|
1219
|
+
|
|
|
1220
|
+ } else if val.TaskStageCheck.RealCompletedAt > 0 && val.TaskStageCheck.Id > 0 {
|
|
|
1221
|
+ //逾期完成
|
|
|
1222
|
+ planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
1223
|
+ realCompletedAt := time.Unix(val.TaskStageCheck.RealCompletedAt, 0)
|
|
|
1224
|
+ subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
|
|
|
1225
|
+ item.AnomalyDesc = fmt.Sprintf("里程碑%s逾期%d天完成", val.TaskStageCheck.Name, subDay)
|
|
|
1226
|
+ item.AnomalyDesc2 = map[string]string{
|
|
|
1227
|
+ "types": "11",
|
|
|
1228
|
+ "stageName": val.TaskStageCheck.Name,
|
|
|
1229
|
+ "interval": strconv.Itoa(subDay),
|
|
|
1230
|
+ "noticeWho": strings.Join(noticeWho, ","),
|
|
|
1231
|
+ }
|
|
|
1232
|
+ }
|
|
|
1233
|
+ }
|
|
|
1234
|
+ case domain.AnomalyCategoryType2:
|
|
|
1235
|
+ //反馈异常
|
|
|
1236
|
+ {
|
|
|
1237
|
+ recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
1238
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
1239
|
+ item.AnomalyDesc = fmt.Sprintf(
|
|
|
1240
|
+ "本任务自%s未正常反馈项目进度,已异常%d天",
|
|
|
1241
|
+ recordBegin.Local().Format("2006-01-02"),
|
|
|
1242
|
+ subDay,
|
|
|
1243
|
+ )
|
|
|
1244
|
+ item.AnomalyDesc2 = map[string]string{
|
|
|
1245
|
+ "types": "2",
|
|
|
1246
|
+ "dayTime": recordBegin.Local().Format("2006-01-02"),
|
|
|
1247
|
+ "interval": strconv.Itoa(subDay),
|
|
|
1248
|
+ "noticeWho": strings.Join(noticeWho, ","),
|
|
|
1249
|
+ }
|
|
|
1250
|
+ }
|
|
|
1251
|
+ case domain.AnomalyCategoryType3:
|
|
|
1252
|
+ //辅导异常
|
|
|
1253
|
+ {
|
|
|
1254
|
+ recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
1255
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
1256
|
+ item.AnomalyDesc = fmt.Sprintf(
|
|
|
1257
|
+ "本任务计划于%s完成辅导,已逾期%d天",
|
|
|
1258
|
+ recordBegin.Local().Format("2006-01-02"),
|
|
|
1259
|
+ subDay,
|
|
|
1260
|
+ )
|
|
|
1261
|
+ item.AnomalyDesc2 = map[string]string{
|
|
|
1262
|
+ "types": "3",
|
|
|
1263
|
+ "dayTime": recordBegin.Local().Format("2006-01-02"),
|
|
|
1264
|
+ "interval": strconv.Itoa(subDay),
|
|
|
1265
|
+ "noticeWho": strings.Join(noticeWho, ","),
|
|
|
1266
|
+ }
|
|
|
1267
|
+ }
|
|
|
1268
|
+ }
|
|
|
1269
|
+
|
|
|
1270
|
+ listData = append(listData, item)
|
|
|
1271
|
+ }
|
|
|
1272
|
+
|
|
|
1273
|
+ result := tool_funs.SimpleWrapGridMap(int64(len(listData)), listData)
|
|
|
1274
|
+ return result, nil
|
|
|
1275
|
+} |