Search in sources :

Example 1 with SortList

use of hry.core.util.SortList 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)

Aggregations

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