| | |
| | | boolean pm_flag = BuyAndSellUtils.isTransTime(pm_begin, pm_end); |
| | | log.info("是否在上午交易时间 = {} 是否在下午交易时间 = {}", Boolean.valueOf(am_flag), Boolean.valueOf(pm_flag)); |
| | | |
| | | // if (!am_flag && !pm_flag) { |
| | | // return ServerResponse.createByErrorMsg("下单失败,不在交易时段内"); |
| | | // } |
| | | if (!am_flag && !pm_flag) { |
| | | return ServerResponse.createByErrorMsg("下单失败,不在交易时段内"); |
| | | } |
| | | if (siteProduct.getHolidayDisplay()) { |
| | | return ServerResponse.createByErrorMsg("周末或节假日不能交易!"); |
| | | } |
| | |
| | | stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid())); |
| | | } |
| | | |
| | | if (stockListVO.getNowPrice() == null) { |
| | | stockListVO.setNowPrice("0"); |
| | | if (stockListVO.getNowPrice() == null || new BigDecimal(stockListVO.getNowPrice()).compareTo(BigDecimal.ZERO) <= 0) { |
| | | // stockListVO.setNowPrice("0"); |
| | | stockListVO.setNowPrice(String.valueOf(position.getBuyOrderIdIndex())); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | // stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid())); |
| | | nowPrice = stockListVO.getNowPrice(); |
| | | if (nowPrice == null) { |
| | | if(position.getBuyOrderIdIndex().compareTo(BigDecimal.ZERO) > 0){ |
| | | if (nowPrice == null || new BigDecimal(stockListVO.getNowPrice()).compareTo(BigDecimal.ZERO) <= 0) { |
| | | if(null != position.getBuyOrderIdIndex() && position.getBuyOrderIdIndex().compareTo(BigDecimal.ZERO) > 0){ |
| | | nowPrice = String.valueOf(position.getBuyOrderIdIndex()); |
| | | }else { |
| | | nowPrice = String.valueOf(position.getBuyOrderPrice()); |
| | |
| | | public void synchronizePrice(){ |
| | | Map<String,BigDecimal> priceMap = new HashMap<>(); |
| | | List<UserPosition> userPositions = this.userPositionMapper.synchronizePrice(); |
| | | log.info("-------------------同步收盘价,查询数据总量 {}个--------------",userPositions.size()); |
| | | int count = 0; |
| | | for (UserPosition position : userPositions) { |
| | | if(priceMap.containsKey(position.getStockGid())){ |
| | | BigDecimal newPrice = priceMap.get(position.getStockGid()); |
| | | position.setBuyOrderIdIndex(newPrice); |
| | | userPositionMapper.updateByPrimaryKey(position); |
| | | }else { |
| | | StockListVO stockListVO = new StockListVO(); |
| | | stockListVO = SinaStockApi.assembleLideStockListVO(LiDeDataUtils.getStock(position.getStockCode())); |
| | | if (ObjectUtils.isEmpty(stockListVO)) { |
| | | stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid())); |
| | | } |
| | | if(stockListVO.getNowPrice() == null){ |
| | | stockListVO.setNowPrice(String.valueOf(position.getBuyOrderPrice())); |
| | | if(stockListVO.getNowPrice() != null && new BigDecimal(stockListVO.getNowPrice()).compareTo(BigDecimal.ZERO) > 0){ |
| | | position.setBuyOrderIdIndex(new BigDecimal(stockListVO.getNowPrice())); |
| | | priceMap.put(position.getStockGid(),new BigDecimal(stockListVO.getNowPrice())); |
| | | userPositionMapper.updateByPrimaryKey(position); |
| | | } |
| | | position.setBuyOrderIdIndex(new BigDecimal(stockListVO.getNowPrice())); |
| | | priceMap.put(position.getStockGid(),new BigDecimal(stockListVO.getNowPrice())); |
| | | } |
| | | userPositionMapper.updateByPrimaryKey(position); |
| | | count++; |
| | | } |
| | | log.info("-------------------同步收盘价 {}个--------------"); |
| | | log.info("-------------------同步收盘价 {}个--------------",count); |
| | | } |
| | | } |
| | | |
| | |
| | | System.out.println("http://36.138.182.213:7001/crypto/getSinaStock?stockGid=" + stockGid); |
| | | sina_result = HttpClientRequest.doGet("http://36.138.182.213:7001/crypto/getSinaStock?stockGid=" + stockGid); |
| | | System.out.println("请求返回:"+sina_result); |
| | | // sina_result = "var hq_str_sz300270=\"中威电子,0.000,11.710,0.000,0.000,0.000,0.000,0.000,0,0.000,0,0.000,0,0.000,0,0.000,0,0.000,0,0.000,0,0.000,0,0.000,0,0.000,0,0.000,0,0.000,2025-12-03,09:10:06,00\";"; |
| | | } catch (Exception e) { |
| | | log.error("获取股票行情出错,错误信息 = {}", e); |
| | | } |
| | |
| | | } |
| | | log.info("am = {} pm = {}", Boolean.valueOf(am), Boolean.valueOf(pm)); |
| | | } |
| | | @Scheduled(cron = "0 0 18 * * ?") |
| | | @Scheduled(cron = "0 30 16 * * ?") |
| | | // @Scheduled(cron = "0 * * * * ?") |
| | | public void synchronizePrice(){ |
| | | this.userPositionService.synchronizePrice(); |
| | |
| | | stock_gid, stock_spell, buy_order_id, buy_order_time, buy_order_price, sell_order_id, |
| | | sell_order_time, sell_order_price, profit_target_price, stop_target_price, order_direction, |
| | | order_num, order_lever, order_total_price, order_fee, order_spread, order_stay_fee, |
| | | order_stay_days, profit_and_lose, all_profit_and_lose,is_lock,lock_msg,stock_plate,spread_rate_price,margin_add |
| | | order_stay_days, profit_and_lose, all_profit_and_lose,is_lock,lock_msg,stock_plate,spread_rate_price,margin_add,buy_order_id_index |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > |
| | | select |