statistics.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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. var begin_date = $("#begin_date").val();
  151. var end_date =$("#end_date").val();
  152. if (end_date == "") end_date = getDay(0)
  153. if (begin_date == "") {
  154. if (type > 0){
  155. begin_date = getDay(type)
  156. } else {
  157. begin_date = getDay(1)
  158. }
  159. }
  160. initColumn.title.text = begin_date +"~"+ end_date +' 各街道申报项目数';
  161. $.ajax({
  162. type: "post",
  163. dataType: "json",
  164. data: {
  165. begin_date: begin_date,
  166. end_date: end_date,
  167. type: type
  168. },
  169. url: pagePath + "/projectDeclaration/streetDeclaerNum/",
  170. success: function (result) {
  171. console.log(result);
  172. if (result.success) {
  173. var chart = new Highcharts.Chart(initColumn);
  174. var categoies = [];
  175. var row1 = [];
  176. var row2 = [];
  177. var value = result.obj;
  178. for (var j = 0; j < value.length; j++) {
  179. categoies.push(value[j].street_name);
  180. row1.push(value[j].declare_num);
  181. row2.push(value[j].declare_success);
  182. }
  183. chart.xAxis[0].categories = categoies;
  184. chart.addSeries({
  185. name: "申报项目",
  186. data: row1
  187. });
  188. chart.addSeries({
  189. name: "申报成功",
  190. data: row2
  191. });
  192. } else {
  193. errorMessage(result.message);
  194. }
  195. },
  196. error: function () {
  197. errorMessage('系统错误!');
  198. }
  199. });
  200. }
  201. function getDay(minusYear) {
  202. var currentday = new Date(new Date(new Date().toLocaleDateString()).getTime());
  203. return (currentday.getFullYear()-minusYear) + "-" + ((currentday.getMonth() + 1) < 10 ? "0" + (currentday.getMonth() + 1):(currentday.getMonth() + 1))+ "-" + (currentday.getDate() < 10 ? "0" + currentday.getDate():currentday.getDate())
  204. }
  205. //项目类别占比
  206. function projectCategoryRate(type) {
  207. $("#chartType").val(2);
  208. $.ajax({
  209. type: "post",
  210. dataType: "json",
  211. data: {
  212. begin_date: $("#begin_date").val(),
  213. end_date: $("#end_date").val(),
  214. type: type
  215. },
  216. url: pagePath + "/projectDeclaration/projectCategoryRate",
  217. success: function (result) {
  218. console.log(result);
  219. if (result.success) {
  220. var value = result.obj;
  221. var data = [];
  222. for (var j = 0; j < value.length; j++) {
  223. data.push({"name": value[j].project_type_name, "y": value[j].category_rate});
  224. }
  225. console.log(data);
  226. var chart = new Highcharts.Chart(initPie);
  227. chart.series[0].setData(data);
  228. } else {
  229. errorMessage(result.message);
  230. }
  231. },
  232. error: function () {
  233. errorMessage('系统错误!');
  234. }
  235. });
  236. }
  237. //项目发展趋势
  238. function projectDevelopmentTrend(type) {
  239. $("#chartType").val(3);
  240. var initPolyline = Highcharts.chart('container', {
  241. title: {
  242. text: '项目发展趋势',
  243. x: -20 //center
  244. },
  245. // subtitle: {
  246. // text: 'Source: WorldClimate.com',
  247. // x: -20
  248. // },
  249. xAxis: {
  250. categories: []
  251. },
  252. yAxis: {
  253. title: {
  254. text: '项目申请次数(次)'
  255. },
  256. plotLines: [{
  257. value: 0,
  258. width: 1,
  259. color: '#808080'
  260. }]
  261. },
  262. tooltip: {
  263. valueSuffix: '次'
  264. },
  265. legend: {
  266. layout: 'vertical',
  267. align: 'right',
  268. verticalAlign: 'middle',
  269. borderWidth: 0
  270. },
  271. series: []
  272. });
  273. $.ajax({
  274. type: "post",
  275. dataType: "json",
  276. data: {
  277. begin_date: $("#begin_date").val(),
  278. end_date: $("#end_date").val(),
  279. type: type
  280. },
  281. url: pagePath + "/projectDeclaration/projectDevelopmentTrend",
  282. success: function (result) {
  283. console.log(result);
  284. if (result.success) {
  285. var obj = result.obj;
  286. var map = obj.polyline_data;
  287. //x轴年份
  288. var categories = obj.year_array;
  289. initPolyline.xAxis[0].categories = categories;
  290. //展示数据
  291. for (var key in map) {
  292. initPolyline.addSeries({
  293. name: key,
  294. data: map[key]
  295. });
  296. }
  297. } else {
  298. errorMessage(result.message);
  299. }
  300. },
  301. error: function () {
  302. errorMessage('系统错误!');
  303. }
  304. });
  305. }
  306. //各街道申报趋势
  307. function streetReportingTrend(type) {
  308. $("#chartType").val(4);
  309. var initPolyline = Highcharts.chart('container', {
  310. title: {
  311. text: '各街道申报趋势',
  312. x: -20 //center
  313. },
  314. // subtitle: {
  315. // text: 'Source: WorldClimate.com',
  316. // x: -20
  317. // },
  318. xAxis: {
  319. categories: []
  320. },
  321. yAxis: {
  322. title: {
  323. text: '申请次数(次)'
  324. },
  325. min: 0,
  326. allowDecimals: false,
  327. },
  328. tooltip: {
  329. valueSuffix: '次'
  330. },
  331. legend: {
  332. layout: 'vertical',
  333. align: 'right',
  334. verticalAlign: 'middle',
  335. borderWidth: 0
  336. },
  337. series: []
  338. });
  339. $.ajax({
  340. type: "post",
  341. dataType: "json",
  342. data: {
  343. begin_date: $("#begin_date").val(),
  344. end_date: $("#end_date").val(),
  345. type: type
  346. },
  347. url: pagePath + "/projectDeclaration/streetReportingTrend",
  348. success: function (result) {
  349. console.log(result);
  350. if (result.success) {
  351. var obj = result.obj;
  352. var map = obj.polyline_data;
  353. //x轴年份
  354. var categories = obj.year_array;
  355. initPolyline.xAxis[0].categories = categories;
  356. //展示数据
  357. for (var key in map) {
  358. initPolyline.addSeries({
  359. name: key,
  360. data: map[key]
  361. });
  362. }
  363. } else {
  364. errorMessage(result.message);
  365. }
  366. },
  367. error: function () {
  368. errorMessage('系统错误!');
  369. }
  370. });
  371. }
  372. //各类别项目申请情况
  373. function filingSituation(type) {
  374. $("#chartType").val(5);
  375. $.ajax({
  376. type: "post",
  377. dataType: "json",
  378. data: {
  379. begin_date: $("#begin_date").val(),
  380. end_date: $("#end_date").val(),
  381. type: type
  382. },
  383. url: pagePath + "/projectDeclaration/filingSituation/",
  384. success: function (result) {
  385. console.log(result);
  386. if (result.success) {
  387. var chart = new Highcharts.Chart(initColumn);
  388. var categoies = [];
  389. var row1 = [];
  390. var row2 = [];
  391. var value = result.obj;
  392. for (var j = 0; j < value.length; j++) {
  393. categoies.push(value[j].project_type_name);
  394. row1.push(value[j].declare_num);
  395. row2.push(value[j].declare_success);
  396. }
  397. chart.xAxis[0].categories = categoies;
  398. chart.addSeries({
  399. name: "申报项目",
  400. data: row1
  401. });
  402. chart.addSeries({
  403. name: "申报成功",
  404. data: row2
  405. });
  406. } else {
  407. errorMessage(result.message);
  408. }
  409. },
  410. error: function () {
  411. errorMessage('系统错误!');
  412. }
  413. });
  414. }
  415. function streetDeclaer() {
  416. var chartType = $("#chartType").val();
  417. if (chartType == 1) {
  418. streetDeclaerNum();
  419. }
  420. if (chartType == 2) {
  421. projectCategoryRate();
  422. }
  423. if (chartType == 3) {
  424. projectDevelopmentTrend();
  425. }
  426. if (chartType == 4) {
  427. streetReportingTrend();
  428. }
  429. if (chartType == 5) {
  430. filingSituation();
  431. }
  432. }
  433. function getDataByYear(type) {
  434. var chartType = $("#chartType").val();
  435. $("#begin_date").val("");
  436. $("#end_date").val("");
  437. if (chartType == 1) {
  438. streetDeclaerNum(type);
  439. }
  440. if (chartType == 2) {
  441. projectCategoryRate(type);
  442. }
  443. if (chartType == 3) {
  444. projectDevelopmentTrend(type);
  445. }
  446. if (chartType == 4) {
  447. streetReportingTrend(type);
  448. }
  449. if (chartType == 5) {
  450. filingSituation(type);
  451. }
  452. }
  453. /**
  454. * 取消
  455. */
  456. function removeIframe() {
  457. var index = parent.layer.getFrameIndex(window.name);
  458. parent.layer.close(index);
  459. }
  460. laydate.render({
  461. elem: '#begin_date', //指定元素
  462. // min: 0
  463. });
  464. laydate.render({
  465. elem: '#end_date', //指定元素
  466. // min: 0
  467. });
  468. </script>
  469. </body>
  470. </html>