|
@@ -15,7 +15,7 @@ import ( |
|
@@ -15,7 +15,7 @@ import ( |
15
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
15
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
16
|
)
|
16
|
)
|
17
|
|
17
|
|
18
|
-func messageTaskStageAnomaly(companyId int) ([]*domain.MessagePersonal, error) {
|
18
|
+func messageTaskStageAnomaly() ([]*domain.MessagePersonal, error) {
|
19
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
19
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
20
|
if err != nil {
|
20
|
if err != nil {
|
21
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
21
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -28,7 +28,7 @@ func messageTaskStageAnomaly(companyId int) ([]*domain.MessagePersonal, error) { |
|
@@ -28,7 +28,7 @@ func messageTaskStageAnomaly(companyId int) ([]*domain.MessagePersonal, error) { |
28
|
}()
|
28
|
}()
|
29
|
taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext})
|
29
|
taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext})
|
30
|
userDao := dao.NewUserDao(map[string]interface{}{"transactionContext": transactionContext})
|
30
|
userDao := dao.NewUserDao(map[string]interface{}{"transactionContext": transactionContext})
|
31
|
- taskData, err := taskDao.TaskStageAnomalyAll(companyId)
|
31
|
+ taskData, err := taskDao.TaskStageAnomalyAll()
|
32
|
if err != nil {
|
32
|
if err != nil {
|
33
|
return nil, fmt.Errorf("获取任务信息%s", err)
|
33
|
return nil, fmt.Errorf("获取任务信息%s", err)
|
34
|
}
|
34
|
}
|
|
@@ -112,36 +112,14 @@ func saveAllMessagePersonal(msgList []*domain.MessagePersonal) error { |
|
@@ -112,36 +112,14 @@ func saveAllMessagePersonal(msgList []*domain.MessagePersonal) error { |
112
|
return nil
|
112
|
return nil
|
113
|
}
|
113
|
}
|
114
|
|
114
|
|
|
|
115
|
+// 发送手机端通知
|
115
|
func appMessageSend() error {
|
116
|
func appMessageSend() error {
|
116
|
- transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
117
|
- if err != nil {
|
|
|
118
|
- return err
|
|
|
119
|
- }
|
|
|
120
|
- if err := transactionContext.StartTransaction(); err != nil {
|
|
|
121
|
- return err
|
|
|
122
|
- }
|
|
|
123
|
- defer func() {
|
|
|
124
|
- _ = transactionContext.RollbackTransaction()
|
|
|
125
|
- }()
|
|
|
126
|
-
|
|
|
127
|
- taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
128
|
- //获取公司id
|
|
|
129
|
- companyIds, err := taskDao.TaskStageAnomalyForCompany()
|
|
|
130
|
- if err != nil {
|
|
|
131
|
- return fmt.Errorf("获取公司id%s", err)
|
|
|
132
|
- }
|
|
|
133
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
134
|
- return err
|
|
|
135
|
- }
|
|
|
136
|
var appMessage []*domain.MessagePersonal
|
117
|
var appMessage []*domain.MessagePersonal
|
137
|
- for _, val := range companyIds {
|
|
|
138
|
- messageList, err := messageTaskStageAnomaly(val)
|
118
|
+ messageList, err := messageTaskStageAnomaly()
|
139
|
if err != nil {
|
119
|
if err != nil {
|
140
|
return fmt.Errorf("生成里程碑异常的消息通知失败%s", err)
|
120
|
return fmt.Errorf("生成里程碑异常的消息通知失败%s", err)
|
141
|
}
|
121
|
}
|
142
|
appMessage = append(appMessage, messageList...)
|
122
|
appMessage = append(appMessage, messageList...)
|
143
|
- }
|
|
|
144
|
-
|
|
|
145
|
openApi := serviceGateway.NewHttplibMmmOpenApiServiceGateway()
|
123
|
openApi := serviceGateway.NewHttplibMmmOpenApiServiceGateway()
|
146
|
for _, val := range appMessage {
|
124
|
for _, val := range appMessage {
|
147
|
_, err := openApi.PushInfo(1, constant.APP_MESSAGE_KEY, []int64{int64(val.TargetUserId)}, val.Title, val.Content)
|
125
|
_, err := openApi.PushInfo(1, constant.APP_MESSAGE_KEY, []int64{int64(val.TargetUserId)}, val.Title, val.Content)
|
|
@@ -149,7 +127,6 @@ func appMessageSend() error { |
|
@@ -149,7 +127,6 @@ func appMessageSend() error { |
149
|
log.Logger.Error("发送远端openApi关于里程碑异常的消息通知:" + err.Error())
|
127
|
log.Logger.Error("发送远端openApi关于里程碑异常的消息通知:" + err.Error())
|
150
|
}
|
128
|
}
|
151
|
}
|
129
|
}
|
152
|
-
|
|
|
153
|
err = saveAllMessagePersonal(appMessage)
|
130
|
err = saveAllMessagePersonal(appMessage)
|
154
|
if err != nil {
|
131
|
if err != nil {
|
155
|
return fmt.Errorf("保存里程碑异常的消息通知失败%s", err)
|
132
|
return fmt.Errorf("保存里程碑异常的消息通知失败%s", err)
|