作者 tangxvhui

Merge branch 'test' into dev-tangxvhui

... ... @@ -525,7 +525,9 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
if project.State == domain.ProjectStateEnable {
return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动")
}
if project.State == domain.ProjectStatePause {
return nil, application.ThrowError(application.BUSINESS_ERROR, "项目暂停中,先进行恢复")
}
// 周期内的所有项目,已启用的员工不能重复被评估
_, projects, err := projectRepository.Find(map[string]interface{}{"companyId": project.CompanyId, "cycleId": project.CycleId}, "template")
if err != nil {
... ... @@ -625,7 +627,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
task.NextSentAt = nil
}
task, err := taskRepository.Insert(task)
_, err := taskRepository.Insert(task)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -871,6 +873,17 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo
}
func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContext application.TransactionContext, project *domain.EvaluationProject) error {
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
var err error
cnt, _, err := itemUsedRepo.Find(map[string]interface{}{"projectId": project.Id})
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, "检查评估选项"+err.Error())
}
if cnt > 0 {
return nil
}
var itemUsedList []*domain.EvaluationItemUsed
nowTime := time.Now()
for _, v := range project.Template.LinkNodes {
... ... @@ -901,10 +914,8 @@ func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContex
itemUsedList = append(itemUsedList, &item)
}
}
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
err := itemUsedRepo.BatchInsert(itemUsedList)
err = itemUsedRepo.BatchInsert(itemUsedList)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -138,8 +138,9 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
return resp, nil
}
userDao := dao.NewUserDao(map[string]interface{}{"transactionContext": transactionContext})
// 针对任务负责人
taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext})
// 我作为任务负责人的提醒
leaderIds := []string{strconv.Itoa(param.UserId)}
taskStageList, err := taskDao.TaskStageAnomaly(leaderIds)
if err != nil {
... ... @@ -155,7 +156,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
childUserId = append(childUserId, strconv.Itoa(val.Id))
}
}
// 针对上级
// 作为上级,我的下级员工的异常里程碑
var taskStageList2 []dao.TaskStageData
if len(childUserId) == 0 {
taskStageList2, err = taskDao.TaskStageAnomaly(childUserId)
... ... @@ -169,7 +170,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
childUserId = append(childUserId, strconv.Itoa(val.Id))
}
}
// 针对上上级
// 作为上级, 我的下下级员工的异常里程碑
var taskStageList3 []dao.TaskStageData
if len(childUserId) == 0 {
taskStageList3, err = taskDao.TaskStageAnomaly(childUserId2)
... ...
... ... @@ -431,8 +431,6 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取项目EvaluationProject信息"+err.Error())
}
// projectData.PrincipalId
userIdstr := strconv.Itoa(staffAssess.Executor.UserId)
if projectData.PrincipalId != userIdstr {
return nil, nil
... ... @@ -454,6 +452,7 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess)
_, taskList, err := taskRepo.Find(map[string]interface{}{
"name": val.Name,
"leaderId": projectData.PrincipalId,
"status": domain.TaskRunning,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取评估项指标任务task信息"+err.Error())
... ...
... ... @@ -699,14 +699,17 @@ func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]i
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.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())
... ...
... ... @@ -125,7 +125,7 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
join t_task_1 on task.id=t_task_1.id
join task_stage on task.id =task_stage.task_id
where 1=1 and task.company_id=?
order by diff_time,task."level",task.created_at
order by diff_time,task."level",task.created_at desc
),
-- 按任务数据分页获取
t_task_page as (
... ... @@ -234,7 +234,7 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
from task
join task_stage on task.id =task_stage.task_id
where 1=1 and task.company_id=?
order by diff_time,task."level",task.created_at
order by diff_time,task."level",task.created_at desc
),
-- 按任务数据分页获取
t_task_page as (
... ... @@ -274,7 +274,7 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
}
if param.SearchWord != "" {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (t_task_tage_1.leader_name like ? or t_task_tage_1.task_alias_name like ?)`
whereSql += ` and (t_task_tage_1.leader_name like ? or t_task_tage_1.task_alias_name like ?) `
}
condition = append(condition, param.Limit, param.Offset)
sqlStr := fmt.Sprintf(withSql, whereSql)
... ... @@ -374,6 +374,9 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err
}
func (d *TaskDao) IncreaseAnomaly(id []int, incr int) error {
if len(id) == 0 {
return nil
}
sqlStr := `update task set anomaly=task.anomaly+?
where id in(?)`
tx := d.transactionContext.PgTx
... ...
... ... @@ -132,6 +132,9 @@ func (repo *TaskRepository) Find(queryOptions map[string]interface{}) (int, []*d
if val, ok := queryOptions["aliasOrLeader"]; ok {
query.Where(`task.alias like ? or task.leader->>'name' like ?`, val, val)
}
if val, ok := queryOptions["status"]; ok {
query.Where("task.status=?", val)
}
query.Order("id desc")
count, err := query.SelectAndCount()
if err != nil {
... ...
... ... @@ -13,7 +13,7 @@ func init() {
web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()),
web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo),
web.NSCtrlPut("/", (*controllers.TaskController).UpdateTask),
web.NSCtrlPost("/delete", (*controllers.TaskController).DeleteTask),
web.NSCtrlPut("/delete", (*controllers.TaskController).DeleteTask),
web.NSCtrlPost("/run", (*controllers.TaskController).RunTask),
web.NSCtrlPost("/stop", (*controllers.TaskController).StopTask),
web.NSCtrlPost("/list", (*controllers.TaskController).ListTask),
... ...