Search in sources :

Example 1 with ExEntrust

use of hry.trade.entrust.model.ExEntrust in project benchmark by seelunzi.

the class ExOrderInfoServiceImpl method reidsToMysql.

/*     */
/*     */
/*     */
public void reidsToMysql() /*     */
{
    /* 196 */
    long start = System.currentTimeMillis();
    /*     */
    /* 198 */
    Map<String, EntrustTrade> map = new java.util.HashMap();
    /* 199 */
    long start4 = System.currentTimeMillis();
    /* 200 */
    Set<String> keysTradeDealEntrustChange = this.redisService.noPerkeys("deal:tradeDealEntrustChange:");
    /* 201 */
    long end4 = System.currentTimeMillis();
    /*     */
    /* 203 */
    List<BigDecimal> list2 = new ArrayList();
    /* 204 */
    Iterator<String> iterator1 = keysTradeDealEntrustChange.iterator();
    /* 205 */
    while (iterator1.hasNext()) {
        /* 206 */
        String keystr = (String) iterator1.next();
        /* 207 */
        BigDecimal ks = new BigDecimal(keystr.split(":")[2]);
        /* 208 */
        list2.add(ks);
    /*     */
    }
    /* 210 */
    java.util.Collections.sort(list2, new hry.trade.comparator.AscBigDecimalComparator());
    /* 211 */
    long start5 = System.currentTimeMillis();
    /* 212 */
    for (BigDecimal l : list2) {
        /* 213 */
        String keystr = "deal:tradeDealEntrustChange:" + l;
        /*     */
        /* 215 */
        List<EntrustTrade> entrustTradeSlist = JSON.parseArray(this.redisService.get(keystr), EntrustTrade.class);
        /* 216 */
        if (null != entrustTradeSlist) {
            /* 217 */
            for (EntrustTrade es : entrustTradeSlist) {
                /* 218 */
                map.put(es.getEntrustNum(), es);
            /*     */
            }
        /*     */
        }
    /*     */
    }
    /*     */
    /* 223 */
    long end5 = System.currentTimeMillis();
    /*     */
    /* 225 */
    List<EntrustTrade> entrustlisted = new ArrayList(map.values());
    /* 226 */
    long end2;
    if ((null != entrustlisted) && (entrustlisted.size() > 0)) {
        /* 227 */
        List<ExEntrust> entrustupdatelist = this.exEntrustDao.getExEntrustListByNumstoMysql(entrustlisted);
        /* 228 */
        List<EntrustTrade> entrustnewlist = new ArrayList();
        /* 229 */
        if ((null != entrustupdatelist) && (entrustupdatelist.size() > 0)) {
            /* 230 */
            int k = 0;
            /* 231 */
            int size = entrustlisted.size();
            /* 232 */
            while (k < size) {
                /* 233 */
                int i = 0;
                /* 234 */
                EntrustTrade entrusted = (EntrustTrade) entrustlisted.get(k);
                /* 235 */
                for (ExEntrust entrustUpdate : entrustupdatelist) {
                    /* 236 */
                    if (entrusted.getEntrustNum().equals(entrustUpdate.getEntrustNum())) {
                        /* 237 */
                        entrustUpdate.setStatusint(entrusted.getStatus().intValue());
                        /* 238 */
                        entrustUpdate.setSurplusEntrustCountDouble(entrusted.getSurplusEntrustCount().doubleValue());
                        /* 239 */
                        entrustUpdate.setTransactionSumDouble(entrusted.getTransactionSum().doubleValue());
                        /* 240 */
                        entrustUpdate.setTransactionFeeDouble(entrusted.getTransactionFee().doubleValue());
                        /* 241 */
                        if (null == entrusted.getProcessedPrice()) {
                            /* 242 */
                            entrustUpdate.setProcessedPriceDouble(Double.valueOf("0").doubleValue());
                        /*     */
                        } else {
                            /* 244 */
                            entrustUpdate.setProcessedPriceDouble(entrusted.getProcessedPrice().doubleValue());
                        /*     */
                        }
                        /*     */
                        /* 247 */
                        entrustUpdate.setModified(new Date());
                        /* 248 */
                        i++;
                        /* 249 */
                        break;
                    /*     */
                    }
                /*     */
                }
                /* 252 */
                if (i == 0) {
                    /* 253 */
                    if (null == entrusted.getProcessedPrice()) {
                        /* 254 */
                        entrusted.setProcessedPrice(new BigDecimal("0"));
                    /*     */
                    }
                    /* 256 */
                    entrustnewlist.add(entrusted);
                /*     */
                }
                /* 258 */
                k++;
            /*     */
            }
        /*     */
        } else {
            /* 261 */
            entrustnewlist = entrustlisted;
        /*     */
        }
        /*     */
        long end1;
        /* 264 */
        if ((null != entrustupdatelist) && (entrustupdatelist.size() > 0)) {
            /* 265 */
            long start1 = System.currentTimeMillis();
            /*     */
            /* 267 */
            this.exEntrustDao.updateExEntrust(entrustupdatelist);
            /* 268 */
            end1 = System.currentTimeMillis();
        /*     */
        }
        /* 272 */
        if ((null != entrustnewlist) && (entrustnewlist.size() > 0)) {
            /* 273 */
            long start2 = System.currentTimeMillis();
            /*     */
            /* 275 */
            this.exEntrustDao.insertExEntrust(entrustnewlist);
            /* 276 */
            end2 = System.currentTimeMillis();
        /*     */
        }
    /*     */
    }
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /* 306 */
    List<ExOrderInfo> eExOrderInfolistss = new ArrayList();
    /* 307 */
    Set<String> keysTradeDealOrderInfoChange = this.redisService.noPerkeys("deal:tradeDealOrderInfoChange:");
    /* 308 */
    Iterator<String> iteratorTradeDealOrderInfoChange = keysTradeDealOrderInfoChange.iterator();
    /* 309 */
    while (iteratorTradeDealOrderInfoChange.hasNext()) {
        /* 310 */
        String keystr = (String) iteratorTradeDealOrderInfoChange.next();
        /* 311 */
        List<ExOrderInfo> accountaddSlist = JSON.parseArray(this.redisService.get(keystr), ExOrderInfo.class);
        /* 312 */
        if (null != accountaddSlist) {
            /* 313 */
            eExOrderInfolistss.addAll(accountaddSlist);
        /*     */
        }
    /*     */
    }
    /*     */
    long end3;
    /* 317 */
    if ((null != eExOrderInfolistss) && (eExOrderInfolistss.size() > 0)) {
        /* 318 */
        long start3 = System.currentTimeMillis();
        /* 319 */
        this.exOrderInfoDao.insertExorderInfos(eExOrderInfolistss);
        /* 320 */
        end3 = System.currentTimeMillis();
    /*     */
    }
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /*     */
    /* 328 */
    Iterator<String> keysTradeDealEntrustChangedelete = keysTradeDealEntrustChange.iterator();
    /* 329 */
    while (keysTradeDealEntrustChangedelete.hasNext()) {
        /* 330 */
        String keystr = (String) keysTradeDealEntrustChangedelete.next();
        /* 331 */
        this.redisService.delete(keystr);
    /*     */
    }
    /*     */
    /* 334 */
    Iterator<String> keysTradeDealOrderInfoChangedelete = keysTradeDealOrderInfoChange.iterator();
    /* 335 */
    while (keysTradeDealOrderInfoChangedelete.hasNext()) {
        /* 336 */
        String keystr = (String) keysTradeDealOrderInfoChangedelete.next();
        /* 337 */
        this.redisService.delete(keystr);
    /*     */
    }
    /*     */
    /* 340 */
    long end = System.currentTimeMillis();
    /* 341 */
    long time = end - start;
    /* 342 */
    if (time > 800L) {
        /* 343 */
        LogFactory.info("redis(委托单和成交单)入库总耗时:" + time + "ms");
    /*     */
    }
/*     */
}
Also used : ExEntrust(hry.trade.entrust.model.ExEntrust) BigDecimal(java.math.BigDecimal) ExOrderInfo(hry.trade.entrust.model.ExOrderInfo) EntrustTrade(hry.trade.redis.model.EntrustTrade)

Example 2 with ExEntrust

use of hry.trade.entrust.model.ExEntrust in project benchmark by seelunzi.

the class ExEntrustServiceImpl method getExEntrustByentrustNum.

/*     */
/*     */
public ExEntrust getExEntrustByentrustNum(String entrustNum) /*     */
{
    /* 550 */
    QueryFilter filter = new QueryFilter(ExEntrust.class);
    /* 551 */
    filter.addFilter("entrustNum=", entrustNum);
    /* 552 */
    filter.setSaasId("hurong_system");
    /* 553 */
    return (ExEntrust) get(filter);
/*     */
}
Also used : QueryFilter(hry.core.util.QueryFilter) ExEntrust(hry.trade.entrust.model.ExEntrust)

Example 3 with ExEntrust

use of hry.trade.entrust.model.ExEntrust in project benchmark by seelunzi.

the class ExEntrustServiceImpl method tradeInit.

/*     */
/*     */
/*     */
/*     */
public void tradeInit() /*     */
{
    /* 104 */
    RedisTradeService redisTradeService = (RedisTradeService) ContextUtil.getBean("redisTradeService");
    /*     */
    /* 106 */
    redisTradeService.delkeys(":buy:");
    /* 107 */
    redisTradeService.delkeys(":sell:");
    /*     */
    /*     */
    /* 110 */
    List<ExCointoCoin> listExCointoCoin = this.commonDao.getExointocoinValid();
    /* 111 */
    for (ExCointoCoin exCointoCoin : listExCointoCoin) {
        /* 112 */
        String header = getHeader(exCointoCoin.getCoinCode(), exCointoCoin.getFixPriceCoinCode());
        /*     */
        /* 114 */
        QueryFilter filterbuy = new QueryFilter(ExEntrust.class);
        /* 115 */
        filterbuy.addFilter("status<", Integer.valueOf(2));
        /* 116 */
        filterbuy.addFilter("type=", Integer.valueOf(1));
        /* 117 */
        filterbuy.addFilter("coinCode=", exCointoCoin.getCoinCode());
        /* 118 */
        filterbuy.addFilter("fixPriceCoinCode=", exCointoCoin.getFixPriceCoinCode());
        /* 119 */
        filterbuy.setOrderby("entrustPrice desc");
        /* 120 */
        List<ExEntrust> listbuy = find(filterbuy);
        /* 121 */
        List<EntrustTrade> listbuypricesame = new ArrayList();
        /* 122 */
        String buyonePricekey = header + ":" + "buyonePrice";
        /* 123 */
        if ((null != listbuy) && (listbuy.size() > 0)) {
            /* 124 */
            BigDecimal sameprice = ((ExEntrust) listbuy.get(0)).getEntrustPrice();
            /* 125 */
            EntrustTrade entrustTrade = null;
            /* 126 */
            for (ExEntrust l : listbuy) {
                /* 127 */
                String exentrust = JSON.toJSONString(l);
                /* 128 */
                entrustTrade = (EntrustTrade) JSON.parseObject(exentrust, EntrustTrade.class);
                /* 129 */
                if (l.getEntrustPrice().compareTo(sameprice) == 0) {
                    /* 130 */
                    listbuypricesame.add(entrustTrade);
                /*     */
                } else {
                    /* 132 */
                    String key = getHeader(entrustTrade) + ":buy:" + sameprice.setScale(10, 6).toString();
                    /* 133 */
                    redisTradeService.save(key, JSON.toJSONString(listbuypricesame));
                    /* 134 */
                    listbuypricesame = new ArrayList();
                    /* 135 */
                    listbuypricesame.add(entrustTrade);
                    /* 136 */
                    sameprice = l.getEntrustPrice();
                /*     */
                }
            /*     */
            }
            /* 139 */
            String key = header + ":buy:" + sameprice.setScale(10, 6).toString();
            /* 140 */
            redisTradeService.save(key, JSON.toJSONString(listbuypricesame));
            /*     */
            /*     */
            /* 143 */
            this.redisService.save(buyonePricekey, JSON.toJSONString(((ExEntrust) listbuy.get(0)).getEntrustPrice()));
        /*     */
        } else {
            /* 145 */
            this.redisService.delete(buyonePricekey);
        /*     */
        }
        /*     */
        /*     */
        /*     */
        /* 150 */
        QueryFilter filtersell = new QueryFilter(ExEntrust.class);
        /* 151 */
        filtersell.addFilter("status<", Integer.valueOf(2));
        /* 152 */
        filtersell.addFilter("type=", Integer.valueOf(2));
        /* 153 */
        filtersell.addFilter("coinCode=", exCointoCoin.getCoinCode());
        /* 154 */
        filtersell.addFilter("fixPriceCoinCode=", exCointoCoin.getFixPriceCoinCode());
        /* 155 */
        filtersell.setOrderby("entrustPrice asc");
        /* 156 */
        List<ExEntrust> listsell = find(filtersell);
        /* 157 */
        List<EntrustTrade> listsellpricesame = new ArrayList();
        /* 158 */
        String sellonePricekey = header + ":" + "sellonePrice";
        /* 159 */
        if ((null != listsell) && (listsell.size() > 0)) {
            /* 160 */
            BigDecimal sameprice = ((ExEntrust) listsell.get(0)).getEntrustPrice();
            /* 161 */
            EntrustTrade entrustTrade = null;
            /* 162 */
            for (ExEntrust l : listsell) {
                /* 163 */
                String exentrust = JSON.toJSONString(l);
                /* 164 */
                entrustTrade = (EntrustTrade) JSON.parseObject(exentrust, EntrustTrade.class);
                /* 165 */
                if (l.getEntrustPrice().compareTo(sameprice) == 0) {
                    /* 166 */
                    listsellpricesame.add(entrustTrade);
                /*     */
                } else {
                    /* 168 */
                    String key = getHeader(entrustTrade) + ":sell:" + sameprice.setScale(10, 6).toString();
                    /* 169 */
                    redisTradeService.save(key, JSON.toJSONString(listsellpricesame));
                    /* 170 */
                    listsellpricesame = new ArrayList();
                    /* 171 */
                    listsellpricesame.add(entrustTrade);
                    /* 172 */
                    sameprice = l.getEntrustPrice();
                /*     */
                }
            /*     */
            }
            /*     */
            /*     */
            /* 177 */
            String key = header + ":sell:" + sameprice.setScale(10, 6).toString();
            /* 178 */
            redisTradeService.save(key, JSON.toJSONString(listsellpricesame));
            /*     */
            /* 180 */
            this.redisService.save(sellonePricekey, JSON.toJSONString(((ExEntrust) listsell.get(0)).getEntrustPrice()));
        /*     */
        } else {
            /* 182 */
            this.redisService.delete(sellonePricekey);
        /*     */
        }
    /*     */
    }
/*     */
}
Also used : ExCointoCoin(hry.exchange.product.model.ExCointoCoin) EntrustTrade(hry.trade.redis.model.EntrustTrade) QueryFilter(hry.core.util.QueryFilter) ExEntrust(hry.trade.entrust.model.ExEntrust) RedisTradeService(hry.redis.common.utils.RedisTradeService) BigDecimal(java.math.BigDecimal)

Aggregations

ExEntrust (hry.trade.entrust.model.ExEntrust)3 QueryFilter (hry.core.util.QueryFilter)2 EntrustTrade (hry.trade.redis.model.EntrustTrade)2 BigDecimal (java.math.BigDecimal)2 ExCointoCoin (hry.exchange.product.model.ExCointoCoin)1 RedisTradeService (hry.redis.common.utils.RedisTradeService)1 ExOrderInfo (hry.trade.entrust.model.ExOrderInfo)1