resistance.jsp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: SamRichard
  4. Date: 2019/7/19
  5. Time: 14:28
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
  9. <%@ page import="org.apache.commons.lang3.StringUtils" %>
  10. <%
  11. String IMEI = (String)request.getParameter("IMEI");
  12. String strStartTime = (String)request.getParameter("starttime");
  13. String strEndTime = (String)request.getParameter("endtime");
  14. String strName = (String)request.getParameter("name");
  15. String strIdx = (String)request.getParameter("idx");
  16. String strIdxname = (String)request.getParameter("idxname");
  17. String strSrc = (String)request.getParameter("src");
  18. %>
  19. <!DOCTYPE html>
  20. <html lang="ch">
  21. <head>
  22. <title>阻力监控后台管理系统-设备管理</title>
  23. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  24. <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
  25. <meta content="" name="description"/>
  26. <meta content="" name="author"/>
  27. <!-- BEGIN GLOBAL MANDATORY STYLES -->
  28. <link href="css/gfonts1.css" rel="stylesheet" type="text/css">
  29. <link href="css/font-awesome.min.css" rel="stylesheet" type="text/css">
  30. <link href="css/simple-line-icons.min.css" rel="stylesheet">
  31. <link href="css/bootstrap-editable.css" rel="stylesheet">
  32. <link href="css/bootstrap.min.css" rel="stylesheet">
  33. <!-- END GLOBAL MANDATORY STYLES -->
  34. <!-- BEGIN PAGE LEVEL STYLES -->
  35. <!-- BEGIN THEME STYLES -->
  36. <link href="css/components.css" id="style_components" rel="stylesheet">
  37. <link href="css/plugins.css" rel="stylesheet" type="text/css">
  38. <link href="css/layout.css" rel="stylesheet" type="text/css">
  39. <link href="css/default.css" rel="stylesheet" id="style_color">
  40. <link href="css/sweetalert.css" rel="stylesheet">
  41. <link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
  42. <!-- END THEME STYLES -->
  43. <!-- js -->
  44. <!-- Load jQuery -->
  45. <script src="js/jquery.min.js"></script>
  46. <script src="js/jquery-migrate.min.js" type="text/javascript"></script>
  47. <!-- IMPORTANT! Load jquery-ui-1.10.3.custom.min.js before bootstrap.js to fix bootstrap tooltip conflict with jquery ui tooltip -->
  48. <script src="js/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>
  49. <script src="js/bootstrap.min.js" type="text/javascript"></script>
  50. <!-- BEGIN PAGE LEVEL SCRIPTS -->
  51. <script src="js/metronic.js"></script>
  52. <script src="js/scripts/layout.js"></script>
  53. <script src="js/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
  54. <script src="js/jquery.slimscroll.min.js" type="text/javascript"></script>
  55. <script src="js/jquery.blockui.min.js" type="text/javascript"></script>
  56. <script src="js/jquery.cokie.min.js" type="text/javascript"></script>
  57. <script src="js/jquery.uniform.min.js" type="text/javascript"></script>
  58. <script src="js/morris.min.js" type="text/javascript"></script>
  59. <script src="js/raphael-min.js" type="text/javascript"></script>
  60. <script src="js/jquery.sparkline.min.js" type="text/javascript"></script>
  61. <script src="js/highcharts/highcharts.js"></script>
  62. <script src="js/highcharts/boost.js"></script>
  63. <!-- END CORE PLUGINS -->
  64. <script src="js/sweetalert.min.js"></script>
  65. <script src="js/jBox.min.js"></script>
  66. <script src="js/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
  67. <script src="js/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
  68. <!--<script src="js/highcharts/no-data-to-display.js"></script>-->
  69. <!-- END PAGE LEVEL PLUGINS -->
  70. <!-- test -->
  71. <link rel="shortcut icon" href="favicon.ico">
  72. </head>
  73. <!-- END HEAD -->
  74. <!-- BEGIN BODY -->
  75. <!-- DOC: Apply "page-header-menu-fixed" class to set the mega menu fixed -->
  76. <!-- DOC: Apply "page-header-top-fixed" class to set the top menu fixed -->
  77. <body>
  78. <!-- BEGIN PAGE CONTAINER -->
  79. <div class="page-container">
  80. <!-- BEGIN PAGE HEAD -->
  81. <jsp:include page="frame_head.jsp" flush="false"></jsp:include>
  82. <!-- END PAGE HEAD -->
  83. <!-- BEGIN PAGE CONTENT -->
  84. <div class="page-content">
  85. <div class="container">
  86. <form class="row form-inline" id="t2" style="margin-top: 15px;margin-bottom: 14px;padding-left: 15px;">
  87. <fieldset>
  88. <div class="col-md-3 form-group">
  89. <div class="input-group date form_datetime" data-date="2016/09/16 00:00:00+0800" data-date-format="yyyy-mm-dd hh:ii:00" data-link-field="dtp_input1" id="starttime">
  90. <input class="form-control" size="16" type="text" value="" readonly>
  91. <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
  92. <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
  93. </div>
  94. <input type="hidden" id="dtp_input1" value="" /><br/>
  95. </div>
  96. <div class="col-md-3 form-group">
  97. <div class="input-group date form_datetime" data-date="2016-09-16T05:25:07+08:00" data-date-format="yyyy-mm-dd hh:ii:00" data-link-field="dtp_input2" id="endtime">
  98. <input class="form-control" size="16" type="text" value="" readonly>
  99. <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
  100. <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
  101. </div>
  102. <input type="hidden" id="dtp_input2" value="" /><br/>
  103. </div>
  104. <div class="col-md-3 form-group">
  105. <button id="getresistance" type="button" class="btn btn-primary btn-block">查看</button>
  106. </div>
  107. <div class="col-md-3 form-group">
  108. <button type="button" class="btn btn-primary btn-block" onclick="JavaScript:history.go(-1)">返回</button>
  109. </div>
  110. </fieldset>
  111. </form>
  112. <div id="resistance" class="col-md-12"></div>
  113. </div>
  114. </div>
  115. <!-- END PAGE CONTENT -->
  116. <!-- END PAGE CONTENT -->
  117. <jsp:include page="frame_tail.jsp" flush="false"></jsp:include>
  118. <!-- END PAGE CONTAINER -->
  119. </div>
  120. <!--
  121. <script src="js/jquery-3.1.1.min.js"></script>
  122. <script src="js/bootstrap.min.js"></script>
  123. <script src="js/sweetalert2.min.js"></script>
  124. -->
  125. <!-- for IE support -->
  126. <!--
  127. <script src="js/es6-promise.auto.min.js"></script>
  128. -->
  129. <script>
  130. (function($){
  131. Date.prototype.format = function(fmt) {
  132. var o = {
  133. "M+" : this.getMonth()+1, //月份
  134. "d+" : this.getDate(), //日
  135. "h+" : this.getHours(), //小时
  136. "m+" : this.getMinutes(), //分
  137. "s+" : this.getSeconds(), //秒
  138. "q+" : Math.floor((this.getMonth()+3)/3), //季度
  139. "S" : this.getMilliseconds() //毫秒
  140. };
  141. if(/(y+)/.test(fmt)) {
  142. fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
  143. }
  144. for(var k in o) {
  145. if(new RegExp("("+ k +")").test(fmt)){
  146. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
  147. }
  148. }
  149. return fmt;
  150. }
  151. }(jQuery));
  152. jQuery(document).ready(function () {
  153. //Metronic.init(); // init metronic core components
  154. //Layout.init(); // init current layout
  155. // IE8 Fix: function.bind polyfill
  156. if (Metronic.isIE8() && !Function.prototype.bind) {
  157. Function.prototype.bind = function (oThis) {
  158. if (typeof this !== "function") {
  159. // closest thing possible to the ECMAScript 5 internal IsCallable function
  160. throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
  161. }
  162. var aArgs = Array.prototype.slice.call(arguments, 1),
  163. fToBind = this,
  164. fNOP = function () {
  165. },
  166. fBound = function () {
  167. return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
  168. aArgs.concat(Array.prototype.slice.call(arguments)));
  169. };
  170. fNOP.prototype = this.prototype;
  171. fBound.prototype = new fNOP();
  172. return fBound;
  173. };
  174. }
  175. });
  176. //设置中文
  177. Highcharts.setOptions({
  178. lang:{
  179. contextButtonTitle:"图表导出菜单",
  180. decimalPoint:".",
  181. downloadJPEG:"下载JPEG图片",
  182. downloadPDF:"下载PDF文件",
  183. downloadPNG:"下载PNG文件",
  184. downloadSVG:"下载SVG文件",
  185. drillUpText:"返回 {series.name}",
  186. loading:"加载中",
  187. months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
  188. noData:"没有数据",
  189. numericSymbols: [ "千" , "兆" , "G" , "T" , "P" , "E"],
  190. printChart:"打印图表",
  191. resetZoom:"恢复缩放",
  192. resetZoomTitle:"恢复图表",
  193. //shortMonths: [ "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec"],
  194. shortMonths: [ "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "11" , "12"],
  195. thousandsSep:",",
  196. weekdays: ["星期一", "星期二", "星期三", "星期三", "星期四", "星期五", "星期六","星期天"]
  197. },
  198. global : {
  199. useUTC : false
  200. }
  201. });
  202. //图表属性
  203. var options = {
  204. chart: {
  205. zoomType: 'x',
  206. },
  207. boost: {
  208. useGPUTranslations: true
  209. },
  210. title: {
  211. text: '受力曲线图'
  212. },
  213. subtitle : {
  214. text: ""
  215. },
  216. xAxis: {
  217. type: 'datetime',
  218. dateTimeLabelFormats: {
  219. millisecond: '%H:%M:%S.%L',
  220. second: '%H:%M:%S',
  221. minute: '%H:%M',
  222. hour: '%H:%M',
  223. day: '%m-%d',
  224. week: '%m-%d',
  225. month: '%Y-%m',
  226. year: '%Y'
  227. },
  228. },
  229. tooltip: {
  230. //shared: true,
  231. //crosshairs: true,
  232. positioner : function(width, height, point)
  233. {
  234. return {
  235. x : point.plotX,
  236. y : 1
  237. }
  238. },
  239. dateTimeLabelFormats: {
  240. millisecond: '%H:%M:%S.%L',
  241. second: '%H:%M:%S',
  242. minute: '%H:%M',
  243. hour: '%H:%M',
  244. day: '%Y-%m-%d',
  245. week: '%m-%d',
  246. month: '%Y-%m',
  247. year: '%Y'
  248. }
  249. },
  250. yAxis: {
  251. minRange:1000,
  252. title: {
  253. text: '受力值(N)'
  254. }
  255. },
  256. legend: {
  257. enabled: true
  258. },
  259. credits:{
  260. enabled:false, // 版权信息
  261. text:"杭州慧景科技股份有限公司",
  262. href:"http://www.hzhjkj.com/"
  263. },
  264. // animation:禁止动画
  265. // enableMouseTracking:禁止鼠标移到线上时,线条变粗
  266. plotOptions: {
  267. series: {
  268. animation: false,
  269. marker: {
  270. enabled: false,
  271. states: {
  272. hover: {
  273. enabled: false
  274. }
  275. }
  276. },
  277. //enableMouseTracking: false,
  278. turboThreshold:100000
  279. }
  280. },// 优化性能损耗结束
  281. series: [],
  282. };
  283. var starttime = '<%=strStartTime%>';
  284. var endtime = '<%=strEndTime%>';
  285. var $startime = $("#starttime");
  286. var $endtime = $("#endtime");
  287. //初始函数
  288. $(function () {
  289. if (<%=StringUtils.isNotBlank(strStartTime) && StringUtils.isNotBlank(strEndTime)%>) {
  290. var a = new Date(Date.parse('<%=strStartTime%>'.replace(/-/g, "/")));
  291. var b = new Date(Date.parse('<%=strEndTime%>'.replace(/-/g, "/")));
  292. $startime.datetimepicker('update', a);
  293. $endtime.datetimepicker('update', b);
  294. //setType(a, b);
  295. //$("#timequickselect").val(6).trigger("change");
  296. } else {
  297. var date = new Date();
  298. date.setSeconds(0);
  299. date.setMilliseconds(0);
  300. date.setMinutes(date.getMinutes() + 10);
  301. var date2 = new Date(date.getTime());
  302. date2.setHours(0);
  303. date2.setMinutes(0);
  304. date2.setSeconds(0);
  305. $startime.datetimepicker('update', date2);
  306. $endtime.datetimepicker('update', date);
  307. starttime = date2.toISOString();
  308. endtime = date.toISOString();
  309. };
  310. })
  311. var chart;
  312. //请求数据
  313. function queryData() {
  314. /*
  315. $.getJSON('https://data.jianshukeji.com/jsonp?filename=json/usdeur.json&callback=?', function (data) {
  316. options.subtitle.text = (new Date(starttime)).toLocaleDateString();
  317. options.series[0].data = data;
  318. chart = new Highcharts.chart("resistance", options);
  319. });
  320. */
  321. var urladdr = "getresistance.cpp?starttime=" + encodeURI(starttime) + "&endtime=" + encodeURI(endtime) +
  322. "&IMEI=<%=IMEI%>&name=" + encodeURI("<%=strName%>") + "&idx=" + <%=strIdx%> + "&timestamp=" + new Date().getTime() +
  323. "&idxname=" + encodeURI("<%=strIdxname%>");
  324. $.ajax({
  325. url: urladdr,
  326. type: "get",
  327. dataType: "json",
  328. success: function (data) {
  329. if (data === null || data.series.length === 0) {
  330. clearTimeout(refreshtimer);
  331. swal({
  332. type: 'success',
  333. title: '无数据',
  334. timer: 3000
  335. }).then(
  336. function () {
  337. },
  338. // handling the promise rejection
  339. function (dismiss) {
  340. if (dismiss === 'timer') {
  341. console.log('I was closed by the timer')
  342. }
  343. }
  344. )
  345. return;
  346. }
  347. options.subtitle.text = (new Date(starttime)).toLocaleDateString();
  348. var otext = "受力曲线图";
  349. if ('<%=strIdxname%>' != 'undefined')
  350. otext = '<%=strIdxname%>_' + otext;
  351. if ('<%=strName%>' != 'undefined')
  352. otext = '<%=strName%>_' + otext;
  353. options.title.text = otext;
  354. if (<%=strSrc == null%> && data.series.length >= 3 && data.series[2].data != undefined)
  355. {
  356. //算数平均数
  357. var myArray = new Array();
  358. var len = data.series[2].data.length / 2;
  359. var dt = data.series[2].data;
  360. for (var i = 0; i < len; i++)
  361. {
  362. myArray[i] = dt[i * 2];
  363. myArray[i].y = (dt[i * 2].y + dt[i * 2 + 1].y) / 2;
  364. }
  365. data.series[2].data = myArray;
  366. }
  367. options.series = data.series;
  368. if (chart) {
  369. chart = null;
  370. }
  371. chart = new Highcharts.chart("resistance", options);
  372. }
  373. })
  374. }
  375. $("#getresistance").click(function () {
  376. starttime = $("#dtp_input1").val();
  377. endtime = $("#dtp_input2").val();
  378. queryData();
  379. })
  380. </script>
  381. </body>
  382. <!-- END BODY -->
  383. </html>