reprotManage_cbd_detail.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
  8. <link href="../css/mui.min.css" rel="stylesheet" />
  9. <link rel="stylesheet" href="../css/reset.css" />
  10. <link rel="stylesheet" href="../css/iconfont.css" />
  11. <link href="../css/common.css" rel="stylesheet" />
  12. <style type="text/css">
  13. .iconfont {
  14. font-size: 35px;
  15. color: #3bb9e7;
  16. /*font-weight: bold;*/
  17. line-height: 80px;
  18. margin: 10px 10px 10px 20px;
  19. }
  20. .equipState {
  21. font-size: 18px;
  22. margin-top: 14px;
  23. color: #333;
  24. }
  25. .conversion {
  26. width: 110px;
  27. }
  28. @media(max-width: 400px) {
  29. .mui-col-sm-6 {
  30. width: 50%;
  31. }
  32. }
  33. #detial>div {
  34. border-bottom: 2px solid #eee;
  35. }
  36. .topBorder{
  37. border-top: 2px solid #eee;
  38. }
  39. #detial>div:nth-of-type(odd) {
  40. border-right: 2px solid #eee;
  41. }
  42. #detial .mui-navigate-right {
  43. line-height: 80px;
  44. }
  45. .clearfix:after {
  46. content: " ";
  47. display: block;
  48. clear: both;
  49. visibility: hidden;
  50. line-height: 0;
  51. height: 0;
  52. font-size: 0;
  53. }
  54. .clearfix{
  55. *zoom:1;
  56. }
  57. .fl{
  58. float: left;
  59. }
  60. body,.mui-content{
  61. background: #fff;
  62. }
  63. .msgTop{
  64. background: #24b2e7;
  65. background: url(../images/bluesky.jpg) no-repeat;
  66. background-size: 100% 120%;
  67. position: relative;
  68. height: 150px;
  69. }
  70. .currEquip{
  71. color: #fff;
  72. font-size: 14px;
  73. position: absolute;
  74. bottom: 15px;
  75. left: 35px;
  76. }
  77. .currEquipId{
  78. font-size: 18px;
  79. line-height: 34px;
  80. color: #fffac9;
  81. font-weight: 700;
  82. }
  83. .equipImg{
  84. position: absolute;
  85. right: 37px;
  86. bottom: 0px;
  87. }
  88. /*统计图*/
  89. .echartsBox{
  90. text-align: center;
  91. }
  92. .timeSelectUl{
  93. display: inline-block;
  94. border: 1px solid #eee;
  95. margin: 15px 0 0;
  96. }
  97. .timeSelectUl >li{
  98. padding: 5px 14px;
  99. border-left: 1px solid #eee;
  100. color: #a5a5a5;
  101. }
  102. .timeSelectUl >li:nth-child(1){
  103. border: none;
  104. }
  105. .timeSelectUl >li.active{
  106. color: #13a1e2;
  107. }
  108. .chart{
  109. height: 250px;
  110. /*background: red;*/
  111. }
  112. .progressBarBox{
  113. margin-left: 5%;
  114. }
  115. .progressBarBox >li{
  116. width: 30%;
  117. text-align: center;
  118. }
  119. .progressBartitle{
  120. text-align: center;
  121. font-size: 14px;
  122. margin: 15px 0 7px;
  123. color: #333;
  124. }
  125. .circleChart_text{
  126. color: #13a1e2;
  127. font-size: 20px !important;
  128. }
  129. /*分界线*/
  130. .boundaryline{
  131. width: 100%;
  132. height: 10px;
  133. background: #F3F3F3;
  134. }
  135. /*数据*/
  136. .dataShowBox >h1{
  137. padding-left: 30px;
  138. margin: 10px 0 10px 15px;
  139. background: url(../images/statusTag.png) no-repeat 0 2px;
  140. line-height: 25px;
  141. font-weight: 700;
  142. }
  143. .dataShowBox hr{
  144. margin: 0 12px 10px 12px;
  145. border: 1px dashed #e7f3fc;
  146. }
  147. .dataShowBox >.equipStatus{
  148. background: url(../images/statusTag.png) no-repeat 0 -26px;
  149. }
  150. /*查看详情*/
  151. .lookDetialBox{
  152. text-align: center;
  153. margin: 20px 0;
  154. }
  155. .lookDetialBox button{
  156. width: 80%;
  157. border-radius: 15px;
  158. }
  159. /*查看详情*/
  160. .areaTitle {
  161. color: #424242;
  162. padding-left: 30px;
  163. /*border-left: 14px solid #ff6e00;*/
  164. font-weight: bold;
  165. font-size: 16px;
  166. position: relative;
  167. background: url(../images/statusTag.png) no-repeat 0 -52px;
  168. }
  169. .detialBox .fa{
  170. padding-right: 5px;
  171. color: #3bb9e7;
  172. }
  173. </style>
  174. </head>
  175. <body>
  176. <header class="mui-bar mui-bar-nav">
  177. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  178. <h1 class="mui-title" id="title">测报灯数据详情</h1>
  179. <!--<a class="headRightIcon fa fa-search mui-pull-right" id="reloadEquip">查询</a>-->
  180. </header>
  181. <div class="mui-content">
  182. <div class="msgTop">
  183. <div class="currEquip">
  184. <div id="currEquipId" class="currEquipId"></div>
  185. <div id="upl_time"></div>
  186. </div>
  187. <img class="equipImg" src="../images/cbdequipImg.png" width="50" height="130"/>
  188. </div>
  189. <div class="echartsBox">
  190. <div class="timeSelectBox">
  191. <ul class="timeSelectUl clearfix">
  192. <li class="fl active">近1月</li>
  193. <li class="fl">近3月</li>
  194. <li class="fl">近1年</li>
  195. <li class="fl">累计至今</li>
  196. </ul>
  197. </div>
  198. <div class="chart" id="lineChart"></div>
  199. </div>
  200. <div class="boundaryline"></div>
  201. <div class="dataShowBox">
  202. <h1>测报灯仓内数据</h1>
  203. <hr />
  204. <div>
  205. <ul class="progressBarBox clearfix">
  206. <li class="fl">
  207. <!--<div class="circleChart" id="circleChart1"></div>-->
  208. <canvas id="circleChart1" width="95%" height="95%"></canvas>
  209. <div class="progressBartitle">环境湿度(%RH)</div>
  210. </li>
  211. <li class="fl">
  212. <!--<div class="circleChart" id="c1"></div>-->
  213. <canvas id="circleChart2" width="95%" height="95%"></canvas>
  214. <div class="progressBartitle">环境温度(℃)</div>
  215. </li>
  216. <li class="fl">
  217. <!--<div class="circleChart" id="c2"></div>-->
  218. <canvas id="circleChart3" width="95%" height="95%"></canvas>
  219. <div class="progressBartitle">加热仓温度(℃)</div>
  220. </li>
  221. </ul>
  222. </div>
  223. <!--状态-->
  224. <h1 class="equipStatus">测报灯当前状态</h1>
  225. <hr style="margin-bottom: 0;" />
  226. <div class="mui-row" id="detial">
  227. <div class="mui-col-xs-6">
  228. <div class="mui-pull-left">
  229. <i class="iconfont">&#xe635;</i>
  230. </div>
  231. <div class="mui-pull-left ">
  232. <p class="equipState" id="rps"></p>
  233. <p class="equipFun">雨控状态</p>
  234. </div>
  235. </div>
  236. <div class="mui-col-xs-6">
  237. <div class="mui-pull-left">
  238. <i class="iconfont">&#xe64c;</i>
  239. </div>
  240. <div class="mui-pull-left ">
  241. <p class="equipState" id="lps"></p>
  242. <p class="equipFun">光控状态</p>
  243. </div>
  244. </div>
  245. <div class="mui-col-xs-6">
  246. <div class="mui-pull-left">
  247. <i class="iconfont">&#xe711;</i>
  248. </div>
  249. <div class="mui-pull-left ">
  250. <p class="equipState conversion" id="lng"></p>
  251. <p class="equipFun">经度</p>
  252. </div>
  253. </div>
  254. <div class="mui-col-xs-6">
  255. <div class="mui-pull-left">
  256. <i class="iconfont">&#xe634;</i>
  257. </div>
  258. <div class="mui-pull-left ">
  259. <p class="equipState conversion" id="lat"></p>
  260. <p class="equipFun">纬度</p>
  261. </div>
  262. </div>
  263. <div class="mui-col-xs-6">
  264. <div class="mui-pull-left">
  265. <i class="iconfont">&#xe633;</i>
  266. </div>
  267. <div class="mui-pull-left ">
  268. <p class="equipState" id="tps"></p>
  269. <p class="equipFun">温控状态</p>
  270. </div>
  271. </div>
  272. <div class="mui-col-xs-6">
  273. <div class="mui-pull-left">
  274. <i class="iconfont">&#xe688;</i>
  275. </div>
  276. <div class="mui-pull-left " id="lookImg">
  277. <div class="mui-navigate-right">查看图片</div>
  278. </div>
  279. </div>
  280. </div>
  281. </div>
  282. <ul class="mui-table-view detialBox">
  283. <li class="mui-table-view-cell">
  284. <h1 class="areaTitle">配置设备操作</h1>
  285. </li>
  286. <!--<li class="mui-table-view-cell" id="lookImg">
  287. <a class="mui-navigate-right">
  288. <i class="fa fa-file-image-o" aria-hidden="true"></i>
  289. 查看图片
  290. </a>
  291. </li>-->
  292. <li class="mui-table-view-cell" id="lookDetial">
  293. <a class="mui-navigate-right">
  294. <i class="fa fa-list" aria-hidden="true"></i>
  295. 查看列表详情
  296. </a>
  297. </li>
  298. <li class="mui-table-view-cell" id="reloadEquip">
  299. <a class="mui-navigate-right">
  300. <i class="fa fa-refresh" aria-hidden="true"></i>
  301. 查询最新状态
  302. </a>
  303. </li>
  304. <li class="mui-table-view-cell" id="wormChart">
  305. <a class="mui-navigate-right">
  306. <i class="fa fa-line-chart" aria-hidden="true"></i>
  307. 害虫统计
  308. </a>
  309. </li>
  310. </ul>
  311. </div>
  312. <script src="../js/jquery-2.1.0.js"></script>
  313. <script src="../js/mui.min.js"></script>
  314. <script src="../js/echarts.js"></script>
  315. <script src="../js/progress.js"></script>
  316. <script type="text/javascript">
  317. mui.init();
  318. var equipId;
  319. var equipName;
  320. //统计按钮查询
  321. $('.timeSelectUl').on('tap','li',function(){
  322. if(!$(this).hasClass('active')){
  323. var year = [1,3,12,""]
  324. $('.timeSelectUl li').removeClass('active');
  325. $(this).addClass('active');
  326. getChartData(year[$(this).index()])
  327. }
  328. })
  329. // 1基于准备好的dom,初始化echarts实例
  330. var lineChart = echarts.init(document.getElementById('lineChart'));
  331. // 指定图表的配置项和数据
  332. var lineOption = {
  333. tooltip: {
  334. trigger: 'axis',
  335. formatter: function(params) {
  336. if(params.length > 1) {
  337. var returnData = '';
  338. var time = '';
  339. for(var g in params) {
  340. time = params[g].axisValue;
  341. if(params[g].seriesIndex == 0){
  342. returnData += params[g].seriesName + ':' + params[g].value + '°C<br/>';
  343. }else{
  344. returnData += params[g].seriesName + ':' + params[g].value + '%<br/>';
  345. }
  346. }
  347. return time + '<br/>' + returnData;
  348. }
  349. }
  350. },
  351. grid: {
  352. left: '3%',
  353. right: '4%',
  354. bottom: '5%',
  355. containLabel: true
  356. },
  357. legend: {
  358. x:'center',
  359. y:'20',
  360. data: ['环境温度', '环境湿度'],
  361. },
  362. xAxis: {
  363. type: 'category'
  364. },
  365. dataZoom : {
  366. type:'inside',
  367. },
  368. yAxis: {
  369. axisLine:{
  370. lineStyle:{
  371. color:'#aeabae',
  372. width:0,//这里是为了突出显示加上的
  373. }
  374. },
  375. splitLine: { show: true, // Y轴的横线显示
  376. lineStyle: {
  377. type: 'dashed'
  378. }
  379. },
  380. type: 'value', //数据
  381. },
  382. series: [{
  383. name: '环境温度',
  384. type: 'line',
  385. smooth: true, //是否平滑曲线显示
  386. itemStyle: {
  387. normal: {
  388. color: '#6ecdfe'
  389. }
  390. }
  391. }, {
  392. name: '环境湿度',
  393. type: 'line',
  394. smooth: true, //是否平滑曲线显示
  395. itemStyle: {
  396. normal: {
  397. color: '#5689f2'
  398. }
  399. }
  400. }]
  401. };
  402. mui.plusReady(function() {
  403. var self = plus.webview.currentWebview();
  404. equipId = self.equipId;
  405. // upl_time = self.upl_time
  406. $('#currEquipId').html('ID:'+equipId);
  407. // $('#upl_time').html(upl_time);
  408. //详情
  409. requestData();
  410. //统计图
  411. getChartData(1)
  412. //查看图片
  413. document.getElementById('lookImg').addEventListener('tap', function() {
  414. mui.openWindow({
  415. url: 'lookImage.html',
  416. id: 'lookImage',
  417. extras: {
  418. equipId: equipId
  419. }
  420. })
  421. })
  422. //查看详情
  423. document.getElementById('lookDetial').addEventListener('tap', function() {
  424. mui.openWindow({
  425. url: 'cbd_detail_list.html',
  426. id: 'cbd_detail_list',
  427. extras: {
  428. equipId: equipId,
  429. equipName:equipName
  430. }
  431. })
  432. })
  433. //查询
  434. document.getElementById('reloadEquip').addEventListener('tap',function(){
  435. mui.ajax('http://120.27.222.26/scd_mqtt',{
  436. data:{
  437. 'sw': 'read',
  438. 'topicid': equipId,
  439. 'kind': 'data'
  440. },
  441. dataType:'json',//服务器返回json格式数据
  442. type:'post',//HTTP请求类型
  443. timeout: 10000,//超时时间设置为10秒;
  444. beforeSend: function() {
  445. plus.nativeUI.showWaiting('请求中...');
  446. },
  447. complete: function() {
  448. setTimeout(function() {
  449. plus.nativeUI.closeWaiting();
  450. }, 4000);
  451. },
  452. success:function(data){
  453. setTimeout(function() {
  454. mui.toast('查询成功')
  455. window.location.reload();
  456. }, 4000);
  457. },
  458. error:function(xhr,type,errorThrown){
  459. mui.toast('查询失败')
  460. }
  461. });
  462. })
  463. //害虫统计
  464. document.getElementById('wormChart').addEventListener('tap', function() {
  465. mui.openWindow({
  466. url: 'cbd_pest_data.html',
  467. id: 'cbd_pest_data',
  468. extras: {
  469. equipId: equipId,
  470. equipName:equipName
  471. }
  472. })
  473. })
  474. })
  475. //请求图表数据:
  476. function getChartData(monthNum){
  477. if(monthNum){
  478. var begindate = new Date();
  479. begindate.setMonth(begindate.getMonth()-monthNum);
  480. var ybegin = begindate.getFullYear();
  481. var mbegin = begindate.getMonth()+1;
  482. var dbegin = begindate.getDate();
  483. var nowdate = new Date();
  484. var ynow = nowdate.getFullYear();
  485. var mnow = nowdate.getMonth()+1;
  486. var dnow = nowdate.getDate();
  487. var beginTime = ybegin+'-'+mbegin+'-'+dbegin;
  488. var endTime = ynow+'-'+mnow+'-'+dnow;
  489. }else{
  490. var beginTime = '';
  491. var endTime = '';
  492. }
  493. $.ajax({
  494. url: 'http://120.27.222.26/cbd_report_detail_chart',
  495. type: 'post',
  496. data: {
  497. 'id':equipId,
  498. 'req': 'filter',
  499. 'begin': beginTime,
  500. 'end': endTime
  501. },
  502. success: function(data) {
  503. var temp = eval('(' + data + ')');
  504. var at = [],
  505. ah = [],
  506. time = [],
  507. cv = [],
  508. bv = [],
  509. ct = [];
  510. for(var i = 0; i < temp.length; i++) {
  511. at.unshift(Number(temp[i].at / 10).toFixed(1));
  512. ah.unshift(Number(temp[i].ah / 10).toFixed(1));
  513. cv.unshift((Number(temp[i].cv) / 1000).toFixed(1));
  514. bv.unshift((Number(temp[i].bv) / 1000).toFixed(1));
  515. ct.unshift(Number(temp[i].ct));
  516. time.unshift(temp[i].tim);
  517. }
  518. lineOption.series[0].data = at;
  519. lineOption.series[1].data = ah;
  520. lineOption.xAxis.data = time;
  521. if(!temp.length) {
  522. lineOption.series[0].data = [0];
  523. lineOption.xAxis.data = ['暂无数据'];
  524. }
  525. // 使用刚指定的配置项和数据显示图表。
  526. setTimeout(function() {
  527. lineChart.setOption(lineOption);
  528. })
  529. }
  530. })
  531. }
  532. function requestData() {
  533. mui.ajax('http://120.27.222.26/app_reportmanage_unflod', {
  534. data: {
  535. 'etype': 'cbd',
  536. 'equip_id': equipId,
  537. },
  538. dataType: 'json', //服务器返回json格式数据
  539. type: 'post', //HTTP请求类型
  540. timeout: 10000, //超时时间设置为10秒;
  541. beforeSend: function() {
  542. plus.nativeUI.showWaiting('请求中...');
  543. },
  544. complete: function() {
  545. plus.nativeUI.closeWaiting();
  546. },
  547. success: function(data) {
  548. // console.log(JSON.stringify(data))
  549. upl_time = data.upl_time
  550. $('#upl_time').html(upl_time);
  551. // var discern = data.discern
  552. // if(!discern){
  553. // $('#wormChart').show();
  554. // }else{
  555. // $('#wormChart').hide();
  556. // }
  557. equipName = data.equip_name || '无'
  558. var stat = eval('(' + data.cbd_data + ')');
  559. // $('#at').html((stat.at / 10).toFixed(1)); //温度
  560. // $('#ah').html((stat.ah / 10).toFixed(1));
  561. // $('#hrt').html(stat.hrt);
  562. var rps = stat.rps == 0 ? '正常':'雨控';
  563. $('#rps').html(rps);
  564. var tps = stat.tps == 0 ? '正常':'温控';
  565. $('#tps').html(tps);
  566. var lps = stat.lps == 0 ? '夜晚':'白天';
  567. $('#lps').html(lps);
  568. if (stat.lng > 999) {
  569. var lng = Math.floor(stat.lng / 100) + ((stat.lng % 100) / 60);
  570. var lat = Math.floor(stat.lat / 100) + ((stat.lat % 100) / 60);
  571. } else {
  572. var lng = Number(stat.lng);
  573. var lat = Number(stat.lat);
  574. }
  575. //判断当前设备是否具备图片识别功能
  576. console.log(data.discern)
  577. if (data.discern == 1) {
  578. console.log('全都有')
  579. localStorage.setItem('possess', '1')
  580. $('#wormChart').show()
  581. } else if (data.discern == 2) {
  582. //有统计无识别
  583. localStorage.setItem('possess', '0')
  584. console.log('有统计无识别')
  585. $('#wormChart').show()
  586. } else if (data.discern == 0) {
  587. console.log('啥都没')
  588. localStorage.setItem('possess', '0')
  589. $('#wormChart').hide()
  590. }
  591. $('#lng').html(lng.toFixed(4));
  592. $('#lat').html(lat.toFixed(4));
  593. //进度条
  594. var p1 = new Progress({
  595. el: 'circleChart1', //canvas元素id
  596. deg: (stat.ah / 10).toFixed(1), //填入你的数据 如data
  597. currtype:'%RH',
  598. timer: 10, //绘制时间
  599. lineWidth: 10, //线宽
  600. lineBgColor: '#f4f3f3', //底圆颜色
  601. lineColor: '#1f8aff', //动态圆颜色
  602. textColor: '#1f8aff', //文本颜色
  603. fontSize: 20, //字体大小
  604. circleRadius: 100 //圆半径
  605. });
  606. var p2 = new Progress({
  607. el: 'circleChart2', //canvas元素id
  608. deg: (stat.at / 10).toFixed(1), //填入你的数据 如data
  609. currtype:'℃',
  610. timer: 10, //绘制时间
  611. lineWidth: 10, //线宽
  612. lineBgColor: '#f4f3f3', //底圆颜色
  613. lineColor: '#1f8aff', //动态圆颜色
  614. textColor: '#1f8aff', //文本颜色
  615. fontSize: 20, //字体大小
  616. circleRadius: 100 //圆半径
  617. });
  618. var p3 = new Progress({
  619. el: 'circleChart3', //canvas元素id
  620. deg: stat.hrt, //填入你的数据 如data
  621. currtype:'℃',
  622. timer: 10, //绘制时间
  623. lineWidth: 10, //线宽
  624. lineBgColor: '#f4f3f3', //底圆颜色
  625. lineColor: '#1f8aff', //动态圆颜色
  626. textColor: '#1f8aff', //文本颜色
  627. fontSize: 20, //字体大小
  628. circleRadius: 100 //圆半径
  629. });
  630. },
  631. error: function(xhr, type, errorThrown) {
  632. mui.toast('数据请求失败');
  633. }
  634. })
  635. }
  636. </script>
  637. </body>
  638. </html>