pies.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <html lang="en">
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  5. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  6. <title></title>
  7. <!-- <link rel="stylesheet" href="../lib/layui-v2.4.5/layui-v2.4.5/layui/css/layui.css"> -->
  8. <link rel="stylesheet" href="../css/index.css">
  9. <!-- <script type="text/javascript" src="../lib/layui-v2.4.5/layui-v2.4.5/layui/layui.js"></script> -->
  10. <script src="../lib/echarts.min.js"></script>
  11. <script src="../lib/jquery/jquery.min.js"></script>
  12. <style>
  13. .chart {
  14. width: 80px;
  15. height: 80px;
  16. }
  17. .chart1 {
  18. width: 60px;
  19. height: 60px;
  20. }
  21. .label {
  22. margin-left: 12px;
  23. }
  24. .container {
  25. width: 450px;
  26. position: relative;
  27. }
  28. .container1 {
  29. width: 320px;
  30. position: absolute;
  31. top: 8px;
  32. left: 450px;
  33. }
  34. .row {
  35. width: 100%;
  36. }
  37. .col {
  38. width: 85px;
  39. float: left;
  40. }
  41. .col1 {
  42. width: 60px;
  43. float: left;
  44. }
  45. .margin-top {
  46. margin-top: 50px;
  47. }
  48. </style>
  49. </head>
  50. <body style="padding-top:8px;">
  51. <div style="width:450px;float:left;">
  52. <div class="container">
  53. <div class="row">
  54. <div class="col">
  55. <label class="label">MTBF</label>
  56. </div>
  57. <div class="col">
  58. <label class="label">综合效率</label>
  59. </div>
  60. <div class="col">
  61. <label class="label">稼动率</label>
  62. </div>
  63. <div class="col">
  64. <label class="label">闲置率</label>
  65. </div>
  66. <div class="col">
  67. <label class="label">报警率</label>
  68. </div>
  69. </div>
  70. <div class="row">
  71. <div class="col">
  72. <div id="total-mtbf" class="chart"></div>
  73. </div>
  74. <div class="col">
  75. <div id="total-effi" class="chart"></div>
  76. </div>
  77. <div class="col">
  78. <div id="total-runrate" class="chart"></div>
  79. </div>
  80. <div class="col">
  81. <div id="total-idlerate" class="chart"></div>
  82. </div>
  83. <div class="col">
  84. <div id="total-alarmrate" class="chart"></div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <div style=" width: 320px;float: left;margin-left: 10px;">
  90. <div class="container1">
  91. <div class="row">
  92. <div class="col1">
  93. <div id="db-mtbf" class="chart1"></div>
  94. </div>
  95. <div class="col1">
  96. <div id="db-effi" class="chart1"></div>
  97. </div>
  98. <div class="col1">
  99. <div id="db-runrate" class="chart1"></div>
  100. </div>
  101. <div class="col1">
  102. <div id="db-idlerate" class="chart1"></div>
  103. </div>
  104. <div class="col1">
  105. <div id="db-alarmrate" class="chart1"></div>
  106. </div>
  107. <div class="row">
  108. <div class="col1">
  109. <div id="wb-mtbf" class="chart1"></div>
  110. </div>
  111. <div class="col1">
  112. <div id="wb-effi" class="chart1"></div>
  113. </div>
  114. <div class="col1">
  115. <div id="wb-runrate" class="chart1"></div>
  116. </div>
  117. <div class="col1">
  118. <div id="wb-idlerate" class="chart1"></div>
  119. </div>
  120. <div class="col1">
  121. <div id="wb-alarmrate" class="chart1"></div>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. <script type="text/javascript">
  128. $(function () {
  129. var option = {
  130. title: {
  131. text: '',
  132. textStyle: {
  133. fontSize: '10',
  134. }
  135. },
  136. tooltip: {
  137. show: false
  138. },
  139. legend: {
  140. orient: 'vertical',
  141. x: 'left',
  142. data: ['']
  143. },
  144. series: [
  145. {
  146. hoverAnimation: false,
  147. name: '',
  148. type: 'pie',
  149. radius: ['60%', '90%'],
  150. //center:['40%','70%'],
  151. // avoidLabelOverlap: true,
  152. label: {
  153. normal: {
  154. show: true,
  155. position: 'center',
  156. textStyle: {
  157. fontSize: '12',
  158. fontWeight: 'bold'
  159. }
  160. },
  161. },
  162. labelLine: {
  163. normal: {
  164. show: false
  165. }
  166. },
  167. data: [
  168. ]
  169. }
  170. ]
  171. };
  172. var totalMtbfPie = echarts.init(document.getElementById('total-mtbf'));
  173. var totalEffi = echarts.init(document.getElementById('total-effi'));
  174. var totalRun = echarts.init(document.getElementById('total-runrate'));
  175. var totalIdle = echarts.init(document.getElementById('total-idlerate'));
  176. var totalAlarm = echarts.init(document.getElementById('total-alarmrate'));
  177. var dbMtbf = echarts.init(document.getElementById('db-mtbf'));
  178. var dbEffi = echarts.init(document.getElementById('db-effi'));
  179. var dbRun = echarts.init(document.getElementById('db-runrate'));
  180. var dbIdle = echarts.init(document.getElementById('db-idlerate'));
  181. var dbAlarm = echarts.init(document.getElementById('db-alarmrate'));
  182. var wbMtbfs = echarts.init(document.getElementById('wb-mtbf'));
  183. var wbEffi = echarts.init(document.getElementById('wb-effi'));
  184. var wbRun = echarts.init(document.getElementById('wb-runrate'));
  185. var wbIdle = echarts.init(document.getElementById('wb-idlerate'));
  186. var wbAlarm = echarts.init(document.getElementById('wb-alarmrate'));
  187. loadData();
  188. function loadData() {
  189. $.ajax({
  190. url: 'http://localhost:18531/eap/api/analysis2/getstatustotal',
  191. type: 'get',
  192. dataType: 'json',
  193. success: function (res) {
  194. console.log(res);
  195. var mtbfs = [];
  196. var effics = [];
  197. var dbM = 0, wbM = 0;
  198. if (res.mtbfs != null || res.mtbfs.length > 0) {
  199. for (var i = 0; i < res.mtbfs.length; i++) {
  200. if (res.mtbfs[i].pcode == 'DB') {
  201. dbM += res.mtbfs[i].mtbf;
  202. }
  203. if (res.mtbfs[i].pcode == 'WB') {
  204. wbM += res.mtbfs[i].mtbf;
  205. }
  206. }
  207. dbM = Math.round(dbM);
  208. wbM = Math.round(wbM);
  209. var overalMtbf = dbM + wbM;
  210. mtbfs = [{ type: 'total', value: overalMtbf }, { type: 'DB', value: dbM }, { type: 'WB', value: wbM }];
  211. }
  212. setOption('', ['MTBF'], overalMtbf.toString(), [{ value: overalMtbf, name: overalMtbf.toString() }, { value: 1440 - overalMtbf, name: '' }], totalMtbfPie);
  213. setOption('', ['MTBF'], dbM.toString(), [{ value: dbM, name: dbM.toString() }, { value: 1440 - dbM, name: '' }], dbMtbf);
  214. setOption('', ['MTBF'], wbM.toString(), [{ value: wbM, name: wbM.toString() }, { value: 1440 - wbM, name: '' }], wbMtbfs);
  215. if (res.effics != null || res.effics.length > 0) {
  216. var dbEffiency = 0, dbRunRate = 0, dbIdleRate = 0, dbAlarmRate = 0;
  217. var wbEffiency = 0, wbRunRate = 0, wbIdleRate = 0, wbAlarmRate = 0;
  218. var totalEffiency = 0, totalRunRate = 0, totalIdleRate = 0, totalAlarmRate;
  219. for (var j = 0; j < res.effics.length; j++) {
  220. if (res.effics[j].key == 'DB') {
  221. dbEffiency = Math.round(res.effics[j].overallEfficiency * 100);
  222. dbRunRate = Math.round(res.effics[j].runRate * 100);
  223. // dbIdleRate = Math.round(res.effics[j].idleRate * 100);
  224. dbAlarmRate = Math.round(res.effics[j].alarmRate * 100);
  225. dbIdleRate = 100 - dbAlarmRate - dbRunRate;
  226. }
  227. if (res.effics[j].key == 'WB') {
  228. wbEffiency += Math.round(res.effics[j].overallEfficiency * 100);
  229. wbRunRate += Math.round(res.effics[j].runRate * 100);
  230. // wbIdleRate += Math.round(res.effics[j].idleRate * 100);
  231. wbAlarmRate += Math.round(res.effics[j].alarmRate * 100);
  232. wbIdleRate = 100 - wbRunRate - wbAlarmRate;
  233. }
  234. }
  235. totalEffiency = Math.round((dbEffiency + wbEffiency) / 2);
  236. totalRunRate = Math.round((dbRunRate + wbRunRate) / 2);
  237. // totalIdleRate = Math.round((dbIdleRate + wbIdleRate) / 2);
  238. totalAlarmRate = Math.round((dbAlarmRate + wbAlarmRate) / 2);
  239. totalIdleRate = 100 - totalRunRate - totalAlarmRate;
  240. plusZero(overalMtbf);
  241. plusZero(dbM);
  242. plusZero(wbM);
  243. plusZero(dbEffiency);
  244. plusZero(dbRunRate);
  245. plusZero(dbIdleRate);
  246. plusZero(dbAlarmRate);
  247. plusZero(wbEffiency);
  248. plusZero(wbRunRate);
  249. plusZero(wbIdleRate);
  250. plusZero(wbAlarmRate);
  251. plusZero(totalEffiency);
  252. plusZero(totalRunRate);
  253. plusZero(totalIdleRate);
  254. plusZero(totalAlarmRate);
  255. }
  256. setOption('', ['综合效率'], totalEffiency.toString(), [{ value: totalEffiency, name: Math.round(totalEffiency).toString() }, { value: 100 - totalEffiency, name: '' }], totalEffi);
  257. setOption('', ['稼动率'], totalRunRate.toString(), [{ value: totalRunRate, name: Math.round(totalRunRate).toString() }, { value: 100 - totalRunRate, name: '' }], totalRun);
  258. setOption('', ['待机率'], totalIdleRate.toString(), [{ value: totalIdleRate, name: Math.round(totalIdleRate).toString() }, { value: 100 - totalIdleRate, name: '' }], totalIdle);
  259. setOption('', ['故障率'], totalAlarmRate.toString(), [{ value: totalAlarmRate, name: Math.round(totalAlarmRate).toString() }, { value: 100 - totalAlarmRate, name: '' }], totalAlarm);
  260. setOption('', ['综合效率'], dbEffiency.toString(), [{ value: dbEffiency, name: Math.round(dbEffiency).toString() }, { value: 100 - dbEffiency, name: '' }], dbEffi);
  261. setOption('', ['稼动率'], dbRunRate.toString(), [{ value: dbRunRate, name: Math.round(dbRunRate).toString() }, { value: 100 - dbRunRate, name: '' }], dbRun);
  262. setOption('', ['待机率'], dbIdleRate.toString(), [{ value: dbIdleRate, name: Math.round(dbIdleRate).toString() }, { value: 100 - dbIdleRate, name: '' }], dbIdle);
  263. setOption('', ['故障率'], dbAlarmRate.toString(), [{ value: dbAlarmRate, name: Math.round(dbAlarmRate).toString() }, { value: 100 - dbAlarmRate, name: '' }], dbAlarm);
  264. setOption('', ['综合效率'], wbEffiency.toString(), [{ value: wbEffiency, name: Math.round(wbEffiency).toString() }, { value: 100 - wbEffiency, name: '' }], wbEffi);
  265. setOption('', ['稼动率'], wbRunRate.toString(), [{ value: wbRunRate, name: Math.round(wbRunRate).toString() }, { value: 100 - wbRunRate, name: '' }], wbRun);
  266. setOption('', ['待机率'], wbIdleRate.toString(), [{ value: wbIdleRate, name: Math.round(wbIdleRate).toString() }, { value: 100 - wbIdleRate, name: '' }], wbIdle);
  267. setOption('', ['故障率'], wbAlarmRate.toString(), [{ value: wbAlarmRate, name: Math.round(wbAlarmRate).toString() }, { value: 100 - wbAlarmRate, name: '' }], wbAlarm);
  268. }
  269. });
  270. setTimeout(() => {
  271. loadData();
  272. }, 1000 * 60 * 60 * 2);
  273. }
  274. function setOption(title, lenged, name, data, chart) {
  275. option.title.text = title;
  276. option.legend.title = lenged;
  277. option.series[0].name = name;
  278. option.series[0].data = data;
  279. chart.setOption(option);
  280. }
  281. function plusZero(value) {
  282. if (value > 0)
  283. return value + 0.001;
  284. }
  285. });
  286. </script>
  287. </body>
  288. </html>