浏览代码

Merge remote-tracking branch 'origin/debug' into debug

Roc 1 年之前
父节点
当前提交
a56f1766bb
共有 3 个文件被更改,包括 22 次插入7 次删除
  1. 0 1
      controllers/data_manage/my_chart.go
  2. 6 6
      models/data_manage/chart_edb_mapping.go
  3. 16 0
      services/data/chart_info.go

+ 0 - 1
controllers/data_manage/my_chart.go

@@ -1869,7 +1869,6 @@ func (this *MyChartController) Locate() {
 				return
 			}
 			condition += fmt.Sprintf(` AND chart_classify_id IN (%s)`, strIds)
-			orderRule = `chart_classify_id`
 		}
 	}
 

+ 6 - 6
models/data_manage/chart_edb_mapping.go

@@ -36,7 +36,7 @@ func AddChartEdbMapping(items []*ChartEdbMapping) (err error) {
 
 func GetChartEdbMappingList(chartInfoId int) (list []*ChartEdbInfoMapping, err error) {
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT a.*,b.source_name,b.source,b.classify_id,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type
+	sql := ` SELECT a.*,b.source_name,b.source,b.classify_id,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.edb_type
              FROM chart_edb_mapping AS a
 			 INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			 WHERE chart_info_id=? 
@@ -47,7 +47,7 @@ func GetChartEdbMappingList(chartInfoId int) (list []*ChartEdbInfoMapping, err e
 
 func GetChartEdbMappingListByChartInfoIds(chartInfoIds string) (list []*ChartEdbInfoMapping, err error) {
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT a.*,b.source_name,b.source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type
+	sql := ` SELECT a.*,b.source_name,b.source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.edb_type
              FROM chart_edb_mapping AS a
 			 INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			 WHERE chart_info_id in (` + chartInfoIds + `) 
@@ -58,7 +58,7 @@ func GetChartEdbMappingListByChartInfoIds(chartInfoIds string) (list []*ChartEdb
 
 func GetChartEdbMappingListByEdbInfoId(edbInfoStr string) (list []*ChartEdbInfoMapping, err error) {
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT edb_info_id,source_name,source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value
+	sql := ` SELECT edb_info_id,source_name,source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value,edb_type
              FROM edb_info
 			 WHERE edb_info_id IN(` + edbInfoStr + `)
 			ORDER BY FIELD(edb_info_id,` + edbInfoStr + `)
@@ -74,7 +74,7 @@ func GetChartEdbMappingListByEdbInfoIdList(edbIdList []int) (list []*ChartEdbInf
 		return
 	}
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT edb_info_id,source_name,source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value
+	sql := ` SELECT edb_info_id,source_name,source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value,edb_type
              FROM edb_info
 			 WHERE edb_info_id IN(` + utils.GetOrmInReplace(num) + `)
 			ORDER BY FIELD(edb_info_id,` + utils.GetOrmInReplace(num) + `)
@@ -90,7 +90,7 @@ func GetChartEdbMappingListByIdList(chartInfoIdList []int) (list []*ChartEdbInfo
 		return
 	}
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT a.*,b.source_name,b.source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type
+	sql := ` SELECT a.*,b.source_name,b.source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type,b.edb_type AS edb_info_category_type
              FROM chart_edb_mapping AS a
 			 INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			 WHERE chart_info_id in (` + utils.GetOrmInReplace(num) + `) 
@@ -192,7 +192,7 @@ func GetChartEdbMappingByEdbInfoId(edbInfoId int) (item *ChartEdbInfoMapping, er
 // GetChartEdbMappingByFutureGoodEdbInfoId 根据指标id获取edb_mapping
 func GetChartEdbMappingByFutureGoodEdbInfoId(edbInfoId int) (item *ChartEdbInfoMapping, err error) {
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT future_good_edb_info_id as edb_info_id,future_good_edb_code as edb_code,b.future_good_edb_name as edb_name,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value
+	sql := ` SELECT future_good_edb_info_id as edb_info_id,future_good_edb_code as edb_code,b.future_good_edb_name as edb_name,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.region_type
              FROM future_good_edb_info b
 			 WHERE future_good_edb_info_id = ?  limit 1 `
 	err = o.Raw(sql, edbInfoId).QueryRow(&item)

+ 16 - 0
services/data/chart_info.go

@@ -237,6 +237,21 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 					startDateReal = startDate
 					diffSeconds = 0
 				}
+
+				// 预测指标的开始日期也要偏移
+				{
+					day, tmpErr := utils.GetDaysBetween2Date(utils.FormatDate, startDate, startDateReal)
+					if tmpErr != nil {
+						err = tmpErr
+						return
+					}
+					latestDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, item.LatestDate, time.Local)
+					if tmpErr != nil {
+						err = tmpErr
+						return
+					}
+					item.LatestDate = latestDateTime.AddDate(0, 0, day).Format(utils.FormatDate)
+				}
 			} else {
 				startDateReal = startDate
 			}
@@ -599,6 +614,7 @@ func BarChartData(mappingList []*data_manage.ChartEdbInfoMapping, edbDataListMap
 				}
 			}
 			if tmpValue, ok := edbDataMap[edbInfoId][findDate]; ok {
+				tmpValue, _ = decimal.NewFromFloat(tmpValue).Round(4).Float64()
 				findDataList = append(findDataList, tmpValue)
 			} else {
 				findDataList = append(findDataList, 0)