|
@@ -147,7 +147,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
@@ -147,7 +147,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
147
|
if err != nil {
|
147
|
if err != nil {
|
148
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
|
148
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
|
149
|
}
|
149
|
}
|
150
|
- newTask.CurrentStage = *newTaskStage[0]
|
150
|
+ //记录待执行的里程碑
|
|
|
151
|
+ newTask.SetCurrentStage(newTaskStage)
|
151
|
err = taskRepo.Save(&newTask)
|
152
|
err = taskRepo.Save(&newTask)
|
152
|
if err != nil {
|
153
|
if err != nil {
|
153
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务失败:"+err.Error())
|
154
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务失败:"+err.Error())
|
|
@@ -291,12 +292,13 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
@@ -291,12 +292,13 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
291
|
if err != nil {
|
292
|
if err != nil {
|
292
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
293
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
293
|
}
|
294
|
}
|
294
|
- for _, val := range stageList {
|
|
|
295
|
- if val.RealCompletedAt == 0 {
|
|
|
296
|
- taskData.CurrentStage = *val
|
|
|
297
|
- break
|
|
|
298
|
- }
|
|
|
299
|
- }
|
295
|
+ // for _, val := range stageList {
|
|
|
296
|
+ // if val.RealCompletedAt == 0 {
|
|
|
297
|
+ // taskData.CurrentStage = *val
|
|
|
298
|
+ // break
|
|
|
299
|
+ // }
|
|
|
300
|
+ // }
|
|
|
301
|
+ taskData.SetCurrentStage(stageList)
|
300
|
err = taskRepo.Save(taskData)
|
302
|
err = taskRepo.Save(taskData)
|
301
|
if err != nil {
|
303
|
if err != nil {
|
302
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
304
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -920,7 +922,7 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction |
|
@@ -920,7 +922,7 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction |
920
|
taskData.Anomaly = 0
|
922
|
taskData.Anomaly = 0
|
921
|
}
|
923
|
}
|
922
|
for _, val2 := range stageList {
|
924
|
for _, val2 := range stageList {
|
923
|
- if val2.Id == val.TaskStageCheck.Id {
|
925
|
+ if val2.Id != val.TaskStageCheck.Id {
|
924
|
continue
|
926
|
continue
|
925
|
}
|
927
|
}
|
926
|
val2.RealCompletedAt = val.TaskStageCheck.RealCompletedAt
|
928
|
val2.RealCompletedAt = val.TaskStageCheck.RealCompletedAt
|
|
@@ -931,18 +933,11 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction |
|
@@ -931,18 +933,11 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction |
931
|
}
|
933
|
}
|
932
|
break
|
934
|
break
|
933
|
}
|
935
|
}
|
934
|
- taskData.CurrentStage = domain.TaskStage{}
|
|
|
935
|
- //设置下一个 待执行的里程碑
|
|
|
936
|
- for _, val2 := range stageList {
|
|
|
937
|
- if val2.RealCompletedAt == 0 {
|
|
|
938
|
- taskData.CurrentStage = *val2
|
|
|
939
|
- break
|
|
|
940
|
- }
|
|
|
941
|
- }
|
|
|
942
|
err = taskStageRepo.Save(stageList)
|
936
|
err = taskStageRepo.Save(stageList)
|
943
|
if err != nil {
|
937
|
if err != nil {
|
944
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务里程碑数据"+err.Error())
|
938
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务里程碑数据"+err.Error())
|
945
|
}
|
939
|
}
|
|
|
940
|
+ taskData.SetCurrentStage(stageList)
|
946
|
err = taskRepo.Save(taskData)
|
941
|
err = taskRepo.Save(taskData)
|
947
|
if err != nil {
|
942
|
if err != nil {
|
948
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务数据"+err.Error())
|
943
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务数据"+err.Error())
|
|
@@ -1133,3 +1128,236 @@ func (srv TaskService) ConditionForListTask2(param *command.GetSelcetCommand) (m |
|
@@ -1133,3 +1128,236 @@ func (srv TaskService) ConditionForListTask2(param *command.GetSelcetCommand) (m |
1133
|
}
|
1128
|
}
|
1134
|
return result, nil
|
1129
|
return result, nil
|
1135
|
}
|
1130
|
}
|
|
|
1131
|
+
|
|
|
1132
|
+// 员工绩效-任务管理-列表 (新)
|
|
|
1133
|
+func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]interface{}, error) {
|
|
|
1134
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
1135
|
+ if err != nil {
|
|
|
1136
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1137
|
+ }
|
|
|
1138
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
1139
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1140
|
+ }
|
|
|
1141
|
+ defer func() {
|
|
|
1142
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
1143
|
+ }()
|
|
|
1144
|
+ hrbpFlag, err := roleService.GetHrBp(transactionContext, int(param.CompanyId), int(param.UserId))
|
|
|
1145
|
+ if err != nil {
|
|
|
1146
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
|
|
|
1147
|
+ }
|
|
|
1148
|
+ if len(param.SearchWord) > 0 {
|
|
|
1149
|
+ param.SearchWord = "%" + param.SearchWord + "%"
|
|
|
1150
|
+ }
|
|
|
1151
|
+ if hrbpFlag == domain.RoleTypeSystem {
|
|
|
1152
|
+ listData, err := srv.listTask3ForHrbp(param)
|
|
|
1153
|
+ return listData, err
|
|
|
1154
|
+ }
|
|
|
1155
|
+ var limit = 20
|
|
|
1156
|
+ var offset = 0
|
|
|
1157
|
+ if param.PageSize > 0 {
|
|
|
1158
|
+ limit = param.PageSize
|
|
|
1159
|
+ if param.PageNumber > 0 {
|
|
|
1160
|
+ offset = (param.PageNumber - 1) * param.PageSize
|
|
|
1161
|
+ }
|
|
|
1162
|
+ }
|
|
|
1163
|
+ condition := dao.ListTaskCondition{
|
|
|
1164
|
+ Limit: limit,
|
|
|
1165
|
+ Offset: offset,
|
|
|
1166
|
+ UserId: param.UserId,
|
|
|
1167
|
+ CompanyId: param.CompanyId,
|
|
|
1168
|
+ OnlyMy: param.OnlyMy,
|
|
|
1169
|
+ SearchWord: param.SearchWord,
|
|
|
1170
|
+ }
|
|
|
1171
|
+
|
|
|
1172
|
+ taskDao := dao.NewTaskDao(map[string]interface{}{
|
|
|
1173
|
+ "transactionContext": transactionContext,
|
|
|
1174
|
+ })
|
|
|
1175
|
+ //任务列表数据
|
|
|
1176
|
+ taskListData, err := taskDao.ListTaskNotHrbpV2(condition)
|
|
|
1177
|
+ if err != nil {
|
|
|
1178
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
|
|
|
1179
|
+ }
|
|
|
1180
|
+ //查到的任务数据总数
|
|
|
1181
|
+ taskCount, err := taskDao.CountTaskStageNotHrbp(condition)
|
|
|
1182
|
+ if err != nil {
|
|
|
1183
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
|
|
|
1184
|
+ }
|
|
|
1185
|
+ //
|
|
|
1186
|
+ taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition)
|
|
|
1187
|
+ if err != nil {
|
|
|
1188
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
1189
|
+ }
|
|
|
1190
|
+ taskAnomalyCnt, err := taskDao.CountTaskAnomalyNotHrbp(condition)
|
|
|
1191
|
+ if err != nil {
|
|
|
1192
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
1193
|
+ }
|
|
|
1194
|
+
|
|
|
1195
|
+ taskResult := []*adapter.TaskItem{}
|
|
|
1196
|
+ taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
|
|
|
1197
|
+ "transactionContext": transactionContext,
|
|
|
1198
|
+ })
|
|
|
1199
|
+ for _, val := range taskListData {
|
|
|
1200
|
+ tk := adapter.TaskItem{
|
|
|
1201
|
+ Id: val.TaskId,
|
|
|
1202
|
+ Name: "",
|
|
|
1203
|
+ Alias: val.Alias,
|
|
|
1204
|
+ Leader: val.LeaderName,
|
|
|
1205
|
+ Status: val.Status,
|
|
|
1206
|
+ Level: val.Level,
|
|
|
1207
|
+ LevelName: val.LevelName,
|
|
|
1208
|
+ UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
1209
|
+ Anomaly: val.Anomaly,
|
|
|
1210
|
+ WarnFlag: 0,
|
|
|
1211
|
+ }
|
|
|
1212
|
+ _, stageList, err := taskStageRepo.Find(map[string]interface{}{
|
|
|
1213
|
+ "taskId": val.TaskId,
|
|
|
1214
|
+ })
|
|
|
1215
|
+ if err != nil {
|
|
|
1216
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务里程碑"+err.Error())
|
|
|
1217
|
+ }
|
|
|
1218
|
+
|
|
|
1219
|
+ for _, val2 := range stageList {
|
|
|
1220
|
+ stage := adapter.TaskStage{
|
|
|
1221
|
+ Id: val2.Id,
|
|
|
1222
|
+ Name: val2.Name,
|
|
|
1223
|
+ SortBy: val2.SortBy,
|
|
|
1224
|
+ PlanCompletedAt: time.Unix(int64(val2.PlanCompletedAt), 0).Local().Format("2006-01-02"),
|
|
|
1225
|
+ RealCompletedAt: "",
|
|
|
1226
|
+ }
|
|
|
1227
|
+ if val2.RealCompletedAt > 0 {
|
|
|
1228
|
+ stage.RealCompletedAt = time.Unix(int64(val2.RealCompletedAt), 0).Local().Format("2006-01-02")
|
|
|
1229
|
+ }
|
|
|
1230
|
+ switch val2.SortBy {
|
|
|
1231
|
+ case 1:
|
|
|
1232
|
+ tk.StageA = stage
|
|
|
1233
|
+ case 2:
|
|
|
1234
|
+ tk.StageB = stage
|
|
|
1235
|
+ case 3:
|
|
|
1236
|
+ tk.StageC = stage
|
|
|
1237
|
+ case 4:
|
|
|
1238
|
+ tk.StageD = stage
|
|
|
1239
|
+ case 5:
|
|
|
1240
|
+ tk.StageE = stage
|
|
|
1241
|
+ }
|
|
|
1242
|
+ }
|
|
|
1243
|
+ taskResult = append(taskResult, &tk)
|
|
|
1244
|
+ }
|
|
|
1245
|
+ result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
|
|
1246
|
+ result["taskStageAnomaly"] = taskStageAnomalyCnt
|
|
|
1247
|
+ result["taskAnomalyCnt"] = taskAnomalyCnt
|
|
|
1248
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1249
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1250
|
+ }
|
|
|
1251
|
+ return result, nil
|
|
|
1252
|
+}
|
|
|
1253
|
+
|
|
|
1254
|
+// 员工绩效-任务管理-列表 (新)
|
|
|
1255
|
+func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) {
|
|
|
1256
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
1257
|
+ if err != nil {
|
|
|
1258
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1259
|
+ }
|
|
|
1260
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
1261
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1262
|
+ }
|
|
|
1263
|
+ defer func() {
|
|
|
1264
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
1265
|
+ }()
|
|
|
1266
|
+ var limit = 20
|
|
|
1267
|
+ var offset = 0
|
|
|
1268
|
+ if param.PageSize > 0 {
|
|
|
1269
|
+ limit = param.PageSize
|
|
|
1270
|
+ if param.PageNumber > 0 {
|
|
|
1271
|
+ offset = (param.PageNumber - 1) * param.PageSize
|
|
|
1272
|
+ }
|
|
|
1273
|
+ }
|
|
|
1274
|
+ condition := dao.ListTaskCondition{
|
|
|
1275
|
+ Limit: limit,
|
|
|
1276
|
+ Offset: offset,
|
|
|
1277
|
+ UserId: param.UserId,
|
|
|
1278
|
+ CompanyId: param.CompanyId,
|
|
|
1279
|
+ OnlyMy: param.OnlyMy,
|
|
|
1280
|
+ SearchWord: param.SearchWord,
|
|
|
1281
|
+ }
|
|
|
1282
|
+
|
|
|
1283
|
+ taskDao := dao.NewTaskDao(map[string]interface{}{
|
|
|
1284
|
+ "transactionContext": transactionContext,
|
|
|
1285
|
+ })
|
|
|
1286
|
+ //任务列表数据
|
|
|
1287
|
+ taskListData, err := taskDao.ListTaskByHrbpV2(condition)
|
|
|
1288
|
+ if err != nil {
|
|
|
1289
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
|
|
|
1290
|
+ }
|
|
|
1291
|
+ //查到的任务数据总数
|
|
|
1292
|
+ taskCount, err := taskDao.CountTaskStageNotHrbp(condition)
|
|
|
1293
|
+ if err != nil {
|
|
|
1294
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
|
|
|
1295
|
+ }
|
|
|
1296
|
+ //
|
|
|
1297
|
+ taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition)
|
|
|
1298
|
+ if err != nil {
|
|
|
1299
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
1300
|
+ }
|
|
|
1301
|
+ taskAnomalyCnt, err := taskDao.CountTaskAnomalyNotHrbp(condition)
|
|
|
1302
|
+ if err != nil {
|
|
|
1303
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
1304
|
+ }
|
|
|
1305
|
+
|
|
|
1306
|
+ taskResult := []*adapter.TaskItem{}
|
|
|
1307
|
+ taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
|
|
|
1308
|
+ "transactionContext": transactionContext,
|
|
|
1309
|
+ })
|
|
|
1310
|
+ for _, val := range taskListData {
|
|
|
1311
|
+ tk := adapter.TaskItem{
|
|
|
1312
|
+ Id: val.TaskId,
|
|
|
1313
|
+ Name: "",
|
|
|
1314
|
+ Alias: val.Alias,
|
|
|
1315
|
+ Leader: val.LeaderName,
|
|
|
1316
|
+ Status: val.Status,
|
|
|
1317
|
+ Level: val.Level,
|
|
|
1318
|
+ LevelName: val.LevelName,
|
|
|
1319
|
+ UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
1320
|
+ Anomaly: val.Anomaly,
|
|
|
1321
|
+ WarnFlag: 0,
|
|
|
1322
|
+ }
|
|
|
1323
|
+ _, stageList, err := taskStageRepo.Find(map[string]interface{}{
|
|
|
1324
|
+ "taskId": val.TaskId,
|
|
|
1325
|
+ })
|
|
|
1326
|
+ if err != nil {
|
|
|
1327
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务里程碑"+err.Error())
|
|
|
1328
|
+ }
|
|
|
1329
|
+
|
|
|
1330
|
+ for _, val2 := range stageList {
|
|
|
1331
|
+ stage := adapter.TaskStage{
|
|
|
1332
|
+ Id: val2.Id,
|
|
|
1333
|
+ Name: val2.Name,
|
|
|
1334
|
+ SortBy: val2.SortBy,
|
|
|
1335
|
+ PlanCompletedAt: time.Unix(int64(val2.PlanCompletedAt), 0).Local().Format("2006-01-02"),
|
|
|
1336
|
+ RealCompletedAt: "",
|
|
|
1337
|
+ }
|
|
|
1338
|
+ if val2.RealCompletedAt > 0 {
|
|
|
1339
|
+ stage.RealCompletedAt = time.Unix(int64(val2.RealCompletedAt), 0).Local().Format("2006-01-02")
|
|
|
1340
|
+ }
|
|
|
1341
|
+ switch val2.SortBy {
|
|
|
1342
|
+ case 1:
|
|
|
1343
|
+ tk.StageA = stage
|
|
|
1344
|
+ case 2:
|
|
|
1345
|
+ tk.StageB = stage
|
|
|
1346
|
+ case 3:
|
|
|
1347
|
+ tk.StageC = stage
|
|
|
1348
|
+ case 4:
|
|
|
1349
|
+ tk.StageD = stage
|
|
|
1350
|
+ case 5:
|
|
|
1351
|
+ tk.StageE = stage
|
|
|
1352
|
+ }
|
|
|
1353
|
+ }
|
|
|
1354
|
+ taskResult = append(taskResult, &tk)
|
|
|
1355
|
+ }
|
|
|
1356
|
+ result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
|
|
1357
|
+ result["taskStageAnomaly"] = taskStageAnomalyCnt
|
|
|
1358
|
+ result["taskAnomalyCnt"] = taskAnomalyCnt
|
|
|
1359
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1360
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1361
|
+ }
|
|
|
1362
|
+ return result, nil
|
|
|
1363
|
+} |