切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
郑周
2 years ago
提交
ca22f2bae59dc3d8888afa73b115cc59abeb3b33
2 个父辈
5c7ad832
6d014ebb
Merge branch 'dev-tangxvhui' into dev-zhengzhou
显示空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
402 行增加
和
15 行删除
pkg/application/task/adapter/task_info.go
pkg/application/task/adapter/task_list.go
pkg/application/task/command/search_task.go
pkg/application/task/service/service.go
pkg/domain/task.go
pkg/domain/task_stage.go
pkg/infrastructure/dao/task.go
pkg/application/task/adapter/task_info.go
查看文件 @
ca22f2b
...
...
@@ -7,7 +7,7 @@ type TaskInfoAdapter struct {
LeaderId
int64
`json:"leaderId,string"`
//
Leader
UserData
`json:"leader"`
// 任务负责人
Status
int
`json:"status"`
// 任务的状态
StatusDescript
string
`json:"statusDescript"`
//
StatusDescript
ion
string
`json:"statusDescription"`
//
Level
int
`json:"level"`
// 优先级,值越小优先级越高
LevalName
string
`json:"levalName"`
// 优先级名称
RelatedUserId
[]
string
`json:"relatedUserId"`
// 相关的员工id
...
...
@@ -24,7 +24,7 @@ type UserData struct {
type
TaskStage
struct
{
Id
int
`json:"id,string"`
Name
string
`json:"name"`
//里程碑名称
StatusDescript
string
`json:"statusDescript
"`
//里程碑的完成情况
StatusDescript
ion
string
`json:"statusDescription
"`
//里程碑的完成情况
Status
int
`json:"status"`
//里程碑状态
SortBy
int
`json:"sortBy"`
PlanCompletedAt
string
`json:"planCompletedAt"`
//计划完成时间, 例:2006-01-02
...
...
pkg/application/task/adapter/task_list.go
查看文件 @
ca22f2b
...
...
@@ -13,4 +13,5 @@ type TaskItem struct {
StageC
TaskStage
`json:"stageC"`
// 里程碑3
StageD
TaskStage
`json:"stageD"`
// 里程碑4
StageE
TaskStage
`json:"stageE"`
// 里程碑5
UpdatedAt
string
`json:"updatedAt"`
//
}
...
...
pkg/application/task/command/search_task.go
0 → 100644
查看文件 @
ca22f2b
package
command
type
SearchTaskCommand
struct
{
UserId
int
`json:"-"`
//谁要查看任务数据
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
}
...
...
pkg/application/task/service/service.go
查看文件 @
ca22f2b
...
...
@@ -7,9 +7,11 @@ import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
roleService
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
)
type
TaskService
struct
{}
...
...
@@ -337,7 +339,7 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
Name
:
taskData
.
Leader
.
Name
,
},
Status
:
int
(
taskData
.
Status
),
StatusDescript
:
taskData
.
StatusDescript
(),
StatusDescript
ion
:
taskData
.
StatusDescription
(),
Level
:
taskData
.
Level
,
LevalName
:
taskData
.
LevelName
,
RelatedUserId
:
[]
string
{},
...
...
@@ -369,7 +371,7 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
PlanCompletedAt
:
t1
,
RealCompletedAt
:
t2
,
SortBy
:
val
.
SortBy
,
StatusDescript
:
val
.
StatusDescript
(),
StatusDescript
ion
:
val
.
StatusDescription
(),
Status
:
int
(
val
.
Status
),
})
}
...
...
@@ -531,7 +533,7 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte
stage
:=
adapter
.
TaskStage
{
Id
:
val
.
Id
,
Name
:
val
.
Name
,
StatusDescript
:
val
.
StatusDescript
(),
StatusDescript
ion
:
val
.
StatusDescription
(),
Status
:
int
(
val
.
Status
),
SortBy
:
val
.
SortBy
,
}
...
...
@@ -556,10 +558,6 @@ func (t TaskService) canUpdateTask(taskData *domain.Task, stageList []*domain.Ta
return
true
,
nil
}
func
(
t
TaskService
)
ListTask2
()
error
{
return
nil
}
// CancelAttention 用户取消关注某个任务
func
(
t
TaskService
)
CancelAttention
(
param
*
command
.
CancelAttentionCommand
)
error
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
...
...
@@ -590,3 +588,57 @@ func (t TaskService) CancelAttention(param *command.CancelAttentionCommand) erro
}
return
nil
}
// 员工绩效-任务管理-列表
func
(
t
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
())
}
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
,
TaskName
:
param
.
TaskName
,
LevelName
:
param
.
LevelName
,
OnlyMy
:
param
.
OnlyMy
,
LeaderId
:
param
.
LeaderId
,
}
if
hrbpFlag
==
domain
.
RoleTypeSystem
{
//已hrbp权限获取
// info.IsHrbp = true
return
nil
,
nil
}
taskDato
:=
dao
.
NewTaskDao
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
taskDato
.
ListTaskStageNotHrbp
(
condition
)
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
return
nil
,
nil
}
// 以hrbp角色权限获取任务列表
func
(
t
TaskService
)
ListTask2ForHrbp
(
param
command
.
SearchTaskCommand
)
(
map
[
string
]
interface
{},
error
)
{
return
nil
,
nil
}
...
...
pkg/domain/task.go
查看文件 @
ca22f2b
...
...
@@ -36,6 +36,7 @@ type TaskLeader struct {
}
// 设置任务的优先级
// 值越小优先级越高,不是预定义的任务优先级,排在最后
func
(
t
*
Task
)
ApplyLevelName
(
name
string
)
{
t
.
LevelName
=
name
switch
name
{
...
...
@@ -51,7 +52,7 @@ func (t *Task) ApplyLevelName(name string) {
}
// StatusDescript
func
(
t
*
Task
)
StatusDescript
()
string
{
func
(
t
*
Task
)
StatusDescript
ion
()
string
{
switch
t
.
Status
{
case
TaskWait
:
return
"待启动"
...
...
pkg/domain/task_stage.go
查看文件 @
ca22f2b
...
...
@@ -6,8 +6,8 @@ type TaskStageState int
const
(
TaskStageUncompleted
TaskStageState
=
1
//里程碑未完成
TaskStageCompletedOverdue
TaskStageState
=
2
//里程碑逾期完成
TaskStageCompleted
TaskStageState
=
3
//里程碑完成
// TaskStageCompletedOverdue TaskStageState = 2 //里程碑逾期完成
TaskStageCompleted
TaskStageState
=
2
//里程碑完成
)
...
...
@@ -32,7 +32,7 @@ type TaskStageRepository interface {
}
// 描述里程碑完成情况
func
(
t
TaskStage
)
StatusDescript
()
string
{
func
(
t
TaskStage
)
StatusDescript
ion
()
string
{
nowDay
:=
time
.
Now
()
.
Format
(
"2006-01-02"
)
nowTime
,
_
:=
time
.
ParseInLocation
(
"2006-01-02"
,
nowDay
,
time
.
Local
)
...
...
@@ -45,10 +45,11 @@ func (t TaskStage) StatusDescript() string {
str
=
"未完成"
}
case
TaskStageCompleted
:
if
t
.
PlanCompletedAt
>=
t
.
RealCompletedAt
{
str
=
"已完成"
case
TaskStageCompletedOverdue
:
}
else
{
str
=
"逾期完成"
}
}
return
str
}
...
...
pkg/infrastructure/dao/task.go
0 → 100644
查看文件 @
ca22f2b
package
dao
import
(
"fmt"
"time"
"github.com/go-pg/pg/v10"
pgTransaction
"github.com/linmadan/egglib-go/transaction/pg"
)
type
TaskDao
struct
{
transactionContext
*
pgTransaction
.
TransactionContext
}
func
NewTaskDao
(
options
map
[
string
]
interface
{})
*
TaskDao
{
var
transactionContext
*
pgTransaction
.
TransactionContext
if
value
,
ok
:=
options
[
"transactionContext"
];
ok
{
transactionContext
=
value
.
(
*
pgTransaction
.
TransactionContext
)
}
return
&
TaskDao
{
transactionContext
:
transactionContext
,
}
}
func
(
d
*
TaskDao
)
catchTaskIdByPermission
(
userId
int
)
string
{
sqlStr
:=
`with
-- 人员自身以及全下级
recursive t_user as (
(
select "user".id,"user".parent_id
from "user"
where "user".id=%d
)
union
(
select "child_user".id,"child_user".parent_id
from "user" as "child_user"
join t_user as "parent_user" on "parent_user".id="child_user".parent_id
)
),
-- 根据任务负责人和相关人员查询
t_task_0 as (
(select task.id from task
join t_user on task.leader ->>'id'=t_user.id::text
)
union
(select task.id from task where task.related_user@>'[%d]')
),
t_task_ignore as (
select * from task_ignore where task_ignore.user_id =%d
),
-- 过滤取消关注的
t_task_1 as (
select t_task_0.id
from t_task_0
left join t_task_ignore on t_task_0.id=t_task_ignore.task_id
where t_task_ignore.id isnull
)`
return
fmt
.
Sprintf
(
sqlStr
,
userId
,
userId
,
userId
)
}
type
ListTaskCondition
struct
{
Limit
int
//分页
Offset
int
//分页
UserId
int
//谁要查看任务数据
TaskName
string
//任务名称
LevelName
string
//优先级
OnlyMy
bool
//只查看我负责的任务
LeaderId
string
//任务负责人id
}
// 任务和里程碑列表
type
ListTaskStage
struct
{
TaskId
string
`pg:"task_id"`
TaskName
string
`pg:"task_name"`
LeaderName
string
`pg:"leader_name"`
LeaderId
string
`pg:"leader_id"`
LevelName
string
`pg:"level_name"`
Level
int
`pg:"level"`
Anomaly
int
`pg:"anomaly"`
UpdatedAt
time
.
Time
`pg:"updated_at"`
CreatedAt
time
.
Time
`pg:"created_at"`
StageName
string
`pg:"stage_name"`
StageSortBy
int
`pg:"stage_sort_by"`
StageStatus
int
`pg:"stage_status"`
PlanCompletedAt
int
`pg:"plan_completed_at"`
}
// 获取任务以及里程碑列表,用于页面展示; 有过滤查看权限
// userid 谁要查看任务数据
// limit 分页
// offset 分页
func
(
d
*
TaskDao
)
ListTaskStageNotHrbp
(
param
ListTaskCondition
)
([]
ListTaskStage
,
error
)
{
task1
:=
d
.
catchTaskIdByPermission
(
param
.
UserId
)
withSql
:=
task1
+
`,
-- 获取的里程碑数据,以及排序
t_task_tage_1 as(
select
task.id as task_id,
task."name" as task_name,
task.leader ->>'name' as leader_name,
task.leader ->>'id' as leader_id,
task.level_name ,
task.anomaly ,
task.updated_at ,
task.created_at ,
task."level" ,
task_stage."name" as stage_name,
task_stage.sort_by as stage_sort_by,
task_stage.status as stage_status,
task_stage.plan_completed_at,
(case
when task_stage.real_completed_at =0
then task_stage.plan_completed_at - floor( extract(epoch from now()))
else task_stage.plan_completed_at - task_stage.real_completed_at
end) as diff_time
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
order by diff_time,task."level",task.created_at
),
-- 按任务数据分页获取
t_task_page as (
select distinct t_task_tage_1.task_id
from t_task_tage_1
where 1=1
%s
limit ? offset ?
)
select
t_task_tage_1.task_id,
t_task_tage_1.task_name,
t_task_tage_1.leader_name,
t_task_tage_1.level_name ,
t_task_tage_1.anomaly ,
t_task_tage_1.updated_at ,
t_task_tage_1.created_at ,
t_task_tage_1."level" ,
t_task_tage_1.plan_completed_at,
t_task_tage_1.stage_name,
t_task_tage_1.stage_sort_by,
t_task_tage_1.stage_status,
from t_task_tage_1
where t_task_tage_1.task_id in(
select t_task_page.task_id from t_task_page
)`
condition
:=
[]
interface
{}{}
whereSql
:=
``
if
param
.
OnlyMy
{
condition
=
append
(
condition
,
param
.
UserId
)
whereSql
+=
` and t_task_tage_1.leader_id = '?' `
}
else
if
param
.
LeaderId
!=
""
{
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 ? `
}
condition
=
append
(
condition
,
param
.
Limit
,
param
.
Offset
)
sqlStr
:=
fmt
.
Sprintf
(
withSql
,
whereSql
)
result
:=
[]
ListTaskStage
{}
tx
:=
d
.
transactionContext
.
PgTx
_
,
err
:=
tx
.
Query
(
&
result
,
sqlStr
,
condition
...
)
return
result
,
err
}
// 获取任务总数,用于页面展示; 有过滤查看权限
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
{}{}
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 ? `
}
sqlStr
:=
withSql
+
whereSql
tx
:=
d
.
transactionContext
.
PgTx
var
cnt
int
_
,
err
:=
tx
.
QueryOne
(
pg
.
Scan
(
&
cnt
),
sqlStr
,
condition
...
)
return
cnt
,
err
}
// 获取任务以及里程碑列表,用于页面展示; 无过滤查看权限
// userid 谁要查看任务数据
// limit 分页
// offset 分页
func
(
d
*
TaskDao
)
ListTaskStageByHrbp
(
param
ListTaskCondition
)
([]
ListTaskStage
,
error
)
{
withSql
:=
`with
t_task_ignore as (
select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
),
-- 获取的里程碑数据,以及排序
t_task_tage_1 as(
select
task.id as task_id,
task."name" as task_name,
task.leader ->>'name' as leader_name,
task.leader ->>'id' as leader_id,
task.level_name ,
task.anomaly ,
task.updated_at ,
task.created_at ,
task."level" ,
task_stage."name" as stage_name,
task_stage.sort_by as stage_sort_by,
task_stage.status as stage_status,
task_stage.plan_completed_at,
(case
when task_stage.real_completed_at =0
then task_stage.plan_completed_at - floor( extract(epoch from now()))
else task_stage.plan_completed_at - task_stage.real_completed_at
end) as diff_time
from task
join task_stage on task.id =task_stage.task_id
where 1=1
order by diff_time,task."level",task.created_at
),
-- 按任务数据分页获取
t_task_page as (
select distinct t_task_tage_1.task_id
from t_task_tage_1
left join t_task_ignore on t_task_ignore.task_id=t_task_tage_1.task_id
where t_task_ignore.id isnull
%s
limit ? offset ?
)
select
t_task_tage_1.task_id,
t_task_tage_1.task_name,
t_task_tage_1.leader_name,
t_task_tage_1.level_name ,
t_task_tage_1.anomaly ,
t_task_tage_1.updated_at ,
t_task_tage_1.created_at ,
t_task_tage_1."level" ,
t_task_tage_1.plan_completed_at,
t_task_tage_1.stage_name,
t_task_tage_1.stage_sort_by,
t_task_tage_1.stage_status,
from t_task_tage_1
where t_task_tage_1.task_id in(
select t_task_page.task_id from t_task_page
)`
condition
:=
[]
interface
{}{}
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 ? `
}
condition
=
append
(
condition
,
param
.
Limit
,
param
.
Offset
)
sqlStr
:=
fmt
.
Sprintf
(
withSql
,
whereSql
)
result
:=
[]
ListTaskStage
{}
tx
:=
d
.
transactionContext
.
PgTx
_
,
err
:=
tx
.
Query
(
&
result
,
sqlStr
,
condition
...
)
return
result
,
err
}
// 获取任务总数,用于页面展示; 无过滤查看权限
func
(
d
*
TaskDao
)
CountTaskStageByHrbp
(
param
ListTaskCondition
)
(
int
,
error
)
{
withSql
:=
`with
t_task_ignore as (
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
{}{}
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 ? `
}
sqlStr
:=
withSql
+
whereSql
tx
:=
d
.
transactionContext
.
PgTx
var
cnt
int
_
,
err
:=
tx
.
QueryOne
(
pg
.
Scan
(
&
cnt
),
sqlStr
,
condition
...
)
return
cnt
,
err
}
...
...
请
注册
或
登录
后发表评论