|
@@ -13,7 +13,9 @@ func InitTask() {
|
|
|
// 创建Es索引
|
|
|
CreateIndex()
|
|
|
// 初始化研报推送状态
|
|
|
- InitReportPushStatus()
|
|
|
+ InitEtaReportPushStatus()
|
|
|
+ // 初始化pdf报告推送状态
|
|
|
+ InitPdfReportPushStatus()
|
|
|
// 初始化系统用户权限
|
|
|
InitSystemUserPermission()
|
|
|
fmt.Println("end task!")
|
|
@@ -58,7 +60,7 @@ func CreateIndex() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func InitReportPushStatus() {
|
|
|
+func InitEtaReportPushStatus() {
|
|
|
for {
|
|
|
maxId, err := models.GetMaxSyncIdReportPush(1)
|
|
|
fmt.Println("同步研报开始, maxId:", maxId)
|
|
@@ -73,7 +75,7 @@ func InitReportPushStatus() {
|
|
|
for _, v := range reportList {
|
|
|
reportIds = append(reportIds, v.Id)
|
|
|
}
|
|
|
- reportPushList, err := models.GetReportPushStatusByReportIds(reportIds)
|
|
|
+ reportPushList, err := models.GetReportPushStatusByReportIds(utils.ReportTypeEta, reportIds)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -97,7 +99,65 @@ func InitReportPushStatus() {
|
|
|
ClassifyIdThird: v.ClassifyIdThird,
|
|
|
ClassifyNameThird: v.ClassifyNameThird,
|
|
|
Author: v.Author,
|
|
|
- ReportType: 1,
|
|
|
+ ReportType: utils.ReportTypeEta,
|
|
|
+ PublishTime: v.PublishTime,
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ ModifyTime: time.Now(),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ err = models.BatchAddReportPushStatus(insertReportPushList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(reportList) != 100 {
|
|
|
+ fmt.Println("同步研报完成")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 初始化pdf报告的推送状态
|
|
|
+func InitPdfReportPushStatus() {
|
|
|
+ for {
|
|
|
+ maxId, err := models.GetMaxSyncIdReportPush(2)
|
|
|
+ fmt.Println("同步研报开始, maxId:", maxId)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("同步研报失败, Err:", err)
|
|
|
+ }
|
|
|
+ reportList, err := models.GetBatchPdfReport(maxId, 100)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("同步研报失败, Err:", err)
|
|
|
+ }
|
|
|
+ var reportIds []int
|
|
|
+ for _, v := range reportList {
|
|
|
+ reportIds = append(reportIds, v.ReportPdfId)
|
|
|
+ }
|
|
|
+ reportPushList, err := models.GetReportPushStatusByReportIds(utils.ReportTypePdf, reportIds)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reportPushMap := make(map[int]struct{})
|
|
|
+ for _, v := range reportPushList {
|
|
|
+ reportPushMap[v.ReportId] = struct{}{}
|
|
|
+ }
|
|
|
+ var insertReportPushList []*models.ReportPushStatus
|
|
|
+ for _, v := range reportList {
|
|
|
+ if _, ok := reportPushMap[v.ReportPdfId]; !ok {
|
|
|
+ insertReportPushList = append(insertReportPushList, &models.ReportPushStatus{
|
|
|
+ ReportId: v.ReportPdfId,
|
|
|
+ State: 0,
|
|
|
+ Title: v.Title,
|
|
|
+ Abstract: v.Abstract,
|
|
|
+ Stage: v.Stage,
|
|
|
+ ClassifyIdFirst: v.ClassifyIdFirst,
|
|
|
+ ClassifyNameFirst: v.ClassifyNameFirst,
|
|
|
+ ClassifyIdSecond: v.ClassifyIdSecond,
|
|
|
+ ClassifyNameSecond: v.ClassifyNameSecond,
|
|
|
+ ClassifyIdThird: v.ClassifyIdThird,
|
|
|
+ ClassifyNameThird: v.ClassifyNameThird,
|
|
|
+ Author: v.Author,
|
|
|
+ ReportType: utils.ReportTypePdf,
|
|
|
PublishTime: v.PublishTime,
|
|
|
CreateTime: time.Now(),
|
|
|
ModifyTime: time.Now(),
|