Commit 6c60709b90ea31d52a266295cc85fdd20ecfbf6f
1 parent
4e840439
SQL注入漏洞;
Showing
1 changed file
with
141 additions
and
64 deletions
src/main/java/com/bsth/server_rs/bigdata/BigdataService.java
| ... | ... | @@ -125,9 +125,11 @@ public class BigdataService { |
| 125 | 125 | } |
| 126 | 126 | public Map<String, Long> getEndtime(String date){ |
| 127 | 127 | Map<String, Long> map=new HashMap<String,Long>(); |
| 128 | + List<String> objList = new ArrayList<String>(); | |
| 128 | 129 | String sql="select xl,endtime from bsth_c_calc_count " |
| 129 | - + " where date='"+date+"' "; | |
| 130 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 130 | + + " where date = ? "; | |
| 131 | + objList.add(date); | |
| 132 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 131 | 133 | new RowMapper<Map<String, Object>>(){ |
| 132 | 134 | @Override |
| 133 | 135 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -225,13 +227,15 @@ public class BigdataService { |
| 225 | 227 | @GET |
| 226 | 228 | @Path("/line/company/{companyId}") |
| 227 | 229 | public List<Map<String, Object>> findLineByCompany(@PathParam("companyId") String companyId) { |
| 230 | + List<String> objList = new ArrayList<String>(); | |
| 228 | 231 | String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level," |
| 229 | 232 | + " a.shanghai_linecode, a.nature from " |
| 230 | 233 | + " bsth_c_line a left join bsth_c_line_config b " |
| 231 | 234 | + " on a.id=b.line where " |
| 232 | 235 | + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 " |
| 233 | - + " and a.remove=0 and a.company = '"+companyId+"'"; | |
| 234 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 236 | + + " and a.remove=0 and a.company = ?"; | |
| 237 | + objList.add(companyId); | |
| 238 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 235 | 239 | new RowMapper<Map<String, Object>>(){ |
| 236 | 240 | @Override |
| 237 | 241 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -303,13 +307,15 @@ public class BigdataService { |
| 303 | 307 | @GET |
| 304 | 308 | @Path("/line/{lineCode}") |
| 305 | 309 | public List<Map<String, Object>> findLineByCode(@PathParam("lineCode") String lineCode) { |
| 310 | + List<String> objList = new ArrayList<String>(); | |
| 306 | 311 | String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level," |
| 307 | 312 | + " a.shanghai_linecode, a.nature from " |
| 308 | 313 | + " bsth_c_line a left join bsth_c_line_config b " |
| 309 | 314 | + " on a.id=b.line where " |
| 310 | 315 | + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 " |
| 311 | - + " and a.remove=0 and a.line_code = '"+lineCode+"'"; | |
| 312 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 316 | + + " and a.remove=0 and a.line_code = ?"; | |
| 317 | + objList.add(lineCode); | |
| 318 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 313 | 319 | new RowMapper<Map<String, Object>>(){ |
| 314 | 320 | @Override |
| 315 | 321 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -381,13 +387,15 @@ public class BigdataService { |
| 381 | 387 | @GET |
| 382 | 388 | @Path("/line/level/{level}") |
| 383 | 389 | public List<Map<String, Object>> findLineByLevle(@PathParam("level") String level) { |
| 390 | + List<String> objList = new ArrayList<String>(); | |
| 384 | 391 | String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level," |
| 385 | 392 | + " a.shanghai_linecode, a.nature from " |
| 386 | 393 | + " bsth_c_line a left join bsth_c_line_config b " |
| 387 | 394 | + " on a.id=b.line where " |
| 388 | 395 | + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 " |
| 389 | - + " and a.remove=0 and a.level = '"+level+"'"; | |
| 390 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 396 | + + " and a.remove=0 and a.level = ?"; | |
| 397 | + objList.add(level); | |
| 398 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 391 | 399 | new RowMapper<Map<String, Object>>(){ |
| 392 | 400 | @Override |
| 393 | 401 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -467,15 +475,18 @@ public class BigdataService { |
| 467 | 475 | @Path("/lineCar/{type}/date/{date}") |
| 468 | 476 | public List<Map<String, Object>> findLineCarByDate(@PathParam("type") String type,@PathParam("date") String date) { |
| 469 | 477 | String sql=""; |
| 478 | + List<String> objList = new ArrayList<String>(); | |
| 470 | 479 | if(type.equals("all")){ |
| 471 | 480 | sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhccz as jhcc,t.sjcc" |
| 472 | - + " from bsth_c_calc_count t where t.date='"+date+"'"; | |
| 481 | + + " from bsth_c_calc_count t where t.date = ?"; | |
| 482 | + objList.add(date); | |
| 473 | 483 | } |
| 474 | 484 | if(type.equals("actual")){ |
| 475 | 485 | sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhcc as jhcc,t.sjcc" |
| 476 | - + " from bsth_c_calc_count t where t.date='"+date+"'"; | |
| 486 | + + " from bsth_c_calc_count t where t.date = ?"; | |
| 487 | + objList.add(date); | |
| 477 | 488 | } |
| 478 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 489 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 479 | 490 | new RowMapper<Map<String, Object>>(){ |
| 480 | 491 | @Override |
| 481 | 492 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -500,18 +511,23 @@ public class BigdataService { |
| 500 | 511 | public List<Map<String, Object>> findLineCarByDateLine(@PathParam("type") String type,@PathParam("date") String date, |
| 501 | 512 | @PathParam("line") String line) { |
| 502 | 513 | String sql=""; |
| 514 | + List<String> objList = new ArrayList<String>(); | |
| 503 | 515 | if(type.equals("all")){ |
| 504 | 516 | sql="select t.gsdm,t.xl,t.xl_name,t.jhccz as jhcc,t.sjcc" |
| 505 | - + " from bsth_c_calc_count t where t.date='"+date+"'" | |
| 506 | - + " and xl ='"+line+"'"; | |
| 517 | + + " from bsth_c_calc_count t where t.date = ?" | |
| 518 | + + " and xl = ?"; | |
| 519 | + objList.add(date); | |
| 520 | + objList.add(line); | |
| 507 | 521 | } |
| 508 | 522 | if(type.equals("actual")){ |
| 509 | 523 | sql="select t.gsdm,t.xl,t.xl_name,t.jhcc as jhcc,t.sjcc" |
| 510 | - + " from bsth_c_calc_count t where t.date='"+date+"'" | |
| 511 | - + " and xl ='"+line+"'"; | |
| 524 | + + " from bsth_c_calc_count t where t.date = ?" | |
| 525 | + + " and xl = ?"; | |
| 526 | + objList.add(date); | |
| 527 | + objList.add(line); | |
| 512 | 528 | |
| 513 | 529 | } |
| 514 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 530 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 515 | 531 | new RowMapper<Map<String, Object>>(){ |
| 516 | 532 | @Override |
| 517 | 533 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -540,15 +556,18 @@ public class BigdataService { |
| 540 | 556 | @Path("/linePerson/{type}/date/{date}") |
| 541 | 557 | public List<Map<String, Object>> findLinePersonByDate(@PathParam("type") String type,@PathParam("date") String date) { |
| 542 | 558 | String sql=""; |
| 559 | + List<String> objList = new ArrayList<String>(); | |
| 543 | 560 | if(type.equals("all")){ |
| 544 | 561 | sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprz as jhpr,t.sjpr" |
| 545 | - + " from bsth_c_calc_count t where t.date='"+date+"'"; | |
| 562 | + + " from bsth_c_calc_count t where t.date = ?"; | |
| 563 | + objList.add(date); | |
| 546 | 564 | } |
| 547 | 565 | if(type.equals("actual")){ |
| 548 | 566 | sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprss as jhpr,t.sjpr" |
| 549 | - + " from bsth_c_calc_count t where t.date='"+date+"'"; | |
| 567 | + + " from bsth_c_calc_count t where t.date = ?"; | |
| 568 | + objList.add(date); | |
| 550 | 569 | } |
| 551 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 570 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 552 | 571 | new RowMapper<Map<String, Object>>(){ |
| 553 | 572 | @Override |
| 554 | 573 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -577,17 +596,22 @@ public class BigdataService { |
| 577 | 596 | public List<Map<String, Object>> findLinePersonByDateLine(@PathParam("type") String type,@PathParam("date") String date, |
| 578 | 597 | @PathParam("line") String line) { |
| 579 | 598 | String sql=""; |
| 599 | + List<String> objList = new ArrayList<String>(); | |
| 580 | 600 | if(type.equals("all")){ |
| 581 | 601 | sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprz as jhpr,t.sjpr" |
| 582 | - + " from bsth_c_calc_count t where t.date='"+date+"'" | |
| 583 | - + " and xl ='"+line+"'"; | |
| 602 | + + " from bsth_c_calc_count t where t.date = ?" | |
| 603 | + + " and xl = ?"; | |
| 604 | + objList.add(date); | |
| 605 | + objList.add(line); | |
| 584 | 606 | } |
| 585 | 607 | if(type.equals("actual")){ |
| 586 | 608 | sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprss as jhpr,t.sjpr" |
| 587 | - + " from bsth_c_calc_count t where t.date='"+date+"'" | |
| 588 | - + " and xl ='"+line+"'"; | |
| 609 | + + " from bsth_c_calc_count t where t.date = ?" | |
| 610 | + + " and xl = ?"; | |
| 611 | + objList.add(date); | |
| 612 | + objList.add(line); | |
| 589 | 613 | } |
| 590 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 614 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 591 | 615 | new RowMapper<Map<String, Object>>(){ |
| 592 | 616 | @Override |
| 593 | 617 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -626,17 +650,20 @@ public class BigdataService { |
| 626 | 650 | public List<Map<String, Object>> findLineBcByDate(@PathParam("type") String type, |
| 627 | 651 | @PathParam("date") String date) { |
| 628 | 652 | String sql=""; |
| 653 | + List<String> objList = new ArrayList<String>(); | |
| 629 | 654 | if(type.equals("all")){ |
| 630 | 655 | sql="select t.gsdm,t.xl,t.xl_name,t.jhbcz as jhbc,t.jhzgfbcz as jhzgfbc," |
| 631 | 656 | + " t.jhwgfbcz as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t" |
| 632 | - + " where t.date='"+date+"'"; | |
| 657 | + + " where t.date = ?"; | |
| 658 | + objList.add(date); | |
| 633 | 659 | } |
| 634 | 660 | if(type.equals("actual")){ |
| 635 | 661 | sql="select t.gsdm,t.xl,t.xl_name,t.jhbc as jhbc,t.jhzgfbcss as jhzgfbc," |
| 636 | 662 | + " t.jhwgfbcss as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t" |
| 637 | - + " where t.date='"+date+"'"; | |
| 663 | + + " where t.date = ?"; | |
| 664 | + objList.add(date); | |
| 638 | 665 | } |
| 639 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 666 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 640 | 667 | new RowMapper<Map<String, Object>>(){ |
| 641 | 668 | @Override |
| 642 | 669 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -663,17 +690,22 @@ public class BigdataService { |
| 663 | 690 | public List<Map<String, Object>> findLineBcByDateLine(@PathParam("type") String type, |
| 664 | 691 | @PathParam("date") String date,@PathParam("line") String line) { |
| 665 | 692 | String sql=""; |
| 693 | + List<String> objList = new ArrayList<String>(); | |
| 666 | 694 | if(type.equals("all")){ |
| 667 | 695 | sql="select t.gsdm,t.xl,t.xl_name,t.jhbcz as jhbc,t.jhzgfbcz as jhzgfbc," |
| 668 | 696 | + " t.jhwgfbcz as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t " |
| 669 | - + " where t.date='"+date+"' and xl='"+line+"'"; | |
| 697 | + + " where t.date = ? and xl = ?"; | |
| 698 | + objList.add(date); | |
| 699 | + objList.add(line); | |
| 670 | 700 | } |
| 671 | 701 | if(type.equals("actual")){ |
| 672 | 702 | sql="select t.gsdm,t.xl,t.xl_name,t.jhbc as jhbc,t.jhzgfbcss as jhzgfbc," |
| 673 | 703 | + " t.jhwgfbcss as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t" |
| 674 | - + " where t.date='"+date+"' and xl='"+line+"'"; | |
| 704 | + + " where t.date = ? and xl = ?"; | |
| 705 | + objList.add(date); | |
| 706 | + objList.add(line); | |
| 675 | 707 | } |
| 676 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 708 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 677 | 709 | new RowMapper<Map<String, Object>>(){ |
| 678 | 710 | @Override |
| 679 | 711 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -707,17 +739,20 @@ public class BigdataService { |
| 707 | 739 | public List<Map<String, Object>> findLineLcByDate(@PathParam("type") String type, |
| 708 | 740 | @PathParam("date") String date) { |
| 709 | 741 | String sql=""; |
| 742 | + List<String> objList = new ArrayList<String>(); | |
| 710 | 743 | if(type.equals("all")){ |
| 711 | 744 | sql="select t.gsdm,t.xl,t.xl_name,t.jhzglz as jhzlc,t.jhyylcz as jhyylc," |
| 712 | 745 | + " t.jhkslcz as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t" |
| 713 | - + " where t.date='"+date+"'"; | |
| 746 | + + " where t.date = ?"; | |
| 747 | + objList.add(date); | |
| 714 | 748 | } |
| 715 | 749 | if(type.equals("actual")){ |
| 716 | 750 | sql="select t.gsdm,t.xl,t.xl_name,t.jhzgl as jhzlc,t.jhyylc as jhyylc," |
| 717 | 751 | + " t.jhkslc as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t" |
| 718 | - + " where t.date='"+date+"'"; | |
| 752 | + + " where t.date = ?"; | |
| 753 | + objList.add(date); | |
| 719 | 754 | } |
| 720 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 755 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 721 | 756 | new RowMapper<Map<String, Object>>(){ |
| 722 | 757 | @Override |
| 723 | 758 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -757,17 +792,22 @@ public class BigdataService { |
| 757 | 792 | public List<Map<String, Object>> findLineLcByDateLine(@PathParam("type") String type, |
| 758 | 793 | @PathParam("date") String date,@PathParam("line") String line) { |
| 759 | 794 | String sql=""; |
| 795 | + List<String> objList = new ArrayList<String>(); | |
| 760 | 796 | if(type.equals("all")){ |
| 761 | 797 | sql="select t.gsdm,t.xl,t.xl_name,t.jhzglz as jhzlc,t.jhyylcz as jhyylc," |
| 762 | 798 | + " t.jhkslcz as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t" |
| 763 | - + " where t.date='"+date+"' and xl ='"+line+"'"; | |
| 799 | + + " where t.date = ? and xl = ?"; | |
| 800 | + objList.add(date); | |
| 801 | + objList.add(line); | |
| 764 | 802 | } |
| 765 | 803 | if(type.equals("actual")){ |
| 766 | 804 | sql="select t.gsdm,t.xl,t.xl_name,t.jhzgl as jhzlc,t.jhyylc as jhyylc," |
| 767 | 805 | + " t.jhkslc as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t" |
| 768 | - + " where t.date='"+date+"' and xl ='"+line+"'"; | |
| 806 | + + " where t.date = ? and xl = ?"; | |
| 807 | + objList.add(date); | |
| 808 | + objList.add(line); | |
| 769 | 809 | } |
| 770 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 810 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 771 | 811 | new RowMapper<Map<String, Object>>(){ |
| 772 | 812 | @Override |
| 773 | 813 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -811,9 +851,11 @@ public class BigdataService { |
| 811 | 851 | @GET |
| 812 | 852 | @Path("/abnormal/executionRate/date/{date}") |
| 813 | 853 | public List<Map<String, Object>> executionRate(@PathParam("date") String date) { |
| 854 | + List<String> objList = new ArrayList<String>(); | |
| 814 | 855 | String sql="select gs_name,show_date,xl_bm,xl_name from bsth_c_calc_push t" |
| 815 | - + " where t.date='"+date+"' and push_type in ('1','3')"; | |
| 816 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 856 | + + " where t.date = ? and push_type in ('1','3')"; | |
| 857 | + objList.add(date); | |
| 858 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 817 | 859 | new RowMapper<Map<String, Object>>(){ |
| 818 | 860 | @Override |
| 819 | 861 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -833,9 +875,11 @@ public class BigdataService { |
| 833 | 875 | @GET |
| 834 | 876 | @Path("/abnormal/firstAndLast/date/{date}") |
| 835 | 877 | public List<Map<String, Object>> firstAndLast(@PathParam("date") String date) { |
| 878 | + List<String> objList = new ArrayList<String>(); | |
| 836 | 879 | String sql="select gs_name,show_date,xl_bm,xl_name from bsth_c_calc_push t" |
| 837 | - + " where t.date='"+date+"' and push_type in ('2','3')"; | |
| 838 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 880 | + + " where t.date = ? and push_type in ('2','3')"; | |
| 881 | + objList.add(date); | |
| 882 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 839 | 883 | new RowMapper<Map<String, Object>>(){ |
| 840 | 884 | @Override |
| 841 | 885 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -1023,15 +1067,20 @@ public class BigdataService { |
| 1023 | 1067 | @Path("/findByAll/starDate/{starDate}/endDate/{endDate}/line/{line}") |
| 1024 | 1068 | public List<Map<String, Object>> findMinhang(@PathParam("starDate") String starDate, |
| 1025 | 1069 | @PathParam("endDate") String endDate,@PathParam("line") String line) { |
| 1070 | + List<String> objList = new ArrayList<String>(); | |
| 1026 | 1071 | String sql="select xl,xl_name,date,jhszfcs,sjszfczds,jhbc,sjbc,jhcc,sjcc," |
| 1027 | 1072 | + " jhyylc,sjyylc,jhkslc,sjkslc,jhssgfbcs,sjgfbcs,jhssdgbcs," |
| 1028 | 1073 | + " sjdgbcs from bsth_c_calc_count " |
| 1029 | - + " where date>='"+starDate+"' and date<= '"+endDate+"'"; | |
| 1074 | + + " where date >= ? and date <= ?"; | |
| 1075 | + objList.add(starDate); | |
| 1076 | + objList.add(endDate); | |
| 1077 | + | |
| 1030 | 1078 | if(!line.equals("all")){ |
| 1031 | - sql +=" and xl='"+line+"'"; | |
| 1079 | + sql +=" and xl = ?"; | |
| 1080 | + objList.add(line); | |
| 1032 | 1081 | } |
| 1033 | 1082 | |
| 1034 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1083 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 1035 | 1084 | new RowMapper<Map<String, Object>>(){ |
| 1036 | 1085 | @Override |
| 1037 | 1086 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -1067,23 +1116,28 @@ public class BigdataService { |
| 1067 | 1116 | @Path("/findByCompany/{company}/date/{date}") |
| 1068 | 1117 | public List<Map<String, Object>> findByCompany(@PathParam("company") String company, |
| 1069 | 1118 | @PathParam("date") String date) { |
| 1119 | + List<String> objList = new ArrayList<String>(); | |
| 1070 | 1120 | String sql="select t.company as gs_code,t.date,SUM(t.jhcczgf) as jhccs ,SUM(t.sjcczgf) as ccs,AVG(ccl) as ccl" |
| 1071 | 1121 | + " ,SUM(t.sjzgl*1000)/1000 as sum_mileage ,SUM(jcgl*1000)/1000 as airpor_mileage " |
| 1072 | 1122 | + " from (select a.line_code,b.date,a.company,b.jhcczgf,b.sjcczgf," |
| 1073 | 1123 | + " round(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0)),3) as ccl,c.sjzgl ," |
| 1074 | 1124 | + " ifnull(d.sjzgl,0) as jcgl from bsth_c_line a LEFT JOIN " |
| 1075 | - + " (SELECT * from bsth_c_calc_sheet where date='"+date+"') b on a.line_code=b.xl" | |
| 1076 | - + " left join (select * from bsth_c_calc_count where date='"+date+"') c on a.line_code=c.xl " | |
| 1077 | - + " left join (select * from bsth_c_calc_count where date='"+date+"' " | |
| 1125 | + + " (SELECT * from bsth_c_calc_sheet where date = ?) b on a.line_code=b.xl" | |
| 1126 | + + " left join (select * from bsth_c_calc_count where date = ?) c on a.line_code=c.xl " | |
| 1127 | + + " left join (select * from bsth_c_calc_count where date = ? " | |
| 1078 | 1128 | + " and xl_name like '%机场%') d on a.line_code=d.xl " |
| 1079 | 1129 | + " where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl')) t " |
| 1080 | 1130 | + " where t.date is not null "; |
| 1131 | + objList.add(date); | |
| 1132 | + objList.add(date); | |
| 1133 | + objList.add(date); | |
| 1081 | 1134 | if(!company.equals("all")){ |
| 1082 | - sql +=" and t.company='"+company+"'"; | |
| 1135 | + sql +=" and t.company = ?"; | |
| 1136 | + objList.add(company); | |
| 1083 | 1137 | } |
| 1084 | 1138 | sql +=" group by t.company,t.date"; |
| 1085 | 1139 | |
| 1086 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1140 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 1087 | 1141 | new RowMapper<Map<String, Object>>(){ |
| 1088 | 1142 | @Override |
| 1089 | 1143 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -1108,43 +1162,54 @@ public class BigdataService { |
| 1108 | 1162 | SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); |
| 1109 | 1163 | String d=sdf.format(new Date()); |
| 1110 | 1164 | String sql=""; |
| 1165 | + List<String> objList = new ArrayList<String>(); | |
| 1111 | 1166 | if(gs.equals("all")){ |
| 1112 | 1167 | sql ="select x.gsdm,'' as fgsdm,x.smb_zdl,x.zgf_ccl,y.yylc_zxl,y.szfc_zdl,y.bc_zxl from (" |
| 1113 | 1168 | + " select b.gsdm,round(avg(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0))),3)* 100 as zgf_ccl," |
| 1114 | 1169 | + " round(avg(ifnull(b.smbfczdl,0)),3) as smb_zdl from " |
| 1115 | - + " bsth_c_calc_sheet b where b.date like '%"+date+"%' and b.date<'"+d+"' " | |
| 1170 | + + " bsth_c_calc_sheet b where b.date like ? and b.date < ? " | |
| 1116 | 1171 | + " and b.xl in(select a.line_code from bsth_c_line a where " |
| 1117 | 1172 | + " a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) group by b.gsdm ) x " |
| 1118 | 1173 | + " left join (select c.gsdm,round(avg(if(CONVERT(c.yylczxl,DECIMAL(9,2))>100,100,c.yylczxl)),3) as yylc_zxl," |
| 1119 | 1174 | + " round(avg(if(CONVERT(c.szfczdl,DECIMAL(9,2))>100,100,c.szfczdl)),3) as szfc_zdl," |
| 1120 | 1175 | + " round(avg(if(CONVERT(c.bczxl,DECIMAL(9,2))>100,100,c.bczxl)),3) as bc_zxl " |
| 1121 | - + " from bsth_c_calc_count c where c.date like '%"+date+"%' and c.date<'"+d+"' and " | |
| 1176 | + + " from bsth_c_calc_count c where c.date like ? and c.date < ? and " | |
| 1122 | 1177 | + " c.xl in(select a.line_code from bsth_c_line a where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) " |
| 1123 | 1178 | + " group by c.gsdm ) y on x.gsdm=y.gsdm where 1=1 "; |
| 1179 | + objList.add("%"+date+"%"); | |
| 1180 | + objList.add(d); | |
| 1181 | + objList.add("%"+date+"%"); | |
| 1182 | + objList.add(d); | |
| 1124 | 1183 | |
| 1125 | 1184 | }else{ |
| 1126 | 1185 | sql ="select x.gsdm,x.fgsdm,x.smb_zdl,x.zgf_ccl,y.yylc_zxl,y.szfc_zdl,y.bc_zxl from (" |
| 1127 | 1186 | + " select b.gsdm,b.fgsdm,round(avg(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0))),3) * 100 as zgf_ccl," |
| 1128 | 1187 | + " round(avg(ifnull(b.smbfczdl,0)),3) as smb_zdl from " |
| 1129 | - + " bsth_c_calc_sheet b where b.date like '%"+date+"%' and b.date<'"+d+"' " | |
| 1188 | + + " bsth_c_calc_sheet b where b.date like ? and b.date < ? " | |
| 1130 | 1189 | + " and b.xl in(select a.line_code from bsth_c_line a where " |
| 1131 | 1190 | + " a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) group by b.gsdm,b.fgsdm ) x " |
| 1132 | 1191 | + " left join (select c.gsdm,c.fgsdm,round(avg(if(CONVERT(c.yylczxl,DECIMAL(9,2))>100,100,c.yylczxl)),3) as yylc_zxl," |
| 1133 | 1192 | + " round(avg(if(CONVERT(c.szfczdl,DECIMAL(9,2))>100,100,c.szfczdl)),3) as szfc_zdl," |
| 1134 | 1193 | + " round(avg(if(CONVERT(c.bczxl,DECIMAL(9,2))>100,100,c.bczxl)),3) as bc_zxl " |
| 1135 | - + " from bsth_c_calc_count c where c.date like '%"+date+"%' and c.date <'"+d+"' and " | |
| 1194 | + + " from bsth_c_calc_count c where c.date like ? and c.date < ? and " | |
| 1136 | 1195 | + " c.xl in(select a.line_code from bsth_c_line a where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) " |
| 1137 | 1196 | + " group by c.gsdm,c.fgsdm ) y on x.gsdm=y.gsdm and x.fgsdm=y.fgsdm where 1=1 "; |
| 1197 | + objList.add("%"+date+"%"); | |
| 1198 | + objList.add(d); | |
| 1199 | + objList.add("%"+date+"%"); | |
| 1200 | + objList.add(d); | |
| 1138 | 1201 | |
| 1139 | 1202 | } |
| 1140 | 1203 | if(!gs.equals("all")){ |
| 1141 | - sql += " and x.gsdm='"+gs+"'"; | |
| 1204 | + sql += " and x.gsdm = ?"; | |
| 1205 | + objList.add(gs); | |
| 1142 | 1206 | } |
| 1143 | 1207 | |
| 1144 | 1208 | if(!fgs.equals("all")){ |
| 1145 | - sql += " and x.fgsdm='"+fgs+"'"; | |
| 1209 | + sql += " and x.fgsdm = ?"; | |
| 1210 | + objList.add(fgs); | |
| 1146 | 1211 | } |
| 1147 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1212 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 1148 | 1213 | new RowMapper<Map<String, Object>>(){ |
| 1149 | 1214 | @Override |
| 1150 | 1215 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -1172,14 +1237,18 @@ public class BigdataService { |
| 1172 | 1237 | @Path("/basicData/starDate/{starDate}/endDate/{endDate}/line/{line}") |
| 1173 | 1238 | public List<Map<String, Object>> basicData(@PathParam("starDate") String starDate, |
| 1174 | 1239 | @PathParam("endDate") String endDate,@PathParam("line") String line) { |
| 1240 | + List<String> objList = new ArrayList<String>(); | |
| 1175 | 1241 | String sql="select gsdm,fgsdm,xl,xl_name,date,jhbc,sjbc," |
| 1176 | 1242 | + " jhyylc,sjyylc,jhkslc,sjkslc,jhgfbcsz,sjgfbcs,jhdgbcsz," |
| 1177 | 1243 | + " sjdgbcs from bsth_c_calc_count " |
| 1178 | - + " where date>='"+starDate+"' and date<= '"+endDate+"'"; | |
| 1244 | + + " where date >= ? and date <= ?"; | |
| 1245 | + objList.add(starDate); | |
| 1246 | + objList.add(endDate); | |
| 1179 | 1247 | if(!line.equals("all")){ |
| 1180 | - sql +=" and xl='"+line+"'"; | |
| 1248 | + sql +=" and xl = ?"; | |
| 1249 | + objList.add(line); | |
| 1181 | 1250 | } |
| 1182 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1251 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 1183 | 1252 | new RowMapper<Map<String, Object>>(){ |
| 1184 | 1253 | @Override |
| 1185 | 1254 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -1209,14 +1278,18 @@ public class BigdataService { |
| 1209 | 1278 | @Path("/targetData/starDate/{starDate}/endDate/{endDate}/line/{line}") |
| 1210 | 1279 | public List<Map<String, Object>> targetData(@PathParam("starDate") String starDate, |
| 1211 | 1280 | @PathParam("endDate") String endDate,@PathParam("line") String line) { |
| 1281 | + List<String> objList = new ArrayList<String>(); | |
| 1212 | 1282 | String sql="select gsdm,fgsdm,date,xl,xl_name,szfczdl,smbfczdl," |
| 1213 | 1283 | + " round(if(ifnull(sjcczgf/jhcczgf,0)>1,1,ifnull(sjcczgf/jhcczgf,0)),3) * 100 as zgfccl , " |
| 1214 | 1284 | + " round(if(ifnull(sjcc/jhcc,0)>1,1,ifnull(sjcc/jhcc,0)),3) * 100 as ccl from bsth_c_calc_sheet " |
| 1215 | - + " where date>='"+starDate+"' and date<= '"+endDate+"'"; | |
| 1285 | + + " where date >= ? and date <= ?"; | |
| 1286 | + objList.add(starDate); | |
| 1287 | + objList.add(endDate); | |
| 1216 | 1288 | if(!line.equals("all")){ |
| 1217 | - sql +=" and xl='"+line+"'"; | |
| 1289 | + sql +=" and xl = ?"; | |
| 1290 | + objList.add(line); | |
| 1218 | 1291 | } |
| 1219 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1292 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 1220 | 1293 | new RowMapper<Map<String, Object>>(){ |
| 1221 | 1294 | @Override |
| 1222 | 1295 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| ... | ... | @@ -1240,18 +1313,22 @@ public class BigdataService { |
| 1240 | 1313 | @Path("/departureTime/starDate/{starDate}/endDate/{endDate}/line/{line}") |
| 1241 | 1314 | public List<Map<String, Object>> departureTime(@PathParam("starDate") String starDate, |
| 1242 | 1315 | @PathParam("endDate") String endDate,@PathParam("line") String line) { |
| 1316 | + List<String> objList = new ArrayList<String>(); | |
| 1243 | 1317 | String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," |
| 1244 | 1318 | + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," |
| 1245 | 1319 | + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," |
| 1246 | 1320 | + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," |
| 1247 | 1321 | + " jhszfcs,sjszfczds,szfczdl," |
| 1248 | 1322 | + " create_date from bsth_c_calc_count " |
| 1249 | - + " where date>='"+starDate+"' and date<= '"+endDate+"'"; | |
| 1323 | + + " where date >= ? and date <= ?"; | |
| 1324 | + objList.add(starDate); | |
| 1325 | + objList.add(endDate); | |
| 1250 | 1326 | if(!line.equals("all")){ |
| 1251 | - sql +=" and xl='"+line+"'"; | |
| 1327 | + sql +=" and xl = ?"; | |
| 1328 | + objList.add(line); | |
| 1252 | 1329 | } |
| 1253 | 1330 | |
| 1254 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1331 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(), | |
| 1255 | 1332 | new RowMapper<Map<String, Object>>(){ |
| 1256 | 1333 | @Override |
| 1257 | 1334 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ... | ... |