作者 郑周

Merge remote-tracking branch 'origin/test' into test

... ... @@ -165,14 +165,14 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
}
childUserId2 := []string{}
for _, val := range childUser {
if val.Level == 3 {
if val.Level >= 3 {
childUserId = append(childUserId, strconv.Itoa(val.Id))
}
}
// 针对上上级
var taskStageList3 []dao.TaskStageData
if len(childUserId) == 0 {
taskStageList2, err = taskDao.TaskStageAnomaly(childUserId2)
taskStageList3, err = taskDao.TaskStageAnomaly(childUserId2)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())
}
... ... @@ -189,7 +189,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
payloadStr, _ := json.Marshal(payload)
newMessage := domain.MessagePersonal{
Id: 0,
Types: domain.MessageTypesOther,
Types: domain.MessageTypesTaskStage,
TargetUserId: param.UserId,
ReadFlag: domain.MessageIsRead,
Title: s,
... ... @@ -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,
})
... ... @@ -214,7 +214,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
payloadStr, _ := json.Marshal(payload)
newMessage := domain.MessagePersonal{
Id: 0,
Types: domain.MessageTypesOther,
Types: domain.MessageTypesTaskStage,
TargetUserId: param.UserId,
ReadFlag: domain.MessageIsRead,
Title: s,
... ... @@ -239,7 +239,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
payloadStr, _ := json.Marshal(payload)
newMessage := domain.MessagePersonal{
Id: 0,
Types: domain.MessageTypesOther,
Types: domain.MessageTypesTaskStage,
TargetUserId: param.UserId,
ReadFlag: domain.MessageIsRead,
Title: s,
... ... @@ -320,7 +320,7 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
}
}
// 针对上级
var taskStageList2 []dao.TaskStageData
var taskStageList2 []dao.TaskData2
if len(childUserId) == 0 {
taskStageList2, err = taskDao.TaskAnomaly(childUserId, 4)
if err != nil {
... ... @@ -329,14 +329,14 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
}
childUserId2 := []string{}
for _, val := range childUser {
if val.Level == 3 {
if val.Level >= 3 {
childUserId = append(childUserId, strconv.Itoa(val.Id))
}
}
// 针对上上级
var taskStageList3 []dao.TaskStageData
var taskStageList3 []dao.TaskData2
if len(childUserId) == 0 {
taskStageList2, err = taskDao.TaskAnomaly(childUserId2, 5)
taskStageList3, err = taskDao.TaskAnomaly(childUserId2, 5)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())
}
... ... @@ -354,7 +354,7 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
payloadStr, _ := json.Marshal(payload)
newMessage := domain.MessagePersonal{
Id: 0,
Types: domain.MessageTypesOther,
Types: domain.MessageTypesTaskRecord,
TargetUserId: param.UserId,
ReadFlag: domain.MessageIsRead,
Title: s,
... ... @@ -379,7 +379,7 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
payloadStr, _ := json.Marshal(payload)
newMessage := domain.MessagePersonal{
Id: 0,
Types: domain.MessageTypesOther,
Types: domain.MessageTypesTaskRecord,
TargetUserId: param.UserId,
ReadFlag: domain.MessageIsRead,
Title: s,
... ... @@ -404,7 +404,7 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
payloadStr, _ := json.Marshal(payload)
newMessage := domain.MessagePersonal{
Id: 0,
Types: domain.MessageTypesOther,
Types: domain.MessageTypesTaskRecord,
TargetUserId: param.UserId,
ReadFlag: domain.MessageIsRead,
Title: 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
}
... ...
... ... @@ -5,8 +5,9 @@ type SearchTaskCommand struct {
CompanyId int `json:"-"`
PageNumber int `json:"pageNumber"` //分页
PageSize int `json:"pageSize"` //分页
TaskName string `json:"taskName"` //任务名称
LevelName string `json:"levelName"` //优先级
OnlyMy bool `json:"onlyMy"` //只查看我负责的任务
LeaderId string `json:"leaderId"` //任务负责人id
SearchWord string `json:"searchWord"`
// TaskName string `json:"taskName"` //任务名称
// LevelName string `json:"levelName"` //优先级
// LeaderName string `json:"leaderId"` //任务负责人id
}
... ...
... ... @@ -555,13 +555,16 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte
for _, val := range taskList {
taskIdList = append(taskIdList, val.Id)
}
_, stageList, err := taskStageRepo.Find(map[string]interface{}{
"taskIdList": taskIdList,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询任务阶段数据"+err.Error())
var stageList []*domain.TaskStage
if len(taskIdList) > 0 {
_, stageList, err = taskStageRepo.Find(map[string]interface{}{
"taskIdList": taskIdList,
})
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())
}
... ... @@ -668,6 +671,9 @@ func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]i
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
... ... @@ -681,13 +687,12 @@ 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,
CompanyId: param.CompanyId,
OnlyMy: param.OnlyMy,
SearchWord: param.SearchWord,
}
taskDao := dao.NewTaskDao(map[string]interface{}{
... ... @@ -780,13 +785,12 @@ 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,
CompanyId: param.CompanyId,
OnlyMy: param.OnlyMy,
SearchWord: param.SearchWord,
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -987,7 +991,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 +1026,74 @@ 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, param.CompanyId)
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 {
if _, ok := uniqueMap[val.Name]; ok {
continue
}
uniqueMap[val.Name] = struct{}{}
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:"创建时间"`
... ...
... ... @@ -9,8 +9,8 @@ import (
func TestGenerateToken(t *testing.T) {
ut := UserAuth{
CompanyId: 8,
UserId: 3438641393081088,
Phone: "17711111111",
UserId: 3422174102828544,
Phone: "17708397664",
PlatformId: 29,
AdminType: 1,
}
... ...
... ... @@ -60,13 +60,12 @@ 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 //分页
CompanyId int //公司id
UserId int //谁要查看任务数据
OnlyMy bool //只查看我负责的任务
SearchWord string
}
// 任务和里程碑列表
... ... @@ -125,7 +124,7 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
from task
join t_task_1 on task.id=t_task_1.id
join task_stage on task.id =task_stage.task_id
where 1=1
where 1=1 and task.company_id=?
order by diff_time,task."level",task.created_at
),
-- 按任务数据分页获取
... ... @@ -156,22 +155,15 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
where t_task_tage_1.task_id in(
select t_task_page.task_id from t_task_page
)`
condition := []interface{}{}
condition := []interface{}{param.CompanyId}
whereSql := ``
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 = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
whereSql += ` and t_task_tage_1.task_name like ? `
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and t_task_tage_1.level_name like ? `
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 ?)`
}
condition = append(condition, param.Limit, param.Offset)
sqlStr := fmt.Sprintf(withSql, whereSql)
... ... @@ -186,24 +178,18 @@ func (d *TaskDao) CountTaskStageNotHrbp(param ListTaskCondition) (int, error) {
task1 := d.catchTaskIdByPermission(param.UserId)
withSql := task1 + `select count(*) from task
join t_task_1 on task.id =t_task_1.id
where 1=1 `
condition := []interface{}{}
where 1=1 and task.company_id=?`
condition := []interface{}{param.CompanyId}
whereSql := ``
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' = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
whereSql += ` and task.name like ? `
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name like ? `
if param.SearchWord != "" {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
var cnt int
... ... @@ -247,7 +233,7 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
end) as diff_time
from task
join task_stage on task.id =task_stage.task_id
where 1=1
where 1=1 and task.company_id=?
order by diff_time,task."level",task.created_at
),
-- 按任务数据分页获取
... ... @@ -280,22 +266,15 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
where t_task_tage_1.task_id in(
select t_task_page.task_id from t_task_page
)`
condition := []interface{}{param.UserId}
condition := []interface{}{param.UserId, param.CompanyId}
whereSql := ``
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 = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
whereSql += ` and t_task_tage_1.task_name like ? `
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and t_task_tage_1.level_name like ? `
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 ?)`
}
condition = append(condition, param.Limit, param.Offset)
sqlStr := fmt.Sprintf(withSql, whereSql)
... ... @@ -313,23 +292,16 @@ func (d *TaskDao) CountTaskStageByHrbp(param ListTaskCondition) (int, error) {
select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
)select count(*) from task
left join t_task_ignore on t_task_ignore.task_id=task.id
where 1=1 `
condition := []interface{}{param.UserId}
where 1=1 and task.company_id=?`
condition := []interface{}{param.UserId, param.CompanyId}
whereSql := ``
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' = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
whereSql += ` and task.name like ? `
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name like ? `
if param.SearchWord != "" {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
... ... @@ -345,28 +317,21 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er
from task_stage
join task on task_stage.task_id =task.id
join t_task_1 on task.id =t_task_1.id
where 1=1
where 1=1 and task.company_id=?
and(
(task_stage.plan_completed_at <task_stage.real_completed_at)
or
(task_stage.real_completed_at=0 and task_stage.plan_completed_at<extract(epoch from now()))
) `
condition := []interface{}{}
condition := []interface{}{param.CompanyId}
whereSql := ``
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' = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
whereSql += ` and task.name like ? `
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name like ? `
if param.SearchWord != "" {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
... ... @@ -384,29 +349,23 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err
from task_stage
join task on task_stage.task_id =task.id
left join t_task_ignore on t_task_ignore.task_id=task.id
where 1=1
where 1=1 and task.company_id=?
and(
(task_stage.plan_completed_at <task_stage.real_completed_at)
or
(task_stage.real_completed_at=0 and task_stage.plan_completed_at<extract(epoch from now()))
) `
condition := []interface{}{param.UserId}
condition := []interface{}{param.UserId, param.CompanyId}
whereSql := ``
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' = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
whereSql += ` and task.name like ? `
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name like ? `
if param.SearchWord != "" {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
var cnt int
... ... @@ -446,16 +405,25 @@ func (d *TaskDao) TaskStageAnomaly(leaderId []string) ([]TaskStageData, error) {
return result, err
}
// 异常的里程碑任务
func (d *TaskDao) TaskAnomaly(leaderId []string, anomaly int) ([]TaskStageData, error) {
type TaskData2 struct {
Id int `pg:"id"`
Name string `pg:"name"`
Alias string `pg:"alias"`
LeaderName string `pg:"leader_name"`
Anomaly string `pg:"anomaly"`
}
// 异常的任务
func (d *TaskDao) TaskAnomaly(leaderId []string, anomaly int) ([]TaskData2, error) {
sqlStr := `select
task."id",
task."name" ,
task.alias ,
task.leader ->>'name' as leader_name,
task.anomaly
from task
where task.anomaly >=? and task.leader ->'id' in(?) `
result := []TaskStageData{}
where task.anomaly >=? and task.leader ->>'id' in(?) `
result := []TaskData2{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, anomaly, pg.In(leaderId))
return result, err
... ... @@ -474,17 +442,10 @@ 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)
whereSql += ` and task.leader ->>'id' = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
whereSql += ` and task.name like ? `
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name like ? `
if param.SearchWord != "" {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
... ... @@ -501,23 +462,16 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) {
)select count(*)
from task
left join t_task_ignore on t_task_ignore.task_id=task.id
where 1=1 and task.anomaly>1 `
condition := []interface{}{param.UserId}
where 1=1 and task.anomaly>1 and task.company_id=?`
condition := []interface{}{param.UserId, param.CompanyId}
whereSql := ``
if param.OnlyMy {
condition = append(condition, param.UserId)
whereSql += ` and task.leader ->>'id' = '?' `
} else if param.LeaderId != "" {
condition = append(condition, param.LeaderId)
whereSql += ` and task.leader ->>'id' = ? `
}
if len(param.TaskName) > 0 {
condition = append(condition, param.TaskName)
whereSql += ` and task.name like ? `
}
if len(param.LevelName) > 0 {
condition = append(condition, param.LevelName)
whereSql += ` and task.level_name like ? `
if param.SearchWord != "" {
condition = append(condition, param.SearchWord, param.SearchWord)
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
... ... @@ -525,3 +479,47 @@ 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 leader_name,
task.level_name
from task
join t_task_1 on task.id =t_task_1.id
`
result := []TaskData1{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr)
return result, err
}
// 获取任务列表
func (d *TaskDao) ListTask2ForHrbp(userId int, companyId 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 leader_name,
task.level_name
from task
left join t_task_ignore on t_task_ignore.task_id=task.id
where 1=1 and task.company_id=? `
result := []TaskData1{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, userId, companyId)
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),
)
... ...