作者 tangxvhui

更新

... ... @@ -204,7 +204,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
}
}
for _, val := range taskStageList2 {
s := fmt.Sprintf("您下级%s负责的项目【%s】里程碑未按时完成,请前往辅导。", val.LeaderName, val.Name)
s := fmt.Sprintf("【您下级%s负责的项目【%s】里程碑未按时完成,请前往辅导。】", val.LeaderName, val.Name)
msgList = append(msgList, adapter.MessageListAdapter{
Content: s,
})
... ...
... ... @@ -134,6 +134,8 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
// 保存 员工的需要填写的每日任务型 指标项
taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext})
newTaskIdList := []int{}
for i := range assessList {
assessList[i].StaffAssessTaskId = assessTaskData.Id
_, err = assessRepo.Save(&assessList[i])
... ... @@ -156,13 +158,14 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人任务型指标项"+err.Error())
}
err = taskDao.IncreaseAnomaly([]int{val2.TaskId}, 1)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人任务型指标项"+err.Error())
}
newTaskIdList = append(newTaskIdList, val2.TaskId)
}
}
}
err = taskDao.IncreaseAnomaly(newTaskIdList, 1)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人任务型指标项"+err.Error())
}
return map[string]interface{}{
"assessTaskId": assessTaskData.Id,
}, nil
... ...
package adapter
type ConditionSelect struct {
Name string
}
... ...
package command
type GetSelcetCommand struct {
Cmd string `json:"cmd"` // 任务名称,负责人,优先级
UserId int `json:"-"` //当前用户id
CompanyId int `json:"-"` //当前公司id
}
... ...
... ... @@ -8,5 +8,5 @@ type SearchTaskCommand struct {
TaskName string `json:"taskName"` //任务名称
LevelName string `json:"levelName"` //优先级
OnlyMy bool `json:"onlyMy"` //只查看我负责的任务
LeaderId string `json:"leaderId"` //任务负责人id
LeaderName string `json:"leaderId"` //任务负责人id
}
... ...
... ... @@ -681,13 +681,13 @@ func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]i
}
}
condition := dao.ListTaskCondition{
Limit: limit,
Offset: offset,
UserId: param.UserId,
TaskName: param.TaskName,
LevelName: param.LevelName,
OnlyMy: param.OnlyMy,
LeaderId: param.LeaderId,
Limit: limit,
Offset: offset,
UserId: param.UserId,
TaskName: param.TaskName,
LevelName: param.LevelName,
OnlyMy: param.OnlyMy,
LeaderName: param.LeaderName,
}
taskDao := dao.NewTaskDao(map[string]interface{}{
... ... @@ -780,13 +780,13 @@ func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[s
}
}
condition := dao.ListTaskCondition{
Limit: limit,
Offset: offset,
UserId: param.UserId,
TaskName: param.TaskName,
LevelName: param.LevelName,
OnlyMy: param.OnlyMy,
LeaderId: param.LeaderId,
Limit: limit,
Offset: offset,
UserId: param.UserId,
TaskName: param.TaskName,
LevelName: param.LevelName,
OnlyMy: param.OnlyMy,
LeaderName: param.LeaderName,
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -987,7 +987,7 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map
return result, nil
}
// 获取任务详情
// 删除任务
func (srv TaskService) DeleteTaskInfo(param *command.GetTaskCommand) (*adapter.TaskInfoAdapter, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -1022,3 +1022,70 @@ func (srv TaskService) DeleteTaskInfo(param *command.GetTaskCommand) (*adapter.T
}
return nil, nil
}
// 员工绩效-任务管理-列表筛选项
func (srv TaskService) ConditionForListTask2(param *command.GetSelcetCommand) (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()
}()
taskDao := dao.NewTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
})
hrbpFlag, err := roleService.GetHrBp(transactionContext, int(param.CompanyId), int(param.UserId))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
}
var tasklistData []dao.TaskData1
if hrbpFlag == domain.RoleTypeSystem {
tasklistData, err = taskDao.ListTask2ForHrbp(param.UserId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
}
} else {
tasklistData, err = taskDao.ListTask2(param.UserId)
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())
}
selectList := []adapter.ConditionSelect{}
uniqueMap := map[string]struct{}{}
// 任务名称,负责人,优先级
switch param.Cmd {
case "任务名称":
for _, val := range tasklistData {
selectList = append(selectList, adapter.ConditionSelect{Name: val.Name})
}
case "负责人":
for _, val := range tasklistData {
if _, ok := uniqueMap[val.LeaderName]; ok {
continue
}
uniqueMap[val.LeaderName] = struct{}{}
selectList = append(selectList, adapter.ConditionSelect{Name: val.LeaderName})
}
case "优先级":
for _, val := range tasklistData {
if _, ok := uniqueMap[val.LevelName]; ok {
continue
}
uniqueMap[val.LevelName] = struct{}{}
if len(val.LevelName) > 0 {
selectList = append(selectList, adapter.ConditionSelect{Name: val.LevelName})
}
}
}
result := map[string]interface{}{
"list": selectList,
}
return result, nil
}
... ...
... ... @@ -26,7 +26,7 @@ type TaskRecord struct {
TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`
AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
AssistContent string `json:"assistContent" comment:"上级辅导内容"`
AnomalyState int `json:"anomalyState" comment:"异常反馈状态(0异常、1正常)"`
AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(0异常、1正常)"`
TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"`
TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"`
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
... ...
... ... @@ -60,13 +60,13 @@ func (d *TaskDao) catchTaskIdByPermission(userId int) string {
}
type ListTaskCondition struct {
Limit int //分页
Offset int //分页
UserId int //谁要查看任务数据
TaskName string //任务名称
LevelName string //优先级
OnlyMy bool //只查看我负责的任务
LeaderId string //任务负责人id
Limit int //分页
Offset int //分页
UserId int //谁要查看任务数据
TaskName string //任务名称
LevelName string //优先级
OnlyMy bool //只查看我负责的任务
LeaderName string //任务负责人名称
}
// 任务和里程碑列表
... ... @@ -161,9 +161,9 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and t_task_tage_1.leader_id = '?' `
} else if param.LeaderId != "" && param.LeaderId != "0" {
condition = append(condition, param.LeaderId)
whereSql += ` and t_task_tage_1.leader_id = ? `
} else if param.LeaderName != "" {
condition = append(condition, param.LeaderName)
whereSql += ` and t_task_tage_1.leader_name = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
... ... @@ -192,9 +192,9 @@ func (d *TaskDao) CountTaskStageNotHrbp(param ListTaskCondition) (int, error) {
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and task.leader ->>'id' = '?' `
} else if param.LeaderId != "" && param.LeaderId != "0" {
condition = append(condition, param.LeaderId)
whereSql += ` and task.leader ->>'id' = ? `
} else if param.LeaderName != "" {
condition = append(condition, param.LeaderName)
whereSql += ` and task.leader ->>'name' = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
... ... @@ -285,9 +285,9 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and t_task_tage_1.leader_id = '?' `
} else if param.LeaderId != "" && param.LeaderId != "0" {
condition = append(condition, param.LeaderId)
whereSql += ` and t_task_tage_1.leader_id = ? `
} else if param.LeaderName != "" {
condition = append(condition, param.LeaderName)
whereSql += ` and t_task_tage_1.leader_name = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
... ... @@ -319,9 +319,9 @@ func (d *TaskDao) CountTaskStageByHrbp(param ListTaskCondition) (int, error) {
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and task.leader ->>'id' = '?' `
} else if param.LeaderId != "" && param.LeaderId != "0" {
condition = append(condition, param.LeaderId)
whereSql += ` and task.leader ->>'id' = ? `
} else if param.LeaderName != "" {
condition = append(condition, param.LeaderName)
whereSql += ` and task.leader ->>'name' = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
... ... @@ -356,9 +356,9 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and task.leader ->>'id' = '?' `
} else if param.LeaderId != "" && param.LeaderId != "0" {
condition = append(condition, param.LeaderId)
whereSql += ` and task.leader ->>'id' = ? `
} else if param.LeaderName != "" {
condition = append(condition, param.LeaderName)
whereSql += ` and task.leader ->>'name' = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
... ... @@ -395,9 +395,9 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and task.leader ->>'id' = '?' `
} else if param.LeaderId != "" && param.LeaderId != "0" {
condition = append(condition, param.LeaderId)
whereSql += ` and task.leader ->>'id' = ? `
} else if param.LeaderName != "" {
condition = append(condition, param.LeaderName)
whereSql += ` and task.leader ->>'name' = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
... ... @@ -474,8 +474,8 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error)
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and task.leader ->>'id' = '?' `
} else if param.LeaderId != "" {
condition = append(condition, param.LeaderId)
} else if param.LeaderName != "" {
condition = append(condition, param.LeaderName)
whereSql += ` and task.leader ->>'id' = ? `
}
if len(param.TaskName) > 0 {
... ... @@ -507,8 +507,8 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) {
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and task.leader ->>'id' = '?' `
} else if param.LeaderId != "" {
condition = append(condition, param.LeaderId)
} else if param.LeaderName != "" {
condition = append(condition, param.LeaderName)
whereSql += ` and task.leader ->>'id' = ? `
}
if len(param.TaskName) > 0 {
... ... @@ -525,3 +525,45 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) {
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
return cnt, err
}
// 任务数据
type TaskData1 struct {
Name string `pg:"name"`
Alias string `pg:"alias"`
LeaderId string `pg:"leader_id"`
LeaderName string `pg:"leader_name"`
LevelName string `pg:"level_name"`
}
// 获取任务列表
func (d *TaskDao) ListTask2(userId int) ([]TaskData1, error) {
task1 := d.catchTaskIdByPermission(userId)
sqlStr := task1 + ` select task."name" ,task.alias ,
task.leader ->>'id' as leader_id,
task.leader ->>'name' as leaer_name,
task.level_name
from task `
result := []TaskData1{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr)
return result, err
}
// 获取任务列表
func (d *TaskDao) ListTask2ForHrbp(userId int) ([]TaskData1, error) {
sqlStr := `with
t_task_ignore as (
select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
)select task."name" ,task.alias ,
task.leader ->>'id' as leader_id,
task.leader ->>'name' as leaer_name,
task.level_name
from task
left join t_task_ignore on t_task_ignore.task_id=task.id
where 1=1 `
result := []TaskData1{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, userId)
return result, err
}
... ...
... ... @@ -9,20 +9,20 @@ import (
// 任务
type Task struct {
tableName struct{} `comment:"任务" pg:"task"`
Id int `pg:"id,pk"` //
CreatedAt time.Time `pg:"created_at"` //
UpdatedAt time.Time `pg:"updated_at"` //
DeletedAt *time.Time `pg:"deleted_at"` //
Name string `pg:"name"` // 任务名称
Alias string `pg:"alias"` //
CompanyId int `pg:"company_id"` //
Leader domain.TaskLeader `pg:"leader"` // 任务负责人
Status int `pg:"status"` // 任务的状态
Level int `pg:"level"` // 优先级,值越小优先级越高
LevelName string `pg:"level_name"` // 优先级名称
RelatedUser []int `pg:"related_user"` //
RunAt int64 `pg:"run_at"` // 启动的时间
StopAt int64 `pg:"stop_at"` // 停止的时间
Anomaly int `pg:"anomaly"` // 异常反馈的数量
WarnFlag int `pg:"warn_flag"` // 里程碑异常标记
Id int `pg:"id,pk"` //
CreatedAt time.Time `pg:"created_at"` //
UpdatedAt time.Time `pg:"updated_at"` //
DeletedAt *time.Time `pg:"deleted_at"` //
Name string `pg:"name"` // 任务名称
Alias string `pg:"alias"` //
CompanyId int `pg:"company_id"` //
Leader domain.TaskLeader `pg:"leader"` // 任务负责人
Status int `pg:"status,use_zero"` // 任务的状态
Level int `pg:"level,use_zero"` // 优先级,值越小优先级越高
LevelName string `pg:"level_name"` // 优先级名称
RelatedUser []int `pg:"related_user"` //
RunAt int64 `pg:"run_at,use_zero"` // 启动的时间
StopAt int64 `pg:"stop_at,use_zero" ` // 停止的时间
Anomaly int `pg:"anomaly,use_zero"` // 异常反馈的数量
WarnFlag int `pg:"warn_flag,use_zero"` // 里程碑异常标记
}
... ...
... ... @@ -172,3 +172,20 @@ func (c *TaskController) DeleteTask() {
data, err := srv.DeleteTaskInfo(paramReq)
c.Response(data, err)
}
// SelectCondition 员工绩效-任务管理-任务列表-筛选条件
func (c *TaskController) SelectCondition() {
srv := service.NewTaskService()
paramReq := &command.GetSelcetCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.UserId = int(userReq.UserId)
data, err := srv.ConditionForListTask2(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -24,6 +24,7 @@ func init() {
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/attention/cancel", (*controllers.TaskController).CancelAttention),
web.NSCtrlPost("/list", (*controllers.TaskController).ListTask2),
web.NSCtrlPost("/list/select", (*controllers.TaskController).SelectCondition),
web.NSCtrlPost("/task_record/list", (*controllers.TaskController).ListTaskRecord),
web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo),
)
... ...