|
|
@@ -4700,10 +4700,48 @@ select t.reckondate,
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
|
|
|
+// buildSqlByToday 今日走势数据
|
|
|
+func (r *WrReckonSpotGoodsTradeSum) buildSqlByToday(today string) string {
|
|
|
+ var sqlId utils.SQLVal = utils.SQLVal(fmt.Sprintf(`
|
|
|
+ with tmp as
|
|
|
+ (select
|
|
|
+ to_char(t.TradeTime, 'HH24:MI:SS') RECKONDATE,
|
|
|
+ to_char(t.TradeTime, 'yyyymmdd') TRADEDATE,
|
|
|
+ t.marketid,
|
|
|
+ w.wrstandardid,
|
|
|
+ t.tradeqty,
|
|
|
+ t.tradeamount
|
|
|
+ from WRTrade_TradeDetail t
|
|
|
+ left join WRFactorType w on w.WRFactorTypeID = t.WRFactorTypeID
|
|
|
+ where t.marketid = %v and w.wrstandardid = %v
|
|
|
+ order by t.TradeTime desc)
|
|
|
+ select distinct
|
|
|
+ t.RECKONDATE,
|
|
|
+ t.marketid,
|
|
|
+ t.wrstandardid,
|
|
|
+ t.tradeqty,
|
|
|
+ t.tradeamount
|
|
|
+ from tmp t where t.TRADEDATE = '%v'
|
|
|
+ `, r.MARKETID, r.WRSTANDARDID, today))
|
|
|
+
|
|
|
+ sqlId.Page(1, r.LastNum)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
// GetDataEx 获取价格走势
|
|
|
func (r *WrReckonSpotGoodsTradeSum) GetDataEx() (interface{}, error) {
|
|
|
+ sql := r.buildSql()
|
|
|
+ // 判断是否获取今日走势
|
|
|
+ if r.MARKETID > 0 && r.ENDDATE != "" {
|
|
|
+ if marketRun, err := GetMarketRun(r.MARKETID); err == nil {
|
|
|
+ if marketRun.Tradedate == r.ENDDATE {
|
|
|
+ sql = r.buildSqlByToday(marketRun.Tradedate)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
sData := make([]WrReckonSpotGoodsTradeSum, 0)
|
|
|
- err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ err := db.GetEngine().SQL(sql).Find(&sData)
|
|
|
for i := range sData {
|
|
|
sData[i].calc()
|
|
|
sData[i].BEGINDATE = r.BEGINDATE
|