7611bc3630a9428aef8f073f45fc9e15e526916b.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>变电站停趋势图</title>
  5. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <script type="text/javascript" src="/nwyj/page/cockpit/context.js"></script>
  8. <!--框架必需start-->
  9. <script type="text/javascript" src="/nwyj/scripts/qui/libs/js/jquery.js"></script>
  10. <script type="text/javascript" src="/nwyj/scripts/qui/libs/js/language/cn.js"></script>
  11. <script type="text/javascript" src="/nwyj/scripts/qui/libs/js/main.js"></script>
  12. <script type="text/javascript" src="/nwyj/scripts/qui/libs/js/framework.js"></script>
  13. <link href="/nwyj/scripts/qui/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  14. <link rel="stylesheet" type="text/css" id="skin" prePath="/nwyj/scripts/qui/" scrollerY="false"/>
  15. <link rel="stylesheet" type="text/css" id="customSkin"/>
  16. <!--框架必需end-->
  17. <!--树组件start-->
  18. <link rel="stylesheet" type="text/css" href="/nwyj/scripts/qui/libs/js/tree/ztree/ztree.css" />
  19. <script type="text/javascript" src="/nwyj/scripts/qui/libs/js/tree/ztree/ztree.js"></script>
  20. <script type="text/javascript" src="/nwyj/scripts/qui/libs/js/form/selectTree.js"></script>
  21. <script type="text/javascript" src="/nwyj/scripts/qui/libs/js/form/listerTree.js"></script>
  22. <!--树组件end-->
  23. <!-- <script type="text/javascript" src="/nwyj/scripts/jquery/jquery-1.11.1.min.js"></script> -->
  24. <script type="text/javascript" src="/nwyj/scripts/highcharts/highcharts.js"></script>
  25. <script type="text/javascript" src="/nwyj/page/cockpit/chart_line_substation_trend.js"></script>
  26. <link rel="stylesheet" type="text/css" href="/nwyj/page/cockpit/chartPage.css">
  27. <script type="text/javascript" src="/nwyj/page/cockpit/laydate/laydate.js"></script>
  28. <script type="text/javascript" src="/nwyj/page/cockpit/webgis/util.js"></script>
  29. <style type="text/css">
  30. </style>
  31. </head>
  32. <body>
  33. <div id="title" style="background-color:#144E52; width:100%; height:35px; line-height:35px; color:#ffc000; text-align:center; font-weight:bold; font-size:26px; "></div>
  34. <div id="container"></div>
  35. <div id="choose_content">
  36. <h2>单位:</h2>
  37. <div id="compTree" class="selectTree" selWidth="280" asyncMode="true" multiMode="true"></div></br>
  38. <h2>电压等级:</h2>
  39. <div class="selectTree" id="levelTree" selWidth="280" multiMode="true" keepDefaultStyle="true"></div></br>
  40. <h2>状态:</h2>
  41. <ul>
  42. <li><input type="checkbox" name="state" value="PRESSURE_LOSS" data="已恢复" checked="checked">已恢复<br/></li>
  43. <li><input type="checkbox" name="state" value="NO_RECOVER" data="未恢复">未恢复<br/></li>
  44. </ul>
  45. <h2>开始时间:</h2>
  46. <input id="startTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
  47. <h2>结束时间:</h2>
  48. <input id="dataTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
  49. <h2>间隔时间:</h2>
  50. <select id="selectList" value=""></select><br/>
  51. <h2>X轴数据(个):</h2>
  52. <input id="n" type="text">
  53. <!-- <h2 class="_center"><span class="_query_command">查询</span><span class="_query_command">刷新</span></h2> -->
  54. <h2 class="_center"><span class="_query_command">查询历史</span><span class="_rend_command">实时刷新</span></h2>
  55. </div>
  56. <script type="text/javascript">
  57. var urlParams=resolveUrl();
  58. var rendState=renderState;//状态:1:刷新,0:查看历史
  59. var privence=urlParams["dept_name"];
  60. HTitle["fixed"]=urlParams["dept_name"];
  61. HTitle["change"]=urlParams["dept_name"];
  62. var text=HTitle[tState]+stationTitleTrend;
  63. var childId="'"+urlParams["dept_id"]+"'";
  64. var comId=urlParams["parentId"];
  65. var startTime=defaultStartTime;
  66. var dateTime=getNowDateTime();
  67. var interval=intervalTime;
  68. var list=intervalList
  69. var n=xn;
  70. var chart;
  71. var categorie=[urlParams["dept_name"]];
  72. var categories= [];
  73. var level=[{name:"500KV",column:"ONE"} /* ,{name:"200KV",column:"TWO"} ,{name:"110KV",column:"THREE"},{name:"35KV",column:"FORE"} */]
  74. var series= [];
  75. var state=[{name:"已恢复",column:"PRESSURE_LOSS" } ,
  76. {name:"未恢复",column:"NO_RECOVER"} ];
  77. var deptUrl=deptTreePath;
  78. var zNodes2 ={"treeNodes":substationLevel};
  79. //获取间隔时间
  80. function getInterval(){
  81. if($("#selectList").data("selectedNode")==""||$("#selectList").data("selectedNode")==undefined)return;
  82. interval=$("#selectList").data("selectedNode").value;
  83. }
  84. //x轴数据个数
  85. function getN(){
  86. n=$("#n").val()==""?n:$("#n").val();
  87. }
  88. //获取电压级别
  89. function getLevel(){
  90. if($("#levelTree").data("selectedNodes")<1)return false;
  91. level=[];
  92. $.each($("#levelTree").data("selectedNodes"),function(index,item){
  93. level.push({name:item.name,column:item.column});
  94. })
  95. return true;
  96. }
  97. //获取部门
  98. function getDepartment(){
  99. if($("#compTree").data("selectedNodes")<1)return false;
  100. HTitle["change"]="";
  101. categorie=[];
  102. childId="";
  103. comId="";
  104. $.each($("#compTree").data("selectedNodes"),function(index,item){
  105. HTitle["change"]+=',"'+item.name+'"';
  106. categorie.push(item.name);
  107. childId+="'"+item.id+"',";
  108. comId=item.parentId;
  109. })
  110. childId=childId.substring(0,childId.lastIndexOf(","));
  111. HTitle["change"]=HTitle["change"].substring(1,HTitle["change"].length);
  112. text=HTitle[tState]+stationTitleTrend;
  113. return true;
  114. }
  115. //获取时间
  116. //获取时间
  117. function getTime(){
  118. if(""!=$("#startTime").val())startTime=$("#startTime").val();
  119. dateTime=$("#dataTime").val()==""?getNowDateTime():$("#dataTime").val();
  120. }
  121. //打桩成功
  122. function getState(){
  123. //未选中复选款时退出
  124. if($("input[name=state]:checked").size()<1)return false;
  125. //选中复选框,更新恢复的状态
  126. state=[];
  127. $("input[name=state]:checked").each(function(){
  128. var temp={};
  129. temp.name=$(this).attr("data");
  130. temp.column=$(this).attr("value");
  131. state.push(temp);
  132. });
  133. return true;
  134. }
  135. function init(){
  136. loadSelect($("#selectList"),list);
  137. // 添加额外属性主要用于最初的初始节点
  138. $("#compTree").attr('params', '{"deptId":"'+urlParams["dept_id"]+'"}');
  139. // 异步加载请求地址
  140. $("#compTree").attr('url', deptUrl);
  141. $.post(deptUrl, {"id" : urlParams["dept_id"]}, function(data) {$("#compTree").data("data", data);$("#compTree").render();}, "json");
  142. $("#levelTree").data("data",zNodes2);
  143. $("#levelTree").render();
  144. $("._rend_command").on("click",rend);
  145. $("._query_command").on("click",query);
  146. }
  147. //获取所有的参数
  148. function getParam(){
  149. getState();//获取恢复状态
  150. getTime();//获取查询时间
  151. getDepartment();//获取查询部门
  152. getLevel();//获取电压
  153. getInterval();//获取间隔时间
  154. getN();
  155. categories=[];
  156. series=[]
  157. }
  158. //刷新
  159. //刷新
  160. function rend(){
  161. getParam();
  162. rendState=1;
  163. //alert("comId="+comId+"===childId="+childId+"===dateTime="+dateTime+"===interval="+interval+"===n="+n+"===rendState="+rendState);
  164. loadChart(comId,childId,getNowDateTime(),interval,n);
  165. console.log(JSON.stringify({categories:categories}));
  166. console.log("categorie_________:"+JSON.stringify({categorie:categorie}));
  167. console.log("level_________:"+JSON.stringify({level:level}));
  168. console.log("childId_________:"+childId);
  169. }
  170. // 查询
  171. function query(){
  172. getTime();//获取查询时间
  173. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getHistoryRecords",{startDate:startTime,endDate:dateTime,comId:comId,typeId:"2"},function(result){
  174. console.log(JSON.stringify(result));
  175. if(result.state=="FAILURE") throw new Error("查询失败");
  176. if(result.rows.length<1){
  177. alert("此区间段内尚无历史数据");
  178. rend();
  179. return ;
  180. }
  181. var dateStr=getDateStr(result.rows);
  182. loadHistory(dateStr);
  183. },"json");
  184. console.log(JSON.stringify({categories:categories}));
  185. console.log("categorie_________:"+JSON.stringify({categorie:categorie}));
  186. console.log("level_________:"+JSON.stringify({level:level}));
  187. console.log("childId_________:"+childId);
  188. }
  189. function getDateStr(dateArr){
  190. var dateArray=[];
  191. for(var item=0 ;item<dateArr.length; item++){
  192. dateArray.push(dateArr[item]["APPEAR_TIME"])
  193. }
  194. return dateArray.join(",");
  195. }
  196. function getInitParams(){
  197. if(loadState["stationStrend"]==0){
  198. loadChart(parentId,childId,dateTime);
  199. }else{
  200. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getParentsInfo",{comId:urlParams["dept_id"],count:loadState["stationStrend"]},function(result){
  201. categorie=[];
  202. childId="'"+result.rows.childId.join("','")+"'";
  203. categorie=result.rows.childName;
  204. HTitle["change"]='"'+categorie.join('","')+'"';
  205. text=HTitle[tState]+stationTitleTrend;
  206. comId=urlParams["dept_id"];
  207. // alert("comId="+comId+"===childId="+childId+"===dateTime="+dateTime+"===interval="+interval+"===n="+n+"===rendState="+rendState);
  208. loadChart(comId,childId,dateTime,interval,n);
  209. },"json");
  210. }
  211. }
  212. //初始化
  213. $(function(){
  214. init();
  215. getInitParams();
  216. })
  217. /****************************************************************************************************************/
  218. //加载历史
  219. function loadHistory(dateStr){
  220. getParam();
  221. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getHistoryInfos",{dateStr:dateStr,childId:childId,comId:comId,typeId:"2"},function(result){
  222. rendState=0;
  223. loadData(result);
  224. },"json");
  225. }
  226. function loadChart(compId,childId,date,timeInterval,n){
  227. categories=[];
  228. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getChartInfos",{comId:compId,childId:childId,typeId:"2",date:date,timeInterval:timeInterval,n:n},function(result){
  229. loadData(result);
  230. },"json");
  231. $("#title").html(text) ;
  232. var chart = $('#container').highcharts();
  233. }
  234. /****************************************************************************************************************************************/
  235. function loadData(result){
  236. var colorIndex=0;
  237. categories=[];
  238. series=[];
  239. console.log("result====="+JSON.stringify(result));
  240. console.log("resultthleng====="+result.length);
  241. categories=result["xAxisCategories"].substring(result["xAxisCategories"].indexOf("[")+1,result["xAxisCategories"].indexOf("]")).split(",").reverse();
  242. for(var item in categorie){
  243. for(var index in level){
  244. for(var i in state){
  245. var tem=tem= {name:categorie[item]+level[index]["name"]+state[i].name+"线路" ,color: color[0][colorIndex],type: 'line',data:new Array()};//null;
  246. /* if(state[i].column=="PRESSURE_LOSS"){
  247. tem= {name:categorie[item]+level[index]["name"]+state[i].name+"线路" ,color: color[0][colorIndex],type: 'line',data:new Array()};
  248. }else{
  249. tem= {name:categorie[item]+level[index]["name"]+state[i].name+"线路" ,color: color[0][colorIndex],type: 'line',data:new Array()};
  250. } */
  251. colorIndex++;
  252. //var tem= {name:categorie[item]+level[index]["name"]+state[i].name+"线路" ,color: '#FF3300',type: 'line',data:new Array()};
  253. for(var data=0;data<result.data.length/categorie.length;data++){
  254. if(state[i].column=="PRESSURE_LOSS"){
  255. console.log("==="+state[i].column);
  256. console.log("==="+level[index].column);
  257. console.log("==="+(state[i].column+"_"+level[index].column));
  258. console.log("==="+result.data[parseInt(data*categorie.length)+parseInt(item)][state[i].column+"_"+level[index].column]);
  259. console.log("NO_RECOVER_"+level[index].column);
  260. console.log(JSON.stringify(result.data[parseInt(data*categorie.length)+parseInt(item)]));
  261. console.log("==="+changeQ(result.data[parseInt(data*categorie.length)+parseInt(item)]["NO_RECOVER_"+level[index].column]));
  262. tem.data.push(changeQ(result.data[parseInt(data*categorie.length)+parseInt(item)][state[i].column+"_"+level[index].column])-changeQ(result.data[parseInt(data*categorie.length)+parseInt(item)]["NO_RECOVER_"+level[index].column]));
  263. }else{
  264. console.log("=="+(state[i].column+"_"+level[index].column))
  265. tem.data.push(changeQ(result.data[parseInt(data*categorie.length)+parseInt(item)][state[i].column+"_"+level[index].column]));
  266. }
  267. }
  268. series.push(tem);
  269. }
  270. }
  271. }
  272. console.log("categories===="+JSON.stringify({categories:categories}))
  273. console.log("series===="+JSON.stringify({series:series}))
  274. var options={
  275. "title.text":"",
  276. "xAxis.categories":categories,
  277. "yAxis.title.text":"单位:(/座)",
  278. "subtitle.text":"数据来源:人工填报<br/>时间:"+getNowDateTime(),
  279. series:series
  280. }
  281. $("#container").createChart(options,null);
  282. }
  283. </script>
  284. </body>
  285. </html>