631185405328fa92c1bcff9fcb3c06357100036d.svn-base 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. <link rel="stylesheet" type="text/css" href="/nwyj/page/cockpit/chartPage.css">
  24. <script type="text/javascript" src="/nwyj/page/cockpit/echarts-2.2.7/build/dist/echarts-all.js"></script>
  25. <script type="text/javascript" src="/nwyj/page/cockpit/echarts-2.2.7/build/dist/chart/line.js"></script>
  26. <script type="text/javascript" src=" /nwyj/page/cockpit/cockpit_echart.js"></script>
  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. <link rel="stylesheet" type="text/css" href="/nwyj/css/cockpit/charTitle.css">
  30. <body>
  31. <div id="title" class="jsc_chartitle"></div>
  32. <div id="container"></div>
  33. <div id="choose_content">
  34. <h2>单位:</h2>
  35. <div id="compTree" class="selectTree" selWidth="280" asyncMode="true" multiMode="true"></div></br>
  36. <h2>开始时间:</h2>
  37. <input id="startTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
  38. <h2>结束时间:</h2>
  39. <input id="dataTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
  40. <h2>间隔时间:</h2>
  41. <select id="selectList" value=""></select><br/>
  42. <h2>X轴数据(个):</h2>
  43. <input id="n" type="text">
  44. <!-- <h2 class="_center"><span class="_query_command">查询</span><span class="_query_command">刷新</span></h2> -->
  45. <h2 class="_center"><span class="_query_command">查询</span><span class="_rend_command">刷新</span></h2>
  46. </div>
  47. <script type="text/javascript">
  48. /******************************************************查询条件***********************************************************/
  49. // dept_id//user_id//user_name//dept_name
  50. var customMadeTool=["search","render","list","enlarge","resource"];//父页面显示的工具栏
  51. var urlParams=resolveUrl();//主页面传递的参数
  52. var timer=null;//定时器
  53. HTitle["fixed"]=urlParams["dept_name"];//固定显示的部门名称
  54. HTitle["change"]=urlParams["dept_name"];//查询部门的名称
  55. var text=HTitle[tState]+lossTitleTrend;
  56. var childId="'"+urlParams["dept_id"]+"'";//查询部门的ID
  57. var parentId=urlParams["parentId"];//父部门ID
  58. var startTime=defaultStartTime;//默认查询历史的初始时间
  59. var dateTime=getNowDateTime();//默认查询历史的截止时间
  60. var interval=intervalTime;//每次增加数据间隔的时间
  61. var list=intervalList;//选择间隔时间列表
  62. var n=xn;//x轴显示数据的数量
  63. var chart=null;//chart对象
  64. var categorie=[urlParams["dept_name"]];//部门名称
  65. var deptUrl=deptTreePath;
  66. var state=powerState;
  67. function init(){
  68. // 添加额外属性主要用于最初的初始节点
  69. $("#compTree").attr('params', '{"deptId":"'+urlParams["dept_id"]+'"}');
  70. // 异步加载请求地址
  71. $("#compTree").attr('url', deptUrl);
  72. $.post(deptUrl, {"id" : urlParams["dept_id"]}, function(data) {$("#compTree").data("data", data);$("#compTree").render();}, "json");
  73. //加载刷新时间
  74. loadSelect($("#selectList"),list);
  75. //绑定刷新事件
  76. $("._rend_command").on("click",rend);
  77. //绑定查询历史
  78. $("._query_command").on("click",query);
  79. }
  80. //获取所有的参数
  81. function getParam(){
  82. getTime();//获取查询时间
  83. getDepartment($("#compTree"),lossTitleTrend);;//获取查询部门
  84. interval=getInterval($("#selectList"),interval);//获取间隔时间
  85. n=getN(n);//获取x轴显示的数据数量
  86. }
  87. //刷新
  88. function rend(){
  89. //移除定时器,一面定时器中为完成的数据在加载后进行二次加载
  90. timer=removeRendChart(timer);
  91. //刷新全局参数
  92. getParam();
  93. //alert("comId="+comId+"===childId="+childId+"===dateTime="+dateTime+"===interval="+interval+"===n="+n+"===rendState="+rendState);
  94. loadChart(parentId,childId,getNowDateTime(),interval,n,5);
  95. //定时刷新数据
  96. timer=outoRendChart(timer,interval,rendChart);
  97. }
  98. /**
  99. *查询历史记录
  100. *
  101. */
  102. function query(){
  103. //移除定时器,一面定时器中为完成的数据在加载后进行二次加载
  104. timer=removeRendChart(timer);
  105. getParam();
  106. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getHistoryRecords",{startDate:startTime,endDate:dateTime,comId:parentId,typeId:"5"},function(result){
  107. console.log(JSON.stringify(result));
  108. //判断是否正确查询到数据
  109. if(result.state=="FAILURE") throw new Error("查询失败");
  110. //判断是否存在历史数据
  111. if(result.rows.length<1){
  112. alert("此区间段内尚无历史数据");
  113. loadChart(parentId,childId,getNowDateTime(),interval,n,5);
  114. return ;
  115. }
  116. var dateStr=getDateStr(result.rows);//拼接历史日期的字符串
  117. loadHistory(dateStr,5);//加载历史数据
  118. },"json");
  119. }
  120. /*
  121. *初始化加载判断
  122. */
  123. function getInitParams(){
  124. if(loadState["outageStrend"]==0){
  125. loadChart(parentId,childId,getNowDateTime(),interval,n,5);
  126. timer=outoRendChart(timer,interval,rendChart);
  127. }else{
  128. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getParentsInfo",{comId:urlParams["dept_id"],count:loadState["outageStrend"]},function(result){
  129. categorie=[];
  130. HTitle["change"]="";
  131. childId="'"+result.rows.childId.join("','")+"'";
  132. categorie=result.rows.childName;
  133. HTitle["change"]='"'+categorie.join('","')+'"';
  134. text=HTitle[tState]+lossTitleTrend;
  135. parentId=urlParams["dept_id"];
  136. //检查查询条件是否合法
  137. // alert("parentId="+parentId+"===childId="+childId+"===dateTime="+dateTime+"===interval="+interval+"===n="+n+"===rendState="+rendState);
  138. loadChart(parentId,childId,getNowDateTime(),interval,n,5);
  139. timer=outoRendChart(timer,interval,rendChart);
  140. },"json");
  141. }
  142. }
  143. //初始化
  144. $(function(){
  145. init();
  146. getInitParams();
  147. })
  148. /**
  149. *自动刷新增加数据节点
  150. *
  151. */
  152. function rendChart(){
  153. var nowTime=getNowTime();
  154. $.post("/nwyj/ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getChartInfo",{comId:parentId,childId:childId,typeId:"5",date:getNowDateTime()},function(result){
  155. var count=0;
  156. var tempArr=[];
  157. for(var item=0;item<categorie.length;item++){
  158. var temp=[count, changeQ(result[item]["ENERGY_LOSS"]),false,false];
  159. tempArr.push(temp);
  160. count++;
  161. }
  162. tempArr[0].push(nowTime);
  163. chart.addData(tempArr);
  164. },"json");
  165. }
  166. /*****************************************************************************************************************/
  167. //加载历史
  168. function loadHistory(dateStr,typeId){
  169. getParam();
  170. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getHistoryInfos",{dateStr:dateStr,childId:childId,comId:parentId,typeId:typeId},function(result){
  171. rendState=0;
  172. loadData(result);
  173. },"json");
  174. }
  175. //加载最新数据
  176. function loadChart(compId,childId,date,timeInterval,n,typeId){
  177. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getChartInfos",{comId:compId,childId:childId,typeId:typeId,date:date,timeInterval:timeInterval,n:n},function(result){
  178. loadData(result);
  179. },"json");
  180. $("#title").html(text) ;
  181. }
  182. /********************************************************************************************************************************************/
  183. function loadData(result){
  184. var leArr=[];
  185. var xArr=[];
  186. var sArr=[];
  187. var colorIndex=0;
  188. console.log("result====="+JSON.stringify(result));
  189. console.log("resultthleng====="+result.length);
  190. xArr=result["xAxisCategories"].substring(result["xAxisCategories"].indexOf("[")+1,result["xAxisCategories"].indexOf("]")).split(",");
  191. for(var item in categorie){
  192. for(var i in state){
  193. var tem=null; //{name:categorie[item]+state[i].name+"线路" ,color: '#FF3300',type: 'line',data:new Array()};
  194. tem= {name:categorie[item]+state[i].name+"线路" ,color: color[0][colorIndex],type: 'line',data:new Array()};
  195. leArr.push(tem.name);
  196. colorIndex++;
  197. for(var data=0;data<result.data.length/categorie.length;data++){
  198. tem.data.push(changeQ(result.data[parseInt(data*categorie.length)+parseInt(item)]["ENERGY_LOSS"]));
  199. }
  200. }
  201. sArr.push(tem);
  202. }
  203. var opParams={
  204. title:"",//标题
  205. unit:"单位:条",//单位
  206. leArr:leArr,//图例
  207. xArr:xArr,//x轴
  208. sArr:sArr//主数据
  209. };
  210. //alert(JSON.stringify(opParams))
  211. chart=getEchart($("#container"),getOption,opParams);
  212. $(window).resize(function(){
  213. chart.resize();
  214. });
  215. }
  216. </script>
  217. </body>
  218. </html>