...
|
...
|
@@ -15,7 +15,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
|
|
)
|
|
|
|
|
|
func messageTaskStageAnomaly(companyId int) ([]*domain.MessagePersonal, error) {
|
|
|
func messageTaskStageAnomaly() ([]*domain.MessagePersonal, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -28,7 +28,7 @@ func messageTaskStageAnomaly(companyId int) ([]*domain.MessagePersonal, error) { |
|
|
}()
|
|
|
taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
userDao := dao.NewUserDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
taskData, err := taskDao.TaskStageAnomalyAll(companyId)
|
|
|
taskData, err := taskDao.TaskStageAnomalyAll()
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("获取任务信息%s", err)
|
|
|
}
|
...
|
...
|
@@ -112,36 +112,14 @@ func saveAllMessagePersonal(msgList []*domain.MessagePersonal) error { |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 发送手机端通知
|
|
|
func appMessageSend() error {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
//获取公司id
|
|
|
companyIds, err := taskDao.TaskStageAnomalyForCompany()
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("获取公司id%s", err)
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
var appMessage []*domain.MessagePersonal
|
|
|
for _, val := range companyIds {
|
|
|
messageList, err := messageTaskStageAnomaly(val)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("生成里程碑异常的消息通知失败%s", err)
|
|
|
}
|
|
|
appMessage = append(appMessage, messageList...)
|
|
|
messageList, err := messageTaskStageAnomaly()
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("生成里程碑异常的消息通知失败%s", err)
|
|
|
}
|
|
|
|
|
|
appMessage = append(appMessage, messageList...)
|
|
|
openApi := serviceGateway.NewHttplibMmmOpenApiServiceGateway()
|
|
|
for _, val := range appMessage {
|
|
|
_, err := openApi.PushInfo(1, constant.APP_MESSAGE_KEY, []int64{int64(val.TargetUserId)}, val.Title, val.Content)
|
...
|
...
|
@@ -149,7 +127,6 @@ func appMessageSend() error { |
|
|
log.Logger.Error("发送远端openApi关于里程碑异常的消息通知:" + err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
err = saveAllMessagePersonal(appMessage)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("保存里程碑异常的消息通知失败%s", err)
|
...
|
...
|
|