CallBackController.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package com.zx.dataservice.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.jfinal.plugin.activerecord.Db;
  4. import com.jfinal.plugin.activerecord.Record;
  5. import com.zx.dataservice.utils.ZXOptions;
  6. import org.slf4j.Logger;
  7. import org.slf4j.LoggerFactory;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12. import java.util.List;
  13. @Controller
  14. @RequestMapping({"/admin/"})
  15. public class CallBackController {
  16. private static Logger LOG = LoggerFactory.getLogger(CallBackController.class);
  17. @GetMapping("/t1")
  18. @ResponseBody
  19. public String quantCallBack(String code){
  20. String url1 = "https://api.huobi.pro/market/history/kline?period=1day&size=200&symbol=btcusdt";
  21. String ur2 = "https://status.huobigroup.com/api/v2/summary.json";
  22. String url = "https://api.huobi.pro/market/history/kline?period=1day&size=200&symbol=btcusdt";
  23. String s1 = "";
  24. try {
  25. // String wssurl1 = "ws://192.168.1.101:8088/websocket/zxdata9876541+";
  26. // String wssurl1 = "ws://101.32.215.72:8080/data_server_java/websocket/zxdata9876541+";
  27. // http://qwer16888.vip/stock2coin/ws/test/start.do
  28. // String s = HttpRequest.doGet(url, "");
  29. // WsClient myClient = new WsClient(new URI(wssurl1));
  30. // myClient.connect();
  31. // 判断是否连接成功,未成功后面发送消息时会报错
  32. // while (!myClient.getReadyState().equals(WebSocket.READYSTATE.OPEN)) {
  33. // System.out.println("连接中···请稍后");
  34. // Thread.sleep(1000);
  35. // }
  36. // myClient.send("123");
  37. // System.out.println("发送成功");
  38. // new WebSocketController().sendSysMsg("zxdata987654+","sss");
  39. } catch (Exception e) {
  40. return e.toString();
  41. // e.printStackTrace();
  42. // if(e.toString().length()>500){ LOG.error(e.toString().substring(0,450)); }else { LOG.error(e.toString()); }
  43. }
  44. // Request executeRequest = new Request.Builder()
  45. // .url(url)
  46. // .addHeader("Content-Type", "application/x-www-form-urlencoded")
  47. // .build();
  48. // String str = ConnectionFactory.execute(executeRequest);
  49. return "true";
  50. }
  51. @GetMapping("/test")
  52. @ResponseBody
  53. public boolean test(String code){
  54. try {
  55. // QuantUtil quantUtil = new QuantUtil();
  56. //// System.out.println("初始化东方财富");
  57. // quantUtil.init();
  58. //// //调用登录函数
  59. // quantUtil.start();
  60. } catch (Exception e) {
  61. if(e.toString().length()>500){ LOG.error(e.toString().substring(0,450)); }else { LOG.error(e.toString()); }
  62. }
  63. return true;
  64. }
  65. @GetMapping("/updateZX")
  66. @ResponseBody
  67. public boolean updateZX(String code){
  68. try {
  69. List<Record> records = Db.use("gp").find("select config_key,config_value from sys_config ");
  70. for (Record record:records) {
  71. ZXOptions.set(record.getStr("config_key"),record.getStr("config_value"));
  72. }
  73. System.out.println(ZXOptions.get("ws.key"));
  74. } catch (Exception e) {
  75. if(e.toString().length()>500){ LOG.error(e.toString().substring(0,450)); }else { LOG.error(e.toString()); }
  76. }
  77. return true;
  78. }
  79. @GetMapping("/start")
  80. @ResponseBody
  81. public boolean start(String code){
  82. try {
  83. } catch (Exception e) {
  84. if(e.toString().length()>500){ LOG.error(e.toString().substring(0,450)); }else { LOG.error(e.toString()); }
  85. }
  86. return true;
  87. }
  88. @GetMapping("/remMap")
  89. @ResponseBody
  90. public boolean remMap2(String key){
  91. try {
  92. } catch (Exception e) {
  93. if(e.toString().length()>500){ LOG.error(e.toString().substring(0,450)); }else { LOG.error(e.toString()); }
  94. }
  95. return true;
  96. }
  97. @GetMapping("/remWSKey")
  98. @ResponseBody
  99. public boolean remWSKey(String key){
  100. try {
  101. new WebSocketController().remWSKey(key);
  102. } catch (Exception e) {
  103. if(e.toString().length()>500){ LOG.error(e.toString().substring(0,450)); }else { LOG.error(e.toString()); }
  104. }
  105. return true;
  106. }
  107. @GetMapping("/testis")
  108. @ResponseBody
  109. public boolean testis(String key){
  110. try {
  111. final String[] webArr = ZXOptions.get("ws.key").split(";");//websocket key
  112. for (int j = 0; j < webArr.length; j++) {
  113. new WebSocketController().sendSysMsg(webArr[j],key);
  114. }
  115. } catch (Exception e) {
  116. if(e.toString().length()>500){ LOG.error(e.toString().substring(0,450)); }else { LOG.error(e.toString()); }
  117. }
  118. return true;
  119. }
  120. }