Commit 9ca70c2c05cf9b8fa77a085fcf884dceaecc8bd4
Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control into pudong
Showing
6 changed files
with
1433 additions
and
855 deletions
Too many changes to show.
To preserve performance only 6 of 8 files are displayed.
src/main/java/com/bsth/controller/forms/ExportController.java
| ... | ... | @@ -214,7 +214,47 @@ public class ExportController { |
| 214 | 214 | |
| 215 | 215 | return resList; |
| 216 | 216 | } |
| 217 | + @RequestMapping(value = "/singledataExportTj", method = RequestMethod.GET) | |
| 218 | + public List<Map<String, Object>> singledataExportTj(@RequestParam Map<String, Object> map) { | |
| 219 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 220 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 221 | + ReportUtils ee = new ReportUtils(); | |
| 222 | + List<Singledata> singledata = formsService.singledatatj(map); | |
| 223 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 224 | + int i = 1; | |
| 225 | + for (Singledata l : singledata) { | |
| 226 | + Map<String, Object> m = new HashMap<String, Object>(); | |
| 227 | + m.put("i", i); | |
| 228 | + m.put("rQ", l.getrQ()); | |
| 229 | + m.put("gS", l.getgS()); | |
| 230 | + m.put("xL", l.getXlmc()); | |
| 231 | + m.put("clzbh", l.getClzbh()); | |
| 232 | + m.put("jsy", l.getJsy()); | |
| 233 | + m.put("jName", l.getjName()); | |
| 234 | + m.put("sgh", l.getSgh()); | |
| 235 | + m.put("sName", l.getsName()); | |
| 236 | + m.put("jhlc", l.getJhlc()); | |
| 237 | + m.put("emptMileage", l.getEmptMileage()); | |
| 238 | + m.put("hyl", l.getHyl()); | |
| 239 | + m.put("jzl", l.getJzl()); | |
| 240 | + m.put("unyyyl", l.getUnyyyl()); | |
| 241 | + m.put("jhjl", l.getJhjl()); | |
| 242 | + resList.add(m); | |
| 243 | + | |
| 244 | + i++; | |
| 245 | + } | |
| 246 | + | |
| 247 | + try { | |
| 248 | + listI.add(resList.iterator()); | |
| 249 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 250 | + ee.excelReplace(listI, new Object[] { map }, path + "mould/singledata.xls", | |
| 251 | + path + "export/路单数据" + sdfSimple.format(sdfMonth.parse(map.get("startDate").toString())) + ".xls"); | |
| 252 | + } catch (Exception e) { | |
| 253 | + e.printStackTrace(); | |
| 254 | + } | |
| 217 | 255 | |
| 256 | + return resList; | |
| 257 | + } | |
| 218 | 258 | // 车辆加注 |
| 219 | 259 | @RequestMapping(value = "/vehicleloadingExport", method = RequestMethod.GET) |
| 220 | 260 | public List<Map<String, Object>> vehicleloadingExport(@RequestParam Map<String, Object> map) { | ... | ... |
src/main/java/com/bsth/controller/forms/MCY_FormsController.java
| ... | ... | @@ -83,9 +83,15 @@ public class MCY_FormsController { |
| 83 | 83 | @RequestMapping(value = "/singledatanew", method = RequestMethod.GET) |
| 84 | 84 | public List<Singledata> singledatanew(@RequestParam Map<String, Object> map) { |
| 85 | 85 | |
| 86 | - return formsService.singledata(map); | |
| 86 | + return formsService.singledatanew(map); | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | + @RequestMapping(value = "/singledatatj", method = RequestMethod.GET) | |
| 90 | + public List<Singledata> singledatatj(@RequestParam Map<String, Object> map) { | |
| 91 | + | |
| 92 | + return formsService.singledatatj(map); | |
| 93 | + } | |
| 94 | + | |
| 89 | 95 | // 车辆加注 |
| 90 | 96 | @RequestMapping(value = "/vehicleloading", method = RequestMethod.GET) |
| 91 | 97 | public List<Vehicleloading> vehicleloading(@RequestParam String line, @RequestParam String data) { | ... | ... |
src/main/java/com/bsth/repository/oil/YlbRepository.java
| ... | ... | @@ -71,6 +71,11 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 71 | 71 | @Query(value="SELECT * FROM bsth_c_ylb where to_days(?1)=to_days(rq) and ssgsdm like %?2% " |
| 72 | 72 | + " and fgsdm like %?3%" |
| 73 | 73 | + " and xlbm = ?4 and nbbm like %?5% order by ?6 asc ",nativeQuery=true) |
| 74 | + List<Ylb> obtainYlEq(String rq,String gsdm,String fgsdm,String xlbm,String nbbm,String px); | |
| 75 | + | |
| 76 | + @Query(value="SELECT * FROM bsth_c_ylb where to_days(?1)=to_days(rq) and ssgsdm like %?2% " | |
| 77 | + + " and fgsdm like %?3%" | |
| 78 | + + " and xlbm = ?4 and nbbm like %?5% order by ?6 asc ",nativeQuery=true) | |
| 74 | 79 | List<Ylb> obtainYl_eq(String rq,String gsdm,String fgsdm,String xlbm,String nbbm,String px); |
| 75 | 80 | |
| 76 | 81 | ... | ... |
src/main/java/com/bsth/service/forms/FormsService.java
| ... | ... | @@ -31,6 +31,7 @@ public interface FormsService { |
| 31 | 31 | |
| 32 | 32 | public List<Singledata> singledata(Map<String, Object> map); |
| 33 | 33 | public List<Singledata> singledatanew(Map<String, Object> map); |
| 34 | + public List<Singledata> singledatatj(Map<String, Object> map); | |
| 34 | 35 | |
| 35 | 36 | public List<Vehicleloading> vehicleloading(String line,String data); |
| 36 | 37 | ... | ... |
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
| ... | ... | @@ -633,6 +633,532 @@ public class FormsServiceImpl implements FormsService { |
| 633 | 633 | |
| 634 | 634 | |
| 635 | 635 | // 路单数据 |
| 636 | + @Override | |
| 637 | + public List<Singledata> singledatatj(Map<String, Object> map) { | |
| 638 | + String gsdm=""; | |
| 639 | + if(map.get("gsdmSing")!=null){ | |
| 640 | + gsdm=map.get("gsdmSing").toString(); | |
| 641 | + } | |
| 642 | + String fgsdm=""; | |
| 643 | + if(map.get("fgsdmSing")!=null){ | |
| 644 | + fgsdm=map.get("fgsdmSing").toString(); | |
| 645 | + } | |
| 646 | + | |
| 647 | + String tjtype=map.get("tjtype").toString(); | |
| 648 | + String xlbm=map.get("line").toString().trim(); | |
| 649 | + startDate = map.get("startDate").toString(); | |
| 650 | + | |
| 651 | + List<ScheduleRealInfo> listReal=new ArrayList<ScheduleRealInfo>(); | |
| 652 | + if(xlbm.equals("")){ | |
| 653 | + listReal=scheduleRealInfoRepository.scheduleByDateAndLineByGs_(gsdm, fgsdm, startDate); | |
| 654 | + }else{ | |
| 655 | + listReal=scheduleRealInfoRepository.scheduleByDateAndLineQp(xlbm, startDate); | |
| 656 | + } | |
| 657 | + List<Singledata> list=new ArrayList<Singledata>(); | |
| 658 | + List<Singledata> list_=new ArrayList<Singledata>(); | |
| 659 | + if(tjtype.equals("jsy")){ | |
| 660 | + //油统计 | |
| 661 | + String sql="select r.j_gh, r.xl_bm,r.cl_zbh" | |
| 662 | + + " from bsth_c_s_sp_info_real r where " | |
| 663 | + + " r.schedule_date_str = '"+startDate+"'"; | |
| 664 | + if(xlbm.equals("")){ | |
| 665 | + sql +="and r.gs_bm='"+gsdm+"' " | |
| 666 | + + " and r.fgs_bm='"+fgsdm+"'"; | |
| 667 | + }else{ | |
| 668 | + sql += " and r.xl_bm = '"+xlbm+"'"; | |
| 669 | + } | |
| 670 | + sql += " group by r.j_gh,r.xl_bm,r.cl_zbh order by r.xl_bm,r.cl_zbh"; | |
| 671 | + list = jdbcTemplate.query(sql, new RowMapper<Singledata>() { | |
| 672 | + @Override | |
| 673 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | |
| 674 | + Singledata sin = new Singledata(); | |
| 675 | + sin.setxL(arg0.getString("xl_bm")); | |
| 676 | + sin.setJsy(arg0.getString("j_gh")); | |
| 677 | + sin.setClzbh(arg0.getString("cl_zbh")); | |
| 678 | + return sin; | |
| 679 | + } | |
| 680 | + }); | |
| 681 | + String linesql=""; | |
| 682 | + if(!xlbm.equals("")){ | |
| 683 | + linesql +=" and xlbm ='"+xlbm+"' "; | |
| 684 | + } | |
| 685 | + String nysql="SELECT id,xlbm,nbbm, jsy,jzl as jzl,yh as yh,sh as sh FROM bsth_c_ylb " | |
| 686 | + + " WHERE rq = '"+startDate+"'" | |
| 687 | + + " AND ssgsdm = '"+gsdm+"' AND fgsdm = '"+fgsdm+"'" +linesql | |
| 688 | + + " union" | |
| 689 | + + " SELECT id,xlbm,nbbm,jsy,cdl as jzl,hd as yh,sh as sh FROM bsth_c_dlb" | |
| 690 | + + " WHERE rq = '"+startDate+"'" | |
| 691 | + + " AND ssgsdm = '"+gsdm+"' AND fgsdm = '"+fgsdm+"'"+linesql; | |
| 692 | + List<Singledata> listNy = jdbcTemplate.query(nysql, new RowMapper<Singledata>() { | |
| 693 | + @Override | |
| 694 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | |
| 695 | + Singledata sin = new Singledata(); | |
| 696 | + sin.setxL(arg0.getString("xlbm")); | |
| 697 | + sin.setJsy(arg0.getString("jsy")); | |
| 698 | + sin.setClzbh(arg0.getString("nbbm")); | |
| 699 | + sin.setJzl(arg0.getString("jzl")); | |
| 700 | + sin.setHyl(arg0.getString("yh")); | |
| 701 | + sin.setUnyyyl(arg0.getString("sh")); | |
| 702 | + return sin; | |
| 703 | + } | |
| 704 | + }); | |
| 705 | + //统计油,电表中手动添加的或者有加注没里程的数据 | |
| 706 | + for (int i = 0; i < listNy.size(); i++) { | |
| 707 | + Singledata sin_=listNy.get(i); | |
| 708 | + String jsy=sin_.getJsy(); | |
| 709 | + String line=sin_.getxL(); | |
| 710 | + String clzbh=sin_.getClzbh(); | |
| 711 | + boolean fages=true; | |
| 712 | + for (int j = 0; j < list.size(); j++) { | |
| 713 | + Singledata sin=list.get(j); | |
| 714 | + String jsy_=sin.getJsy(); | |
| 715 | + String line_=sin.getxL(); | |
| 716 | + String clzbh_=sin.getClzbh(); | |
| 717 | + if(jsy.equals(jsy_) | |
| 718 | + &&line.equals(line_) | |
| 719 | + &&clzbh.equals(clzbh_)){ | |
| 720 | + fages=false; | |
| 721 | + } | |
| 722 | + } | |
| 723 | + if(fages){ | |
| 724 | + Singledata s=new Singledata(); | |
| 725 | + s.setJsy(jsy); | |
| 726 | + s.setjName(BasicData.allPerson.get(gsdm+"-"+jsy)); | |
| 727 | + s.setClzbh(clzbh); | |
| 728 | + s.setSgh(""); | |
| 729 | + s.setsName(""); | |
| 730 | + s.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm)); | |
| 731 | + s.setxL(line); | |
| 732 | + s.setXlmc(BasicData.lineCode2NameMap.get(line)); | |
| 733 | + s.setJzl(sin_.getJzl()); | |
| 734 | + s.setHyl(sin_.getHyl()); | |
| 735 | + s.setUnyyyl(sin_.getUnyyyl()); | |
| 736 | + s.setJhlc("0.0"); | |
| 737 | + s.setEmptMileage("0.0"); | |
| 738 | + s.setJhjl("0.0"); | |
| 739 | + s.setrQ(startDate); | |
| 740 | + list_.add(s); | |
| 741 | + } | |
| 742 | + } | |
| 743 | + for (int i= 0; i < list.size(); i++) { | |
| 744 | + Singledata sin=list.get(i); | |
| 745 | + String jsy=sin.getJsy(); | |
| 746 | + String line=sin.getxL(); | |
| 747 | + String clzbh=sin.getClzbh(); | |
| 748 | + double jzl=0.0; | |
| 749 | + double yh=0.0; | |
| 750 | + double sh=0.0; | |
| 751 | + for (int j = 0; j < listNy.size(); j++) { | |
| 752 | + Singledata y=listNy.get(j); | |
| 753 | + if(y.getJsy().equals(jsy) | |
| 754 | + &&y.getClzbh().equals(clzbh) | |
| 755 | + &&y.getxL().equals(line)){ | |
| 756 | + jzl=Arith.add(jzl, y.getJzl()); | |
| 757 | + yh=Arith.add(yh, y.getHyl()); | |
| 758 | + sh=Arith.add(sh, y.getUnyyyl()); | |
| 759 | + } | |
| 760 | + } | |
| 761 | + sin.setHyl(String.valueOf(yh)); | |
| 762 | + sin.setJzl(String.valueOf(jzl)); | |
| 763 | + sin.setUnyyyl(String.valueOf(sh)); | |
| 764 | + | |
| 765 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | |
| 766 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | |
| 767 | + for (int j = 0; j < listReal.size(); j++) { | |
| 768 | + ScheduleRealInfo s=listReal.get(j); | |
| 769 | + if(s.getjGh().equals(jsy) | |
| 770 | + && s.getClZbh().equals(clzbh) | |
| 771 | + &&s.getXlBm().equals(line)){ | |
| 772 | + newList.add(s); | |
| 773 | + Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 774 | + if(cts != null && cts.size() > 0){ | |
| 775 | + newList_.add(s); | |
| 776 | + }else{ | |
| 777 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | |
| 778 | + newList_.add(s); | |
| 779 | + } | |
| 780 | + } | |
| 781 | + } | |
| 782 | + } | |
| 783 | + double jhgl=culateMileageService.culateJhgl(newList); | |
| 784 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | |
| 785 | + double yygl=culateMileageService.culateSjgl(newList_); | |
| 786 | + double ljgl=culateMileageService.culateLjgl(newList_); | |
| 787 | + double ksgl=culateMileageService.culateKsgl(newList_); | |
| 788 | + double jcgl=culateMileageService.culateJccgl(newList_); | |
| 789 | + | |
| 790 | + double zyygl=Arith.add(yygl, ljgl); | |
| 791 | + double zksgl=Arith.add(ksgl, jcgl); | |
| 792 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | |
| 793 | + sin.setEmptMileage(String.valueOf(zksgl)); | |
| 794 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | |
| 795 | + sin.setXlmc(BasicData.lineCode2NameMap.get(line)); | |
| 796 | + sin.setrQ(startDate); | |
| 797 | + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy)); | |
| 798 | + sin.setSgh(""); | |
| 799 | + sin.setsName(""); | |
| 800 | + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm)); | |
| 801 | + list_.add(sin); | |
| 802 | + | |
| 803 | + } | |
| 804 | + Collections.sort(list_,new SingledataByXlbm()); | |
| 805 | + }else{ | |
| 806 | + String sql="select r.s_gh,r.s_name, " | |
| 807 | + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm" | |
| 808 | + + " from bsth_c_s_sp_info_real r where " | |
| 809 | + + " r.schedule_date_str = '"+startDate+"'" | |
| 810 | + + " and r.s_gh !='' and r.s_gh is not null "; | |
| 811 | + if(xlbm.equals("")){ | |
| 812 | + sql +="and r.gs_bm='"+gsdm+"' " | |
| 813 | + + " and r.fgs_bm='"+fgsdm+"'"; | |
| 814 | + }else{ | |
| 815 | + sql += " and r.xl_bm = '"+xlbm+"'"; | |
| 816 | + } | |
| 817 | + sql += " group by r.s_gh,r.s_name," | |
| 818 | + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh"; | |
| 819 | + | |
| 820 | + list = jdbcTemplate.query(sql, new RowMapper<Singledata>() { | |
| 821 | + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 822 | + @Override | |
| 823 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | |
| 824 | + Singledata sin = new Singledata(); | |
| 825 | + sin.setrQ(startDate); | |
| 826 | + sin.setxL(arg0.getString("xl_bm")); | |
| 827 | + sin.setClzbh(arg0.getString("cl_zbh")); | |
| 828 | + sin.setSgh(arg0.getString("s_gh")); | |
| 829 | + sin.setsName(arg0.getString("s_name")); | |
| 830 | + return sin; | |
| 831 | + } | |
| 832 | + }); | |
| 833 | + | |
| 834 | + for (int i = 0; i < list.size(); i++) { | |
| 835 | + Singledata sin=list.get(i); | |
| 836 | + String jsy=sin.getSgh(); | |
| 837 | + String line=sin.getxL(); | |
| 838 | + String clzbh=sin.getClzbh(); | |
| 839 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | |
| 840 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | |
| 841 | + | |
| 842 | + for (int j = 0; j < listReal.size(); j++) { | |
| 843 | + ScheduleRealInfo s=listReal.get(j); | |
| 844 | + if(s.getsGh().equals(jsy) && s.getClZbh().equals(clzbh) | |
| 845 | + &&s.getXlBm().equals(line)){ | |
| 846 | + newList.add(s); | |
| 847 | + Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 848 | + if(cts != null && cts.size() > 0){ | |
| 849 | + newList_.add(s); | |
| 850 | + }else{ | |
| 851 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | |
| 852 | + newList_.add(s); | |
| 853 | + } | |
| 854 | + } | |
| 855 | + } | |
| 856 | + } | |
| 857 | + double jhgl=culateMileageService.culateJhgl(newList); | |
| 858 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | |
| 859 | + double yygl=culateMileageService.culateSjgl(newList_); | |
| 860 | + double ljgl=culateMileageService.culateLjgl(newList_); | |
| 861 | + double ksgl=culateMileageService.culateKsgl(newList_); | |
| 862 | + double jcgl=culateMileageService.culateJccgl(newList_); | |
| 863 | + | |
| 864 | + double zyygl=Arith.add(yygl, ljgl); | |
| 865 | + double zksgl=Arith.add(ksgl, jcgl); | |
| 866 | + | |
| 867 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | |
| 868 | + | |
| 869 | + sin.setEmptMileage(String.valueOf(zksgl)); | |
| 870 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | |
| 871 | + sin.setxL(BasicData.lineCode2NameMap.get(line)); | |
| 872 | + sin.setClzbh(clzbh); | |
| 873 | + sin.setJsy(""); | |
| 874 | + sin.setjName(""); | |
| 875 | + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm)); | |
| 876 | + sin.setHyl(""); | |
| 877 | + sin.setJzl(""); | |
| 878 | + sin.setUnyyyl(""); | |
| 879 | + } | |
| 880 | + Collections.sort(list,new SingledataByXlbm()); | |
| 881 | + } | |
| 882 | + return list_; | |
| 883 | + } | |
| 884 | + | |
| 885 | + /*// 路单数据 | |
| 886 | + @Override | |
| 887 | + public List<Singledata> singledatatj(Map<String, Object> map) { | |
| 888 | + | |
| 889 | + String gsdm=""; | |
| 890 | + if(map.get("gsdmSing")!=null){ | |
| 891 | + gsdm=map.get("gsdmSing").toString(); | |
| 892 | + } | |
| 893 | + String fgsdm=""; | |
| 894 | + if(map.get("fgsdmSing")!=null){ | |
| 895 | + fgsdm=map.get("fgsdmSing").toString(); | |
| 896 | + } | |
| 897 | + | |
| 898 | + String tjtype=map.get("tjtype").toString(); | |
| 899 | + String xlbm=map.get("line").toString().trim(); | |
| 900 | + startDate = map.get("startDate").toString(); | |
| 901 | + | |
| 902 | + List<ScheduleRealInfo> listReal=new ArrayList<ScheduleRealInfo>(); | |
| 903 | + if(xlbm.equals("")){ | |
| 904 | + listReal=scheduleRealInfoRepository.scheduleByDateAndLineByGs_(gsdm, fgsdm, startDate); | |
| 905 | + }else{ | |
| 906 | + listReal=scheduleRealInfoRepository.scheduleByDateAndLineQp(xlbm, startDate); | |
| 907 | + } | |
| 908 | + List<Singledata> list=new ArrayList<Singledata>(); | |
| 909 | + List<Singledata> listY=new ArrayList<Singledata>(); | |
| 910 | + List<Singledata> listD=new ArrayList<Singledata>(); | |
| 911 | + | |
| 912 | + if(tjtype.equals("jsy")){ | |
| 913 | + //油统计 | |
| 914 | + String sql="select xlbm,nbbm,jsy from bsth_c_ylb where rq='"+startDate+"'"; | |
| 915 | + if(xlbm.equals("")){ | |
| 916 | + sql += " and ssgsdm= '"+gsdm+"' and fgsdm= '"+fgsdm+"'"; | |
| 917 | + }else{ | |
| 918 | + sql +=" and xlbm= '"+xlbm+"'"; | |
| 919 | + } | |
| 920 | + sql += " group by xlbm,nbbm,jsy"; | |
| 921 | + listY = jdbcTemplate.query(sql, new RowMapper<Singledata>() { | |
| 922 | + @Override | |
| 923 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | |
| 924 | + Singledata sin = new Singledata(); | |
| 925 | + sin.setxL(arg0.getString("xlbm")); | |
| 926 | + sin.setJsy(arg0.getString("jsy")); | |
| 927 | + sin.setClzbh(arg0.getString("nbbm")); | |
| 928 | + return sin; | |
| 929 | + } | |
| 930 | + }); | |
| 931 | + | |
| 932 | + List<Ylb> listYlb= ylbRepository.obtainYl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); | |
| 933 | + for (int i = 0; i < listY.size(); i++) { | |
| 934 | + Singledata sin=listY.get(i); | |
| 935 | + String jsy=sin.getJsy(); | |
| 936 | + String line=sin.getxL(); | |
| 937 | + String clzbh=sin.getClzbh(); | |
| 938 | + | |
| 939 | + double jzl=0.0; | |
| 940 | + double yh=0.0; | |
| 941 | + double sh=0.0; | |
| 942 | + for (int j = 0; j < listYlb.size(); j++) { | |
| 943 | + Ylb y=listYlb.get(j); | |
| 944 | + if(y.getJsy().equals(jsy) | |
| 945 | + &&y.getNbbm().equals(clzbh) | |
| 946 | + &&y.getXlbm().equals(line)){ | |
| 947 | + jzl=Arith.add(jzl, y.getJzl()); | |
| 948 | + yh=Arith.add(yh, y.getYh()); | |
| 949 | + sh=Arith.add(sh, y.getSh()); | |
| 950 | + } | |
| 951 | + } | |
| 952 | + sin.setHyl(String.valueOf(yh)); | |
| 953 | + sin.setJzl(String.valueOf(jzl)); | |
| 954 | + sin.setUnyyyl(String.valueOf(sh)); | |
| 955 | + | |
| 956 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | |
| 957 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | |
| 958 | + for (int j = 0; j < listReal.size(); j++) { | |
| 959 | + ScheduleRealInfo s=listReal.get(j); | |
| 960 | + if(s.getjGh().equals(jsy) | |
| 961 | + && s.getClZbh().equals(clzbh) | |
| 962 | + &&s.getXlBm().equals(line)){ | |
| 963 | + newList.add(s); | |
| 964 | + Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 965 | + if(cts != null && cts.size() > 0){ | |
| 966 | + newList_.add(s); | |
| 967 | + }else{ | |
| 968 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | |
| 969 | + newList_.add(s); | |
| 970 | + } | |
| 971 | + } | |
| 972 | + } | |
| 973 | + } | |
| 974 | + double jhgl=culateMileageService.culateJhgl(newList); | |
| 975 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | |
| 976 | + double yygl=culateMileageService.culateSjgl(newList_); | |
| 977 | + double ljgl=culateMileageService.culateLjgl(newList_); | |
| 978 | + double ksgl=culateMileageService.culateKsgl(newList_); | |
| 979 | + double jcgl=culateMileageService.culateJccgl(newList_); | |
| 980 | + | |
| 981 | + double zyygl=Arith.add(yygl, ljgl); | |
| 982 | + double zksgl=Arith.add(ksgl, jcgl); | |
| 983 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | |
| 984 | + sin.setEmptMileage(String.valueOf(zksgl)); | |
| 985 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | |
| 986 | + sin.setXlmc(BasicData.lineCode2NameMap.get(line)); | |
| 987 | + sin.setrQ(startDate); | |
| 988 | + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy)); | |
| 989 | + sin.setSgh(""); | |
| 990 | + sin.setsName(""); | |
| 991 | + } | |
| 992 | + | |
| 993 | + | |
| 994 | + //电量计算 | |
| 995 | + String sqldl="select xlbm,nbbm,jsy from bsth_c_dlb where rq='"+startDate+"'"; | |
| 996 | + if(xlbm.equals("")){ | |
| 997 | + sqldl += " and ssgsdm= '"+gsdm+"' and fgsdm= '"+fgsdm+"'"; | |
| 998 | + }else{ | |
| 999 | + sqldl +=" and xlbm= '"+xlbm+"'"; | |
| 1000 | + } | |
| 1001 | + sqldl += " group by xlbm,nbbm,jsy"; | |
| 1002 | + listD = jdbcTemplate.query(sqldl, new RowMapper<Singledata>() { | |
| 1003 | + @Override | |
| 1004 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | |
| 1005 | + Singledata sin = new Singledata(); | |
| 1006 | + sin.setxL(arg0.getString("xlbm")); | |
| 1007 | + sin.setJsy(arg0.getString("jsy")); | |
| 1008 | + sin.setClzbh(arg0.getString("nbbm")); | |
| 1009 | + return sin; | |
| 1010 | + } | |
| 1011 | + }); | |
| 1012 | + List<Dlb> listDlb= dlbRepository.obtainDl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); | |
| 1013 | + | |
| 1014 | + for (int i = 0; i < listD.size(); i++) { | |
| 1015 | + Singledata sin=listD.get(i); | |
| 1016 | + String jsy=sin.getJsy(); | |
| 1017 | + String line=sin.getxL(); | |
| 1018 | + String clzbh=sin.getClzbh(); | |
| 1019 | + | |
| 1020 | + double jzl=0.0; | |
| 1021 | + double yh=0.0; | |
| 1022 | + double sh=0.0; | |
| 1023 | + for (int j = 0; j < listDlb.size(); j++) { | |
| 1024 | + Dlb d=listDlb.get(j); | |
| 1025 | + if(d.getJsy().equals(jsy) | |
| 1026 | + &&d.getNbbm().equals(clzbh) | |
| 1027 | + &&d.getXlbm().equals(line)){ | |
| 1028 | + jzl=Arith.add(jzl, d.getCdl()); | |
| 1029 | + yh=Arith.add(yh, d.getHd()); | |
| 1030 | + sh=Arith.add(sh, d.getSh()); | |
| 1031 | + } | |
| 1032 | + } | |
| 1033 | + sin.setHyl(String.valueOf(yh)); | |
| 1034 | + sin.setJzl(String.valueOf(jzl)); | |
| 1035 | + sin.setUnyyyl(String.valueOf(sh)); | |
| 1036 | + | |
| 1037 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | |
| 1038 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | |
| 1039 | + for (int j = 0; j < listReal.size(); j++) { | |
| 1040 | + ScheduleRealInfo s=listReal.get(j); | |
| 1041 | + if(s.getjGh().equals(jsy) | |
| 1042 | + && s.getClZbh().equals(clzbh) | |
| 1043 | + &&s.getXlBm().equals(line)){ | |
| 1044 | + newList.add(s); | |
| 1045 | + Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 1046 | + if(cts != null && cts.size() > 0){ | |
| 1047 | + newList_.add(s); | |
| 1048 | + }else{ | |
| 1049 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | |
| 1050 | + newList_.add(s); | |
| 1051 | + } | |
| 1052 | + } | |
| 1053 | + } | |
| 1054 | + } | |
| 1055 | + double jhgl=culateMileageService.culateJhgl(newList); | |
| 1056 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | |
| 1057 | + double yygl=culateMileageService.culateSjgl(newList_); | |
| 1058 | + double ljgl=culateMileageService.culateLjgl(newList_); | |
| 1059 | + double ksgl=culateMileageService.culateKsgl(newList_); | |
| 1060 | + double jcgl=culateMileageService.culateJccgl(newList_); | |
| 1061 | + | |
| 1062 | + double zyygl=Arith.add(yygl, ljgl); | |
| 1063 | + double zksgl=Arith.add(ksgl, jcgl); | |
| 1064 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | |
| 1065 | + sin.setEmptMileage(String.valueOf(zksgl)); | |
| 1066 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | |
| 1067 | + sin.setXlmc(BasicData.lineCode2NameMap.get(line)); | |
| 1068 | + sin.setrQ(startDate); | |
| 1069 | + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy)); | |
| 1070 | + sin.setSgh(""); | |
| 1071 | + sin.setsName(""); | |
| 1072 | + } | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + Collections.sort(listY,new SingledataByXlbm()); | |
| 1076 | + Collections.sort(listD,new SingledataByXlbm()); | |
| 1077 | + list.addAll(listY); | |
| 1078 | + list.addAll(listD); | |
| 1079 | + }else{ | |
| 1080 | + String sql="select r.s_gh,r.s_name, " | |
| 1081 | + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm" | |
| 1082 | + + " from bsth_c_s_sp_info_real r where " | |
| 1083 | + + " r.schedule_date_str = '"+startDate+"'" | |
| 1084 | + + " and r.s_gh !='' and r.s_gh is not null "; | |
| 1085 | + if(xlbm.equals("")){ | |
| 1086 | + sql +="and r.gs_bm='"+gsdm+"' " | |
| 1087 | + + " and r.fgs_bm='"+fgsdm+"'"; | |
| 1088 | + }else{ | |
| 1089 | + sql += " and r.xl_bm = '"+xlbm+"'"; | |
| 1090 | + } | |
| 1091 | + sql += " group by r.s_gh,r.s_name," | |
| 1092 | + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh"; | |
| 1093 | + | |
| 1094 | + list = jdbcTemplate.query(sql, new RowMapper<Singledata>() { | |
| 1095 | + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 1096 | + @Override | |
| 1097 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | |
| 1098 | + Singledata sin = new Singledata(); | |
| 1099 | + sin.setrQ(startDate); | |
| 1100 | + sin.setxL(arg0.getString("xl_bm")); | |
| 1101 | + sin.setClzbh(arg0.getString("cl_zbh")); | |
| 1102 | + sin.setSgh(arg0.getString("s_gh")); | |
| 1103 | + sin.setsName(arg0.getString("s_name")); | |
| 1104 | + return sin; | |
| 1105 | + } | |
| 1106 | + }); | |
| 1107 | + | |
| 1108 | + for (int i = 0; i < list.size(); i++) { | |
| 1109 | + Singledata sin=list.get(i); | |
| 1110 | + String jsy=sin.getSgh(); | |
| 1111 | + String line=sin.getxL(); | |
| 1112 | + String clzbh=sin.getClzbh(); | |
| 1113 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | |
| 1114 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | |
| 1115 | + | |
| 1116 | + for (int j = 0; j < listReal.size(); j++) { | |
| 1117 | + ScheduleRealInfo s=listReal.get(j); | |
| 1118 | + if(s.getsGh().equals(jsy) && s.getClZbh().equals(clzbh) | |
| 1119 | + &&s.getXlBm().equals(line)){ | |
| 1120 | + newList.add(s); | |
| 1121 | + Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 1122 | + if(cts != null && cts.size() > 0){ | |
| 1123 | + newList_.add(s); | |
| 1124 | + }else{ | |
| 1125 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | |
| 1126 | + newList_.add(s); | |
| 1127 | + } | |
| 1128 | + } | |
| 1129 | + } | |
| 1130 | + } | |
| 1131 | + double jhgl=culateMileageService.culateJhgl(newList); | |
| 1132 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | |
| 1133 | + double yygl=culateMileageService.culateSjgl(newList_); | |
| 1134 | + double ljgl=culateMileageService.culateLjgl(newList_); | |
| 1135 | + double ksgl=culateMileageService.culateKsgl(newList_); | |
| 1136 | + double jcgl=culateMileageService.culateJccgl(newList_); | |
| 1137 | + | |
| 1138 | + double zyygl=Arith.add(yygl, ljgl); | |
| 1139 | + double zksgl=Arith.add(ksgl, jcgl); | |
| 1140 | + | |
| 1141 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | |
| 1142 | + | |
| 1143 | + sin.setEmptMileage(String.valueOf(zksgl)); | |
| 1144 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | |
| 1145 | + sin.setxL(BasicData.lineCode2NameMap.get(line)); | |
| 1146 | + sin.setClzbh(clzbh); | |
| 1147 | + sin.setJsy(""); | |
| 1148 | + sin.setjName(""); | |
| 1149 | + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm)); | |
| 1150 | + sin.setHyl(""); | |
| 1151 | + sin.setJzl(""); | |
| 1152 | + sin.setUnyyyl(""); | |
| 1153 | + } | |
| 1154 | + Collections.sort(list,new SingledataByXlbm()); | |
| 1155 | + } | |
| 1156 | + | |
| 1157 | + return list; | |
| 1158 | + | |
| 1159 | + }*/ | |
| 1160 | + | |
| 1161 | + // 路单数据 | |
| 636 | 1162 | @Override |
| 637 | 1163 | public List<Singledata> singledatanew(Map<String, Object> map) { |
| 638 | 1164 | ... | ... |
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalLpObj.js
| 1 | -/** | |
| 2 | - * 内部路牌对象。 | |
| 3 | - * @constructor | |
| 4 | - */ | |
| 5 | -var InternalLpObj = function( | |
| 6 | - orilpObj, // 原始路牌对象 | |
| 7 | - qCount, // 总共多少圈 | |
| 8 | - isUp // 圈是以上行开始还是下行开始 | |
| 9 | -) { | |
| 10 | - // TODO:原始路牌对象(这个路牌是对接外部gantt图像,以后有机会改了) | |
| 11 | - this._$$_orign_lp_obj = orilpObj; | |
| 12 | - | |
| 13 | - this._$_isUp = isUp; | |
| 14 | - | |
| 15 | - // 路牌的圈数,注意每个路牌的圈数都是一致的, | |
| 16 | - // 但并不是每一圈都有值 | |
| 17 | - // 第1圈从上标线开始 | |
| 18 | - // 第0圈表示中标线的第一个班次组成的半圈 | |
| 19 | - // 有多少圈根据最终迭代的结果来看 | |
| 20 | - this._$_qCount = qCount; | |
| 21 | - // 保存的是 InternalGroupBcObj 对象 | |
| 22 | - this._$_groupBcArray = new Array(qCount); | |
| 23 | - | |
| 24 | - var i; | |
| 25 | - for (i = 0; i < this._$_qCount; i++) { | |
| 26 | - this._$_groupBcArray[i] = new InternalGroupObj( | |
| 27 | - this, this._$_isUp, undefined, undefined); | |
| 28 | - } | |
| 29 | - | |
| 30 | - // 距离上一个路牌的最小发车间隔时间 | |
| 31 | - // 用于纵向添加班次的时候使用 | |
| 32 | - // 默认第一个路牌为0 | |
| 33 | - this._$_minVerticalIntervalTime = 0; | |
| 34 | - | |
| 35 | - // 详细记录每圈每个方向上的发车间隔时间 | |
| 36 | - // 第一维度表示圈数,第二维度表示第一个方向,第二个方向 | |
| 37 | - // 第一个方向是否上行由 _$_isUp 决定 | |
| 38 | - // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔 | |
| 39 | - // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔 | |
| 40 | - this._$_aVerticalIntervalTime = new Array(this._$_qCount); | |
| 41 | - var i; | |
| 42 | - for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) { | |
| 43 | - this._$_aVerticalIntervalTime[i] = new Array(2); | |
| 44 | - } | |
| 45 | - | |
| 46 | - // 班型的相关变量 | |
| 47 | - this._$_bx_isLb = false; // 是否连班 | |
| 48 | - this._$_bx_isfb = false; // 是否分班 | |
| 49 | - this._$_bx_isfb_5_2 = false; // 是否5休2分班 | |
| 50 | - this._$_bx_desc; // 班型描述(默认为路牌编号) | |
| 51 | - | |
| 52 | - // 其他班次(进出场,例包,吃饭等),TODO:以后再拆 | |
| 53 | - this._$_other_bc_array = []; | |
| 54 | - | |
| 55 | - // TODO: | |
| 56 | - | |
| 57 | -}; | |
| 58 | - | |
| 59 | -//------------------- get/set 方法 -------------------// | |
| 60 | - | |
| 61 | -InternalLpObj.prototype.getOtherBcArray = function() { | |
| 62 | - return this._$_other_bc_array; | |
| 63 | -}; | |
| 64 | -InternalLpObj.prototype.addOtherBcArray = function(ba) { | |
| 65 | - this._$_other_bc_array = this._$_other_bc_array.concat(ba); | |
| 66 | -}; | |
| 67 | - | |
| 68 | -/** | |
| 69 | - * 获取圈 | |
| 70 | - * @param qIndex 圈index | |
| 71 | - */ | |
| 72 | -InternalLpObj.prototype.getGroup = function(qIndex) { | |
| 73 | - return this._$_groupBcArray[qIndex]; | |
| 74 | -}; | |
| 75 | - | |
| 76 | -/** | |
| 77 | - * 获取班次。 | |
| 78 | - * @param qIndex 第几圈 | |
| 79 | - * @param bcIndex 第几个班次 | |
| 80 | - */ | |
| 81 | -InternalLpObj.prototype.getBc = function(qIndex, bcIndex) { | |
| 82 | - var group = this._$_groupBcArray[qIndex]; | |
| 83 | - var bc; | |
| 84 | - if (bcIndex == 0) { | |
| 85 | - bc = group.getBc1(); | |
| 86 | - } else if (bcIndex == 1) { | |
| 87 | - bc = group.getBc2(); | |
| 88 | - } | |
| 89 | - return bc; | |
| 90 | -}; | |
| 91 | - | |
| 92 | -/** | |
| 93 | - * 在具体位置设置班次。 | |
| 94 | - * @param qIndex 第几圈 | |
| 95 | - * @param bcIndex 第几个班次 | |
| 96 | - * @param bc 班次对象 | |
| 97 | - */ | |
| 98 | -InternalLpObj.prototype.setBc = function(qIndex, bcIndex, bc) { | |
| 99 | - var group = this._$_groupBcArray[qIndex]; | |
| 100 | - if (bcIndex == 0) { | |
| 101 | - group.setBc1(bc); | |
| 102 | - bc.setGroup(group); | |
| 103 | - } else if (bcIndex == 1) { | |
| 104 | - group.setBc2(bc); | |
| 105 | - bc.setGroup(group); | |
| 106 | - } | |
| 107 | -}; | |
| 108 | - | |
| 109 | -/** | |
| 110 | - * 设置原始路牌对象。 | |
| 111 | - * @param lpObj 原始路牌对象 | |
| 112 | - */ | |
| 113 | -InternalLpObj.prototype.setLp = function(lpObj) { | |
| 114 | - this._$$_orign_lp_obj = lpObj; | |
| 115 | - var i; | |
| 116 | - var group; | |
| 117 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 118 | - group = this._$_groupBcArray[i]; | |
| 119 | - if (group) { | |
| 120 | - group.setLp(this); // 圈和班次保存都是 InternalLpObj 对象 | |
| 121 | - } | |
| 122 | - } | |
| 123 | -}; | |
| 124 | - | |
| 125 | -InternalLpObj.prototype.getLpNo = function() { | |
| 126 | - return this._$$_orign_lp_obj.lpNo; | |
| 127 | -}; | |
| 128 | -InternalLpObj.prototype.getLpName = function() { | |
| 129 | - return this._$$_orign_lp_obj.lpName; | |
| 130 | -}; | |
| 131 | -InternalLpObj.prototype.setBxFb5_2 = function(fb) { | |
| 132 | - this._$_bx_isfb_5_2 = fb; | |
| 133 | -}; | |
| 134 | -InternalLpObj.prototype.isBxFb5_2 = function() { | |
| 135 | - return this._$_bx_isfb_5_2; | |
| 136 | -}; | |
| 137 | -InternalLpObj.prototype.setBxLb = function(lb) { | |
| 138 | - this._$_bx_isLb = lb; | |
| 139 | -}; | |
| 140 | -InternalLpObj.prototype.isBxLb = function() { | |
| 141 | - return this._$_bx_isLb; | |
| 142 | -}; | |
| 143 | - | |
| 144 | -InternalLpObj.prototype.setBxFb = function(fb) { | |
| 145 | - this._$_bx_isfb = fb; | |
| 146 | -}; | |
| 147 | -InternalLpObj.prototype.isBxFb = function() { | |
| 148 | - return this._$_bx_isfb; | |
| 149 | -}; | |
| 150 | - | |
| 151 | -/** | |
| 152 | - * 设置路牌的班型描述(最终是设置班次的路牌名字)。 | |
| 153 | - * @param desc 描述 | |
| 154 | - */ | |
| 155 | -InternalLpObj.prototype.setBxDesc = function(desc) { | |
| 156 | - // 最终原始路牌的名字 | |
| 157 | - this._$$_orign_lp_obj.lpName = desc + "_" + this._$$_orign_lp_obj.lpNo; | |
| 158 | - // 内部对象的班型描述 | |
| 159 | - this._$_bx_desc = desc; | |
| 160 | -}; | |
| 161 | -/** | |
| 162 | - * 获取版型描述 | |
| 163 | - * @returns string | |
| 164 | - */ | |
| 165 | -InternalLpObj.prototype.getBxDesc = function() { | |
| 166 | - return this._$_bx_desc; | |
| 167 | -}; | |
| 168 | - | |
| 169 | -/** | |
| 170 | - * 设置纵向最小发车间隔时间。 | |
| 171 | - * @param v | |
| 172 | - */ | |
| 173 | -InternalLpObj.prototype.setVerticalMinIntervalTime = function(v) { | |
| 174 | - // 第一个路牌,都为0 | |
| 175 | - this._$_minVerticalIntervalTime = v; | |
| 176 | -}; | |
| 177 | -/** | |
| 178 | - * 获取纵向最小发车间隔时间。 | |
| 179 | - * @returns {number|*} | |
| 180 | - */ | |
| 181 | -InternalLpObj.prototype.getVerticalMinIntervalTime = function() { | |
| 182 | - return this._$_minVerticalIntervalTime; | |
| 183 | -}; | |
| 184 | - | |
| 185 | -/** | |
| 186 | - * 设置纵向发车间隔。 | |
| 187 | - * @param iQindex 圈index | |
| 188 | - * @param iBindex 班次index | |
| 189 | - * @param iTime 间隔时间 | |
| 190 | - */ | |
| 191 | -InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) { | |
| 192 | - this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime; | |
| 193 | -}; | |
| 194 | - | |
| 195 | -/** | |
| 196 | - * 返回纵向发车间隔。 | |
| 197 | - * @param iQindex 圈index | |
| 198 | - * @param iBindex 班次index | |
| 199 | - */ | |
| 200 | -InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) { | |
| 201 | - return this._$_aVerticalIntervalTime[iQindex][iBindex]; | |
| 202 | -}; | |
| 203 | - | |
| 204 | -//-------------------- 班次操作方法(查询,统计,删除) -----------------------// | |
| 205 | - | |
| 206 | -/** | |
| 207 | - * 返回总共班次数。 | |
| 208 | - */ | |
| 209 | -InternalLpObj.prototype.getBcCount = function() { | |
| 210 | - var i; | |
| 211 | - var group; | |
| 212 | - var bccount = 0; | |
| 213 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 214 | - group = this._$_groupBcArray[i]; | |
| 215 | - if (group) { | |
| 216 | - if (group.getBc1()) { | |
| 217 | - bccount += 1; | |
| 218 | - } | |
| 219 | - if (group.getBc2()) { | |
| 220 | - bccount += 1; | |
| 221 | - } | |
| 222 | - } | |
| 223 | - } | |
| 224 | - | |
| 225 | - return bccount; | |
| 226 | -}; | |
| 227 | - | |
| 228 | -/** | |
| 229 | - * 返回班次列表,过滤空的班次,将所有存在的班次连成连续的对象数组返回。 | |
| 230 | - * @returns arrays (InternalBcObj) | |
| 231 | - */ | |
| 232 | -InternalLpObj.prototype.getBcArray = function() { | |
| 233 | - var bcArray = []; | |
| 234 | - var i; | |
| 235 | - var group; | |
| 236 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 237 | - group = this._$_groupBcArray[i]; | |
| 238 | - if (group) { | |
| 239 | - group.getBc1() ? bcArray.push(group.getBc1()) : ""; | |
| 240 | - group.getBc2() ? bcArray.push(group.getBc2()) : ""; | |
| 241 | - } | |
| 242 | - } | |
| 243 | - | |
| 244 | - return bcArray; | |
| 245 | -}; | |
| 246 | - | |
| 247 | -/** | |
| 248 | - * 获取最小(最早)班次对象。 | |
| 249 | - * @returns [{圈index},{班次index}] | |
| 250 | - */ | |
| 251 | -InternalLpObj.prototype.getMinBcObjPosition = function() { | |
| 252 | - var i; | |
| 253 | - var bIndex = []; | |
| 254 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 255 | - if (this._$_groupBcArray[i].getBc1()) { | |
| 256 | - bIndex.push(i); | |
| 257 | - bIndex.push(0); | |
| 258 | - break; | |
| 259 | - } | |
| 260 | - if (this._$_groupBcArray[i].getBc2()) { | |
| 261 | - bIndex.push(i); | |
| 262 | - bIndex.push(1); | |
| 263 | - break; | |
| 264 | - } | |
| 265 | - } | |
| 266 | - return bIndex; | |
| 267 | -}; | |
| 268 | - | |
| 269 | -/** | |
| 270 | - * 获取最大(最晚)班次对象。 | |
| 271 | - * @returns [{圈index},{班次index}] | |
| 272 | - */ | |
| 273 | -InternalLpObj.prototype.getMaxBcObjPosition = function() { | |
| 274 | - var i; | |
| 275 | - var bIndex = []; | |
| 276 | - for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 277 | - if (this._$_groupBcArray[i].getBc2()) { | |
| 278 | - bIndex.push(i); | |
| 279 | - bIndex.push(1); | |
| 280 | - break; | |
| 281 | - } | |
| 282 | - if (this._$_groupBcArray[i].getBc1()) { | |
| 283 | - bIndex.push(i); | |
| 284 | - bIndex.push(0); | |
| 285 | - break; | |
| 286 | - } | |
| 287 | - } | |
| 288 | - return bIndex; | |
| 289 | -}; | |
| 290 | - | |
| 291 | -InternalLpObj.prototype.getMinBcObj = function() { | |
| 292 | - var i; | |
| 293 | - var bcObj; | |
| 294 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 295 | - bcObj = this._$_groupBcArray[i].getBc1(); | |
| 296 | - if (bcObj) { | |
| 297 | - break; | |
| 298 | - } | |
| 299 | - bcObj = this._$_groupBcArray[i].getBc2(); | |
| 300 | - if (bcObj) { | |
| 301 | - break; | |
| 302 | - } | |
| 303 | - } | |
| 304 | - return bcObj; | |
| 305 | -}; | |
| 306 | -InternalLpObj.prototype.getMaxBcObj = function() { | |
| 307 | - var i; | |
| 308 | - var bcObj; | |
| 309 | - for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 310 | - bcObj = this._$_groupBcArray[i].getBc2(); | |
| 311 | - if (bcObj) { | |
| 312 | - break; | |
| 313 | - } | |
| 314 | - bcObj = this._$_groupBcArray[i].getBc1(); | |
| 315 | - if (bcObj) { | |
| 316 | - break; | |
| 317 | - } | |
| 318 | - } | |
| 319 | - return bcObj; | |
| 320 | -}; | |
| 321 | - | |
| 322 | -/** | |
| 323 | - * 获取车次链信息。 | |
| 324 | - * @param num 第几个车次链 | |
| 325 | - * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}} | |
| 326 | - */ | |
| 327 | -InternalLpObj.prototype.fnGetBcChainInfo = function(num) { | |
| 328 | - // 计算总的车次链信息 | |
| 329 | - var aChainInfo = []; | |
| 330 | - var oChainInfo; | |
| 331 | - var aBcIndex = this.getMinBcObjPosition(); | |
| 332 | - var oBc; | |
| 333 | - var iQIndex; | |
| 334 | - var iBcIndex; | |
| 335 | - var i; | |
| 336 | - var bFlag; | |
| 337 | - | |
| 338 | - var iBcount = 0; | |
| 339 | - | |
| 340 | - if (aBcIndex.length == 2) { | |
| 341 | - iBcount = 1; | |
| 342 | - oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1}; | |
| 343 | - aChainInfo.push(oChainInfo); | |
| 344 | - bFlag = true; | |
| 345 | - | |
| 346 | - // 下一个班次的索引 | |
| 347 | - iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 348 | - iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 349 | - | |
| 350 | - for (i = iQIndex; i < this._$_qCount; i++) { | |
| 351 | - while (iBcIndex <= 1) { | |
| 352 | - oBc = this.getBc(i, iBcIndex); | |
| 353 | - if (!oBc) { | |
| 354 | - if (bFlag) { | |
| 355 | - // 车次链结尾是这个班次的前一个班次 | |
| 356 | - oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i; | |
| 357 | - oChainInfo.e_b = iBcIndex == 0 ? 1 : 0; | |
| 358 | - oChainInfo.bcount = iBcount; | |
| 359 | - } | |
| 360 | - | |
| 361 | - bFlag = false; | |
| 362 | - } else { | |
| 363 | - if (bFlag) { | |
| 364 | - iBcount ++; | |
| 365 | - oChainInfo.bcount = iBcount; | |
| 366 | - } else { | |
| 367 | - // 下一个车次链开始 | |
| 368 | - iBcount = 1; | |
| 369 | - oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1}; | |
| 370 | - aChainInfo.push(oChainInfo); | |
| 371 | - bFlag = true; | |
| 372 | - } | |
| 373 | - } | |
| 374 | - | |
| 375 | - | |
| 376 | - iBcIndex ++; | |
| 377 | - } | |
| 378 | - iBcIndex = 0; | |
| 379 | - } | |
| 380 | - | |
| 381 | - } | |
| 382 | - | |
| 383 | - return aChainInfo[num]; | |
| 384 | -}; | |
| 385 | - | |
| 386 | -/** | |
| 387 | - * 获取车次链的个数。 | |
| 388 | - * @returns int | |
| 389 | - */ | |
| 390 | -InternalLpObj.prototype.fnGetBcChainCount = function() { | |
| 391 | - var iChainCount = 0; | |
| 392 | - var aBcIndex = this.getMinBcObjPosition(); | |
| 393 | - | |
| 394 | - var oBc; | |
| 395 | - var iQIndex; | |
| 396 | - var iBcIndex; | |
| 397 | - var i; | |
| 398 | - var bFlag; | |
| 399 | - | |
| 400 | - if (aBcIndex.length == 2) { | |
| 401 | - iChainCount = 1; | |
| 402 | - bFlag = true; | |
| 403 | - | |
| 404 | - // 下一个班次的索引 | |
| 405 | - iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 406 | - iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 407 | - | |
| 408 | - for (i = iQIndex; i < this._$_qCount; i++) { | |
| 409 | - while (iBcIndex <= 1) { | |
| 410 | - oBc = this.getBc(i, iBcIndex); | |
| 411 | - if (!oBc) { | |
| 412 | - bFlag = false; | |
| 413 | - } else { | |
| 414 | - if (bFlag) { | |
| 415 | - | |
| 416 | - } else { | |
| 417 | - iChainCount ++; | |
| 418 | - bFlag = true; | |
| 419 | - } | |
| 420 | - } | |
| 421 | - | |
| 422 | - | |
| 423 | - iBcIndex ++; | |
| 424 | - } | |
| 425 | - iBcIndex = 0; | |
| 426 | - } | |
| 427 | - | |
| 428 | - } | |
| 429 | - | |
| 430 | - | |
| 431 | - return iChainCount; | |
| 432 | -}; | |
| 433 | - | |
| 434 | -/** | |
| 435 | - * 在具体位置移除班次。 | |
| 436 | - * @param qIndex 第几圈 | |
| 437 | - * @param bcIndex 第几个班次 | |
| 438 | - */ | |
| 439 | -InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) { | |
| 440 | - var group = this._$_groupBcArray[qIndex]; | |
| 441 | - if (bcIndex == 0) { | |
| 442 | - group.removeBc1(); | |
| 443 | - } else if (bcIndex == 1) { | |
| 444 | - group.removeBc2(); | |
| 445 | - } | |
| 446 | -}; | |
| 447 | - | |
| 448 | -/** | |
| 449 | - * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 450 | - * 使用时间差的绝度值,比较,取最小的 | |
| 451 | - * 如果有两个一样的时间差,取比fctime大的时间 | |
| 452 | - * @param fctime moment 比较用时间 | |
| 453 | - * @param groupArray 圈数组 | |
| 454 | - * @param hasUp boolean 计算上行班次 | |
| 455 | - * @param hasDown boolean 计算下行班次 | |
| 456 | - * @returns [{第几圈},{第几个班次}] | |
| 457 | - */ | |
| 458 | -InternalLpObj.prototype.fnGetQBcIndexWithFcTimeFromGroupArray = function( | |
| 459 | - fctime, groupArray, hasUp, hasDown | |
| 460 | -) { | |
| 461 | - var i; | |
| 462 | - var timediff; // 时间差取绝对值 | |
| 463 | - var qIndex; | |
| 464 | - var bcIndex; | |
| 465 | - | |
| 466 | - var group; | |
| 467 | - var bc1time; | |
| 468 | - var bc2time; | |
| 469 | - | |
| 470 | - var tempdiff; | |
| 471 | - | |
| 472 | - console.log("比较时间=" + fctime.format("HH:mm")); | |
| 473 | - | |
| 474 | - for (i = 0; i < this._$_qCount; i++) { | |
| 475 | - group = groupArray[i]; | |
| 476 | - if (group) { | |
| 477 | - if (group.getBc1() && hasUp) { | |
| 478 | - bc1time = group.getBc1().getFcTimeObj(); | |
| 479 | - console.log("bc1time=" + bc1time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 480 | - tempdiff = Math.abs(bc1time.diff(fctime)); | |
| 481 | - | |
| 482 | - if (!timediff) { | |
| 483 | - timediff = Math.abs(tempdiff); | |
| 484 | - qIndex = i; | |
| 485 | - bcIndex = 0; | |
| 486 | - } else { | |
| 487 | - if (tempdiff < timediff) { | |
| 488 | - timediff = tempdiff; | |
| 489 | - qIndex = i; | |
| 490 | - bcIndex = 0; | |
| 491 | - } if (Math.abs(tempdiff) == timediff) { | |
| 492 | - if (bc1time.isAfter(fctime)) { | |
| 493 | - timediff = tempdiff; | |
| 494 | - qIndex = i; | |
| 495 | - bcIndex = 0; | |
| 496 | - } | |
| 497 | - | |
| 498 | - } | |
| 499 | - } | |
| 500 | - } | |
| 501 | - | |
| 502 | - if (group.getBc2() && hasDown) { | |
| 503 | - bc2time = group.getBc2().getFcTimeObj(); | |
| 504 | - console.log("bc2time=" + bc2time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 505 | - tempdiff = Math.abs(bc2time.diff(fctime)); | |
| 506 | - | |
| 507 | - if (!timediff) { | |
| 508 | - timediff = Math.abs(tempdiff); | |
| 509 | - qIndex = i; | |
| 510 | - bcIndex = 1; | |
| 511 | - } else { | |
| 512 | - if (tempdiff < timediff) { | |
| 513 | - timediff = tempdiff; | |
| 514 | - qIndex = i; | |
| 515 | - bcIndex = 1; | |
| 516 | - } if (Math.abs(tempdiff) == timediff) { | |
| 517 | - if (bc2time.isBefore(fctime)) { | |
| 518 | - timediff = tempdiff; | |
| 519 | - qIndex = i; | |
| 520 | - bcIndex = 1; | |
| 521 | - } | |
| 522 | - | |
| 523 | - } | |
| 524 | - } | |
| 525 | - } | |
| 526 | - } | |
| 527 | - } | |
| 528 | - | |
| 529 | - console.log("中标线对应数组索引=" + qIndex); | |
| 530 | - | |
| 531 | - var rst = []; | |
| 532 | - rst.push(qIndex); | |
| 533 | - rst.push(bcIndex); | |
| 534 | - | |
| 535 | - return rst; | |
| 536 | -}; | |
| 537 | - | |
| 538 | -/** | |
| 539 | - * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 540 | - * 使用时间差的绝度值,比较,取最小的 | |
| 541 | - * 如果有两个一样的时间差,取比fctime大的时间 | |
| 542 | - * @param fctime moment 比较用时间 | |
| 543 | - * @param hasUp boolean 计算上行班次 | |
| 544 | - * @param hasDown boolean 计算下行班次 | |
| 545 | - * @returns [{第几圈},{第几个班次}] | |
| 546 | - */ | |
| 547 | -InternalLpObj.prototype.getQBcIndexWithFcTime = function( | |
| 548 | - fctime, hasUp, hasDown | |
| 549 | -) { | |
| 550 | - return this.fnGetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown); | |
| 551 | -}; | |
| 552 | - | |
| 553 | -//---------------------- 内部数据初始化方法(不同于构造函数)---------------------// | |
| 554 | - | |
| 555 | -/** | |
| 556 | - * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌 | |
| 557 | - * 注意,之前有班次会删除后再创建。 | |
| 558 | - * @param startTime 开始时间 | |
| 559 | - * @param endTime 结束时间 | |
| 560 | - * @param isUp 第一个班次是上行还是下行 | |
| 561 | - * @param fromQ 从第几圈开始加入 | |
| 562 | - * @param paramObj 参数对象 | |
| 563 | - * @param factory 工厂对象 | |
| 564 | - */ | |
| 565 | -InternalLpObj.prototype.initDataFromTimeToTime = function( | |
| 566 | - startTime, | |
| 567 | - endTime, | |
| 568 | - isUp, | |
| 569 | - fromQ, | |
| 570 | - paramObj, | |
| 571 | - factory) { | |
| 572 | - | |
| 573 | - var bcData = []; // 班次数组 | |
| 574 | - var bcObj; | |
| 575 | - var kssj = startTime; | |
| 576 | - var fcno = 1; // 发车顺序号 | |
| 577 | - var bcCount = 1; // 班次数 | |
| 578 | - do { | |
| 579 | - bcObj = factory.createBcObj( | |
| 580 | - this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象 | |
| 581 | - bcData.push(bcObj); | |
| 582 | - | |
| 583 | - kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime()); | |
| 584 | - fcno ++; | |
| 585 | - bcCount ++; | |
| 586 | - isUp = !isUp; | |
| 587 | - } while(kssj.isBefore(endTime)); | |
| 588 | - bcCount--; | |
| 589 | - | |
| 590 | - //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm")); | |
| 591 | - //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm")); | |
| 592 | - //console.log("endtime: " + endTime.format("HH:mm")); | |
| 593 | - | |
| 594 | - //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) { | |
| 595 | - // // 如果最后一个班次的到达时间超过结束时间,也要去除 | |
| 596 | - // bcData.splice(bcCount - 1, 1); | |
| 597 | - //} | |
| 598 | - | |
| 599 | - this._initDataFromLbBcArray(bcData, fromQ); | |
| 600 | - | |
| 601 | -}; | |
| 602 | - | |
| 603 | -/** | |
| 604 | - * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。 | |
| 605 | - * @param bcArray 连班班次数组 | |
| 606 | - * @param fromQ 从第几圈开始加入 | |
| 607 | - */ | |
| 608 | -InternalLpObj.prototype._initDataFromLbBcArray = function( | |
| 609 | - bcArray, | |
| 610 | - fromQ | |
| 611 | -) { | |
| 612 | - var _bc1Obj; | |
| 613 | - var _bc2Obj; | |
| 614 | - var _qObj; | |
| 615 | - | |
| 616 | - // 第一班次是上行还是下行 | |
| 617 | - var isUp = bcArray[0].isUp(); | |
| 618 | - | |
| 619 | - if (bcArray.length > 0 && fromQ < this._$_qCount) { | |
| 620 | - // 构造圈数 | |
| 621 | - if (isUp != this._$_isUp) { | |
| 622 | - // 如果方向不一致,意味着第一个班次是半圈 | |
| 623 | - // 加半圈,并加在bc2上 | |
| 624 | - _bc2Obj = bcArray.slice(0, 1)[0]; | |
| 625 | - _qObj = new InternalGroupObj( | |
| 626 | - this, | |
| 627 | - this._$_isUp, | |
| 628 | - undefined, | |
| 629 | - _bc2Obj | |
| 630 | - ); | |
| 631 | - _bc2Obj.setGroup(_qObj); | |
| 632 | - this._$_groupBcArray[fromQ] = _qObj; | |
| 633 | - | |
| 634 | - bcArray.splice(0, 1); | |
| 635 | - fromQ ++; | |
| 636 | - } | |
| 637 | - | |
| 638 | - var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈 | |
| 639 | - var qCount2 = bcArray.length % 2; // 最后是否有半圈 | |
| 640 | - | |
| 641 | - while (fromQ < this._$_qCount) { | |
| 642 | - if (qCount1 > 0) { | |
| 643 | - _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 644 | - _bc2Obj = bcArray.slice(1, 2)[0]; | |
| 645 | - _qObj = new InternalGroupObj( | |
| 646 | - this, | |
| 647 | - this._$_isUp, | |
| 648 | - _bc1Obj, | |
| 649 | - _bc2Obj | |
| 650 | - ); | |
| 651 | - _bc1Obj.setGroup(_qObj); | |
| 652 | - _bc2Obj.setGroup(_qObj); | |
| 653 | - this._$_groupBcArray[fromQ] = _qObj; | |
| 654 | - | |
| 655 | - bcArray.splice(0, 2); | |
| 656 | - qCount1 --; | |
| 657 | - } else if (qCount2 > 0) { | |
| 658 | - // 加半圈,并加在bc1上 | |
| 659 | - _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 660 | - _qObj = new InternalGroupObj( | |
| 661 | - this, | |
| 662 | - this._$_isUp, | |
| 663 | - _bc1Obj, | |
| 664 | - undefined | |
| 665 | - ); | |
| 666 | - _bc1Obj.setGroup(_qObj); | |
| 667 | - this._$_groupBcArray[fromQ] = _qObj; | |
| 668 | - | |
| 669 | - bcArray.splice(0, 1); | |
| 670 | - qCount2 --; | |
| 671 | - } else { | |
| 672 | - break; | |
| 673 | - } | |
| 674 | - | |
| 675 | - fromQ ++; | |
| 676 | - } | |
| 677 | - } | |
| 678 | -}; | |
| 679 | - | |
| 680 | -//-------------------------- 其他方法 ----------------------------// | |
| 681 | - | |
| 682 | -/** | |
| 683 | - * 从指定位置的班次开始,往后所有的班次修正发车时间 | |
| 684 | - * @param groupIndex | |
| 685 | - * @param bcIndex | |
| 686 | - * @param time | |
| 687 | - */ | |
| 688 | -InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) { | |
| 689 | - var i; | |
| 690 | - var oCurBc; | |
| 691 | - | |
| 692 | - // 修正之前班次的停站时间 | |
| 693 | - //oCurBc = this.getBc( | |
| 694 | - // bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 695 | - // bcIndex == 1 ? 0 : 1 | |
| 696 | - //); | |
| 697 | - //if (oCurBc) { | |
| 698 | - // oCurBc.setStopTime(oCurBc.getStopTime() + time); | |
| 699 | - //} | |
| 700 | - | |
| 701 | - | |
| 702 | - for (i = groupIndex; i < this._$_qCount; i++) { | |
| 703 | - if (bcIndex == 0) { | |
| 704 | - oCurBc = this.getBc(i, 0); | |
| 705 | - if (oCurBc) { | |
| 706 | - oCurBc.addMinuteToFcsj(time); | |
| 707 | - } | |
| 708 | - oCurBc = this.getBc(i, 1); | |
| 709 | - if (oCurBc) { | |
| 710 | - oCurBc.addMinuteToFcsj(time); | |
| 711 | - } | |
| 712 | - | |
| 713 | - } else { | |
| 714 | - oCurBc = this.getBc(i, 1); | |
| 715 | - if (oCurBc) { | |
| 716 | - oCurBc.addMinuteToFcsj(time); | |
| 717 | - } | |
| 718 | - | |
| 719 | - } | |
| 720 | - | |
| 721 | - bcIndex = 0; | |
| 722 | - } | |
| 723 | -}; | |
| 724 | - | |
| 725 | -/** | |
| 726 | - * 在指定位置添加一个吃饭班次。 | |
| 727 | - * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array | |
| 728 | - * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化 | |
| 729 | - * @param groupIndex | |
| 730 | - * @param bcIndex | |
| 731 | - * @param factory | |
| 732 | - * @param paramObj | |
| 733 | - * @returns int 相差时间(吃饭时间距离和停站时间相差值) | |
| 734 | - */ | |
| 735 | -InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) { | |
| 736 | - var oPreBc; | |
| 737 | - var oEatBc; | |
| 738 | - var iBcModifyTime; | |
| 739 | - oPreBc = this.getBc( // 前一个邻接班次 | |
| 740 | - bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 741 | - bcIndex == 1 ? 0 : 1); | |
| 742 | - if (oPreBc) { // 存在前一个班次 | |
| 743 | - oEatBc = factory.createBcObj( | |
| 744 | - this, | |
| 745 | - "cf", | |
| 746 | - !oPreBc.isUp(), // 和上一个班次方向相反 | |
| 747 | - 1, | |
| 748 | - paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间 | |
| 749 | - paramObj | |
| 750 | - ); | |
| 751 | - | |
| 752 | - //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间 | |
| 753 | - | |
| 754 | - // 修正之后的班次发车时间 | |
| 755 | - // 注意:之后那个班次发车时间就是吃饭班次的到达时间 | |
| 756 | - iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m"); | |
| 757 | - this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime); | |
| 758 | - | |
| 759 | - oPreBc.setStopTime(0); // 不重置停站时间 | |
| 760 | - oPreBc.fnSetEatTime(oEatBc.getBcTime()); | |
| 761 | - | |
| 762 | - //this._$_other_bc_array.push(oEatBc); | |
| 763 | - | |
| 764 | - return iBcModifyTime; | |
| 765 | - } else { | |
| 766 | - return false; | |
| 767 | - } | |
| 768 | - | |
| 769 | -}; | |
| 770 | - | |
| 771 | -/** | |
| 772 | - * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。 | |
| 773 | - * @param iPeakAverStopTime 高峰平均停站时间 | |
| 774 | - * @param iTroughAverStopTime 低谷平均停站时间 | |
| 775 | - * @param oParam 参数对象 | |
| 776 | - */ | |
| 777 | -InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) { | |
| 778 | - // 获取车次链个数 | |
| 779 | - var iBcChainCount = this.fnGetBcChainCount(); | |
| 780 | - | |
| 781 | - var i; | |
| 782 | - var j; | |
| 783 | - var oBcIndex; | |
| 784 | - var iQIndex; | |
| 785 | - var iBcIndex; | |
| 786 | - var iBcCount; | |
| 787 | - var oBc; | |
| 788 | - var oNextBc; | |
| 789 | - | |
| 790 | - var iBcStopTime; | |
| 791 | - | |
| 792 | - for (i = 0; i < iBcChainCount; i++) { | |
| 793 | - oBcIndex = this.fnGetBcChainInfo(i); | |
| 794 | - iQIndex = oBcIndex["s_q"]; | |
| 795 | - iBcIndex = oBcIndex["s_b"]; | |
| 796 | - iBcCount = oBcIndex["bcount"]; | |
| 797 | - | |
| 798 | - for (j = 0; j < iBcCount - 1; j++) { | |
| 799 | - oBc = this.getBc(iQIndex, iBcIndex); | |
| 800 | - oNextBc = this.getBc( | |
| 801 | - iBcIndex == 0 ? iQIndex : iQIndex + 1, | |
| 802 | - iBcIndex == 0 ? 1 : 0); | |
| 803 | - | |
| 804 | - if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理 | |
| 805 | - continue; | |
| 806 | - } | |
| 807 | - | |
| 808 | - // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间 | |
| 809 | - iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m"); | |
| 810 | - if (iBcStopTime < 0) { | |
| 811 | - // 当前班次使用最小停站时间 | |
| 812 | - oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 813 | - oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 814 | - | |
| 815 | - } else { | |
| 816 | - if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) { | |
| 817 | - // 停站时间一致,没有问题 | |
| 818 | - | |
| 819 | - | |
| 820 | - } else { | |
| 821 | - // TODO:当前班次使用最小停站时间 | |
| 822 | - oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 823 | - oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 824 | - | |
| 825 | - } | |
| 826 | - } | |
| 827 | - | |
| 828 | - iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 829 | - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 830 | - } | |
| 831 | - | |
| 832 | - this.getBc(iQIndex, iBcIndex).setStopTime(0); | |
| 833 | - } | |
| 834 | - | |
| 835 | - | |
| 836 | -}; | |
| 837 | - | |
| 838 | - | |
| 839 | -// TODO | |
| 840 | - | |
| 841 | -/** | |
| 842 | - * | |
| 843 | - * | |
| 844 | - */ | |
| 845 | -InternalLpObj.prototype.calcuLpBx = function() { | |
| 846 | - | |
| 847 | -}; | |
| 848 | - | |
| 849 | - | |
| 850 | - | |
| 851 | - | |
| 852 | - | |
| 853 | - | |
| 854 | - | |
| 1 | +/** | |
| 2 | + * 内部路牌对象。 | |
| 3 | + * @constructor | |
| 4 | + */ | |
| 5 | +var InternalLpObj = function( | |
| 6 | + orilpObj, // 原始路牌对象 | |
| 7 | + qCount, // 总共多少圈 | |
| 8 | + isUp // 圈是以上行开始还是下行开始 | |
| 9 | +) { | |
| 10 | + // TODO:原始路牌对象(这个路牌是对接外部gantt图像,以后有机会改了) | |
| 11 | + this._$$_orign_lp_obj = orilpObj; | |
| 12 | + | |
| 13 | + this._$_isUp = isUp; | |
| 14 | + | |
| 15 | + // 路牌的圈数,注意每个路牌的圈数都是一致的, | |
| 16 | + // 但并不是每一圈都有值 | |
| 17 | + // 第1圈从上标线开始 | |
| 18 | + // 第0圈表示中标线的第一个班次组成的半圈 | |
| 19 | + // 有多少圈根据最终迭代的结果来看 | |
| 20 | + this._$_qCount = qCount; | |
| 21 | + // 保存的是 InternalGroupBcObj 对象 | |
| 22 | + this._$_groupBcArray = new Array(qCount); | |
| 23 | + | |
| 24 | + var i; | |
| 25 | + for (i = 0; i < this._$_qCount; i++) { | |
| 26 | + this._$_groupBcArray[i] = new InternalGroupObj( | |
| 27 | + this, this._$_isUp, undefined, undefined); | |
| 28 | + } | |
| 29 | + | |
| 30 | + // 距离上一个路牌的最小发车间隔时间 | |
| 31 | + // 用于纵向添加班次的时候使用 | |
| 32 | + // 默认第一个路牌为0 | |
| 33 | + this._$_minVerticalIntervalTime = 0; | |
| 34 | + | |
| 35 | + // 详细记录每圈每个方向上的发车间隔时间 | |
| 36 | + // 第一维度表示圈数,第二维度表示第一个方向,第二个方向 | |
| 37 | + // 第一个方向是否上行由 _$_isUp 决定 | |
| 38 | + // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔 | |
| 39 | + // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔 | |
| 40 | + this._$_aVerticalIntervalTime = new Array(this._$_qCount); | |
| 41 | + var i; | |
| 42 | + for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) { | |
| 43 | + this._$_aVerticalIntervalTime[i] = new Array(2); | |
| 44 | + } | |
| 45 | + | |
| 46 | + // 班型的相关变量 | |
| 47 | + this._$_bx_isLb = false; // 是否连班 | |
| 48 | + this._$_bx_isfb = false; // 是否分班 | |
| 49 | + this._$_bx_isfb_5_2 = false; // 是否5休2分班 | |
| 50 | + this._$_bx_desc; // 班型描述(默认为路牌编号) | |
| 51 | + | |
| 52 | + // 其他班次(进出场,例包,吃饭等),TODO:以后再拆 | |
| 53 | + this._$_other_bc_array = []; | |
| 54 | + | |
| 55 | + // TODO: | |
| 56 | + | |
| 57 | +}; | |
| 58 | + | |
| 59 | +//------------------- get/set 方法 -------------------// | |
| 60 | + | |
| 61 | +InternalLpObj.prototype.getOtherBcArray = function() { | |
| 62 | + return this._$_other_bc_array; | |
| 63 | +}; | |
| 64 | +InternalLpObj.prototype.addOtherBcArray = function(ba) { | |
| 65 | + this._$_other_bc_array = this._$_other_bc_array.concat(ba); | |
| 66 | +}; | |
| 67 | + | |
| 68 | +/** | |
| 69 | + * 获取圈 | |
| 70 | + * @param qIndex 圈index | |
| 71 | + */ | |
| 72 | +InternalLpObj.prototype.getGroup = function(qIndex) { | |
| 73 | + return this._$_groupBcArray[qIndex]; | |
| 74 | +}; | |
| 75 | + | |
| 76 | +/** | |
| 77 | + * 获取班次。 | |
| 78 | + * @param qIndex 第几圈 | |
| 79 | + * @param bcIndex 第几个班次 | |
| 80 | + */ | |
| 81 | +InternalLpObj.prototype.getBc = function(qIndex, bcIndex) { | |
| 82 | + var group = this._$_groupBcArray[qIndex]; | |
| 83 | + var bc; | |
| 84 | + if (bcIndex == 0) { | |
| 85 | + bc = group.getBc1(); | |
| 86 | + } else if (bcIndex == 1) { | |
| 87 | + bc = group.getBc2(); | |
| 88 | + } | |
| 89 | + return bc; | |
| 90 | +}; | |
| 91 | + | |
| 92 | +/** | |
| 93 | + * 在具体位置设置班次。 | |
| 94 | + * @param qIndex 第几圈 | |
| 95 | + * @param bcIndex 第几个班次 | |
| 96 | + * @param bc 班次对象 | |
| 97 | + */ | |
| 98 | +InternalLpObj.prototype.setBc = function(qIndex, bcIndex, bc) { | |
| 99 | + var group = this._$_groupBcArray[qIndex]; | |
| 100 | + if (bcIndex == 0) { | |
| 101 | + group.setBc1(bc); | |
| 102 | + bc.setGroup(group); | |
| 103 | + } else if (bcIndex == 1) { | |
| 104 | + group.setBc2(bc); | |
| 105 | + bc.setGroup(group); | |
| 106 | + } | |
| 107 | +}; | |
| 108 | + | |
| 109 | +/** | |
| 110 | + * 设置原始路牌对象。 | |
| 111 | + * @param lpObj 原始路牌对象 | |
| 112 | + */ | |
| 113 | +InternalLpObj.prototype.setLp = function(lpObj) { | |
| 114 | + this._$$_orign_lp_obj = lpObj; | |
| 115 | + var i; | |
| 116 | + var group; | |
| 117 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 118 | + group = this._$_groupBcArray[i]; | |
| 119 | + if (group) { | |
| 120 | + group.setLp(this); // 圈和班次保存都是 InternalLpObj 对象 | |
| 121 | + } | |
| 122 | + } | |
| 123 | +}; | |
| 124 | + | |
| 125 | +InternalLpObj.prototype.getLpNo = function() { | |
| 126 | + return this._$$_orign_lp_obj.lpNo; | |
| 127 | +}; | |
| 128 | +InternalLpObj.prototype.getLpName = function() { | |
| 129 | + return this._$$_orign_lp_obj.lpName; | |
| 130 | +}; | |
| 131 | +InternalLpObj.prototype.setBxFb5_2 = function(fb) { | |
| 132 | + this._$_bx_isfb_5_2 = fb; | |
| 133 | +}; | |
| 134 | +InternalLpObj.prototype.isBxFb5_2 = function() { | |
| 135 | + return this._$_bx_isfb_5_2; | |
| 136 | +}; | |
| 137 | +InternalLpObj.prototype.setBxLb = function(lb) { | |
| 138 | + this._$_bx_isLb = lb; | |
| 139 | +}; | |
| 140 | +InternalLpObj.prototype.isBxLb = function() { | |
| 141 | + return this._$_bx_isLb; | |
| 142 | +}; | |
| 143 | + | |
| 144 | +InternalLpObj.prototype.setBxFb = function(fb) { | |
| 145 | + this._$_bx_isfb = fb; | |
| 146 | +}; | |
| 147 | +InternalLpObj.prototype.isBxFb = function() { | |
| 148 | + return this._$_bx_isfb; | |
| 149 | +}; | |
| 150 | + | |
| 151 | +/** | |
| 152 | + * 设置路牌的班型描述(最终是设置班次的路牌名字)。 | |
| 153 | + * @param desc 描述 | |
| 154 | + */ | |
| 155 | +InternalLpObj.prototype.setBxDesc = function(desc) { | |
| 156 | + // 最终原始路牌的名字 | |
| 157 | + this._$$_orign_lp_obj.lpName = desc + "_" + this._$$_orign_lp_obj.lpNo; | |
| 158 | + // 内部对象的班型描述 | |
| 159 | + this._$_bx_desc = desc; | |
| 160 | +}; | |
| 161 | +/** | |
| 162 | + * 获取版型描述 | |
| 163 | + * @returns string | |
| 164 | + */ | |
| 165 | +InternalLpObj.prototype.getBxDesc = function() { | |
| 166 | + return this._$_bx_desc; | |
| 167 | +}; | |
| 168 | + | |
| 169 | +/** | |
| 170 | + * 设置纵向最小发车间隔时间。 | |
| 171 | + * @param v | |
| 172 | + */ | |
| 173 | +InternalLpObj.prototype.setVerticalMinIntervalTime = function(v) { | |
| 174 | + // 第一个路牌,都为0 | |
| 175 | + this._$_minVerticalIntervalTime = v; | |
| 176 | +}; | |
| 177 | +/** | |
| 178 | + * 获取纵向最小发车间隔时间。 | |
| 179 | + * @returns {number|*} | |
| 180 | + */ | |
| 181 | +InternalLpObj.prototype.getVerticalMinIntervalTime = function() { | |
| 182 | + return this._$_minVerticalIntervalTime; | |
| 183 | +}; | |
| 184 | + | |
| 185 | +/** | |
| 186 | + * 设置纵向发车间隔。 | |
| 187 | + * @param iQindex 圈index | |
| 188 | + * @param iBindex 班次index | |
| 189 | + * @param iTime 间隔时间 | |
| 190 | + */ | |
| 191 | +InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) { | |
| 192 | + this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime; | |
| 193 | +}; | |
| 194 | + | |
| 195 | +/** | |
| 196 | + * 返回纵向发车间隔。 | |
| 197 | + * @param iQindex 圈index | |
| 198 | + * @param iBindex 班次index | |
| 199 | + */ | |
| 200 | +InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) { | |
| 201 | + return this._$_aVerticalIntervalTime[iQindex][iBindex]; | |
| 202 | +}; | |
| 203 | + | |
| 204 | +//-------------------- 班次操作方法(查询,统计,删除) -----------------------// | |
| 205 | + | |
| 206 | +/** | |
| 207 | + * 返回总共班次数。 | |
| 208 | + */ | |
| 209 | +InternalLpObj.prototype.getBcCount = function() { | |
| 210 | + var i; | |
| 211 | + var group; | |
| 212 | + var bccount = 0; | |
| 213 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 214 | + group = this._$_groupBcArray[i]; | |
| 215 | + if (group) { | |
| 216 | + if (group.getBc1()) { | |
| 217 | + bccount += 1; | |
| 218 | + } | |
| 219 | + if (group.getBc2()) { | |
| 220 | + bccount += 1; | |
| 221 | + } | |
| 222 | + } | |
| 223 | + } | |
| 224 | + | |
| 225 | + return bccount; | |
| 226 | +}; | |
| 227 | + | |
| 228 | +/** | |
| 229 | + * 返回班次列表,过滤空的班次,将所有存在的班次连成连续的对象数组返回。 | |
| 230 | + * @returns arrays (InternalBcObj) | |
| 231 | + */ | |
| 232 | +InternalLpObj.prototype.getBcArray = function() { | |
| 233 | + var bcArray = []; | |
| 234 | + var i; | |
| 235 | + var group; | |
| 236 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 237 | + group = this._$_groupBcArray[i]; | |
| 238 | + if (group) { | |
| 239 | + group.getBc1() ? bcArray.push(group.getBc1()) : ""; | |
| 240 | + group.getBc2() ? bcArray.push(group.getBc2()) : ""; | |
| 241 | + } | |
| 242 | + } | |
| 243 | + | |
| 244 | + return bcArray; | |
| 245 | +}; | |
| 246 | + | |
| 247 | +/** | |
| 248 | + * 获取最小(最早)班次对象。 | |
| 249 | + * @returns [{圈index},{班次index}] | |
| 250 | + */ | |
| 251 | +InternalLpObj.prototype.getMinBcObjPosition = function() { | |
| 252 | + var i; | |
| 253 | + var bIndex = []; | |
| 254 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 255 | + if (this._$_groupBcArray[i].getBc1()) { | |
| 256 | + bIndex.push(i); | |
| 257 | + bIndex.push(0); | |
| 258 | + break; | |
| 259 | + } | |
| 260 | + if (this._$_groupBcArray[i].getBc2()) { | |
| 261 | + bIndex.push(i); | |
| 262 | + bIndex.push(1); | |
| 263 | + break; | |
| 264 | + } | |
| 265 | + } | |
| 266 | + return bIndex; | |
| 267 | +}; | |
| 268 | + | |
| 269 | +/** | |
| 270 | + * 获取最大(最晚)班次对象。 | |
| 271 | + * @returns [{圈index},{班次index}] | |
| 272 | + */ | |
| 273 | +InternalLpObj.prototype.getMaxBcObjPosition = function() { | |
| 274 | + var i; | |
| 275 | + var bIndex = []; | |
| 276 | + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 277 | + if (this._$_groupBcArray[i].getBc2()) { | |
| 278 | + bIndex.push(i); | |
| 279 | + bIndex.push(1); | |
| 280 | + break; | |
| 281 | + } | |
| 282 | + if (this._$_groupBcArray[i].getBc1()) { | |
| 283 | + bIndex.push(i); | |
| 284 | + bIndex.push(0); | |
| 285 | + break; | |
| 286 | + } | |
| 287 | + } | |
| 288 | + return bIndex; | |
| 289 | +}; | |
| 290 | + | |
| 291 | +InternalLpObj.prototype.getMinBcObj = function() { | |
| 292 | + var i; | |
| 293 | + var bcObj; | |
| 294 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 295 | + bcObj = this._$_groupBcArray[i].getBc1(); | |
| 296 | + if (bcObj) { | |
| 297 | + break; | |
| 298 | + } | |
| 299 | + bcObj = this._$_groupBcArray[i].getBc2(); | |
| 300 | + if (bcObj) { | |
| 301 | + break; | |
| 302 | + } | |
| 303 | + } | |
| 304 | + return bcObj; | |
| 305 | +}; | |
| 306 | +InternalLpObj.prototype.getMaxBcObj = function() { | |
| 307 | + var i; | |
| 308 | + var bcObj; | |
| 309 | + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 310 | + bcObj = this._$_groupBcArray[i].getBc2(); | |
| 311 | + if (bcObj) { | |
| 312 | + break; | |
| 313 | + } | |
| 314 | + bcObj = this._$_groupBcArray[i].getBc1(); | |
| 315 | + if (bcObj) { | |
| 316 | + break; | |
| 317 | + } | |
| 318 | + } | |
| 319 | + return bcObj; | |
| 320 | +}; | |
| 321 | + | |
| 322 | +/** | |
| 323 | + * 获取车次链信息。 | |
| 324 | + * @param num 第几个车次链 | |
| 325 | + * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}} | |
| 326 | + */ | |
| 327 | +InternalLpObj.prototype.fnGetBcChainInfo = function(num) { | |
| 328 | + // 计算总的车次链信息 | |
| 329 | + var aChainInfo = []; | |
| 330 | + var oChainInfo; | |
| 331 | + var aBcIndex = this.getMinBcObjPosition(); | |
| 332 | + var oBc; | |
| 333 | + var iQIndex; | |
| 334 | + var iBcIndex; | |
| 335 | + var i; | |
| 336 | + var bFlag; | |
| 337 | + | |
| 338 | + var iBcount = 0; | |
| 339 | + | |
| 340 | + if (aBcIndex.length == 2) { | |
| 341 | + iBcount = 1; | |
| 342 | + oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1}; | |
| 343 | + aChainInfo.push(oChainInfo); | |
| 344 | + bFlag = true; | |
| 345 | + | |
| 346 | + // 下一个班次的索引 | |
| 347 | + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 348 | + iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 349 | + | |
| 350 | + for (i = iQIndex; i < this._$_qCount; i++) { | |
| 351 | + while (iBcIndex <= 1) { | |
| 352 | + oBc = this.getBc(i, iBcIndex); | |
| 353 | + if (!oBc) { | |
| 354 | + if (bFlag) { | |
| 355 | + // 车次链结尾是这个班次的前一个班次 | |
| 356 | + oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i; | |
| 357 | + oChainInfo.e_b = iBcIndex == 0 ? 1 : 0; | |
| 358 | + oChainInfo.bcount = iBcount; | |
| 359 | + } | |
| 360 | + | |
| 361 | + bFlag = false; | |
| 362 | + } else { | |
| 363 | + if (bFlag) { | |
| 364 | + iBcount ++; | |
| 365 | + oChainInfo.bcount = iBcount; | |
| 366 | + } else { | |
| 367 | + // 下一个车次链开始 | |
| 368 | + iBcount = 1; | |
| 369 | + oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1}; | |
| 370 | + aChainInfo.push(oChainInfo); | |
| 371 | + bFlag = true; | |
| 372 | + } | |
| 373 | + } | |
| 374 | + | |
| 375 | + | |
| 376 | + iBcIndex ++; | |
| 377 | + } | |
| 378 | + iBcIndex = 0; | |
| 379 | + } | |
| 380 | + | |
| 381 | + } | |
| 382 | + | |
| 383 | + return aChainInfo[num]; | |
| 384 | +}; | |
| 385 | + | |
| 386 | +/** | |
| 387 | + * 获取车次链的个数。 | |
| 388 | + * @returns int | |
| 389 | + */ | |
| 390 | +InternalLpObj.prototype.fnGetBcChainCount = function() { | |
| 391 | + var iChainCount = 0; | |
| 392 | + var aBcIndex = this.getMinBcObjPosition(); | |
| 393 | + | |
| 394 | + var oBc; | |
| 395 | + var iQIndex; | |
| 396 | + var iBcIndex; | |
| 397 | + var i; | |
| 398 | + var bFlag; | |
| 399 | + | |
| 400 | + if (aBcIndex.length == 2) { | |
| 401 | + iChainCount = 1; | |
| 402 | + bFlag = true; | |
| 403 | + | |
| 404 | + // 下一个班次的索引 | |
| 405 | + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 406 | + iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 407 | + | |
| 408 | + for (i = iQIndex; i < this._$_qCount; i++) { | |
| 409 | + while (iBcIndex <= 1) { | |
| 410 | + oBc = this.getBc(i, iBcIndex); | |
| 411 | + if (!oBc) { | |
| 412 | + bFlag = false; | |
| 413 | + } else { | |
| 414 | + if (bFlag) { | |
| 415 | + | |
| 416 | + } else { | |
| 417 | + iChainCount ++; | |
| 418 | + bFlag = true; | |
| 419 | + } | |
| 420 | + } | |
| 421 | + | |
| 422 | + | |
| 423 | + iBcIndex ++; | |
| 424 | + } | |
| 425 | + iBcIndex = 0; | |
| 426 | + } | |
| 427 | + | |
| 428 | + } | |
| 429 | + | |
| 430 | + | |
| 431 | + return iChainCount; | |
| 432 | +}; | |
| 433 | + | |
| 434 | +/** | |
| 435 | + * 在具体位置移除班次。 | |
| 436 | + * @param qIndex 第几圈 | |
| 437 | + * @param bcIndex 第几个班次 | |
| 438 | + */ | |
| 439 | +InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) { | |
| 440 | + var group = this._$_groupBcArray[qIndex]; | |
| 441 | + if (bcIndex == 0) { | |
| 442 | + group.removeBc1(); | |
| 443 | + } else if (bcIndex == 1) { | |
| 444 | + group.removeBc2(); | |
| 445 | + } | |
| 446 | +}; | |
| 447 | + | |
| 448 | +/** | |
| 449 | + * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 450 | + * 使用时间差的绝度值,比较,取最小的 | |
| 451 | + * 如果有两个一样的时间差,取比fctime大的时间 | |
| 452 | + * @param fctime moment 比较用时间 | |
| 453 | + * @param groupArray 圈数组 | |
| 454 | + * @param hasUp boolean 计算上行班次 | |
| 455 | + * @param hasDown boolean 计算下行班次 | |
| 456 | + * @returns [{第几圈},{第几个班次}] | |
| 457 | + */ | |
| 458 | +InternalLpObj.prototype.fnGetQBcIndexWithFcTimeFromGroupArray = function( | |
| 459 | + fctime, groupArray, hasUp, hasDown | |
| 460 | +) { | |
| 461 | + var i; | |
| 462 | + var timediff; // 时间差取绝对值 | |
| 463 | + var qIndex; | |
| 464 | + var bcIndex; | |
| 465 | + | |
| 466 | + var group; | |
| 467 | + var bc1time; | |
| 468 | + var bc2time; | |
| 469 | + | |
| 470 | + var tempdiff; | |
| 471 | + | |
| 472 | + console.log("比较时间=" + fctime.format("HH:mm")); | |
| 473 | + | |
| 474 | + for (i = 0; i < this._$_qCount; i++) { | |
| 475 | + group = groupArray[i]; | |
| 476 | + if (group) { | |
| 477 | + if (group.getBc1() && hasUp) { | |
| 478 | + bc1time = group.getBc1().getFcTimeObj(); | |
| 479 | + console.log("bc1time=" + bc1time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 480 | + tempdiff = Math.abs(bc1time.diff(fctime)); | |
| 481 | + | |
| 482 | + if (!timediff) { | |
| 483 | + timediff = Math.abs(tempdiff); | |
| 484 | + qIndex = i; | |
| 485 | + bcIndex = 0; | |
| 486 | + } else { | |
| 487 | + if (tempdiff < timediff) { | |
| 488 | + timediff = tempdiff; | |
| 489 | + qIndex = i; | |
| 490 | + bcIndex = 0; | |
| 491 | + } if (Math.abs(tempdiff) == timediff) { | |
| 492 | + if (bc1time.isAfter(fctime)) { | |
| 493 | + timediff = tempdiff; | |
| 494 | + qIndex = i; | |
| 495 | + bcIndex = 0; | |
| 496 | + } | |
| 497 | + | |
| 498 | + } | |
| 499 | + } | |
| 500 | + } | |
| 501 | + | |
| 502 | + if (group.getBc2() && hasDown) { | |
| 503 | + bc2time = group.getBc2().getFcTimeObj(); | |
| 504 | + console.log("bc2time=" + bc2time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 505 | + tempdiff = Math.abs(bc2time.diff(fctime)); | |
| 506 | + | |
| 507 | + if (!timediff) { | |
| 508 | + timediff = Math.abs(tempdiff); | |
| 509 | + qIndex = i; | |
| 510 | + bcIndex = 1; | |
| 511 | + } else { | |
| 512 | + if (tempdiff < timediff) { | |
| 513 | + timediff = tempdiff; | |
| 514 | + qIndex = i; | |
| 515 | + bcIndex = 1; | |
| 516 | + } if (Math.abs(tempdiff) == timediff) { | |
| 517 | + if (bc2time.isBefore(fctime)) { | |
| 518 | + timediff = tempdiff; | |
| 519 | + qIndex = i; | |
| 520 | + bcIndex = 1; | |
| 521 | + } | |
| 522 | + | |
| 523 | + } | |
| 524 | + } | |
| 525 | + } | |
| 526 | + } | |
| 527 | + } | |
| 528 | + | |
| 529 | + console.log("中标线对应数组索引=" + qIndex); | |
| 530 | + | |
| 531 | + var rst = []; | |
| 532 | + rst.push(qIndex); | |
| 533 | + rst.push(bcIndex); | |
| 534 | + | |
| 535 | + return rst; | |
| 536 | +}; | |
| 537 | + | |
| 538 | +/** | |
| 539 | + * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 540 | + * 使用时间差的绝度值,比较,取最小的 | |
| 541 | + * 如果有两个一样的时间差,取比fctime大的时间 | |
| 542 | + * @param fctime moment 比较用时间 | |
| 543 | + * @param hasUp boolean 计算上行班次 | |
| 544 | + * @param hasDown boolean 计算下行班次 | |
| 545 | + * @returns [{第几圈},{第几个班次}] | |
| 546 | + */ | |
| 547 | +InternalLpObj.prototype.getQBcIndexWithFcTime = function( | |
| 548 | + fctime, hasUp, hasDown | |
| 549 | +) { | |
| 550 | + return this.fnGetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown); | |
| 551 | +}; | |
| 552 | + | |
| 553 | +//---------------------- 内部数据初始化方法(不同于构造函数)---------------------// | |
| 554 | + | |
| 555 | +/** | |
| 556 | + * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌 | |
| 557 | + * 注意,之前有班次会删除后再创建。 | |
| 558 | + * @param startTime 开始时间 | |
| 559 | + * @param endTime 结束时间 | |
| 560 | + * @param isUp 第一个班次是上行还是下行 | |
| 561 | + * @param fromQ 从第几圈开始加入 | |
| 562 | + * @param paramObj 参数对象 | |
| 563 | + * @param factory 工厂对象 | |
| 564 | + */ | |
| 565 | +InternalLpObj.prototype.initDataFromTimeToTime = function( | |
| 566 | + startTime, | |
| 567 | + endTime, | |
| 568 | + isUp, | |
| 569 | + fromQ, | |
| 570 | + paramObj, | |
| 571 | + factory) { | |
| 572 | + | |
| 573 | + var bcData = []; // 班次数组 | |
| 574 | + var bcObj; | |
| 575 | + var kssj = startTime; | |
| 576 | + var fcno = 1; // 发车顺序号 | |
| 577 | + var bcCount = 1; // 班次数 | |
| 578 | + do { | |
| 579 | + bcObj = factory.createBcObj( | |
| 580 | + this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象 | |
| 581 | + bcData.push(bcObj); | |
| 582 | + | |
| 583 | + kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime()); | |
| 584 | + fcno ++; | |
| 585 | + bcCount ++; | |
| 586 | + isUp = !isUp; | |
| 587 | + } while(kssj.isBefore(endTime)); | |
| 588 | + bcCount--; | |
| 589 | + | |
| 590 | + //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm")); | |
| 591 | + //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm")); | |
| 592 | + //console.log("endtime: " + endTime.format("HH:mm")); | |
| 593 | + | |
| 594 | + //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) { | |
| 595 | + // // 如果最后一个班次的到达时间超过结束时间,也要去除 | |
| 596 | + // bcData.splice(bcCount - 1, 1); | |
| 597 | + //} | |
| 598 | + | |
| 599 | + this._initDataFromLbBcArray(bcData, fromQ); | |
| 600 | + | |
| 601 | +}; | |
| 602 | + | |
| 603 | +/** | |
| 604 | + * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。 | |
| 605 | + * @param bcArray 连班班次数组 | |
| 606 | + * @param fromQ 从第几圈开始加入 | |
| 607 | + */ | |
| 608 | +InternalLpObj.prototype._initDataFromLbBcArray = function( | |
| 609 | + bcArray, | |
| 610 | + fromQ | |
| 611 | +) { | |
| 612 | + var _bc1Obj; | |
| 613 | + var _bc2Obj; | |
| 614 | + var _qObj; | |
| 615 | + | |
| 616 | + // 第一班次是上行还是下行 | |
| 617 | + var isUp = bcArray[0].isUp(); | |
| 618 | + | |
| 619 | + if (bcArray.length > 0 && fromQ < this._$_qCount) { | |
| 620 | + // 构造圈数 | |
| 621 | + if (isUp != this._$_isUp) { | |
| 622 | + // 如果方向不一致,意味着第一个班次是半圈 | |
| 623 | + // 加半圈,并加在bc2上 | |
| 624 | + _bc2Obj = bcArray.slice(0, 1)[0]; | |
| 625 | + _qObj = new InternalGroupObj( | |
| 626 | + this, | |
| 627 | + this._$_isUp, | |
| 628 | + undefined, | |
| 629 | + _bc2Obj | |
| 630 | + ); | |
| 631 | + _bc2Obj.setGroup(_qObj); | |
| 632 | + this._$_groupBcArray[fromQ] = _qObj; | |
| 633 | + | |
| 634 | + bcArray.splice(0, 1); | |
| 635 | + fromQ ++; | |
| 636 | + } | |
| 637 | + | |
| 638 | + var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈 | |
| 639 | + var qCount2 = bcArray.length % 2; // 最后是否有半圈 | |
| 640 | + | |
| 641 | + while (fromQ < this._$_qCount) { | |
| 642 | + if (qCount1 > 0) { | |
| 643 | + _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 644 | + _bc2Obj = bcArray.slice(1, 2)[0]; | |
| 645 | + _qObj = new InternalGroupObj( | |
| 646 | + this, | |
| 647 | + this._$_isUp, | |
| 648 | + _bc1Obj, | |
| 649 | + _bc2Obj | |
| 650 | + ); | |
| 651 | + _bc1Obj.setGroup(_qObj); | |
| 652 | + _bc2Obj.setGroup(_qObj); | |
| 653 | + this._$_groupBcArray[fromQ] = _qObj; | |
| 654 | + | |
| 655 | + bcArray.splice(0, 2); | |
| 656 | + qCount1 --; | |
| 657 | + } else if (qCount2 > 0) { | |
| 658 | + // 加半圈,并加在bc1上 | |
| 659 | + _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 660 | + _qObj = new InternalGroupObj( | |
| 661 | + this, | |
| 662 | + this._$_isUp, | |
| 663 | + _bc1Obj, | |
| 664 | + undefined | |
| 665 | + ); | |
| 666 | + _bc1Obj.setGroup(_qObj); | |
| 667 | + this._$_groupBcArray[fromQ] = _qObj; | |
| 668 | + | |
| 669 | + bcArray.splice(0, 1); | |
| 670 | + qCount2 --; | |
| 671 | + } else { | |
| 672 | + break; | |
| 673 | + } | |
| 674 | + | |
| 675 | + fromQ ++; | |
| 676 | + } | |
| 677 | + } | |
| 678 | +}; | |
| 679 | + | |
| 680 | +//-------------------------- 其他方法 ----------------------------// | |
| 681 | + | |
| 682 | +/** | |
| 683 | + * 从指定位置的班次开始,往后所有的班次修正发车时间 | |
| 684 | + * @param groupIndex | |
| 685 | + * @param bcIndex | |
| 686 | + * @param time | |
| 687 | + */ | |
| 688 | +InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) { | |
| 689 | + var i; | |
| 690 | + var oCurBc; | |
| 691 | + | |
| 692 | + // 修正之前班次的停站时间 | |
| 693 | + //oCurBc = this.getBc( | |
| 694 | + // bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 695 | + // bcIndex == 1 ? 0 : 1 | |
| 696 | + //); | |
| 697 | + //if (oCurBc) { | |
| 698 | + // oCurBc.setStopTime(oCurBc.getStopTime() + time); | |
| 699 | + //} | |
| 700 | + | |
| 701 | + | |
| 702 | + for (i = groupIndex; i < this._$_qCount; i++) { | |
| 703 | + if (bcIndex == 0) { | |
| 704 | + oCurBc = this.getBc(i, 0); | |
| 705 | + if (oCurBc) { | |
| 706 | + oCurBc.addMinuteToFcsj(time); | |
| 707 | + } | |
| 708 | + oCurBc = this.getBc(i, 1); | |
| 709 | + if (oCurBc) { | |
| 710 | + oCurBc.addMinuteToFcsj(time); | |
| 711 | + } | |
| 712 | + | |
| 713 | + } else { | |
| 714 | + oCurBc = this.getBc(i, 1); | |
| 715 | + if (oCurBc) { | |
| 716 | + oCurBc.addMinuteToFcsj(time); | |
| 717 | + } | |
| 718 | + | |
| 719 | + } | |
| 720 | + | |
| 721 | + bcIndex = 0; | |
| 722 | + } | |
| 723 | +}; | |
| 724 | + | |
| 725 | +/** | |
| 726 | + * 在指定位置添加一个吃饭班次。 | |
| 727 | + * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array | |
| 728 | + * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化 | |
| 729 | + * @param groupIndex | |
| 730 | + * @param bcIndex | |
| 731 | + * @param factory | |
| 732 | + * @param paramObj | |
| 733 | + * @returns int 相差时间(吃饭时间距离和停站时间相差值) | |
| 734 | + */ | |
| 735 | +InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) { | |
| 736 | + var oPreBc; | |
| 737 | + var oEatBc; | |
| 738 | + var iBcModifyTime; | |
| 739 | + oPreBc = this.getBc( // 前一个邻接班次 | |
| 740 | + bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 741 | + bcIndex == 1 ? 0 : 1); | |
| 742 | + if (oPreBc) { // 存在前一个班次 | |
| 743 | + oEatBc = factory.createBcObj( | |
| 744 | + this, | |
| 745 | + "cf", | |
| 746 | + !oPreBc.isUp(), // 和上一个班次方向相反 | |
| 747 | + 1, | |
| 748 | + paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间 | |
| 749 | + paramObj | |
| 750 | + ); | |
| 751 | + | |
| 752 | + //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间 | |
| 753 | + | |
| 754 | + // 修正之后的班次发车时间 | |
| 755 | + // 注意:之后那个班次发车时间就是吃饭班次的到达时间 | |
| 756 | + iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m"); | |
| 757 | + this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime); | |
| 758 | + | |
| 759 | + oPreBc.setStopTime(0); // 不重置停站时间 | |
| 760 | + oPreBc.fnSetEatTime(oEatBc.getBcTime()); | |
| 761 | + | |
| 762 | + //this._$_other_bc_array.push(oEatBc); | |
| 763 | + | |
| 764 | + return iBcModifyTime; | |
| 765 | + } else { | |
| 766 | + return false; | |
| 767 | + } | |
| 768 | + | |
| 769 | +}; | |
| 770 | + | |
| 771 | +/** | |
| 772 | + * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。 | |
| 773 | + * @param iPeakAverStopTime 高峰平均停站时间 | |
| 774 | + * @param iTroughAverStopTime 低谷平均停站时间 | |
| 775 | + * @param oParam 参数对象 | |
| 776 | + */ | |
| 777 | +InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) { | |
| 778 | + // 获取车次链个数 | |
| 779 | + var iBcChainCount = this.fnGetBcChainCount(); | |
| 780 | + | |
| 781 | + var i; | |
| 782 | + var j; | |
| 783 | + var oBcIndex; | |
| 784 | + var iQIndex; | |
| 785 | + var iBcIndex; | |
| 786 | + var iBcCount; | |
| 787 | + var oBc; | |
| 788 | + var oNextBc; | |
| 789 | + | |
| 790 | + var iBcStopTime; | |
| 791 | + | |
| 792 | + for (i = 0; i < iBcChainCount; i++) { | |
| 793 | + oBcIndex = this.fnGetBcChainInfo(i); | |
| 794 | + iQIndex = oBcIndex["s_q"]; | |
| 795 | + iBcIndex = oBcIndex["s_b"]; | |
| 796 | + iBcCount = oBcIndex["bcount"]; | |
| 797 | + | |
| 798 | + for (j = 0; j < iBcCount - 1; j++) { | |
| 799 | + oBc = this.getBc(iQIndex, iBcIndex); | |
| 800 | + oNextBc = this.getBc( | |
| 801 | + iBcIndex == 0 ? iQIndex : iQIndex + 1, | |
| 802 | + iBcIndex == 0 ? 1 : 0); | |
| 803 | + | |
| 804 | + if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理 | |
| 805 | + continue; | |
| 806 | + } | |
| 807 | + | |
| 808 | + // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间 | |
| 809 | + iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m"); | |
| 810 | + if (iBcStopTime < 0) { | |
| 811 | + // 当前班次使用最小停站时间 | |
| 812 | + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 813 | + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 814 | + | |
| 815 | + } else { | |
| 816 | + if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) { | |
| 817 | + // 停站时间一致,没有问题 | |
| 818 | + | |
| 819 | + | |
| 820 | + } else { | |
| 821 | + // TODO:当前班次使用最小停站时间 | |
| 822 | + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 823 | + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 824 | + | |
| 825 | + } | |
| 826 | + } | |
| 827 | + | |
| 828 | + iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 829 | + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 830 | + } | |
| 831 | + | |
| 832 | + this.getBc(iQIndex, iBcIndex).setStopTime(0); | |
| 833 | + } | |
| 834 | + | |
| 835 | + | |
| 836 | +}; | |
| 837 | + | |
| 838 | + | |
| 839 | +// TODO | |
| 840 | + | |
| 841 | +/** | |
| 842 | + * | |
| 843 | + * | |
| 844 | + */ | |
| 845 | +InternalLpObj.prototype.calcuLpBx = function() { | |
| 846 | + | |
| 847 | +}; | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | ... | ... |