Search in sources :

Example 1 with MarketTradesSub

use of hry.trade.websoketContext.model.MarketTradesSub in project benchmark by seelunzi.

the class ExOrderServiceImpl method getNewListMarket.

/*     */
/*     */
/*     */
/*     */
/*     */
public String getNewListMarket(String header, String timeorder) /*     */
{
    /* 187 */
    String[] headarry = header.split("_");
    /* 188 */
    int keepDecimalForCoin = 8;
    /* 189 */
    int keepDecimalForCurrency = 8;
    /*     */
    /* 191 */
    String str = this.redisService.get("cn:coinInfoList");
    /* 192 */
    if (!StringUtils.isEmpty(str)) {
        /* 193 */
        JSONArray pa = JSON.parseArray(str);
        /* 194 */
        if (pa != null) {
            /* 195 */
            for (int i = 0; i < pa.size(); i++) {
                /* 196 */
                JSONObject obj = pa.getJSONObject(i);
                /* 197 */
                if (header.equals(obj.getString("coinCode") + "_" + obj.getString("fixPriceCoinCode"))) {
                    /* 198 */
                    keepDecimalForCoin = obj.getIntValue("keepDecimalForCoin");
                    /* 199 */
                    keepDecimalForCurrency = obj.getIntValue("keepDecimalForCurrency");
                    /* 200 */
                    break;
                /*     */
                }
            /*     */
            }
        /*     */
        }
    /*     */
    }
    /*     */
    /* 206 */
    Map<String, Object> seramap = new HashMap();
    /* 207 */
    seramap.put("coinCode", headarry[0]);
    /* 208 */
    seramap.put("fixPriceCoinCode", headarry[1]);
    /* 209 */
    seramap.put("count", ExchangeDataCacheRedis.LastOrderRecordsLmit);
    /* 210 */
    List<ExOrderInfo> list = null;
    /* 211 */
    if (timeorder.equals("asc")) {
        /* 212 */
        String v = header + ":" + "LastOrderRecords";
        /* 213 */
        if (!StringUtil.isEmpty(v)) {
            /* 214 */
            list = this.exOrderInfoDao.findNewList(seramap);
            /* 215 */
            this.redisService.save(header + ":" + "LastOrderRecords", JSON.toJSONString(list));
        /*     */
        } else {
            /* 217 */
            list = JSON.parseArray(v, ExOrderInfo.class);
        /*     */
        }
    /*     */
    } else /*     */
    {
        /* 221 */
        String v = this.redisService.get(header + ":" + "LastOrderRecords");
        /* 222 */
        if (StringUtil.isEmpty(v)) {
            /* 223 */
            list = this.exOrderInfoDao.findNewListDesc(seramap);
            /* 224 */
            Collections.reverse(list);
            /* 225 */
            this.redisService.save(header + ":" + "LastOrderRecords", JSON.toJSONString(list));
        /*     */
        } else {
            /* 227 */
            list = JSON.parseArray(v, ExOrderInfo.class);
            /* 228 */
            Collections.reverse(list);
        /*     */
        }
    /*     */
    }
    /*     */
    /* 232 */
    List<MarketTradesSub> listsub = new ArrayList();
    /* 233 */
    for (ExOrderInfo l : list) {
        /* 234 */
        MarketTradesSub sub = new MarketTradesSub();
        /* 235 */
        sub.setAmount(l.getTransactionCount().setScale(keepDecimalForCoin, 4));
        /* 236 */
        sub.setPrice(l.getTransactionPrice().setScale(keepDecimalForCurrency, 4));
        /* 237 */
        sub.setTid(l.getOrderNum());
        /* 238 */
        sub.setType(l.getInOrOutTransaction());
        /* 239 */
        sub.setTime(l.getTransactionTime().getTime() / 1000L);
        /* 240 */
        listsub.add(sub);
    /*     */
    }
    /* 242 */
    SortList<MarketTradesSub> sort = new SortList();
    /* 243 */
    sort.Sort(listsub, "getTime", "desc");
    /* 244 */
    MarketTrades marketTrades = new MarketTrades();
    /* 245 */
    marketTrades.setTrades(listsub);
    /* 246 */
    return JSON.toJSONString(marketTrades).toString();
/*     */
}
Also used : JSONArray(com.alibaba.fastjson.JSONArray) ExOrderInfo(hry.trade.entrust.model.ExOrderInfo) MarketTrades(hry.trade.websoketContext.model.MarketTrades) JSONObject(com.alibaba.fastjson.JSONObject) MarketTradesSub(hry.trade.websoketContext.model.MarketTradesSub) SortList(hry.core.util.SortList) JSONObject(com.alibaba.fastjson.JSONObject)

Example 2 with MarketTradesSub

use of hry.trade.websoketContext.model.MarketTradesSub in project benchmark by seelunzi.

the class ExOrderServiceImpl method findNewListMarketnewAdd.

/*     */
/*     */
public String findNewListMarketnewAdd(String header, String minDate, String maxDate) /*     */
{
    /* 251 */
    ExOrderDao exOrderDao = (ExOrderDao) this.dao;
    /* 252 */
    String[] headarry = header.split(":");
    /* 253 */
    Map<String, Object> seramap = new HashMap();
    /* 254 */
    seramap.put("website", headarry[0]);
    /* 255 */
    seramap.put("currencyType", headarry[1]);
    /* 256 */
    seramap.put("coinCode", headarry[2].split("_")[0]);
    /* 257 */
    seramap.put("fixPriceCoinCode", headarry[2].split("_")[1]);
    /* 258 */
    seramap.put("minDate", minDate);
    /* 259 */
    seramap.put("maxDate", maxDate);
    /* 260 */
    List<ExOrder> list = new ArrayList();
    /* 261 */
    if (DifCustomer.isexOrderIsMemory().booleanValue()) {
        /* 262 */
        list = this.redisService.getList1(header + ":" + "LastOrderRecordAdds");
        /* 263 */
        if ((null == list) || (list.size() == 0)) {
            /* 264 */
            list = exOrderDao.findNewListnewAdd(seramap);
            /* 265 */
            this.redisService.setList(header + ":" + "LastOrderRecords", list);
        /*     */
        } else {
            /* 267 */
            Collections.reverse(list);
            /*     */
            /* 269 */
            this.redisService.setList(header + ":" + "LastOrderRecordAdds", new ArrayList());
        /*     */
        }
    /*     */
    } else /*     */
    {
        /* 273 */
        list = exOrderDao.findNewListnewAdd(seramap);
    /*     */
    }
    /* 275 */
    List<MarketTradesSub> listsub = new ArrayList();
    /* 276 */
    if ((null != list) && (list.size() > 0)) {
        /* 277 */
        for (ExOrder l : list) {
            /* 278 */
            MarketTradesSub sub = new MarketTradesSub();
            /* 279 */
            sub.setAmount(l.getTransactionCount().setScale(4, 4));
            /* 280 */
            sub.setPrice(l.getTransactionPrice().setScale(2, 4));
            /* 281 */
            sub.setTid(l.getOrderNum());
            /* 282 */
            sub.setType(l.getInOrOutTransaction());
            /* 283 */
            sub.setTime(l.getTransactionTime().getTime() / 1000L);
            /* 284 */
            listsub.add(sub);
        /*     */
        }
        /* 286 */
        MarketTrades marketTrades = new MarketTrades();
        /* 287 */
        marketTrades.setTrades(listsub);
        /* 288 */
        return JSON.toJSONString(marketTrades).toString();
    /*     */
    }
    /* 290 */
    return "";
/*     */
}
Also used : MarketTrades(hry.trade.websoketContext.model.MarketTrades) MarketTradesSub(hry.trade.websoketContext.model.MarketTradesSub) ExOrder(hry.trade.entrust.model.ExOrder) JSONObject(com.alibaba.fastjson.JSONObject) ExOrderDao(hry.trade.entrust.dao.ExOrderDao)

Aggregations

JSONObject (com.alibaba.fastjson.JSONObject)2 MarketTrades (hry.trade.websoketContext.model.MarketTrades)2 MarketTradesSub (hry.trade.websoketContext.model.MarketTradesSub)2 JSONArray (com.alibaba.fastjson.JSONArray)1 SortList (hry.core.util.SortList)1 ExOrderDao (hry.trade.entrust.dao.ExOrderDao)1 ExOrder (hry.trade.entrust.model.ExOrder)1 ExOrderInfo (hry.trade.entrust.model.ExOrderInfo)1