|
|
@@ -352,11 +352,19 @@ func GetPriceCurve(c *gin.Context) { |
|
|
|
switch kind { |
|
|
|
case "1": |
|
|
|
var date = now.AddDate(0, 0, -6).Format("2006-01-02") |
|
|
|
var sql = fmt.Sprintf("SELECT price,date FROM `egg_energy_price` WHERE HOUR = 23 AND DATE >= \"%s\" AND DATE != \"%s\" ORDER BY DATE ASC ", date, now.Format("2006-01-02")) |
|
|
|
results, _ := db.Db.QueryString(db.Db, sql) |
|
|
|
for _, v := range results { |
|
|
|
tmpDate := utils.String2TimeV2(v["date"]) |
|
|
|
yData = append(yData, v["price"]) |
|
|
|
var priceModel []model.EggEnergyPrice |
|
|
|
err1 := db.Db.Table("egg_energy_price"). |
|
|
|
And("hour = 23"). |
|
|
|
And("date > ?", date). |
|
|
|
Asc("date"). |
|
|
|
Find(&priceModel) |
|
|
|
if err1 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
for _, v := range priceModel { |
|
|
|
tmpDate := utils.String2TimeV2(v.Date) |
|
|
|
yData = append(yData, v.Price) |
|
|
|
xData = append(xData, tmpDate.Format("01-02")) |
|
|
|
} |
|
|
|
yData = append(yData, m.Price) |
|
|
@@ -385,12 +393,18 @@ func GetPriceCurve(c *gin.Context) { |
|
|
|
var nums = 6 |
|
|
|
for i := nums; i >= 1; i-- { |
|
|
|
var date = now.AddDate(0, 0, -7*i).Format("2006-01-02") |
|
|
|
var sql = "SELECT price,date FROM `egg_energy_price` WHERE HOUR = 23 AND DATE = \"%s\" " |
|
|
|
sql = fmt.Sprintf(sql, date) |
|
|
|
results, _ := db.Db.QueryString(db.Db, sql) |
|
|
|
if results != nil { |
|
|
|
tmpDate := utils.String2TimeV2(results[0]["date"]) |
|
|
|
yData = append(yData, results[0]["price"]) |
|
|
|
var priceModel model.EggEnergyPrice |
|
|
|
exist, err1 := db.Db.Table("egg_energy_price"). |
|
|
|
And("hour = 23"). |
|
|
|
And("date = ?", date). |
|
|
|
Get(&priceModel) |
|
|
|
if err1 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if exist { |
|
|
|
tmpDate := utils.String2TimeV2(priceModel.Date) |
|
|
|
yData = append(yData, priceModel.Price) |
|
|
|
xData = append(xData, tmpDate.Format("01-02")) |
|
|
|
} |
|
|
|
} |
|
|
|