...
|
...
|
@@ -73,7 +73,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询任务失败:"+err.Error())
|
|
|
}
|
|
|
if cnt > 0 {
|
|
|
//TODO
|
|
|
|
|
|
//任务已存在
|
|
|
return nil
|
|
|
}
|
...
|
...
|
@@ -172,11 +172,11 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
if len(param.StageList) < 3 {
|
|
|
return map[string]interface{}{
|
|
|
"id": param.Id,
|
|
|
}, application.ThrowError(application.INTERNAL_SERVER_ERROR, "里程碑数量至少3个")
|
|
|
}
|
|
|
// if len(param.StageList) < 3 {
|
|
|
// return map[string]interface{}{
|
|
|
// "id": param.Id,
|
|
|
// }, application.ThrowError(application.INTERNAL_SERVER_ERROR, "里程碑数量至少3个")
|
|
|
// }
|
|
|
if len(param.StageList) > 5 {
|
|
|
return map[string]interface{}{
|
|
|
"id": param.Id,
|
...
|
...
|
@@ -213,30 +213,14 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
if len(relatedUserIds) > 0 {
|
|
|
_, relatedUser, err = userRepo.Find(map[string]interface{}{
|
|
|
"ids": relatedUserIds,
|
|
|
"companyId": param.CompanyId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的相关人员"+err.Error())
|
|
|
}
|
|
|
}
|
|
|
_, leaderList, err := userRepo.Find(map[string]interface{}{
|
|
|
"id": taskData.Leader.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询人员失败:"+err.Error())
|
|
|
}
|
|
|
if len(leaderList) == 0 {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有查询到人员")
|
|
|
}
|
|
|
leaderData := leaderList[0]
|
|
|
//更新相关人员
|
|
|
taskData.RelatedUser = []int{int(leaderData.Id)}
|
|
|
if leaderData.ParentId != 0 {
|
|
|
taskData.RelatedUser = append(taskData.RelatedUser, int(leaderData.ParentId))
|
|
|
}
|
|
|
taskData.RelatedUser = []int{}
|
|
|
for _, val := range relatedUser {
|
|
|
if val.Id == leaderData.Id || val.Id == leaderData.ParentId {
|
|
|
continue
|
|
|
}
|
|
|
taskData.RelatedUser = append(taskData.RelatedUser, int(val.Id))
|
|
|
}
|
|
|
//更新任务名称
|
...
|
...
|
@@ -314,7 +298,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
}
|
|
|
taskData.SetCurrentStage(stageList)
|
|
|
taskData.SetSortBy(param.SortBy)
|
|
|
taskData.EndTime = param.EndTime
|
|
|
//处理endTime
|
|
|
taskData.EndTime = dayEndTime(time.Unix(param.EndTime, 10)).Unix()
|
|
|
taskData.UseEndTime = param.UseEndtime
|
|
|
err = taskRepo.Save(taskData)
|
|
|
if err != nil {
|
...
|
...
|
@@ -323,7 +308,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//更具markStage 记录的里程碑数据生成通知
|
|
|
//根据markStage 记录的里程碑数据生成通知
|
|
|
for _, val := range markStage {
|
|
|
for _, val2 := range taskData.RelatedUser {
|
|
|
t1 := time.Unix(val.PlanCompletedAt, 0).Format("2006-01-02")
|
...
|
...
|
@@ -486,8 +471,11 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task |
|
|
},
|
|
|
Status: int(taskData.Status),
|
|
|
StatusDescription: taskData.StatusDescription(),
|
|
|
Level: taskData.Level,
|
|
|
// Level: taskData.Level,
|
|
|
LevelName: taskData.LevelName,
|
|
|
SortBy: int(taskData.SortBy),
|
|
|
EndTime: taskData.EndTime,
|
|
|
UseEndtime: taskData.UseEndTime,
|
|
|
RelatedUserId: []string{},
|
|
|
RelatedUser: []adapter.UserData{},
|
|
|
StageList: []adapter.TaskStage{},
|
...
|
...
|
@@ -910,6 +898,22 @@ func (srv TaskService) DeleteTaskInfo(param *command.GetTaskCommand) (*adapter.T |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error())
|
|
|
}
|
|
|
|
|
|
taskIgnoreRepo := factory.CreateTaskIgnoreRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, taskIgnoreList, err := taskIgnoreRepo.Find(map[string]interface{}{
|
|
|
"taskId": param.TaskId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error())
|
|
|
}
|
|
|
for _, v := range taskIgnoreList {
|
|
|
err = taskIgnoreRepo.Remove(v.Id)
|
|
|
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())
|
|
|
}
|
...
|
...
|
@@ -1026,6 +1030,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i |
|
|
CompanyId: param.CompanyId,
|
|
|
OnlyMy: param.OnlyMy,
|
|
|
SearchWord: param.SearchWord,
|
|
|
LevelName: param.LevelName,
|
|
|
}
|
|
|
|
|
|
taskDao := dao.NewTaskDao(map[string]interface{}{
|
...
|
...
|
@@ -1041,7 +1046,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
|
|
|
}
|
|
|
//里程碑异常s
|
|
|
//里程碑异常
|
|
|
taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计异常的任务里程碑总数"+err.Error())
|
...
|
...
|
@@ -1172,6 +1177,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s |
|
|
CompanyId: param.CompanyId,
|
|
|
OnlyMy: param.OnlyMy,
|
|
|
SearchWord: param.SearchWord,
|
|
|
LevelName: param.LevelName,
|
|
|
}
|
|
|
|
|
|
taskDao := dao.NewTaskDao(map[string]interface{}{
|
...
|
...
|
@@ -1321,3 +1327,174 @@ func (srv TaskService) ListTaskLevel(companyId int) (map[string]interface{}, err |
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 取消关注的任务列表
|
|
|
func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result map[string]interface{}, err 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
|
|
|
}
|
|
|
}
|
|
|
param.SearchWord = strings.TrimSpace(param.SearchWord)
|
|
|
if len(param.SearchWord) > 0 {
|
|
|
param.SearchWord = "%" + param.SearchWord + "%"
|
|
|
}
|
|
|
condition := dao.ListTaskCondition{
|
|
|
Limit: limit,
|
|
|
Offset: offset,
|
|
|
UserId: param.UserId,
|
|
|
CompanyId: param.CompanyId,
|
|
|
OnlyMy: param.OnlyMy,
|
|
|
SearchWord: param.SearchWord,
|
|
|
LevelName: param.LevelName,
|
|
|
}
|
|
|
|
|
|
taskDao := dao.NewTaskDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//任务列表数据
|
|
|
taskListData, err := taskDao.ListTaskIgnore(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
|
|
|
}
|
|
|
//查到的任务数据总数
|
|
|
taskCount, err := taskDao.CountTaskIgnore(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,
|
|
|
})
|
|
|
nowTime := time.Now().Unix()
|
|
|
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,
|
|
|
LastStage: adapter.TaskStage{
|
|
|
Id: val.LastStage.Id,
|
|
|
Name: val.LastStage.Name,
|
|
|
StatusDescription: val.LastStage.StatusDescription(),
|
|
|
SortBy: val.LastStage.SortBy,
|
|
|
PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
IsRef: false,
|
|
|
},
|
|
|
CurrentStage: adapter.TaskStage{
|
|
|
Id: val.CurrentStage.Id,
|
|
|
Name: val.CurrentStage.Name,
|
|
|
StatusDescription: val.CurrentStage.StatusDescription(),
|
|
|
SortBy: val.CurrentStage.SortBy,
|
|
|
PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
IsRef: false,
|
|
|
},
|
|
|
}
|
|
|
if val.LastStage.RealCompletedAt > 0 {
|
|
|
tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
if val.CurrentStage.RealCompletedAt > 0 {
|
|
|
tk.CurrentStage.RealCompletedAt = time.Unix(int64(val.CurrentStage.RealCompletedAt), 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
if val.LastStage.Id > 0 && val.LastStage.PlanCompletedAt < val.LastStage.RealCompletedAt {
|
|
|
tk.WarnFlag = int(domain.TaskWarn)
|
|
|
}
|
|
|
if val.CurrentStage.Id > 0 && val.CurrentStage.PlanCompletedAt < nowTime {
|
|
|
tk.WarnFlag = int(domain.TaskWarn)
|
|
|
}
|
|
|
_, 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)
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
result = tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 从取消关注的列表中移除数据
|
|
|
func (srv *TaskService) CancleTaskIgnore(param *command.CancelIgnoreCommand) (result map[string]interface{}, err 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()
|
|
|
}()
|
|
|
|
|
|
taskIgnoreRepo := factory.CreateTaskIgnoreRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, taskIgnoreList, err := taskIgnoreRepo.Find(map[string]interface{}{
|
|
|
"userId": param.UserId,
|
|
|
"taskId": param.TaskId,
|
|
|
})
|
|
|
if len(taskIgnoreList) == 0 {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
err = taskIgnoreRepo.Remove(taskIgnoreList[0].Id)
|
|
|
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())
|
|
|
}
|
|
|
return nil, nil
|
|
|
} |
...
|
...
|
|