浏览代码

Merge branch 'feature/eta2.2.1_usda_fas' into debug

# Conflicts:
#	models/data_manage/edb_info.go
xyxie 6 月之前
父节点
当前提交
3a842346ed
共有 3 个文件被更改,包括 67 次插入6 次删除
  1. 47 6
      controllers/data_manage/usda_fas_data.go
  2. 11 0
      models/data_manage/base_from_usda_fas.go
  3. 9 0
      routers/commentsRouter.go

+ 47 - 6
controllers/data_manage/usda_fas_data.go

@@ -178,6 +178,7 @@ func (this *BaseFromUsdaFasController) UsdaFasIndexData() {
 	}
 	edbInfoMap := make(map[string]*data_manage.EdbInfo)
 	dataMap := make(map[string][]*data_manage.BaseFromUsdaFasData)
+	total := 0
 	if len(edbCodeList) > 0 {
 		edbInfoList, err := data_manage.GetEdbInfoByEdbCodeList(utils.DATA_SOURCE_USDA_FAS, edbCodeList)
 		if err != nil {
@@ -212,13 +213,15 @@ func (this *BaseFromUsdaFasController) UsdaFasIndexData() {
 				dataMap[v.IndexCode] = append(dataMap[v.IndexCode], v)
 			}
 		}
+
+		total, err = data_manage.GetUsdaFasIndexDataTimePageCount(edbCodeList)
+		if err != nil {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "获取指标数据失败,Err:" + err.Error()
+			return
+		}
 	}
-	total, err := data_manage.GetUsdaFasIndexDataTimePageCount(edbCodeList)
-	if err != nil {
-		br.Msg = "获取数据失败"
-		br.ErrMsg = "获取指标数据失败,Err:" + err.Error()
-		return
-	}
+
 	page := paging.GetPaging(currentIndex, pageSize, total)
 
 	resultList := make([]*data_manage.BaseFromUsdaFasIndexList, 0)
@@ -1241,3 +1244,41 @@ func (this *BaseFromUsdaFasController) ExportUsdaFasList() {
 	br.Success = true
 	br.Msg = "success"
 }
+
+// GetFrequency
+// @Title 美国农业部数据频度
+// @Description 美国农业部数据频度接口
+// @Param   ClassifyId   query   string  true       "分类Id"
+// @Success 200 {object} data_manage.LzFrequency
+// @router /usda_fas/frequency [get]
+func (this *BaseFromUsdaFasController) GetFrequency() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	classifyId, _ := this.GetInt("ClassifyId")
+	if classifyId < 0 {
+		br.Msg = "请选择分类"
+		br.ErrMsg = "请选择分类"
+		return
+	}
+
+	frequencyList, err := data_manage.GetUsdaFasFrequencyByClassifyId(classifyId)
+	if err != nil {
+		br.Msg = "获取频度失败"
+		br.ErrMsg = "获取频度失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = frequencyList
+}

+ 11 - 0
models/data_manage/base_from_usda_fas.go

@@ -27,6 +27,9 @@ type BaseFromUsdaFasIndexList struct {
 	EdbInfoId              int
 	EdbUniqueCode          string `description:"指标库唯一编码"`
 	EdbClassifyId          int    `description:"指标库分类ID"`
+	StartDate              string
+	EndDate                string
+	EndValue               float64
 	IndexCode              string
 	IndexName              string
 	Frequency              string
@@ -246,3 +249,11 @@ type UsdaFasIndexSource2EdbReq struct {
 	AdminId       int
 	AdminRealName string
 }
+
+func GetUsdaFasFrequencyByClassifyId(classifyId int) (items []*GlFrequency, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT frequency FROM base_from_usda_fas_index WHERE classify_id = ? `
+	sql += ` GROUP BY frequency ORDER BY frequency ASC `
+	_, err = o.Raw(sql, classifyId).QueryRows(&items)
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -2824,6 +2824,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:BaseFromUsdaFasController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:BaseFromUsdaFasController"],
+        beego.ControllerComments{
+            Method: "GetFrequency",
+            Router: `/usda_fas/frequency`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:BaseFromUsdaFasController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:BaseFromUsdaFasController"],
         beego.ControllerComments{
             Method: "UsdaFasIndexData",