detect_statistics.ftl 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  6. <meta name="apple-mobile-web-app-capable" content="yes">
  7. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  8. <#include "/base/add_base.ftl">
  9. <title>维修统计</title>
  10. <style>
  11. .my-title{font-weight: 500;padding-left: 15px;position: relative;}
  12. .my-title:after{content: '';position: absolute;left: 0;top:12%;width: 3px;height: 80%;background: #32a3d8;}
  13. .my-input{padding: 8px 5px;width: 80%;border:1px solid rgba(0,0,0,.1);}
  14. .my-input-date{padding: 8px 10px;border:1px solid rgba(0,0,0,.1);width: 80%;background: url(http://s.iamberry.com/images/rili-1.png) 98.5% center no-repeat; background-size:auto 50%;}
  15. .input-box{margin: 18px 0;}
  16. .input-dic{float: left;margin:5px 10px 0 0;font-size: 12px;}
  17. .add-list{list-style-type: none;padding: 10px;background-color: #f5f5f5;width: 60%;float: left;margin: 0;}
  18. .add-list>li{margin: 10px 0;}
  19. .my-textarea{padding: 5px 10px;width: 65%;border:1px solid rgba(0,0,0,.1);margin-left: 12.5%;}
  20. .my-btn-reset{padding: 10px 20px;width: 150px; background-color: #fff;color: #32a3d8;border: 1px solid #32a3d8;cursor:pointer;margin: 10px 10px 0 10px;}
  21. .my-btn-submit{padding: 10px 20px;width: 130px; background-color: #50a2ea;color: #fff;border: 1px solid #50a2ea;cursor:pointer;margin: 10px auto 0 auto;display: block;}
  22. .my-select{border: 1px solid rgba(0,0,0,.1);padding:6px 50px 6px 15px;height: 34px; -webkit-appearance:none;appearance:none;background: url(/common/images/pts/select-11.png) right center no-repeat;background-size:auto 100%;}
  23. input[type=radio]{-webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/radio-1.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
  24. input[type=radio]:checked{-webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/radio-2.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
  25. .huanhang{ float:left}
  26. .check-box, .radio-box{padding-left: 0;}
  27. .my-close{position:absolute;right: 0.5em;top: 0.45em;width:0.15em;height:1em;background: #333;-webkit-transform: rotate(45deg);transform: rotate(45deg);display: inline-block;}
  28. .my-close:after{content: "";position: absolute;top: 0;left: 0;width:0.15em;height:1em;background: #333;-webkit-transform: rotate(270deg);transform: rotate(270deg);}
  29. .b-close{position: relative; display: inline-block;margin: 2px 0; padding:4px 1em 4px 4px; width: 100px;background: #f0f0f0;border: 1px solid rgba(0,0,0,.1);border-radius: 5px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;cursor: pointer;}
  30. .close-box{width: 500px;margin-left: 15px;margin-top: -15px;}
  31. </style>
  32. </head>
  33. <body>
  34. <div id="main" style="width: 1400px;height:500px;"></div>
  35. <div class="input-box" style="height: 45px;" class="dataTableStatis" seachType="3">
  36. <label class="form-label col-2 col-sm-2 huanhang" style="text-align: right;margin: 10px 0px;font-weight: bold;font-size: 23px;">判定结果</label>
  37. <div class="formControls col-2 col-sm-2 text-c huanhang" style="margin-left: -4%;margin: 10px 0px 10px -19px;">
  38. <input class="my-input beginTime" style="width: 90%;" type="text" value="" name="beginTime_1" id="beginTime_1" onClick="WdatePicker({skin:'whyGreen',maxDate:'%y-%M',dateFmt: 'yyyy-MM',onpicked: getResetDateByTime,oncleared :getResetDateByTime })" placeholder="请选择月份(开始)" readonly="readonly"/>
  39. </div>
  40. <div class="formControls col-2 col-sm-2 text-c huanhang" style="margin-left: -4%;margin: 10px 0px 10px -19px;">
  41. <input class="my-input endTime" style="width: 90%;" type="text" value="" name="endTime_1" id="endTime_1" onClick="WdatePicker({skin:'whyGreen',maxDate:'%y-%M',dateFmt: 'yyyy-MM',minDate:beginTime_1.value,onpicked: getResetDateByTime,oncleared :getResetDateByTime })" placeholder="请选择月份(结束)" readonly="readonly"/>
  42. </div>
  43. <div class="formControls col-2 col-sm-2 huanhang" style="margin: 10px 0px;line-height: 34px;">
  44. <select id="configSelect_1" name="configSelect_1" class="chosen configSelect" style="">
  45. <option value="">判断结果</option>
  46. <#if (criticalResultList?size > 0)>
  47. <#list criticalResultList as config>
  48. <option value="${config.configId!""}">${config.configDetectContent!""}</option>
  49. </#list>
  50. </#if>
  51. </select>
  52. </div>
  53. </div>
  54. <div id="main3" style="width: 1400px;height:500px;"></div>
  55. <div class="input-box" style="height: 45px;" class="dataTableStatis" seachType="2">
  56. <label class="form-label col-2 col-sm-2 huanhang" style="text-align: right;margin: 10px 0px;font-weight: bold;font-size: 23px;">故障原因</label>
  57. <div class="formControls col-2 col-sm-2 text-c huanhang" style="margin-left: -4%;margin: 10px 0px 10px -19px;">
  58. <input class="my-input beginTime" style="width: 90%;" type="text" value="" name="beginTime_2" id="beginTime_2" onClick="WdatePicker({skin:'whyGreen',maxDate:'%y-%M',dateFmt: 'yyyy-MM',onpicked: getResetDateByTime,oncleared :getResetDateByTime })" placeholder="请选择月份(开始)" readonly="readonly"/>
  59. </div>
  60. <div class="formControls col-2 col-sm-2 text-c huanhang" style="margin-left: -4%;margin: 10px 0px 10px -19px;">
  61. <input class="my-input endTime" style="width: 90%;" type="text" value="" name="endTime_2" id="endTime_2" onClick="WdatePicker({skin:'whyGreen',maxDate:'%y-%M',dateFmt: 'yyyy-MM',minDate:beginTime_2.value,onpicked: getResetDateByTime,oncleared :getResetDateByTime })" placeholder="请选择月份(结束)" readonly="readonly"/>
  62. </div>
  63. <div class="formControls col-2 col-sm-2 huanhang" style="margin: 10px 0px;line-height: 34px;">
  64. <select id="configSelect_2" name="configSelect_2" class="chosen configSelect" style="">
  65. <option value="">故障原因</option>
  66. <#if (causeIssueList?size > 0)>
  67. <#list causeIssueList as config>
  68. <option value="${config.configId!""}">${config.configDetectContent!""}</option>
  69. </#list>
  70. </#if>
  71. </select>
  72. </div>
  73. </div>
  74. <div id="main4" style="width: 1400px;height:500px;"></div>
  75. <div class="input-box" style="height: 45px;" class="dataTableStatis" seachType="5">
  76. <label class="form-label col-2 col-sm-2 huanhang" style="text-align: right;margin: 10px 0px;font-weight: bold;font-size: 23px;">原因分析</label>
  77. <div class="formControls col-2 col-sm-2 text-c huanhang" style="margin-left: -4%;margin: 10px 0px 10px -19px;">
  78. <input class="my-input beginTime" style="width: 90%;" type="text" value="" name="beginTime_3" id="beginTime_3" onClick="WdatePicker({skin:'whyGreen',maxDate:'%y-%M',dateFmt: 'yyyy-MM',onpicked: getResetDateByTime,oncleared :getResetDateByTime })" placeholder="请选择月份(开始)" readonly="readonly"/>
  79. </div>
  80. <div class="formControls col-2 col-sm-2 text-c huanhang" style="margin-left: -4%;margin: 10px 0px 10px -19px;">
  81. <input class="my-input endTime" style="width: 90%;" type="text" value="" name="endTime_3" id="endTime_3" onClick="WdatePicker({skin:'whyGreen',maxDate:'%y-%M',dateFmt: 'yyyy-MM',minDate:beginTime_3.value,onpicked: getResetDateByTime,oncleared :getResetDateByTime })" placeholder="请选择月份(结束)" readonly="readonly"/>
  82. </div>
  83. <div class="formControls col-2 col-sm-2 huanhang" style="margin: 10px 0px;line-height: 34px;">
  84. <select id="configSelect_3" name="configSelect_3" class="chosen configSelect" style="">
  85. <option value="">原因分析</option>
  86. <#if (causeAnalysisList?size > 0)>
  87. <#list causeAnalysisList as config>
  88. <option value="${config.configId!""}">${config.configDetectContent!""}</option>
  89. </#list>
  90. </#if>
  91. </select>
  92. </div>
  93. </div>
  94. <div id="main5" style="width: 1400px;height:500px;"></div>
  95. </body>
  96. <script type="text/javascript" src="${path}/common/lib/echarts/3.8/echarts.common.min.js"></script>
  97. <script type="text/javascript" src="${path}/common/lib/echarts/3.8/echarts.min.js"></script>
  98. <script type="text/javascript" src="${path}/common/lib/echarts/3.8/macarons.js"></script>
  99. <script type="text/javascript" src="${path}/common/lib/My97DatePicker/4.8/WdatePicker.js"></script>
  100. <script>
  101. var myChart = echarts.init(document.getElementById('main'));
  102. //type = 3
  103. var myChart3 = echarts.init(document.getElementById('main3'));
  104. //type = 2
  105. var myChart4 = echarts.init(document.getElementById('main4'));
  106. //type = 5
  107. var myChart5 = echarts.init(document.getElementById('main5'));
  108. $(function () {
  109. detectStatisticsData();
  110. detectStatisticsJudgement(3,"","","");
  111. detectStatisticsJudgement(2,"","","");
  112. detectStatisticsJudgement(5,"","","");
  113. })
  114. /**
  115. * 当月统计
  116. * @param state
  117. */
  118. function detectStatisticsData() {
  119. $.ajax({
  120. type: "POST",
  121. data: {},
  122. url: "${path}/admin/detect/detect_statistics_data",
  123. success: function(data){
  124. if (data.returnCode == 200) {
  125. var numArray = new Array();
  126. var monthArray = new Array();
  127. for (var i=0;i<data.returnMsg.complaintDetectInfoList.length;i++){
  128. var countNum = data.returnMsg.complaintDetectInfoList[i].countNum;
  129. numArray.push(countNum);
  130. var detectProduction = data.returnMsg.complaintDetectInfoList[i].detectProduction;
  131. if(detectProduction == "未知"){
  132. var flag = false;
  133. for (var k=0;k<monthArray.length;k++){
  134. if(monthArray[k] == '未知'){
  135. var otherMonthNum = numArray[k];
  136. numArray[k] = numArray[k]+countNum;
  137. flag = true;
  138. }
  139. }
  140. if(!flag){
  141. monthArray.push('未知');
  142. }
  143. }else{
  144. var newDate = formatDate(detectProduction,"yyyy年MM月");
  145. monthArray.push(newDate.substring(2,newDate.length))
  146. }
  147. }
  148. var newNumArray = new Array();
  149. for (var i=0;i<monthArray.length;i++){
  150. newNumArray.push(numArray[i]);
  151. }
  152. var option = {
  153. title : {
  154. text: '本月故障机器',
  155. subtext: ''
  156. },
  157. tooltip : {
  158. trigger: 'axis'
  159. },
  160. legend: {
  161. data:['本月故障机器']
  162. },
  163. toolbox: {
  164. show : true,
  165. feature : {
  166. // dataView : {show: true, readOnly: false},
  167. // magicType : {show: true, type: ['line', 'bar']},
  168. // restore : {show: true},
  169. // saveAsImage : {show: true}
  170. }
  171. },
  172. calculable : true,
  173. xAxis : [
  174. {
  175. type : 'category',
  176. data : monthArray
  177. }
  178. ],
  179. yAxis : [
  180. {
  181. type : 'value'
  182. }
  183. ],
  184. series : {
  185. name:'本月故障机器',
  186. type:'bar',
  187. data:newNumArray,
  188. // barWidth : 10%,
  189. markPoint : {
  190. data : [
  191. {type : 'max', name: '最大值'},
  192. {type : 'min', name: '最小值'}
  193. ]
  194. }
  195. // ,markLine : {
  196. // data : [
  197. // {type : 'average', name: '平均值'}
  198. // ]
  199. // }
  200. }
  201. };
  202. // 使用刚指定的配置项和数据显示图表。
  203. myChart.setOption(option);
  204. }else{
  205. layer.msg("获取信息失败!", {icon: 5, time: 3000});
  206. }
  207. },
  208. error: function(XmlHttpRequest, textStatus, errorThrown){
  209. }
  210. });
  211. }
  212. /**
  213. * @param configType
  214. * @param beginTime
  215. * @param endTime
  216. * @param echartsObj
  217. */
  218. function detectStatisticsJudgement(configType,beginTime,endTime,configId,) {
  219. var echartsObj = null;
  220. switch (parseInt(configType)){
  221. case 3:
  222. echartsObj = myChart3;
  223. break;
  224. case 2:
  225. echartsObj = myChart4;
  226. break;
  227. case 5:
  228. echartsObj = myChart5;
  229. break;
  230. default:
  231. break
  232. }
  233. if(!isEmpty(echartsObj)){
  234. return false;
  235. }
  236. $.ajax({
  237. type: "POST",
  238. data: {
  239. configType : configType,
  240. beginTime : beginTime,
  241. endTime : endTime,
  242. configId :configId
  243. },
  244. url: "${path}/admin/detect/detect_statistics_one",
  245. success: function(data){
  246. if (data.returnCode == 200) {
  247. var menuDate = new Array();
  248. for (var i=0;i<data.returnMsg.detectConfigList.length;i++) {
  249. var configDetectContent = data.returnMsg.detectConfigList[i].configDetectContent;
  250. menuDate.push(configDetectContent);
  251. }
  252. var monthArray = new Array();
  253. for (var j=0;j<data.returnMsg.detectProductionList.length;j++) {
  254. var detectProduction = data.returnMsg.detectProductionList[j].detectProduction;
  255. if(detectProduction == "未知"){
  256. monthArray.push(detectProduction);
  257. }else{
  258. var newDate = formatDate(detectProduction,"yyyy-MM");
  259. monthArray.push(newDate.substring(2,newDate.length));
  260. }
  261. }
  262. var seriesArray = new Array();
  263. for (var k=0;k<data.returnMsg.list.length;k++) {
  264. var newDate = data.returnMsg.list[k];
  265. var dateName,dateAttr;
  266. var configId = data.returnMsg.cinfigList[k];
  267. for(var m in newDate) {
  268. dateName = m;
  269. dateAttr = newDate[m];
  270. }
  271. var objArray = new Array();
  272. for(var q=0;q<dateAttr.length;q++){
  273. var obj = {
  274. value:dateAttr[q],
  275. name:dateName,
  276. configId:configId,
  277. configName:dateName
  278. }
  279. objArray.push(obj);
  280. }
  281. var series = {
  282. name:dateName,
  283. type:'bar',
  284. data:objArray,
  285. markLine : {
  286. // data : [
  287. // {type : 'average', name: '平均值'}
  288. // ]
  289. }
  290. }
  291. seriesArray.push(series);
  292. }
  293. var option = {
  294. title : {
  295. text: '',
  296. subtext: ''
  297. },
  298. tooltip : {
  299. trigger: 'axis'
  300. },
  301. legend: {
  302. data:menuDate
  303. },
  304. toolbox: {
  305. show : true,
  306. feature : {
  307. // dataView : {show: true, readOnly: false},
  308. // magicType : {show: true, type: ['line', 'bar']},
  309. // restore : {show: true},
  310. // saveAsImage : {show: true}
  311. }
  312. },
  313. calculable : true,
  314. xAxis : [
  315. {
  316. type : 'category',
  317. data : monthArray
  318. }
  319. ],
  320. yAxis : [
  321. {
  322. type : 'value'
  323. }
  324. ],
  325. series :seriesArray
  326. };
  327. // 使用刚指定的配置项和数据显示图表。
  328. echartsObj.setOption(option,true);
  329. echartsObj.on('click', function (params) {
  330. toSelectConfigStatistic(params.data);
  331. // alert("单击了"+params.componentType+"x轴标签");
  332. //param具体包含的参数见 https://blog.csdn.net/allenjay11/article/details/76033232
  333. // updatePage(option.xAxis.data[params.dataIndex],params.value);
  334. // refresh();
  335. });
  336. }else{
  337. layer.msg("获取信息失败!", {icon: 5, time: 3000});
  338. }
  339. },
  340. error: function(XmlHttpRequest, textStatus, errorThrown){
  341. }
  342. });
  343. }
  344. $('.configSelect').change(function() {
  345. getResetDate($(this));
  346. });
  347. $('.beginTime').change(function() {
  348. getResetDate($(this));
  349. });
  350. $('.endTime').change(function() {
  351. getResetDate($(this));
  352. });
  353. /**
  354. * 选择数据后重置数据
  355. */
  356. function getResetDateByTime() {
  357. var id = this.id;
  358. var $node = $("#"+id);
  359. // var $thisDiv = $node.parents(".dataTableStatis");
  360. var $thisDiv = $node.parent().parent();
  361. var type = $thisDiv.attr("seachType");
  362. var beginTime = $thisDiv.find(".beginTime").val();
  363. var endTime = $thisDiv.find(".endTime").val();
  364. var configName = $thisDiv.find(".configSelect").find("option:selected").text();
  365. var configId = $thisDiv.find(".configSelect").val();
  366. detectStatisticsJudgement(type,beginTime,endTime,configId);
  367. }
  368. /**
  369. * 选择数据后重置数据
  370. */
  371. function getResetDate($node) {
  372. // var $thisDiv = $node.parents(".dataTableStatis");
  373. var $thisDiv = $node.parent().parent();
  374. var type = $thisDiv.attr("seachType");
  375. var beginTime = $thisDiv.find(".beginTime").val();
  376. var endTime = $thisDiv.find(".endTime").val();
  377. var configName = $thisDiv.find(".configSelect").find("option:selected").text();
  378. var configId = $thisDiv.find(".configSelect").val();
  379. detectStatisticsJudgement(type,beginTime,endTime,configId);
  380. }
  381. /**
  382. * 到单独配置页面
  383. */
  384. function toSelectConfigStatistic(data) {
  385. var configId = data.configId;
  386. window.location.href= "${path}/admin/detect/to_select_config_statistic?configId="+configId;
  387. }
  388. $('.chosen').chosen({
  389. no_results_text: "没有找到结果!",//搜索无结果时显示的提示
  390. search_contains:true, //关键字模糊搜索。设置为true,只要选项包含搜索词就会显示;设置为false,则要求从选项开头开始匹配
  391. allow_single_deselect:true, //单选下拉框是否允许取消选择。如果允许,选中选项会有一个x号可以删除选项
  392. disable_search: false, //禁用搜索。设置为true,则无法搜索选项。
  393. disable_search_threshold: 0, //当选项少等于于指定个数时禁用搜索。
  394. inherit_select_classes: true, //是否继承原下拉框的样式类,此处设为继承
  395. placeholder_text_single: '', //单选选择框的默认提示信息,当选项为空时会显示。如果原下拉框设置了data-placeholder,会覆盖这里的值。
  396. width: '200px', //设置chosen下拉框的宽度。即使原下拉框本身设置了宽度,也会被width覆盖。
  397. max_shown_results: 1000, //下拉框最大显示选项数量
  398. display_disabled_options: false,
  399. single_backstroke_delete: false, //false表示按两次删除键才能删除选项,true表示按一次删除键即可删除
  400. case_sensitive_search: false, //搜索大小写敏感。此处设为不敏感
  401. group_search: false, //选项组是否可搜。此处搜索不可搜
  402. include_group_label_in_selected: true //选中选项是否显示选项分组。false不显示,true显示。默认false。
  403. });
  404. </script>
  405. </html>