hsun 1 éve
szülő
commit
5d5c91c986

+ 3 - 3
controllers/data_manage/lz_data.go

@@ -562,7 +562,7 @@ func (this *EdbInfoController) ExportLzQuotasData() {
 	}
 	}
 
 
 	// 获取多个品种的指标信息
 	// 获取多个品种的指标信息
-	quotaList, err := models.GetExportLzSurveyProductByBreedIds(breedIdsStr)
+	quotaList, err := models.GetExportLzSurveyProductByBreedIds(breedIds)
 	if err != nil {
 	if err != nil {
 		br.Msg = "导出失败"
 		br.Msg = "导出失败"
 		br.ErrMsg = "获取指标信息失败, Err: " + err.Error()
 		br.ErrMsg = "获取指标信息失败, Err: " + err.Error()
@@ -570,7 +570,7 @@ func (this *EdbInfoController) ExportLzQuotasData() {
 	}
 	}
 
 
 	// 获取多个品种的指标最大数据量
 	// 获取多个品种的指标最大数据量
-	quotaMaxCountList, err := data_source.GetExportLzSurveyDataMaxCount(breedIdsStr)
+	quotaMaxCountList, err := data_source.GetExportLzSurveyDataMaxCount(breedIds)
 	if err != nil {
 	if err != nil {
 		br.Msg = "导出失败"
 		br.Msg = "导出失败"
 		br.ErrMsg = "获取指标最大数据量失败, Err: " + err.Error()
 		br.ErrMsg = "获取指标最大数据量失败, Err: " + err.Error()
@@ -587,7 +587,7 @@ func (this *EdbInfoController) ExportLzQuotasData() {
 		var iniArr []*data_source.LongzhongSurveyData
 		var iniArr []*data_source.LongzhongSurveyData
 		productIdDataMatch[quotaList[i].SurveyProductId] = iniArr
 		productIdDataMatch[quotaList[i].SurveyProductId] = iniArr
 	}
 	}
-	quotaDataList, err := data_source.GetExportLzSurveyDataByBreedIds(breedIdsStr)
+	quotaDataList, err := data_source.GetExportLzSurveyDataByBreedIds(breedIds)
 	for k, _ := range productIdDataMatch {
 	for k, _ := range productIdDataMatch {
 		var tmpArr []*data_source.LongzhongSurveyData
 		var tmpArr []*data_source.LongzhongSurveyData
 		for _, qd := range quotaDataList {
 		for _, qd := range quotaDataList {

+ 5 - 5
controllers/report.go

@@ -139,14 +139,14 @@ func (this *ReportController) ListReport() {
 				syncReportIdArr = append(syncReportIdArr, strconv.Itoa(list[i].OldReportId))
 				syncReportIdArr = append(syncReportIdArr, strconv.Itoa(list[i].OldReportId))
 			}
 			}
 		}
 		}
-		reportIds := strings.Join(reportIdArr, ",")
-		syncReportIds := strings.Join(syncReportIdArr, ",")
+		//reportIds := strings.Join(reportIdArr, ",")
+		//syncReportIds := strings.Join(syncReportIdArr, ",")
 
 
 		// 查询同步过来的报告对应的老报告PV+UV
 		// 查询同步过来的报告对应的老报告PV+UV
 		pvMap := make(map[int]int, 0)
 		pvMap := make(map[int]int, 0)
 		uvMap := make(map[int]int, 0)
 		uvMap := make(map[int]int, 0)
-		if syncReportIds != "" {
-			puvList, e := models.GetPUVByResearchReportIds(syncReportIds)
+		if len(syncReportIdArr) > 0 {
+			puvList, e := models.GetPUVByResearchReportIds(syncReportIdArr)
 			if e != nil {
 			if e != nil {
 				br.Msg = "获取失败"
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取同步报告对应的PV、UV失败, Err: " + e.Error()
 				br.ErrMsg = "获取同步报告对应的PV、UV失败, Err: " + e.Error()
@@ -159,7 +159,7 @@ func (this *ReportController) ListReport() {
 			}
 			}
 		}
 		}
 		// 晨周报音频列表
 		// 晨周报音频列表
-		videoList, err := models.GetReportChapterVideoListByReportIds(reportIds)
+		videoList, err := models.GetReportChapterVideoListByReportIds(reportIdArr)
 		if err != nil {
 		if err != nil {
 			br.Msg = "获取失败"
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取报告音频文件失败,Err:" + err.Error()
 			br.ErrMsg = "获取报告音频文件失败,Err:" + err.Error()

+ 7 - 5
controllers/sys_admin.go

@@ -116,7 +116,7 @@ func (this *SysAdminController) ListSysuser() {
 	}
 	}
 
 
 	var list []*system.AdminItem
 	var list []*system.AdminItem
-	adminIdArr := make([]string, 0)
+	adminIdArr := make([]int, 0)
 	if teamId <= 0 {
 	if teamId <= 0 {
 		//if groupId > 0 {
 		//if groupId > 0 {
 		//	ids, err := system.GetGroupIdByParentId(groupId, startSize, pageSize)
 		//	ids, err := system.GetGroupIdByParentId(groupId, startSize, pageSize)
@@ -145,7 +145,8 @@ func (this *SysAdminController) ListSysuser() {
 		for i := 0; i < lenList; i++ {
 		for i := 0; i < lenList; i++ {
 
 
 			item := list[i]
 			item := list[i]
-			adminIdArr = append(adminIdArr, strconv.Itoa(item.AdminId))
+			//adminIdArr = append(adminIdArr, strconv.Itoa(item.AdminId))
+			adminIdArr = append(adminIdArr, item.AdminId)
 			var secondName *string
 			var secondName *string
 			if item.GroupId != 0 {
 			if item.GroupId != 0 {
 				pid, err := company.GetParentIdFromGroup(item.GroupId)
 				pid, err := company.GetParentIdFromGroup(item.GroupId)
@@ -218,7 +219,8 @@ func (this *SysAdminController) ListSysuser() {
 		lenList := len(list)
 		lenList := len(list)
 		for i := 0; i < lenList; i++ {
 		for i := 0; i < lenList; i++ {
 			item := list[i]
 			item := list[i]
-			adminIdArr = append(adminIdArr, strconv.Itoa(item.AdminId))
+			//adminIdArr = append(adminIdArr, strconv.Itoa(item.AdminId))
+			adminIdArr = append(adminIdArr, item.AdminId)
 
 
 			if item.DepartmentName != "" {
 			if item.DepartmentName != "" {
 				if item.GroupName == "" {
 				if item.GroupName == "" {
@@ -266,9 +268,9 @@ func (this *SysAdminController) ListSysuser() {
 	}
 	}
 	// 研究方向分组
 	// 研究方向分组
 	if len(adminIdArr) > 0 {
 	if len(adminIdArr) > 0 {
-		adminIds := strings.Join(adminIdArr, ",")
+		//adminIds := strings.Join(adminIdArr, ",")
 		//researchGroupList, e := system.GetAdminResearchGroupListByAdminId(adminIds)
 		//researchGroupList, e := system.GetAdminResearchGroupListByAdminId(adminIds)
-		researchGroupList, e := models.GetAdminVarietyTagRelationListByAdminId(adminIds)
+		researchGroupList, e := models.GetAdminVarietyTagRelationListByAdminId(adminIdArr)
 		if e != nil {
 		if e != nil {
 			br.Msg = "获取失败"
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取研究方向分组列表失败, Err:" + e.Error()
 			br.ErrMsg = "获取研究方向分组列表失败, Err:" + e.Error()

+ 20 - 2
controllers/voice.go

@@ -11,6 +11,8 @@ import (
 	"io/ioutil"
 	"io/ioutil"
 	"os"
 	"os"
 	"path"
 	"path"
+	"strconv"
+	"strings"
 	"time"
 	"time"
 )
 )
 
 
@@ -185,11 +187,27 @@ func (this *VoiceCommonController) ReportChapterDownload() {
 		this.Data["json"] = br
 		this.Data["json"] = br
 		this.ServeJSON()
 		this.ServeJSON()
 	}()
 	}()
-	chapterIds := this.GetString("ChapterIds")
-	if chapterIds == "" {
+	strChapterIds := this.GetString("ChapterIds")
+	if strChapterIds == "" {
 		br.Msg = "参数错误"
 		br.Msg = "参数错误"
 		return
 		return
 	}
 	}
+	chapterIds := make([]int, 0)
+	chapterIdArr := strings.Split(strChapterIds, ",")
+	for _, v := range chapterIdArr {
+		id, e := strconv.Atoi(v)
+		if e != nil {
+			br.Msg = "参数有误"
+			br.ErrMsg = "章节ID有误, Err: " + e.Error()
+			return
+		}
+		chapterIds = append(chapterIds, id)
+	}
+	if len(chapterIds) == 0 {
+		br.Msg = "参数有误"
+		return
+	}
+
 	videoList, err := models.GetReportChapterVideoListByChapterIds(chapterIds)
 	videoList, err := models.GetReportChapterVideoListByChapterIds(chapterIds)
 	if err != nil {
 	if err != nil {
 		br.Msg = "获取音频列表失败"
 		br.Msg = "获取音频列表失败"

+ 67 - 58
models/data_manage/baiinfo_data.go

@@ -3,6 +3,7 @@ package data_manage
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hz_eta_api/utils"
 )
 )
 
 
 type BaiinfoClassify struct {
 type BaiinfoClassify struct {
@@ -31,21 +32,21 @@ func GetBaiinfoFrequencyByClassifyId(classifyId int) (items []*GlFrequency, err
 
 
 type BaiinfoIndex struct {
 type BaiinfoIndex struct {
 	BaseFromBaiinfoIndexId int `orm:"column(base_from_baiinfo_index_id);pk"`
 	BaseFromBaiinfoIndexId int `orm:"column(base_from_baiinfo_index_id);pk"`
-	Interface          string
-	Name               string
-	IndexCode          string
-	IndexName          string
-	Type1              string `orm:"column(type_1)"`
-	Type2              string `orm:"column(type_2)"`
-	Type3              string `orm:"column(type_3)"`
-	Frequency          string
-	Unit               string
-	ApiStartTime       string
-	ApiUpdateTime      string
-	StartTime          string
-	FinishTime         string
-	CreateTime         string
-	ModifyTime         string
+	Interface              string
+	Name                   string
+	IndexCode              string
+	IndexName              string
+	Type1                  string `orm:"column(type_1)"`
+	Type2                  string `orm:"column(type_2)"`
+	Type3                  string `orm:"column(type_3)"`
+	Frequency              string
+	Unit                   string
+	ApiStartTime           string
+	ApiUpdateTime          string
+	StartTime              string
+	FinishTime             string
+	CreateTime             string
+	ModifyTime             string
 }
 }
 
 
 func GetBaiinfoIndex(condition string, pars interface{}) (items []*BaiinfoIndex, err error) {
 func GetBaiinfoIndex(condition string, pars interface{}) (items []*BaiinfoIndex, err error) {
@@ -60,26 +61,28 @@ func GetBaiinfoIndex(condition string, pars interface{}) (items []*BaiinfoIndex,
 }
 }
 
 
 type BaiinfoExportIndex struct {
 type BaiinfoExportIndex struct {
-	TypeName	string
-	IndexCode	string
-	IndexName   string
-	Type1		string	`orm:"column(type_1)"`
-	Type2		string	`orm:"column(type_2)"`
-	Type3		string	`orm:"column(type_3)"`
-	Frequency	string
-	Unit		string
-	ModifyTime	string
-}
-
-func GetExportBaiinfoIndex(typeCodes string) (items []*BaiinfoExportIndex, err error) {
+	TypeName   string
+	IndexCode  string
+	IndexName  string
+	Type1      string `orm:"column(type_1)"`
+	Type2      string `orm:"column(type_2)"`
+	Type3      string `orm:"column(type_3)"`
+	Frequency  string
+	Unit       string
+	ModifyTime string
+}
+
+func GetExportBaiinfoIndex(typeCodes []string) (items []*BaiinfoExportIndex, err error) {
+	if len(typeCodes) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT *,CONCAT(type_2, "#", type_3) AS type_name FROM base_from_baiinfo_index WHERE CONCAT(type_2, "#", type_3) IN (` + typeCodes + `) ORDER BY frequency ASC,index_code ASC`
-	_, err = o.Raw(sql).QueryRows(&items)
-
+	sql := ` SELECT *,CONCAT(type_2, "#", type_3) AS type_name FROM base_from_baiinfo_index WHERE CONCAT(type_2, "#", type_3) IN (` + utils.GetOrmInReplace(len(typeCodes)) + `) ORDER BY frequency ASC,index_code ASC`
+	_, err = o.Raw(sql, typeCodes).QueryRows(&items)
 	return
 	return
 }
 }
 
 
-func GetBaiinfoFrequency(classifyId int ) (items []*string,err error){
+func GetBaiinfoFrequency(classifyId int) (items []*string, err error) {
 	sql := `SELECT DISTINCT frequency FROM base_from_baiinfo_index WHERE classify_id=? ORDER BY FIELD(frequency,'日度','周度','月度','季度','半年','年度') `
 	sql := `SELECT DISTINCT frequency FROM base_from_baiinfo_index WHERE classify_id=? ORDER BY FIELD(frequency,'日度','周度','月度','季度','半年','年度') `
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sql, classifyId).QueryRows(&items)
 	_, err = o.Raw(sql, classifyId).QueryRows(&items)
@@ -95,22 +98,22 @@ func GetBaiinfoFrequencyByCode(code string) (items []*string, err error) {
 
 
 type BaiinfoIndexList struct {
 type BaiinfoIndexList struct {
 	BaseFromBaiinfoIndexId int `orm:"column(base_from_baiinfo_index_id);pk"`
 	BaseFromBaiinfoIndexId int `orm:"column(base_from_baiinfo_index_id);pk"`
-	Interface          string
-	Name               string
-	IndexCode          string
-	IndexName          string
-	Type1              string `orm:"column(type_1)"`
-	Type2              string `orm:"column(type_2)"`
-	Type3              string `orm:"column(type_3)"`
-	Frequency          string
-	Unit               string
-	ApiStartTime       string
-	ApiUpdateTime      string
-	StartTime          string
-	FinishTime         string
-	ModifyTime         string
-	DataList           []*BaiinfoIndexData
-	Paging             *paging.PagingItem `description:"分页数据"`
+	Interface              string
+	Name                   string
+	IndexCode              string
+	IndexName              string
+	Type1                  string `orm:"column(type_1)"`
+	Type2                  string `orm:"column(type_2)"`
+	Type3                  string `orm:"column(type_3)"`
+	Frequency              string
+	Unit                   string
+	ApiStartTime           string
+	ApiUpdateTime          string
+	StartTime              string
+	FinishTime             string
+	ModifyTime             string
+	DataList               []*BaiinfoIndexData
+	Paging                 *paging.PagingItem `description:"分页数据"`
 }
 }
 
 
 type BaiinfoIndexData struct {
 type BaiinfoIndexData struct {
@@ -160,11 +163,14 @@ func GetBaiinfoDataMaxCount(classifyId int) (count int, err error) {
 }
 }
 
 
 type ExportBaiinfoDataMaxCount struct {
 type ExportBaiinfoDataMaxCount struct {
-	TypeName	string
-	Count		int
+	TypeName string
+	Count    int
 }
 }
 
 
-func GetExportBaiinfoDataMaxCount(typeCodes string) (items []*ExportBaiinfoDataMaxCount, err error) {
+func GetExportBaiinfoDataMaxCount(typeCodes []string) (items []*ExportBaiinfoDataMaxCount, err error) {
+	if len(typeCodes) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT
 	sql := ` SELECT
 				MAX(t.num) AS count,
 				MAX(t.num) AS count,
@@ -178,26 +184,29 @@ func GetExportBaiinfoDataMaxCount(typeCodes string) (items []*ExportBaiinfoDataM
 						base_from_baiinfo_index AS a
 						base_from_baiinfo_index AS a
 					INNER JOIN base_from_baiinfo_data AS b ON a.index_code = b.index_code
 					INNER JOIN base_from_baiinfo_data AS b ON a.index_code = b.index_code
 					WHERE
 					WHERE
-						CONCAT(a.type_2, "#", a.type_3) IN (` + typeCodes + `)
+						CONCAT(a.type_2, "#", a.type_3) IN (` + utils.GetOrmInReplace(len(typeCodes)) + `)
 					GROUP BY
 					GROUP BY
 						a.base_from_baiinfo_index_id
 						a.base_from_baiinfo_index_id
 				) AS t
 				) AS t
 			GROUP BY
 			GROUP BY
 				type_name `
 				type_name `
-	_, err = o.Raw(sql).QueryRows(&items)
+	_, err = o.Raw(sql, typeCodes).QueryRows(&items)
 
 
 	return
 	return
 }
 }
 
 
 type ExportBaiinfoIndexData struct {
 type ExportBaiinfoIndexData struct {
-	Value    	string 	`orm:"column(value)" description:"日期"`
-	DataTime 	string 	`orm:"column(data_time)" description:"值"`
-	IndexCode	string	`orm:"column(index_code)" description:"指标编码"`
+	Value     string `orm:"column(value)" description:"日期"`
+	DataTime  string `orm:"column(data_time)" description:"值"`
+	IndexCode string `orm:"column(index_code)" description:"指标编码"`
 }
 }
 
 
-func GetExportBaiinfoIndexDataByCodes(indexCodes string) (items []*ExportBaiinfoIndexData, err error) {
+func GetExportBaiinfoIndexDataByCodes(indexCodes []string) (items []*ExportBaiinfoIndexData, err error) {
+	if len(indexCodes) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT index_code,data_time,value FROM base_from_baiinfo_data WHERE index_code IN (` + indexCodes + `) ORDER BY data_time DESC  `
-	_, err = o.Raw(sql).QueryRows(&items)
+	sql := ` SELECT index_code,data_time,value FROM base_from_baiinfo_data WHERE index_code IN (` + utils.GetOrmInReplace(len(indexCodes)) + `) ORDER BY data_time DESC  `
+	_, err = o.Raw(sql, indexCodes).QueryRows(&items)
 	return
 	return
 }
 }

+ 36 - 28
models/data_manage/sci_data.go

@@ -3,6 +3,7 @@ package data_manage
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hz_eta_api/utils"
 )
 )
 
 
 type SciClassify struct {
 type SciClassify struct {
@@ -60,26 +61,28 @@ func GetSciIndex(condition string, pars interface{}) (items []*SciIndex, err err
 }
 }
 
 
 type SciExportIndex struct {
 type SciExportIndex struct {
-	TypeName	string
-	IndexCode	string
-	IndexName   string
-	Type1		string	`orm:"column(type_1)"`
-	Type2		string	`orm:"column(type_2)"`
-	Type3		string	`orm:"column(type_3)"`
-	Frequency	string
-	Unit		string
-	ModifyTime	string
-}
-
-func GetExportSciIndex(typeCodes string) (items []*SciExportIndex, err error) {
+	TypeName   string
+	IndexCode  string
+	IndexName  string
+	Type1      string `orm:"column(type_1)"`
+	Type2      string `orm:"column(type_2)"`
+	Type3      string `orm:"column(type_3)"`
+	Frequency  string
+	Unit       string
+	ModifyTime string
+}
+
+func GetExportSciIndex(typeCodes []string) (items []*SciExportIndex, err error) {
+	if len(typeCodes) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT *,CONCAT(type_2, "#", type_3) AS type_name FROM base_from_sci_index WHERE CONCAT(type_2, "#", type_3) IN (` + typeCodes + `) ORDER BY frequency ASC,index_code ASC`
-	_, err = o.Raw(sql).QueryRows(&items)
-
+	sql := ` SELECT *,CONCAT(type_2, "#", type_3) AS type_name FROM base_from_sci_index WHERE CONCAT(type_2, "#", type_3) IN (` + utils.GetOrmInReplace(len(typeCodes)) + `) ORDER BY frequency ASC,index_code ASC`
+	_, err = o.Raw(sql, typeCodes).QueryRows(&items)
 	return
 	return
 }
 }
 
 
-func GetSciFrequency(classifyId int ) (items []*string,err error){
+func GetSciFrequency(classifyId int) (items []*string, err error) {
 	sql := `SELECT DISTINCT frequency FROM base_from_sci_index WHERE classify_id=? ORDER BY FIELD(frequency,'日度','周度','月度','季度','半年','年度') `
 	sql := `SELECT DISTINCT frequency FROM base_from_sci_index WHERE classify_id=? ORDER BY FIELD(frequency,'日度','周度','月度','季度','半年','年度') `
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sql, classifyId).QueryRows(&items)
 	_, err = o.Raw(sql, classifyId).QueryRows(&items)
@@ -160,11 +163,14 @@ func GetSciDataMaxCount(classifyId int) (count int, err error) {
 }
 }
 
 
 type ExportSciDataMaxCount struct {
 type ExportSciDataMaxCount struct {
-	TypeName	string
-	Count		int
+	TypeName string
+	Count    int
 }
 }
 
 
-func GetExportSciDataMaxCount(typeCodes string) (items []*ExportSciDataMaxCount, err error) {
+func GetExportSciDataMaxCount(typeCodes []string) (items []*ExportSciDataMaxCount, err error) {
+	if len(typeCodes) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT
 	sql := ` SELECT
 				MAX(t.num) AS count,
 				MAX(t.num) AS count,
@@ -178,26 +184,28 @@ func GetExportSciDataMaxCount(typeCodes string) (items []*ExportSciDataMaxCount,
 						base_from_sci_index AS a
 						base_from_sci_index AS a
 					INNER JOIN base_from_sci_data AS b ON a.index_code = b.index_code
 					INNER JOIN base_from_sci_data AS b ON a.index_code = b.index_code
 					WHERE
 					WHERE
-						CONCAT(a.type_2, "#", a.type_3) IN (` + typeCodes + `)
+						CONCAT(a.type_2, "#", a.type_3) IN (` + utils.GetOrmInReplace(len(typeCodes)) + `)
 					GROUP BY
 					GROUP BY
 						a.base_from_sci_index_id
 						a.base_from_sci_index_id
 				) AS t
 				) AS t
 			GROUP BY
 			GROUP BY
 				type_name `
 				type_name `
-	_, err = o.Raw(sql).QueryRows(&items)
-
+	_, err = o.Raw(sql, typeCodes).QueryRows(&items)
 	return
 	return
 }
 }
 
 
 type ExportSciIndexData struct {
 type ExportSciIndexData struct {
-	Value    	string 	`orm:"column(value)" description:"日期"`
-	DataTime 	string 	`orm:"column(data_time)" description:"值"`
-	IndexCode	string	`orm:"column(index_code)" description:"指标编码"`
+	Value     string `orm:"column(value)" description:"日期"`
+	DataTime  string `orm:"column(data_time)" description:"值"`
+	IndexCode string `orm:"column(index_code)" description:"指标编码"`
 }
 }
 
 
-func GetExportSciIndexDataByCodes(indexCodes string) (items []*ExportSciIndexData, err error) {
+func GetExportSciIndexDataByCodes(indexCodes []string) (items []*ExportSciIndexData, err error) {
+	if len(indexCodes) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT index_code,data_time,value FROM base_from_sci_data WHERE index_code IN (` + indexCodes + `) ORDER BY data_time DESC  `
-	_, err = o.Raw(sql).QueryRows(&items)
+	sql := ` SELECT index_code,data_time,value FROM base_from_sci_data WHERE index_code IN (` + utils.GetOrmInReplace(len(indexCodes)) + `) ORDER BY data_time DESC  `
+	_, err = o.Raw(sql, indexCodes).QueryRows(&items)
 	return
 	return
 }
 }

+ 36 - 28
models/data_manage/smm_data.go

@@ -3,6 +3,7 @@ package data_manage
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hz_eta_api/utils"
 )
 )
 
 
 type SmmClassify struct {
 type SmmClassify struct {
@@ -60,26 +61,28 @@ func GetSmmIndex(condition string, pars interface{}) (items []*SmmIndex, err err
 }
 }
 
 
 type SmmExportIndex struct {
 type SmmExportIndex struct {
-	TypeName	string
-	IndexCode	string
-	IndexName   string
-	Type1		string	`orm:"column(type_1)"`
-	Type2		string	`orm:"column(type_2)"`
-	Type3		string	`orm:"column(type_3)"`
-	Frequency	string
-	Unit		string
-	ModifyTime	string
-}
-
-func GetExportSmmIndex(typeCodes string) (items []*SmmExportIndex, err error) {
+	TypeName   string
+	IndexCode  string
+	IndexName  string
+	Type1      string `orm:"column(type_1)"`
+	Type2      string `orm:"column(type_2)"`
+	Type3      string `orm:"column(type_3)"`
+	Frequency  string
+	Unit       string
+	ModifyTime string
+}
+
+func GetExportSmmIndex(typeCodes []string) (items []*SmmExportIndex, err error) {
+	if len(typeCodes) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT *,CONCAT(type_2, "#", type_3) AS type_name FROM base_from_smm_index WHERE CONCAT(type_2, "#", type_3) IN (` + typeCodes + `) ORDER BY frequency ASC,index_code ASC`
-	_, err = o.Raw(sql).QueryRows(&items)
-
+	sql := ` SELECT *,CONCAT(type_2, "#", type_3) AS type_name FROM base_from_smm_index WHERE CONCAT(type_2, "#", type_3) IN (` + utils.GetOrmInReplace(len(typeCodes)) + `) ORDER BY frequency ASC,index_code ASC`
+	_, err = o.Raw(sql, typeCodes).QueryRows(&items)
 	return
 	return
 }
 }
 
 
-func GetSmmFrequency(classifyId int ) (items []*string,err error){
+func GetSmmFrequency(classifyId int) (items []*string, err error) {
 	sql := `SELECT DISTINCT frequency FROM base_from_smm_index WHERE classify_id=? ORDER BY FIELD(frequency,'日度','周度','月度','季度','半年','年度') `
 	sql := `SELECT DISTINCT frequency FROM base_from_smm_index WHERE classify_id=? ORDER BY FIELD(frequency,'日度','周度','月度','季度','半年','年度') `
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
 	_, err = o.Raw(sql, classifyId).QueryRows(&items)
 	_, err = o.Raw(sql, classifyId).QueryRows(&items)
@@ -160,11 +163,14 @@ func GetSmmDataMaxCount(classifyId int) (count int, err error) {
 }
 }
 
 
 type ExportSmmDataMaxCount struct {
 type ExportSmmDataMaxCount struct {
-	TypeName	string
-	Count		int
+	TypeName string
+	Count    int
 }
 }
 
 
-func GetExportSmmDataMaxCount(typeCodes string) (items []*ExportSmmDataMaxCount, err error) {
+func GetExportSmmDataMaxCount(typeCodes []string) (items []*ExportSmmDataMaxCount, err error) {
+	if len(typeCodes) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT
 	sql := ` SELECT
 				MAX(t.num) AS count,
 				MAX(t.num) AS count,
@@ -178,26 +184,28 @@ func GetExportSmmDataMaxCount(typeCodes string) (items []*ExportSmmDataMaxCount,
 						base_from_smm_index AS a
 						base_from_smm_index AS a
 					INNER JOIN base_from_smm_data AS b ON a.index_code = b.index_code
 					INNER JOIN base_from_smm_data AS b ON a.index_code = b.index_code
 					WHERE
 					WHERE
-						CONCAT(a.type_2, "#", a.type_3) IN (` + typeCodes + `)
+						CONCAT(a.type_2, "#", a.type_3) IN (` + utils.GetOrmInReplace(len(typeCodes)) + `)
 					GROUP BY
 					GROUP BY
 						a.base_from_smm_index_id
 						a.base_from_smm_index_id
 				) AS t
 				) AS t
 			GROUP BY
 			GROUP BY
 				type_name `
 				type_name `
-	_, err = o.Raw(sql).QueryRows(&items)
-
+	_, err = o.Raw(sql, typeCodes).QueryRows(&items)
 	return
 	return
 }
 }
 
 
 type ExportSmmIndexData struct {
 type ExportSmmIndexData struct {
-	Value    	string 	`orm:"column(value)" description:"日期"`
-	DataTime 	string 	`orm:"column(data_time)" description:"值"`
-	IndexCode	string	`orm:"column(index_code)" description:"指标编码"`
+	Value     string `orm:"column(value)" description:"日期"`
+	DataTime  string `orm:"column(data_time)" description:"值"`
+	IndexCode string `orm:"column(index_code)" description:"指标编码"`
 }
 }
 
 
-func GetExportSmmIndexDataByCodes(indexCodes string) (items []*ExportSmmIndexData, err error) {
+func GetExportSmmIndexDataByCodes(indexCodes []string) (items []*ExportSmmIndexData, err error) {
+	if len(indexCodes) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("data")
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT index_code,data_time,value FROM base_from_smm_data WHERE index_code IN (` + indexCodes + `) ORDER BY data_time DESC  `
-	_, err = o.Raw(sql).QueryRows(&items)
+	sql := ` SELECT index_code,data_time,value FROM base_from_smm_data WHERE index_code IN (` + utils.GetOrmInReplace(len(indexCodes)) + `) ORDER BY data_time DESC  `
+	_, err = o.Raw(sql, indexCodes).QueryRows(&items)
 	return
 	return
 }
 }

+ 13 - 8
models/data_source/longzhong.go

@@ -3,6 +3,7 @@ package data_source
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
 	"hongze/hz_eta_api/models/data_manage"
 	"hongze/hz_eta_api/models/data_manage"
+	"hongze/hz_eta_api/utils"
 	"time"
 	"time"
 )
 )
 
 
@@ -83,7 +84,10 @@ type ExportLzSurveyDataMaxCount struct {
 	BreedId int `description:"品种ID"`
 	BreedId int `description:"品种ID"`
 }
 }
 
 
-func GetExportLzSurveyDataMaxCount(breedIds string) (items []ExportLzSurveyDataMaxCount, err error) {
+func GetExportLzSurveyDataMaxCount(breedIds []string) (items []ExportLzSurveyDataMaxCount, err error) {
+	if len(breedIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("edb")
 	o := orm.NewOrmUsingDB("edb")
 	sql := ` SELECT
 	sql := ` SELECT
 				MAX(t.num) AS count,
 				MAX(t.num) AS count,
@@ -97,23 +101,24 @@ func GetExportLzSurveyDataMaxCount(breedIds string) (items []ExportLzSurveyDataM
 						longzhong_survey_product AS a
 						longzhong_survey_product AS a
 					INNER JOIN longzhong_survey_data AS b ON a.survey_product_id = b.survey_product_id
 					INNER JOIN longzhong_survey_data AS b ON a.survey_product_id = b.survey_product_id
 					WHERE
 					WHERE
-						a.breed_id IN (` + breedIds + `)
+						a.breed_id IN (` + utils.GetOrmInReplace(len(breedIds)) + `)
 					GROUP BY
 					GROUP BY
 						a.survey_product_id
 						a.survey_product_id
 				) AS t
 				) AS t
 			GROUP BY
 			GROUP BY
 				t.breed_id `
 				t.breed_id `
-	_, err = o.Raw(sql).QueryRows(&items)
-
+	_, err = o.Raw(sql, breedIds).QueryRows(&items)
 	return
 	return
 }
 }
 
 
-func GetExportLzSurveyDataByBreedIds(breedIds string) (items []*LongzhongSurveyData, err error) {
+func GetExportLzSurveyDataByBreedIds(breedIds []string) (items []*LongzhongSurveyData, err error) {
+	if len(breedIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("edb")
 	o := orm.NewOrmUsingDB("edb")
 	fields := ` survey_product_id, breed_id, input_value, data_time `
 	fields := ` survey_product_id, breed_id, input_value, data_time `
-	sql := `SELECT ` + fields + ` FROM longzhong_survey_data WHERE breed_id IN (` + breedIds + `) ORDER BY breed_id ASC, survey_product_id ASC, data_time DESC `
-	_, err = o.Raw(sql).QueryRows(&items)
-
+	sql := `SELECT ` + fields + ` FROM longzhong_survey_data WHERE breed_id IN (` + utils.GetOrmInReplace(len(breedIds)) + `) ORDER BY breed_id ASC, survey_product_id ASC, data_time DESC `
+	_, err = o.Raw(sql, breedIds).QueryRows(&items)
 	return
 	return
 }
 }
 
 

+ 20 - 13
models/report.go

@@ -3,6 +3,7 @@ package models
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hz_eta_api/utils"
 	"strings"
 	"strings"
 	"time"
 	"time"
 )
 )
@@ -125,10 +126,13 @@ func GetReportList(condition string, pars []interface{}, companyType string, sta
 	return
 	return
 }
 }
 
 
-// 发布报告
-func PublishReport(reportIds string) (err error) {
+// PublishReport 发布报告
+func PublishReport(reportIds []int) (err error) {
+	if len(reportIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("rddp")
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `UPDATE report SET state=2,publish_time=now(),modify_time=NOW() WHERE id IN (` + reportIds + `)`
+	sql := `UPDATE report SET state=2,publish_time=now(),modify_time=NOW() WHERE id IN (` + utils.GetOrmInReplace(len(reportIds)) + `)`
 	_, err = o.Raw(sql).Exec()
 	_, err = o.Raw(sql).Exec()
 	return
 	return
 }
 }
@@ -196,10 +200,13 @@ func GetReportByIds(reportIds string) (list []*ReportDetail, err error) {
 }
 }
 
 
 // GetSimpleReportByIds 根据报告ID查询报告基本信息
 // GetSimpleReportByIds 根据报告ID查询报告基本信息
-func GetSimpleReportByIds(reportIds string) (list []*ReportDetail, err error) {
+func GetSimpleReportByIds(reportIds []int) (list []*ReportDetail, err error) {
+	if len(reportIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("rddp")
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT id, title FROM report WHERE id IN (` + reportIds + `)`
-	_, err = o.Raw(sql).QueryRows(&list)
+	sql := `SELECT id, title FROM report WHERE id IN (` + utils.GetOrmInReplace(len(reportIds)) + `)`
+	_, err = o.Raw(sql, reportIds).QueryRows(&list)
 	return
 	return
 }
 }
 
 
@@ -598,7 +605,7 @@ func GetNewReportExist(oldReportId int) (item *Report, err error) {
 }
 }
 
 
 // PublishReportAndChapter 发布报告及章节
 // PublishReportAndChapter 发布报告及章节
-func PublishReportAndChapter(reportInfo *Report, publishIds string, unPublishIds string, isPublishReport bool, cols []string) (err error) {
+func PublishReportAndChapter(reportInfo *Report, publishIds, unPublishIds []int, isPublishReport bool, cols []string) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	o := orm.NewOrmUsingDB("rddp")
 	to, err := o.Begin()
 	to, err := o.Begin()
 	if err != nil {
 	if err != nil {
@@ -618,13 +625,13 @@ func PublishReportAndChapter(reportInfo *Report, publishIds string, unPublishIds
 		}
 		}
 	}
 	}
 	// 发布章节
 	// 发布章节
-	if publishIds != "" {
-		sql := ` UPDATE report_chapter SET publish_state = 2, publish_time = ? WHERE report_id = ? AND report_chapter_id IN (` + publishIds + `) `
-		_, err = to.Raw(sql, reportInfo.PublishTime, reportInfo.Id).Exec()
+	if len(publishIds) > 0 {
+		sql := ` UPDATE report_chapter SET publish_state = 2, publish_time = ? WHERE report_id = ? AND report_chapter_id IN (` + utils.GetOrmInReplace(len(publishIds)) + `) `
+		_, err = to.Raw(sql, reportInfo.PublishTime, reportInfo.Id, publishIds).Exec()
 	}
 	}
-	if unPublishIds != "" {
-		sql := ` UPDATE report_chapter SET publish_state = 1, publish_time = NULL, is_edit = 0 WHERE report_id = ? AND report_chapter_id IN (` + unPublishIds + `) `
-		_, err = to.Raw(sql, reportInfo.Id).Exec()
+	if len(unPublishIds) > 0 {
+		sql := ` UPDATE report_chapter SET publish_state = 1, publish_time = NULL, is_edit = 0 WHERE report_id = ? AND report_chapter_id IN (` + utils.GetOrmInReplace(len(unPublishIds)) + `) `
+		_, err = to.Raw(sql, reportInfo.Id, unPublishIds).Exec()
 	}
 	}
 	return
 	return
 }
 }

+ 32 - 17
models/report_chapter.go

@@ -2,6 +2,7 @@ package models
 
 
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hz_eta_api/utils"
 	"time"
 	"time"
 )
 )
 
 
@@ -187,7 +188,10 @@ func GetReportChapterVideoList(reportId int) (list []*ReportChapterVideoList, er
 }
 }
 
 
 // GetReportChapterVideoListByReportIds 根据报告ID集合获取报告章节音频列表
 // GetReportChapterVideoListByReportIds 根据报告ID集合获取报告章节音频列表
-func GetReportChapterVideoListByReportIds(reportIds string) (list []*ReportChapterVideoList, err error) {
+func GetReportChapterVideoListByReportIds(reportIds []string) (list []*ReportChapterVideoList, err error) {
+	if len(reportIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("rddp")
 	o := orm.NewOrmUsingDB("rddp")
 	sql := ` SELECT
 	sql := ` SELECT
 				report_id,
 				report_id,
@@ -198,16 +202,19 @@ func GetReportChapterVideoListByReportIds(reportIds string) (list []*ReportChapt
 			FROM
 			FROM
 				report_chapter
 				report_chapter
 			WHERE
 			WHERE
-				report_id IN (` + reportIds + `) AND publish_state = 2 AND video_url != ""
+				report_id IN (` + utils.GetOrmInReplace(len(reportIds)) + `) AND publish_state = 2 AND video_url != ""
 			ORDER BY
 			ORDER BY
 				report_chapter_id ASC `
 				report_chapter_id ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
+	_, err = o.Raw(sql, reportIds).QueryRows(&list)
 
 
 	return
 	return
 }
 }
 
 
 // GetReportChapterVideoListByChapterIds 根据章节ID集合获取报告章节音频列表
 // GetReportChapterVideoListByChapterIds 根据章节ID集合获取报告章节音频列表
-func GetReportChapterVideoListByChapterIds(chapterIds string) (list []*ReportChapterVideoList, err error) {
+func GetReportChapterVideoListByChapterIds(chapterIds []int) (list []*ReportChapterVideoList, err error) {
+	if len(chapterIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("rddp")
 	o := orm.NewOrmUsingDB("rddp")
 	sql := ` SELECT
 	sql := ` SELECT
 				report_id,
 				report_id,
@@ -218,11 +225,10 @@ func GetReportChapterVideoListByChapterIds(chapterIds string) (list []*ReportCha
 			FROM
 			FROM
 				report_chapter
 				report_chapter
 			WHERE
 			WHERE
-				report_chapter_id IN (` + chapterIds + `) AND publish_state = 2
+				report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) AND publish_state = 2
 			ORDER BY
 			ORDER BY
 				report_chapter_id ASC `
 				report_chapter_id ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-
+	_, err = o.Raw(sql, chapterIds).QueryRows(&list)
 	return
 	return
 }
 }
 
 
@@ -251,27 +257,36 @@ func CountPublishedChapterNum(reportId int) (count int, err error) {
 	return
 	return
 }
 }
 
 
-// GetChapterListByReportId 根据ReportId获取章节列表
-func GetChapterListByChapterIds(chapterIds string) (list []*ReportChapter, err error) {
+// GetChapterListByChapterIds 根据ReportId获取章节列表
+func GetChapterListByChapterIds(chapterIds []int) (list []*ReportChapter, err error) {
+	if len(chapterIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("rddp")
 	o := orm.NewOrmUsingDB("rddp")
-	sql := ` SELECT * FROM report_chapter WHERE report_chapter_id IN (` + chapterIds + `) ORDER BY sort ASC`
-	_, err = o.Raw(sql).QueryRows(&list)
+	sql := ` SELECT * FROM report_chapter WHERE report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) ORDER BY sort ASC`
+	_, err = o.Raw(sql, chapterIds).QueryRows(&list)
 	return
 	return
 }
 }
 
 
 // GetChapterSimpleListByChapterIds 根据章节ID获取章节列表
 // GetChapterSimpleListByChapterIds 根据章节ID获取章节列表
-func GetChapterSimpleListByChapterIds(chapterIds string) (list []*ReportChapter, err error) {
+func GetChapterSimpleListByChapterIds(chapterIds []int) (list []*ReportChapter, err error) {
+	if len(chapterIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("rddp")
 	o := orm.NewOrmUsingDB("rddp")
-	sql := ` SELECT report_id, report_chapter_id, title, type_name, create_time, IF(publish_time,publish_time,create_time) as publish_time FROM report_chapter WHERE report_chapter_id IN (` + chapterIds + `) ORDER BY publish_time desc, sort ASC`
-	_, err = o.Raw(sql).QueryRows(&list)
+	sql := ` SELECT report_id, report_chapter_id, title, type_name, create_time, IF(publish_time,publish_time,create_time) as publish_time FROM report_chapter WHERE report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) ORDER BY publish_time desc, sort ASC`
+	_, err = o.Raw(sql, chapterIds).QueryRows(&list)
 	return
 	return
 }
 }
 
 
 // GetChapterSimpleListByReportIds 根据ReportId获取章节列表
 // GetChapterSimpleListByReportIds 根据ReportId获取章节列表
-func GetChapterSimpleListByReportIds(reportIds string) (list []*ReportChapter, err error) {
+func GetChapterSimpleListByReportIds(reportIds []int) (list []*ReportChapter, err error) {
+	if len(reportIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("rddp")
 	o := orm.NewOrmUsingDB("rddp")
-	sql := ` SELECT report_id, report_chapter_id, title, type_name, create_time, IF(publish_time,publish_time,create_time) as publish_time FROM report_chapter WHERE publish_state = 2 and report_id IN (` + reportIds + `) ORDER BY publish_time desc, sort ASC`
-	_, err = o.Raw(sql).QueryRows(&list)
+	sql := ` SELECT report_id, report_chapter_id, title, type_name, create_time, IF(publish_time,publish_time,create_time) as publish_time FROM report_chapter WHERE publish_state = 2 and report_id IN (` + utils.GetOrmInReplace(len(reportIds)) + `) ORDER BY publish_time desc, sort ASC`
+	_, err = o.Raw(sql, reportIds).QueryRows(&list)
 	return
 	return
 }
 }
 
 

+ 24 - 12
models/research_report.go

@@ -104,24 +104,33 @@ type ResearchReportTypeTicker struct {
 	LastUpdatedTime            time.Time `description:"最近一次更新时间"`
 	LastUpdatedTime            time.Time `description:"最近一次更新时间"`
 }
 }
 
 
-func GetResearchReportTypeListByReportIds(reportIds string) (list []*ResearchReportType, err error) {
+func GetResearchReportTypeListByReportIds(reportIds []int) (list []*ResearchReportType, err error) {
+	if len(reportIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("weekly")
 	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type WHERE research_report_id IN (` + reportIds + `) ORDER BY created_time ASC,research_report_type_id ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
+	sql := ` SELECT * FROM research_report_type WHERE research_report_id IN (` + utils.GetOrmInReplace(len(reportIds)) + `) ORDER BY created_time ASC,research_report_type_id ASC `
+	_, err = o.Raw(sql, reportIds).QueryRows(&list)
 	return
 	return
 }
 }
 
 
-func GetResearchReportTypeContentListByReportTypeIds(reportTypeIds string) (list []*ResearchReportTypeContent, err error) {
+func GetResearchReportTypeContentListByReportTypeIds(reportTypeIds []int) (list []*ResearchReportTypeContent, err error) {
+	if len(reportTypeIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("weekly")
 	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type_content WHERE research_report_type_id IN (` + reportTypeIds + `) ORDER BY research_report_type_id ASC,sort ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
+	sql := ` SELECT * FROM research_report_type_content WHERE research_report_type_id IN (` + utils.GetOrmInReplace(len(reportTypeIds)) + `) ORDER BY research_report_type_id ASC,sort ASC `
+	_, err = o.Raw(sql, reportTypeIds).QueryRows(&list)
 	return
 	return
 }
 }
 
 
-func GetResearchReportTypeTickerListByReportTypeIds(reportTypeIds string) (list []*ResearchReportTypeTicker, err error) {
+func GetResearchReportTypeTickerListByReportTypeIds(reportTypeIds []int) (list []*ResearchReportTypeTicker, err error) {
+	if len(reportTypeIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("weekly")
 	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type_ticker WHERE research_report_type_id IN (` + reportTypeIds + `) ORDER BY research_report_type_id ASC,sort ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
+	sql := ` SELECT * FROM research_report_type_ticker WHERE research_report_type_id IN (` + utils.GetOrmInReplace(len(reportTypeIds)) + `) ORDER BY research_report_type_id ASC,sort ASC `
+	_, err = o.Raw(sql, reportTypeIds).QueryRows(&list)
 	return
 	return
 }
 }
 
 
@@ -236,10 +245,13 @@ type ChartPermissionChapterMapping struct {
 	ResearchType        string `description:"报告类型 week;two_week;tactic;month;other;rddp; "`
 	ResearchType        string `description:"报告类型 week;two_week;tactic;month;other;rddp; "`
 }
 }
 
 
-func GetChapterPermissionMappingByResearchReportIds(researchReportIds string) (list []*ChartPermissionChapterMapping, err error) {
+func GetChapterPermissionMappingByResearchReportIds(researchReportIds []int) (list []*ChartPermissionChapterMapping, err error) {
+	if len(researchReportIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("weekly")
 	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM chart_permission_chapter_mapping WHERE report_chapter_type_id IN (` + researchReportIds + `) AND research_type != "rddp" ORDER BY report_chapter_type_id ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
+	sql := ` SELECT * FROM chart_permission_chapter_mapping WHERE report_chapter_type_id IN (` + utils.GetOrmInReplace(len(researchReportIds)) + `) AND research_type != "rddp" ORDER BY report_chapter_type_id ASC `
+	_, err = o.Raw(sql, researchReportIds).QueryRows(&list)
 	return
 	return
 }
 }
 
 

+ 7 - 3
models/system/research_group.go

@@ -2,6 +2,7 @@ package system
 
 
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hz_eta_api/utils"
 	"time"
 	"time"
 )
 )
 
 
@@ -110,7 +111,10 @@ type AdminResearchGroupList struct {
 }
 }
 
 
 // GetAdminResearchGroupListByAdminId 获取研究员研究方向分组列表
 // GetAdminResearchGroupListByAdminId 获取研究员研究方向分组列表
-func GetAdminResearchGroupListByAdminId(adminIds string) (list []*AdminResearchGroupList, err error) {
+func GetAdminResearchGroupListByAdminId(adminIds []int) (list []*AdminResearchGroupList, err error) {
+	if len(adminIds) == 0 {
+		return
+	}
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	sql := `SELECT
 	sql := `SELECT
 				a.admin_id,
 				a.admin_id,
@@ -119,9 +123,9 @@ func GetAdminResearchGroupListByAdminId(adminIds string) (list []*AdminResearchG
 				research_group_relation AS a
 				research_group_relation AS a
 			INNER JOIN research_group AS b ON a.research_group_id = b.research_group_id
 			INNER JOIN research_group AS b ON a.research_group_id = b.research_group_id
 			WHERE
 			WHERE
-				a.admin_id IN (` + adminIds + `)
+				a.admin_id IN (` + utils.GetOrmInReplace(len(adminIds)) + `)
 			GROUP BY
 			GROUP BY
 				a.admin_id`
 				a.admin_id`
-	_, err = o.Raw(sql).QueryRows(&list)
+	_, err = o.Raw(sql, adminIds).QueryRows(&list)
 	return
 	return
 }
 }

+ 6 - 4
models/target.go

@@ -1152,12 +1152,14 @@ func GetLzSurveyProductByNameAndFrequency(productName string, frequency int) (it
 	return
 	return
 }
 }
 
 
-func GetExportLzSurveyProductByBreedIds(breedIds string) (items []*LongzhongSurveyProduct, err error) {
+func GetExportLzSurveyProductByBreedIds(breedIds []string) (items []*LongzhongSurveyProduct, err error) {
+	if len(breedIds) == 0 {
+		return
+	}
 	field := ` survey_product_id, breed_id, breed_name, sample_name, custom, quota_name, lz_code, frequency, unit_name, end_date, input_value `
 	field := ` survey_product_id, breed_id, breed_name, sample_name, custom, quota_name, lz_code, frequency, unit_name, end_date, input_value `
-	sql := `SELECT ` + field + ` FROM longzhong_survey_product WHERE breed_id IN (` + breedIds + `) ORDER BY breed_id ASC, frequency ASC, survey_product_id ASC `
+	sql := `SELECT ` + field + ` FROM longzhong_survey_product WHERE breed_id IN (` + utils.GetOrmInReplace(len(breedIds)) + `) ORDER BY breed_id ASC, frequency ASC, survey_product_id ASC `
 	o := orm.NewOrmUsingDB("edb")
 	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql).QueryRows(&items)
-
+	_, err = o.Raw(sql, breedIds).QueryRows(&items)
 	return
 	return
 }
 }
 
 

+ 7 - 3
models/user_view_history.go

@@ -2,6 +2,7 @@ package models
 
 
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hz_eta_api/utils"
 )
 )
 
 
 type ResearchReportViewPUV struct {
 type ResearchReportViewPUV struct {
@@ -11,7 +12,10 @@ type ResearchReportViewPUV struct {
 }
 }
 
 
 // GetPUVByResearchReportIds 通过报告IDs获取老报告PV、UV
 // GetPUVByResearchReportIds 通过报告IDs获取老报告PV、UV
-func GetPUVByResearchReportIds(reportIds string) (list []*ResearchReportViewPUV, err error) {
+func GetPUVByResearchReportIds(reportIds []string) (list []*ResearchReportViewPUV, err error) {
+	if len(reportIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("weekly")
 	o := orm.NewOrmUsingDB("weekly")
 	sql := `SELECT
 	sql := `SELECT
 				research_report_id,
 				research_report_id,
@@ -20,9 +24,9 @@ func GetPUVByResearchReportIds(reportIds string) (list []*ResearchReportViewPUV,
 			FROM
 			FROM
 				user_view_history
 				user_view_history
 			WHERE
 			WHERE
-				research_report_id IN (` + reportIds + `)
+				research_report_id IN (` + utils.GetOrmInReplace(len(reportIds)) + `)
 			GROUP BY
 			GROUP BY
 				research_report_id`
 				research_report_id`
-	_, err = o.Raw(sql).QueryRows(&list)
+	_, err = o.Raw(sql, reportIds).QueryRows(&list)
 	return
 	return
 }
 }

+ 7 - 3
models/variety_tag.go

@@ -2,6 +2,7 @@ package models
 
 
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hz_eta_api/utils"
 	"time"
 	"time"
 )
 )
 
 
@@ -277,7 +278,10 @@ type AdminVarietyTagRelationList struct {
 }
 }
 
 
 // GetAdminVarietyTagRelationListByAdminId 获取研究员研究方向分组列表
 // GetAdminVarietyTagRelationListByAdminId 获取研究员研究方向分组列表
-func GetAdminVarietyTagRelationListByAdminId(adminIds string) (list []*AdminVarietyTagRelationList, err error) {
+func GetAdminVarietyTagRelationListByAdminId(adminIds []int) (list []*AdminVarietyTagRelationList, err error) {
+	if len(adminIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("weekly")
 	o := orm.NewOrmUsingDB("weekly")
 	sql := `SELECT
 	sql := `SELECT
 				a.admin_id,
 				a.admin_id,
@@ -286,9 +290,9 @@ func GetAdminVarietyTagRelationListByAdminId(adminIds string) (list []*AdminVari
 				research_variety_tag_relation AS a
 				research_variety_tag_relation AS a
 			INNER JOIN variety_tag AS b ON a.variety_tag_id = b.variety_tag_id
 			INNER JOIN variety_tag AS b ON a.variety_tag_id = b.variety_tag_id
 			WHERE
 			WHERE
-				a.admin_id IN (` + adminIds + `)
+				a.admin_id IN (` + utils.GetOrmInReplace(len(adminIds)) + `)
 			GROUP BY
 			GROUP BY
 				a.admin_id`
 				a.admin_id`
-	_, err = o.Raw(sql).QueryRows(&list)
+	_, err = o.Raw(sql, adminIds).QueryRows(&list)
 	return
 	return
 }
 }

+ 25 - 13
services/report.go

@@ -245,9 +245,9 @@ func PublishDayWeekReport(reportId int) (tips string, err error) {
 		report.ModifyTime = time.Now().Local()
 		report.ModifyTime = time.Now().Local()
 	}
 	}
 	publishIdStr := utils.IntArr2joinString(publishIdArr, ",")
 	publishIdStr := utils.IntArr2joinString(publishIdArr, ",")
-	unPublishIdStr := utils.IntArr2joinString(unPublishIdArr, ",")
+	//unPublishIdStr := utils.IntArr2joinString(unPublishIdArr, ",")
 
 
-	if e := models.PublishReportAndChapter(report, publishIdStr, unPublishIdStr, publishReport, updateCols); e != nil {
+	if e := models.PublishReportAndChapter(report, publishIdArr, unPublishIdArr, publishReport, updateCols); e != nil {
 		err = errors.New("发布报告及章节失败")
 		err = errors.New("发布报告及章节失败")
 		return
 		return
 	}
 	}
@@ -273,7 +273,17 @@ func UpdateChaptersVideo(chapterIds string) (err error) {
 	if chapterIds == "" {
 	if chapterIds == "" {
 		return
 		return
 	}
 	}
-	chapterList, err := models.GetChapterListByChapterIds(chapterIds)
+	ids := make([]int, 0)
+	chapterIdArr := strings.Split(chapterIds, ",")
+	for _, v := range chapterIdArr {
+		id, e := strconv.Atoi(v)
+		if e != nil {
+			return
+		}
+		ids = append(ids, id)
+	}
+
+	chapterList, err := models.GetChapterListByChapterIds(ids)
 	if err != nil {
 	if err != nil {
 		return
 		return
 	}
 	}
@@ -610,20 +620,21 @@ func MigrateOldReport() (err error) {
 	}
 	}
 
 
 	// 报告ID集合
 	// 报告ID集合
-	idArr := make([]string, 0)
+	idArr := make([]int, 0)
 	for i := 0; i < lenReport; i++ {
 	for i := 0; i < lenReport; i++ {
-		idArr = append(idArr, strconv.Itoa(reportList[i].ResearchReportId))
+		//idArr = append(idArr, strconv.Itoa(reportList[i].ResearchReportId))
+		idArr = append(idArr, reportList[i].ResearchReportId)
 	}
 	}
-	idStr := strings.Join(idArr, ",")
+	//idStr := strings.Join(idArr, ",")
 
 
 	// 获取报告章节
 	// 获取报告章节
-	reportTypeList, err := models.GetResearchReportTypeListByReportIds(idStr)
+	reportTypeList, err := models.GetResearchReportTypeListByReportIds(idArr)
 	if err != nil {
 	if err != nil {
 		fmt.Println("获取报告章节失败, Err: " + err.Error())
 		fmt.Println("获取报告章节失败, Err: " + err.Error())
 		return
 		return
 	}
 	}
 	// 获取非晨周报权限mapping
 	// 获取非晨周报权限mapping
-	reportPermissionList, err := models.GetChapterPermissionMappingByResearchReportIds(idStr)
+	reportPermissionList, err := models.GetChapterPermissionMappingByResearchReportIds(idArr)
 	if err != nil {
 	if err != nil {
 		fmt.Println("获取报告权限失败, Err: " + err.Error())
 		fmt.Println("获取报告权限失败, Err: " + err.Error())
 		return
 		return
@@ -651,18 +662,19 @@ func MigrateOldReport() (err error) {
 	}
 	}
 
 
 	// 获取章节内容
 	// 获取章节内容
-	typeIdArr := make([]string, 0)
+	typeIdArr := make([]int, 0)
 	for i := 0; i < len(reportTypeList); i++ {
 	for i := 0; i < len(reportTypeList); i++ {
-		typeIdArr = append(typeIdArr, strconv.Itoa(reportTypeList[i].ResearchReportTypeId))
+		//typeIdArr = append(typeIdArr, strconv.Itoa(reportTypeList[i].ResearchReportTypeId))
+		typeIdArr = append(typeIdArr, reportTypeList[i].ResearchReportTypeId)
 	}
 	}
-	typeIdStr := strings.Join(typeIdArr, ",")
-	reportContentList, err := models.GetResearchReportTypeContentListByReportTypeIds(typeIdStr)
+	//typeIdStr := strings.Join(typeIdArr, ",")
+	reportContentList, err := models.GetResearchReportTypeContentListByReportTypeIds(typeIdArr)
 	if err != nil {
 	if err != nil {
 		fmt.Println("获取报告内容失败, Err: " + err.Error())
 		fmt.Println("获取报告内容失败, Err: " + err.Error())
 		return
 		return
 	}
 	}
 	// 获取章节ticker
 	// 获取章节ticker
-	reportTickerList, err := models.GetResearchReportTypeTickerListByReportTypeIds(typeIdStr)
+	reportTickerList, err := models.GetResearchReportTypeTickerListByReportTypeIds(typeIdArr)
 	if err != nil {
 	if err != nil {
 		fmt.Println("获取报告ticker失败, Err: " + err.Error())
 		fmt.Println("获取报告ticker失败, Err: " + err.Error())
 		return
 		return

+ 0 - 511
services/report_sync.go

@@ -1,511 +0,0 @@
-package services
-
-import (
-	"errors"
-	"fmt"
-	"hongze/hz_eta_api/models"
-	"hongze/hz_eta_api/services/alarm_msg"
-	"hongze/hz_eta_api/utils"
-	"html"
-	"regexp"
-	"strconv"
-	"strings"
-	"time"
-)
-
-func AutoSyncOldReport() {
-	defer func() {
-		if err := recover(); err != nil {
-			fmt.Println("[AutoSyncOldReport]", err)
-		}
-	}()
-	for {
-		utils.Rc.Brpop(utils.CACHE_KEY_OLD_REPORT_PUBLISH, func(b []byte) {
-			reportId, _ := strconv.Atoi(string(b))
-			if reportId > 0 {
-				if err := SyncOldReport(reportId); err != nil {
-					fmt.Println("AutoSyncOldReport: ", err.Error(), "reportId: ", reportId)
-				}
-			}
-		})
-	}
-}
-
-// SyncOldReport 同步老后台报告
-func SyncOldReport(reportId int) (err error) {
-	defer func() {
-		if err != nil {
-			utils.FileLog.Error("SyncOldReport, reportId:%s, Err:%s", strconv.Itoa(reportId), err.Error())
-			go alarm_msg.SendAlarmMsg("同步老后台报告失败, 报告ID: "+strconv.Itoa(reportId)+", Err: "+err.Error(), 3)
-		}
-	}()
-	// 查询报告信息
-	if reportId <= 0 {
-		return
-	}
-	reportInfo, e := models.GetResearchReportById(reportId)
-	if e != nil {
-		err = errors.New("报告信息有误" + e.Error())
-		return
-	}
-	if reportInfo.Status != "report" {
-		return
-	}
-	// 20220615-周报不做同步了
-	if reportInfo.Type == utils.REPORT_TYPE_WEEK {
-		return
-	}
-	// 若已存在报告,则后续更新报告信息
-	existReport, e := models.GetNewReportExist(reportId)
-	if e != nil && e.Error() != utils.ErrNoRow() {
-		err = errors.New("获取报告是否已同步失败" + e.Error())
-		return
-	}
-	// 报告分类
-	classifyList, e := models.GetAllClassify()
-	if e != nil {
-		err = errors.New("获取报告分类失败" + e.Error())
-		return
-	}
-	classifyIdName := make(map[int]string, 0)
-	classifyNameId := make(map[string]int, 0)
-	classifyIdParentId := make(map[int]int, 0)
-	classifyLen := len(classifyList)
-	for i := 0; i < classifyLen; i++ {
-		classifyIdName[classifyList[i].Id] = classifyList[i].ClassifyName
-		classifyNameId[classifyList[i].ClassifyName] = classifyList[i].Id
-		classifyIdParentId[classifyList[i].Id] = classifyList[i].ParentId
-	}
-	// 获取报告章节
-	reportTypeList, e := models.GetResearchReportTypeListByReportId(reportId)
-	if e != nil {
-		err = errors.New("获取报告章节失败" + e.Error())
-		return
-	}
-	reportTypeListLen := len(reportTypeList)
-	if reportTypeListLen == 0 {
-		return
-	}
-	// 获取章节内容
-	typeIdArr := make([]string, 0)
-	for i := 0; i < reportTypeListLen; i++ {
-		typeIdArr = append(typeIdArr, strconv.Itoa(reportTypeList[i].ResearchReportTypeId))
-	}
-	typeIdStr := strings.Join(typeIdArr, ",")
-	reportContentList, e := models.GetResearchReportTypeContentListByReportTypeIds(typeIdStr)
-	if e != nil {
-		err = errors.New("获取章节内容失败" + e.Error())
-		return
-	}
-	reportContentListLen := len(reportContentList)
-	if reportContentListLen == 0 {
-		return
-	}
-	// 报告章节内容map
-	reportContentListMap := make(map[int][]*models.ResearchReportTypeContent, 0)
-	for i := 0; i < reportTypeListLen; i++ {
-		rtid := reportTypeList[i].ResearchReportTypeId
-		reportContentMap := make([]*models.ResearchReportTypeContent, 0)
-		for ii := 0; ii < reportContentListLen; ii++ {
-			if rtid == reportContentList[ii].ResearchReportTypeId {
-				reportContentMap = append(reportContentMap, reportContentList[ii])
-			}
-		}
-		reportContentListMap[rtid] = reportContentMap
-	}
-
-	frequencyMap := map[string]string{
-		"day":      "日度",
-		"week":     "周度",
-		"two_week": "双周度",
-		"month":    "月度",
-		"other":    "不定时",
-	}
-	newReport := new(models.Report)
-	newReport.AddType = 1
-	// 标题去掉【】
-	re, _ := regexp.Compile("^【[^】]*】")
-	newTitle := re.ReplaceAllString(reportInfo.ResearchReportName, "")
-	newReport.Title = newTitle
-	newReport.Author = reportInfo.Author
-	newReport.Frequency = frequencyMap[reportInfo.Type]
-	newReport.CreateTime = reportInfo.CreatedTime
-	modifyTime, _ := time.ParseInLocation(utils.FormatDateTime, reportInfo.CreatedTime, time.Local)
-	newReport.ModifyTime = modifyTime
-	newReport.State = 2
-	newReport.PublishTime = reportInfo.ResearchReportDate
-	newReport.Stage = reportInfo.Periods
-	//newReport.MsgIsSend = 1
-	//newReport.ThsMsgIsSend = 1
-	newReport.ReportVersion = 1
-	newReport.OldReportId = reportInfo.ResearchReportId
-	// 判断报告类型
-	newReportId := 0
-	if reportInfo.Type == utils.REPORT_TYPE_DAY || reportInfo.Type == utils.REPORT_TYPE_WEEK {
-		// 晨周报
-		newReport.HasChapter = 1
-		newReport.ChapterType = reportInfo.Type
-		// 章节类型
-		typeList, tmpErr := models.GetReportChapterTypeList()
-		if tmpErr != nil {
-			err = errors.New("获取晨周报章节类型失败" + tmpErr.Error())
-			return
-		}
-		typeIdName := make(map[int]string, 0)
-		typeIdSort := make(map[int]int, 0)
-		for i := 0; i < len(typeList); i++ {
-			typeIdName[typeList[i].ReportChapterTypeId] = typeList[i].ReportChapterTypeName
-			typeIdSort[typeList[i].ReportChapterTypeId] = typeList[i].Sort
-		}
-		// 分类
-		classifyIdFirst := 0
-		classifyNameFirst := ""
-		if reportInfo.Type == utils.REPORT_TYPE_DAY {
-			newReport.ClassifyIdFirst = classifyNameId["晨报"]
-			newReport.ClassifyNameFirst = "晨报"
-			classifyIdFirst = classifyNameId["晨报"]
-			classifyNameFirst = "晨报"
-		} else {
-			newReport.ClassifyIdFirst = classifyNameId["周报"]
-			newReport.ClassifyNameFirst = "周报"
-			classifyIdFirst = classifyNameId["周报"]
-			classifyNameFirst = "周报"
-		}
-
-		// 报告已存在时的更新报告及章节,否则新增
-		if existReport != nil {
-			// 更新报告
-			existReport.Title = newTitle
-			existReport.Author = reportInfo.Author
-			existReport.PublishTime = reportInfo.ResearchReportDate
-			existReport.ModifyTime = time.Now()
-			var updateReportCol, updateChapterCol []string
-			updateReportCol = append(updateReportCol, "Title", "Author", "PublishTime", "ModifyTime")
-			if tmpErr = existReport.UpdateReport(updateReportCol); tmpErr != nil {
-				err = errors.New("更新已存在的报告失败" + tmpErr.Error())
-				return
-			}
-			// 章节
-			existChapterList, tmpErr := models.GetChapterListByReportId(existReport.Id)
-			if tmpErr != nil {
-				err = errors.New("获取已存在的报告章节失败" + tmpErr.Error())
-				return
-			}
-			typeChapterMap := make(map[int]*models.ResearchReportType, 0)
-			for i := 0; i < reportTypeListLen; i++ {
-				typeChapterMap[reportTypeList[i].TypeId] = reportTypeList[i]
-			}
-			for _, exChapter := range existChapterList {
-				chapter := typeChapterMap[exChapter.TypeId]
-				if chapter == nil {
-					continue
-				}
-				// 章节内容
-				chapterContents := ""
-				contentList := reportContentListMap[chapter.ResearchReportTypeId]
-				for _, contents := range contentList {
-					// 2022-08-09加上段落标题
-					if contents.ContentType != "" {
-						chapterContents += `<p><br></p><p style="font-size: 16px; text-align: left;"><strong>`
-						chapterContents += contents.ContentType
-						chapterContents += `</strong></p><p><br></p>`
-					}
-					chapterContents += contents.Content
-				}
-				chapterContents, tmpErr := replaceReportBase64ToImg(chapterContents)
-				if tmpErr != nil {
-					err = errors.New("章节存在base64图片转换失败" + tmpErr.Error())
-					return
-				}
-				contentClean, e := FilterReportContentBr(chapterContents)
-				if e != nil {
-					err = errors.New("内容去除前后空格失败, Err: " + e.Error())
-					return
-				}
-				chapterContents = contentClean
-
-				contentSub, tmpErr := GetReportContentSub(chapterContents)
-				if tmpErr != nil {
-					err = errors.New("解析章节ContentSub失败" + tmpErr.Error())
-					return
-				}
-				exChapter.Title = chapter.ResearchReportTypeTitle
-				exChapter.Content = html.EscapeString(chapterContents)
-				exChapter.ContentSub = html.EscapeString(contentSub)
-				exChapter.ModifyTime = time.Now()
-				updateChapterCol = append(updateChapterCol, "Title", "Content", "ContentSub", "ModifyTime")
-				updateTickerList := make([]*models.ReportChapterTicker, 0)
-				// 晨报数据指标
-				if reportInfo.Type == utils.REPORT_TYPE_DAY {
-					// 获取章节ticker
-					reportTickerList, tmpErr := models.GetResearchReportTypeTickerListByReportTypeIds(typeIdStr)
-					if tmpErr != nil {
-						err = errors.New("获取报告Ticker失败" + tmpErr.Error())
-						return
-					}
-					reportTickerListMap := make(map[int][]*models.ResearchReportTypeTicker, 0)
-					for i := 0; i < len(reportTypeList); i++ {
-						// 报告Ticker
-						tid := reportTypeList[i].ResearchReportTypeId
-						reportTickerMap := make([]*models.ResearchReportTypeTicker, 0)
-						for iii := 0; iii < len(reportTickerList); iii++ {
-							if tid == reportTickerList[iii].ResearchReportTypeId {
-								reportTickerMap = append(reportTickerMap, reportTickerList[iii])
-							}
-						}
-						reportTickerListMap[tid] = reportTickerMap
-					}
-
-					tickerList := reportTickerListMap[chapter.ResearchReportTypeId]
-					for _, ticker := range tickerList {
-						updateTickerList = append(updateTickerList, &models.ReportChapterTicker{
-							Sort:       ticker.Sort,
-							Ticker:     ticker.Ticker,
-							CreateTime: ticker.CreatedTime,
-							UpdateTime: ticker.LastUpdatedTime,
-						})
-					}
-				}
-				// 更新章节
-				if tmpErr = models.UpdateChapterAndTicker(exChapter, updateChapterCol, updateTickerList); tmpErr != nil {
-					err = errors.New("UpdateChapterAndTicker更新已存在的章节失败" + tmpErr.Error())
-					return
-				}
-			}
-		} else {
-			newDayWeekReport := new(models.CreateDayWeekReport)
-			newChapterList := make([]*models.CreateDayWeekReportChapter, 0)
-			for _, chapter := range reportTypeList {
-				chapterAndTicker := new(models.CreateDayWeekReportChapter)
-				tmpTickerList := make([]*models.ReportChapterTicker, 0)
-				chapterContents := ""
-				// 章节内容列表
-				contentList := reportContentListMap[chapter.ResearchReportTypeId]
-				for _, contents := range contentList {
-					// 2022-08-09加上段落标题
-					if contents.ContentType != "" {
-						chapterContents += `<p><br></p><p style="font-size: 16px; text-align: left;"><strong>`
-						chapterContents += contents.ContentType
-						chapterContents += `</strong></p><p><br></p>`
-					}
-					chapterContents += contents.Content
-				}
-				chapterContents, tmpErr := replaceReportBase64ToImg(chapterContents)
-				if tmpErr != nil {
-					err = errors.New("章节存在base64图片转换失败" + tmpErr.Error())
-					return
-				}
-				state := 2
-				if chapterContents == "" {
-					state = 1
-				}
-
-				contentClean, e := FilterReportContentBr(chapterContents)
-				if e != nil {
-					err = errors.New("内容去除前后空格失败, Err: " + e.Error())
-					return
-				}
-				chapterContents = contentClean
-
-				contentSub, tmpErr := GetReportContentSub(chapterContents)
-				if tmpErr != nil {
-					err = errors.New("解析章节ContentSub失败" + tmpErr.Error())
-					return
-				}
-				chapterContents = html.EscapeString(chapterContents)
-				contentSub = html.EscapeString(contentSub)
-
-				chapterAndTicker.Chapter = &models.ReportChapter{
-					ReportType:        reportInfo.Type,
-					ClassifyIdFirst:   classifyIdFirst,
-					ClassifyNameFirst: classifyNameFirst,
-					TypeId:            chapter.TypeId,
-					TypeName:          typeIdName[chapter.TypeId],
-					Sort:              typeIdSort[chapter.TypeId],
-					Title:             chapter.ResearchReportTypeTitle,
-					AddType:           1,
-					Author:            reportInfo.Author,
-					Content:           chapterContents,
-					ContentSub:        contentSub,
-					Stage:             reportInfo.Periods,
-					Trend:             chapter.Trend,
-					IsEdit:            1,
-					PublishState:      state,
-					PublishTime:       chapter.LastUpdatedTime,
-					CreateTime:        chapter.CreatedTime,
-					ModifyTime:        chapter.LastUpdatedTime,
-				}
-				// 晨报数据指标
-				if reportInfo.Type == utils.REPORT_TYPE_DAY {
-					// 获取章节ticker
-					reportTickerList, tmpErr := models.GetResearchReportTypeTickerListByReportTypeIds(typeIdStr)
-					if tmpErr != nil {
-						err = errors.New("获取报告Ticker失败" + tmpErr.Error())
-						return
-					}
-					reportTickerListMap := make(map[int][]*models.ResearchReportTypeTicker, 0)
-					for i := 0; i < len(reportTypeList); i++ {
-						// 报告Ticker
-						tid := reportTypeList[i].ResearchReportTypeId
-						reportTickerMap := make([]*models.ResearchReportTypeTicker, 0)
-						for iii := 0; iii < len(reportTickerList); iii++ {
-							if tid == reportTickerList[iii].ResearchReportTypeId {
-								reportTickerMap = append(reportTickerMap, reportTickerList[iii])
-							}
-						}
-						reportTickerListMap[tid] = reportTickerMap
-					}
-
-					tickerList := reportTickerListMap[chapter.ResearchReportTypeId]
-					for _, ticker := range tickerList {
-						tmpTickerList = append(tmpTickerList, &models.ReportChapterTicker{
-							Sort:       ticker.Sort,
-							Ticker:     ticker.Ticker,
-							CreateTime: ticker.CreatedTime,
-							UpdateTime: ticker.LastUpdatedTime,
-						})
-					}
-				}
-				chapterAndTicker.TickerList = tmpTickerList
-				newChapterList = append(newChapterList, chapterAndTicker)
-			}
-			newDayWeekReport.Report = newReport
-			newDayWeekReport.ChapterList = newChapterList
-			// 新增晨周报
-			newReportId, tmpErr = models.CreateMigrateNewDayWeekReport(newDayWeekReport)
-			if tmpErr != nil {
-				err = errors.New("新增晨周报失败" + tmpErr.Error())
-				return
-			}
-		}
-	} else {
-		// 非晨周报
-		if reportInfo.ReportVariety == "铁矿库存点评" {
-			reportInfo.ReportVariety = "铁矿库存数据点评"
-		}
-		//newReport.Abstract = newTitle
-		newReport.ClassifyIdSecond = classifyNameId[reportInfo.ReportVariety]
-		newReport.ClassifyNameSecond = reportInfo.ReportVariety
-		newReport.ClassifyIdFirst = classifyIdParentId[newReport.ClassifyIdSecond]
-		newReport.ClassifyNameFirst = classifyIdName[newReport.ClassifyIdFirst]
-		// 忽略分类匹配不上的
-		if newReport.ClassifyIdFirst == 0 || newReport.ClassifyIdSecond == 0 || newReport.ClassifyNameFirst == "" || newReport.ClassifyNameSecond == "" {
-			fmt.Printf("分类匹配不上,忽略报告, FirstClassify:%s, SecondClassify:%s", newReport.ClassifyNameFirst, newReport.ClassifyNameSecond)
-			return
-		}
-		reportContents := ""
-		for _, chapter := range reportTypeList {
-			// 章节内容列表
-			contentList := reportContentListMap[chapter.ResearchReportTypeId]
-			for _, contents := range contentList {
-				// 2022-08-09加上段落标题
-				if contents.ContentType != "" {
-					reportContents += `<p><br></p><p style="font-size: 16px; text-align: left;"><strong>`
-					reportContents += contents.ContentType
-					reportContents += `</strong></p><p><br></p>`
-				}
-				reportContents += contents.Content
-			}
-		}
-		reportContents, tmpErr := replaceReportBase64ToImg(reportContents)
-		if tmpErr != nil {
-			err = errors.New("报告存在base64图片转换失败" + tmpErr.Error())
-			return
-		}
-		newReport.State = 2
-		if reportContents == "" {
-			newReport.State = 1
-		}
-
-		contentClean, e := FilterReportContentBr(reportContents)
-		if e != nil {
-			err = errors.New("内容去除前后空格失败, Err: " + e.Error())
-			return
-		}
-		reportContents = contentClean
-
-		reportContentSub, tmpErr := GetReportContentSub(reportContents)
-		if tmpErr != nil {
-			err = errors.New("解析ContentSub失败" + tmpErr.Error())
-			return
-		}
-		newReport.Content = html.EscapeString(reportContents)
-		newReport.ContentSub = html.EscapeString(reportContentSub)
-		// 报告已存在则更新部分字段
-		if existReport != nil {
-			existReport.Title = newTitle
-			existReport.Abstract = newReport.Abstract
-			existReport.Author = newReport.Author
-			existReport.Content = newReport.Content
-			existReport.ContentSub = newReport.ContentSub
-			existReport.PublishTime = reportInfo.ResearchReportDate
-			existReport.ModifyTime = time.Now()
-			existReport.ClassifyIdFirst = newReport.ClassifyIdFirst
-			existReport.ClassifyNameFirst = newReport.ClassifyNameFirst
-			existReport.ClassifyIdSecond = newReport.ClassifyIdSecond
-			existReport.ClassifyNameSecond = newReport.ClassifyNameSecond
-			updateCol := make([]string, 0)
-			updateCol = append(updateCol, "Title", "Abstract", "Author", "Content", "ContentSub", "PublishTime", "ModifyTime", "ClassifyIdFirst", "ClassifyNameFirst", "ClassifyIdSecond", "ClassifyNameSecond")
-			tmpErr = existReport.UpdateReport(updateCol)
-			if tmpErr != nil {
-				err = errors.New("更新报告失败" + tmpErr.Error())
-				return
-			}
-		} else {
-			// 获取非晨周报权限mapping
-			reportPermissionList, tmpErr := models.GetChapterPermissionMappingByResearchReportIds(strconv.Itoa(reportId))
-			if tmpErr != nil {
-				err = errors.New("获取报告权限mapping失败" + tmpErr.Error())
-				return
-			}
-			// 新增非晨周报
-			newReportId, tmpErr = models.CreateMigrateNewOtherReport(newReport, reportPermissionList)
-			if tmpErr != nil {
-				err = errors.New("新增非晨周报失败" + tmpErr.Error())
-				return
-			}
-		}
-	}
-	if existReport != nil {
-		newReportId = existReport.Id
-	}
-	if newReportId == 0 {
-		err = errors.New("同步报告失败")
-		return
-	}
-	if existReport == nil {
-		// 更新音频
-		if e = UpdateReportVideo(newReportId); e != nil {
-			err = errors.New("更新音频失败" + e.Error())
-			return
-		}
-	}
-	// 更新ES
-	if e = UpdateReportEs(newReportId, 2); e != nil {
-		err = errors.New("更新报告ES失败" + e.Error())
-		return
-	}
-	return
-}
-
-// UpdateSyncReport (一次性)更新已同步的报告
-func UpdateSyncReport() (err error) {
-	defer func() {
-		if err != nil {
-			fmt.Println(err.Error())
-		}
-	}()
-	reportList, e := models.GetMigrateReportList()
-	if e != nil {
-		err = errors.New("获取今年报告失败, Err: " + e.Error())
-		return
-	}
-	lenReport := len(reportList)
-	for i := 0; i < lenReport; i++ {
-		if e = SyncOldReport(reportList[i].ResearchReportId); e != nil {
-			err = errors.New("同步报告失败, ResearchReportId: " + strconv.Itoa(reportList[i].ResearchReportId) + ", Err: " + e.Error())
-			return
-		}
-	}
-	return
-}

+ 0 - 3
services/task.go

@@ -31,9 +31,6 @@ func Task() {
 	//data.GetSmmIndex()
 	//data.GetSmmIndex()
 	//data.GetSmmIndexData()
 	//data.GetSmmIndexData()
 	go AutoInsertLogToDB()
 	go AutoInsertLogToDB()
-	// TODO:确定晨报在新后台撰写之后打开, 防止误写之后被自动推送
-	//go AutoPublishDayReport()
-	go AutoSyncOldReport()
 
 
 	//手工数据表格导入后的指标库刷新
 	//手工数据表格导入后的指标库刷新
 	go ImportManualDataRefresh()
 	go ImportManualDataRefresh()