Main.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. //package com.huimv.eco.sgd;
  2. //
  3. //import cn.hutool.core.util.ObjectUtil;
  4. //import cn.hutool.json.JSONUtil;
  5. //import com.huimv.eco.sgd.entity.Item;
  6. //import com.huimv.eco.sgd.entity.Monitory;
  7. //import com.huimv.eco.sgd.entity.MonitoryGetArgs;
  8. //import com.huimv.eco.sgd.entity.MonitoryValue;
  9. //import com.huimv.eco.sgd.fbox.ConsoleLoggerFactory;
  10. //import com.huimv.eco.sgd.fbox.ServerCaller;
  11. //import com.huimv.eco.sgd.fbox.StaticCredentialProvider;
  12. //import com.huimv.eco.sgd.fbox.TokenManager;
  13. //import com.huimv.eco.sgd.fbox.models.BoxGroup;
  14. //import com.huimv.eco.sgd.fbox.models.BoxReg;
  15. //
  16. //import javax.sound.midi.Soundbank;
  17. //import java.io.IOException;
  18. //import java.util.ArrayList;
  19. //import java.util.HashMap;
  20. //import java.util.List;
  21. //import java.util.Map;
  22. //
  23. //public class Main {
  24. //// private static final long SLEEP_TIME = 1000;
  25. //
  26. //// public static void main(String[] args) throws IOException, InterruptedException {
  27. //// ConsoleLoggerFactory loggerFactory = new ConsoleLoggerFactory();
  28. //// // 指定连接服务器的凭据参数
  29. //// TokenManager tokenManager = new TokenManager(new StaticCredentialProvider(Global.clientId, Global.clientSecret, Global.username, Global.password), Global.idServerUrl, loggerFactory);
  30. //// ServerCaller appServer = new ServerCaller(tokenManager, Global.appServerApiUrl, Global.signalrClientId, loggerFactory);
  31. //// ServerCaller apiBaseServer = new ServerCaller(tokenManager, Global.apiBaserUrl, Global.signalrClientId, loggerFactory);
  32. //// Global.appServer = appServer;
  33. //// Global.apiBaseServer = apiBaseServer;
  34. ////
  35. //// BoxGroup[] boxGroups = appServer.executeGet("api/client/box/grouped", BoxGroup[].class);
  36. //// // 返回的是 盒子分组-盒子注册项(BoxReg) 的二层结构
  37. //// List<Map> list = new ArrayList();
  38. //// for (BoxGroup group : boxGroups) {
  39. //// //盒子
  40. //// for (BoxReg boxReg : group.boxRegs) {
  41. //// if (boxReg.alias.contains("环控")){
  42. //// Monitory[] monitories = apiBaseServer.executeGet("/v2/box/" + boxReg.boxUid + "/dmon/grouped", Monitory[].class);
  43. //// //每个监控点
  44. //// List<Map> groupnames = new ArrayList();
  45. //// for (Monitory monitory : monitories) {
  46. ////// System.out.println("监控点------------->" + monitory.toString());
  47. //// List names = new ArrayList();
  48. //// for (Item item : monitory.items) {
  49. //// String name = item.name;
  50. //// if ( monitory.name.contains("每个房间") && name != null ) {
  51. //// if (name.contains("平均温度") || name.contains("湿度") ||name.contains("日用水量") ||name.contains("月用水量") ) {
  52. //// names.add(name);
  53. //// }
  54. //// }
  55. ////
  56. //// }
  57. //// Map map = new HashMap();
  58. ////
  59. //// if (ObjectUtil.isNotEmpty(names)) {
  60. //// MonitoryValue[] monitoryValues = apiBaseServer.executePost("/v2/box/" + boxReg.boxUid + "/dmon/value/get", new MonitoryGetArgs(names, null, new ArrayList()), MonitoryValue[].class);
  61. //// StringBuilder str = new StringBuilder();
  62. //// for (MonitoryValue monitoryValue : monitoryValues) {
  63. //// if (ObjectUtil.isNotEmpty(monitory)) {
  64. //// str.append(JSONUtil.toJsonStr(monitoryValue));
  65. //// }
  66. ////
  67. //// }
  68. //// map.put("monitoryValues", str);
  69. //// map.put("grpName", monitory.name);
  70. ////// map.put("names",names);
  71. //// groupnames.add(map);
  72. //// }
  73. //// }
  74. ////
  75. //// if (ObjectUtil.isNotEmpty(groupnames)){
  76. //// Map map = new HashMap();
  77. //// map.put("name",boxReg.alias);
  78. //// map.put("groupnames",groupnames);
  79. ////
  80. //// list.add(map);
  81. //// }
  82. ////
  83. //// }
  84. //// }
  85. //// }
  86. ////
  87. //// for (Map map : list) {
  88. //// System.out.println(map.get("name")+"----->"+map.get("groupnames"));
  89. //// }
  90. ////
  91. ////
  92. //// }
  93. //
  94. //
  95. //
  96. //
  97. // private static final long SLEEP_TIME = 3000;
  98. // public static void main(String[] args) {
  99. //
  100. // ConsoleLoggerFactory loggerFactory = new ConsoleLoggerFactory();
  101. //
  102. // // 指定连接服务器的凭据参数
  103. // TokenManager tokenManager = new TokenManager(new StaticCredentialProvider(Global.clientId, Global.clientSecret, Global.username, Global.password), Global.idServerUrl, loggerFactory);
  104. //
  105. // ServerCaller commServer = new ServerCaller(tokenManager, Global.commServerApiUrl, Global.signalrClientId, loggerFactory);
  106. // ServerCaller appServer = new ServerCaller(tokenManager, Global.appServerApiUrl, Global.signalrClientId, loggerFactory);
  107. // ServerCaller hdataServer = new ServerCaller(tokenManager, Global.hdataServerApiUrl, Global.signalrClientId, loggerFactory);
  108. //
  109. // Global.commServer = commServer;
  110. // Global.appServer = appServer;
  111. // Global.hdataServer = hdataServer;
  112. //
  113. // //建立signalr实例,signalr为单例模式
  114. // FBoxSignalRConnection fboxSignalR = new FBoxSignalRConnection(Global.commServerSignalRUrl, Global.signalrClientId, tokenManager, Global.proxy, loggerFactory);
  115. //
  116. // // 连接SignalR推送通道
  117. // fboxSignalR.start();
  118. //// fboxSignalR.onHubProxyCreated();
  119. // // signalr连上后,请看src/main/java/FBoxSignalRConnection.java 接受推送数据的回调类。
  120. //
  121. // System.out.println("Box list:");
  122. //// try {
  123. ////以下为调接口示例,可忽略,若使用,参数请根据文档填写自己的账号下的参数
  124. //
  125. // // 获取盒子列表接口示例,可忽略
  126. // try {
  127. // BoxGroup[] boxGroups = Global.appServer.executeGet("api/client/box/grouped", BoxGroup[].class);
  128. // // 返回的是 盒子分组-盒子注册项(BoxReg) 的二层结构
  129. //// for (BoxGroup group : boxGroups) {
  130. //// for (BoxReg boxReg : group.boxRegs) {
  131. //// System.out.printf("\t%s\t%s\t%s\n", boxReg.alias, boxReg.box.boxNo, boxReg.box.boxType);
  132. //// }
  133. //// }
  134. //// commServer.executePost("box/300220120152/dmon/start", Object.class);
  135. // for (BoxGroup boxGroup : boxGroups) {
  136. // for (BoxReg boxReg : boxGroup.boxRegs) {
  137. // commServer.executePost("box/" + boxReg.boxUid +"/dmon/start", Object.class);
  138. // Thread.sleep(1000);
  139. //
  140. // }
  141. // }
  142. // } catch (Exception e) {
  143. // e.printStackTrace();
  144. // }
  145. //// try {
  146. //// JsonObject jsonObject = commServer.executePost("dmon/222171502968050130/start", JsonObject.class);
  147. //// } catch (IOException e) {
  148. //// System.out.println("调用失败!");
  149. //// e.printStackTrace();
  150. //// }
  151. //
  152. //// try {
  153. //// commServer.executePost("box/-6025651360718913057/dmon/start", Object.class);
  154. //// } catch (Exception e) {
  155. //// System.out.println("500");
  156. //// e.printStackTrace();
  157. //// }
  158. // System.out.println("测试");
  159. //
  160. //
  161. //
  162. //
  163. // // 获取按通道的数据接口示例 (数组第1维是固定两个元素时间和值,第2维是单个通道的所有数据,第3维是请求的每个通道)
  164. //// Object[][][] result =
  165. ////// String result =
  166. //// Global.hdataServer.executePost(String.format("v2/hdata/get"),
  167. //// new GetByChannelHdataArgs(channelIds, new Date().getTime() - 7 * 86400000, new Date().getTime(), -100, 3),
  168. ////// String.class);
  169. //// Object[][][].class);
  170. ////
  171. //// System.out.println(result);
  172. ////
  173. //// SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd");
  174. ////
  175. //// for (int i = 0; i < result.length; i++) {
  176. //// Object[][] channel = result[i];
  177. //// System.out.print("Channel " + channelNames.get(i));
  178. //// for (Object[] datum : channel) {
  179. //// System.out.printf("(%s: %s)", dateFormatter.format(new Date(Math.round((double) datum[0]))), datum[1]);
  180. //// }
  181. //// System.out.println();
  182. //// }
  183. ////
  184. //// //获取按行的数据接口示例(每行固定有通道个数个数据,如果这行的时间某些通道没有值,则为null)
  185. //// ByRowHdata result2 =
  186. ////// String result2 =
  187. //// Global.hdataServer.executePost(String.format("v2/hdata/get"),
  188. //// new GetByRowHdataArgs(channelIds, new Date().getTime() - 7 * 86400000, new Date().getTime(), -100, 3),
  189. ////// String.class);
  190. //// ByRowHdata.class);
  191. ////// System.out.println(result2);
  192. ////
  193. //// for (ByRowHdataRow row : result2.rows) {
  194. //// System.out.print(dateFormatter.format(row.getTime()) + ": ");
  195. //// Object[] c = row.c;
  196. //// for (int i = 0; i < c.length; i++) {
  197. //// Object value = c[i];
  198. //// if (i == 0) {
  199. //// System.out.printf("%s", value);
  200. //// } else {
  201. //// System.out.printf(",%s", value);
  202. //// }
  203. //// }
  204. //// System.out.println();
  205. //// }
  206. //
  207. //
  208. //// } catch (IOException e) {
  209. //// e.printStackTrace();
  210. //// }
  211. ////
  212. ////
  213. //// Scanner s = new Scanner(System.in);
  214. //// s.nextLine();
  215. // }
  216. //
  217. //
  218. //}