reprotManage_cbd_detail.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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. returnData += params[g].seriesName + ':' + params[g].value + '°C<br/>';
  342. }
  343. return time + '<br/>' + returnData;
  344. }
  345. }
  346. },
  347. grid: {
  348. left: '3%',
  349. right: '4%',
  350. bottom: '5%',
  351. containLabel: true
  352. },
  353. legend: {
  354. x:'center',
  355. y:'20',
  356. data: ['环境温度', '环境湿度'],
  357. },
  358. xAxis: {
  359. type: 'category'
  360. },
  361. dataZoom : {
  362. type:'inside',
  363. },
  364. yAxis: {
  365. axisLine:{
  366. lineStyle:{
  367. color:'#aeabae',
  368. width:0,//这里是为了突出显示加上的
  369. }
  370. },
  371. splitLine: { show: true, // Y轴的横线显示
  372. lineStyle: {
  373. type: 'dashed'
  374. }
  375. },
  376. type: 'value', //数据
  377. },
  378. series: [{
  379. name: '环境温度',
  380. type: 'line',
  381. smooth: true, //是否平滑曲线显示
  382. itemStyle: {
  383. normal: {
  384. color: '#6ecdfe'
  385. }
  386. }
  387. }, {
  388. name: '环境湿度',
  389. type: 'line',
  390. smooth: true, //是否平滑曲线显示
  391. itemStyle: {
  392. normal: {
  393. color: '#5689f2'
  394. }
  395. }
  396. }]
  397. };
  398. mui.plusReady(function() {
  399. var self = plus.webview.currentWebview();
  400. equipId = self.equipId;
  401. // upl_time = self.upl_time
  402. $('#currEquipId').html('ID:'+equipId);
  403. // $('#upl_time').html(upl_time);
  404. //详情
  405. requestData();
  406. //统计图
  407. getChartData(1)
  408. //查看图片
  409. document.getElementById('lookImg').addEventListener('tap', function() {
  410. mui.openWindow({
  411. url: 'lookImage.html',
  412. id: 'lookImage',
  413. extras: {
  414. equipId: equipId
  415. }
  416. })
  417. })
  418. //查看详情
  419. document.getElementById('lookDetial').addEventListener('tap', function() {
  420. mui.openWindow({
  421. url: 'cbd_detail_list.html',
  422. id: 'cbd_detail_list',
  423. extras: {
  424. equipId: equipId,
  425. equipName:equipName
  426. }
  427. })
  428. })
  429. //查询
  430. document.getElementById('reloadEquip').addEventListener('tap',function(){
  431. mui.ajax('http://120.27.222.26/scd_mqtt',{
  432. data:{
  433. 'sw': 'read',
  434. 'topicid': equipId,
  435. 'kind': 'data'
  436. },
  437. dataType:'json',//服务器返回json格式数据
  438. type:'post',//HTTP请求类型
  439. timeout: 10000,//超时时间设置为10秒;
  440. beforeSend: function() {
  441. plus.nativeUI.showWaiting('请求中...');
  442. },
  443. complete: function() {
  444. setTimeout(function() {
  445. plus.nativeUI.closeWaiting();
  446. }, 4000);
  447. },
  448. success:function(data){
  449. setTimeout(function() {
  450. mui.toast('查询成功')
  451. window.location.reload();
  452. }, 4000);
  453. },
  454. error:function(xhr,type,errorThrown){
  455. mui.toast('查询失败')
  456. }
  457. });
  458. })
  459. //害虫统计
  460. document.getElementById('wormChart').addEventListener('tap', function() {
  461. mui.openWindow({
  462. url: 'cbd_pest_data.html',
  463. id: 'cbd_pest_data',
  464. extras: {
  465. equipId: equipId,
  466. equipName:equipName
  467. }
  468. })
  469. })
  470. })
  471. //请求图表数据:
  472. function getChartData(monthNum){
  473. if(monthNum){
  474. var begindate = new Date();
  475. begindate.setMonth(begindate.getMonth()-monthNum);
  476. var ybegin = begindate.getFullYear();
  477. var mbegin = begindate.getMonth()+1;
  478. var dbegin = begindate.getDate();
  479. var nowdate = new Date();
  480. var ynow = nowdate.getFullYear();
  481. var mnow = nowdate.getMonth()+1;
  482. var dnow = nowdate.getDate();
  483. var beginTime = ybegin+'-'+mbegin+'-'+dbegin;
  484. var endTime = ynow+'-'+mnow+'-'+dnow;
  485. }else{
  486. var beginTime = '';
  487. var endTime = '';
  488. }
  489. $.ajax({
  490. url: 'http://120.27.222.26/cbd_report_detail_chart',
  491. type: 'post',
  492. data: {
  493. 'id':equipId,
  494. 'req': 'filter',
  495. 'begin': beginTime,
  496. 'end': endTime
  497. },
  498. success: function(data) {
  499. var temp = eval('(' + data + ')');
  500. var at = [],
  501. ah = [],
  502. time = [],
  503. cv = [],
  504. bv = [],
  505. ct = [];
  506. for(var i = 0; i < temp.length; i++) {
  507. at.unshift(Number(temp[i].at / 10).toFixed(1));
  508. ah.unshift(Number(temp[i].ah / 10).toFixed(1));
  509. cv.unshift((Number(temp[i].cv) / 1000).toFixed(1));
  510. bv.unshift((Number(temp[i].bv) / 1000).toFixed(1));
  511. ct.unshift(Number(temp[i].ct));
  512. time.unshift(temp[i].tim);
  513. }
  514. lineOption.series[0].data = at;
  515. lineOption.series[1].data = ah;
  516. lineOption.xAxis.data = time;
  517. if(!temp.length) {
  518. lineOption.series[0].data = [0];
  519. lineOption.xAxis.data = ['暂无数据'];
  520. }
  521. // 使用刚指定的配置项和数据显示图表。
  522. setTimeout(function() {
  523. lineChart.setOption(lineOption);
  524. })
  525. }
  526. })
  527. }
  528. function requestData() {
  529. mui.ajax('http://120.27.222.26/app_reportmanage_unflod', {
  530. data: {
  531. 'etype': 'cbd',
  532. 'equip_id': equipId,
  533. },
  534. dataType: 'json', //服务器返回json格式数据
  535. type: 'post', //HTTP请求类型
  536. timeout: 10000, //超时时间设置为10秒;
  537. beforeSend: function() {
  538. plus.nativeUI.showWaiting('请求中...');
  539. },
  540. complete: function() {
  541. plus.nativeUI.closeWaiting();
  542. },
  543. success: function(data) {
  544. // console.log(JSON.stringify(data))
  545. upl_time = data.upl_time
  546. $('#upl_time').html(upl_time);
  547. // var discern = data.discern
  548. // if(!discern){
  549. // $('#wormChart').show();
  550. // }else{
  551. // $('#wormChart').hide();
  552. // }
  553. equipName = data.equip_name || '无'
  554. var stat = eval('(' + data.cbd_data + ')');
  555. // $('#at').html((stat.at / 10).toFixed(1)); //温度
  556. // $('#ah').html((stat.ah / 10).toFixed(1));
  557. // $('#hrt').html(stat.hrt);
  558. var rps = stat.rps == 0 ? '正常':'雨控';
  559. $('#rps').html(rps);
  560. var tps = stat.tps == 0 ? '正常':'温控';
  561. $('#tps').html(tps);
  562. var lps = stat.lps == 0 ? '夜晚':'白天';
  563. $('#lps').html(lps);
  564. if (stat.lng > 999) {
  565. var lng = Math.floor(stat.lng / 100) + ((stat.lng % 100) / 60);
  566. var lat = Math.floor(stat.lat / 100) + ((stat.lat % 100) / 60);
  567. } else {
  568. var lng = Number(stat.lng);
  569. var lat = Number(stat.lat);
  570. }
  571. //判断当前设备是否具备图片识别功能
  572. console.log(data.discern)
  573. if (data.discern == 1) {
  574. console.log('全都有')
  575. localStorage.setItem('possess', '1')
  576. $('#wormChart').show()
  577. } else if (data.discern == 2) {
  578. //有统计无识别
  579. localStorage.setItem('possess', '0')
  580. console.log('有统计无识别')
  581. $('#wormChart').show()
  582. } else if (data.discern == 0) {
  583. console.log('啥都没')
  584. localStorage.setItem('possess', '0')
  585. $('#wormChart').hide()
  586. }
  587. $('#lng').html(lng.toFixed(4));
  588. $('#lat').html(lat.toFixed(4));
  589. //进度条
  590. var p1 = new Progress({
  591. el: 'circleChart1', //canvas元素id
  592. deg: (stat.ah / 10).toFixed(1), //填入你的数据 如data
  593. currtype:'%RH',
  594. timer: 10, //绘制时间
  595. lineWidth: 10, //线宽
  596. lineBgColor: '#f4f3f3', //底圆颜色
  597. lineColor: '#1f8aff', //动态圆颜色
  598. textColor: '#1f8aff', //文本颜色
  599. fontSize: 20, //字体大小
  600. circleRadius: 100 //圆半径
  601. });
  602. var p2 = new Progress({
  603. el: 'circleChart2', //canvas元素id
  604. deg: (stat.at / 10).toFixed(1), //填入你的数据 如data
  605. currtype:'℃',
  606. timer: 10, //绘制时间
  607. lineWidth: 10, //线宽
  608. lineBgColor: '#f4f3f3', //底圆颜色
  609. lineColor: '#1f8aff', //动态圆颜色
  610. textColor: '#1f8aff', //文本颜色
  611. fontSize: 20, //字体大小
  612. circleRadius: 100 //圆半径
  613. });
  614. var p3 = new Progress({
  615. el: 'circleChart3', //canvas元素id
  616. deg: stat.hrt, //填入你的数据 如data
  617. currtype:'℃',
  618. timer: 10, //绘制时间
  619. lineWidth: 10, //线宽
  620. lineBgColor: '#f4f3f3', //底圆颜色
  621. lineColor: '#1f8aff', //动态圆颜色
  622. textColor: '#1f8aff', //文本颜色
  623. fontSize: 20, //字体大小
  624. circleRadius: 100 //圆半径
  625. });
  626. },
  627. error: function(xhr, type, errorThrown) {
  628. mui.toast('数据请求失败');
  629. }
  630. })
  631. }
  632. </script>
  633. </body>
  634. </html>