Răsfoiți Sursa

修改克拉克森兼容高斯数据库

317699326@qq.com 1 lună în urmă
părinte
comite
996a87abd8

+ 9 - 8
controllers/data_manage/clarksons_data.go

@@ -1257,8 +1257,8 @@ func (this *ClarksonsDataController) DeleteClarksonsData() {
 }
 
 // ExportClarksonsList
-// @Title 导出Sci数据
-// @Description 导出Sci数据
+// @Title 导出克拉克森数据
+// @Description 导出克拉克森数据
 // @Param   BaseFromClassifyId   query   int  true       "关键字搜索"
 // @Param   IndexCode   query   string  true       "指标编码"
 // @Success 200  导出成功
@@ -1356,14 +1356,13 @@ func (this *ClarksonsDataController) ExportClarksonsList() {
 		for rk, dv := range dataTimeList {
 			rowIndex := setRowIndex + rk
 			row := sheetNew.Row(rowIndex)
-			displayDate, _ := time.Parse(utils.FormatDate, dv)
+			//displayDate, _ := time.Parse(utils.FormatDate, dv)
 			displayDateCell := row.AddCell()
 			style := new(xlsx.Style)
 			style.ApplyAlignment = true
 			style.Alignment.WrapText = true
 			displayDateCell.SetStyle(style)
-			displayDateCell.SetDate(displayDate)
-
+			displayDateCell.SetDate(dv)
 		}
 		for k, sv := range secNameList {
 			//获取数据
@@ -1391,14 +1390,16 @@ func (this *ClarksonsDataController) ExportClarksonsList() {
 			lastModifyDateRow.AddCell().SetValue(sv.ModifyTime.Format(utils.FormatDate))
 			dataInfoMap := make(map[string]*data_manage.BaseFromClarksonsData)
 			for _, v := range dataList {
-				dataInfoMap[v.DataTime] = v
+				dataInfoMap[v.DataTime.Format(utils.FormatDate)] = v
 			}
 
+			fmt.Println(dataInfoMap)
 			for rk, dtv := range dataTimeList {
 				rowIndex := setRowIndex + rk
 				row := sheetNew.Row(rowIndex)
 				displayDateCell := row.AddCell()
-				tmpData, ok := dataInfoMap[dtv]
+				dtvStr := dtv.Format(utils.FormatDate)
+				tmpData, ok := dataInfoMap[dtvStr]
 				if ok {
 					displayDateCell.SetValue(tmpData.Value)
 				}
@@ -1439,7 +1440,7 @@ func (this *ClarksonsDataController) ExportClarksonsList() {
 	br.Msg = "success"
 }
 
-// getClarksonsClassifyTree 返回卓创红旗的树形结构
+// getClarksonsClassifyTree 返回克拉克森的树形结构
 func getClarksonsClassifyTree(items []*data_manage.BaseFromClarksonsClassifyItem, parentId int) []*data_manage.BaseFromClarksonsClassifyItem {
 	res := make([]*data_manage.BaseFromClarksonsClassifyItem, 0)
 	for _, item := range items {

+ 2 - 2
models/data_manage/base_from_clarksons_data.go

@@ -11,7 +11,7 @@ type BaseFromClarksonsData struct {
 	BaseFromClarksonsDataId  int       `orm:"column(base_from_clarksons_data_id);pk;auto"`
 	BaseFromClarksonsIndexId int       `description:"指标id"`
 	IndexCode                string    `description:"指标编码"`
-	DataTime                 string    `description:"数据日期"`
+	DataTime                 time.Time `description:"数据日期"`
 	Value                    float64   `description:"数据值"`
 	CreateTime               time.Time `description:"创建时间"`
 	ModifyTime               time.Time `description:"修改时间"`
@@ -27,7 +27,7 @@ func GetClarksonsDataByIndexId(indexId int) (items []*BaseFromClarksonsData, err
 }
 
 // GetClarksonsDataDataTimeByIndexId 根据指标id获取指标数据的日期列表
-func GetClarksonsDataDataTimeByIndexId(indexIdList []int) (items []string, err error) {
+func GetClarksonsDataDataTimeByIndexId(indexIdList []int) (items []time.Time, err error) {
 	if len(indexIdList) == 0 {
 		return
 	}

+ 63 - 2
models/data_manage/base_from_clarksons_index.go

@@ -22,6 +22,23 @@ type BaseFromClarksonsIndex struct {
 	ModifyTime               time.Time
 }
 
+type BaseFromClarksonsIndexOrm struct {
+	BaseFromClarksonsIndexId int       `orm:"pk"`
+	EdbInfoId                int       `description:"指标库id"`
+	ClassifyId               int       `description:"指标分类id"`
+	IndexCode                string    `description:"指标编码"`
+	IndexName                string    `description:"指标名称"`
+	UniqueCode               string    `description:"唯一code"`
+	Frequency                string    `description:"频度"`
+	Unit                     string    `description:"单位"`
+	StartDate                time.Time `description:"开始日期"`
+	EndDate                  time.Time `description:"结束日期"`
+	Sort                     int       `description:"排序"`
+	LatestDate               time.Time `description:"最后更新时间"`
+	EdbExist                 int       `description:"edb是否存在"`
+	ModifyTime               time.Time
+}
+
 type BaseFromClarksonsIndexView struct {
 	BaseFromClarksonsIndexId int    `orm:"pk"`
 	EdbInfoId                int    `description:"指标库id"`
@@ -152,13 +169,35 @@ func GetClarksonsIndexCountByClassifyIds(classifyIds []int) (count int, err erro
 
 // GetClarksonsIndexByClassifyId 根据分类id获取克拉克森指标列表
 func GetClarksonsIndexByClassifyId(classifyIds []int, startSize, pageSize int) (items []*BaseFromClarksonsIndexView, err error) {
+	itemsOrm := make([]*BaseFromClarksonsIndexOrm, 0)
 	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT b.*, e.edb_info_id,
 	CASE WHEN e.edb_info_id IS NULL THEN 0 ELSE 1 END AS edb_exist
 	FROM base_from_clarksons_index AS b
 	LEFT JOIN edb_info AS e ON b.index_code=e.edb_code AND e.source=101
 	WHERE b.classify_id IN (` + utils.GetOrmInReplace(len(classifyIds)) + `) ORDER BY b.sort ASC LIMIT ?,? `
-	_, err = o.Raw(sql, classifyIds, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, classifyIds, startSize, pageSize).QueryRows(&itemsOrm)
+	if err != nil {
+		return
+	}
+	for _, v := range itemsOrm {
+		viewItem := new(BaseFromClarksonsIndexView)
+		viewItem.BaseFromClarksonsIndexId = v.BaseFromClarksonsIndexId
+		viewItem.EdbInfoId = v.EdbInfoId
+		viewItem.ClassifyId = v.ClassifyId
+		viewItem.IndexCode = v.IndexCode
+		viewItem.IndexName = v.IndexName
+		viewItem.UniqueCode = v.UniqueCode
+		viewItem.Frequency = v.Frequency
+		viewItem.Unit = v.Unit
+		viewItem.StartDate = v.StartDate.Format(utils.FormatDate)
+		viewItem.EndDate = v.EndDate.Format(utils.FormatDate)
+		viewItem.Sort = v.Sort
+		viewItem.LatestDate = v.LatestDate.Format(utils.FormatDateTime)
+		viewItem.EdbExist = v.EdbExist
+		viewItem.ModifyTime = v.ModifyTime.Format(utils.FormatDateTime)
+		items = append(items, viewItem)
+	}
 	return
 }
 
@@ -182,13 +221,35 @@ func GetClarksonsIndexCount() (count int, err error) {
 }
 
 func GetClarksonsIndexByPage(startSize, pageSize int) (items []*BaseFromClarksonsIndexView, err error) {
+	itemsOrm := make([]*BaseFromClarksonsIndexOrm, 0)
 	o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT b.*, e.edb_info_id,
 	CASE WHEN e.edb_info_id IS NULL THEN 0 ELSE 1 END AS edb_exist
 	FROM base_from_clarksons_index AS b
 	LEFT JOIN edb_info AS e ON b.index_code=e.edb_code AND e.source=101
 	ORDER BY b.modify_time DESC LIMIT ?,?`
-	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&itemsOrm)
+	if err != nil {
+		return
+	}
+	for _, v := range itemsOrm {
+		viewItem := new(BaseFromClarksonsIndexView)
+		viewItem.BaseFromClarksonsIndexId = v.BaseFromClarksonsIndexId
+		viewItem.EdbInfoId = v.EdbInfoId
+		viewItem.ClassifyId = v.ClassifyId
+		viewItem.IndexCode = v.IndexCode
+		viewItem.IndexName = v.IndexName
+		viewItem.UniqueCode = v.UniqueCode
+		viewItem.Frequency = v.Frequency
+		viewItem.Unit = v.Unit
+		viewItem.StartDate = v.StartDate.Format(utils.FormatDate)
+		viewItem.EndDate = v.EndDate.Format(utils.FormatDate)
+		viewItem.Sort = v.Sort
+		viewItem.LatestDate = v.LatestDate.Format(utils.FormatDateTime)
+		viewItem.EdbExist = v.EdbExist
+		viewItem.ModifyTime = v.ModifyTime.Format(utils.FormatDateTime)
+		items = append(items, viewItem)
+	}
 	return
 }
 

+ 1 - 1
services/data/base_from_clarksons.go

@@ -615,7 +615,7 @@ func GetClarksonsIndexInfo(keyWord string, classifyIdList []string, frequencyLis
 		if indexDataMap[indexInfo.IndexCode] == nil {
 			continue
 		}
-		indexInfo.ModifyTimeMax = indexDataMap[indexInfo.IndexCode].DataTime
+		indexInfo.ModifyTimeMax = indexDataMap[indexInfo.IndexCode].DataTime.Format(utils.FormatDate)
 		indexInfo.Value = indexDataMap[indexInfo.IndexCode].Value
 	}