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,6 +11,7 @@ import java.util.Collections; | ||
| 11 | import java.util.Comparator; | 11 | import java.util.Comparator; |
| 12 | import java.util.Date; | 12 | import java.util.Date; |
| 13 | import java.util.HashMap; | 13 | import java.util.HashMap; |
| 14 | +import java.util.HashSet; | ||
| 14 | import java.util.Iterator; | 15 | import java.util.Iterator; |
| 15 | import java.util.List; | 16 | import java.util.List; |
| 16 | import java.util.Map; | 17 | import java.util.Map; |
| @@ -585,7 +586,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { | @@ -585,7 +586,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 585 | 586 | ||
| 586 | @Override | 587 | @Override |
| 587 | public Map<String, Object> timeAndSpeed(Map<String, Object> map) { | 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 | List<ChildTaskPlan> cList = new ArrayList<ChildTaskPlan>(); | 590 | List<ChildTaskPlan> cList = new ArrayList<ChildTaskPlan>(); |
| 590 | List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | 591 | List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); |
| 591 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | 592 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| @@ -593,6 +594,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { | @@ -593,6 +594,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 593 | Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>(); | 594 | Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>(); |
| 594 | Map<String, List<ChildTaskPlan>> cMap = new HashMap<String, List<ChildTaskPlan>>(); | 595 | Map<String, List<ChildTaskPlan>> cMap = new HashMap<String, List<ChildTaskPlan>>(); |
| 595 | Map<String, Object> modelMap = new HashMap<String, Object>(); | 596 | Map<String, Object> modelMap = new HashMap<String, Object>(); |
| 597 | + Set<Long> tsSet = new HashSet<Long>(); | ||
| 596 | 598 | ||
| 597 | String company = map.get("company").toString(); | 599 | String company = map.get("company").toString(); |
| 598 | String subCompany = map.get("subCompany").toString(); | 600 | String subCompany = map.get("subCompany").toString(); |
| @@ -616,20 +618,23 @@ public class BusIntervalServiceImpl implements BusIntervalService { | @@ -616,20 +618,23 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 616 | 618 | ||
| 617 | try { | 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 | if(line.length() != 0 && statu.equals("1")){ | 622 | if(line.length() != 0 && statu.equals("1")){ |
| 621 | - sql += " and xl_bm = '"+line+"'"; | 623 | + where += " and xl_bm = '"+line+"'"; |
| 622 | } | 624 | } |
| 623 | if(lp.length() != 0 && statu.equals("1")){ | 625 | if(lp.length() != 0 && statu.equals("1")){ |
| 624 | - sql += " and lp_name = '"+lp+"'"; | 626 | + where += " and lp_name = '"+lp+"'"; |
| 625 | } | 627 | } |
| 626 | if(company.length() != 0){ | 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 | if(sfqr == 1){ | 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 | list = jdbcTemplate.query(sql, | 639 | list = jdbcTemplate.query(sql, |
| 635 | new RowMapper<ScheduleRealInfo>(){ | 640 | new RowMapper<ScheduleRealInfo>(){ |
| @@ -704,6 +709,65 @@ public class BusIntervalServiceImpl implements BusIntervalService { | @@ -704,6 +709,65 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 704 | return schedule; | 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 | sql = "select * from bsth_c_s_child_task order by start_date"; | 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,13 +787,17 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 723 | }); | 787 | }); |
| 724 | 788 | ||
| 725 | if(model.length() != 0){ | 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 | ttList = jdbcTemplate.query(sql, | 793 | ttList = jdbcTemplate.query(sql, |
| 729 | - new RowMapper<Long>(){ | 794 | + new RowMapper<Map<String, Object>>(){ |
| 730 | @Override | 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,13 +839,15 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 771 | if(schedule.getXlName()==null || schedule.getXlName().trim().length()==0) | 839 | if(schedule.getXlName()==null || schedule.getXlName().trim().length()==0) |
| 772 | continue; | 840 | continue; |
| 773 | if(model.length() != 0){ | 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 | String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName(); | 845 | String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName(); |
| 777 | if(!keyMap.containsKey(key)) | 846 | if(!keyMap.containsKey(key)) |
| 778 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | 847 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); |
| 779 | keyMap.get(key).add(schedule); | 848 | keyMap.get(key).add(schedule); |
| 780 | } | 849 | } |
| 850 | + } | ||
| 781 | }else{ | 851 | }else{ |
| 782 | String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName(); | 852 | String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName(); |
| 783 | if(!keyMap.containsKey(key)) | 853 | if(!keyMap.containsKey(key)) |
| @@ -821,14 +891,16 @@ public class BusIntervalServiceImpl implements BusIntervalService { | @@ -821,14 +891,16 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 821 | for(int i = 1; i < keyList.size(); i++){ | 891 | for(int i = 1; i < keyList.size(); i++){ |
| 822 | ScheduleRealInfo schedule1 = sortMap.get(keyList.get(i - 1)); | 892 | ScheduleRealInfo schedule1 = sortMap.get(keyList.get(i - 1)); |
| 823 | ScheduleRealInfo schedule2 = sortMap.get(keyList.get(i)); | 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 | long zdsj2 = schedule2.getZdsjT(); | 904 | long zdsj2 = schedule2.getZdsjT(); |
| 833 | long fcsj2 = schedule2.getFcsjT(); | 905 | long fcsj2 = schedule2.getFcsjT(); |
| 834 | if(fcsj2 > zdsj2) | 906 | if(fcsj2 > zdsj2) |
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
| @@ -662,22 +662,28 @@ public class ReportServiceImpl implements ReportService{ | @@ -662,22 +662,28 @@ public class ReportServiceImpl implements ReportService{ | ||
| 662 | + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,1 as xh FROM " | 662 | + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,1 as xh FROM " |
| 663 | + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and " | 663 | + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and " |
| 664 | + " fcsj > '"+minfcsj+"' and bc_type!='in' and bc_type!='out' and bc_type!='ldks') " | 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 | Map<String, Object> map=new HashMap<String,Object>(); | 666 | Map<String, Object> map=new HashMap<String,Object>(); |
| 667 | List<Map<String, Object>> list= jdbcTemplate.query(sqlPc, | 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 | List<Map<String, Object>> newList=new ArrayList<Map<String,Object>>(); | 689 | List<Map<String, Object>> newList=new ArrayList<Map<String,Object>>(); |
| @@ -711,6 +717,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -711,6 +717,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 711 | List<Map<String, Object>> list2 = keyMap.get(key); | 717 | List<Map<String, Object>> list2 = keyMap.get(key); |
| 712 | List<Integer> cjs = new ArrayList<Integer>(); | 718 | List<Integer> cjs = new ArrayList<Integer>(); |
| 713 | int sxsj = 0, xxsj = 0, zcj = 0, tssj = 0; | 719 | int sxsj = 0, xxsj = 0, zcj = 0, tssj = 0; |
| 720 | + int sxbc = 0, xxbc = 0; | ||
| 714 | int temp = 24*60+1; | 721 | int temp = 24*60+1; |
| 715 | boolean ists = false; | 722 | boolean ists = false; |
| 716 | for(Map<String, Object> m : list2){ | 723 | for(Map<String, Object> m : list2){ |
| @@ -720,8 +727,10 @@ public class ReportServiceImpl implements ReportService{ | @@ -720,8 +727,10 @@ public class ReportServiceImpl implements ReportService{ | ||
| 720 | int bcsj = Integer.valueOf(m.get("bcsj").toString()); | 727 | int bcsj = Integer.valueOf(m.get("bcsj").toString()); |
| 721 | if(xlDir == 0){ | 728 | if(xlDir == 0){ |
| 722 | sxsj += bcsj; | 729 | sxsj += bcsj; |
| 730 | + sxbc ++; | ||
| 723 | } else { | 731 | } else { |
| 724 | xxsj += bcsj; | 732 | xxsj += bcsj; |
| 733 | + xxbc ++; | ||
| 725 | } | 734 | } |
| 726 | if(temp >= fcsj){ | 735 | if(temp >= fcsj){ |
| 727 | temp = fcsj; | 736 | temp = fcsj; |
| @@ -744,9 +753,9 @@ public class ReportServiceImpl implements ReportService{ | @@ -744,9 +753,9 @@ public class ReportServiceImpl implements ReportService{ | ||
| 744 | zcj += i; | 753 | zcj += i; |
| 745 | } | 754 | } |
| 746 | tempMap.put("sjd", key); | 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 | tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——"); | 759 | tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——"); |
| 751 | tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/"); | 760 | tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/"); |
| 752 | tempMap.put("tssj", tssj); | 761 | tempMap.put("tssj", tssj); |