water.js 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053
  1. //建筑下拉
  2. getNameList();
  3. function getNameList(queryParam = {}) {
  4. ajaxRequest(GET_NAME_LIST_DATA, "POST", queryParam, function(result) {
  5. let data = result.RESULT;
  6. let items = '';
  7. data.forEach(function(item, key) {
  8. items += `<option value="${item.owner_id}">${item.owner_name}</option>`
  9. })
  10. $('#building').html(items);
  11. }, function(errorMsg) {
  12. // alert("请求数据失败!");
  13. }, 2)
  14. };
  15. // 数据请求传参
  16. getListData(getSearchParamObj());
  17. function getListData(queryParam = {}) {
  18. ajaxRequest(WATER_DATA, "POST", queryParam, function(result) {
  19. if (result.totalCount != 0) {
  20. /*
  21. 主页面数据对接 start
  22. */
  23. //数据统计
  24. var data_statistics = result.RESULT[0].data_statistics;
  25. $('.total').html(data_statistics.alarm_number);
  26. $('.solved').html(data_statistics.processing_number);
  27. $('.unsolve').html(data_statistics.unprocessed_number);
  28. // 环状饼图定制 (数据统计计算)
  29. (function() {
  30. // 实例化对象
  31. var myChart = echarts.init(document.querySelector(".bar-3d .chart"));
  32. // 生成扇形的曲面参数方程,用于 series-surface.parametricEquation
  33. function getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, height) {
  34. // 计算
  35. let midRatio = (startRatio + endRatio) / 2;
  36. let startRadian = startRatio * Math.PI * 2;
  37. let endRadian = endRatio * Math.PI * 2;
  38. let midRadian = midRatio * Math.PI * 2;
  39. // 如果只有一个扇形,则不实现选中效果。
  40. if (startRatio === 0 && endRatio === 1) {
  41. isSelected = false;
  42. }
  43. // 通过扇形内径/外径的值,换算出辅助参数 k(默认值 1/3)
  44. k = typeof k !== 'undefined' ? k : 1 / 3;
  45. // 计算选中效果分别在 x 轴、y 轴方向上的位移(未选中,则位移均为 0)
  46. let offsetX = isSelected ? Math.cos(midRadian) * 0.1 : 0;
  47. let offsetY = isSelected ? Math.sin(midRadian) * 0.1 : 0;
  48. // 计算高亮效果的放大比例(未高亮,则比例为 1)
  49. let hoverRate = isHovered ? 1.05 : 1;
  50. // 返回曲面参数方程
  51. return {
  52. u: {
  53. min: -Math.PI,
  54. max: Math.PI * 3,
  55. step: Math.PI / 32
  56. },
  57. v: {
  58. min: 0,
  59. max: Math.PI * 2,
  60. step: Math.PI / 20
  61. },
  62. x: function(u, v) {
  63. if (u < startRadian) {
  64. return offsetX + Math.cos(startRadian) * (1 + Math.cos(v) * k) * hoverRate;
  65. }
  66. if (u > endRadian) {
  67. return offsetX + Math.cos(endRadian) * (1 + Math.cos(v) * k) * hoverRate;
  68. }
  69. return offsetX + Math.cos(u) * (1 + Math.cos(v) * k) * hoverRate;
  70. },
  71. y: function(u, v) {
  72. if (u < startRadian) {
  73. return offsetY + Math.sin(startRadian) * (1 + Math.cos(v) * k) * hoverRate;
  74. }
  75. if (u > endRadian) {
  76. return offsetY + Math.sin(endRadian) * (1 + Math.cos(v) * k) * hoverRate;
  77. }
  78. return offsetY + Math.sin(u) * (1 + Math.cos(v) * k) * hoverRate;
  79. },
  80. z: function(u, v) {
  81. if (u < -Math.PI * 0.5) {
  82. return Math.sin(u);
  83. }
  84. if (u > Math.PI * 2.5) {
  85. return Math.sin(u);
  86. }
  87. return Math.sin(v) > 0 ? 1 : -1;
  88. }
  89. };
  90. }
  91. // 生成模拟 3D 饼图的配置项
  92. function getPie3D(pieData, internalDiameterRatio) {
  93. let series = [];
  94. let sumValue = 0;
  95. let startValue = 0;
  96. let endValue = 0;
  97. let legendData = [];
  98. let k = typeof internalDiameterRatio !== 'undefined' ? (1 - internalDiameterRatio) / (1 + internalDiameterRatio) : 1 / 3;
  99. // 为每一个饼图数据,生成一个 series-surface 配置
  100. for (let i = 0; i < pieData.length; i++) {
  101. sumValue += pieData[i].value;
  102. let seriesItem = {
  103. name: typeof pieData[i].name === 'undefined' ? `series${i}` : pieData[i].name,
  104. type: 'surface',
  105. parametric: true,
  106. wireframe: {
  107. show: false
  108. },
  109. pieData: pieData[i],
  110. pieStatus: {
  111. selected: false,
  112. hovered: false,
  113. k: k
  114. }
  115. };
  116. if (typeof pieData[i].itemStyle != 'undefined') {
  117. let itemStyle = {};
  118. typeof pieData[i].itemStyle.color != 'undefined' ? itemStyle.color = pieData[i].itemStyle.color : null;
  119. typeof pieData[i].itemStyle.opacity != 'undefined' ? itemStyle.opacity = pieData[i].itemStyle.opacity : null;
  120. seriesItem.itemStyle = itemStyle;
  121. }
  122. series.push(seriesItem);
  123. }
  124. // 使用上一次遍历时,计算出的数据和 sumValue,调用 getParametricEquation 函数,
  125. // 向每个 series-surface 传入不同的参数方程 series-surface.parametricEquation,也就是实现每一个扇形。
  126. for (let i = 0; i < series.length; i++) {
  127. endValue = startValue + series[i].pieData.value;
  128. // console.log(series[i]);
  129. series[i].pieData.startRatio = startValue / sumValue;
  130. series[i].pieData.endRatio = endValue / sumValue;
  131. series[i].parametricEquation = getParametricEquation(series[i].pieData.startRatio, series[i].pieData.endRatio, false, false, k, series[i].pieData.value);
  132. startValue = endValue;
  133. legendData.push(series[i].name);
  134. }
  135. // 准备待返回的配置项,把准备好的 legendData、series 传入。
  136. let option = {
  137. tooltip: {
  138. backgroundColor: '#12DFE0',
  139. formatter: params => {
  140. if (params.seriesName !== 'mouseoutSeries') {
  141. // return `${params.seriesName}<br/><span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${params.color};"></span>${option.series[params.seriesIndex].pieData.value}%`;
  142. return `${params.seriesName}: ${option.series[params.seriesIndex].pieData.value}%`;
  143. }
  144. }
  145. },
  146. xAxis3D: {
  147. min: -1,
  148. max: 1
  149. },
  150. yAxis3D: {
  151. min: -1,
  152. max: 1
  153. },
  154. zAxis3D: {
  155. min: -1,
  156. max: 1
  157. },
  158. grid3D: {
  159. show: false,
  160. boxHeight: 40,
  161. top: '-10%',
  162. // bottom: '80%',
  163. // environment: '../images/3d-bg.png', //aa背景色
  164. viewControl: {
  165. distance: 170, //aa距离
  166. alpha: 21, //aa角度
  167. beta: 60, //aa角度
  168. zoomSensitivity: false //是否开启缩放和平移
  169. },
  170. },
  171. series: series
  172. };
  173. return option;
  174. }
  175. // 传入数据生成 option
  176. var option = getPie3D([{
  177. name: '已处理率',
  178. value: data_statistics.treatment_rate,
  179. itemStyle: {
  180. opacity: 0.5,
  181. color: 'rgba(0,127,244,.8)',
  182. }
  183. }, {
  184. name: '未处理率',
  185. value: data_statistics.untreated_rate,
  186. itemStyle: {
  187. opacity: 0.5,
  188. color: 'rgba(209,126,23,.8)',
  189. }
  190. }], 2);
  191. // 把配置给实例对象
  192. myChart.setOption(option);
  193. window.addEventListener("resize", function() {
  194. myChart.resize();
  195. });
  196. })();
  197. // 折线图定制 (数据离散率挖掘)
  198. (function() {
  199. let dispersion_rate = result.RESULT[0].dispersion_rate;
  200. // 结论数据渲染
  201. var items = '';
  202. var conclusion = dispersion_rate.conclusion
  203. for (x in conclusion) {
  204. xIndex = x.substr(x.length - 1, 1);
  205. items += `<p>${xIndex}、${conclusion[x]}</p>`
  206. }
  207. $('.divergence .summaryDetail').html(items);
  208. let a = [];
  209. let b = [];
  210. let c = [];
  211. let data_time = [];
  212. let hydraulic_pressure = dispersion_rate.hydraulic_pressure;
  213. hydraulic_pressure.forEach(function(item, index) {
  214. a.push(item.variance)
  215. b.push(item.standard_deviation)
  216. c.push(item.average_value)
  217. data_time.push(item.data_time)
  218. });
  219. var sortData = [{
  220. data: [a, b, c]
  221. }];
  222. var xData = function() {
  223. var data = [];
  224. for (var i = 1; i < hydraulic_pressure.length + 1; i++) {
  225. data.push(i);
  226. }
  227. return data;
  228. }();
  229. // 1. 实例化对象
  230. var myChart = echarts.init(document.querySelector(".divergence .chart"));
  231. // 2.指定配置
  232. var option = {
  233. color: [{
  234. colorStops: [{
  235. offset: 0,
  236. color: '#F9860C' // 0% 处的颜色
  237. }, {
  238. offset: 1,
  239. color: '#fff' // 100% 处的颜色
  240. }],
  241. },
  242. {
  243. colorStops: [{
  244. offset: 0,
  245. color: '#07E1F1' // 0% 处的颜色
  246. }, {
  247. offset: 1,
  248. color: '#0456CB' // 100% 处的颜色
  249. }],
  250. },
  251. {
  252. colorStops: [{
  253. offset: 0,
  254. color: '#11F90C' // 0% 处的颜色
  255. }, {
  256. offset: 1,
  257. color: '#3FC713' // 100% 处的颜色
  258. }],
  259. }
  260. ],
  261. tooltip: {
  262. trigger: "axis",
  263. textStyle: {
  264. align: 'left' //图例左对齐
  265. },
  266. backgroundColor: '#12DFE0',
  267. formatter: function(params) {
  268. var res = params[0].seriesName + ':' + params[0].value + '<br />' + params[1].seriesName + ':' + params[1].value + '<br />' + params[2].seriesName + ':' + params[2].value + '<br />时间:' + data_time[params[2].dataIndex];
  269. return res;
  270. },
  271. // formatter: '{a0}: {c0}<br />{a1}: {c1}<br />{a2}: {c2}<br />时间:' + chooseTime + ''
  272. },
  273. legend: {
  274. // 如果series 对象有name 值,则 legend可以不用写data
  275. itemGap: 20,
  276. itemHeight: 2,
  277. itemWidth: 15,
  278. icon: 'rect',
  279. textStyle: {
  280. color: "#fff"
  281. },
  282. top: "bottom",
  283. },
  284. grid: {
  285. top: "0%",
  286. left: "1%",
  287. right: "1%",
  288. bottom: "15%",
  289. show: true, // 显示边框
  290. borderWidth: '0', //去除边框
  291. containLabel: true // 包含刻度文字在内
  292. },
  293. xAxis: {
  294. type: "category",
  295. boundaryGap: false,
  296. data: xData,
  297. axisTick: {
  298. show: false // 去除刻度线
  299. },
  300. axisLabel: {
  301. color: "#AADDFF" // 文本颜色
  302. },
  303. axisLine: {
  304. lineStyle: {
  305. color: 'rgba(255,255,255,.3)'
  306. }
  307. },
  308. splitNumber: 8,
  309. splitLine: {
  310. show: false
  311. },
  312. splitArea: {
  313. show: true,
  314. areaStyle: {
  315. color: ["rgba(250,250,250,0.05)", "rgba(250,250,250,0.0)"]
  316. }
  317. }
  318. },
  319. yAxis: {
  320. // scale: true,
  321. // min: 'dataMin',
  322. type: "value",
  323. axisTick: {
  324. show: false // 去除刻度线
  325. },
  326. axisLabel: {
  327. show: false // 去除文本
  328. },
  329. axisLine: {
  330. show: false // 去除轴线
  331. },
  332. splitLine: {
  333. lineStyle: {
  334. color: "#012f4a" // 分割线颜色
  335. }
  336. }
  337. },
  338. series: [{
  339. symbol: "none",
  340. name: "方差",
  341. type: "line",
  342. data: a
  343. },
  344. {
  345. symbol: "none",
  346. name: "标准差",
  347. type: "line",
  348. data: b
  349. }, {
  350. symbol: "none",
  351. name: "平均值",
  352. type: "line",
  353. data: c
  354. }
  355. ]
  356. };
  357. myChart.setOption(option);
  358. window.addEventListener("resize", function() {
  359. myChart.resize();
  360. });
  361. })();
  362. // 渗漏隐患排查
  363. (function() {
  364. let leakage_investigation = result.RESULT[0].leakage_investigation;
  365. // 结论数据渲染
  366. var items = '';
  367. var conclusion = leakage_investigation.conclusion
  368. for (x in conclusion) {
  369. xIndex = x.substr(x.length - 1, 1);
  370. items += `<p>${xIndex}、${conclusion[x]}</p>`
  371. }
  372. $('.hiddenCheck .summaryDetail').html(items);
  373. let abnormal_pressure = [];
  374. let location_description = [];
  375. let start_pressure = [];
  376. let end_pressure = [];
  377. let data_time = [];
  378. let leakage_data = leakage_investigation.leakage_data;
  379. leakage_data.forEach(function(item, index) {
  380. //异常值
  381. abnormal_pressure.push(item.abnormal_pressure)
  382. //楼层
  383. location_description.push(item.location_description)
  384. //开始值
  385. start_pressure.push(item.start_pressure)
  386. //结束值
  387. end_pressure.push(item.end_pressure)
  388. //时间
  389. data_time.push(item.data_time)
  390. });
  391. var xData = location_description;
  392. // 基于准备好的dom,初始化echarts实例
  393. var myChart = echarts.init(document.querySelector(".bar.hiddenCheck .chart"));
  394. var option = {
  395. backgroundColor: 'transparent',
  396. color: ['rgba(0,150,255,.5)', 'rgba(255,156,0,.5)'],
  397. tooltip: {
  398. backgroundColor: '#12DFE0',
  399. //提示框组件
  400. trigger: 'axis',
  401. formatter: function(params) {
  402. var res = '位置:' + params[0].axisValue + '<br />异常水压值 :' + abnormal_pressure[params[0].dataIndex] + 'Mpa<br />时间:' + data_time[params[0].dataIndex];
  403. return res;
  404. },
  405. axisPointer: {
  406. type: 'shadow',
  407. },
  408. textStyle: {
  409. fontStyle: 'normal',
  410. fontFamily: '微软雅黑',
  411. },
  412. },
  413. grid: {
  414. left: '0',
  415. right: '0',
  416. bottom: '40',
  417. top: '0',
  418. containLabel: true,
  419. },
  420. //添加横线滚动条
  421. dataZoom: {
  422. start: 0, //默认为0
  423. end: 100 - 1500 / 12, //默认为100
  424. type: 'slider',
  425. show: xData.length > 4 ? true : false,
  426. xAxisIndex: [0],
  427. handleSize: 0, //滑动条的 左右2个滑动条的大小
  428. height: 4, //组件高度
  429. left: 20, //左边的距离
  430. right: 20, //右边的距离
  431. bottom: 20, //右边的距离
  432. handleColor: '#CBBCDB', //h滑动图标的颜色
  433. handleStyle: {
  434. borderColor: "#CBBCDB",
  435. borderWidth: "1",
  436. shadowBlur: 2,
  437. background: "#CBBCDB",
  438. shadowColor: "#CBBCDB",
  439. },
  440. textStyle: {
  441. color: "#fff"
  442. },
  443. backgroundColor: 'rgba(37, 46, 100, 0.45)', //两边未选中的滑动条区域的颜色
  444. showDataShadow: false, //是否显示数据阴影 默认auto
  445. // showDetail: false, //即拖拽时候是否显示详细数值信息 默认true
  446. filterMode: 'filter',
  447. },
  448. xAxis: [{
  449. type: 'category',
  450. // boundaryGap: true,//坐标轴两边留白
  451. data: xData,
  452. axisLabel: {
  453. interval: 0,
  454. // rotate: 340,
  455. // formatter: function(val) {
  456. // return val.split("").join("\n");
  457. // }, //横轴信息文字竖直显示
  458. textStyle: {
  459. color: '#AADDFF',
  460. fontStyle: 'normal',
  461. fontFamily: '微软雅黑',
  462. fontSize: 12,
  463. },
  464. },
  465. axisTick: {
  466. //坐标轴刻度相关设置。
  467. show: false,
  468. },
  469. axisLine: {
  470. //坐标轴轴线相关设置
  471. },
  472. splitLine: {
  473. //坐标轴在 grid 区域中的分隔线。
  474. show: false,
  475. },
  476. }, ],
  477. yAxis: [{
  478. type: 'value',
  479. axisLabel: false,
  480. axisLine: {
  481. show: false,
  482. },
  483. axisTick: {
  484. show: false,
  485. },
  486. splitLine: {
  487. show: true,
  488. lineStyle: {
  489. color: ['#204C6F'],
  490. opacity: 0.3,
  491. },
  492. },
  493. boundaryGap: ['0', '10%'],
  494. }],
  495. series: [{
  496. name: '起层',
  497. type: 'bar',
  498. data: start_pressure,
  499. barMaxWidth: '11',
  500. itemStyle: {
  501. borderColor: "#0096FF",
  502. },
  503. barGap: '50%',
  504. },
  505. {
  506. name: '始层',
  507. type: 'bar',
  508. data: end_pressure,
  509. barMaxWidth: '11',
  510. itemStyle: {
  511. borderColor: "#FF9C00",
  512. },
  513. },
  514. ],
  515. };
  516. // 使用刚指定的配置项和数据显示图表。
  517. myChart.setOption(option);
  518. window.addEventListener("resize", function() {
  519. myChart.resize();
  520. });
  521. })();
  522. // 折线图定制 (跨设备数据关联)
  523. (function() {
  524. let device_association = result.RESULT[0].device_association;
  525. // 结论数据渲染
  526. var items = '';
  527. var conclusion = device_association.conclusion
  528. for (x in conclusion) {
  529. xIndex = x.substr(x.length - 1, 1);
  530. items += `<p>${xIndex}、${conclusion[x]}</p>`
  531. }
  532. $('.device_association .summaryDetail').html(items);
  533. // 喷淋末端、消火栓与水泵启停关联
  534. let spray_end = [];
  535. let fire_hydrant = [];
  536. let pump_status = [];
  537. let data_time = [];
  538. let pump_associated_data = device_association.pump_associated_data;
  539. pump_associated_data.forEach(function(item, index) {
  540. spray_end.push(item.spray_end)
  541. fire_hydrant.push(item.fire_hydrant)
  542. pump_status.push(item.pump_status)
  543. data_time.push(item.data_time)
  544. });
  545. // 喷淋末端、消火栓屋顶水箱液位关联
  546. let spray_end2 = [];
  547. let fire_hydrant2 = [];
  548. let water_tank_level = [];
  549. let data_time2 = [];
  550. let water_associated_data = device_association.water_associated_data;
  551. water_associated_data.forEach(function(item, index) {
  552. spray_end2.push(item.spray_end)
  553. fire_hydrant2.push(item.fire_hydrant)
  554. water_tank_level.push(item.water_tank_level)
  555. data_time2.push(item.data_time)
  556. });
  557. var sortData = [{
  558. sortName: "喷淋末端、消火栓与水泵启停关联",
  559. data: [
  560. spray_end, fire_hydrant
  561. ]
  562. },
  563. {
  564. sortName: "喷淋末端、消火栓屋顶水箱液位关联",
  565. data: [
  566. spray_end2, fire_hydrant2
  567. ]
  568. }
  569. ];
  570. var xData = function() {
  571. var data = [];
  572. for (var i = 1; i < water_associated_data.length + 1; i++) {
  573. data.push(i);
  574. }
  575. return data;
  576. }();
  577. // 1. 实例化对象
  578. var myChart = echarts.init(document.querySelector(".device_association .chart"));
  579. // 2.指定配置
  580. var option = {
  581. color: ["#FF9C00", "#0096FF"], // 通过这个color修改两条线的颜色
  582. tooltip: {
  583. trigger: "axis",
  584. textStyle: {
  585. align: 'left' //图例左对齐
  586. },
  587. backgroundColor: '#12DFE0',
  588. formatter: function(params) {
  589. if ($('#active').hasClass('active')) {
  590. var res = params[0].seriesName + ':' + params[0].value + 'Mpa<br />' + params[1].seriesName + ':' + params[1].value + 'Mpa<br />水泵启动状态 :' + pump_status[params[0].dataIndex] + '<br />时间:' + data_time[params[0].dataIndex] + '';
  591. } else {
  592. var res = params[0].seriesName + ':' + params[0].value + 'Mpa<br />' + params[1].seriesName + ':' + params[1].value + 'Mpa<br /> 水箱液位 :' + water_tank_level[params[0].dataIndex] + 'm<br />时间:' + data_time2[params[0].dataIndex] + '';
  593. }
  594. return res;
  595. },
  596. },
  597. legend: {
  598. // 如果series 对象有name 值,则 legend可以不用写data
  599. itemGap: 20,
  600. itemHeight: 2,
  601. itemWidth: 15,
  602. icon: 'rect',
  603. textStyle: {
  604. color: "#fff"
  605. },
  606. top: "bottom",
  607. },
  608. grid: {
  609. top: "0%",
  610. left: "1%",
  611. right: "1%",
  612. bottom: "15%",
  613. show: true, // 显示边框
  614. borderWidth: '0', //去除边框
  615. containLabel: true // 包含刻度文字在内
  616. },
  617. xAxis: {
  618. type: "category",
  619. boundaryGap: false,
  620. data: xData,
  621. axisTick: {
  622. show: false // 去除刻度线
  623. },
  624. axisLabel: {
  625. color: "#AADDFF" // 文本颜色
  626. },
  627. axisLine: {
  628. show: false // 去除轴线
  629. }
  630. },
  631. yAxis: {
  632. type: "value",
  633. axisTick: {
  634. show: false // 去除刻度线
  635. },
  636. axisLabel: {
  637. show: false // 去除文本
  638. },
  639. axisLine: {
  640. show: false // 去除轴线
  641. },
  642. splitLine: {
  643. lineStyle: {
  644. color: "#012f4a" // 分割线颜色
  645. }
  646. }
  647. },
  648. series: [{
  649. symbol: "none",
  650. name: "喷淋末端",
  651. type: "line",
  652. smooth: true, // true 可以让我们的折线显示带有弧度
  653. areaStyle: {
  654. normal: {
  655. color: new echarts.graphic.LinearGradient(
  656. 0,
  657. 0,
  658. 0,
  659. 1, [{
  660. offset: 0,
  661. color: "rgba(255,156,0, 0.4)"
  662. },
  663. {
  664. offset: 0.8,
  665. color: "rgba(255,156,0, 0.3)"
  666. }
  667. ],
  668. false
  669. ),
  670. shadowColor: "rgba(0, 0, 0, 0.1)"
  671. }
  672. },
  673. data: sortData[0].data[0]
  674. },
  675. {
  676. symbol: "none",
  677. name: "消防栓",
  678. type: "line",
  679. smooth: true,
  680. areaStyle: {
  681. normal: {
  682. color: new echarts.graphic.LinearGradient(
  683. 0,
  684. 0,
  685. 0,
  686. 1, [{
  687. offset: 0,
  688. color: "rgba(0,150,255,0.5)"
  689. },
  690. {
  691. offset: 0.8,
  692. color: "rgba(0,150,255, 0.1)"
  693. }
  694. ],
  695. false
  696. ),
  697. shadowColor: "rgba(0, 0, 0, 0.1)"
  698. }
  699. },
  700. data: sortData[0].data[1]
  701. }
  702. ]
  703. };
  704. myChart.setOption(option);
  705. window.addEventListener("resize", function() {
  706. myChart.resize();
  707. });
  708. // 点击切换效果
  709. $(".device_association .tab-line").on("click", "a", function() {
  710. $(this).addClass('active').siblings().removeClass('active')
  711. var obj = sortData[$(this).index()];
  712. option.series[0].data = obj.data[0];
  713. option.series[1].data = obj.data[1];
  714. // 重新渲染
  715. myChart.setOption(option);
  716. });
  717. })();
  718. // 折线图定制 (数据波动关联)
  719. (function() {
  720. let data_fluctuation = result.RESULT[0].data_fluctuation;
  721. console.log('data_fluctuation')
  722. console.log(data_fluctuation)
  723. // 结论数据渲染
  724. var items = '';
  725. var conclusion = data_fluctuation.conclusion
  726. for (x in conclusion) {
  727. xIndex = x.substr(x.length - 1, 1);
  728. items += `<p>${xIndex}、${conclusion[x]}</p>`
  729. }
  730. $('.data_fluctuation .summaryDetail').html(items);
  731. let position = [];
  732. let before_fluctuation = [];
  733. let after_fluctuation = [];
  734. let data_time = [];
  735. let volatility_data = data_fluctuation.volatility_data;
  736. volatility_data.forEach(function(item, index) {
  737. //楼层
  738. position.push(item.position)
  739. //开始值
  740. before_fluctuation.push(item.before_fluctuation)
  741. //结束值
  742. after_fluctuation.push(item.after_fluctuation)
  743. //时间
  744. data_time.push(item.data_time)
  745. });
  746. // 1. 实例化对象
  747. var myChart = echarts.init(document.querySelector(".data_fluctuation .chart"));
  748. var xData = position;
  749. // 2.指定配置
  750. var option = {
  751. backgroundColor: 'transparent',
  752. color: ['rgba(0,150,255,.5)', 'rgba(255,156,0,.5)'],
  753. tooltip: {
  754. backgroundColor: '#12DFE0',
  755. //提示框组件
  756. trigger: 'axis',
  757. formatter: function(params) {
  758. var res = params[0].seriesName + ':' + params[0].value + 'Mpa<br />' + params[1].seriesName + ':' + params[1].value + 'Mpa<br />' + data_time[params[1].dataIndex];
  759. return res;
  760. },
  761. // formatter: '{a0}: {c0}<span>Mpa</span><br />{a1}: {c1}<span>Mpa</span><br />时间:' + chooseTime + '',
  762. axisPointer: {
  763. type: 'shadow',
  764. },
  765. textStyle: {
  766. fontStyle: 'normal',
  767. fontFamily: '微软雅黑',
  768. align: 'left' //图例左对齐
  769. },
  770. },
  771. grid: {
  772. left: '0',
  773. right: '0',
  774. bottom: '40',
  775. top: '0',
  776. containLabel: true,
  777. },
  778. //添加横线滚动条
  779. dataZoom: {
  780. start: 0, //默认为0
  781. end: 100 - 1500 / 8, //默认为100
  782. type: 'slider',
  783. show: xData.length > 5 ? true : false,
  784. xAxisIndex: [0],
  785. handleSize: 0, //滑动条的 左右2个滑动条的大小
  786. height: 4, //组件高度
  787. left: 20, //左边的距离
  788. right: 20, //右边的距离
  789. bottom: 20, //右边的距离
  790. handleColor: '#CBBCDB', //h滑动图标的颜色
  791. handleStyle: {
  792. borderColor: "#CBBCDB",
  793. borderWidth: "1",
  794. shadowBlur: 2,
  795. background: "#CBBCDB",
  796. shadowColor: "#CBBCDB",
  797. },
  798. textStyle: {
  799. color: "#fff"
  800. },
  801. backgroundColor: 'rgba(37, 46, 100, 0.45)', //两边未选中的滑动条区域的颜色
  802. showDataShadow: false, //是否显示数据阴影 默认auto
  803. // showDetail: false, //即拖拽时候是否显示详细数值信息 默认true
  804. filterMode: 'filter',
  805. },
  806. xAxis: [{
  807. type: 'category',
  808. // boundaryGap: true,//坐标轴两边留白
  809. data: xData,
  810. axisLabel: {
  811. interval: 0,
  812. // rotate: 340,
  813. // formatter: function(val) {
  814. // return val.split("").join("\n");
  815. // }, //横轴信息文字竖直显示
  816. textStyle: {
  817. color: '#AADDFF',
  818. fontStyle: 'normal',
  819. fontFamily: '微软雅黑',
  820. fontSize: 12,
  821. },
  822. },
  823. axisTick: {
  824. //坐标轴刻度相关设置。
  825. show: false,
  826. },
  827. axisLine: {
  828. //坐标轴轴线相关设置
  829. },
  830. splitLine: {
  831. //坐标轴在 grid 区域中的分隔线。
  832. show: false,
  833. },
  834. }, ],
  835. yAxis: [{
  836. type: 'value',
  837. axisLabel: false,
  838. axisLine: {
  839. show: false,
  840. },
  841. axisTick: {
  842. show: false,
  843. },
  844. splitLine: {
  845. show: true,
  846. lineStyle: {
  847. color: ['#204C6F'],
  848. opacity: 0.3,
  849. },
  850. },
  851. boundaryGap: ['0', '10%'],
  852. }],
  853. series: [{
  854. name: '波动前水压值',
  855. type: 'bar',
  856. data: before_fluctuation,
  857. barMaxWidth: '11',
  858. itemStyle: {
  859. borderColor: "#0096FF",
  860. },
  861. barGap: '50%',
  862. },
  863. {
  864. name: '波动后水压值',
  865. type: 'bar',
  866. data: after_fluctuation,
  867. barMaxWidth: '11',
  868. itemStyle: {
  869. borderColor: "#FF9C00",
  870. },
  871. },
  872. ],
  873. };
  874. myChart.setOption(option);
  875. window.addEventListener("resize", function() {
  876. myChart.resize();
  877. });
  878. })();
  879. /*
  880. 主页面数据对接 end
  881. */
  882. /*
  883. 导出数据对接 start
  884. */
  885. //项目情况
  886. var project_situation = result.RESULT[0].project_situation;
  887. var items = '';
  888. items = `<tr>
  889. <td>单位名称</td>
  890. <td colspan="5">${project_situation.company_name}</td>
  891. </tr>
  892. <tr>
  893. <td>进场日期</td>
  894. <td>${project_situation.entry_date} </td>
  895. <td>完工日期</td>
  896. <td>${project_situation.completion_date}</td>
  897. <td>验收日期</td>
  898. <td>${project_situation.acceptance_date}</td>
  899. </tr>`
  900. $('#project_situation').html(items);
  901. //设备清单
  902. var equipment_list = result.RESULT[0].equipment_list;
  903. var items2 = '';
  904. if (equipment_list) {
  905. equipment_list.forEach(function(item, key) {
  906. items2 += `<tr>
  907. <td>${item.device_name}</td>
  908. <td>${item.device_info}</td>
  909. <td>${item.device_code}</td>
  910. <td>${item.remarks}</td>
  911. </tr>`;
  912. })
  913. $('#equipment_list').html(items2)
  914. }
  915. //统计时段
  916. var statistical_period = result.RESULT[0].statistical_period;
  917. var items3 = '';
  918. items3 = `<div>统计起始日期:${statistical_period.start_date}</div>
  919. <div>统计截止日期:${statistical_period.closing_date}</div>
  920. <div>统计时段时长:${statistical_period.duration}</div>`;
  921. $('#statistical_period').html(items3)
  922. //数据统计计算
  923. var data_statistics = result.RESULT[0].data_statistics;
  924. var items4 = '';
  925. items4 = `<tr>
  926. <td>${data_statistics.alarm_number}</td>
  927. <td>${data_statistics.processing_number}</td>
  928. <td>${data_statistics.unprocessed_number}</td>
  929. <td>${data_statistics.treatment_rate}</td>
  930. <td>${data_statistics.untreated_rate}</td>
  931. </tr>`;
  932. $('#data_statistics').html(items4);
  933. // 数据离散率挖掘
  934. let dispersion_rate = result.RESULT[0].dispersion_rate;
  935. console.log(result.RESULT[0].dispersion_rate)
  936. // 结论数据渲染
  937. var items = '';
  938. var conclusion = dispersion_rate.conclusion
  939. for (x in conclusion) {
  940. xIndex = x.substr(x.length - 1, 1);
  941. items += `<div>${xIndex}、${conclusion[x]}</div>`
  942. }
  943. $('.exportBox .divergence .summaryDetail').html(items);
  944. // 数据离散率挖掘1
  945. (function() {
  946. let a = [];
  947. let b = [];
  948. let c = [];
  949. let data_time = [];
  950. let hydraulic_pressure = dispersion_rate.hydraulic_pressure;
  951. hydraulic_pressure.forEach(function(item, index) {
  952. a.push(item.variance)
  953. b.push(item.standard_deviation)
  954. c.push(item.average_value)
  955. data_time.push(item.data_time)
  956. });
  957. var sortData = [{
  958. data: [a, b, c]
  959. }];
  960. var xData = function() {
  961. var data = [];
  962. for (var i = 1; i < hydraulic_pressure.length + 1; i++) {
  963. data.push(i);
  964. }
  965. return data;
  966. }();
  967. // 1. 实例化对象
  968. var myChart = echarts.init(document.querySelector("#divergenceChart1"));
  969. // 2.指定配置
  970. var option = {
  971. color: [{
  972. colorStops: [{
  973. offset: 0,
  974. color: '#F9860C' // 0% 处的颜色
  975. }, {
  976. offset: 1,
  977. color: '#fff' // 100% 处的颜色
  978. }],
  979. },
  980. {
  981. colorStops: [{
  982. offset: 0,
  983. color: '#07E1F1' // 0% 处的颜色
  984. }, {
  985. offset: 1,
  986. color: '#0456CB' // 100% 处的颜色
  987. }],
  988. },
  989. {
  990. colorStops: [{
  991. offset: 0,
  992. color: '#11F90C' // 0% 处的颜色
  993. }, {
  994. offset: 1,
  995. color: '#3FC713' // 100% 处的颜色
  996. }],
  997. }
  998. ],
  999. tooltip: {
  1000. trigger: "axis",
  1001. textStyle: {
  1002. align: 'left' //图例左对齐
  1003. },
  1004. backgroundColor: '#12DFE0',
  1005. formatter: function(params) {
  1006. var res = params[0].seriesName + ':' + params[0].value + '<br />' + params[1].seriesName + ':' + params[1].value + '<br />' + params[2].seriesName + ':' + params[2].value + '<br />时间:' + data_time[params[2].dataIndex];
  1007. return res;
  1008. },
  1009. // formatter: '{a0}: {c0}<br />{a1}: {c1}<br />{a2}: {c2}<br />时间:2021年3月{b}日'
  1010. },
  1011. legend: {
  1012. // 如果series 对象有name 值,则 legend可以不用写data
  1013. itemGap: 20,
  1014. itemHeight: 2,
  1015. itemWidth: 15,
  1016. icon: 'rect',
  1017. textStyle: {
  1018. color: "#aaa"
  1019. },
  1020. top: "bottom",
  1021. },
  1022. grid: {
  1023. top: "0%",
  1024. left: "1%",
  1025. right: "1%",
  1026. bottom: "15%",
  1027. show: true, // 显示边框
  1028. borderWidth: '0', //去除边框
  1029. containLabel: true // 包含刻度文字在内
  1030. },
  1031. xAxis: {
  1032. type: "category",
  1033. boundaryGap: false,
  1034. data: xData,
  1035. axisTick: {
  1036. show: false // 去除刻度线
  1037. },
  1038. axisLabel: {
  1039. color: "#AADDFF" // 文本颜色
  1040. },
  1041. axisLine: {
  1042. lineStyle: {
  1043. color: 'rgba(255,255,255,.3)'
  1044. }
  1045. },
  1046. splitNumber: 8,
  1047. splitLine: {
  1048. show: false
  1049. },
  1050. splitArea: {
  1051. show: true,
  1052. areaStyle: {
  1053. color: ["rgba(250,250,250,0.05)", "rgba(250,250,250,0.0)"]
  1054. }
  1055. }
  1056. },
  1057. yAxis: {
  1058. splitNumber: 8,
  1059. type: "value",
  1060. axisTick: {
  1061. show: false // 去除刻度线
  1062. },
  1063. axisLabel: {
  1064. show: false // 去除文本
  1065. },
  1066. axisLine: {
  1067. show: false // 去除轴线
  1068. },
  1069. splitLine: {
  1070. lineStyle: {
  1071. color: "#aaa", // 分割线颜色
  1072. opacity: '0.1'
  1073. }
  1074. }
  1075. },
  1076. series: [{
  1077. symbol: "none",
  1078. name: "方差",
  1079. type: "line",
  1080. data: sortData[0].data[0]
  1081. },
  1082. {
  1083. symbol: "none",
  1084. name: "标准差",
  1085. type: "line",
  1086. data: sortData[0].data[1]
  1087. }, {
  1088. symbol: "none",
  1089. name: "平均值",
  1090. type: "line",
  1091. data: sortData[0].data[2]
  1092. }
  1093. ]
  1094. };
  1095. myChart.setOption(option);
  1096. //echarts赋值到src
  1097. var img1 = document.getElementById('divergenceChart1_img');
  1098. setTimeout(function() {
  1099. img1.src = myChart.getDataURL();
  1100. }, 1000)
  1101. })();
  1102. // 渗漏隐患排查
  1103. let leakage_investigation = result.RESULT[0].leakage_investigation;
  1104. // 结论数据渲染
  1105. var items = '';
  1106. var conclusion = leakage_investigation.conclusion
  1107. for (x in conclusion) {
  1108. xIndex = x.substr(x.length - 1, 1);
  1109. items += `<div>${xIndex}、${conclusion[x]}</div>`
  1110. }
  1111. $('.exportBox .hiddenCheck .summaryDetail').html(items);
  1112. // 渗漏隐患排查
  1113. (function() {
  1114. let abnormal_pressure = [];
  1115. let location_description = [];
  1116. let start_pressure = [];
  1117. let end_pressure = [];
  1118. let data_time = [];
  1119. let leakage_data = leakage_investigation.leakage_data;
  1120. leakage_data.forEach(function(item, index) {
  1121. //异常值
  1122. abnormal_pressure.push(item.abnormal_pressure)
  1123. //楼层
  1124. location_description.push(item.location_description)
  1125. //开始值
  1126. start_pressure.push(item.start_pressure)
  1127. //结束值
  1128. end_pressure.push(item.end_pressure)
  1129. //时间
  1130. data_time.push(item.data_time)
  1131. });
  1132. var xData = location_description;
  1133. // 基于准备好的dom,初始化echarts实例
  1134. var myChart = echarts.init(document.querySelector("#hiddenCheckChart1"));
  1135. var option = {
  1136. backgroundColor: 'transparent',
  1137. color: ['rgba(0,150,255,.5)', 'rgba(255,156,0,.5)'],
  1138. tooltip: {
  1139. backgroundColor: '#12DFE0',
  1140. //提示框组件
  1141. trigger: 'axis',
  1142. formatter: function(params) {
  1143. var res = '位置:' + params[0].axisValue + '<br />异常水压值 :' + abnormal_pressure[params[0].dataIndex] + 'Mpa<br />时间:' + data_time[params[0].dataIndex];
  1144. return res;
  1145. },
  1146. axisPointer: {
  1147. type: 'shadow',
  1148. },
  1149. textStyle: {
  1150. fontStyle: 'normal',
  1151. fontFamily: '微软雅黑',
  1152. },
  1153. },
  1154. grid: {
  1155. left: '0',
  1156. right: '0',
  1157. bottom: '40',
  1158. top: '0',
  1159. containLabel: true,
  1160. },
  1161. legend: {
  1162. // 如果series 对象有name 值,则 legend可以不用写data
  1163. itemGap: 20,
  1164. itemHeight: 2,
  1165. itemWidth: 15,
  1166. icon: 'rect',
  1167. textStyle: {
  1168. color: "#AAA"
  1169. },
  1170. top: "bottom",
  1171. },
  1172. xAxis: [{
  1173. type: 'category',
  1174. // boundaryGap: true,//坐标轴两边留白
  1175. data: xData,
  1176. axisLabel: {
  1177. interval: 0,
  1178. // rotate: 340,
  1179. // formatter: function(val) {
  1180. // return val.split("").join("\n");
  1181. // }, //横轴信息文字竖直显示
  1182. textStyle: {
  1183. color: '#AAA',
  1184. fontStyle: 'normal',
  1185. fontFamily: '微软雅黑',
  1186. fontSize: 12,
  1187. },
  1188. },
  1189. axisTick: {
  1190. //坐标轴刻度相关设置。
  1191. show: false,
  1192. },
  1193. axisLine: {
  1194. //坐标轴轴线相关设置
  1195. },
  1196. splitLine: {
  1197. //坐标轴在 grid 区域中的分隔线。
  1198. show: false,
  1199. },
  1200. }, ],
  1201. yAxis: [{
  1202. type: 'value',
  1203. axisLabel: false,
  1204. axisLine: {
  1205. show: false,
  1206. },
  1207. axisTick: {
  1208. show: false,
  1209. },
  1210. splitLine: {
  1211. show: true,
  1212. lineStyle: {
  1213. color: "#aaa", // 分割线颜色
  1214. opacity: '0.2'
  1215. }
  1216. },
  1217. boundaryGap: ['0', '10%'],
  1218. }],
  1219. series: [{
  1220. name: '起层',
  1221. type: 'bar',
  1222. data: start_pressure,
  1223. barMaxWidth: '11',
  1224. itemStyle: {
  1225. borderColor: "#0096FF",
  1226. },
  1227. barGap: '50%',
  1228. },
  1229. {
  1230. name: '始层',
  1231. type: 'bar',
  1232. data: end_pressure,
  1233. barMaxWidth: '11',
  1234. itemStyle: {
  1235. borderColor: "#FF9C00",
  1236. },
  1237. },
  1238. ],
  1239. };
  1240. myChart.setOption(option);
  1241. //echarts赋值到src
  1242. var img1 = document.getElementById('hiddenCheckChart1_img');
  1243. setTimeout(function() {
  1244. img1.src = myChart.getDataURL();
  1245. }, 1000)
  1246. })();
  1247. // 跨设备数据关联
  1248. let device_association = result.RESULT[0].device_association;
  1249. // 结论数据渲染
  1250. var items = '';
  1251. var conclusion = device_association.conclusion
  1252. for (x in conclusion) {
  1253. xIndex = x.substr(x.length - 1, 1);
  1254. items += `<div>${xIndex}、${conclusion[x]}</div>`
  1255. }
  1256. $('.exportBox .device_association .summaryDetail').html(items);
  1257. // 跨设备数据关联1
  1258. // 喷淋末端、消火栓与水泵启停关联
  1259. let spray_end = [];
  1260. let fire_hydrant = [];
  1261. let pump_status = [];
  1262. let data_time = [];
  1263. let pump_associated_data = device_association.pump_associated_data;
  1264. pump_associated_data.forEach(function(item, index) {
  1265. spray_end.push(item.spray_end)
  1266. fire_hydrant.push(item.fire_hydrant)
  1267. pump_status.push(item.pump_status)
  1268. data_time.push(item.data_time)
  1269. });
  1270. (function() {
  1271. var sortData = [{
  1272. sortName: "喷淋末端、消火栓与水泵启停关联",
  1273. data: [
  1274. spray_end, fire_hydrant
  1275. ]
  1276. }, ];
  1277. var xData = function() {
  1278. var data = [];
  1279. for (var i = 1; i < spray_end.length + 1; i++) {
  1280. data.push(i);
  1281. }
  1282. return data;
  1283. }();
  1284. // 1. 实例化对象
  1285. var myChart = echarts.init(document.querySelector("#deviceLinkChart1"));
  1286. // 2.指定配置
  1287. var option = {
  1288. color: ["#FF9C00", "#0096FF"], // 通过这个color修改两条线的颜色
  1289. tooltip: {
  1290. trigger: "axis",
  1291. textStyle: {
  1292. align: 'left' //图例左对齐
  1293. },
  1294. backgroundColor: '#12DFE0',
  1295. formatter: function(params) {
  1296. var res = params[0].seriesName + ':' + params[0].value + 'Mpa<br />' + params[1].seriesName + ':' + params[1].value + '<br />水泵启动状态 :' + pump_status[params[0].dataIndex] + 'Mpa<br />时间:' + data_time[params[0].dataIndex] + '';
  1297. return res;
  1298. },
  1299. },
  1300. legend: {
  1301. // 如果series 对象有name 值,则 legend可以不用写data
  1302. itemGap: 20,
  1303. itemHeight: 2,
  1304. itemWidth: 15,
  1305. icon: 'rect',
  1306. textStyle: {
  1307. color: "#aaa"
  1308. },
  1309. top: "bottom",
  1310. },
  1311. grid: {
  1312. top: "0%",
  1313. left: "1%",
  1314. right: "1%",
  1315. bottom: "15%",
  1316. show: true, // 显示边框
  1317. borderWidth: '0', //去除边框
  1318. containLabel: true // 包含刻度文字在内
  1319. },
  1320. xAxis: {
  1321. type: "category",
  1322. boundaryGap: false,
  1323. data: xData,
  1324. axisTick: {
  1325. show: false // 去除刻度线
  1326. },
  1327. axisLabel: {
  1328. color: "#AADDFF" // 文本颜色
  1329. },
  1330. axisLine: {
  1331. show: false // 去除轴线
  1332. }
  1333. },
  1334. yAxis: {
  1335. type: "value",
  1336. axisTick: {
  1337. show: false // 去除刻度线
  1338. },
  1339. axisLabel: {
  1340. show: false // 去除文本
  1341. },
  1342. axisLine: {
  1343. show: false // 去除轴线
  1344. },
  1345. splitLine: {
  1346. lineStyle: {
  1347. color: "#aaa", // 分割线颜色
  1348. opacity: '0.2'
  1349. }
  1350. }
  1351. },
  1352. series: [{
  1353. symbol: "none",
  1354. name: "喷淋末端",
  1355. type: "line",
  1356. smooth: true, // true 可以让我们的折线显示带有弧度
  1357. areaStyle: {
  1358. normal: {
  1359. color: new echarts.graphic.LinearGradient(
  1360. 0,
  1361. 0,
  1362. 0,
  1363. 1, [{
  1364. offset: 0,
  1365. color: "rgba(255,156,0, 0.4)"
  1366. },
  1367. {
  1368. offset: 0.8,
  1369. color: "rgba(255,156,0, 0.3)"
  1370. }
  1371. ],
  1372. false
  1373. ),
  1374. shadowColor: "rgba(0, 0, 0, 0.1)"
  1375. }
  1376. },
  1377. data: sortData[0].data[0]
  1378. },
  1379. {
  1380. symbol: "none",
  1381. name: "消防栓",
  1382. type: "line",
  1383. smooth: true,
  1384. areaStyle: {
  1385. normal: {
  1386. color: new echarts.graphic.LinearGradient(
  1387. 0,
  1388. 0,
  1389. 0,
  1390. 1, [{
  1391. offset: 0,
  1392. color: "rgba(0,150,255,0.5)"
  1393. },
  1394. {
  1395. offset: 0.8,
  1396. color: "rgba(0,150,255, 0.1)"
  1397. }
  1398. ],
  1399. false
  1400. ),
  1401. shadowColor: "rgba(0, 0, 0, 0.1)"
  1402. }
  1403. },
  1404. data: sortData[0].data[1]
  1405. }
  1406. ]
  1407. };
  1408. myChart.setOption(option);
  1409. var img1 = document.getElementById('deviceLinkChart1_img');
  1410. setTimeout(function() {
  1411. img1.src = myChart.getDataURL();
  1412. }, 1000)
  1413. })();
  1414. // 跨设备数据关联2
  1415. // 喷淋末端、消火栓屋顶水箱液位关联
  1416. let spray_end2 = [];
  1417. let fire_hydrant2 = [];
  1418. let data_time2 = [];
  1419. let water_tank_level = []
  1420. let water_associated_data = device_association.water_associated_data;
  1421. water_associated_data.forEach(function(item, index) {
  1422. spray_end2.push(item.spray_end)
  1423. fire_hydrant2.push(item.fire_hydrant)
  1424. data_time2.push(item.data_time)
  1425. water_tank_level.push(item.water_tank_level)
  1426. });
  1427. (function() {
  1428. var sortData = [{
  1429. sortName: "喷淋末端、消火栓屋顶水箱液位关联",
  1430. data: [
  1431. spray_end2, fire_hydrant2
  1432. ]
  1433. }];
  1434. var xData = function() {
  1435. var data = [];
  1436. for (var i = 1; i < water_associated_data.length + 1; i++) {
  1437. data.push(i);
  1438. }
  1439. return data;
  1440. }();
  1441. // 1. 实例化对象
  1442. var myChart = echarts.init(document.querySelector("#deviceLinkChart2"));
  1443. // 2.指定配置
  1444. var option = {
  1445. color: ["#FF9C00", "#0096FF"], // 通过这个color修改两条线的颜色
  1446. tooltip: {
  1447. trigger: "axis",
  1448. textStyle: {
  1449. align: 'left' //图例左对齐
  1450. },
  1451. backgroundColor: '#12DFE0',
  1452. formatter: function(params) {
  1453. var res = params[0].seriesName + ':' + params[0].value + 'Mpa<br />' + params[1].seriesName + ':' + params[1].value + 'Mpa<br /> 水箱液位 :' + water_tank_level[params[0].dataIndex] + 'm<br />时间:' + data_time[params[0].dataIndex] + '';
  1454. return res;
  1455. },
  1456. },
  1457. legend: {
  1458. // 如果series 对象有name 值,则 legend可以不用写data
  1459. itemGap: 20,
  1460. itemHeight: 2,
  1461. itemWidth: 15,
  1462. icon: 'rect',
  1463. textStyle: {
  1464. color: "#aaa"
  1465. },
  1466. top: "bottom",
  1467. },
  1468. grid: {
  1469. top: "0%",
  1470. left: "1%",
  1471. right: "1%",
  1472. bottom: "15%",
  1473. show: true, // 显示边框
  1474. borderWidth: '0', //去除边框
  1475. containLabel: true // 包含刻度文字在内
  1476. },
  1477. xAxis: {
  1478. type: "category",
  1479. boundaryGap: false,
  1480. data: xData,
  1481. axisTick: {
  1482. show: false // 去除刻度线
  1483. },
  1484. axisLabel: {
  1485. color: "#AADDFF" // 文本颜色
  1486. },
  1487. axisLine: {
  1488. show: false // 去除轴线
  1489. }
  1490. },
  1491. yAxis: {
  1492. type: "value",
  1493. axisTick: {
  1494. show: false // 去除刻度线
  1495. },
  1496. axisLabel: {
  1497. show: false // 去除文本
  1498. },
  1499. axisLine: {
  1500. show: false // 去除轴线
  1501. },
  1502. splitLine: {
  1503. lineStyle: {
  1504. color: "#aaa", // 分割线颜色
  1505. opacity: '0.2'
  1506. }
  1507. }
  1508. },
  1509. series: [{
  1510. symbol: "none",
  1511. name: "喷淋末端",
  1512. type: "line",
  1513. smooth: true, // true 可以让我们的折线显示带有弧度
  1514. areaStyle: {
  1515. normal: {
  1516. color: new echarts.graphic.LinearGradient(
  1517. 0,
  1518. 0,
  1519. 0,
  1520. 1, [{
  1521. offset: 0,
  1522. color: "rgba(255,156,0, 0.4)"
  1523. },
  1524. {
  1525. offset: 0.8,
  1526. color: "rgba(255,156,0, 0.3)"
  1527. }
  1528. ],
  1529. false
  1530. ),
  1531. shadowColor: "rgba(0, 0, 0, 0.1)"
  1532. }
  1533. },
  1534. data: sortData[0].data[0]
  1535. },
  1536. {
  1537. symbol: "none",
  1538. name: "消防栓",
  1539. type: "line",
  1540. smooth: true,
  1541. areaStyle: {
  1542. normal: {
  1543. color: new echarts.graphic.LinearGradient(
  1544. 0,
  1545. 0,
  1546. 0,
  1547. 1, [{
  1548. offset: 0,
  1549. color: "rgba(0,150,255,0.5)"
  1550. },
  1551. {
  1552. offset: 0.8,
  1553. color: "rgba(0,150,255, 0.1)"
  1554. }
  1555. ],
  1556. false
  1557. ),
  1558. shadowColor: "rgba(0, 0, 0, 0.1)"
  1559. }
  1560. },
  1561. data: sortData[0].data[1]
  1562. }
  1563. ]
  1564. };
  1565. myChart.setOption(option);
  1566. var img1 = document.getElementById('deviceLinkChart2_img');
  1567. setTimeout(function() {
  1568. img1.src = myChart.getDataURL();
  1569. }, 1000)
  1570. })();
  1571. //数据波动关联
  1572. let data_fluctuation = result.RESULT[0].data_fluctuation;
  1573. // 结论数据渲染
  1574. var items = '';
  1575. var conclusion = data_fluctuation.conclusion
  1576. for (x in conclusion) {
  1577. xIndex = x.substr(x.length - 1, 1);
  1578. items += `<div>${xIndex}、${conclusion[x]}</div>`
  1579. }
  1580. $('.exportBox .data_fluctuation .summaryDetail').html(items);
  1581. // 数据波动关联
  1582. (function() {
  1583. let position = [];
  1584. let before_fluctuation = [];
  1585. let after_fluctuation = [];
  1586. let data_time = [];
  1587. let volatility_data = data_fluctuation.volatility_data;
  1588. volatility_data.forEach(function(item, index) {
  1589. //楼层
  1590. position.push(item.position)
  1591. //开始值
  1592. before_fluctuation.push(item.before_fluctuation)
  1593. //结束值
  1594. after_fluctuation.push(item.after_fluctuation)
  1595. data_time.push(item.data_time)
  1596. });
  1597. // 1. 实例化对象
  1598. var myChart = echarts.init(document.querySelector("#dataChangeChart1"));
  1599. var xData = position;
  1600. // 2.指定配置
  1601. var option = {
  1602. backgroundColor: 'transparent',
  1603. color: ['rgba(0,150,255,.5)', 'rgba(255,156,0,.5)'],
  1604. tooltip: {
  1605. backgroundColor: '#12DFE0',
  1606. //提示框组件
  1607. trigger: 'axis',
  1608. // formatter: '{a0}: {c0}<br />{a1}: {c1}<br />时间:' + chooseTime + '',
  1609. formatter: function(params) {
  1610. var res = params[0].seriesName + ':' + params[0].value + 'Mpa<br />' + params[1].seriesName + ':' + params[1].value + 'Mpa<br />' + data_time[params[1].dataIndex];
  1611. return res;
  1612. },
  1613. axisPointer: {
  1614. type: 'shadow',
  1615. },
  1616. textStyle: {
  1617. fontStyle: 'normal',
  1618. fontFamily: '微软雅黑',
  1619. align: 'left' //图例左对齐
  1620. },
  1621. },
  1622. legend: {
  1623. // 如果series 对象有name 值,则 legend可以不用写data
  1624. itemGap: 20,
  1625. itemHeight: 2,
  1626. itemWidth: 15,
  1627. icon: 'rect',
  1628. textStyle: {
  1629. color: "#AAA"
  1630. },
  1631. top: "bottom",
  1632. },
  1633. grid: {
  1634. left: '0',
  1635. right: '0',
  1636. bottom: '40',
  1637. top: '0',
  1638. containLabel: true,
  1639. },
  1640. //添加横线滚动条
  1641. dataZoom: {
  1642. start: 0, //默认为0
  1643. end: 100 - 1500 / 1, //默认为100
  1644. type: 'slider',
  1645. show: xData.length > 10 ? true : false,
  1646. xAxisIndex: [0],
  1647. handleSize: 0, //滑动条的 左右2个滑动条的大小
  1648. height: 4, //组件高度
  1649. left: 20, //左边的距离
  1650. right: 20, //右边的距离
  1651. bottom: 20, //右边的距离
  1652. handleColor: '#CBBCDB', //h滑动图标的颜色
  1653. handleStyle: {
  1654. borderColor: "#CBBCDB",
  1655. borderWidth: "1",
  1656. shadowBlur: 2,
  1657. background: "#CBBCDB",
  1658. shadowColor: "#CBBCDB",
  1659. },
  1660. textStyle: {
  1661. color: "#fff"
  1662. },
  1663. backgroundColor: 'rgba(37, 46, 100, 0.45)', //两边未选中的滑动条区域的颜色
  1664. showDataShadow: false, //是否显示数据阴影 默认auto
  1665. // showDetail: false, //即拖拽时候是否显示详细数值信息 默认true
  1666. filterMode: 'filter',
  1667. },
  1668. xAxis: [{
  1669. type: 'category',
  1670. // boundaryGap: true,//坐标轴两边留白
  1671. data: xData,
  1672. axisLabel: {
  1673. interval: 0,
  1674. // rotate: 340,
  1675. // formatter: function(val) {
  1676. // return val.split("").join("\n");
  1677. // }, //横轴信息文字竖直显示
  1678. textStyle: {
  1679. color: '#AADDFF',
  1680. fontStyle: 'normal',
  1681. fontFamily: '微软雅黑',
  1682. fontSize: 12,
  1683. },
  1684. },
  1685. axisTick: {
  1686. //坐标轴刻度相关设置。
  1687. show: false,
  1688. },
  1689. axisLine: {
  1690. //坐标轴轴线相关设置
  1691. },
  1692. splitLine: {
  1693. //坐标轴在 grid 区域中的分隔线。
  1694. show: false,
  1695. },
  1696. }, ],
  1697. yAxis: [{
  1698. type: 'value',
  1699. axisLabel: false,
  1700. axisLine: {
  1701. show: false,
  1702. },
  1703. axisTick: {
  1704. show: false,
  1705. },
  1706. splitLine: {
  1707. show: true,
  1708. lineStyle: {
  1709. color: "#aaa", // 分割线颜色
  1710. opacity: '0.2'
  1711. },
  1712. },
  1713. boundaryGap: ['0', '10%'],
  1714. }],
  1715. series: [{
  1716. name: '波动前水压值',
  1717. type: 'bar',
  1718. data: before_fluctuation,
  1719. barMaxWidth: '11',
  1720. itemStyle: {
  1721. borderColor: "#0096FF",
  1722. },
  1723. barGap: '50%',
  1724. },
  1725. {
  1726. name: '波动后水压值',
  1727. type: 'bar',
  1728. data: after_fluctuation,
  1729. barMaxWidth: '11',
  1730. itemStyle: {
  1731. borderColor: "#FF9C00",
  1732. },
  1733. },
  1734. ],
  1735. };
  1736. myChart.setOption(option);
  1737. var img1 = document.getElementById('dataChangeChart1_img');
  1738. setTimeout(function() {
  1739. img1.src = myChart.getDataURL();
  1740. }, 1000)
  1741. })();
  1742. /*
  1743. 导出数据对接 end
  1744. */
  1745. } else {
  1746. layui.use('layer', function() {
  1747. var layer = layui.layer;
  1748. layer.alert('暂无数据', { icon: 5 }, function() {
  1749. location.reload();
  1750. });
  1751. });
  1752. }
  1753. }, function(errorMsg) {
  1754. layui.use('layer', function() {
  1755. var layer = layui.layer;
  1756. layer.alert('数据请求失败', { icon: 5 });
  1757. });
  1758. }, 1)
  1759. };
  1760. function getSearchParamObj() {
  1761. let queryParam = {};
  1762. let buildingVal = $('#building').val();
  1763. let chooseTime = $('#chooseTime').val();
  1764. queryParam.company_code = buildingVal;
  1765. queryParam.generation_time = chooseTime;
  1766. return queryParam;
  1767. };
  1768. //日期筛选
  1769. layui.use('laydate', function() {
  1770. var laydate = layui.laydate;
  1771. ///年月选择器
  1772. laydate.render({
  1773. elem: '#chooseTime',
  1774. type: 'month',
  1775. max: -30, //7天后
  1776. trigger: 'click', //呼出事件改成click
  1777. done: function(value, date, endDate) {
  1778. setTimeout(function() {
  1779. getListData(getSearchParamObj());
  1780. }, 100)
  1781. }
  1782. });
  1783. });
  1784. //建筑筛选
  1785. $("#building").change(function() {
  1786. setTimeout(function() {
  1787. getListData(getSearchParamObj());
  1788. }, 100)
  1789. });
  1790. // 打印
  1791. (function() {
  1792. $("#btnPrint").click(function() {
  1793. print_detail()
  1794. });
  1795. var print_detail = function() {
  1796. //打印前echarts图表转换成图片 start
  1797. $('#divergenceChart1_img').show()
  1798. $('#divergenceChart1').hide()
  1799. $('#hiddenCheckChart1_img').show()
  1800. $('#hiddenCheckChart1').hide()
  1801. $('#deviceLinkChart1_img,#deviceLinkChart2_img').show()
  1802. $('#deviceLinkChart1,#deviceLinkChart2').hide()
  1803. $('#dataChangeChart1_img').show()
  1804. $('#dataChangeChart1').hide()
  1805. // end
  1806. var div1_label1 = document.getElementById('printArea').innerHTML;
  1807. var hkey_key;
  1808. var hkey_root = 'HKEY_CURRENT_USER';
  1809. var hkey_path = '\\Software\\Micorsoft\\Internet Explorer\\PageSetup\\';
  1810. var print_win = window.open('打印窗口', '_blank');
  1811. var div = document.createElement('div');
  1812. div.setAttribute('width', '100%');
  1813. div.setAttribute('height', '100%');
  1814. var div_print = document.createElement('div');
  1815. div_print.setAttribute('style', 'width:595px;height:842px;padding:50px 20px;margin:0px auto 0px auto');
  1816. div_print.innerHTML = div1_label1;
  1817. div.appendChild(div_print);
  1818. print_win.document.write(div.innerHTML);
  1819. print_win.document.close();
  1820. try {
  1821. var RegWsh = new ActiveXObject('WScript.Shell');
  1822. hkey_key = 'header';
  1823. RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, '');
  1824. hkey_key = 'footer';
  1825. RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, '');
  1826. } catch (e) {}
  1827. print_win.print();
  1828. print_win.close();
  1829. }
  1830. })()