...
|
...
|
@@ -746,237 +746,237 @@ func (srv TaskService) CancelAttention(param *command.CancelAttentionCommand) er |
|
|
}
|
|
|
|
|
|
// 员工绩效-任务管理-列表
|
|
|
func (srv TaskService) ListTask2(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.listTask2ForHrbp(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,
|
|
|
}
|
|
|
// func (srv TaskService) ListTask2(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.listTask2ForHrbp(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.ListTaskStageNotHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
|
|
|
}
|
|
|
//查到的任务数据总数
|
|
|
taskCount, err := taskDao.CountTaskNotHrbp(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())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// taskDao := dao.NewTaskDao(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// //任务列表数据
|
|
|
// tasklistData, err := taskDao.ListTaskStageNotHrbp(condition)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
|
|
|
// }
|
|
|
// //查到的任务数据总数
|
|
|
// taskCount, err := taskDao.CountTaskNotHrbp(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())
|
|
|
// }
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
|
|
|
taskResult := []*adapter.TaskItem{}
|
|
|
taskMapResult := map[int]*adapter.TaskItem{}
|
|
|
for _, val := range tasklistData {
|
|
|
if _, ok := taskMapResult[val.TaskId]; ok {
|
|
|
continue
|
|
|
}
|
|
|
tk := adapter.TaskItem{
|
|
|
Id: val.TaskId,
|
|
|
Name: val.TaskName,
|
|
|
Alias: val.TaskAliasName,
|
|
|
Leader: val.LeaderName,
|
|
|
Status: val.TaskStatus,
|
|
|
Level: val.Level,
|
|
|
LevelName: val.LevelName,
|
|
|
UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
Anomaly: val.Anomaly,
|
|
|
WarnFlag: val.WarnFlag,
|
|
|
}
|
|
|
taskMapResult[val.TaskId] = &tk
|
|
|
taskResult = append(taskResult, &tk)
|
|
|
}
|
|
|
for _, val := range tasklistData {
|
|
|
taskData, ok := taskMapResult[val.TaskId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
stage := adapter.TaskStage{
|
|
|
Id: val.StageId,
|
|
|
Name: val.StageName,
|
|
|
SortBy: val.StageSortBy,
|
|
|
PlanCompletedAt: time.Unix(int64(val.PlanCompletedAt), 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
}
|
|
|
if val.RealCompletedAt > 0 {
|
|
|
stage.RealCompletedAt = time.Unix(int64(val.RealCompletedAt), 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
switch val.StageSortBy {
|
|
|
case 1:
|
|
|
taskData.StageA = stage
|
|
|
case 2:
|
|
|
taskData.StageB = stage
|
|
|
case 3:
|
|
|
taskData.StageC = stage
|
|
|
case 4:
|
|
|
taskData.StageD = stage
|
|
|
case 5:
|
|
|
taskData.StageE = stage
|
|
|
}
|
|
|
// taskResult := []*adapter.TaskItem{}
|
|
|
// taskMapResult := map[int]*adapter.TaskItem{}
|
|
|
// for _, val := range tasklistData {
|
|
|
// if _, ok := taskMapResult[val.TaskId]; ok {
|
|
|
// continue
|
|
|
// }
|
|
|
// tk := adapter.TaskItem{
|
|
|
// Id: val.TaskId,
|
|
|
// Name: val.TaskName,
|
|
|
// Alias: val.TaskAliasName,
|
|
|
// Leader: val.LeaderName,
|
|
|
// Status: val.TaskStatus,
|
|
|
// Level: val.Level,
|
|
|
// LevelName: val.LevelName,
|
|
|
// UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
// Anomaly: val.Anomaly,
|
|
|
// WarnFlag: val.WarnFlag,
|
|
|
// }
|
|
|
// taskMapResult[val.TaskId] = &tk
|
|
|
// taskResult = append(taskResult, &tk)
|
|
|
// }
|
|
|
// for _, val := range tasklistData {
|
|
|
// taskData, ok := taskMapResult[val.TaskId]
|
|
|
// if !ok {
|
|
|
// continue
|
|
|
// }
|
|
|
// stage := adapter.TaskStage{
|
|
|
// Id: val.StageId,
|
|
|
// Name: val.StageName,
|
|
|
// SortBy: val.StageSortBy,
|
|
|
// PlanCompletedAt: time.Unix(int64(val.PlanCompletedAt), 0).Local().Format("2006-01-02"),
|
|
|
// RealCompletedAt: "",
|
|
|
// }
|
|
|
// if val.RealCompletedAt > 0 {
|
|
|
// stage.RealCompletedAt = time.Unix(int64(val.RealCompletedAt), 0).Local().Format("2006-01-02")
|
|
|
// }
|
|
|
// switch val.StageSortBy {
|
|
|
// case 1:
|
|
|
// taskData.StageA = stage
|
|
|
// case 2:
|
|
|
// taskData.StageB = stage
|
|
|
// case 3:
|
|
|
// taskData.StageC = stage
|
|
|
// case 4:
|
|
|
// taskData.StageD = stage
|
|
|
// case 5:
|
|
|
// taskData.StageE = stage
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
|
|
result["taskStageAnomaly"] = taskStageAnomalyCnt
|
|
|
result["taskAnomalyCnt"] = taskAnomalyCnt
|
|
|
return result, nil
|
|
|
}
|
|
|
// }
|
|
|
// result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
|
|
// result["taskStageAnomaly"] = taskStageAnomalyCnt
|
|
|
// result["taskAnomalyCnt"] = taskAnomalyCnt
|
|
|
// return result, nil
|
|
|
// }
|
|
|
|
|
|
// 以hrbp角色权限获取任务列表
|
|
|
// 统计里程碑异常数,反馈异常数
|
|
|
func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) {
|
|
|
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,
|
|
|
}
|
|
|
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()
|
|
|
}()
|
|
|
taskDao := dao.NewTaskDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
tasklistData, err := taskDao.ListTaskStageByHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
|
|
|
}
|
|
|
taskCount, err := taskDao.CountTaskByHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
|
|
|
}
|
|
|
taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyByHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
}
|
|
|
taskAnomalyCnt, err := taskDao.CountTaskAnomalyByHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
taskResult := []*adapter.TaskItem{}
|
|
|
taskMapResult := map[int]*adapter.TaskItem{}
|
|
|
for _, val := range tasklistData {
|
|
|
if _, ok := taskMapResult[val.TaskId]; ok {
|
|
|
continue
|
|
|
}
|
|
|
tk := adapter.TaskItem{
|
|
|
Id: val.TaskId,
|
|
|
Name: val.TaskName,
|
|
|
Alias: val.TaskAliasName,
|
|
|
Leader: val.LeaderName,
|
|
|
Status: val.TaskStatus,
|
|
|
Level: val.Level,
|
|
|
LevelName: val.LevelName,
|
|
|
UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
Anomaly: val.Anomaly,
|
|
|
WarnFlag: val.WarnFlag,
|
|
|
// StageA: adapter.TaskStage{},
|
|
|
// StageB: adapter.TaskStage{},
|
|
|
// StageC: adapter.TaskStage{},
|
|
|
// StageD: adapter.TaskStage{},
|
|
|
// StageE: adapter.TaskStage{},
|
|
|
}
|
|
|
taskMapResult[val.TaskId] = &tk
|
|
|
taskResult = append(taskResult, &tk)
|
|
|
}
|
|
|
for _, val := range tasklistData {
|
|
|
taskData, ok := taskMapResult[val.TaskId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
stage := adapter.TaskStage{
|
|
|
Id: val.StageId,
|
|
|
Name: val.StageName,
|
|
|
SortBy: val.StageSortBy,
|
|
|
PlanCompletedAt: time.Unix(int64(val.PlanCompletedAt), 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
}
|
|
|
if val.RealCompletedAt > 0 {
|
|
|
stage.RealCompletedAt = time.Unix(int64(val.RealCompletedAt), 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
switch val.StageSortBy {
|
|
|
case 1:
|
|
|
taskData.StageA = stage
|
|
|
case 2:
|
|
|
taskData.StageB = stage
|
|
|
case 3:
|
|
|
taskData.StageC = stage
|
|
|
case 4:
|
|
|
taskData.StageD = stage
|
|
|
case 5:
|
|
|
taskData.StageE = stage
|
|
|
}
|
|
|
}
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
|
|
result["taskStageAnomaly"] = taskStageAnomalyCnt
|
|
|
result["taskAnomalyCnt"] = taskAnomalyCnt
|
|
|
return result, nil
|
|
|
}
|
|
|
// func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) {
|
|
|
// 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,
|
|
|
// }
|
|
|
// 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()
|
|
|
// }()
|
|
|
// taskDao := dao.NewTaskDao(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// tasklistData, err := taskDao.ListTaskStageByHrbp(condition)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
|
|
|
// }
|
|
|
// taskCount, err := taskDao.CountTaskByHrbp(condition)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
|
|
|
// }
|
|
|
// taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyByHrbp(condition)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
// }
|
|
|
// taskAnomalyCnt, err := taskDao.CountTaskAnomalyByHrbp(condition)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
|
|
|
// }
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// taskResult := []*adapter.TaskItem{}
|
|
|
// taskMapResult := map[int]*adapter.TaskItem{}
|
|
|
// for _, val := range tasklistData {
|
|
|
// if _, ok := taskMapResult[val.TaskId]; ok {
|
|
|
// continue
|
|
|
// }
|
|
|
// tk := adapter.TaskItem{
|
|
|
// Id: val.TaskId,
|
|
|
// Name: val.TaskName,
|
|
|
// Alias: val.TaskAliasName,
|
|
|
// Leader: val.LeaderName,
|
|
|
// Status: val.TaskStatus,
|
|
|
// Level: val.Level,
|
|
|
// LevelName: val.LevelName,
|
|
|
// UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
// Anomaly: val.Anomaly,
|
|
|
// WarnFlag: val.WarnFlag,
|
|
|
// // StageA: adapter.TaskStage{},
|
|
|
// // StageB: adapter.TaskStage{},
|
|
|
// // StageC: adapter.TaskStage{},
|
|
|
// // StageD: adapter.TaskStage{},
|
|
|
// // StageE: adapter.TaskStage{},
|
|
|
// }
|
|
|
// taskMapResult[val.TaskId] = &tk
|
|
|
// taskResult = append(taskResult, &tk)
|
|
|
// }
|
|
|
// for _, val := range tasklistData {
|
|
|
// taskData, ok := taskMapResult[val.TaskId]
|
|
|
// if !ok {
|
|
|
// continue
|
|
|
// }
|
|
|
// stage := adapter.TaskStage{
|
|
|
// Id: val.StageId,
|
|
|
// Name: val.StageName,
|
|
|
// SortBy: val.StageSortBy,
|
|
|
// PlanCompletedAt: time.Unix(int64(val.PlanCompletedAt), 0).Local().Format("2006-01-02"),
|
|
|
// RealCompletedAt: "",
|
|
|
// }
|
|
|
// if val.RealCompletedAt > 0 {
|
|
|
// stage.RealCompletedAt = time.Unix(int64(val.RealCompletedAt), 0).Local().Format("2006-01-02")
|
|
|
// }
|
|
|
// switch val.StageSortBy {
|
|
|
// case 1:
|
|
|
// taskData.StageA = stage
|
|
|
// case 2:
|
|
|
// taskData.StageB = stage
|
|
|
// case 3:
|
|
|
// taskData.StageC = stage
|
|
|
// case 4:
|
|
|
// taskData.StageD = stage
|
|
|
// case 5:
|
|
|
// taskData.StageE = stage
|
|
|
// }
|
|
|
// }
|
|
|
// result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
|
|
// result["taskStageAnomaly"] = taskStageAnomalyCnt
|
|
|
// result["taskAnomalyCnt"] = taskAnomalyCnt
|
|
|
// return result, nil
|
|
|
// }
|
|
|
|
|
|
// ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑
|
|
|
func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord, isFirstSubmit bool) error {
|
...
|
...
|
|