切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
257d839f44dc87dd8d5e3ec1af0aedfc549c2ede
1 个父辈
0db37fc1
更新
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
266 行增加
和
9 行删除
pkg/application/notify/service/message_personal.go
pkg/application/staff_assess/service/create_staff_assess.go
pkg/infrastructure/dao/task_dao.go
pkg/infrastructure/dao/user_dao.go
pkg/port/beego/controllers/message_personal_controller.go
pkg/port/beego/routers/message_personal_router.go
pkg/application/notify/service/message_personal.go
查看文件 @
257d839
...
...
@@ -11,6 +11,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
)
// 个人信息提示
...
...
@@ -136,15 +137,75 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
}
return
resp
,
nil
}
// TDOD
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
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"检查任务里程碑异常的消息"
+
err
.
Error
())
}
childUser
,
err
:=
userDao
.
AllChildUser
(
param
.
UserId
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取下级员工"
+
err
.
Error
())
}
childUserId
:=
[]
string
{}
for
_
,
val
:=
range
childUser
{
if
val
.
Level
==
2
{
childUserId
=
append
(
childUserId
,
strconv
.
Itoa
(
val
.
Id
))
}
}
// 针对上级
var
taskStageList2
[]
dao
.
TaskStageData
if
len
(
childUserId
)
==
0
{
taskStageList2
,
err
=
taskDao
.
TaskStageAnomaly
(
childUserId
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"检查任务里程碑异常的消息"
+
err
.
Error
())
}
}
childUserId2
:=
[]
string
{}
for
_
,
val
:=
range
childUser
{
if
val
.
Level
==
3
{
childUserId
=
append
(
childUserId
,
strconv
.
Itoa
(
val
.
Id
))
}
}
// 针对上上级
var
taskStageList3
[]
dao
.
TaskStageData
if
len
(
childUserId
)
==
0
{
taskStageList2
,
err
=
taskDao
.
TaskStageAnomaly
(
childUserId2
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"检查任务里程碑异常的消息"
+
err
.
Error
())
}
}
msgList
:=
[]
adapter
.
MessageListAdapter
{}
for
_
,
val
:=
range
taskStageList
{
s
:=
fmt
.
Sprintf
(
"【您负责的项目【%s】里程碑未按时完成,请重点关注,积极寻找上级辅导。】"
,
val
.
Name
)
msgList
=
append
(
msgList
,
adapter
.
MessageListAdapter
{
Content
:
s
,
})
}
for
_
,
val
:=
range
taskStageList2
{
s
:=
fmt
.
Sprintf
(
"您下级%s负责的项目【%s】里程碑未按时完成,请前往辅导。"
,
val
.
LeaderName
,
val
.
Name
)
msgList
=
append
(
msgList
,
adapter
.
MessageListAdapter
{
Content
:
s
,
})
}
for
_
,
val
:=
range
taskStageList3
{
s
:=
fmt
.
Sprintf
(
"【您下级%s关注的项目【%s】里程碑未按时完成,请前往辅导。】"
,
val
.
LeaderName
,
val
.
Name
)
msgList
=
append
(
msgList
,
adapter
.
MessageListAdapter
{
Content
:
s
,
})
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
resp
:=
map
[
string
]
interface
{}{
"needNotify"
:
false
,
"list"
:
[]
adapter
.
MessageListAdapter
{},
"needNotify"
:
true
,
"list"
:
msgList
,
}
if
len
(
msgList
)
==
0
{
resp
[
"needNotify"
]
=
false
}
return
resp
,
nil
}
...
...
@@ -181,15 +242,80 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
}
return
resp
,
nil
}
userDao
:=
dao
.
NewUserDao
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
// TODO
taskDao
:=
dao
.
NewTaskDao
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
// 针对任务负责人
leaderIds
:=
[]
string
{
strconv
.
Itoa
(
param
.
UserId
)}
taskStageList
,
err
:=
taskDao
.
TaskAnomaly
(
leaderIds
,
2
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"检查任务里程碑异常的消息"
+
err
.
Error
())
}
childUser
,
err
:=
userDao
.
AllChildUser
(
param
.
UserId
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取下级员工"
+
err
.
Error
())
}
childUserId
:=
[]
string
{}
for
_
,
val
:=
range
childUser
{
if
val
.
Level
==
2
{
childUserId
=
append
(
childUserId
,
strconv
.
Itoa
(
val
.
Id
))
}
}
// 针对上级
var
taskStageList2
[]
dao
.
TaskStageData
if
len
(
childUserId
)
==
0
{
taskStageList2
,
err
=
taskDao
.
TaskAnomaly
(
childUserId
,
4
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"检查任务里程碑异常的消息"
+
err
.
Error
())
}
}
childUserId2
:=
[]
string
{}
for
_
,
val
:=
range
childUser
{
if
val
.
Level
==
3
{
childUserId
=
append
(
childUserId
,
strconv
.
Itoa
(
val
.
Id
))
}
}
// 针对上上级
var
taskStageList3
[]
dao
.
TaskStageData
if
len
(
childUserId
)
==
0
{
taskStageList2
,
err
=
taskDao
.
TaskAnomaly
(
childUserId2
,
5
)
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
())
}
msgList
:=
[]
adapter
.
MessageListAdapter
{}
for
_
,
val
:=
range
taskStageList
{
s
:=
fmt
.
Sprintf
(
"【您负责的项目【%s】已超过N日未反馈进度,请前往该战略任务进行反馈。】"
,
val
.
Name
)
msgList
=
append
(
msgList
,
adapter
.
MessageListAdapter
{
Content
:
s
,
})
}
for
_
,
val
:=
range
taskStageList2
{
s
:=
fmt
.
Sprintf
(
"【您下级%s负责的项目【%s】已超过N日未反馈进度,请前往辅导。】"
,
val
.
LeaderName
,
val
.
Name
)
msgList
=
append
(
msgList
,
adapter
.
MessageListAdapter
{
Content
:
s
,
})
}
for
_
,
val
:=
range
taskStageList3
{
s
:=
fmt
.
Sprintf
(
"【您下级%s关注的项目【%s】已超过N日未反馈进度,请前往辅导。】"
,
val
.
LeaderName
,
val
.
Name
)
msgList
=
append
(
msgList
,
adapter
.
MessageListAdapter
{
Content
:
s
,
})
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
resp
:=
map
[
string
]
interface
{}{
"needNotify"
:
false
,
"list"
:
[]
adapter
.
MessageListAdapter
{},
"needNotify"
:
true
,
"list"
:
msgList
,
}
if
len
(
msgList
)
==
0
{
resp
[
"needNotify"
]
=
false
}
return
resp
,
nil
}
...
...
pkg/application/staff_assess/service/create_staff_assess.go
查看文件 @
257d839
...
...
@@ -10,6 +10,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
...
...
@@ -131,7 +132,8 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
assessRepo
:=
factory
.
CreateStaffAssessRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
//保存 员工的需要填写的每日任务型 指标项
taskRecordRepo
:=
factory
.
CreateTaskRecordRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
// 保存 员工的需要填写的每日任务型 指标项
taskDao
:=
dao
.
NewTaskDao
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
for
i
:=
range
assessList
{
assessList
[
i
]
.
StaffAssessTaskId
=
assessTaskData
.
Id
_
,
err
=
assessRepo
.
Save
(
&
assessList
[
i
])
...
...
@@ -154,6 +156,10 @@ 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
())
}
}
}
}
...
...
pkg/infrastructure/dao/task_dao.go
查看文件 @
257d839
...
...
@@ -375,7 +375,7 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er
func
(
d
*
TaskDao
)
CountTaskStageAnomalyByHrbp
(
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 task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
)select count(*)
from task_stage
join task on task_stage.task_id =task.id
...
...
@@ -409,3 +409,50 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err
_
,
err
:=
tx
.
QueryOne
(
pg
.
Scan
(
&
cnt
),
sqlStr
,
condition
...
)
return
cnt
,
err
}
func
(
d
*
TaskDao
)
IncreaseAnomaly
(
id
[]
int
,
incr
int
)
error
{
sqlStr
:=
`update task set anomaly=task.anomaly+?
where id in(?)`
tx
:=
d
.
transactionContext
.
PgTx
_
,
err
:=
tx
.
Exec
(
sqlStr
,
incr
,
pg
.
In
(
id
))
return
err
}
// TaskStageData
type
TaskStageData
struct
{
Id
int
Name
string
LeaderName
string
}
// 异常的里程碑任务
func
(
d
*
TaskDao
)
TaskStageAnomaly
(
leaderId
[]
string
)
([]
TaskStageData
,
error
)
{
sqlStr
:=
`select
task_stage.id,
task_stage."name" ,
task.leader ->>'name' as leader_name
from task_stage
join task on task.id=task_stage.task_id
where 1=1
and task_stage.real_completed_at=0 and task_stage.plan_completed_at<extract(epoch from now())
and task.leader ->>'id' in(?) `
result
:=
[]
TaskStageData
{}
tx
:=
d
.
transactionContext
.
PgTx
_
,
err
:=
tx
.
Query
(
&
result
,
sqlStr
,
pg
.
In
(
leaderId
))
return
result
,
err
}
// 异常的里程碑任务
func
(
d
*
TaskDao
)
TaskAnomaly
(
leaderId
[]
string
,
anomaly
int
)
([]
TaskStageData
,
error
)
{
sqlStr
:=
`select
task."name" ,
task.alias ,
task.leader ->>'name' as leader_name,
task.anomaly
from task
where task.anomaly >=? and task.leader ->'id'='?' `
result
:=
[]
TaskStageData
{}
tx
:=
d
.
transactionContext
.
PgTx
_
,
err
:=
tx
.
Query
(
&
result
,
sqlStr
,
anomaly
,
pg
.
In
(
leaderId
))
return
result
,
err
}
...
...
pkg/infrastructure/dao/user_dao.go
0 → 100644
查看文件 @
257d839
package
dao
import
pgTransaction
"github.com/linmadan/egglib-go/transaction/pg"
type
UserDao
struct
{
transactionContext
*
pgTransaction
.
TransactionContext
}
func
NewUserDao
(
options
map
[
string
]
interface
{})
*
UserDao
{
var
transactionContext
*
pgTransaction
.
TransactionContext
if
value
,
ok
:=
options
[
"transactionContext"
];
ok
{
transactionContext
=
value
.
(
*
pgTransaction
.
TransactionContext
)
}
return
&
UserDao
{
transactionContext
:
transactionContext
,
}
}
type
UserData1
struct
{
Id
int
`pg:"id"`
ParentId
int
`pg:"parent_id"`
Account
string
`pg:"account"`
// 用户账号
Name
string
`pg:"name"`
// 用户姓名
Level
int
`pg:"level"`
}
func
(
d
*
UserDao
)
AllChildUser
(
userId
int
)
([]
UserData1
,
error
)
{
sqlStr
:=
`with
-- 人员自身以及全下级
recursive t_user as (
(
select "user".id,"user".parent_id ,"user".account,"user".name, 1 as "level"
from "user"
where "user".id=3422174102828544
)
union
(
select "child_user".id,"child_user".parent_id,"child_user".account,"child_user".name,
"parent_user"."level"+1 as "level"
from "user" as "child_user"
join t_user as "parent_user" on "parent_user".id="child_user".parent_id
)
)select * from t_user `
result
:=
[]
UserData1
{}
tx
:=
d
.
transactionContext
.
PgTx
_
,
err
:=
tx
.
Query
(
&
result
,
sqlStr
,
userId
)
return
result
,
err
}
func
(
d
*
UserDao
)
ChildUser
(
userId
int
)
([]
UserData1
,
error
)
{
sqlStr
:=
`select "user".id,"user".parent_id ,"user".account,"user".name
from "user"
where "user".parent_id=?`
result
:=
[]
UserData1
{}
tx
:=
d
.
transactionContext
.
PgTx
_
,
err
:=
tx
.
Query
(
&
result
,
sqlStr
,
userId
)
return
result
,
err
}
...
...
pkg/port/beego/controllers/message_personal_controller.go
查看文件 @
257d839
...
...
@@ -21,3 +21,21 @@ func (c *MessagePersonalController) TodayMessageSummaryEvaluation() {
data
,
err
:=
srv
.
TodayMessageSummaryEvaluationSelf
(
&
param
)
c
.
Response
(
data
,
err
)
}
func
(
c
*
MessagePersonalController
)
TodayMessageTaskStageAnomaly
()
{
srv
:=
service
.
NewMessagePersonalService
()
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
param
:=
command
.
GetUserMessageCommand
{}
param
.
UserId
=
int
(
userReq
.
UserId
)
data
,
err
:=
srv
.
TodayMessageTaskStageAnomaly
(
&
param
)
c
.
Response
(
data
,
err
)
}
func
(
c
*
MessagePersonalController
)
TodayMessageTaskRecordAnomaly
()
{
srv
:=
service
.
NewMessagePersonalService
()
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
param
:=
command
.
GetUserMessageCommand
{}
param
.
UserId
=
int
(
userReq
.
UserId
)
data
,
err
:=
srv
.
TodayMessageTaskRecordAnomaly
(
&
param
)
c
.
Response
(
data
,
err
)
}
...
...
pkg/port/beego/routers/message_personal_router.go
查看文件 @
257d839
...
...
@@ -11,6 +11,8 @@ func init() {
ns
:=
web
.
NewNamespace
(
"/v1/message-personal"
,
web
.
NSBefore
(
filters
.
AllowCors
(),
middlewares
.
CheckFontToken
()),
web
.
NSCtrlGet
(
"/summary-evaluation/self/today"
,
(
*
controllers
.
MessagePersonalController
)
.
TodayMessageSummaryEvaluation
),
web
.
NSCtrlGet
(
"/summary-evaluation/task_stage/today"
,
(
*
controllers
.
MessagePersonalController
)
.
TodayMessageTaskStageAnomaly
),
web
.
NSCtrlGet
(
"/summary-evaluation/task_record/today"
,
(
*
controllers
.
MessagePersonalController
)
.
TodayMessageTaskRecordAnomaly
),
)
web
.
AddNamespace
(
ns
)
}
...
...
请
注册
或
登录
后发表评论