#include "stockssqlmanager.h"

StocksSqlManager::StocksSqlManager()
{

}

StocksSqlManager::~StocksSqlManager()
{

}

QString StocksSqlManager::toInsertSql(_stocksInfo stock)
{
    QString sql = QString("insert into stocks (code, trade_day, open,close,differrange,trade_days,volumn,amount,differrange10,differrange20,differrange60,avg_volume20,freefloat_market_value,agencies_hold) "
                                           "SELECT  ':code', ':trade_day', :open,:close,:differrange_c,:trade_days,:volumn,:amount,:differrange10,:differrange20,:differrange60,:avg_volume20,:freefloat_market_value,:agencies_hold from DUAL where not exists(select code from stocks where code = ':code' and trade_day = ':trade_day' and open = :open);");
    sql.replace(":code",stock.code);
    sql.replace(":trade_days",stock.tradeDays);
    sql.replace(":trade_day",stock.tradeDay);
    sql.replace(":open",stock.open);
    sql.replace(":close",stock.close);
    sql.replace(":differrange_c",stock.differRange);
    sql.replace(":volumn",QString::number(stock.volumn.toDouble()));
    sql.replace(":amount",QString::number(stock.amount.toDouble()));
    sql.replace(":differrange10",stock.differRangeP10);
    sql.replace(":differrange20",stock.differRangeP20);
    sql.replace(":differrange60",stock.differRangeP60);
    sql.replace(":avg_volume20",QString::number(stock.avgVolume20.toDouble()));
    sql.replace(":freefloat_market_value",stock.freeFloatMarketValue);
    sql.replace(":agencies_hold",QString::number(stock.agenciesHold.toDouble()));
    return sql;
}

QString StocksSqlManager::toDeleteSql()
{
    return "";
}

QString StocksSqlManager::toQuerySql()
{
    return "";
}
