Commit 4a670b6f9f9b9c1bd23cebd1c6d5dee3a63c1950
1 parent
af3beaa5
update
Showing
2 changed files
with
118 additions
and
37 deletions
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
| ... | ... | @@ -11,6 +11,7 @@ import java.util.Collections; |
| 11 | 11 | import java.util.Comparator; |
| 12 | 12 | import java.util.Date; |
| 13 | 13 | import java.util.HashMap; |
| 14 | +import java.util.HashSet; | |
| 14 | 15 | import java.util.Iterator; |
| 15 | 16 | import java.util.List; |
| 16 | 17 | import java.util.Map; |
| ... | ... | @@ -585,7 +586,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 585 | 586 | |
| 586 | 587 | @Override |
| 587 | 588 | public Map<String, Object> timeAndSpeed(Map<String, Object> map) { |
| 588 | - List<Long> ttList = new ArrayList<Long>(); | |
| 589 | + List<Map<String, Object>> ttList = new ArrayList<Map<String, Object>>(); | |
| 589 | 590 | List<ChildTaskPlan> cList = new ArrayList<ChildTaskPlan>(); |
| 590 | 591 | List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); |
| 591 | 592 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| ... | ... | @@ -593,6 +594,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 593 | 594 | Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>(); |
| 594 | 595 | Map<String, List<ChildTaskPlan>> cMap = new HashMap<String, List<ChildTaskPlan>>(); |
| 595 | 596 | Map<String, Object> modelMap = new HashMap<String, Object>(); |
| 597 | + Set<Long> tsSet = new HashSet<Long>(); | |
| 596 | 598 | |
| 597 | 599 | String company = map.get("company").toString(); |
| 598 | 600 | String subCompany = map.get("subCompany").toString(); |
| ... | ... | @@ -616,20 +618,23 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 616 | 618 | |
| 617 | 619 | try { |
| 618 | 620 | |
| 619 | - String sql = "select * from bsth_c_s_sp_info_real where DATE_FORMAT(schedule_date,'%Y-%m-%d') >= '"+startDate+"' and DATE_FORMAT(schedule_date,'%Y-%m-%d') <= '"+endDate+"'"; | |
| 621 | + String where = ""; | |
| 620 | 622 | if(line.length() != 0 && statu.equals("1")){ |
| 621 | - sql += " and xl_bm = '"+line+"'"; | |
| 623 | + where += " and xl_bm = '"+line+"'"; | |
| 622 | 624 | } |
| 623 | 625 | if(lp.length() != 0 && statu.equals("1")){ |
| 624 | - sql += " and lp_name = '"+lp+"'"; | |
| 626 | + where += " and lp_name = '"+lp+"'"; | |
| 625 | 627 | } |
| 626 | 628 | if(company.length() != 0){ |
| 627 | - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; | |
| 629 | + where += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; | |
| 628 | 630 | } |
| 629 | 631 | if(sfqr == 1){ |
| 630 | - sql += " and zdsj >= '"+times1+"' and fcsj <= '"+times2+"'"; | |
| 632 | + where += " and zdsj >= '"+times1+"' and fcsj <= '"+times2+"'"; | |
| 631 | 633 | } |
| 632 | - sql += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks' order by fcsj"; | |
| 634 | + where += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'"; | |
| 635 | + | |
| 636 | + String sql = "select * from bsth_c_s_sp_info_real where DATE_FORMAT(schedule_date,'%Y-%m-%d') >= '"+startDate+"'" | |
| 637 | + + " and DATE_FORMAT(schedule_date,'%Y-%m-%d') <= '"+endDate+"'"+where+""; | |
| 633 | 638 | |
| 634 | 639 | list = jdbcTemplate.query(sql, |
| 635 | 640 | new RowMapper<ScheduleRealInfo>(){ |
| ... | ... | @@ -704,6 +709,65 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 704 | 709 | return schedule; |
| 705 | 710 | } |
| 706 | 711 | }); |
| 712 | + | |
| 713 | + { | |
| 714 | + List<Map<String, String>> temp1 = new ArrayList<Map<String, String>>(); | |
| 715 | + List<Map<String, String>> temp2 = new ArrayList<Map<String, String>>(); | |
| 716 | + sql = "select * from bsth_c_s_sp_info where bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'"; | |
| 717 | + | |
| 718 | + if(startDate.equals(endDate)){ | |
| 719 | + sql += " and schedule_date = '"+startDate+"'"; | |
| 720 | + } else { | |
| 721 | + sql += " and schedule_date >= '"+startDate+"' and schedule_date <= '"+endDate+"'"; | |
| 722 | + } | |
| 723 | + if(line.length() != 0 && statu.equals("1")){ | |
| 724 | + sql += " and xl_bm = '"+line+"'"; | |
| 725 | + } | |
| 726 | + if(company.length() != 0){ | |
| 727 | + sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; | |
| 728 | + } | |
| 729 | + temp1 = jdbcTemplate.query(sql, | |
| 730 | + new RowMapper<Map<String, String>>(){ | |
| 731 | + @Override | |
| 732 | + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 733 | + Map<String, String> m = new HashMap<String, String>(); | |
| 734 | + m.put("id", rs.getString("id")); | |
| 735 | + m.put("lp", rs.getString("lp")); | |
| 736 | + m.put("fcsj", rs.getString("fcsj")); | |
| 737 | + m.put("xl_bm", rs.getString("xl_bm")); | |
| 738 | + m.put("tt_info", rs.getString("tt_info")); | |
| 739 | + return m; | |
| 740 | + } | |
| 741 | + }); | |
| 742 | + sql = "select * from bsth_c_s_ttinfo_detail where ists = 1" | |
| 743 | + + " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'"; | |
| 744 | + | |
| 745 | + if(line.length() != 0 && statu.equals("1")){ | |
| 746 | + sql += " and xl = '"+line+"'"; | |
| 747 | + } | |
| 748 | + temp2 = jdbcTemplate.query(sql, | |
| 749 | + new RowMapper<Map<String, String>>(){ | |
| 750 | + @Override | |
| 751 | + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 752 | + Map<String, String> m = new HashMap<String, String>(); | |
| 753 | + m.put("id", rs.getString("id")); | |
| 754 | + m.put("lp", rs.getString("lp")); | |
| 755 | + m.put("xl", rs.getString("xl")); | |
| 756 | + m.put("fcsj", rs.getString("fcsj")); | |
| 757 | + m.put("ttinfo", rs.getString("ttinfo")); | |
| 758 | + return m; | |
| 759 | + } | |
| 760 | + }); | |
| 761 | + | |
| 762 | + for(Map<String, String> m2 : temp2){ | |
| 763 | + for(Map<String, String> m1 : temp1){ | |
| 764 | + if(m2.get("ttinfo").equals(m1.get("tt_info")) && m2.get("xl").equals(m1.get("xl_bm")) | |
| 765 | + && m2.get("lp").equals(m1.get("lp")) && m2.get("fcsj").equals(m1.get("fcsj"))){ | |
| 766 | + tsSet.add(Long.valueOf(m1.get("id"))); | |
| 767 | + } | |
| 768 | + } | |
| 769 | + } | |
| 770 | + } | |
| 707 | 771 | |
| 708 | 772 | sql = "select * from bsth_c_s_child_task order by start_date"; |
| 709 | 773 | |
| ... | ... | @@ -723,13 +787,17 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 723 | 787 | }); |
| 724 | 788 | |
| 725 | 789 | if(model.length() != 0){ |
| 726 | - sql = "select id from bsth_c_s_sp_info where tt_info = '" + model + "' and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'"; | |
| 790 | + sql = "select sp.id from bsth_c_s_sp_info sp left join bsth_c_s_ttinfo_detail tt on sp.tt_info = tt.ttinfo and sp.xl_bm = tt.xl and sp.lp = tt.lp and sp.fcsj = tt.fcsj " | |
| 791 | + + "where tt_info = '" + model + "' and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'"; | |
| 727 | 792 | |
| 728 | 793 | ttList = jdbcTemplate.query(sql, |
| 729 | - new RowMapper<Long>(){ | |
| 794 | + new RowMapper<Map<String, Object>>(){ | |
| 730 | 795 | @Override |
| 731 | - public Long mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 732 | - return rs.getLong("id"); | |
| 796 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 797 | + Map<String, Object> m = new HashMap<String, Object>(); | |
| 798 | + m.put("id", rs.getString("id")); | |
| 799 | + m.put("ists", rs.getString("ists")!=null?rs.getString("ists"):"0"); | |
| 800 | + return m; | |
| 733 | 801 | } |
| 734 | 802 | }); |
| 735 | 803 | } |
| ... | ... | @@ -771,13 +839,15 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 771 | 839 | if(schedule.getXlName()==null || schedule.getXlName().trim().length()==0) |
| 772 | 840 | continue; |
| 773 | 841 | if(model.length() != 0){ |
| 774 | - for(Long tt : ttList) | |
| 775 | - if((long) tt == (long)schedule.getSpId()){ | |
| 842 | + for(Map<String, Object> tt : ttList){ | |
| 843 | + long id = Long.valueOf(tt.get("id").toString()); | |
| 844 | + if(id == (long)schedule.getSpId()){ | |
| 776 | 845 | String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName(); |
| 777 | 846 | if(!keyMap.containsKey(key)) |
| 778 | 847 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); |
| 779 | 848 | keyMap.get(key).add(schedule); |
| 780 | 849 | } |
| 850 | + } | |
| 781 | 851 | }else{ |
| 782 | 852 | String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName(); |
| 783 | 853 | if(!keyMap.containsKey(key)) |
| ... | ... | @@ -821,14 +891,16 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 821 | 891 | for(int i = 1; i < keyList.size(); i++){ |
| 822 | 892 | ScheduleRealInfo schedule1 = sortMap.get(keyList.get(i - 1)); |
| 823 | 893 | ScheduleRealInfo schedule2 = sortMap.get(keyList.get(i)); |
| 824 | - if(sfqr == 1 && time1 > schedule1.getFcsjT()){ | |
| 825 | - jhyysj += schedule2.getFcsjT() - time1; | |
| 826 | - }else if(sfqr == 1 && time2 < schedule2.getFcsjT()){ | |
| 827 | - jhyysj += time2 - schedule1.getFcsjT(); | |
| 828 | - }else{ | |
| 829 | - jhyysj += schedule2.getFcsjT() - schedule1.getFcsjT(); | |
| 894 | + if(!tsSet.contains(schedule1.getId())){ | |
| 895 | + if(sfqr == 1 && time1 > schedule1.getFcsjT()){ | |
| 896 | + jhyysj += schedule2.getFcsjT() - time1; | |
| 897 | + }else if(sfqr == 1 && time2 < schedule2.getFcsjT()){ | |
| 898 | + jhyysj += time2 - schedule1.getFcsjT(); | |
| 899 | + }else{ | |
| 900 | + jhyysj += schedule2.getFcsjT() - schedule1.getFcsjT(); | |
| 901 | + } | |
| 902 | + jhyysj1 += schedule2.getFcsjT() - schedule1.getFcsjT(); | |
| 830 | 903 | } |
| 831 | - jhyysj1 += schedule2.getFcsjT() - schedule1.getFcsjT(); | |
| 832 | 904 | long zdsj2 = schedule2.getZdsjT(); |
| 833 | 905 | long fcsj2 = schedule2.getFcsjT(); |
| 834 | 906 | if(fcsj2 > zdsj2) | ... | ... |
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
| ... | ... | @@ -662,22 +662,28 @@ public class ReportServiceImpl implements ReportService{ |
| 662 | 662 | + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,1 as xh FROM " |
| 663 | 663 | + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and " |
| 664 | 664 | + " fcsj > '"+minfcsj+"' and bc_type!='in' and bc_type!='out' and bc_type!='ldks') " |
| 665 | - + " order by xl_dir, xh,fcsj"; | |
| 665 | + + " order by xl_dir, xh, fcsj"; | |
| 666 | 666 | Map<String, Object> map=new HashMap<String,Object>(); |
| 667 | 667 | List<Map<String, Object>> list= jdbcTemplate.query(sqlPc, |
| 668 | - new RowMapper<Map<String, Object>>(){ | |
| 669 | - @Override | |
| 670 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 671 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 672 | - m.put("fcsj", rs.getString("fcsj")); | |
| 673 | - m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc")); | |
| 674 | - m.put("bcsj", rs.getString("bcsj")); | |
| 675 | - m.put("bcType", rs.getString("bc_type")); | |
| 676 | - m.put("lp", rs.getString("lp")); | |
| 677 | - m.put("dir", rs.getString("xl_dir")); | |
| 678 | - m.put("ists", rs.getString("ists")!=null?rs.getString("ists"):""); | |
| 679 | - return m; | |
| 680 | - } | |
| 668 | + new RowMapper<Map<String, Object>>(){ | |
| 669 | + @Override | |
| 670 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 671 | + Map<String, Object> m=new HashMap<String,Object>(); | |
| 672 | + m.put("fcsj", rs.getString("fcsj")); | |
| 673 | + m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc")); | |
| 674 | + m.put("bcsj", rs.getString("bcsj")); | |
| 675 | + m.put("bcType", rs.getString("bc_type")); | |
| 676 | + m.put("lp", rs.getString("lp")); | |
| 677 | + m.put("dir", rs.getString("xl_dir")); | |
| 678 | + m.put("ists", rs.getString("ists")!=null?rs.getString("ists"):""); | |
| 679 | + | |
| 680 | + if(m.get("xh").equals("2")){ | |
| 681 | + String[] split = m.get("fcsj").toString().split(":"); | |
| 682 | + m.put("fcsj", Integer.valueOf(split[0]) + 24 + ":"+split[1]); | |
| 683 | + } | |
| 684 | + | |
| 685 | + return m; | |
| 686 | + } | |
| 681 | 687 | }); |
| 682 | 688 | |
| 683 | 689 | List<Map<String, Object>> newList=new ArrayList<Map<String,Object>>(); |
| ... | ... | @@ -711,6 +717,7 @@ public class ReportServiceImpl implements ReportService{ |
| 711 | 717 | List<Map<String, Object>> list2 = keyMap.get(key); |
| 712 | 718 | List<Integer> cjs = new ArrayList<Integer>(); |
| 713 | 719 | int sxsj = 0, xxsj = 0, zcj = 0, tssj = 0; |
| 720 | + int sxbc = 0, xxbc = 0; | |
| 714 | 721 | int temp = 24*60+1; |
| 715 | 722 | boolean ists = false; |
| 716 | 723 | for(Map<String, Object> m : list2){ |
| ... | ... | @@ -720,8 +727,10 @@ public class ReportServiceImpl implements ReportService{ |
| 720 | 727 | int bcsj = Integer.valueOf(m.get("bcsj").toString()); |
| 721 | 728 | if(xlDir == 0){ |
| 722 | 729 | sxsj += bcsj; |
| 730 | + sxbc ++; | |
| 723 | 731 | } else { |
| 724 | 732 | xxsj += bcsj; |
| 733 | + xxbc ++; | |
| 725 | 734 | } |
| 726 | 735 | if(temp >= fcsj){ |
| 727 | 736 | temp = fcsj; |
| ... | ... | @@ -744,9 +753,9 @@ public class ReportServiceImpl implements ReportService{ |
| 744 | 753 | zcj += i; |
| 745 | 754 | } |
| 746 | 755 | tempMap.put("sjd", key); |
| 747 | - tempMap.put("sxsj", sxsj); | |
| 748 | - tempMap.put("xxsj", xxsj); | |
| 749 | - tempMap.put("fqsj", sxsj + xxsj); | |
| 756 | + tempMap.put("sxsj", sxsj / sxbc); | |
| 757 | + tempMap.put("xxsj", xxsj / xxbc); | |
| 758 | + tempMap.put("fqsj", (sxsj + xxsj) / list2.size()); | |
| 750 | 759 | tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——"); |
| 751 | 760 | tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/"); |
| 752 | 761 | tempMap.put("tssj", tssj); | ... | ... |