mesScreen2.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>MES可视化大屏</title>
  8. <link rel="stylesheet" href="${ctxStatic}/bootstrap/css/bootstrap.min.css">
  9. <link rel="stylesheet" href="${ctxStatic}/screen/style.css">
  10. <style>
  11. .dashboard{
  12. position: absolute;
  13. top: 132px;
  14. left: 25px;
  15. right: 25px;
  16. bottom: 110px;
  17. z-index: 100;
  18. }
  19. .overview-row{
  20. display: flex;
  21. gap: 18px;
  22. height: 126px;
  23. margin-bottom: 18px;
  24. }
  25. .overview-card{
  26. position: relative;
  27. flex: 1;
  28. padding: 24px 28px;
  29. background: linear-gradient(135deg, rgba(17, 46, 109, 0.88), rgba(7, 22, 54, 0.78));
  30. border: 1px solid rgba(64, 173, 255, 0.35);
  31. box-shadow: inset 0 0 26px rgba(56, 160, 255, 0.12), 0 10px 24px rgba(0, 10, 35, 0.4);
  32. overflow: hidden;
  33. }
  34. .overview-card:before{
  35. content: "";
  36. position: absolute;
  37. top: 0;
  38. left: 0;
  39. width: 100%;
  40. height: 3px;
  41. background: linear-gradient(90deg, rgba(55, 180, 255, 0.1), rgba(55, 180, 255, 0.9), rgba(55, 180, 255, 0.1));
  42. }
  43. .overview-label{
  44. font-size: 18px;
  45. color: #79CFFF;
  46. letter-spacing: 2px;
  47. }
  48. .overview-value{
  49. margin-top: 16px;
  50. font-size: 46px;
  51. line-height: 1;
  52. font-weight: bold;
  53. color: #FFFFFF;
  54. font-family: FZChaoCuHei-M10S;
  55. }
  56. .overview-sub{
  57. margin-top: 14px;
  58. font-size: 16px;
  59. color: rgba(196, 231, 255, 0.72);
  60. }
  61. .dashboard-main{
  62. display: flex;
  63. gap: 18px;
  64. height: calc(100% - 144px);
  65. }
  66. .panel-box{
  67. background: linear-gradient(180deg, rgba(10, 28, 70, 0.92), rgba(5, 15, 38, 0.88));
  68. border: 1px solid rgba(64, 173, 255, 0.28);
  69. box-shadow: inset 0 0 32px rgba(60, 143, 255, 0.12), 0 12px 30px rgba(0, 0, 0, 0.22);
  70. }
  71. .table-panel{
  72. flex: 0 0 1210px;
  73. padding: 22px 22px 18px;
  74. }
  75. .side-panel{
  76. flex: 1;
  77. display: flex;
  78. flex-direction: column;
  79. gap: 18px;
  80. }
  81. .panel-title{
  82. display: flex;
  83. align-items: center;
  84. justify-content: space-between;
  85. height: 42px;
  86. line-height: 42px;
  87. margin-bottom: 16px;
  88. padding-left: 16px;
  89. padding-right: 16px;
  90. background: linear-gradient(90deg, rgba(24, 78, 166, 0.58), rgba(24, 78, 166, 0.08));
  91. color: #7ED4FF;
  92. font-size: 22px;
  93. font-weight: bold;
  94. }
  95. .panel-title span{
  96. font-size: 16px;
  97. font-weight: normal;
  98. color: rgba(182, 227, 255, 0.75);
  99. }
  100. .oprnobox-header{
  101. display: flex;
  102. align-items: center;
  103. height: 58px;
  104. padding: 0 12px;
  105. background: rgba(20, 55, 120, 0.85);
  106. font-size: 20px;
  107. color: #3DB3FF;
  108. font-weight: bold;
  109. text-align: center;
  110. border: 1px solid rgba(73, 163, 255, 0.2);
  111. }
  112. .oprnobox-header > div{
  113. flex-shrink: 0;
  114. }
  115. .oprno-num{
  116. width: 150px;
  117. }
  118. .oprno-title{
  119. width: 330px;
  120. }
  121. .oprno-shift{
  122. width: 170px;
  123. }
  124. .oprno-day{
  125. width: 170px;
  126. }
  127. .oprno-rate{
  128. flex: 1;
  129. min-width: 0;
  130. }
  131. #numbox{
  132. margin-top: 14px;
  133. }
  134. .oprnobox-list{
  135. display: flex;
  136. align-items: center;
  137. height: 68px;
  138. padding: 0 12px;
  139. margin-bottom: 12px;
  140. background: linear-gradient(90deg, rgba(14, 49, 108, 0.86), rgba(8, 25, 59, 0.78));
  141. border: 1px solid rgba(62, 163, 255, 0.18);
  142. box-shadow: inset 0 0 18px rgba(56, 160, 255, 0.08);
  143. font-size: 28px;
  144. text-align: center;
  145. font-family: FZChaoCuHei-M10S;
  146. font-weight: 400;
  147. color: #FFFFFF;
  148. }
  149. .oprnobox-list:nth-child(even){
  150. background: linear-gradient(90deg, rgba(11, 41, 92, 0.92), rgba(6, 22, 51, 0.82));
  151. }
  152. .oprnobox-list .oprno-num{
  153. font-size: 24px;
  154. color: #6CD6FF;
  155. }
  156. .oprnobox-list .oprno-title{
  157. padding: 0 12px;
  158. font-size: 24px;
  159. text-align: left;
  160. white-space: nowrap;
  161. overflow: hidden;
  162. text-overflow: ellipsis;
  163. }
  164. .oprnobox-list .oprno-shift,
  165. .oprnobox-list .oprno-day{
  166. font-size: 28px;
  167. color: #FFFFFF;
  168. }
  169. .rate-box{
  170. display: flex;
  171. align-items: center;
  172. gap: 14px;
  173. padding-right: 8px;
  174. }
  175. .rate-track{
  176. position: relative;
  177. flex: 1;
  178. height: 14px;
  179. border-radius: 10px;
  180. background: rgba(255, 255, 255, 0.08);
  181. overflow: hidden;
  182. }
  183. .rate-bar{
  184. height: 100%;
  185. border-radius: 10px;
  186. background: linear-gradient(90deg, #1ED4FF, #2FF4A6);
  187. box-shadow: 0 0 12px rgba(47, 244, 166, 0.35);
  188. }
  189. .rate-text{
  190. width: 76px;
  191. font-size: 22px;
  192. color: #8AE4FF;
  193. }
  194. .chart-panel{
  195. flex: 1;
  196. padding: 18px 18px 10px;
  197. }
  198. .chart-box{
  199. height: calc(100% - 58px);
  200. }
  201. .empty-box{
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. height: calc(100% - 58px);
  206. font-size: 28px;
  207. color: rgba(185, 223, 255, 0.6);
  208. letter-spacing: 4px;
  209. }
  210. .dangerbox{
  211. position: absolute;
  212. z-index: 100000;
  213. bottom: 25px;
  214. left: 25px;
  215. width: 1870px;
  216. height: 64px;
  217. line-height: 64px;
  218. padding: 0 20px;
  219. text-align: center;
  220. background: rgba(255, 0, 0, 0.15);
  221. border: 1px solid rgba(255, 74, 74, 0.6);
  222. box-shadow: inset 0 0 20px rgba(255, 0, 0, 0.08);
  223. color: #FF8F8F;
  224. font-family: Microsoft YaHei;
  225. font-weight: 400;
  226. font-size: 28px;
  227. display: none;
  228. overflow: hidden;
  229. white-space: nowrap;
  230. text-overflow: ellipsis;
  231. }
  232. </style>
  233. </head>
  234. <body id="app">
  235. <div class="screenbg">
  236. <img class="bg1" src="${ctxStatic}/screen/imgs/bg.png" alt="">
  237. <img class="bg2" style="display: none;" src="${ctxStatic}/screen/imgs/bg2.png" alt="">
  238. </div>
  239. <div class="screenbox1">
  240. <div class="screenmain">
  241. <div class="screen-title">MES系统生产数据大屏</div>
  242. <div class="dashboard">
  243. <div class="overview-row">
  244. <div class="overview-card">
  245. <div class="overview-label">工位总数</div>
  246. <div class="overview-value" id="overviewCount">46</div>
  247. <div class="overview-sub" id="overviewPageCount">当前页 46 个工位</div>
  248. </div>
  249. <div class="overview-card">
  250. <div class="overview-label">当班总产值</div>
  251. <div class="overview-value" id="overviewShift">0</div>
  252. <div class="overview-sub">当前班次累计</div>
  253. </div>
  254. <div class="overview-card">
  255. <div class="overview-label">当日总产值</div>
  256. <div class="overview-value" id="overviewDay">0</div>
  257. <div class="overview-sub">08:00 至次日 08:00</div>
  258. </div>
  259. <div class="overview-card">
  260. <div class="overview-label">当班合格率</div>
  261. <div class="overview-value" id="overviewRate">0%</div>
  262. <div class="overview-sub" id="overviewPage">OK 0 / NG 0</div>
  263. </div>
  264. </div>
  265. <div class="dashboard-main">
  266. <div class="table-panel panel-box">
  267. <div class="panel-title">工位产值明细 </div>
  268. <div class="oprnobox-header">
  269. <div class="oprno-num">工位</div>
  270. <div class="oprno-title">工位名称</div>
  271. <div class="oprno-shift">当班产值</div>
  272. <div class="oprno-day">当日产值</div>
  273. <div class="oprno-rate">合格率</div>
  274. </div>
  275. <div id="numbox"></div>
  276. </div>
  277. <div class="side-panel">
  278. <div class="chart-panel panel-box">
  279. <div class="panel-title">当前页工位对比 <span>当班 / 当日</span></div>
  280. <div id="shiftDayChart" class="chart-box"></div>
  281. </div>
  282. <div class="chart-panel panel-box">
  283. <div class="panel-title">日产值 TOP 6 <span>全工位排名</span></div>
  284. <div id="topChart" class="chart-box"></div>
  285. </div>
  286. </div>
  287. </div>
  288. </div>
  289. <div class="dangerbox" id="dangerbox">
  290. </div>
  291. </div>
  292. </div>
  293. <script src="${ctxStatic}/jquery-1.11.3.min.js"></script>
  294. <script src="${ctxStatic}/leaflet/js/echarts.min.js"></script>
  295. <script>
  296. let lists = [];
  297. let overviewData = {};
  298. let topListData = [];
  299. let pageSize = 9;
  300. let pageIndex = 0;
  301. let shiftDayChart = null;
  302. let topChart = null;
  303. $(window).resize(function(){
  304. location.reload()
  305. });
  306. $(function () {
  307. changeZoom();
  308. initCharts();
  309. getData();
  310. getAlarmData();
  311. setInterval(function () {
  312. getData();
  313. },1000*60*2);
  314. setInterval(function () {
  315. formatData();
  316. getAlarmData();
  317. },1000*10);
  318. });
  319. function initCharts() {
  320. if (window.echarts) {
  321. shiftDayChart = echarts.init(document.getElementById('shiftDayChart'));
  322. topChart = echarts.init(document.getElementById('topChart'));
  323. }
  324. }
  325. function getData() {
  326. let url = "/js/a/mes/mesProduct/screenDashboardData";
  327. $.post(url,function (ret) {
  328. let data = ret.data || {};
  329. lists = $.isArray(data.list) ? data.list : [];
  330. overviewData = data.overview || {};
  331. topListData = $.isArray(data.topList) ? data.topList : [];
  332. pageIndex = 0;
  333. formatData();
  334. });
  335. }
  336. function getAlarmData() {
  337. let url = "/js/a/mes/mesProduct/alarmData";
  338. $.post(url,function (ret) {
  339. if(ret.result == "true"){
  340. let str = ret.data.createDate+" 【"+ret.data.oprno+"-"+ret.data.title+"】"+ret.data.remark+":"+ret.data.sn;
  341. $("#dangerbox").show().text(str);
  342. }else{
  343. $("#dangerbox").hide().text("");
  344. }
  345. });
  346. }
  347. function formatData(){
  348. let pageData = getPageData();
  349. renderOverview(pageData);
  350. renderTable(pageData.list);
  351. renderCharts(pageData.list);
  352. if (pageData.totalPages > 1) {
  353. pageIndex = (pageIndex + 1) % pageData.totalPages;
  354. }
  355. }
  356. function getPageData() {
  357. let totalPages = Math.ceil(lists.length / pageSize);
  358. if (totalPages < 1) {
  359. totalPages = 1;
  360. }
  361. if (pageIndex >= totalPages) {
  362. pageIndex = 0;
  363. }
  364. let start = pageIndex * pageSize;
  365. let end = start + pageSize;
  366. return {
  367. list: lists.slice(start, end),
  368. totalPages: totalPages,
  369. currentPage: lists.length ? pageIndex + 1 : 0
  370. };
  371. }
  372. function renderOverview(pageData) {
  373. let totalShift = normalizeNumber(overviewData.totalShift);
  374. let totalDay = normalizeNumber(overviewData.totalDay);
  375. let shiftOkCount = normalizeNumber(overviewData.shiftOkCount);
  376. let shiftNgCount = normalizeNumber(overviewData.shiftNgCount);
  377. let rate = normalizeDecimal(overviewData.qualityRate).toFixed(1);
  378. $("#overviewCount").text(normalizeNumber(46));
  379. $("#overviewPageCount").text("当前页 " + pageData.list.length + " 个工位");
  380. $("#overviewShift").text(totalShift);
  381. $("#overviewDay").text(totalDay);
  382. $("#overviewRate").text(rate + "%");
  383. $("#overviewPage").text("OK " + shiftOkCount + " / NG " + shiftNgCount);
  384. }
  385. function renderTable(dataList) {
  386. let str = '';
  387. if (!dataList.length) {
  388. str = '<div class="empty-box">暂无生产数据</div>';
  389. $("#numbox").html(str);
  390. return;
  391. }
  392. $.each(dataList, function (idx, item) {
  393. let shiftCount = normalizeNumber(item.shiftCount);
  394. let dayCount = normalizeNumber(item.dayCount);
  395. let rateValue = normalizeDecimal(item.qualityRate);
  396. let rateWidth = Math.max(6, Math.min(rateValue, 100));
  397. str += '<div class="oprnobox-list">';
  398. str += '<div class="oprno-num">' + escapeHtml(item.oprno) + '</div>';
  399. str += '<div class="oprno-title">' + escapeHtml(item.title) + '</div>';
  400. str += '<div class="oprno-shift">' + shiftCount + '</div>';
  401. str += '<div class="oprno-day">' + dayCount + '</div>';
  402. str += '<div class="oprno-rate">';
  403. str += '<div class="rate-box">';
  404. str += '<div class="rate-track"><div class="rate-bar" style="width:' + rateWidth + '%;"></div></div>';
  405. str += '<div class="rate-text">' + rateValue.toFixed(1) + '%</div>';
  406. str += '</div>';
  407. str += '</div>';
  408. str += '</div>';
  409. });
  410. $("#numbox").html(str);
  411. }
  412. function renderCharts(dataList) {
  413. renderShiftDayChart(dataList);
  414. renderTopChart();
  415. }
  416. function renderShiftDayChart(dataList) {
  417. if (!shiftDayChart) {
  418. return;
  419. }
  420. if (!dataList.length) {
  421. shiftDayChart.clear();
  422. return;
  423. }
  424. let categories = [];
  425. let shiftData = [];
  426. let dayData = [];
  427. $.each(dataList, function (idx, item) {
  428. categories.push(item.oprno || '');
  429. shiftData.push(normalizeNumber(item.shiftCount));
  430. dayData.push(normalizeNumber(item.dayCount));
  431. });
  432. shiftDayChart.setOption({
  433. backgroundColor: 'transparent',
  434. tooltip: {
  435. trigger: 'axis'
  436. },
  437. legend: {
  438. top: 6,
  439. right: 10,
  440. textStyle: {
  441. color: '#BFE8FF'
  442. },
  443. data: ['当班产值', '当日产值']
  444. },
  445. grid: {
  446. top: 46,
  447. left: 44,
  448. right: 22,
  449. bottom: 42,
  450. borderWidth: 0
  451. },
  452. xAxis: [
  453. {
  454. type: 'category',
  455. data: categories,
  456. axisLine: {
  457. lineStyle: {
  458. color: 'rgba(120, 187, 255, 0.35)'
  459. }
  460. },
  461. axisLabel: {
  462. textStyle: {
  463. color: '#CDEFFF',
  464. fontSize: 12
  465. }
  466. }
  467. }
  468. ],
  469. yAxis: [
  470. {
  471. type: 'value',
  472. axisLine: {
  473. lineStyle: {
  474. color: 'rgba(120, 187, 255, 0.35)'
  475. }
  476. },
  477. splitLine: {
  478. lineStyle: {
  479. color: 'rgba(120, 187, 255, 0.12)'
  480. }
  481. },
  482. axisLabel: {
  483. textStyle: {
  484. color: '#CDEFFF',
  485. fontSize: 12
  486. }
  487. }
  488. }
  489. ],
  490. series: [
  491. {
  492. name: '当班产值',
  493. type: 'bar',
  494. barMaxWidth: 18,
  495. itemStyle: {
  496. normal: {
  497. color: '#1FD6FF'
  498. }
  499. },
  500. data: shiftData
  501. },
  502. {
  503. name: '当日产值',
  504. type: 'bar',
  505. barMaxWidth: 18,
  506. itemStyle: {
  507. normal: {
  508. color: '#35E595'
  509. }
  510. },
  511. data: dayData
  512. }
  513. ]
  514. }, true);
  515. }
  516. function renderTopChart() {
  517. if (!topChart) {
  518. return;
  519. }
  520. if (!topListData.length) {
  521. topChart.clear();
  522. return;
  523. }
  524. let categories = [];
  525. let values = [];
  526. $.each(topListData, function (idx, item) {
  527. categories.push(item.oprno || '');
  528. values.push(normalizeNumber(item.dayCount));
  529. });
  530. topChart.setOption({
  531. backgroundColor: 'transparent',
  532. tooltip: {
  533. trigger: 'axis',
  534. axisPointer: {
  535. type: 'shadow'
  536. }
  537. },
  538. grid: {
  539. top: 16,
  540. left: 90,
  541. right: 30,
  542. bottom: 18,
  543. borderWidth: 0
  544. },
  545. xAxis: [
  546. {
  547. type: 'value',
  548. splitLine: {
  549. lineStyle: {
  550. color: 'rgba(120, 187, 255, 0.12)'
  551. }
  552. },
  553. axisLine: {
  554. lineStyle: {
  555. color: 'rgba(120, 187, 255, 0.35)'
  556. }
  557. },
  558. axisLabel: {
  559. textStyle: {
  560. color: '#CDEFFF',
  561. fontSize: 12
  562. }
  563. }
  564. }
  565. ],
  566. yAxis: [
  567. {
  568. type: 'category',
  569. data: categories,
  570. axisLine: {
  571. lineStyle: {
  572. color: 'rgba(120, 187, 255, 0.35)'
  573. }
  574. },
  575. axisTick: {
  576. show: false
  577. },
  578. axisLabel: {
  579. textStyle: {
  580. color: '#CDEFFF',
  581. fontSize: 12
  582. }
  583. }
  584. }
  585. ],
  586. series: [
  587. {
  588. name: '当日产值',
  589. type: 'bar',
  590. barMaxWidth: 18,
  591. itemStyle: {
  592. normal: {
  593. color: '#3C86FF',
  594. label: {
  595. show: true,
  596. position: 'right',
  597. textStyle: {
  598. color: '#E4F7FF'
  599. }
  600. }
  601. }
  602. },
  603. data: values
  604. }
  605. ]
  606. }, true);
  607. }
  608. function normalizeNumber(value) {
  609. let num = parseInt(value, 10);
  610. return isNaN(num) ? 0 : num;
  611. }
  612. function normalizeDecimal(value) {
  613. let num = parseFloat(value);
  614. return isNaN(num) ? 0 : num;
  615. }
  616. function escapeHtml(value) {
  617. let text = value == null ? '' : String(value);
  618. return text
  619. .replace(/&/g, '&amp;')
  620. .replace(/</g, '&lt;')
  621. .replace(/>/g, '&gt;')
  622. .replace(/"/g, '&quot;')
  623. .replace(/'/g, '&#39;');
  624. }
  625. function changeZoom() {
  626. var wb = $(window).width() / 1920;
  627. var hb = $(window).height() / 1080;
  628. if (wb >= hb) {
  629. $('body').css({
  630. 'zoom': hb,
  631. });
  632. } else {
  633. $('body').css({
  634. 'zoom': wb,
  635. });
  636. }
  637. }
  638. </script>
  639. </body>
  640. </html>