kobe6258 il y a 7 mois
Parent
commit
d8d4ddbf29
2 fichiers modifiés avec 13 ajouts et 9 suppressions
  1. 9 6
      main.go
  2. 4 3
      models/ht/ht_report.go

+ 9 - 6
main.go

@@ -22,7 +22,6 @@ func main() {
 		web.BConfig.WebConfig.DirectoryIndex = true
 		web.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
 	}
-	//sysConfig := config.GetConfig(contants.HT).(*config.HTBizConfig)
 	//web.ErrorHandler("*", exception.ControllerAdvice())
 	web.BConfig.RecoverFunc = exception.PanicAdvice
 	go func() {
@@ -76,11 +75,13 @@ func initReport() {
 					t := time.UnixMilli(timestamp)
 					htReportList[i].PublishedTime = t.Format(time.DateTime)
 					plateId := htReportList[i].PlateId
-					plate, err := ht.GetPermissionNameById(plateId)
+					var plate ht.HTPlate
+					plate, err = ht.GetPermissionNameById(plateId)
 					if err != nil || plate.ParentId == 0 {
 						htReportList[i].PermissionName = htReportList[i].PlateName
 					} else {
-						PermissionName, err := getPermissionNameById(plate.ParentId)
+						var PermissionName string
+						err = getPermissionNameById(plate.Id, &PermissionName)
 						if err != nil {
 							logger.Error("获取ETA研报列表失败:%v", err)
 							htReportList[i].PermissionName = ""
@@ -109,14 +110,16 @@ func initReport() {
 	logger.Info("初始化研报库完成")
 }
 
-func getPermissionNameById(id int) (name string, err error) {
+func getPermissionNameById(id int, currentName *string) (err error) {
 	plate, err := ht.GetPermissionNameById(id)
 	if err != nil {
+		logger.Error("查询海通板块品种名称失败:%v", err)
 		return
 	}
 	if plate.ParentId != 0 {
-		return getPermissionNameById(plate.ParentId)
+		*currentName = plate.PlateName
+		return getPermissionNameById(plate.ParentId, currentName)
 	} else {
-		return plate.PlateName, nil
+		return
 	}
 }

+ 4 - 3
models/ht/ht_report.go

@@ -7,6 +7,7 @@ import (
 
 const (
 	Publish = 3
+	limit   = 50
 )
 
 type HTReport struct {
@@ -24,15 +25,15 @@ type HTReport struct {
 
 func GetHTReports(id int) (reports []HTReport, err error) {
 	db := models.HT()
-	sql := "select tirtp.plate_id as plate_id, tip.plate_name as plate_name, t.id as id ,t.report_name as report_name,t.publish_user_name as publish_user_name,t.publish_time as publish_time,t.is_delete as is_delete,t.status as status from t_iirp_report_to_plate tirtp left join t_iirp_report_info t on t.id=tirtp.report_id left JOIN t_iirp_plate tip on tip.id=tirtp.plate_id  where t.is_delete =0 and t.`status` =3 and t.report_file_path<>'' and t.id > ? order by t.id asc"
-	err = db.Model(&HTReport{}).Raw(sql, id).Scan(&reports).Error
+	sql := "select distinct t.id as id,tirtp.plate_id as plate_id, tip.plate_name as plate_name, t.id as id ,t.report_name as report_name,t.publish_user_name as publish_user_name,t.publish_time as publish_time,t.is_delete as is_delete,t.status as status from t_iirp_report_to_plate tirtp left join t_iirp_report_info t on t.id=tirtp.report_id left JOIN t_iirp_plate tip on tip.id=tirtp.plate_id  where t.is_delete =0 and t.`status` =3 and t.report_file_path<>'' and t.id > ?   order by t.id asc limit 0,?"
+	err = db.Model(&HTReport{}).Raw(sql, id, limit).Scan(&reports).Error
 	return
 }
 func GetUpdateHTReports() (reports []HTReport, err error) {
 	duration := time.Now().Add(-30 * time.Second)
 	updateTime := duration.UnixMilli()
 	db := models.HT()
-	sql := "select tirtp.plate_id as plate_id, tip.plate_name as plate_name, t.id as id ,t.report_name as report_name,t.publish_user_name as publish_user_name,t.publish_time as publish_time,t.is_delete as is_delete,t.status as status from t_iirp_report_to_plate tirtp left join t_iirp_report_info t on t.id=tirtp.report_id left JOIN t_iirp_plate tip on tip.id=tirtp.plate_id  where  t.report_file_path<>'' and t.update_time > ? order by t.id asc"
+	sql := "select distinct t.id as id, tirtp.plate_id as plate_id, tip.plate_name as plate_name, t.id as id ,t.report_name as report_name,t.publish_user_name as publish_user_name,t.publish_time as publish_time,t.is_delete as is_delete,t.status as status from t_iirp_report_to_plate tirtp left join t_iirp_report_info t on t.id=tirtp.report_id left JOIN t_iirp_plate tip on tip.id=tirtp.plate_id  where  t.report_file_path<>'' and t.update_time > ? order by t.id asc"
 	err = db.Model(&HTReport{}).Raw(sql, updateTime).Scan(&reports).Error
 	return
 }