statistics.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <!DOCTYPE HTML>
  2. <html xmlns:th="http://www.thymeleaf.org"
  3. xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
  4. layout:decorate="~{admin/common/common}">
  5. <head>
  6. <title>项目统计</title>
  7. </head>
  8. <body layout:fragment="content">
  9. <div class="page-container">
  10. <form class="form form-horizontal" id="form-add" th:action="@{/projectDeclaration/statistics}" th:method="get">
  11. <input type="hidden" id="chartType" name="chartType"/>
  12. <div class="row cl highlight">
  13. <span><a onclick="streetDeclaerNum(1)" class="btn btn-info radius"> 各街道申报数量</a></span>
  14. <span><a onclick="projectCategoryRate()" class="btn btn-info radius"> 项目类别占比</a></span>
  15. <span><a onclick="projectDevelopmentTrend()" class="btn btn-info radius"> 项目发展趋势</a></span>
  16. <span><a onclick="streetReportingTrend()" class="btn btn-info radius"> 各街道申报趋势</a></span>
  17. <span><a onclick="filingSituation()" class="btn btn-info radius"> 各类别项目申请情况</a></span>
  18. </div>
  19. <div class="row cl">
  20. <span><a onclick="getDataByYear(1)" class="btn btn-info radius">最近1年</a></span>
  21. <span><a onclick="getDataByYear(2)" class="btn btn-info radius">最近2年</a></span>
  22. <span><a onclick="getDataByYear(5)" class="btn btn-info radius">最近5年</a></span>
  23. <label>开始日期:</label><input type="text" class="input-text" style="width:200px" readonly placeholder="请输入开始日期"
  24. id="begin_date" name="begin_date" th:value="${condition.begin_date}"/>
  25. <label>结束日期:</label><input type="text" class="input-text" style="width:200px" readonly placeholder="请输入结束日期"
  26. id="end_date" name="end_date" th:value="${condition.end_date}"/>
  27. <!--<button type="submit" class="btn btn-primary" hidden>-->
  28. <!--<i class="Hui-iconfont">&#xe665;</i>-->
  29. <!--搜索-->
  30. <!--</button>-->
  31. <span><a onclick="streetDeclaer()" class="btn btn-info radius"><i
  32. class="Hui-iconfont">&#xe665;</i> 搜索</a></span>
  33. </div>
  34. <div class="chart_data mt-20 col-xs-12 col-sm-12" style="height: 500px; width: 800px;" id="container"></div>
  35. <div class="row cl">
  36. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
  37. <button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;返回&nbsp;&nbsp;</button>
  38. </div>
  39. </div>
  40. </form>
  41. </div>
  42. <script th:src="@{https://code.highcharts.com/5.0.12/highcharts.js}"></script>
  43. <script th:src="@{https://code.highcharts.com/5.0.12/highcharts-more.js}"></script>
  44. <script th:src="@{https://code.highcharts.com/maps/5.0.12/modules/map.js}"></script>
  45. <script type="text/javascript" th:src="@{/js/lib/highcharts/highcharts.js}"></script>
  46. <script type="text/javascript" th:src="@{/js/lib/highcharts/exporting.js}"></script>
  47. <script type="text/javascript" th:src="@{/js/lib/highcharts/highcharts-zh_CN.js}"></script>
  48. <style>
  49. a.cur {
  50. background: #0a6999;
  51. color: #fff;
  52. }
  53. </style>
  54. <script th:inline="javascript">
  55. $(function () {
  56. $(".highlight a").click(function () {
  57. $(this).addClass("cur").parent().siblings().find("a").removeClass("cur")
  58. })
  59. // var date=new Date;
  60. // var year=date.getFullYear();
  61. // var month=date.getMonth()+1;
  62. // month =(month<10 ? "0"+month:month);
  63. // var currentDate = (year.toString()+"-"+month.toString());
  64. streetDeclaerNum("");
  65. //initPie(currentDate);
  66. //initPolyline();
  67. });
  68. var date = new Date();
  69. var year = date.getFullYear();
  70. //初始化柱形图
  71. var initColumn = {
  72. chart: {
  73. renderTo: 'container',
  74. type: 'column',
  75. events: {
  76. render: function () {
  77. }
  78. }
  79. },
  80. title: {
  81. text: (year - 1) + '年各街道申报项目数'
  82. },
  83. subtitle: {
  84. text: null
  85. },
  86. xAxis: {
  87. crosshair: true
  88. },
  89. yAxis: {
  90. min: 0,
  91. allowDecimals: false,
  92. title: {
  93. text: '',
  94. align: 'high'
  95. },
  96. labels: {
  97. overflow: 'justify'
  98. }
  99. },
  100. tooltip: {
  101. valueSuffix: ' 个'
  102. },
  103. plotOptions: {
  104. column: {
  105. pointPadding: 0.2,
  106. borderWidth: 0
  107. }
  108. },
  109. series: []
  110. };
  111. //初始化饼图
  112. var initPie = {
  113. chart: {
  114. renderTo: 'container',
  115. plotBackgroundColor: null,
  116. plotBorderWidth: null,
  117. plotShadow: false
  118. },
  119. title: {
  120. text: '项目类别占比'
  121. },
  122. tooltip: {
  123. headerFormat: '',
  124. pointFormat: '{point.name}: <b>{point.y}</b> %'
  125. },
  126. plotOptions: {
  127. pie: {
  128. allowPointSelect: true,
  129. cursor: 'pointer',
  130. dataLabels: {
  131. enabled: true,
  132. // 通过 format 或 formatter 来格式化数据标签显示
  133. //format: '值: {point.y} 占比 {point.percentage} %',
  134. formatter: function () {
  135. //this 为当前的点(扇区)对象,可以通过 console.log(this) 来查看详细信息
  136. return '<span"> ' + this.point.name + ':' + this.y + '%</span>';
  137. }
  138. },
  139. showInLegend: true // 显示在图例中
  140. }
  141. },
  142. series: [{
  143. type: 'pie',
  144. name: ''
  145. }]
  146. };
  147. //各街道申报数量
  148. function streetDeclaerNum(type) {
  149. $("#chartType").val(1);
  150. $.ajax({
  151. type: "post",
  152. dataType: "json",
  153. data: {
  154. begin_date: $("#begin_date").val(),
  155. end_date: $("#end_date").val(),
  156. type: type
  157. },
  158. url: pagePath + "/projectDeclaration/streetDeclaerNum/",
  159. success: function (result) {
  160. console.log(result);
  161. if (result.success) {
  162. var chart = new Highcharts.Chart(initColumn);
  163. var categoies = [];
  164. var row1 = [];
  165. var row2 = [];
  166. var value = result.obj;
  167. for (var j = 0; j < value.length; j++) {
  168. categoies.push(value[j].street_name);
  169. row1.push(value[j].declare_num);
  170. row2.push(value[j].declare_success);
  171. }
  172. chart.xAxis[0].categories = categoies;
  173. chart.addSeries({
  174. name: "申报项目",
  175. data: row1
  176. });
  177. chart.addSeries({
  178. name: "申报成功",
  179. data: row2
  180. });
  181. } else {
  182. errorMessage(result.message);
  183. }
  184. },
  185. error: function () {
  186. errorMessage('系统错误!');
  187. }
  188. });
  189. }
  190. //项目类别占比
  191. function projectCategoryRate(type) {
  192. $("#chartType").val(2);
  193. $.ajax({
  194. type: "post",
  195. dataType: "json",
  196. data: {
  197. begin_date: $("#begin_date").val(),
  198. end_date: $("#end_date").val(),
  199. type: type
  200. },
  201. url: pagePath + "/projectDeclaration/projectCategoryRate",
  202. success: function (result) {
  203. console.log(result);
  204. if (result.success) {
  205. var value = result.obj;
  206. var data = [];
  207. for (var j = 0; j < value.length; j++) {
  208. data.push({"name": value[j].project_type_name, "y": value[j].category_rate});
  209. }
  210. console.log(data);
  211. var chart = new Highcharts.Chart(initPie);
  212. chart.series[0].setData(data);
  213. } else {
  214. errorMessage(result.message);
  215. }
  216. },
  217. error: function () {
  218. errorMessage('系统错误!');
  219. }
  220. });
  221. }
  222. //项目发展趋势
  223. function projectDevelopmentTrend(type) {
  224. $("#chartType").val(3);
  225. var initPolyline = Highcharts.chart('container', {
  226. title: {
  227. text: '项目发展趋势',
  228. x: -20 //center
  229. },
  230. // subtitle: {
  231. // text: 'Source: WorldClimate.com',
  232. // x: -20
  233. // },
  234. xAxis: {
  235. categories: []
  236. },
  237. yAxis: {
  238. title: {
  239. text: '项目申请次数(次)'
  240. },
  241. plotLines: [{
  242. value: 0,
  243. width: 1,
  244. color: '#808080'
  245. }]
  246. },
  247. tooltip: {
  248. valueSuffix: '次'
  249. },
  250. legend: {
  251. layout: 'vertical',
  252. align: 'right',
  253. verticalAlign: 'middle',
  254. borderWidth: 0
  255. },
  256. series: []
  257. });
  258. $.ajax({
  259. type: "post",
  260. dataType: "json",
  261. data: {
  262. begin_date: $("#begin_date").val(),
  263. end_date: $("#end_date").val(),
  264. type: type
  265. },
  266. url: pagePath + "/projectDeclaration/projectDevelopmentTrend",
  267. success: function (result) {
  268. console.log(result);
  269. if (result.success) {
  270. var obj = result.obj;
  271. var map = obj.polyline_data;
  272. //x轴年份
  273. var categories = obj.year_array;
  274. initPolyline.xAxis[0].categories = categories;
  275. //展示数据
  276. for (var key in map) {
  277. initPolyline.addSeries({
  278. name: key,
  279. data: map[key]
  280. });
  281. }
  282. } else {
  283. errorMessage(result.message);
  284. }
  285. },
  286. error: function () {
  287. errorMessage('系统错误!');
  288. }
  289. });
  290. }
  291. //各街道申报趋势
  292. function streetReportingTrend(type) {
  293. $("#chartType").val(4);
  294. var initPolyline = Highcharts.chart('container', {
  295. title: {
  296. text: '各街道申报趋势',
  297. x: -20 //center
  298. },
  299. // subtitle: {
  300. // text: 'Source: WorldClimate.com',
  301. // x: -20
  302. // },
  303. xAxis: {
  304. categories: []
  305. },
  306. yAxis: {
  307. title: {
  308. text: '申请次数(次)'
  309. },
  310. min: 0,
  311. allowDecimals: false,
  312. },
  313. tooltip: {
  314. valueSuffix: '次'
  315. },
  316. legend: {
  317. layout: 'vertical',
  318. align: 'right',
  319. verticalAlign: 'middle',
  320. borderWidth: 0
  321. },
  322. series: []
  323. });
  324. $.ajax({
  325. type: "post",
  326. dataType: "json",
  327. data: {
  328. begin_date: $("#begin_date").val(),
  329. end_date: $("#end_date").val(),
  330. type: type
  331. },
  332. url: pagePath + "/projectDeclaration/streetReportingTrend",
  333. success: function (result) {
  334. console.log(result);
  335. if (result.success) {
  336. var obj = result.obj;
  337. var map = obj.polyline_data;
  338. //x轴年份
  339. var categories = obj.year_array;
  340. initPolyline.xAxis[0].categories = categories;
  341. //展示数据
  342. for (var key in map) {
  343. initPolyline.addSeries({
  344. name: key,
  345. data: map[key]
  346. });
  347. }
  348. } else {
  349. errorMessage(result.message);
  350. }
  351. },
  352. error: function () {
  353. errorMessage('系统错误!');
  354. }
  355. });
  356. }
  357. //各类别项目申请情况
  358. function filingSituation(type) {
  359. $("#chartType").val(5);
  360. $.ajax({
  361. type: "post",
  362. dataType: "json",
  363. data: {
  364. begin_date: $("#begin_date").val(),
  365. end_date: $("#end_date").val(),
  366. type: type
  367. },
  368. url: pagePath + "/projectDeclaration/filingSituation/",
  369. success: function (result) {
  370. console.log(result);
  371. if (result.success) {
  372. var chart = new Highcharts.Chart(initColumn);
  373. var categoies = [];
  374. var row1 = [];
  375. var row2 = [];
  376. var value = result.obj;
  377. for (var j = 0; j < value.length; j++) {
  378. categoies.push(value[j].project_type_name);
  379. row1.push(value[j].declare_num);
  380. row2.push(value[j].declare_success);
  381. }
  382. chart.xAxis[0].categories = categoies;
  383. chart.addSeries({
  384. name: "申报项目",
  385. data: row1
  386. });
  387. chart.addSeries({
  388. name: "申报成功",
  389. data: row2
  390. });
  391. } else {
  392. errorMessage(result.message);
  393. }
  394. },
  395. error: function () {
  396. errorMessage('系统错误!');
  397. }
  398. });
  399. }
  400. function streetDeclaer() {
  401. var chartType = $("#chartType").val();
  402. if (chartType == 1) {
  403. streetDeclaerNum();
  404. }
  405. if (chartType == 2) {
  406. projectCategoryRate();
  407. }
  408. if (chartType == 3) {
  409. projectDevelopmentTrend();
  410. }
  411. if (chartType == 4) {
  412. streetReportingTrend();
  413. }
  414. if (chartType == 5) {
  415. filingSituation();
  416. }
  417. }
  418. function getDataByYear(type) {
  419. var chartType = $("#chartType").val();
  420. $("#begin_date").val("");
  421. $("#end_date").val("");
  422. if (chartType == 1) {
  423. streetDeclaerNum(type);
  424. }
  425. if (chartType == 2) {
  426. projectCategoryRate(type);
  427. }
  428. if (chartType == 3) {
  429. projectDevelopmentTrend(type);
  430. }
  431. if (chartType == 4) {
  432. streetReportingTrend(type);
  433. }
  434. if (chartType == 5) {
  435. filingSituation(type);
  436. }
  437. }
  438. /**
  439. * 取消
  440. */
  441. function removeIframe() {
  442. var index = parent.layer.getFrameIndex(window.name);
  443. parent.layer.close(index);
  444. }
  445. laydate.render({
  446. elem: '#begin_date', //指定元素
  447. // min: 0
  448. });
  449. laydate.render({
  450. elem: '#end_date', //指定元素
  451. // min: 0
  452. });
  453. </script>
  454. </body>
  455. </html>