| | |
| | | System.out.println(simpleDateFormat.format(new Date())); |
| | | } |
| | | public Map<String, Object> bulidOne(FuturesOrder order) { |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a", Locale.ENGLISH); |
| | | simpleDateFormat.setTimeZone(TimeZone.getTimeZone("America/New_York")); |
| | | FuturesOrder order_cache = (FuturesOrder) redisHandler.get(FuturesRedisKeys.FUTURES_SUBMITTED_ORDERNO + order.getOrder_no()); |
| | | if (order_cache != null) order = order_cache; |
| | | |
| | | |
| | | Item item = this.itemService.cacheBySymbol(order.getSymbol(), false); |
| | | if (item == null) throw new BusinessException("参数错误"); |
| | | String decimals = "#."; |
| | | |
| | | |
| | | for (int i = 0; i < item.getDecimals(); i++) { |
| | | decimals = decimals + "#"; |
| | | } |
| | | |
| | | |
| | | if (item.getDecimals() == 0) { |
| | | decimals = "#"; |
| | | } |
| | | |
| | | |
| | | DecimalFormat df_symbol = new DecimalFormat(decimals); |
| | | df_symbol.setRoundingMode(RoundingMode.FLOOR);// 向下取整 |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); |
| | | DecimalFormat df = new DecimalFormat("#.##"); |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("order_no", order.getOrder_no()); |
| | | map.put("name", item.getName()); |
| | | map.put("symbol", order.getSymbol()); |
| | | map.put("open_time", simpleDateFormat.format(order.getCreate_time())); |
| | | map.put("open_time", sdf.format(order.getCreate_time())); |
| | | if (order.getClose_time() != null) { |
| | | map.put("close_time", DateUtils.format(order.getClose_time(), "yyyy-MM-dd hh:mm:ss")); |
| | | map.put("close_time", sdf.format(order.getClose_time())); |
| | | } else { |
| | | map.put("close_time", "--"); |
| | | } |
| | |
| | | map.put("state", order.getState()); |
| | | map.put("amount", order.getVolume()); |
| | | map.put("fee", order.getFee()); |
| | | |
| | | |
| | | // 收益 |
| | | if (order.getProfit() > 0) { |
| | | map.put("profit", df.format(order.getProfit())); |
| | |
| | | } |
| | | |
| | | map.put("volume", order.getVolume()); |
| | | map.put("settlement_time", simpleDateFormat.format(order.getSettlement_time()));// 交割时间 |
| | | map.put("settlement_time", sdf.format(order.getSettlement_time()));// 交割时间 |
| | | map.put("close_price", df_symbol.format(order.getClose_avg_price())); |
| | | map.put("remain_time", StringUtils.isEmptyString(order.getRemain_time()) ? "0:0:0" : order.getRemain_time()); |
| | | map.put("time_num", order.getTimeNum()); |
| | |
| | | public List<FuturesOrder> findByPartyIdAndToday(String partyId) { |
| | | return ApplicationUtil.executeSelect(FuturesOrder.class,"WHERE PARTY_ID=? AND DATEDIFF(CREATE_TIME,NOW())=0",new Object[] {partyId}); |
| | | } |
| | | |
| | | public List<FuturesOrder> findByPartyId(String partyId) { |
| | | String querySql="SELECT * FROM T_FUTURES_ORDER WHERE PARTY_ID=? "; |
| | | List<FuturesOrder> list = ApplicationUtil.executeSelect(FuturesOrder.class,"WHERE PARTY_ID=?",new Object[] {partyId}); |
| | | return list; |
| | | } |
| | | |
| | | public List<FuturesOrder> findByHourAndSate(String state, String rolename) { |
| | | String querySql="SELECT * FROM T_FUTURES_ORDER order,PAT_PARTY par WHERE TIMESTAMPDIFF(MINUTE,order.SETTLEMENT_TIME,NOW())<24*60 AND order.STATE=? AND par.UUID=order.PARTY_ID AND par.ROLENAME=?"; |