48d8d878eb900f3cc98eadb4c11c9bb20f440174.svn-base 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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. </head>
  31. <body>
  32. <div id="title" class="jsc_chartitle"></div>
  33. <div id="container"></div>
  34. <div id="choose_content">
  35. <h2>单位:</h2>
  36. <div id="compTree" class="selectTree" selWidth="280" asyncMode="true" multiMode="true"></div>
  37. <h2>电压等级:</h2>
  38. <div class="selectTree" id="levelTree" selWidth="280" multiMode="true" keepDefaultStyle="true"></div>
  39. <h2>状态:</h2>
  40. <ul>
  41. <li><input type="checkbox" name="state" value="PLON_DAOTA" value1="PLON_BIANXING" data="已恢复" checked="checked" >已恢复<br/></li>
  42. <li><input type="checkbox" name="state" value="UNRECOVER" value1="" data="未恢复" >未恢复<br/></li>
  43. </ul>
  44. <h2>开始时间(YYYY-MM-DD hh:mm:ss):</h2>
  45. <input id="startTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
  46. <h2>结束时间(YYYY-MM-DD hh:mm:ss):</h2>
  47. <input id="dataTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
  48. <h2>间隔时间:</h2>
  49. <select id="selectList" value=""></select><br/>
  50. <h2>X轴数据(个):</h2>
  51. <input id="n" type="text">
  52. <h2 class="_center"><span class="_query_command">查询</span><span class="_rend_command">刷新</span></h2>
  53. </div>
  54. <script type="text/javascript">
  55. /******************************************************查询条件***********************************************************/
  56. // dept_id//user_id//user_name//dept_name
  57. var customMadeTool=["search","render","list","enlarge","resource"];//父页面显示的工具栏
  58. var urlParams=resolveUrl();//主页面传递的参数
  59. var timer=null;//定时器
  60. HTitle["fixed"]=urlParams["dept_name"];//固定显示的部门名称
  61. HTitle["change"]=urlParams["dept_name"];//查询部门的名称
  62. var text=HTitle[tState]+equipmentTitleTrend;
  63. var childId="'"+urlParams["dept_id"]+"'";//查询部门的ID
  64. var parentId=urlParams["parentId"];//父部门ID
  65. var startTime=defaultStartTime;//默认查询历史的初始时间
  66. var dateTime=getNowDateTime();//默认查询历史的截止时间
  67. var interval=intervalTime;//每次增加数据间隔的时间
  68. var list=intervalList;//选择间隔时间列表
  69. var n=xn;//x轴显示数据的数量
  70. var chart=null;//chart对象
  71. var categorie=[urlParams["dept_name"]];//部门名称
  72. var level=defaultEquipmentLevel;
  73. var state=equipmentState;
  74. var series= [];
  75. var deptUrl=deptTreePath;
  76. var zNodes2 ={"treeNodes":equipmentLevel};
  77. function init(){
  78. // 添加额外属性主要用于最初的初始节点
  79. $("#compTree").attr('params', '{"deptId":"'+urlParams["dept_id"]+'"}');
  80. // 异步加载请求地址
  81. $("#compTree").attr('url', deptUrl);
  82. $.post(deptUrl, {"id" : urlParams["dept_id"]}, function(data) {$("#compTree").data("data", data);$("#compTree").render();}, "json");
  83. //加载电压级别
  84. $("#levelTree").data("data",zNodes2);
  85. $("#levelTree").render();
  86. //加载刷新时间
  87. loadSelect($("#selectList"),list);
  88. //绑定刷新事件
  89. $("._rend_command").on("click",rend);
  90. //绑定查询历史
  91. $("._query_command").on("click",query);
  92. }
  93. //获取所有的参数
  94. function getParam(){
  95. state=getState(state);//获取恢复状态
  96. getTime();//获取查询时间
  97. getDepartment($("#compTree"),equipmentTitleTrend);;//获取查询部门
  98. level=getLevel($("#levelTree"),level);//获取电压
  99. interval=getInterval($("#selectList"),interval);//获取间隔时间
  100. n=getN(n);//获取x轴显示的数据数量
  101. }
  102. //刷新
  103. function rend(){
  104. //移除定时器,一面定时器中为完成的数据在加载后进行二次加载
  105. timer=removeRendChart(timer);
  106. //刷新全局参数
  107. getParam();
  108. //alert("comId="+comId+"===childId="+childId+"===dateTime="+dateTime+"===interval="+interval+"===n="+n+"===rendState="+rendState);
  109. loadChart(parentId,childId,getNowDateTime(),interval,n,3);
  110. //定时刷新数据
  111. timer=outoRendChart(timer,interval,rendChart);
  112. }
  113. /**
  114. *查询历史记录
  115. *
  116. */
  117. function query(){
  118. //移除定时器,一面定时器中为完成的数据在加载后进行二次加载
  119. timer=removeRendChart(timer);
  120. getParam();
  121. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getHistoryRecords",{startDate:startTime,endDate:dateTime,comId:parentId,typeId:"3"},function(result){
  122. console.log(JSON.stringify(result));
  123. //判断是否正确查询到数据
  124. if(result.state=="FAILURE") throw new Error("查询失败");
  125. //判断是否存在历史数据
  126. if(result.rows.length<1){
  127. alert("此区间段内尚无历史数据");
  128. loadChart(parentId,childId,getNowDateTime(),interval,n,"3");
  129. return ;
  130. }
  131. var dateStr=getDateStr(result.rows);//拼接历史日期的字符串
  132. loadHistory(dateStr,3);//加载历史数据
  133. },"json");
  134. }
  135. /*
  136. *初始化加载判断
  137. */
  138. function getInitParams(){
  139. if(loadState["equipmentStrend"]==0){
  140. loadChart(parentId,childId,getNowDateTime(),interval,n,3);
  141. timer=outoRendChart(timer,interval,rendChart);
  142. }else{
  143. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getParentsInfo",{comId:urlParams["dept_id"],count:loadState["equipmentStrend"]},function(result){
  144. categorie=[];
  145. HTitle["change"]="";
  146. childId="'"+result.rows.childId.join("','")+"'";
  147. categorie=result.rows.childName;
  148. HTitle["change"]='"'+categorie.join('","')+'"';
  149. text=HTitle[tState]+equipmentTitleTrend;
  150. parentId=urlParams["dept_id"];
  151. //检查查询条件是否合法
  152. // alert("parentId="+parentId+"===childId="+childId+"===dateTime="+dateTime+"===interval="+interval+"===n="+n+"===rendState="+rendState);
  153. loadChart(parentId,childId,getNowDateTime(),interval,n,3);
  154. timer=outoRendChart(timer,interval,rendChart);
  155. },"json");
  156. }
  157. }
  158. //初始化
  159. $(function(){
  160. init();
  161. getInitParams();
  162. })
  163. /**
  164. *自动刷新增加数据节点
  165. *
  166. */
  167. function rendChart(){
  168. var nowTime=getNowTime();
  169. $.post("/nwyj/ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getChartInfo",{comId:parentId,childId:childId,typeId:3,date:getNowDateTime()},function(result){
  170. var count=0;
  171. var tempArr=[];
  172. for(var item=0;item<categorie.length;item++){
  173. for(var index=0;index<level.length;index++){
  174. for(var i=0; i<state.length;i++){
  175. var temp=null;
  176. if(state[i].column1=="PLON_DAOTA"){
  177. if(level[index].column=="500"){
  178. temp=[count,changeQ(result[changeQ(item)]["PLON_DAOTA_500"])+
  179. changeQ(result[(item)]["PLON_BIANXING_500"])
  180. -changeQ(result[changeQ(item)]["UNRECOVER_500"]),false,false]
  181. }
  182. if(level[index].column=="200"){
  183. temp=[count,changeQ(result[changeQ(item)]["PLON_DAOTA_200"])+
  184. changeQ(result[(item)]["PLON_BIANXING_200"])
  185. -changeQ(result[changeQ(item)]["UNRECOVER_200"]),false,false]
  186. }
  187. if(level[index].column=="110"){
  188. temp=[count,changeQ(result[changeQ(item)]["PLON_DAOTA_110"])+
  189. changeQ(result[(item)]["PLON_BIANXING_110"])+
  190. changeQ(result[(item)]["DUANGAN_110"])+
  191. changeQ(result[(item)]["DAOGAN_110"])
  192. -changeQ(result[changeQ(item)]["UNRECOVER_110"]),false,false]
  193. }
  194. if(level[index].column=="35"){
  195. temp=[count,changeQ(result[changeQ(item)]["PLON_DAOTA_35"])+
  196. changeQ(result[(item)]["PLON_BIANXING_35"])+
  197. changeQ(result[(item)]["DUANGAN_35"])+
  198. changeQ(result[(item)]["DAOGAN_35"])
  199. -changeQ(result[changeQ(item)]["UNRECOVER_35"]),false,false]
  200. }
  201. if(level[index].column=="10"){
  202. temp=[count,changeQ(result[changeQ(item)]["PLON_DAOTA_10"])+
  203. changeQ(result[(item)]["PLON_BIANXING_10"])+
  204. changeQ(result[(item)]["DUANGAN_10"])+
  205. changeQ(result[(item)]["DAOGAN_10"])
  206. -changeQ(result[changeQ(item)]["UNRECOVER_10"]),false,false];
  207. }
  208. if(level[index].column=="DIYA"){
  209. temp=[count,changeQ(result[changeQ(item)]["DAUNGAN_DIYA"])+
  210. changeQ(result[(item)]["DAOGAN_DIYA"])
  211. -changeQ(result[changeQ(item)]["UNRECOVER_DIYA"]),false,false];
  212. }
  213. /* temp=[count,changeQ(result[item][state[i].column1+"_"+level[index].column])
  214. +changeQ(result[item][state[i].column2+"_"+level[index].column])
  215. -changeQ(result[item]["UNRECOVER_"+level[index].column]), false,false,nowTime]; */
  216. }else{
  217. temp=[count,changeQ(result[item][state[i].column1+"_"+level[index].column]), false, false];
  218. }
  219. tempArr.push(temp);
  220. count++;
  221. }
  222. }
  223. }
  224. tempArr[0].push(nowTime);
  225. chart.addData(tempArr);
  226. },"json");
  227. }
  228. /*****************************************************************************************************************/
  229. //加载历史
  230. function loadHistory(dateStr,typeId){
  231. getParam();
  232. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getHistoryInfos",
  233. {dateStr:dateStr,
  234. childId:childId,
  235. comId:parentId,
  236. typeId:typeId
  237. },function(result){
  238. loadData(result);
  239. },"json");
  240. }
  241. function loadChart(compId,childId,date,timeInterval,n,typeId){
  242. $.post(path+"ws/ChartDaoServiceImpl/ChartDaoServiceImpl/getChartInfos",{comId:compId,childId:childId,typeId:typeId,date:date,timeInterval:timeInterval,n:n},function(result){
  243. loadData(result);
  244. },"json");
  245. $("#title").html(text) ;
  246. };
  247. /*****************************************************************************************************************************************************/
  248. function loadData(result){
  249. //alert(JSON.stringify({result:result}));
  250. var leArr=[];
  251. var xArr=[];
  252. var sArr=[];
  253. //console.log("result====="+JSON.stringify(result));
  254. //console.log("resultthleng====="+result.length);
  255. xArr=result["xAxisCategories"].substring(result["xAxisCategories"].indexOf("[")+1,result["xAxisCategories"].indexOf("]")).split(",");
  256. for(var item in categorie){
  257. for(var index in level){
  258. for(var i in state){
  259. var tem= {name:categorie[item]+level[index]["name"]+state[i].name+"线路" ,type: 'line',data:new Array()};//null;
  260. leArr.push(tem.name);
  261. for(var data=0;data<result.data.length/categorie.length;data++){
  262. if(state[i].column1=="PLON_DAOTA"){
  263. if(level[index].column=="500"){
  264. tem.data.push({
  265. //图表数据
  266. value:changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["PLON_DAOTA_500"])
  267. +changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["PLON_BIANXING_500"])
  268. -changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["UNRECOVER_500"])});
  269. }
  270. if(level[index].column=="200"){
  271. tem.data.push({
  272. //图表数据
  273. value:changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["PLON_DAOTA_200"])+
  274. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["PLON_BIANXING_200"])
  275. -changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["UNRECOVER_200"])});
  276. }
  277. if(level[index].column=="110"){
  278. tem.data.push({
  279. //图表数据
  280. value:changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["PLON_DAOTA_110"])+
  281. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["PLON_BIANXING_110"])+
  282. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["DUANGAN_110"])+
  283. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["DAOGAN_110"])
  284. -changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["UNRECOVER_110"])});
  285. }
  286. if(level[index].column=="35"){
  287. tem.data.push({
  288. //图表数据
  289. value:changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["PLON_DAOTA_35"])+
  290. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["PLON_BIANXING_35"])+
  291. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["DUANGAN_35"])+
  292. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["DAOGAN_35"])
  293. - changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["UNRECOVER_35"])});
  294. }
  295. if(level[index].column=="10"){
  296. tem.data.push({
  297. //图表数据
  298. value:changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["PLON_DAOTA_10"])+
  299. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["PLON_BIANXING_10"])+
  300. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["DUANGAN_10"])+
  301. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["DAOGAN_10"])
  302. -changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["UNRECOVER_10"])});
  303. }
  304. if(level[index].column=="DIYA"){
  305. tem.data.push({
  306. //图表数据
  307. value:changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["DAUNGAN_DIYA"])+
  308. changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["DAOGAN_DIYA"])
  309. -changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["UNRECOVER_DIYA"])});
  310. }
  311. /* tem.data.push(changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)][state[i].column1+"_"+level[index].column])
  312. -changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["UNRECOVER_"+level[index].column])
  313. ); */
  314. }else{
  315. tem.data.push(changeQ(result.data[parseInt(data*categorie.length)+changeQ(item)]["UNRECOVER_"+level[index].column]));
  316. }
  317. }
  318. sArr.push(tem);
  319. }
  320. }
  321. }
  322. var opParams={
  323. title:"",//标题
  324. unit:"单位:条",//单位
  325. leArr:leArr,//图例
  326. xArr:xArr,//x轴
  327. sArr:sArr//主数据
  328. };
  329. //alert(JSON.stringify(opParams))
  330. chart=getEchart($("#container"),getOption,opParams);
  331. //监听窗口大小变化
  332. $(window).resize(function(){
  333. chart.resize();
  334. })
  335. }
  336. </script>
  337. </body>
  338. </html>