Commit 47b86d05fcd6c03cbd025402991cb8a71cf55da8

Authored by 娄高锋
1 parent 9e0c6481

update

src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
... ... @@ -573,191 +573,77 @@ public class ReportServiceImpl implements ReportService{
573 573  
574 574 //查询全程
575 575 String sqlqc="select t.*,x.station_name as qdz_name from ( "
576   - + "(SELECT fcsj,qdz,2 as xh,xl_dir FROM bsth_c_s_ttinfo_detail "
577   - + " where ttinfo ='"+ttinfo+"' and bc_type='normal' and fcsj <='"+minfcsj+"' ) "
  576 + + " (SELECT bc_type, fcsj,qdz,2 as xh,xl_dir FROM bsth_c_s_ttinfo_detail "
  577 + + " where ttinfo ='"+ttinfo+"' and (bc_type='normal' || bc_type='region') "
  578 + + " and fcsj <='"+minfcsj+"') "
578 579 + " union "
579   - + " (SELECT fcsj,qdz,1 as xh,xl_dir FROM bsth_c_s_ttinfo_detail "
580   - + " where ttinfo ='"+ttinfo+"' and bc_type='normal' and fcsj > '"+minfcsj+"') "
581   - + "order by xl_dir,xh,fcsj ) t left join bsth_c_station x on t.qdz=x.id";
  580 + + " (SELECT bc_type, fcsj,qdz,1 as xh,xl_dir FROM bsth_c_s_ttinfo_detail "
  581 + + " where ttinfo ='"+ttinfo+"' and (bc_type='normal' || bc_type='region') "
  582 + + " and fcsj > '"+minfcsj+"') "
  583 + + "order by xl_dir,xh,fcsj ) t left join bsth_c_station x on t.qdz=x.id";
582 584 List<Map<String, String>> qclist= jdbcTemplate.query(sqlqc,
583 585 new RowMapper<Map<String, String>>(){
584 586 @Override
585   - public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {
586   - Map<String, String> m=new HashMap<String,String>();
587   - m.put("qdz_name", rs.getString("qdz_name"));
588   - m.put("fcsj", rs.getString("fcsj"));
589   - m.put("xl", rs.getString("xl_dir"));
590   - return m;
591   - }
  587 + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {
  588 + Map<String, String> m=new HashMap<String,String>();
  589 + m.put("qdz_name", rs.getString("qdz_name"));
  590 + m.put("bcType", rs.getString("bc_type"));
  591 + m.put("fcsj", rs.getString("fcsj"));
  592 + m.put("xl", rs.getString("xl_dir"));
  593 + m.put("xh", rs.getString("xh"));
  594 + return m;
  595 + }
592 596  
593 597 });
594   -
595   - Map<String, Object> qcMap=new HashMap<String,Object>();
596   - int num=0;
597   - String sxfcsj="";
598   - String xxfcsj="";
599   - String sxzd="";
600   - String xxzd="";
601   - for (int i = 0; i < qclist.size(); i++) {
602   - Map<String, String> map=qclist.get(i);
603   - if(map.get("xl").equals("0")){
604   - if(sxzd.equals("")){
605   - sxzd=map.get("qdz_name").toString();
606   - qcMap.put("sxzm", sxzd);
607   - sxfcsj +=map.get("fcsj").toString()+"-";
608   - }
609   - if(!(qclist.get(i+1).get("xl").equals("0"))){
610   - sxfcsj +=map.get("fcsj").toString();
611   - qcMap.put("sxsj",sxfcsj);
612   - qcMap.put("sxbc", i+1);
613   - num=i+1;
614   - }
615   - }
616   - if(map.get("xl").equals("1")){
617   - if(xxzd.equals("")){
618   - xxzd=map.get("qdz_name").toString();
619   - xxfcsj+=map.get("fcsj").toString()+"-";
620   - qcMap.put("xxzm", xxzd);
621   - }
  598 +
  599 + List<List<Map<String, String>>> mapList = new ArrayList<List<Map<String,String>>>();
  600 + mapList.add(new ArrayList<Map<String, String>>());
  601 + mapList.add(new ArrayList<Map<String, String>>());
  602 + for(Map<String, String> m : qclist){
  603 + String bcType = m.get("bcType");
  604 + if(bcType.equals("normal")){
  605 + mapList.get(0).add(m);
  606 + } else {
  607 + mapList.get(1).add(m);
622 608 }
623 609 }
624   - xxfcsj +=qclist.get(qclist.size()-1).get("fcsj").toString();
625   - qcMap.put("xxsj", xxfcsj);
626   - qcMap.put("xxbc", qclist.size()-num);
627   - list.add(qcMap);
628 610  
629   -
630   - //查询区间
631   - String sqlqj="select t.*,x.station_name as qdz_name from ( "
632   - + "(SELECT fcsj,qdz,'1' as gf,xl_dir FROM bsth_c_s_ttinfo_detail "
633   - + "where ttinfo ='"+ttinfo+"' and bc_type='region' and fcsj >='06:31'"
634   - + "and fcsj <'08:30')"
635   - + " union ( SELECT fcsj,qdz,'2' as gf,xl_dir FROM bsth_c_s_ttinfo_detail "
636   - + "where ttinfo ='"+ttinfo+"' and bc_type='region' "
637   - + "and fcsj > '16:01' and fcsj < '18:00') order by xl_dir,gf,fcsj ) t "
638   - + "left join bsth_c_station x on t.qdz=x.id";
639   -
640   - List<Map<String, String>> qjlist= jdbcTemplate.query(sqlqj,
641   - new RowMapper<Map<String, String>>(){
642   - @Override
643   - public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {
644   - Map<String, String> m=new HashMap<String,String>();
645   - m.put("qdz_name", rs.getString("qdz_name"));
646   - m.put("fcsj", rs.getString("fcsj"));
647   - m.put("xl", rs.getString("xl_dir"));
648   - m.put("gf", rs.getString("gf"));
649   - return m;
650   - }
651   - });
652   -
653   - Map<String, Object> qjzMap=new HashMap<String,Object>();
654   - Map<String, Object> qjwMap=new HashMap<String,Object>();
655   - int numqj=0;
656   - String sxfcsjqj="";
657   - String xxfcsjqj="";
658   - String sxzdqj="";
659   - String xxzdqj="";
660   - for(int i=0;i<qjlist.size();i++){
661   - Map<String, String> map=qjlist.get(i);
662   - if(map.get("xl").toString().equals("0")){
663   - if(map.get("gf").toString().equals("1")){
664   - if(sxzdqj.equals("")){
665   - sxzdqj =map.get("qdz_name").toString();
666   - qjzMap.put("sxzm", sxzdqj);
667   - sxfcsjqj +=map.get("fcsj").toString()+"-";
668   - }
669   - if(i<qjlist.size()-1){
670   - if(!(qjlist.get(i+1).get("gf").equals("1"))){
671   - sxfcsjqj +=map.get("fcsj").toString();
672   - qjzMap.put("sxsj",sxfcsjqj);
673   - qjzMap.put("sxbc", i+1);
674   - numqj=i+1;
675   - sxzdqj ="";
676   - sxfcsjqj="";
677   - }
678   - }else{
679   - qjzMap.put("sxsj",sxfcsjqj+"-"+map.get("fcsj").toString());
680   - qjzMap.put("sxbc", i+1);
681   - numqj=i+1;
682   - sxzdqj ="";
683   - sxfcsjqj="";
684   - }
685   - }
686   - if(map.get("gf").toString().equals("2")){
687   - if(sxzdqj.equals("")){
688   - sxzdqj =map.get("qdz_name").toString();
689   - qjwMap.put("sxzm", sxzdqj);
690   - sxfcsjqj +=map.get("fcsj").toString()+"-";
691   - }
692   - if(i<qjlist.size()-1){
693   - if(!(qjlist.get(i+1).get("xl").equals("0"))){
694   - sxfcsjqj +=map.get("fcsj").toString();
695   - qjwMap.put("sxsj",sxfcsjqj);
696   - qjwMap.put("sxbc", i+1-numqj);
697   - numqj=i+1;
698   - }
699   - }else{
700   - qjwMap.put("sxsj",sxfcsjqj+"-"+map.get("fcsj").toString());
701   - qjwMap.put("sxbc", i+1-numqj);
702   - numqj=i+1;
703   - }
704   - }
705   -
706   - }else{
707   - if(map.get("gf").toString().equals("1")){
708   - if(xxzdqj.equals("")){
709   - xxzdqj =map.get("qdz_name").toString();
710   - qjzMap.put("xxzm", xxzdqj);
711   - xxfcsjqj +=map.get("fcsj").toString()+"-";
712   - }
713   - if(i<qjlist.size()-1){
714   - if(!(qjlist.get(i+1).get("gf").equals("1"))){
715   - xxfcsjqj +=map.get("fcsj").toString();
716   - qjzMap.put("xxsj",xxfcsjqj);
717   - qjzMap.put("xxbc", i+1-numqj);
718   - numqj=i+1;
719   - xxzdqj ="";
720   - xxfcsjqj="";
721   - }
722   - }else{
723   - qjzMap.put("xxsj",xxfcsjqj+"-"+map.get("fcsj").toString());
724   - qjzMap.put("xxbc", i+1-numqj);
725   - numqj=i+1;
726   - xxzdqj ="";
727   - xxfcsjqj="";
728   - }
729   - }
730   - if(map.get("gf").toString().equals("2")){
731   - if(xxzdqj.equals("")){
732   - xxzdqj =map.get("qdz_name").toString();
733   - qjwMap.put("xxzm", xxzdqj);
734   - xxfcsjqj +=map.get("fcsj").toString()+"-";
735   - }
736   - if(i<qjlist.size()){
737   - if(i==qjlist.size()-1){
738   - xxfcsjqj +=map.get("fcsj").toString();
739   - qjwMap.put("xxsj",xxfcsjqj);
740   - qjwMap.put("xxbc", i+1-numqj);
741   - numqj=i+1;
742   - }
743   - }else{
744   - qjwMap.put("xxsj",xxfcsjqj+"-"+xxfcsjqj);
745   - qjwMap.put("xxbc", i+1-numqj);
746   - numqj=i+1;
747   - }
  611 + for(int i = 0; i < mapList.size(); i++){
  612 + List<Map<String, String>> l = mapList.get(i);
  613 + Map<String, Object> tempMap = new HashMap<String, Object>();
  614 + List<String> upfcsj = new ArrayList<String>();
  615 + List<String> downfcsj = new ArrayList<String>();
  616 + String sxqdz = "", xxqdz = "";
  617 + String sxfcsj = "", xxfcsj = "";
  618 + int sxbc = 0, xxbc = 0;
  619 + for(Map<String, String> m : l){
  620 + if(m.get("xl").equals("0")){
  621 + sxbc++;
  622 + upfcsj.add(m.get("fcsj"));
  623 + if(sxqdz.length() == 0 && m.containsKey("qdz_name"))
  624 + sxqdz = m.get("qdz_name");
  625 + } else {
  626 + xxbc++;
  627 + downfcsj.add(m.get("fcsj"));
  628 + if(xxqdz.length() == 0 && m.containsKey("qdz_name"))
  629 + xxqdz = m.get("qdz_name");
748 630 }
749   -
750   -
751 631 }
  632 + if(upfcsj.size() != 0)
  633 + sxfcsj = upfcsj.get(0) + "-" + upfcsj.get(upfcsj.size() - 1);
  634 + if(downfcsj.size() != 0)
  635 + xxfcsj = downfcsj.get(0) + "-" + downfcsj.get(downfcsj.size() - 1);
  636 + tempMap.put("sxqdz", sxqdz);
  637 + tempMap.put("sxfcsj", i==0?sxfcsj:"");
  638 + tempMap.put("sxbc", sxbc!=0?sxbc:"");
  639 + tempMap.put("xxqdz", xxqdz);
  640 + tempMap.put("xxfcsj", i==0?xxfcsj:"");
  641 + tempMap.put("xxbc", xxbc!=0?xxbc:"");
  642 + tempMap.put("bcType", i);
  643 + if(sxqdz.length()!=0 || xxqdz.length()!=0)
  644 + list.add(tempMap);
752 645 }
753 646  
754   - if(!qjzMap.isEmpty()){
755   - list.add(qjzMap);
756   - }
757   - if(!qjwMap.isEmpty()){
758   - list.add(qjwMap);
759   -
760   - }
761 647 return list;
762 648 }
763 649 @Override
... ... @@ -769,15 +655,14 @@ public class ReportServiceImpl implements ReportService{
769 655 String[] minSjs = minfcsj.split(":");
770 656 int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]);
771 657 //查询时间里程
772   - String sqlPc=" (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,2 as xh FROM "
  658 + String sqlPc=" (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,2 as xh FROM "
773 659 + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and "
774   - + " fcsj <='"+minfcsj+"' and bc_type = 'normal') "
  660 + + " fcsj <='"+minfcsj+"' and bc_type!='in' and bc_type!='out' and bc_type!='ldks') "
775 661 + " union "
776   - + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,1 as xh FROM "
  662 + + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,1 as xh FROM "
777 663 + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and "
778   - + " fcsj >'"+minfcsj+"' and bc_type ='normal') "
  664 + + " fcsj > '"+minfcsj+"' and bc_type!='in' and bc_type!='out' and bc_type!='ldks') "
779 665 + " order by xl_dir, xh,fcsj";
780   -
781 666 Map<String, Object> map=new HashMap<String,Object>();
782 667 List<Map<String, Object>> list= jdbcTemplate.query(sqlPc,
783 668 new RowMapper<Map<String, Object>>(){
... ... @@ -790,9 +675,10 @@ public class ReportServiceImpl implements ReportService{
790 675 m.put("bcType", rs.getString("bc_type"));
791 676 m.put("lp", rs.getString("lp"));
792 677 m.put("dir", rs.getString("xl_dir"));
  678 + m.put("ists", rs.getString("ists")!=null?rs.getString("ists"):"");
793 679 return m;
794 680 }
795   - });
  681 + });
796 682  
797 683 List<Map<String, Object>> newList=new ArrayList<Map<String,Object>>();
798 684 Map<String, List<Map<String, Object>>> keyMap = new HashMap<String, List<Map<String, Object>>>();
... ... @@ -824,8 +710,9 @@ public class ReportServiceImpl implements ReportService{
824 710 Map<String, Object> tempMap = new HashMap<String, Object>();
825 711 List<Map<String, Object>> list2 = keyMap.get(key);
826 712 List<Integer> cjs = new ArrayList<Integer>();
827   - int sxsj = 0, xxsj = 0, zcj = 0;
  713 + int sxsj = 0, xxsj = 0, zcj = 0, tssj = 0;
828 714 int temp = 24*60+1;
  715 + boolean ists = false;
829 716 for(Map<String, Object> m : list2){
830 717 String[] split = m.get("fcsj").toString().split(":");
831 718 int fcsj = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]);
... ... @@ -838,9 +725,18 @@ public class ReportServiceImpl implements ReportService{
838 725 }
839 726 if(temp >= fcsj){
840 727 temp = fcsj;
  728 + ists = false;
841 729 } else {
842   - cjs.add(fcsj - temp);
  730 + if(ists){
  731 + tssj += fcsj - temp;
  732 + ists = false;
  733 + } else {
  734 + cjs.add(fcsj - temp);
  735 + }
843 736 temp = fcsj;
  737 + if(m.get("ists").equals("1")){
  738 + ists = true;
  739 + }
844 740 }
845 741 }
846 742 Collections.sort(cjs);
... ... @@ -852,7 +748,8 @@ public class ReportServiceImpl implements ReportService{
852 748 tempMap.put("xxsj", xxsj);
853 749 tempMap.put("fqsj", sxsj + xxsj);
854 750 tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");
855   - tempMap.put("pjcj", cjs.size()>0?zcj/(cjs.size()-1):"/");
  751 + tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");
  752 + tempMap.put("tssj", tssj);
856 753 maps.put(key, tempMap);
857 754 }
858 755 newList.add(maps.get("(首)——6:30"));
... ...
src/main/resources/static/pages/report/timetable/timetable.html
... ... @@ -45,7 +45,7 @@
45 45 </div>
46 46 <div class="form-group">
47 47 <input class="btn btn-default" type="button" id="query" value="查询"/>
48   - <input class="btn btn-default" type="button" id="export" value="导出"/>
  48 +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> -->
49 49 </div>
50 50 </form>
51 51 </div>
... ... @@ -165,18 +165,19 @@
165 165 <div class="col-md-6" >
166 166 <table class="table table-bordered table-checkable" id="formsTime5">
167 167 <tr>
168   - <td colspan="6">全日分组行驶时间(区间除外)</td>
  168 + <td colspan="7">全日分组行驶时间(区间除外)</td>
169 169 </tr>
170 170 <tr>
171 171 <td width="20%" rowspan="2" style="text-align:center;vertical-align:middle;">分组 时间</td>
172   - <td width="25%" colspan="2" style="text-align:center;vertical-align:middle;">计划行驶(分)</td>
173   - <td width="20%" rowspan="2" style="text-align:center;vertical-align:middle;">分圈 时间</td>
174   - <td width="20%" rowspan="2" style="text-align:center;vertical-align:middle;">车距区间</td>
175   - <td width="15%" rowspan="2" style="text-align:center;vertical-align:middle;">平均车距</td>
  172 + <td width="23%" colspan="2" style="text-align:center;vertical-align:middle;">计划行驶(分)</td>
  173 + <td width="15%" rowspan="2" style="text-align:center;vertical-align:middle;">分圈时间</td>
  174 + <td width="15%" rowspan="2" style="text-align:center;vertical-align:middle;">停驶时间</td>
  175 + <td width="15%" rowspan="2" style="text-align:center;vertical-align:middle;">车距区间</td>
  176 + <td width="12%" rowspan="2" style="text-align:center;vertical-align:middle;">平均车距</td>
176 177 </tr>
177 178 <tr>
178 179 <td>上行</td>
179   - <td>下行</td>
  180 + <td style="text-align:center;">下行</td>
180 181 </tr>
181 182 <tbody class="tbody_time_5">
182 183  
... ... @@ -313,8 +314,8 @@
313 314 });
314 315  
315 316 $.get('/report/tbodyTime4',{line:line,ttinfo:ttinfo},function(result){
316   - $("#skb_sxzd").html(result[0].sxzm);
317   - $("#skb_xxzd").html(result[0].xxzm);
  317 + $("#skb_sxzd").html(result[0].sxqdz);
  318 + $("#skb_xxzd").html(result[0].xxqdz);
318 319 var tbodyTime4 = template('tbodyTime4',{list:result});
319 320 $('#formsTime4 .tbody_time_4').html(tbodyTime4);
320 321 });
... ... @@ -377,11 +378,11 @@
377 378 {{each list as result i}}
378 379  
379 380 <tr>
380   - <td align="center">{{result.sxzm}}</td>
381   - <td align="center">{{result.sxsj}}</td>
  381 + <td align="center">{{result.sxqdz}}</td>
  382 + <td align="center">{{result.sxfcsj}}</td>
382 383 <td align="center">{{result.sxbc}}</td>
383   - <td align="center">{{result.xxzm}}</td>
384   - <td align="center">{{result.xxsj}}</td>
  384 + <td align="center">{{result.xxqdz}}</td>
  385 + <td align="center">{{result.xxfcsj}}</td>
385 386 <td align="center">{{result.xxbc}}</td>
386 387 </tr>
387 388 {{/each}}
... ... @@ -399,13 +400,14 @@
399 400 <td align="center">{{result.sxsj}}</td>
400 401 <td align="center">{{result.xxsj}}</td>
401 402 <td align="center">{{result.fqsj}}</td>
  403 + <td align="center">{{result.tssj}}</td>
402 404 <td align="center">{{result.cjqj}}</td>
403 405 <td align="center">{{result.pjcj}}</td>
404 406 </tr>
405 407 {{/each}}
406 408 {{if list.length == 0}}
407 409 <tr>
408   - <td colspan="6"><h6 class="muted">没有找到相关数据</h6></td>
  410 + <td colspan="7"><h6 class="muted">没有找到相关数据</h6></td>
409 411 </tr>
410 412 {{/if}}
411 413 </script>
... ...