...
|
...
|
@@ -147,7 +147,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
|
|
|
}
|
|
|
newTask.CurrentStage = *newTaskStage[0]
|
|
|
//记录待执行的里程碑
|
|
|
newTask.SetCurrentStage(newTaskStage)
|
|
|
err = taskRepo.Save(&newTask)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务失败:"+err.Error())
|
...
|
...
|
@@ -291,12 +292,13 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for _, val := range stageList {
|
|
|
if val.RealCompletedAt == 0 {
|
|
|
taskData.CurrentStage = *val
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
// for _, val := range stageList {
|
|
|
// if val.RealCompletedAt == 0 {
|
|
|
// taskData.CurrentStage = *val
|
|
|
// break
|
|
|
// }
|
|
|
// }
|
|
|
taskData.SetCurrentStage(stageList)
|
|
|
err = taskRepo.Save(taskData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -920,7 +922,7 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction |
|
|
taskData.Anomaly = 0
|
|
|
}
|
|
|
for _, val2 := range stageList {
|
|
|
if val2.Id == val.TaskStageCheck.Id {
|
|
|
if val2.Id != val.TaskStageCheck.Id {
|
|
|
continue
|
|
|
}
|
|
|
val2.RealCompletedAt = val.TaskStageCheck.RealCompletedAt
|
...
|
...
|
@@ -931,18 +933,11 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction |
|
|
}
|
|
|
break
|
|
|
}
|
|
|
taskData.CurrentStage = domain.TaskStage{}
|
|
|
//设置下一个 待执行的里程碑
|
|
|
for _, val2 := range stageList {
|
|
|
if val2.RealCompletedAt == 0 {
|
|
|
taskData.CurrentStage = *val2
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
err = taskStageRepo.Save(stageList)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务里程碑数据"+err.Error())
|
|
|
}
|
|
|
taskData.SetCurrentStage(stageList)
|
|
|
err = taskRepo.Save(taskData)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务数据"+err.Error())
|
...
|
...
|
@@ -1133,3 +1128,236 @@ func (srv TaskService) ConditionForListTask2(param *command.GetSelcetCommand) (m |
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 员工绩效-任务管理-列表 (新)
|
|
|
func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
hrbpFlag, err := roleService.GetHrBp(transactionContext, int(param.CompanyId), int(param.UserId))
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
|
|
|
}
|
|
|
if len(param.SearchWord) > 0 {
|
|
|
param.SearchWord = "%" + param.SearchWord + "%"
|
|
|
}
|
|
|
if hrbpFlag == domain.RoleTypeSystem {
|
|
|
listData, err := srv.listTask3ForHrbp(param)
|
|
|
return listData, err
|
|
|
}
|
|
|
var limit = 20
|
|
|
var offset = 0
|
|
|
if param.PageSize > 0 {
|
|
|
limit = param.PageSize
|
|
|
if param.PageNumber > 0 {
|
|
|
offset = (param.PageNumber - 1) * param.PageSize
|
|
|
}
|
|
|
}
|
|
|
condition := dao.ListTaskCondition{
|
|
|
Limit: limit,
|
|
|
Offset: offset,
|
|
|
UserId: param.UserId,
|
|
|
CompanyId: param.CompanyId,
|
|
|
OnlyMy: param.OnlyMy,
|
|
|
SearchWord: param.SearchWord,
|
|
|
}
|
|
|
|
|
|
taskDao := dao.NewTaskDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//任务列表数据
|
|
|
taskListData, err := taskDao.ListTaskNotHrbpV2(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
|
|
|
}
|
|
|
//查到的任务数据总数
|
|
|
taskCount, err := taskDao.CountTaskStageNotHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
|
|
|
}
|
|
|
//
|
|
|
taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
}
|
|
|
taskAnomalyCnt, err := taskDao.CountTaskAnomalyNotHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
}
|
|
|
|
|
|
taskResult := []*adapter.TaskItem{}
|
|
|
taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
for _, val := range taskListData {
|
|
|
tk := adapter.TaskItem{
|
|
|
Id: val.TaskId,
|
|
|
Name: "",
|
|
|
Alias: val.Alias,
|
|
|
Leader: val.LeaderName,
|
|
|
Status: val.Status,
|
|
|
Level: val.Level,
|
|
|
LevelName: val.LevelName,
|
|
|
UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
Anomaly: val.Anomaly,
|
|
|
WarnFlag: 0,
|
|
|
}
|
|
|
_, stageList, err := taskStageRepo.Find(map[string]interface{}{
|
|
|
"taskId": val.TaskId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务里程碑"+err.Error())
|
|
|
}
|
|
|
|
|
|
for _, val2 := range stageList {
|
|
|
stage := adapter.TaskStage{
|
|
|
Id: val2.Id,
|
|
|
Name: val2.Name,
|
|
|
SortBy: val2.SortBy,
|
|
|
PlanCompletedAt: time.Unix(int64(val2.PlanCompletedAt), 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
}
|
|
|
if val2.RealCompletedAt > 0 {
|
|
|
stage.RealCompletedAt = time.Unix(int64(val2.RealCompletedAt), 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
switch val2.SortBy {
|
|
|
case 1:
|
|
|
tk.StageA = stage
|
|
|
case 2:
|
|
|
tk.StageB = stage
|
|
|
case 3:
|
|
|
tk.StageC = stage
|
|
|
case 4:
|
|
|
tk.StageD = stage
|
|
|
case 5:
|
|
|
tk.StageE = stage
|
|
|
}
|
|
|
}
|
|
|
taskResult = append(taskResult, &tk)
|
|
|
}
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
|
|
result["taskStageAnomaly"] = taskStageAnomalyCnt
|
|
|
result["taskAnomalyCnt"] = taskAnomalyCnt
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 员工绩效-任务管理-列表 (新)
|
|
|
func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var limit = 20
|
|
|
var offset = 0
|
|
|
if param.PageSize > 0 {
|
|
|
limit = param.PageSize
|
|
|
if param.PageNumber > 0 {
|
|
|
offset = (param.PageNumber - 1) * param.PageSize
|
|
|
}
|
|
|
}
|
|
|
condition := dao.ListTaskCondition{
|
|
|
Limit: limit,
|
|
|
Offset: offset,
|
|
|
UserId: param.UserId,
|
|
|
CompanyId: param.CompanyId,
|
|
|
OnlyMy: param.OnlyMy,
|
|
|
SearchWord: param.SearchWord,
|
|
|
}
|
|
|
|
|
|
taskDao := dao.NewTaskDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//任务列表数据
|
|
|
taskListData, err := taskDao.ListTaskByHrbpV2(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
|
|
|
}
|
|
|
//查到的任务数据总数
|
|
|
taskCount, err := taskDao.CountTaskStageNotHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
|
|
|
}
|
|
|
//
|
|
|
taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
}
|
|
|
taskAnomalyCnt, err := taskDao.CountTaskAnomalyNotHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
}
|
|
|
|
|
|
taskResult := []*adapter.TaskItem{}
|
|
|
taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
for _, val := range taskListData {
|
|
|
tk := adapter.TaskItem{
|
|
|
Id: val.TaskId,
|
|
|
Name: "",
|
|
|
Alias: val.Alias,
|
|
|
Leader: val.LeaderName,
|
|
|
Status: val.Status,
|
|
|
Level: val.Level,
|
|
|
LevelName: val.LevelName,
|
|
|
UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
Anomaly: val.Anomaly,
|
|
|
WarnFlag: 0,
|
|
|
}
|
|
|
_, stageList, err := taskStageRepo.Find(map[string]interface{}{
|
|
|
"taskId": val.TaskId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务里程碑"+err.Error())
|
|
|
}
|
|
|
|
|
|
for _, val2 := range stageList {
|
|
|
stage := adapter.TaskStage{
|
|
|
Id: val2.Id,
|
|
|
Name: val2.Name,
|
|
|
SortBy: val2.SortBy,
|
|
|
PlanCompletedAt: time.Unix(int64(val2.PlanCompletedAt), 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
}
|
|
|
if val2.RealCompletedAt > 0 {
|
|
|
stage.RealCompletedAt = time.Unix(int64(val2.RealCompletedAt), 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
switch val2.SortBy {
|
|
|
case 1:
|
|
|
tk.StageA = stage
|
|
|
case 2:
|
|
|
tk.StageB = stage
|
|
|
case 3:
|
|
|
tk.StageC = stage
|
|
|
case 4:
|
|
|
tk.StageD = stage
|
|
|
case 5:
|
|
|
tk.StageE = stage
|
|
|
}
|
|
|
}
|
|
|
taskResult = append(taskResult, &tk)
|
|
|
}
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
|
|
result["taskStageAnomaly"] = taskStageAnomalyCnt
|
|
|
result["taskAnomalyCnt"] = taskAnomalyCnt
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return result, nil
|
|
|
} |
...
|
...
|
|