use of hry.trade.entrust.model.ExOrderInfo in project benchmark by seelunzi.
the class ExOrderInfoServiceImpl method createExOrderInfo.
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
public ExOrderInfo createExOrderInfo(Integer type, EntrustTrade buyExEntrust, EntrustTrade sellentrust, BigDecimal tradeCount, BigDecimal tradePrice) /* */
{
/* 132 */
ExOrderInfo exOrderInfo = new ExOrderInfo();
/* 133 */
exOrderInfo.setType(type);
/* 134 */
String transactionNum = IdGenerate.transactionNum("11");
/* 135 */
exOrderInfo.setOrderNum("T" + transactionNum.substring(2, transactionNum.length()));
/* 136 */
exOrderInfo.setTransactionCount(tradeCount);
/* 137 */
exOrderInfo.setTransactionPrice(tradePrice);
/* 138 */
exOrderInfo.setTransactionSum(tradePrice.multiply(tradeCount));
/* 139 */
exOrderInfo.setTransactionTime(new Date());
/* 140 */
exOrderInfo.setOrderTimestapm(Long.valueOf(exOrderInfo.getTransactionTime().getTime()));
/* 141 */
exOrderInfo.setTransactionBuyFeeRate(buyExEntrust.getTransactionFeeRate());
/* 142 */
exOrderInfo.setTransactionSellFeeRate(sellentrust.getTransactionFeeRate());
/* 143 */
exOrderInfo.setTransactionBuyFee(exOrderInfo.getTransactionCount().multiply(exOrderInfo.getTransactionBuyFeeRate()).divide(new BigDecimal("100")));
/* 144 */
exOrderInfo.setTransactionSellFee(exOrderInfo.getTransactionSum().multiply(exOrderInfo.getTransactionSellFeeRate()).divide(new BigDecimal("100")));
/* 145 */
exOrderInfo.setBuyCustomId(buyExEntrust.getCustomerId());
/* 146 */
exOrderInfo.setSellCustomId(sellentrust.getCustomerId());
/* 147 */
exOrderInfo.setWebsite("cn");
/* 148 */
exOrderInfo.setCurrencyType("cny");
/* 149 */
exOrderInfo.setFixPriceCoinCode(buyExEntrust.getFixPriceCoinCode());
/* 150 */
exOrderInfo.setFixPriceType(buyExEntrust.getFixPriceType());
/* 151 */
exOrderInfo.setCoinCode(buyExEntrust.getCoinCode());
/* */
/* */
/* 154 */
exOrderInfo.setBuyEntrustNum(buyExEntrust.getEntrustNum());
/* 155 */
exOrderInfo.setSellEntrustNum(sellentrust.getEntrustNum());
/* */
/* 157 */
exOrderInfo.setBuyUserName(buyExEntrust.getUserName());
/* 158 */
exOrderInfo.setSellUserName(sellentrust.getUserName());
/* 159 */
exOrderInfo.setTransactionTime(new Date());
/* 160 */
exOrderInfo.setOrderTimestapm(Long.valueOf(exOrderInfo.getTransactionTime().getTime()));
/* 164 */
return exOrderInfo;
/* */
}
use of hry.trade.entrust.model.ExOrderInfo 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");
/* */
}
/* */
}
use of hry.trade.entrust.model.ExOrderInfo 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();
/* */
}
use of hry.trade.entrust.model.ExOrderInfo in project benchmark by seelunzi.
the class TradeRedis method matchOneEnd.
/* */
/* */
/* */
public static void matchOneEnd(List<Accountadd> exEntrustAccountadd, EntrustTrade exEntrust, Map<String, List<EntrustTrade>> maping, List<EntrustTrade> listed, BigDecimal matchonePrice) /* */
{
/* 199 */
aaddlists.addAll(0, exEntrustAccountadd);
/* 200 */
listed.add(exEntrust);
/* 201 */
if (!exEntrust.getStatus().equals(Integer.valueOf(2))) {
/* 202 */
putSelfEntrustTradelist(exEntrust);
/* 203 */
setSelfonePrice(exEntrust);
/* */
}
/* */
/* 206 */
RedisTradeService redisTradeService = (RedisTradeService) ContextUtil.getBean("redisTradeService");
/* 207 */
for (Entry<String, List<EntrustTrade>> entry : maping.entrySet()) {
/* 208 */
List<EntrustTrade> listing = (List) entry.getValue();
/* 209 */
if ((null == listing) || (listing.size() == 0)) {
/* 210 */
redisTradeService.delete((String) entry.getKey());
/* */
} else {
/* 212 */
redisTradeService.save((String) entry.getKey(), JSON.toJSONString(listing));
/* */
}
/* */
}
/* */
/* */
/* 217 */
MQEnter.pushDealFundMQ(aaddlists);
/* 220 */
for (EntrustTrade entrust : listed) {
/* 221 */
putEntrustByUser(entrust);
/* */
}
/* 223 */
setMatchOnePrice(matchonePrice, exEntrust);
/* 224 */
String keyFront = getHeaderFront(exEntrust);
/* 225 */
setExchangeDataCache(eoinfolists, keyFront);
/* */
/* 227 */
RedisService redisService = (RedisService) ContextUtil.getBean("redisService");
/* 228 */
redisService.save(getTradeDealEntrustChangeNum(), JSON.toJSONString(listed));
/* 229 */
redisService.save(getTradeDealOrderInfoChangeNum(), JSON.toJSONString(eoinfolists));
/* */
/* */
/* */
/* 233 */
List<ExOrderInfo> arr = new ArrayList();
/* 234 */
arr.addAll(eoinfolists);
/* 235 */
PeriodLastKLineListRunable periodLastKLineListRunable = new PeriodLastKLineListRunable(arr);
/* 236 */
ThreadPool.exe(periodLastKLineListRunable);
/* 237 */
aaddlists.clear();
/* 238 */
eoinfolists.clear();
/* */
/* 240 */
redisTradeService.save(getEntrustTimeFlag(exEntrust.getCoinCode(), exEntrust.getFixPriceCoinCode()), "1");
/* */
}
use of hry.trade.entrust.model.ExOrderInfo in project benchmark by seelunzi.
the class TradeRedis method putExOrderInfolist.
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
public static void putExOrderInfolist(List<ExOrderInfo> oinfolist) /* */
{
/* 433 */
RedisService redisService = (RedisService) ContextUtil.getBean("redisService");
/* 434 */
String v = redisService.get("exorderinfos");
/* 435 */
List<ExOrderInfo> list = JSON.parseArray(v, ExOrderInfo.class);
/* 436 */
if (null == list) {
/* 437 */
list = new ArrayList();
/* */
}
/* 439 */
for (ExOrderInfo info : oinfolist) {
/* 440 */
list.add(info);
/* */
}
/* 442 */
redisService.save("exorderinfos", JSON.toJSONString(list));
/* */
}
Aggregations