作者 tangxvhui

调整弹窗内容显示

... ... @@ -142,12 +142,15 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext})
// 我作为任务负责人的提醒
leaderIds := []string{strconv.Itoa(param.UserId)}
taskStageList, err := taskDao.TaskStageAnomaly(leaderIds)
taskStageList, err := taskDao.TaskStageAnomalyByLeader(leaderIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())
}
// 我作为任务相关方
taskStageList0, err := taskDao.TaskStageAnomalyByRelatedUser(param.UserId)
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())
... ... @@ -161,7 +164,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
// 作为上级,我的下级员工的异常里程碑
var taskStageList2 []dao.TaskStageData
if len(childUserId) == 0 {
taskStageList2, err = taskDao.TaskStageAnomaly(childUserId)
taskStageList2, err = taskDao.TaskStageAnomalyByLeader(childUserId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())
}
... ... @@ -175,11 +178,12 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
// 作为上级, 我的下下级员工的异常里程碑
var taskStageList3 []dao.TaskStageData
if len(childUserId) == 0 {
taskStageList3, err = taskDao.TaskStageAnomaly(childUserId2)
taskStageList3, err = taskDao.TaskStageAnomalyByLeader(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)
... ... @@ -256,7 +260,32 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
//我作为任务相关人
for _, val := range taskStageList0 {
s := fmt.Sprintf("【您下级%s关注的项目【%s】里程碑未按时完成,请前往辅导。】", val.LeaderName, val.Name)
msgList = append(msgList, adapter.MessageListAdapter{
Content: s,
})
payload := map[string]string{
"id": strconv.Itoa(val.Id),
}
payloadStr, _ := json.Marshal(payload)
newMessage := domain.MessagePersonal{
Id: 0,
Types: domain.MessageTypesTaskStage,
TargetUserId: param.UserId,
ReadFlag: domain.MessageIsRead,
Title: s,
Content: s,
CreatedAt: time.Time{},
UpdatedAt: time.Time{},
Payload: string(payloadStr),
}
err = messageRepo.Save(&newMessage)
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())
}
... ... @@ -306,12 +335,13 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
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.TaskAnomaly(leaderIds, 2)
taskStageList, err := taskDao.TaskAnomalyByLeader(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())
... ... @@ -322,10 +352,10 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
childUserId = append(childUserId, strconv.Itoa(val.Id))
}
}
// 针对上级
//我作为上级, 获取我的下一级的异常任务
var taskStageList2 []dao.TaskData2
if len(childUserId) == 0 {
taskStageList2, err = taskDao.TaskAnomaly(childUserId, 4)
taskStageList2, err = taskDao.TaskAnomalyByLeader(childUserId, 4)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())
}
... ... @@ -336,10 +366,10 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
childUserId = append(childUserId, strconv.Itoa(val.Id))
}
}
// 针对上上级
// 我作为上级,获取我的下下级的异常任务
var taskStageList3 []dao.TaskData2
if len(childUserId) == 0 {
taskStageList3, err = taskDao.TaskAnomaly(childUserId2, 5)
taskStageList3, err = taskDao.TaskAnomalyByLeader(childUserId2, 5)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())
}
... ... @@ -347,7 +377,7 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
msgList := []adapter.MessageListAdapter{}
for _, val := range taskStageList {
s := fmt.Sprintf("【您负责的项目【%s】已超过N日未反馈进度,请前往该战略任务进行反馈。】", val.Name)
s := fmt.Sprintf("【您负责的项目【%s】已超过%s日未反馈进度,请前往该战略任务进行反馈。】", val.Name, val.Anomaly)
msgList = append(msgList, adapter.MessageListAdapter{
Content: s,
})
... ... @@ -372,7 +402,7 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
}
}
for _, val := range taskStageList2 {
s := fmt.Sprintf("【您下级%s负责的项目【%s】已超过N日未反馈进度,请前往辅导。】", val.LeaderName, val.Name)
s := fmt.Sprintf("【您下级%s负责的项目【%s】已超过%s日未反馈进度,请前往辅导。】", val.LeaderName, val.Name, val.Anomaly)
msgList = append(msgList, adapter.MessageListAdapter{
Content: s,
})
... ... @@ -397,7 +427,7 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
}
}
for _, val := range taskStageList3 {
s := fmt.Sprintf("【您下级%s关注的项目【%s】已超过N日未反馈进度,请前往辅导。】", val.LeaderName, val.Name)
s := fmt.Sprintf("【您下级%s关注的项目【%s】已超过%s日未反馈进度,请前往辅导。】", val.LeaderName, val.Name, val.Anomaly)
msgList = append(msgList, adapter.MessageListAdapter{
Content: s,
})
... ...
... ... @@ -391,8 +391,8 @@ type TaskStageData struct {
LeaderName string
}
// 根据负责人异常的里程碑任务
func (d *TaskDao) TaskStageAnomaly(leaderId []string) ([]TaskStageData, error) {
// 根据负责人获取超期未完成的异常的里程碑任务
func (d *TaskDao) TaskStageAnomalyByLeader(leaderId []string) ([]TaskStageData, error) {
sqlStr := `select
task_stage.id,
task_stage."name" ,
... ... @@ -408,6 +408,25 @@ func (d *TaskDao) TaskStageAnomaly(leaderId []string) ([]TaskStageData, error) {
return result, err
}
// 根据任务相关人获取超期未完成的异常的里程碑任务
func (d *TaskDao) TaskStageAnomalyByRelatedUser(relatedUserId int) ([]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.related_user @>? `
relatedUser := fmt.Sprintf("[%d]", relatedUserId)
result := []TaskStageData{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, relatedUser)
return result, err
}
type TaskData2 struct {
Id int `pg:"id"`
Name string `pg:"name"`
... ... @@ -416,8 +435,8 @@ type TaskData2 struct {
Anomaly string `pg:"anomaly"`
}
// 异常的任务
func (d *TaskDao) TaskAnomaly(leaderId []string, anomaly int) ([]TaskData2, error) {
// 根据任务负责任务获取异常的任务
func (d *TaskDao) TaskAnomalyByLeader(leaderId []string, anomaly int) ([]TaskData2, error) {
sqlStr := `select
task."id",
task."name" ,
... ...