Browse Source

Merge branch 'bzq/dev' of eta_mini/eta_mini_crm into master

baoziqiang 5 months ago
parent
commit
8907b572d2

+ 1 - 0
controllers/report_pdf.go

@@ -532,6 +532,7 @@ func (this *ReportPdfController) Publish() {
 		br.ErrMsg = "发布研报失败,系统错误,Err:" + err.Error()
 		br.ErrMsg = "发布研报失败,系统错误,Err:" + err.Error()
 		return
 		return
 	}
 	}
+
 	// 修改es
 	// 修改es
 	go func(reportPdf *models.ReportPdf) {
 	go func(reportPdf *models.ReportPdf) {
 		reportpdfView := reportPdf.ToView()
 		reportpdfView := reportPdf.ToView()

+ 51 - 52
controllers/report_push_status.go

@@ -254,7 +254,7 @@ func (this *ReportPushStatusController) PushCancel() {
 		return
 		return
 	}
 	}
 
 
-	reportPush, err := models.GetReportPushStatusByReportId(req.ReportId, 1)
+	reportPush, err := models.GetReportPushStatusByReportId(req.ReportPushStatusId, 1)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "推送失败"
 		br.Msg = "推送失败"
 		br.ErrMsg = "获取推送消息失败,Err:" + err.Error()
 		br.ErrMsg = "获取推送消息失败,Err:" + err.Error()
@@ -295,17 +295,7 @@ func (this *ReportPushStatusController) Push() {
 		return
 		return
 	}
 	}
 
 
-	count, err := models.GetReportCountById(req.ReportId)
-	if err != nil {
-		br.Msg = "研报未发布或已删除"
-		br.ErrMsg = "研报查询失败,Err:" + err.Error()
-		return
-	}
-	if count == 0 {
-		br.Msg = "研报未发布或已删除"
-		return
-	}
-	reportPush, err := models.GetReportPushStatusByReportId(req.ReportId, 0)
+	reportPush, err := models.GetReportPushStatusByReportId(req.ReportPushStatusId, 0)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "推送失败"
 		br.Msg = "推送失败"
 		br.ErrMsg = "获取推送消息失败,Err:" + err.Error()
 		br.ErrMsg = "获取推送消息失败,Err:" + err.Error()
@@ -349,6 +339,7 @@ func (this *ReportPushStatusController) BatchPush() {
 	}
 	}
 	var condition string
 	var condition string
 	var pars []interface{}
 	var pars []interface{}
+	condition = ` AND state = 0 `
 	if req.PublishStartDate != "" && req.PublishEndDate != "" {
 	if req.PublishStartDate != "" && req.PublishEndDate != "" {
 		condition += " AND publish_time >= ?"
 		condition += " AND publish_time >= ?"
 		publishStartTime, err := time.Parse(utils.FormatDate, req.PublishStartDate)
 		publishStartTime, err := time.Parse(utils.FormatDate, req.PublishStartDate)
@@ -414,39 +405,39 @@ func (this *ReportPushStatusController) BatchPush() {
 	}
 	}
 	if req.IsSelectAll {
 	if req.IsSelectAll {
 		if len(req.SelectedIds) > 0 {
 		if len(req.SelectedIds) > 0 {
-			condition += ` AND report_id NOT IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
+			condition += ` AND report_push_status_id NOT IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
 			pars = append(pars, req.SelectedIds)
 			pars = append(pars, req.SelectedIds)
 		}
 		}
 	} else {
 	} else {
 		if len(req.SelectedIds) > 0 {
 		if len(req.SelectedIds) > 0 {
-			condition += ` AND report_id IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
+			condition += ` AND report_push_status_id IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
 			pars = append(pars, req.SelectedIds)
 			pars = append(pars, req.SelectedIds)
 		}
 		}
 	}
 	}
-	reportIds, err := models.GetReportIdListByCondition(condition, pars)
+	reportPushStatusIds, err := models.GetReportPushStatusIdListByCondition(condition, pars)
 	if err != nil {
 	if err != nil {
 		br.Msg = "批量推送失败"
 		br.Msg = "批量推送失败"
 		br.ErrMsg = "查询研报失败,Err:" + err.Error()
 		br.ErrMsg = "查询研报失败,Err:" + err.Error()
 		return
 		return
 	}
 	}
-	reportPush, err := models.GetReportPushStatusByReportIdAndState(reportIds, 0)
-	if err != nil {
-		br.Msg = "批量推送失败"
-		br.ErrMsg = "查询推送状态失败,Err:" + err.Error()
-		return
-	}
-	existReportMap := make(map[int]struct{})
-	for _, v := range reportPush {
-		existReportMap[v.ReportId] = struct{}{}
-	}
-	existReportIds := make([]int, 0)
-	for _, v := range reportIds {
-		if _, ok := existReportMap[v]; ok {
-			existReportIds = append(existReportIds, v)
-		}
-	}
+	// reportPush, err := models.GetReportPushStatusByIdAndState(reportIds, 0)
+	// if err != nil {
+	// 	br.Msg = "批量推送失败"
+	// 	br.ErrMsg = "查询推送状态失败,Err:" + err.Error()
+	// 	return
+	// }
+	// existReportMap := make(map[int]struct{})
+	// for _, v := range reportPush {
+	// 	existReportMap[v.ReportId] = struct{}{}
+	// }
+	// existReportIds := make([]int, 0)
+	// for _, v := range reportIds {
+	// 	if _, ok := existReportMap[v]; ok {
+	// 		existReportIds = append(existReportIds, v)
+	// 	}
+	// }
 
 
-	err = models.BatchPushReport(existReportIds)
+	err = models.BatchPushReport(reportPushStatusIds)
 	if err != nil {
 	if err != nil {
 		br.Msg = "批量推送失败"
 		br.Msg = "批量推送失败"
 		br.ErrMsg = "批量修改推送失败,Err:" + err.Error()
 		br.ErrMsg = "批量修改推送失败,Err:" + err.Error()
@@ -478,6 +469,7 @@ func (this *ReportPushStatusController) BatchPushCancel() {
 	}
 	}
 	var condition string
 	var condition string
 	var pars []interface{}
 	var pars []interface{}
+	condition = ` AND state = 1 `
 	if req.PublishStartDate != "" && req.PublishEndDate != "" {
 	if req.PublishStartDate != "" && req.PublishEndDate != "" {
 		condition += " AND publish_time >= ?"
 		condition += " AND publish_time >= ?"
 		publishStartTime, err := time.Parse(utils.FormatDate, req.PublishStartDate)
 		publishStartTime, err := time.Parse(utils.FormatDate, req.PublishStartDate)
@@ -543,39 +535,46 @@ func (this *ReportPushStatusController) BatchPushCancel() {
 	}
 	}
 	if req.IsSelectAll {
 	if req.IsSelectAll {
 		if len(req.SelectedIds) > 0 {
 		if len(req.SelectedIds) > 0 {
-			condition += ` AND report_id NOT IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
+			condition += ` AND report_push_status_id NOT IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
 			pars = append(pars, req.SelectedIds)
 			pars = append(pars, req.SelectedIds)
 		}
 		}
 	} else {
 	} else {
 		if len(req.SelectedIds) > 0 {
 		if len(req.SelectedIds) > 0 {
-			condition += ` AND report_id IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
+			condition += ` AND report_push_status_id IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
 			pars = append(pars, req.SelectedIds)
 			pars = append(pars, req.SelectedIds)
 		}
 		}
 	}
 	}
-	reportIds, err := models.GetReportIdListByCondition(condition, pars)
+
+	reportPushStatusIds, err := models.GetReportPushStatusIdListByCondition(condition, pars)
 	if err != nil {
 	if err != nil {
 		br.Msg = "批量推送失败"
 		br.Msg = "批量推送失败"
 		br.ErrMsg = "查询研报失败,Err:" + err.Error()
 		br.ErrMsg = "查询研报失败,Err:" + err.Error()
 		return
 		return
 	}
 	}
-	reportPush, err := models.GetReportPushStatusByReportIdAndState(reportIds, 1)
-	if err != nil {
-		br.Msg = "批量推送失败"
-		br.ErrMsg = "查询推送状态失败,Err:" + err.Error()
-		return
-	}
-	existReportMap := make(map[int]struct{})
-	for _, v := range reportPush {
-		existReportMap[v.ReportId] = struct{}{}
-	}
-	existReportIds := make([]int, 0)
-	for _, v := range reportIds {
-		if _, ok := existReportMap[v]; ok {
-			existReportIds = append(existReportIds, v)
-		}
-	}
+	// reportIds, err := models.GetReportIdListByCondition(condition, pars)
+	// if err != nil {
+	// 	br.Msg = "批量推送失败"
+	// 	br.ErrMsg = "查询研报失败,Err:" + err.Error()
+	// 	return
+	// }
+	// reportPush, err := models.GetReportPushStatusByReportIdAndState(reportIds, 1)
+	// if err != nil {
+	// 	br.Msg = "批量推送失败"
+	// 	br.ErrMsg = "查询推送状态失败,Err:" + err.Error()
+	// 	return
+	// }
+	// existReportMap := make(map[int]struct{})
+	// for _, v := range reportPush {
+	// 	existReportMap[v.ReportId] = struct{}{}
+	// }
+	// existReportIds := make([]int, 0)
+	// for _, v := range reportIds {
+	// 	if _, ok := existReportMap[v]; ok {
+	// 		existReportIds = append(existReportIds, v)
+	// 	}
+	// }
 
 
-	err = models.BatchPushCancelReport(existReportIds)
+	err = models.BatchPushCancelReport(reportPushStatusIds)
 	if err != nil {
 	if err != nil {
 		br.Msg = "批量取消推送失败"
 		br.Msg = "批量取消推送失败"
 		br.ErrMsg = "批量修改推送失败,Err:" + err.Error()
 		br.ErrMsg = "批量修改推送失败,Err:" + err.Error()

+ 111 - 6
models/report_pdf.go

@@ -27,7 +27,7 @@ type ReportPdf struct {
 	Uv                 int       `description:"uv"`
 	Uv                 int       `description:"uv"`
 	SysUserId          int       `description:"创建人id"`
 	SysUserId          int       `description:"创建人id"`
 	SysRealName        string    `description:"创建人姓名"`
 	SysRealName        string    `description:"创建人姓名"`
-	State              int       `description:"状态"`
+	State              int       `description:"状态,1:已发布;2:未发布"`
 }
 }
 
 
 type ReportPdfView struct {
 type ReportPdfView struct {
@@ -50,21 +50,55 @@ type ReportPdfView struct {
 	Uv                 int       `description:"uv"`
 	Uv                 int       `description:"uv"`
 	SysUserId          int       `description:"创建人id"`
 	SysUserId          int       `description:"创建人id"`
 	SysRealName        string    `description:"创建人姓名"`
 	SysRealName        string    `description:"创建人姓名"`
-	State              int       `description:"状态"`
+	State              int       `description:"状态,1:已发布;2:未发布"`
 }
 }
 
 
 func (r *ReportPdf) Insert() (insertId int64, err error) {
 func (r *ReportPdf) Insert() (insertId int64, err error) {
-	o := orm.NewOrm()
+	tx, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			tx.Rollback()
+		} else {
+			tx.Commit()
+		}
+	}()
 	// 计算研报期数
 	// 计算研报期数
 	sql := `SELECT MAX(stage) + 1 AS count FROM report_pdf WHERE classify_id_second=?`
 	sql := `SELECT MAX(stage) + 1 AS count FROM report_pdf WHERE classify_id_second=?`
-	err = o.Raw(sql, r.ClassifyIdSecond).QueryRow(&r.Stage)
+	err = tx.Raw(sql, r.ClassifyIdSecond).QueryRow(&r.Stage)
 	if r.Stage == 0 {
 	if r.Stage == 0 {
 		r.Stage = 1
 		r.Stage = 1
 	}
 	}
 	if err != nil {
 	if err != nil {
 		return
 		return
 	}
 	}
-	insertId, err = o.Insert(r)
+	insertId, err = tx.Insert(r)
+	if err != nil {
+		return
+	}
+	if r.State == utils.ReportStatusUp {
+		insertPushStatus := &ReportPushStatus{
+			ReportId:           int(insertId),
+			State:              0,
+			Title:              r.Title,
+			Abstract:           r.Abstract,
+			Stage:              r.Stage,
+			ClassifyIdFirst:    r.ClassifyIdFirst,
+			ClassifyNameFirst:  r.ClassifyNameFirst,
+			ClassifyIdSecond:   r.ClassifyIdSecond,
+			ClassifyNameSecond: r.ClassifyNameSecond,
+			ClassifyIdThird:    r.ClassifyIdThird,
+			ClassifyNameThird:  r.ClassifyNameThird,
+			Author:             r.Author,
+			ReportType:         utils.ReportTypePdf,
+			PublishTime:        r.PublishTime,
+			CreateTime:         time.Now(),
+			ModifyTime:         time.Now(),
+		}
+		_, err = tx.Insert(insertPushStatus)
+	}
 	return
 	return
 }
 }
 
 
@@ -93,8 +127,72 @@ func (r *ReportPdf) ToView() (item *ReportPdfView) {
 }
 }
 
 
 func (r *ReportPdf) Update(cols []string) (err error) {
 func (r *ReportPdf) Update(cols []string) (err error) {
+	// reportPushStatus := new(ReportPushStatus)
+	var reportPushStatus *ReportPushStatus
 	o := orm.NewOrm()
 	o := orm.NewOrm()
-	_, err = o.Update(r, cols...)
+	sql := `SELECT * FROM report_push_status WHERE report_id=? AND report_type=?`
+	err = o.Raw(sql, r.ReportPdfId, utils.ReportTypePdf).QueryRow(&reportPushStatus)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+
+	tx, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			tx.Rollback()
+		} else {
+			tx.Commit()
+		}
+
+	}()
+	_, err = tx.Update(r, cols...)
+	if err != nil {
+		return
+	}
+	if reportPushStatus == nil && r.State == utils.ReportStatusUp {
+		insertPushStatus := &ReportPushStatus{
+			ReportId:           r.ReportPdfId,
+			State:              0,
+			Title:              r.Title,
+			Abstract:           r.Abstract,
+			Stage:              r.Stage,
+			ClassifyIdFirst:    r.ClassifyIdFirst,
+			ClassifyNameFirst:  r.ClassifyNameFirst,
+			ClassifyIdSecond:   r.ClassifyIdSecond,
+			ClassifyNameSecond: r.ClassifyNameSecond,
+			ClassifyIdThird:    r.ClassifyIdThird,
+			ClassifyNameThird:  r.ClassifyNameThird,
+			Author:             r.Author,
+			ReportType:         utils.ReportTypePdf,
+			PublishTime:        r.PublishTime,
+			CreateTime:         time.Now(),
+			ModifyTime:         time.Now(),
+		}
+		_, err = tx.Insert(insertPushStatus)
+	} else if reportPushStatus != nil {
+		// pdf报告发布后编辑,则更新report_push_status表, 若取消发布,则在推送表中删除
+		if r.State == utils.ReportStatusDown {
+			err = reportPushStatus.Delete()
+		} else {
+			reportPushStatus.Title = r.Title
+			reportPushStatus.Abstract = r.Abstract
+			reportPushStatus.Stage = r.Stage
+			reportPushStatus.ClassifyIdFirst = r.ClassifyIdFirst
+			reportPushStatus.ClassifyNameFirst = r.ClassifyNameFirst
+			reportPushStatus.ClassifyIdSecond = r.ClassifyIdSecond
+			reportPushStatus.ClassifyNameSecond = r.ClassifyNameSecond
+			reportPushStatus.ClassifyIdThird = r.ClassifyIdThird
+			reportPushStatus.ClassifyNameThird = r.ClassifyNameThird
+			reportPushStatus.Author = r.Author
+			reportPushStatus.PublishTime = r.PublishTime
+			reportPushStatus.ModifyTime = time.Now()
+			updateCols := []string{"title", "abstract", "stage", "classify_id_first", "classify_name_first", "classify_id_second", "classify_name_second", "classify_id_third", "classify_name_third", "author", "publish_time", "modify_time"}
+			_, err = tx.Update(reportPushStatus, updateCols...)
+		}
+	}
 	return
 	return
 }
 }
 
 
@@ -134,3 +232,10 @@ func GetReportPdfById(id int) (item *ReportPdf, err error) {
 	err = o.Raw(sql, id).QueryRow(&item)
 	err = o.Raw(sql, id).QueryRow(&item)
 	return
 	return
 }
 }
+
+func GetBatchPdfReport(maxId, batchSize int) (items []*ReportPdf, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM report_pdf WHERE report_pdf_id>? AND state=1 LIMIT ?`
+	_, err = o.Raw(sql, maxId, batchSize).QueryRows(&items)
+	return
+}

+ 42 - 16
models/report_push_status.go

@@ -21,7 +21,7 @@ type ReportPushStatus struct {
 	ClassifyIdThird    int       `description:"三级分类id"`
 	ClassifyIdThird    int       `description:"三级分类id"`
 	ClassifyNameThird  string    `description:"三级分类名称"`
 	ClassifyNameThird  string    `description:"三级分类名称"`
 	Author             string    `description:"报告作者"`
 	Author             string    `description:"报告作者"`
-	ReportType         int       `description:"报告类型:1-eta报告"`
+	ReportType         int       `description:"报告类型:1-eta报告 2-pdf报告"`
 	PublishTime        time.Time `description:"报告发布时间"`
 	PublishTime        time.Time `description:"报告发布时间"`
 	CreateTime         time.Time `description:"创建时间"`
 	CreateTime         time.Time `description:"创建时间"`
 	ModifyTime         time.Time `description:"修改时间"`
 	ModifyTime         time.Time `description:"修改时间"`
@@ -62,7 +62,7 @@ type ReportPushView struct {
 	State              int    `description:"报告状态:0-未推送,1-已推送"`
 	State              int    `description:"报告状态:0-未推送,1-已推送"`
 	PushTime           string `description:"推送时间"`
 	PushTime           string `description:"推送时间"`
 	PublishTime        string `description:"报告发布时间"`
 	PublishTime        string `description:"报告发布时间"`
-	ReportType         int    `description:"报告类型:1-eta报告"`
+	ReportType         int    `description:"报告类型:1-eta报告 2-pdf报告"`
 	CreateTime         string `description:"创建时间"`
 	CreateTime         string `description:"创建时间"`
 	ModifyTime         string `description:"修改时间"`
 	ModifyTime         string `description:"修改时间"`
 }
 }
@@ -85,10 +85,16 @@ func (r *ReportPushStatus) Update(cols []string) (err error) {
 	return
 	return
 }
 }
 
 
-func GetReportPushStatusByReportId(reportId, state int) (item *ReportPushStatus, err error) {
+func (r *ReportPushStatus) Delete() (err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
-	sql := `SELECT * FROM report_push_status WHERE report_id=? AND state=?`
-	err = o.Raw(sql, reportId, state).QueryRow(&item)
+	_, err = o.Delete(r)
+	return
+}
+
+func GetReportPushStatusByReportId(reportPushStatusId, state int) (item *ReportPushStatus, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM report_push_status WHERE report_push_status_id=? AND state=?`
+	err = o.Raw(sql, reportPushStatusId, state).QueryRow(&item)
 	return
 	return
 }
 }
 
 
@@ -102,13 +108,23 @@ func GetReportPushStatusByReportIdAndState(reportId []int, state int) (items []*
 	return
 	return
 }
 }
 
 
-func GetReportPushStatusByReportIds(reportId []int) (items []*ReportPushStatus, err error) {
+func GetReportPushStatusByIdAndState(Id []int, state int) (items []*ReportPushStatus, err error) {
+	if len(Id) == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := `SELECT * FROM report_push_status WHERE report_push_status_id IN (` + utils.GetOrmReplaceHolder(len(Id)) + `) AND state=?`
+	_, err = o.Raw(sql, Id, state).QueryRows(&items)
+	return
+}
+
+func GetReportPushStatusByReportIds(reportType int, reportId []int) (items []*ReportPushStatus, err error) {
 	if len(reportId) == 0 {
 	if len(reportId) == 0 {
 		return
 		return
 	}
 	}
 	o := orm.NewOrm()
 	o := orm.NewOrm()
-	sql := `SELECT * FROM report_push_status WHERE report_id IN (` + utils.GetOrmReplaceHolder(len(reportId)) + `) `
-	_, err = o.Raw(sql, reportId).QueryRows(&items)
+	sql := `SELECT * FROM report_push_status WHERE report_type=? AND report_id IN (` + utils.GetOrmReplaceHolder(len(reportId)) + `) `
+	_, err = o.Raw(sql, reportType, reportId).QueryRows(&items)
 	return
 	return
 }
 }
 
 
@@ -146,6 +162,16 @@ func GetReportIdListByCondition(condition string, pars []interface{}) (reportId
 	return
 	return
 }
 }
 
 
+func GetReportPushStatusIdListByCondition(condition string, pars []interface{}) (reportPushStatusId []int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT report_push_status_id FROM report_push_status WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&reportPushStatusId)
+	return
+}
+
 func GetReportCountById(id int) (count int, err error) {
 func GetReportCountById(id int) (count int, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	o := orm.NewOrmUsingDB("rddp")
 	sql := `SELECT COUNT(*) AS count FROM report WHERE (state=2 OR state=6) AND id=?`
 	sql := `SELECT COUNT(*) AS count FROM report WHERE (state=2 OR state=6) AND id=?`
@@ -164,24 +190,24 @@ func GetReportCountByCondition(condition string, pars []interface{}) (count int,
 }
 }
 
 
 // BatchPushReport 批量推送报告
 // BatchPushReport 批量推送报告
-func BatchPushReport(reportId []int) (err error) {
-	if len(reportId) == 0 {
+func BatchPushReport(reportPushStatusId []int) (err error) {
+	if len(reportPushStatusId) == 0 {
 		return
 		return
 	}
 	}
 	o := orm.NewOrm()
 	o := orm.NewOrm()
-	sql := `UPDATE report_push_status SET state=1, push_time=NOW() WHERE report_id IN (` + utils.GetOrmReplaceHolder(len(reportId)) + `)`
-	_, err = o.Raw(sql, reportId).Exec()
+	sql := `UPDATE report_push_status SET state=1, push_time=NOW() WHERE report_push_status_id IN (` + utils.GetOrmReplaceHolder(len(reportPushStatusId)) + `)`
+	_, err = o.Raw(sql, reportPushStatusId).Exec()
 	return
 	return
 }
 }
 
 
 // BatchPushCancelReport 批量撤销推送报告
 // BatchPushCancelReport 批量撤销推送报告
-func BatchPushCancelReport(reportId []int) (err error) {
-	if len(reportId) == 0 {
+func BatchPushCancelReport(reportPushStatusId []int) (err error) {
+	if len(reportPushStatusId) == 0 {
 		return
 		return
 	}
 	}
 	o := orm.NewOrm()
 	o := orm.NewOrm()
-	sql := `UPDATE report_push_status SET state=0, modify_time=NOW() WHERE report_id IN (` + utils.GetOrmReplaceHolder(len(reportId)) + `)`
-	_, err = o.Raw(sql, reportId).Exec()
+	sql := `UPDATE report_push_status SET state=0, modify_time=NOW() WHERE report_push_status_id IN (` + utils.GetOrmReplaceHolder(len(reportPushStatusId)) + `)`
+	_, err = o.Raw(sql, reportPushStatusId).Exec()
 	return
 	return
 }
 }
 
 

+ 1 - 1
models/request/report_push_status.go

@@ -1,7 +1,7 @@
 package request
 package request
 
 
 type ReportPushStatusReq struct {
 type ReportPushStatusReq struct {
-	ReportId int
+	ReportPushStatusId int
 }
 }
 
 
 type BatchReportModifyPushStatusReq struct {
 type BatchReportModifyPushStatusReq struct {

+ 1 - 1
scheduler/task.go

@@ -44,7 +44,7 @@ func SyncReportPushStatus(ctx context.Context) (err error) {
 	for _, v := range reportList {
 	for _, v := range reportList {
 		reportIds = append(reportIds, v.Id)
 		reportIds = append(reportIds, v.Id)
 	}
 	}
-	reportPushList, err := models.GetReportPushStatusByReportIds(reportIds)
+	reportPushList, err := models.GetReportPushStatusByReportIds(utils.ReportTypeEta, reportIds)
 	if err != nil {
 	if err != nil {
 		return
 		return
 	}
 	}

+ 64 - 4
services/task.go

@@ -13,7 +13,9 @@ func InitTask() {
 	// 创建Es索引
 	// 创建Es索引
 	CreateIndex()
 	CreateIndex()
 	// 初始化研报推送状态
 	// 初始化研报推送状态
-	InitReportPushStatus()
+	InitEtaReportPushStatus()
+	// 初始化pdf报告推送状态
+	InitPdfReportPushStatus()
 	// 初始化系统用户权限
 	// 初始化系统用户权限
 	InitSystemUserPermission()
 	InitSystemUserPermission()
 	fmt.Println("end task!")
 	fmt.Println("end task!")
@@ -58,7 +60,7 @@ func CreateIndex() {
 	}
 	}
 }
 }
 
 
-func InitReportPushStatus() {
+func InitEtaReportPushStatus() {
 	for {
 	for {
 		maxId, err := models.GetMaxSyncIdReportPush(1)
 		maxId, err := models.GetMaxSyncIdReportPush(1)
 		fmt.Println("同步研报开始, maxId:", maxId)
 		fmt.Println("同步研报开始, maxId:", maxId)
@@ -73,7 +75,7 @@ func InitReportPushStatus() {
 		for _, v := range reportList {
 		for _, v := range reportList {
 			reportIds = append(reportIds, v.Id)
 			reportIds = append(reportIds, v.Id)
 		}
 		}
-		reportPushList, err := models.GetReportPushStatusByReportIds(reportIds)
+		reportPushList, err := models.GetReportPushStatusByReportIds(utils.ReportTypeEta, reportIds)
 		if err != nil {
 		if err != nil {
 			return
 			return
 		}
 		}
@@ -97,7 +99,7 @@ func InitReportPushStatus() {
 					ClassifyIdThird:    v.ClassifyIdThird,
 					ClassifyIdThird:    v.ClassifyIdThird,
 					ClassifyNameThird:  v.ClassifyNameThird,
 					ClassifyNameThird:  v.ClassifyNameThird,
 					Author:             v.Author,
 					Author:             v.Author,
-					ReportType:         1,
+					ReportType:         utils.ReportTypeEta,
 					PublishTime:        v.PublishTime,
 					PublishTime:        v.PublishTime,
 					CreateTime:         time.Now(),
 					CreateTime:         time.Now(),
 					ModifyTime:         time.Now(),
 					ModifyTime:         time.Now(),
@@ -115,6 +117,64 @@ func InitReportPushStatus() {
 	}
 	}
 }
 }
 
 
+// 初始化pdf报告的推送状态
+func InitPdfReportPushStatus() {
+	for {
+		maxId, err := models.GetMaxSyncIdReportPush(2)
+		fmt.Println("同步pdf研报开始, maxId:", maxId)
+		if err != nil {
+			fmt.Println("同步研pdf报失败, Err:", err)
+		}
+		reportList, err := models.GetBatchPdfReport(maxId, 100)
+		if err != nil {
+			fmt.Println("同步pdf研报失败, 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(),
+				})
+			}
+		}
+		err = models.BatchAddReportPushStatus(insertReportPushList)
+		if err != nil {
+			return
+		}
+		if len(reportList) != 100 {
+			fmt.Println("同步pdf研报完成")
+			return
+		}
+	}
+}
+
 func InitSystemUserPermission() {
 func InitSystemUserPermission() {
 	menuList, err := models.GetSysMenuItemsByCondition("", []interface{}{}, []string{"sys_menu_id"}, "")
 	menuList, err := models.GetSysMenuItemsByCondition("", []interface{}{}, []string{"sys_menu_id"}, "")
 	if err != nil {
 	if err != nil {

+ 5 - 0
utils/constants.go

@@ -60,6 +60,11 @@ const (
 	ReportStatusDown = 2 // 研报未发布
 	ReportStatusDown = 2 // 研报未发布
 )
 )
 
 
+const (
+	ReportTypeEta = 1 // eta研报
+	ReportTypePdf = 2 // pdf研报
+)
+
 const (
 const (
 	STORAGESOURCE_OSS_NAME   = "oss"
 	STORAGESOURCE_OSS_NAME   = "oss"
 	STORAGESOURCE_MINIO_NAME = "minio"
 	STORAGESOURCE_MINIO_NAME = "minio"