Explorar el Código

Merge branch 'refs/heads/eta_2.0.8_ly_0804@guomengyuan' into debug

gmy hace 1 mes
padre
commit
1d68bbd7c3

+ 298 - 48
controllers/base_from_ly.go

@@ -7,6 +7,7 @@ import (
 	"eta/eta_index_lib/models"
 	"eta/eta_index_lib/services"
 	"eta/eta_index_lib/utils"
+	"fmt"
 	"strconv"
 	"time"
 )
@@ -143,7 +144,7 @@ func (this *BaseFromLyController) Refresh() {
 // @Title 获取分类
 // @Description 获取分类
 // @Success 200 {object} models.BaseFromLyClassify
-// @router /get/ly/classify/by/name [get]
+// @router /get/ly/classify/by/name [post]
 func (this *BaseFromLyController) GetLyClassifyByName() {
 	br := new(models.BaseResponse).Init()
 	var cacheKey string
@@ -155,9 +156,15 @@ func (this *BaseFromLyController) GetLyClassifyByName() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
-	categoryName := this.GetString("CategoryName")
-
+	var reqData struct {
+		CategoryName string `json:"CategoryName"`
+	}
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
+	if err != nil {
+		br.ErrMsg = "无法解析请求体"
+		return
+	}
+	categoryName := reqData.CategoryName
 	if categoryName == "" {
 		br.Msg = "请输入分类!"
 		br.ErrMsg = "请输入分类"
@@ -179,7 +186,7 @@ func (this *BaseFromLyController) GetLyClassifyByName() {
 // @Title 根据url获取指标已读取记录
 // @Description 根据url获取指标已读取记录
 // @Success 200 {object} models.BaseFromLyIndexRecord
-// @router /get/ly/index/record/by/url [get]
+// @router /get/ly/index/record/by/url [post]
 func (this *BaseFromLyController) GetLyIndexRecordByUrl() {
 	br := new(models.BaseResponse).Init()
 	var cacheKey string
@@ -191,9 +198,15 @@ func (this *BaseFromLyController) GetLyIndexRecordByUrl() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
-	url := this.GetString("Url")
-
+	var reqData struct {
+		Url string `json:"Url"`
+	}
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
+	if err != nil {
+		br.ErrMsg = "无法解析请求体"
+		return
+	}
+	url := reqData.Url
 	if url == "" {
 		br.Msg = "请输入地址链接!"
 		br.ErrMsg = "请输入地址链接"
@@ -235,13 +248,14 @@ func (this *BaseFromLyController) AddLyIndexRecord() {
 		return
 	}
 
-	_, err = models.AddLyIndexRecord(&req)
+	id, err := models.AddLyIndexRecord(&req)
 	if err != nil {
 		return
 	}
 
 	br.Ret = 200
 	br.Success = true
+	br.Data = id
 	br.Msg = "处理成功"
 }
 
@@ -262,6 +276,7 @@ func (this *BaseFromLyController) AddLyDataList() {
 		this.ServeJSON()
 	}()
 	var req []models.BaseFromLyData
+	fmt.Println(string(this.Ctx.Input.RequestBody))
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
 	if err != nil {
 		br.Msg = "参数解析异常!"
@@ -271,6 +286,8 @@ func (this *BaseFromLyController) AddLyDataList() {
 
 	err = models.AddLyDataList(req)
 	if err != nil {
+		br.Msg = "新增指标数据失败!"
+		br.ErrMsg = "新增指标数据失败,Err:" + err.Error()
 		return
 	}
 
@@ -318,7 +335,7 @@ func (this *BaseFromLyController) AddLyIndex() {
 // @Title 根据指标id和时间获取指标数据
 // @Description 根据指标id和时间获取指标数据
 // @Success 200 {object} models.BaseFromLyData
-// @router /get/ly/data/by/index/id/and/data/time [get]
+// @router /get/ly/data/by/index/id/and/data/time [post]
 func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTime() {
 	br := new(models.BaseResponse).Init()
 	var cacheKey string
@@ -330,21 +347,24 @@ func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTime() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
-	indexId, err := this.GetInt("IndexId")
+	var reqData struct {
+		IndexId  int    `json:"IndexId"`
+		DataTime string `json:"DataTime"`
+	}
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
 	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		br.ErrMsg = "无法解析请求体"
 		return
 	}
+
+	indexId := reqData.IndexId
 	if indexId == 0 {
 		br.Msg = "请输入指标id!"
 		br.ErrMsg = "请输入指标id"
 		return
 	}
 
-	dataTime := this.GetString("DataTime")
-
+	dataTime := reqData.DataTime
 	if dataTime == "" {
 		br.Msg = "请输入时间!"
 		br.ErrMsg = "请输入时间"
@@ -366,7 +386,7 @@ func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTime() {
 // @Title 根据指标id和年月时间获取指标数据
 // @Description 根据指标id和年月时间获取指标数据
 // @Success 200 {object} models.BaseFromLyData
-// @router /get/ly/data/by/index/id/and/data/time/ym [get]
+// @router /get/ly/data/by/index/id/and/data/time/ym [post]
 func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTimeYM() {
 	br := new(models.BaseResponse).Init()
 	var cacheKey string
@@ -378,20 +398,24 @@ func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTimeYM() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
-	indexId, err := this.GetInt("IndexId")
+	var reqData struct {
+		IndexId   int    `json:"IndexId"`
+		YearMonth string `json:"YearMonth"`
+	}
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
 	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		br.ErrMsg = "无法解析请求体"
 		return
 	}
+
+	indexId := reqData.IndexId
 	if indexId == 0 {
 		br.Msg = "请输入指标id!"
 		br.ErrMsg = "请输入指标id"
 		return
 	}
 
-	yearMonth := this.GetString("YearMonth")
+	yearMonth := reqData.YearMonth
 
 	if yearMonth == "" {
 		br.Msg = "请输入时间!"
@@ -414,7 +438,7 @@ func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTimeYM() {
 // @Title 更新数据源指标数据
 // @Description 更新数据源指标数据
 // @Success 200 string "处理成功"
-// @router /update/ly/data/by/id [get]
+// @router /update/ly/data/by/id [post]
 func (this *BaseFromLyController) UpdateLyDataById() {
 	br := new(models.BaseResponse).Init()
 	var cacheKey string
@@ -426,26 +450,24 @@ func (this *BaseFromLyController) UpdateLyDataById() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
-	id, err := this.GetInt("Id")
+	var reqData struct {
+		Id    int     `json:"Id"`
+		Value float64 `json:"Value"`
+	}
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
 	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		br.ErrMsg = "无法解析请求体"
 		return
 	}
+
+	id := reqData.Id
 	if id == 0 {
 		br.Msg = "请输入id!"
 		br.ErrMsg = "请输入id"
 		return
 	}
 
-	value, err := this.GetFloat("Value")
-	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
-	}
-
+	value := reqData.Value
 	if value == 0 {
 		br.Msg = "请输入值!"
 		br.ErrMsg = "请输入值"
@@ -462,11 +484,113 @@ func (this *BaseFromLyController) UpdateLyDataById() {
 	br.Msg = "处理成功"
 }
 
+// GetLyEdbDataByIndexCodeAndDataTime
+// @Title 根据指标编码和模糊日期获取指标库数据
+// @Description 根据指标编码和模糊日期获取指标库数据
+// @Success 200 {object} []models.EdbDataLy
+// @router /get/ly/edb/data/by/index/code/and/data/time [post]
+func (this *BaseFromLyController) GetLyEdbDataByIndexCodeAndDataTime() {
+	br := new(models.BaseResponse).Init()
+	var cacheKey string
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		_ = utils.Rc.Delete(cacheKey)
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	var reqData struct {
+		IndexCode string `json:"IndexCode"`
+		DataTime  string `json:"DataTime"`
+	}
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
+	if err != nil {
+		br.ErrMsg = "无法解析请求体"
+		return
+	}
+
+	indexCode := reqData.IndexCode
+	if indexCode == "" {
+		br.Msg = "请输入指标id!"
+		br.ErrMsg = "请输入指标id"
+		return
+	}
+
+	dataTime := reqData.DataTime
+	if dataTime == "" {
+		br.Msg = "请输入时间!"
+		br.ErrMsg = "请输入时间"
+		return
+	}
+
+	lyEdbData, err := models.GetLyEdbDataByIndexCodeAndDataTime(indexCode, dataTime)
+	if err != nil {
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Data = lyEdbData
+	br.Msg = "获取成功"
+}
+
+// GetLyEdbDataByIndexCodeAndExactDataTime
+// @Title 根据指标编码和精确日期获取指标库数据
+// @Description 根据指标编码和精确日期获取指标库数据
+// @Success 200 {object} []models.EdbDataLy
+// @router /get/ly/edb/data/by/index/code/and/exact/data/time [post]
+func (this *BaseFromLyController) GetLyEdbDataByIndexCodeAndExactDataTime() {
+	br := new(models.BaseResponse).Init()
+	var cacheKey string
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		_ = utils.Rc.Delete(cacheKey)
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	var reqData struct {
+		IndexCode string `json:"IndexCode"`
+		DataTime  string `json:"DataTime"`
+	}
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
+	if err != nil {
+		br.ErrMsg = "无法解析请求体"
+		return
+	}
+
+	indexCode := reqData.IndexCode
+	if indexCode == "" {
+		br.Msg = "请输入指标id!"
+		br.ErrMsg = "请输入指标id"
+		return
+	}
+
+	dataTime := reqData.DataTime
+	if dataTime == "" {
+		br.Msg = "请输入时间!"
+		br.ErrMsg = "请输入时间"
+		return
+	}
+
+	lyEdbData, err := models.GetLyEdbDataByIndexCodeAndExactDataTime(indexCode, dataTime)
+	if err != nil {
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Data = lyEdbData
+	br.Msg = "获取成功"
+}
+
 // UpdateLyEdbDataById
-// @Title 更新指标库指标数据
-// @Description 更新数据源指标数据
+// @Title 更新指标库数据 须根据指标编码和日期更新 仅适合月度数据
+// @Description 更新指标库数据 须根据指标编码和日期更新 仅适合月度数据
 // @Success 200 string "处理成功"
-// @router /update/ly/edb/data/by/id [get]
+// @router /update/ly/edb/data/by/id [post]
 func (this *BaseFromLyController) UpdateLyEdbDataById() {
 	br := new(models.BaseResponse).Init()
 	var cacheKey string
@@ -478,33 +602,159 @@ func (this *BaseFromLyController) UpdateLyEdbDataById() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
-	id, err := this.GetInt("Id")
+	var reqData struct {
+		Id    int     `json:"Id"`
+		Value float64 `json:"Value"`
+	}
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
 	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		br.ErrMsg = "无法解析请求体"
 		return
 	}
+
+	id := reqData.Id
 	if id == 0 {
 		br.Msg = "请输入id!"
 		br.ErrMsg = "请输入id"
 		return
 	}
 
-	value, err := this.GetFloat("Value")
+	value := reqData.Value
+	if value == 0 {
+		br.Msg = "请输入值!"
+		br.ErrMsg = "请输入值"
+		return
+	}
+
+	err = models.UpdateLyEdbDataById(id, value)
 	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
 
-	if value == 0 {
-		br.Msg = "请输入值!"
-		br.ErrMsg = "请输入值"
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "处理成功"
+}
+
+// GetLyIndexByCode
+// @Title 查询指标编码是否存在
+// @Description 查询指标编码是否存在
+// @Success 200 {object} models.BaseFromLyIndex
+// @router /get/ly/index/by/code [post]
+func (this *BaseFromLyController) GetLyIndexByCode() {
+	br := new(models.BaseResponse).Init()
+	var cacheKey string
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		_ = utils.Rc.Delete(cacheKey)
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	var reqData struct {
+		IndexCode string `json:"IndexCode"`
+	}
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
+	if err != nil {
+		br.ErrMsg = "无法解析请求体"
 		return
 	}
 
-	err = models.UpdateLyDataById(id, value)
+	indexCode := reqData.IndexCode
+	if indexCode == "" {
+		br.Msg = "请输入指标id!"
+		br.ErrMsg = "请输入指标id"
+		return
+	}
+
+	lyIndex, err := models.GetLyIndexByCode(indexCode)
+	if err != nil {
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Data = lyIndex
+	br.Msg = "获取成功"
+}
+
+// GetEdbInfoByIndexCode
+// @Title 根据指标code获取指标信息
+// @Description 根据指标code获取指标信息
+// @Success 200 {object} models.EdbInfo
+// @router /get/edb/info/by/index/code [post]
+func (this *BaseFromLyController) GetEdbInfoByIndexCode() {
+	br := new(models.BaseResponse).Init()
+	var cacheKey string
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		_ = utils.Rc.Delete(cacheKey)
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	var reqData struct {
+		IndexCode string `json:"IndexCode"`
+		Source    int    `json:"Source"`
+	}
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
+	if err != nil {
+		br.ErrMsg = "无法解析请求体"
+		return
+	}
+
+	indexCode := reqData.IndexCode
+	if indexCode == "" {
+		br.Msg = "请输入指标id!"
+		br.ErrMsg = "请输入指标id"
+		return
+	}
+	source := reqData.Source
+	if source == 0 {
+		br.Msg = "请输入来源!"
+		br.ErrMsg = "请输入来源"
+		return
+	}
+
+	lyEdbData, err := models.GetEdbInfoByEdbCode(source, indexCode)
+	if err != nil {
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Data = lyEdbData
+	br.Msg = "获取成功"
+}
+
+// AddBatchLyEdbData
+// @Title 批量增加粮油指标库数据
+// @Description 批量增加粮油指标库数据
+// @Success 200 string "处理成功"
+// @router /add/batch/ly/edb/data [post]
+func (this *BaseFromLyController) AddBatchLyEdbData() {
+	br := new(models.BaseResponse).Init()
+	var cacheKey string
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		_ = utils.Rc.Delete(cacheKey)
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	var req []models.EdbDataLy
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	err = models.AddLyEdbDataList(req)
 	if err != nil {
 		return
 	}

+ 8 - 2
models/base_from_ly_classify.go

@@ -1,7 +1,10 @@
 // @Author gmy 2024/8/7 9:26:00
 package models
 
-import "github.com/beego/beego/v2/client/orm"
+import (
+	"errors"
+	"github.com/beego/beego/v2/client/orm"
+)
 
 type BaseFromLyClassify struct {
 	BaseFromLyClassifyId int    `orm:"column(base_from_ly_classify_id);pk"` // 分类ID
@@ -19,8 +22,11 @@ func init() {
 
 // GetLyClassifyByName 根据分类名称查询
 func GetLyClassifyByName(classifyName string) (item *BaseFromLyClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_ly_classify WHERE classify_name=?`
 	err = o.Raw(sql, classifyName).QueryRow(&item)
+	if errors.Is(err, orm.ErrNoRows) {
+		return nil, nil
+	}
 	return
 }

+ 17 - 5
models/base_from_ly_data.go

@@ -1,7 +1,10 @@
 // @Author gmy 2024/8/7 9:50:00
 package models
 
-import "github.com/beego/beego/v2/client/orm"
+import (
+	"errors"
+	"github.com/beego/beego/v2/client/orm"
+)
 
 type BaseFromLyData struct {
 	BaseFromLyDataId  int     `orm:"column(base_from_ly_data_id);pk"` // 数据ID
@@ -19,30 +22,36 @@ func init() {
 
 // AddLyDataList 批量插入数据记录列表
 func AddLyDataList(items []BaseFromLyData) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	_, err = o.InsertMulti(len(items), items)
 	return
 }
 
 // GetLyDataByIndexIdAndDataTime 根据指标id和数据日期查询数据
 func GetLyDataByIndexIdAndDataTime(indexId int, dataTime string) (items []BaseFromLyData, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_ly_data WHERE base_from_ly_index_id=? AND data_time=?`
 	_, err = o.Raw(sql, indexId, dataTime).QueryRows(&items)
+	if errors.Is(err, orm.ErrNoRows) {
+		return nil, nil
+	}
 	return
 }
 
 // GetLyDataByIndexIdAndDataTimeYM 根据指标id和数据日期的年月查询数据
 func GetLyDataByIndexIdAndDataTimeYM(indexId int, dataTime string) (items []BaseFromLyData, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_ly_data WHERE base_from_ly_index_id=? AND data_time like ?`
 	_, err = o.Raw(sql, indexId, dataTime+"%").QueryRows(&items)
+	if errors.Is(err, orm.ErrNoRows) {
+		return nil, nil
+	}
 	return
 }
 
 // UpdateLyDataById 根据主键id更新数据
 func UpdateLyDataById(dataId int, value float64) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := `UPDATE base_from_ly_data SET value=? WHERE base_from_ly_data_id=?`
 	_, err = o.Raw(sql, value, dataId).Exec()
 	return
@@ -56,5 +65,8 @@ func GetBaseFromLyDataByIndexCode(condition string, pars []interface{}) (items [
 		sql += condition
 	}
 	_, err = o.Raw(sql, pars...).QueryRows(&items)
+	if errors.Is(err, orm.ErrNoRows) {
+		return nil, nil
+	}
 	return
 }

+ 3 - 3
models/base_from_ly_index.go

@@ -27,7 +27,7 @@ func init() {
 
 // AddLyIndexList 批量插入指标记录列表
 func AddLyIndexList(items []*BaseFromLyIndex) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	_, err = o.InsertMulti(len(items), items)
 	return
 }
@@ -35,7 +35,7 @@ func AddLyIndexList(items []*BaseFromLyIndex) (err error) {
 // AddLyIndex 添加指标
 func AddLyIndex(item *BaseFromLyIndex) (int64, error) {
 	item.CreateTime = time.Now().Format("2006-01-02 15:04:05")
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	id, err := o.Insert(item)
 	if err != nil {
 		return 0, err
@@ -45,7 +45,7 @@ func AddLyIndex(item *BaseFromLyIndex) (int64, error) {
 
 // GetLyIndexByCode 查询指标编码是否存在
 func GetLyIndexByCode(indexCode string) (item *BaseFromLyIndex, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_ly_index WHERE index_code=?`
 	err = o.Raw(sql, indexCode).QueryRow(&item)
 

+ 2 - 2
models/base_from_ly_index_record.go

@@ -24,7 +24,7 @@ func init() {
 
 // AddLyIndexRecord 添加指标记录
 func AddLyIndexRecord(item *BaseFromLyIndexRecord) (int64, error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	id, err := o.Insert(item)
 	if err != nil {
 		return 0, err
@@ -34,7 +34,7 @@ func AddLyIndexRecord(item *BaseFromLyIndexRecord) (int64, error) {
 
 // GetLyIndexRecordByUrl 查询指标记录是否存在
 func GetLyIndexRecordByUrl(url string) (item *BaseFromLyIndexRecord, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_ly_index_record WHERE url=?`
 	err = o.Raw(sql, url).QueryRow(&item)
 

+ 60 - 0
models/ebd_data_ly.go → models/edb_data_ly.go

@@ -1,6 +1,66 @@
 // @Author gmy 2024/9/14 16:13:00
 package models
 
+import (
+	"errors"
+	"eta/eta_index_lib/utils"
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+	"strconv"
+	"strings"
+	"time"
+)
+
+type EdbDataLy struct {
+	edbDataId     int     `orm:"column(edb_data_id);pk"` // 数据ID
+	CreateTime    string  `orm:"column(create_time)"`    // 创建时间
+	ModifyTime    string  `orm:"column(modify_time)"`    // 修改时间
+	EdbInfoId     int     `orm:"column(edb_info_id)"`    // 指标id
+	EdbCode       string  `orm:"column(edb_code)"`       // 指标编码
+	DataTime      string  `orm:"column(data_time)"`      // 数据日期
+	Value         float64 `orm:"column(value)"`          // 数据值
+	DataTimestamp uint64  `orm:"column(data_timestamp)"` // 数据日期时间戳
+}
+
+func init() {
+	orm.RegisterModel(new(EdbDataLy))
+}
+
+func GetLyEdbDataByIndexCodeAndDataTime(indexCode string, dataTime string) (items []EdbDataLy, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM edb_data_ly WHERE index_code=? AND data_time like ?`
+	_, err = o.Raw(sql, indexCode, dataTime+"%").QueryRows(&items)
+	if errors.Is(err, orm.ErrNoRows) {
+		return nil, nil
+	}
+	return
+}
+
+func GetLyEdbDataByIndexCodeAndExactDataTime(indexCode string, dataTime string) (items []EdbDataLy, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM edb_data_ly WHERE edb_code=? AND data_time=?`
+	_, err = o.Raw(sql, indexCode, dataTime).QueryRows(&items)
+	if errors.Is(err, orm.ErrNoRows) {
+		return nil, nil
+	}
+	return
+}
+
+// UpdateLyEdbDataById 更新指标库数据 须根据指标编码和日期更新 仅适合月度数据
+func UpdateLyEdbDataById(id int, value float64) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE edb_data_ly SET value=? WHERE edb_data_id=?`
+	_, err = o.Raw(sql, value, id).Exec()
+	return
+}
+
+// 新增指标库数据
+func AddLyEdbDataList(items []EdbDataLy) (err error) {
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(len(items), items)
+	return
+}
+
 // AddEdbDataFromLy 新增指标数据
 func AddEdbDataFromLy(edbCode string) (err error) {
 	o := orm.NewOrm()

+ 5 - 0
models/edb_info.go

@@ -540,6 +540,11 @@ func GetEdbInfoByEdbCode(source int, edbCode string) (item *EdbInfo, err error)
 	o := orm.NewOrm()
 	sql := ` SELECT * FROM edb_info WHERE source=? AND edb_code=? `
 	err = o.Raw(sql, source, edbCode).QueryRow(&item)
+
+	if errors.Is(err, orm.ErrNoRows) {
+		err = nil
+	}
+
 	return
 }
 

+ 51 - 6
routers/commentsRouter.go

@@ -106,6 +106,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"],
+        beego.ControllerComments{
+            Method: "AddBatchLyEdbData",
+            Router: `/add/batch/ly/edb/data`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"],
         beego.ControllerComments{
             Method: "AddLyDataList",
@@ -133,11 +142,20 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"],
+        beego.ControllerComments{
+            Method: "GetEdbInfoByIndexCode",
+            Router: `/get/edb/info/by/index/code`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"],
         beego.ControllerComments{
             Method: "GetLyClassifyByName",
             Router: `/get/ly/classify/by/name`,
-            AllowHTTPMethods: []string{"get"},
+            AllowHTTPMethods: []string{"post"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})
@@ -146,7 +164,7 @@ func init() {
         beego.ControllerComments{
             Method: "GetLyDataByIndexIdAndDataTime",
             Router: `/get/ly/data/by/index/id/and/data/time`,
-            AllowHTTPMethods: []string{"get"},
+            AllowHTTPMethods: []string{"post"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})
@@ -155,7 +173,34 @@ func init() {
         beego.ControllerComments{
             Method: "GetLyDataByIndexIdAndDataTimeYM",
             Router: `/get/ly/data/by/index/id/and/data/time/ym`,
-            AllowHTTPMethods: []string{"get"},
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"],
+        beego.ControllerComments{
+            Method: "GetLyEdbDataByIndexCodeAndDataTime",
+            Router: `/get/ly/edb/data/by/index/code/and/data/time`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"],
+        beego.ControllerComments{
+            Method: "GetLyEdbDataByIndexCodeAndExactDataTime",
+            Router: `/get/ly/edb/data/by/index/code/and/exact/data/time`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:BaseFromLyController"],
+        beego.ControllerComments{
+            Method: "GetLyIndexByCode",
+            Router: `/get/ly/index/by/code`,
+            AllowHTTPMethods: []string{"post"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})
@@ -164,7 +209,7 @@ func init() {
         beego.ControllerComments{
             Method: "GetLyIndexRecordByUrl",
             Router: `/get/ly/index/record/by/url`,
-            AllowHTTPMethods: []string{"get"},
+            AllowHTTPMethods: []string{"post"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})
@@ -182,7 +227,7 @@ func init() {
         beego.ControllerComments{
             Method: "UpdateLyDataById",
             Router: `/update/ly/data/by/id`,
-            AllowHTTPMethods: []string{"get"},
+            AllowHTTPMethods: []string{"post"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})
@@ -191,7 +236,7 @@ func init() {
         beego.ControllerComments{
             Method: "UpdateLyEdbDataById",
             Router: `/update/ly/edb/data/by/id`,
-            AllowHTTPMethods: []string{"get"},
+            AllowHTTPMethods: []string{"post"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})