1
zj
2024-07-12 bc9801d6adf582325e8213df11f597f82deda973
src/main/java/project/admin/AdminFuturesOrderController.java
@@ -11,6 +11,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
@@ -21,9 +22,12 @@
import kernel.web.PageActionSupport;
import project.Constants;
import project.futures.AdminFuturesOrderService;
import project.futures.FuturesOrder;
import project.futures.FuturesOrderService;
import project.futures.FuturesRedisKeys;
import project.item.ItemService;
import project.item.model.Item;
import project.redis.RedisHandler;
/**
 * 交割合约单
@@ -37,6 +41,8 @@
   @Autowired
   private FuturesOrderService futuresOrderService;
   
    protected RedisHandler redisHandler;
   @Autowired
   private AdminFuturesOrderService adminFuturesOrderService;
@@ -46,7 +52,7 @@
   
   /**
    * 获取 交割合约单 列表
    *
     * <p>
    * symbol_para 币种
    * direction_para 方向
    * volume_para 下单金额
@@ -137,7 +143,7 @@
   /**
    * 获取 交割合约单 列表
    *
     * <p>
    * symbol_para 币种
    * direction_para 方向
    * volume_para 下单金额
@@ -214,7 +220,7 @@
   /**
    * ajax定时获取表
    *
     * <p>
    * symbol_para 币种
    * direction_para 方向
    * volume_para 下单金额
@@ -262,7 +268,7 @@
   /**
    * orderProfitLoss
    *
     * <p>
    * profit_loss 盈利还是亏损
    */
   @RequestMapping(action + "orderProfitLoss.action")
@@ -291,4 +297,43 @@
      return modelAndView;
   }
    /**
     * 交割合约一键场控
     * <p>
     * profit_loss 盈利还是亏损
     */
    @RequestMapping(action + "orderProfitLossList.action")
    public ModelAndView orderProfitLossList(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("redirect:/" + action + "list.action");
        String stringOrderNo = request.getParameter("orderNos");
        String action = request.getParameter("action");
        logger.info("orderNos:"+stringOrderNo.toString()+"-----action:"+action);
        String[] orderNos = stringOrderNo.split(",");
        List<String> errorList = new ArrayList<>();
        try {
            for (String orderNo : orderNos) {
                logger.info("------->"+orderNo);
                String error = this.futuresOrderService.saveOrderPorfitOrLoss(orderNo, action, this.getUsername_login());
                if (StringUtils.isNotEmpty(error)) {
                    error = "订单号:"+orderNo+",原因:"+error;
                    errorList.add(error);
                }
            }
            if(errorList.size() > 0){
                throw new BusinessException("部分订单操作失败:"+errorList.toString());
            }
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            return modelAndView;
        } catch (Throwable t) {
            logger.error("  error  ", t);
            modelAndView.addObject("error", "[ERROR]  " + t.getMessage());
            return modelAndView;
        }
        modelAndView.addObject("message", "操作成功");
        return modelAndView;
    }
}