ytIoT.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. var pageId = 0;
  2. var pageStroe;
  3. var last_page = function(){
  4. pageId--;
  5. if(pageId<1)
  6. pageId=5;
  7. show_page();
  8. };
  9. var next_page = function(){
  10. if($("#show_detail").val()=='false'){
  11. var e = window.event;
  12. if(e.screenX>400){
  13. pageId++;
  14. if(pageId>5)
  15. pageId=1;
  16. }else{
  17. pageId--;
  18. if(pageId<1)
  19. pageId=5;
  20. }
  21. show_page();
  22. }
  23. }
  24. var show_back = function(){
  25. if($("#show_detail").val() == 'true'){
  26. $("#show_detail").val('false');
  27. show_page();
  28. return;
  29. }else{
  30. window.location.href="main.html";
  31. }
  32. }
  33. var show_iot_data=function(){
  34. var j_body = new Object();
  35. j_body.CMD = 1;
  36. j_body.COMMID=0;
  37. j_body.BUSADD=0;
  38. j_body.VALUE=0;
  39. var json_str = 'queryJson:'+JSON.stringify(j_body);
  40. $.ajax({
  41. url:"cgi-bin/ws",
  42. data:json_str,
  43. timeout:1000,
  44. type:"POST",
  45. success:function(result){
  46. pageStroe = eval('('+result+')');
  47. show_page();
  48. }
  49. });
  50. }
  51. var init = function(){
  52. show_iot_data();
  53. setInterval(show_iot_data,5000);
  54. }
  55. var show_page = function(){
  56. $("#data_div").html('');
  57. for(var i=1;i<6;i++){
  58. if($("#pager_"+i).hasClass("current_page"))
  59. $("#pager_"+i).removeClass("current_page");
  60. }
  61. if(pageId==0){
  62. if(!($("#back_div").hasClass("hidden")))
  63. $("#back_div").addClass("hidden");
  64. for(var i=1;i<6;i++){
  65. if(!($("#pager_"+i).hasClass("hidden")))
  66. $("#pager_"+i).addClass("hidden");
  67. }
  68. show_frontpage();
  69. }else{
  70. if($("#back_div").hasClass("hidden"))
  71. $("#back_div").removeClass("hidden");
  72. for(var i=1;i<6;i++){
  73. if($("#pager_"+i).hasClass("hidden"))
  74. $("#pager_"+i).removeClass("hidden");
  75. }
  76. $("#pager_"+pageId).addClass("current_page");
  77. show_page_at(pageId);
  78. }
  79. };
  80. var show_detail_at=function(){
  81. $("#show_detail").val('true');
  82. show_page();
  83. }
  84. var show_page_at = function(page){
  85. var s_name="";
  86. var out=0;
  87. var alarm=0;
  88. var normal=100;
  89. var page_str="";
  90. if((pageStroe.RESULT != undefined)&&(pageStroe.RESULT.IOT_LIST != undefined))
  91. {
  92. var iot_list = pageStroe.RESULT.IOT_LIST;
  93. for(var i=0;i<iot_list.length;i++)
  94. {
  95. if((iot_list[i].NAME != undefined)
  96. &&(iot_list[i].ID != undefined)
  97. &&(iot_list[i].ID == page)
  98. &&(iot_list[i].COUNT != undefined)
  99. &&(iot_list[i].OUT != undefined)
  100. &&(iot_list[i].ALARM != undefined))
  101. {
  102. if(($("#show_detail").val()==true)||($("#show_detail").val()=='true')){
  103. if(iot_list[i].LIST != undefined)
  104. {
  105. page_str += "<div class='tabletitle'>"+iot_list[i].NAME+"</div>";
  106. page_str += "<div class='header_table' id='header_table'><div style='position:absolute;top:10px;left:0px;width:120px;'>监控点</div><div style='position:absolute;top:10px;left:140px;width:110px;'>数值</div><div style='position:absolute;top:10px;left:230px;width:120px;'>监控点</div><div style='position:absolute;top:10px;left:370px;width:110px;'>数值</div><div style='position:absolute;top:10px;left:460px;width:120px;'>监控点</div><div style='position:absolute;top:10px;left:600px;width:110px;'>数值</div></div>";
  107. page_str += "<div 'id='data_table_area' class='data_table_area'><table class='data_table' id='data_table' width='100%' border='0'>";
  108. var obj_list = iot_list[i].LIST;
  109. for(var j=0;j<obj_list.length;j++){
  110. if((obj_list[j].COMM != undefined)
  111. &&(obj_list[j].ADDR != undefined)
  112. &&(obj_list[j].PNO_NAME != undefined)
  113. &&(obj_list[j].STATUS != undefined)
  114. &&(obj_list[j].STATUS_ID != undefined)
  115. &&(obj_list[j].VALUE != undefined)
  116. &&(obj_list[j].TIME != undefined))
  117. {
  118. if((j%3)==0)
  119. page_str += "<tr>";
  120. page_str += "<td class='databody datatitle'>"+obj_list[j].PNO_NAME+"</td>";
  121. if(obj_list[j].ADDR<19){
  122. if(obj_list[j].VALUE==0)
  123. page_str += "<td class='databody sta_normal'>"+obj_list[j].STATUS+"</td>";
  124. else
  125. page_str += "<td class='databody sta_alarm'>"+obj_list[j].STATUS+"</td>";
  126. }else{
  127. if(obj_list[j].ADDR<22){
  128. if(obj_list[j].VALUE==0)
  129. page_str += "<td class='databody'>开</td>";
  130. else
  131. page_str += "<td class='databody'>合</td>";
  132. }else
  133. page_str += "<td class='databody'>"+obj_list[j].VALUE+"</td>";
  134. }
  135. if((j%3)==2)
  136. page_str += "</tr>";
  137. }
  138. }
  139. if((obj_list.length%3)==2)
  140. page_str += "<td></td></tr>";
  141. else if((obj_list.length%3)==1)
  142. page_str += "<td></td><td></td></tr>";
  143. page_str += "</table></div>";
  144. if(obj_list.length>0)
  145. page_str += "<div id='data_time' class='databody datatitle datatime'>更新时间:"+obj_list[0].TIME+"</div>" ;
  146. $("#data_div").html(page_str);
  147. }
  148. }else{
  149. s_name = iot_list[i].NAME;
  150. if(iot_list[i].COUNT>0){
  151. out = iot_list[i].OUT*100 / iot_list[i].COUNT;
  152. alarm = iot_list[i].ALARM*100 / iot_list[i].COUNT;
  153. normal = (iot_list[i].COUNT-iot_list[i].OUT-iot_list[i].ALARM)*100 / iot_list[i].COUNT;
  154. }
  155. $('#data_div').highcharts({
  156. chart:{
  157. type:'pie',
  158. options3d:{
  159. enabled:true,
  160. alpha:45,
  161. beta:0
  162. },
  163. backgroundColor:'rgba(0,0,0,0)',
  164. animation:false
  165. },
  166. credits:{
  167. enabled:false
  168. },
  169. exporting:{
  170. enabled:false
  171. },
  172. pane:{
  173. size:'80%'
  174. },
  175. title:{
  176. text: s_name,
  177. style:{
  178. color:'#ffffff',fontSize:'18pt',x:-30,y:30
  179. }
  180. },
  181. tooltip: {
  182. pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
  183. },
  184. legend:{
  185. itemStyle:{
  186. color:'#ffffff',fontSize:'14pt'
  187. },
  188. itemWidth:160,
  189. align:'right',
  190. verticalAlign:'top',
  191. y:50,
  192. layout:'vertical',
  193. labelFormat:'{name}: <b>{y:.1f}%</b>'
  194. },
  195. plotOptions: {
  196. pie: {
  197. events:{
  198. click:function(event){
  199. show_detail_at();
  200. }
  201. },
  202. allowPointSelect: true,
  203. cursor: 'pointer',
  204. depth: 35,
  205. dataLabels: {
  206. enabled: false,
  207. style:{
  208. color:'#ffffff',fontSize:'14pt'
  209. }
  210. },
  211. showInLegend:true
  212. },
  213. series:{animation:false}
  214. },
  215. colors:['#ffa400','#ff4646','#60ff4d'],
  216. series: [{
  217. type: 'pie',
  218. name: '占比',
  219. data: [
  220. ['离线', out],
  221. ['告警', alarm],
  222. [ '正常',normal]
  223. ],
  224. pointPlacement:'on'
  225. }]
  226. });
  227. }
  228. break;
  229. }
  230. }
  231. }
  232. }
  233. var show_frontpage = function(){
  234. var s_data_0 = new Array();
  235. var s_data_1 = new Array();
  236. var s_data_2 = new Array();
  237. var s_data_3 = new Array();
  238. var s_name = new Array();
  239. if((pageStroe.RESULT != undefined)&&(pageStroe.RESULT.IOT_LIST != undefined))
  240. {
  241. $("#locip").html(pageStroe.RESULT.LOCIP);
  242. var iot_list = pageStroe.RESULT.IOT_LIST;
  243. for(var i=0;i<iot_list.length;i++)
  244. {
  245. if((iot_list[i].NAME != undefined)
  246. &&(iot_list[i].COUNT != undefined)
  247. &&(iot_list[i].OUT != undefined)
  248. &&(iot_list[i].ALARM != undefined))
  249. {
  250. s_name.push(iot_list[i].NAME);
  251. s_data_0.push(iot_list[i].COUNT);
  252. s_data_1.push(iot_list[i].OUT);
  253. s_data_2.push(iot_list[i].ALARM);
  254. s_data_3.push(iot_list[i].COUNT-iot_list[i].OUT-iot_list[i].ALARM);
  255. }
  256. }
  257. $('#data_div').highcharts({
  258. chart:{
  259. polar:true,
  260. color:'#ffffff',
  261. backgroundColor:'rgba(0,0,0,0)',
  262. type:'line',
  263. animation:false
  264. },
  265. credits:{
  266. enabled:false
  267. },
  268. exporting:{
  269. enabled:false
  270. },
  271. plotOptions:{
  272. series:{animation:false}
  273. },
  274. colors:['#4dffff','#ffa400','#ff4646','#60ff4d'],
  275. title:{
  276. style:{
  277. color:'#ffffff',
  278. fontSize:'20pt'
  279. },
  280. text:'本地消防信息汇总',
  281. x: -80,y:30
  282. },
  283. pane:{
  284. size:'80%'
  285. },
  286. xAxis:{
  287. labels:{
  288. style:{
  289. color:'#ffffff',
  290. fontSize:'14pt'
  291. }
  292. },
  293. categories:s_name,//['火灾监控','电气火灾监控','消防水系统监控','通道监控','消防电源监控'],
  294. tickmarkPlacement:'on',
  295. lineWidth:0
  296. },
  297. yAxis:{
  298. labels:{
  299. style:{
  300. color:'#ffffff'
  301. }
  302. },
  303. gridLineInterpolation:'polygon',
  304. lineWidth:0,
  305. min:0
  306. },
  307. legend:{
  308. itemStyle:{
  309. color:'#ffffff',
  310. fontSize:'14pt'
  311. },
  312. align:'right',
  313. verticalAlign:'top',
  314. y:40,
  315. layout:'vertical'
  316. },
  317. series:[{
  318. name:'监控点总数',
  319. data:s_data_0,//[8,4,5,3,8],
  320. pointPlacement:'on'
  321. },{
  322. name:'离线数量',
  323. data:s_data_1,//[0,1,0,0,0],
  324. pointPlacement:'on'
  325. },{
  326. name:'告警数量',
  327. data:s_data_2,//[0,0,1,0,1],
  328. pointPlacement:'on'
  329. },{
  330. name:'正常数量',
  331. data:s_data_3,//[8,3,4,3,7],
  332. pointPlacement:'on'
  333. }]
  334. });
  335. }
  336. }