|
@@ -6,6 +6,7 @@ import (
|
|
|
"eta/eta_chart_lib/models/mgo"
|
|
|
"eta/eta_chart_lib/utils"
|
|
|
"fmt"
|
|
|
+ "gorm.io/gorm"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
|
|
@@ -61,11 +62,24 @@ type ChartInfo struct {
|
|
|
MarkersAreas string `description:"标识区"`
|
|
|
}
|
|
|
|
|
|
+func (m *ChartInfo) ConvertDate() {
|
|
|
+ m.StartDate = utils.GormDateStrToDateStr(m.StartDate)
|
|
|
+ m.EndDate = utils.GormDateStrToDateStr(m.EndDate)
|
|
|
+ m.SeasonStartDate = utils.GormDateStrToDateStr(m.SeasonStartDate)
|
|
|
+ m.SeasonEndDate = utils.GormDateStrToDateStr(m.SeasonEndDate)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func GetChartInfoByUniqueCode(uniqueCode string) (item *ChartInfo, err error) {
|
|
|
//o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM chart_info WHERE unique_code=? `
|
|
|
//err = o.Raw(sql, uniqueCode).QueryRow(&item)
|
|
|
err = global.DbMap[utils.DbNameIndex].Raw(sql, uniqueCode).First(&item).Error
|
|
|
+ if err != nil {
|
|
|
+ item.ConvertDate()
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -126,6 +140,26 @@ type ChartEdbInfoMapping struct {
|
|
|
IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
|
|
|
}
|
|
|
|
|
|
+func (m *ChartEdbInfoMapping) AfterFind(db *gorm.DB) (err error) {
|
|
|
+ m.StartDate = utils.GormDateStrToDateStr(m.StartDate)
|
|
|
+ m.EndDate = utils.GormDateStrToDateStr(m.EndDate)
|
|
|
+ m.LatestDate = utils.GormDateStrToDateStr(m.LatestDate)
|
|
|
+ m.MoveLatestDate = utils.GormDateStrToDateStr(m.MoveLatestDate)
|
|
|
+ m.ModifyTime = utils.GormDateStrToDateTimeStr(m.ModifyTime)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *ChartEdbInfoMapping) ConvertDate() {
|
|
|
+ m.StartDate = utils.GormDateStrToDateStr(m.StartDate)
|
|
|
+ m.EndDate = utils.GormDateStrToDateStr(m.EndDate)
|
|
|
+ m.LatestDate = utils.GormDateStrToDateStr(m.LatestDate)
|
|
|
+ m.MoveLatestDate = utils.GormDateStrToDateStr(m.MoveLatestDate)
|
|
|
+ m.ModifyTime = utils.GormDateStrToDateTimeStr(m.ModifyTime)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func GetChartEdbMappingList(chartInfoId int) (list []*ChartEdbInfoMapping, err error) {
|
|
|
aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source,a.edb_alias_name,a.chart_scale`
|
|
|
sql := ` SELECT ` + aField + `,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.edb_type,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.sub_source,
|
|
@@ -147,6 +181,12 @@ type EdbDataList struct {
|
|
|
Value float64 `description:"数据值"`
|
|
|
}
|
|
|
|
|
|
+func (m *EdbDataList) AfterFind(db *gorm.DB) (err error) {
|
|
|
+ m.DataTime = utils.GormDateStrToDateStr(m.DataTime)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// GetEdbDataList 获取指标的数据(日期正序返回)
|
|
|
func GetEdbDataList(source, subSource, edbInfoId int, startDate, endDate string) (list []*EdbDataList, err error) {
|
|
|
// 自有数据需要额外处理(从mongo获取)
|
|
@@ -957,6 +997,10 @@ func GetChartInfoById(chartInfoId int) (item *ChartInfo, err error) {
|
|
|
sql := ` SELECT * FROM chart_info WHERE chart_info_id=? `
|
|
|
//err = o.Raw(sql, chartInfoId).QueryRow(&item)
|
|
|
err = global.DbMap[utils.DbNameIndex].Raw(sql, chartInfoId).First(&item).Error
|
|
|
+ if err != nil {
|
|
|
+ item.ConvertDate()
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|