Commit 99da108494c7111c61d1f0b7197f02b0de481cbc
1 parent
81229745
首末班准点率指标统计优化,给临港大屏的两个新接口
Showing
2 changed files
with
1121 additions
and
20 deletions
src/main/java/com/bsth/repository/ScheduleRealInfoRepository.java
| @@ -88,4 +88,8 @@ public interface ScheduleRealInfoRepository extends PagingAndSortingRepository<S | @@ -88,4 +88,8 @@ public interface ScheduleRealInfoRepository extends PagingAndSortingRepository<S | ||
| 88 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 88 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 89 | @Query(value="select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr between ?1 and ?2 order by s.scheduleDateStr, s.gsBm, s.fgsBm, s.xlBm") | 89 | @Query(value="select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr between ?1 and ?2 order by s.scheduleDateStr, s.gsBm, s.fgsBm, s.xlBm") |
| 90 | List<ScheduleRealInfo> findScheduleByDates(String startDate, String endDate); | 90 | List<ScheduleRealInfo> findScheduleByDates(String startDate, String endDate); |
| 91 | + | ||
| 92 | + @Query(value = " select bc_type from bsth_c_s_sp_info where id = ?1 ", nativeQuery = true) | ||
| 93 | + List<String> findoOriginalType(Long spId); | ||
| 94 | + | ||
| 91 | } | 95 | } |
src/main/java/com/bsth/server_rs/bigdata/BigscreenService.java
| @@ -35,6 +35,7 @@ import org.springframework.stereotype.Component; | @@ -35,6 +35,7 @@ import org.springframework.stereotype.Component; | ||
| 35 | 35 | ||
| 36 | import com.alibaba.fastjson.JSON; | 36 | import com.alibaba.fastjson.JSON; |
| 37 | import com.alibaba.fastjson.JSONObject; | 37 | import com.alibaba.fastjson.JSONObject; |
| 38 | +import com.bsth.common.BusinessCodeData; | ||
| 38 | import com.bsth.entity.ChildTaskPlan; | 39 | import com.bsth.entity.ChildTaskPlan; |
| 39 | import com.bsth.entity.ScheduleRealInfo; | 40 | import com.bsth.entity.ScheduleRealInfo; |
| 40 | import com.bsth.repository.ScheduleRealInfoRepository; | 41 | import com.bsth.repository.ScheduleRealInfoRepository; |
| @@ -56,6 +57,8 @@ public class BigscreenService { | @@ -56,6 +57,8 @@ public class BigscreenService { | ||
| 56 | 57 | ||
| 57 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 58 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 58 | 59 | ||
| 60 | + SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 61 | + | ||
| 59 | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | 62 | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); |
| 60 | 63 | ||
| 61 | /* | 64 | /* |
| @@ -2993,13 +2996,13 @@ public class BigscreenService { | @@ -2993,13 +2996,13 @@ public class BigscreenService { | ||
| 2993 | } | 2996 | } |
| 2994 | } | 2997 | } |
| 2995 | 2998 | ||
| 2996 | -// if (!(s.isSflj())) { | 2999 | + if (!(s.isSflj())) { |
| 2997 | if (s.getXlDir().equals("0")) { | 3000 | if (s.getXlDir().equals("0")) { |
| 2998 | listjh0.add(s); | 3001 | listjh0.add(s); |
| 2999 | } else { | 3002 | } else { |
| 3000 | listjh1.add(s); | 3003 | listjh1.add(s); |
| 3001 | } | 3004 | } |
| 3002 | -// } | 3005 | + } |
| 3003 | 3006 | ||
| 3004 | if(s.getFcsjActual() != null && s.getFcsjActual().trim().length() > 0){ | 3007 | if(s.getFcsjActual() != null && s.getFcsjActual().trim().length() > 0){ |
| 3005 | if (s.getXlDir().equals("0")) { | 3008 | if (s.getXlDir().equals("0")) { |
| @@ -3019,28 +3022,68 @@ public class BigscreenService { | @@ -3019,28 +3022,68 @@ public class BigscreenService { | ||
| 3019 | //上行 | 3022 | //上行 |
| 3020 | if(listjh0.size() > 0){ | 3023 | if(listjh0.size() > 0){ |
| 3021 | ScheduleRealInfo jhsb = listjh0.get(0); //计划首班 | 3024 | ScheduleRealInfo jhsb = listjh0.get(0); //计划首班 |
| 3025 | + for(int f = 0; f < listjh0.size(); f++){ | ||
| 3026 | + jhsb = listjh0.get(f); //计划首班 | ||
| 3027 | + String bcType = jhsb.getBcType(); | ||
| 3028 | + List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhsb.getSpId()); | ||
| 3029 | + if(oList.size() > 0 && oList.get(0) != null | ||
| 3030 | + && oList.get(0).trim().length() > 0){ | ||
| 3031 | + bcType = oList.get(0).trim(); | ||
| 3032 | + } | ||
| 3033 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 3034 | + || bcType.equals("major") || isInOut(jhsb)){ | ||
| 3035 | + continue; | ||
| 3036 | + } | ||
| 3037 | + break; | ||
| 3038 | + } | ||
| 3022 | if("1".equals(sfss) ? createDate.getTime() > jhsb.getFcsjT() : true){ | 3039 | if("1".equals(sfss) ? createDate.getTime() > jhsb.getFcsjT() : true){ |
| 3023 | jhFirst++; | 3040 | jhFirst++; |
| 3024 | - if(listsj0.size() > 0){ | ||
| 3025 | - ScheduleRealInfo sjsb = listsj0.get(0); //实际首班 | 3041 | + for(int i = 0; i < listsj0.size(); i++){ |
| 3042 | + ScheduleRealInfo sjsb = listsj0.get(i); //实际首班 | ||
| 3043 | + String bcType = sjsb.getBcType(); | ||
| 3044 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 3045 | + || bcType.equals("major") || isInOut(sjsb)){ | ||
| 3046 | + continue; | ||
| 3047 | + } | ||
| 3026 | long wd = sjsb.getFcsjActualTime() - jhsb.getFcsjT(); //误点,快1慢2 | 3048 | long wd = sjsb.getFcsjActualTime() - jhsb.getFcsjT(); //误点,快1慢2 |
| 3027 | if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | 3049 | if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ |
| 3028 | sjzdFirst++; | 3050 | sjzdFirst++; |
| 3051 | + break; | ||
| 3029 | } | 3052 | } |
| 3030 | } | 3053 | } |
| 3031 | } | 3054 | } |
| 3032 | 3055 | ||
| 3033 | if(listjh0.size() > 1){ | 3056 | if(listjh0.size() > 1){ |
| 3034 | ScheduleRealInfo jhmb = listjh0.get(listjh0.size() - 1); //计划末班 | 3057 | ScheduleRealInfo jhmb = listjh0.get(listjh0.size() - 1); //计划末班 |
| 3058 | + for(int l = listjh0.size() - 1; l >= 0; l--){ | ||
| 3059 | + jhmb = listjh0.get(l); //计划末班 | ||
| 3060 | + String bcType = jhmb.getBcType(); | ||
| 3061 | + List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhmb.getSpId()); | ||
| 3062 | + if(oList.size() > 0 && oList.get(0) != null | ||
| 3063 | + && oList.get(0).trim().length() > 0){ | ||
| 3064 | + bcType = oList.get(0).trim(); | ||
| 3065 | + } | ||
| 3066 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 3067 | + || bcType.equals("major") || isInOut(jhmb)){ | ||
| 3068 | + continue; | ||
| 3069 | + } | ||
| 3070 | + break; | ||
| 3071 | + } | ||
| 3035 | if("1".equals(sfss) ? createDate.getTime() > jhmb.getFcsjT() : true){ | 3072 | if("1".equals(sfss) ? createDate.getTime() > jhmb.getFcsjT() : true){ |
| 3036 | jhLast++; | 3073 | jhLast++; |
| 3037 | - if(listsj0.size() > 1){ | ||
| 3038 | - ScheduleRealInfo sjmb = listsj0.get(listsj0.size() - 1); //实际末班 | ||
| 3039 | - long wd = sjmb.getFcsjActualTime() - jhmb.getFcsjT(); //误点,快1慢2 | 3074 | + for(int i = listsj0.size() - 1; i >= 0; i--){ |
| 3075 | + ScheduleRealInfo sjmb = listsj0.get(i); //实际末班 | ||
| 3076 | + String bcType = sjmb.getBcType(); | ||
| 3077 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 3078 | + || bcType.equals("major") || isInOut(sjmb)){ | ||
| 3079 | + continue; | ||
| 3080 | + } | ||
| 3081 | + long wd = sjmb.getFcsjActualTime() - jhmb.getFcsjT(); //误点,快1慢2 | ||
| 3040 | if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | 3082 | if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ |
| 3041 | sjzdLast++; | 3083 | sjzdLast++; |
| 3084 | + break; | ||
| 3042 | } | 3085 | } |
| 3043 | - } | 3086 | + } |
| 3044 | } | 3087 | } |
| 3045 | } | 3088 | } |
| 3046 | } | 3089 | } |
| @@ -3048,28 +3091,68 @@ public class BigscreenService { | @@ -3048,28 +3091,68 @@ public class BigscreenService { | ||
| 3048 | //下行 | 3091 | //下行 |
| 3049 | if(listjh1.size() > 0){ | 3092 | if(listjh1.size() > 0){ |
| 3050 | ScheduleRealInfo jhsb = listjh1.get(0); //计划首班 | 3093 | ScheduleRealInfo jhsb = listjh1.get(0); //计划首班 |
| 3094 | + for(int f = 0; f < listjh1.size(); f++){ | ||
| 3095 | + jhsb = listjh1.get(f); //计划首班 | ||
| 3096 | + String bcType = jhsb.getBcType(); | ||
| 3097 | + List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhsb.getSpId()); | ||
| 3098 | + if(oList.size() > 0 && oList.get(0) != null | ||
| 3099 | + && oList.get(0).trim().length() > 0){ | ||
| 3100 | + bcType = oList.get(0).trim(); | ||
| 3101 | + } | ||
| 3102 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 3103 | + || bcType.equals("major") || isInOut(jhsb)){ | ||
| 3104 | + continue; | ||
| 3105 | + } | ||
| 3106 | + break; | ||
| 3107 | + } | ||
| 3051 | if("1".equals(sfss) ? createDate.getTime() > jhsb.getFcsjT() : true){ | 3108 | if("1".equals(sfss) ? createDate.getTime() > jhsb.getFcsjT() : true){ |
| 3052 | jhFirst++; | 3109 | jhFirst++; |
| 3053 | - if(listsj1.size() > 0){ | ||
| 3054 | - ScheduleRealInfo sjsb = listsj1.get(0); //实际首班 | ||
| 3055 | - long wd = sjsb.getFcsjActualTime() - jhsb.getFcsjT(); //误点,快1慢2 | 3110 | + for(int i = 0; i < listsj1.size(); i++){ |
| 3111 | + ScheduleRealInfo sjsb = listsj1.get(i); //实际首班 | ||
| 3112 | + String bcType = sjsb.getBcType(); | ||
| 3113 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 3114 | + || bcType.equals("major") || isInOut(sjsb)){ | ||
| 3115 | + continue; | ||
| 3116 | + } | ||
| 3117 | + long wd = sjsb.getFcsjActualTime() - jhsb.getFcsjT(); //误点,快1慢2 | ||
| 3056 | if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | 3118 | if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ |
| 3057 | sjzdFirst++; | 3119 | sjzdFirst++; |
| 3120 | + break; | ||
| 3058 | } | 3121 | } |
| 3059 | - } | 3122 | + } |
| 3060 | } | 3123 | } |
| 3061 | 3124 | ||
| 3062 | if(listjh1.size() > 1){ | 3125 | if(listjh1.size() > 1){ |
| 3063 | ScheduleRealInfo jhmb = listjh1.get(listjh1.size() - 1); //计划末班 | 3126 | ScheduleRealInfo jhmb = listjh1.get(listjh1.size() - 1); //计划末班 |
| 3127 | + for(int l = listjh1.size() - 1; l >= 0; l--){ | ||
| 3128 | + jhmb = listjh1.get(l); //计划末班 | ||
| 3129 | + String bcType = jhmb.getBcType(); | ||
| 3130 | + List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhmb.getSpId()); | ||
| 3131 | + if(oList.size() > 0 && oList.get(0) != null | ||
| 3132 | + && oList.get(0).trim().length() > 0){ | ||
| 3133 | + bcType = oList.get(0).trim(); | ||
| 3134 | + } | ||
| 3135 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 3136 | + || bcType.equals("major") || isInOut(jhmb)){ | ||
| 3137 | + continue; | ||
| 3138 | + } | ||
| 3139 | + break; | ||
| 3140 | + } | ||
| 3064 | if("1".equals(sfss) ? createDate.getTime() > jhmb.getFcsjT() : true){ | 3141 | if("1".equals(sfss) ? createDate.getTime() > jhmb.getFcsjT() : true){ |
| 3065 | jhLast++; | 3142 | jhLast++; |
| 3066 | - if(listsj1.size() > 1){ | ||
| 3067 | - ScheduleRealInfo sjmb = listsj1.get(listsj1.size() - 1); //实际末班 | ||
| 3068 | - long wd = sjmb.getFcsjActualTime() - jhmb.getFcsjT(); //误点,快1慢2 | 3143 | + for(int i = listsj1.size() - 1; i >= 0; i--){ |
| 3144 | + ScheduleRealInfo sjmb = listsj1.get(i); //实际末班 | ||
| 3145 | + String bcType = sjmb.getBcType(); | ||
| 3146 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 3147 | + || bcType.equals("major") || isInOut(sjmb)){ | ||
| 3148 | + continue; | ||
| 3149 | + } | ||
| 3150 | + long wd = sjmb.getFcsjActualTime() - jhmb.getFcsjT(); //误点,快1慢2 | ||
| 3069 | if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | 3151 | if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ |
| 3070 | sjzdLast++; | 3152 | sjzdLast++; |
| 3153 | + break; | ||
| 3071 | } | 3154 | } |
| 3072 | - } | 3155 | + } |
| 3073 | } | 3156 | } |
| 3074 | } | 3157 | } |
| 3075 | } | 3158 | } |
| @@ -3595,10 +3678,1001 @@ public class BigscreenService { | @@ -3595,10 +3678,1001 @@ public class BigscreenService { | ||
| 3595 | 3678 | ||
| 3596 | return resMap; | 3679 | return resMap; |
| 3597 | } | 3680 | } |
| 3598 | - | ||
| 3599 | -// public static void main(String[] args){ | ||
| 3600 | -// | ||
| 3601 | -// } | 3681 | + |
| 3682 | + //线路公里、能耗与统计指标,(临港大屏,给顾婷婷) | ||
| 3683 | + @GET | ||
| 3684 | + @Path("/findMileageAndCount/{date}") | ||
| 3685 | + public List<Map<String, Object>> findMileageAndCount(@PathParam("date") String date) throws ParseException { | ||
| 3686 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 3687 | + | ||
| 3688 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 3689 | + SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 3690 | + Date dateParse = dateFormat.parse(date); | ||
| 3691 | + long newDatetime = new Date().getTime() - (10l * 1000*60); | ||
| 3692 | + | ||
| 3693 | + String yyxlSql="SELECT line_code from bsth_c_line " | ||
| 3694 | + + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | ||
| 3695 | + List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | ||
| 3696 | + new RowMapper<Map<String, Object>>(){ | ||
| 3697 | + @Override | ||
| 3698 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 3699 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3700 | + m.put("lineCode", rs.getString("line_code")); | ||
| 3701 | + return m; | ||
| 3702 | + } | ||
| 3703 | + }); | ||
| 3704 | + Set<String> yyLine = new HashSet<String>(); | ||
| 3705 | + for(Map<String, Object> t : yyxlList){ | ||
| 3706 | + if(t.get("lineCode") != null){ | ||
| 3707 | + yyLine.add(t.get("lineCode").toString()); | ||
| 3708 | + } | ||
| 3709 | + } | ||
| 3710 | + | ||
| 3711 | + String gpLineSql = "select * from bsth_c_line_plate"; | ||
| 3712 | + List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | ||
| 3713 | + new RowMapper<Map<String, Object>>(){ | ||
| 3714 | + @Override | ||
| 3715 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 3716 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3717 | + m.put("lineName", rs.getString("line_name")); | ||
| 3718 | + m.put("lineCode", rs.getString("line_code")); | ||
| 3719 | + return m; | ||
| 3720 | + } | ||
| 3721 | + }); | ||
| 3722 | + Set<String> gpSet = new HashSet<String>(); | ||
| 3723 | + for(Map<String, Object> t : gpLineList){ | ||
| 3724 | + if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | ||
| 3725 | + gpSet.add(t.get("lineCode").toString().trim()); | ||
| 3726 | + } | ||
| 3727 | + } | ||
| 3728 | + | ||
| 3729 | + String sql="select gsdm,fgsdm,xl,xl_name,date,jhbc,jhbcz,sjbc,bczxl,jhcc,sjcc,ccl," | ||
| 3730 | + + " jhzgl,sjzgl,jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | ||
| 3731 | + + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | ||
| 3732 | + + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | ||
| 3733 | + + " jhszfcs,sjszfczds,szfczdl,create_date" | ||
| 3734 | + + " from bsth_c_calc_count " | ||
| 3735 | + + " where date = ? "; | ||
| 3736 | + | ||
| 3737 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, new Object[]{date}, | ||
| 3738 | + new RowMapper<Map<String, Object>>(){ | ||
| 3739 | + @Override | ||
| 3740 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 3741 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3742 | + m.put("gsdm",rs.getString("gsdm")); | ||
| 3743 | + m.put("fgsdm",rs.getString("fgsdm")); | ||
| 3744 | + m.put("lineCode",rs.getString("xl")); | ||
| 3745 | + m.put("lineName", rs.getString("xl_name")); | ||
| 3746 | + m.put("date", rs.getString("date")); | ||
| 3747 | + | ||
| 3748 | + m.put("jhbc", rs.getString("jhbc")); | ||
| 3749 | + m.put("sjbc", rs.getString("sjbc")); | ||
| 3750 | + m.put("bczxl", rs.getString("bczxl")); | ||
| 3751 | + m.put("jhbcz", rs.getString("jhbcz")); | ||
| 3752 | + | ||
| 3753 | + m.put("jhcc", rs.getString("jhcc")); | ||
| 3754 | + m.put("sjcc", rs.getString("sjcc")); | ||
| 3755 | + m.put("ccl", rs.getString("ccl")); | ||
| 3756 | + | ||
| 3757 | + m.put("jhzgl", rs.getString("jhzgl")); | ||
| 3758 | + m.put("sjzgl", rs.getString("sjzgl")); | ||
| 3759 | + m.put("jhyylc", rs.getString("jhyylc")); | ||
| 3760 | + m.put("sjyylc", rs.getString("sjyylc")); | ||
| 3761 | + m.put("jhyylcz", rs.getString("jhyylcz")); | ||
| 3762 | + m.put("jhkslc", rs.getString("jhkslc")); | ||
| 3763 | + m.put("sjkslc", rs.getString("sjkslc")); | ||
| 3764 | + m.put("jhkslcz", rs.getString("jhkslcz")); | ||
| 3765 | + | ||
| 3766 | + m.put("jhgfbcs", rs.getString("jhssgfbcs")); | ||
| 3767 | + m.put("sjgfbcs", rs.getString("sjgfbcs")); | ||
| 3768 | + m.put("jhgfbcsz", rs.getString("jhgfbcsz")); | ||
| 3769 | + m.put("jhdgbcs", rs.getString("jhssdgbcs")); | ||
| 3770 | + m.put("sjdgbcs", rs.getString("sjdgbcs")); | ||
| 3771 | + m.put("jhdgbcsz", rs.getString("jhdgbcsz")); | ||
| 3772 | + | ||
| 3773 | + m.put("jhsmbcs", rs.getString("jhsmbcs")); | ||
| 3774 | + m.put("sjsmbczds", rs.getString("sjsmbczds")); | ||
| 3775 | + m.put("smbczdl", rs.getString("smbczdl")); | ||
| 3776 | + m.put("jhsmbcsz", rs.getString("jhsmbcsz")); | ||
| 3777 | + m.put("sjsmbczdsz", rs.getString("sjsmbczdsz")); | ||
| 3778 | + m.put("smbczdlz", rs.getString("smbczdlz")); | ||
| 3779 | + | ||
| 3780 | + m.put("jhszfcs", rs.getString("jhszfcs")); | ||
| 3781 | + m.put("sjszfczds", rs.getString("sjszfczds")); | ||
| 3782 | + m.put("szfczdl", rs.getString("szfczdl")); | ||
| 3783 | + | ||
| 3784 | + Date date = new Date(); | ||
| 3785 | + date.setTime(rs.getTimestamp("create_date").getTime()); | ||
| 3786 | + m.put("createDate", sdf.format(date)); | ||
| 3787 | + return m; | ||
| 3788 | + } | ||
| 3789 | + }); | ||
| 3790 | + | ||
| 3791 | + String ylbSql="select rq,ssgsdm,fgsdm,xlbm,linename,yh" | ||
| 3792 | + + " from bsth_c_ylb " | ||
| 3793 | + + " where rq = ? "; | ||
| 3794 | + List<Map<String, Object>> ylbList=jdbcTemplate.query(ylbSql, new Object[]{date}, | ||
| 3795 | + new RowMapper<Map<String, Object>>(){ | ||
| 3796 | + @Override | ||
| 3797 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 3798 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3799 | + m.put("lineCode", rs.getString("xlbm")); | ||
| 3800 | + m.put("yh", rs.getString("yh")); | ||
| 3801 | + return m; | ||
| 3802 | + } | ||
| 3803 | + }); | ||
| 3804 | + Map<String, BigDecimal> ylbMap = new HashMap<String, BigDecimal>(); | ||
| 3805 | + for(Map<String, Object> m : ylbList){ | ||
| 3806 | + String lineCode = m.get("lineCode").toString(); | ||
| 3807 | + if(!(ylbMap.containsKey(lineCode))){ | ||
| 3808 | + ylbMap.put(lineCode, new BigDecimal("0")); | ||
| 3809 | + } | ||
| 3810 | + ylbMap.put(lineCode, ylbMap.get(lineCode).add(new BigDecimal(m.get("yh").toString()))); | ||
| 3811 | + } | ||
| 3812 | + | ||
| 3813 | + String dlbSql="select rq,ssgsdm,fgsdm,xlbm,linename,hd" | ||
| 3814 | + + " from bsth_c_dlb " | ||
| 3815 | + + " where rq = ? "; | ||
| 3816 | + List<Map<String, Object>> dlbList=jdbcTemplate.query(dlbSql, new Object[]{date}, | ||
| 3817 | + new RowMapper<Map<String, Object>>(){ | ||
| 3818 | + @Override | ||
| 3819 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 3820 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3821 | + m.put("lineCode", rs.getString("xlbm")); | ||
| 3822 | + m.put("hd", rs.getString("hd")); | ||
| 3823 | + return m; | ||
| 3824 | + } | ||
| 3825 | + }); | ||
| 3826 | + Map<String, BigDecimal> dlbMap = new HashMap<String, BigDecimal>(); | ||
| 3827 | + for(Map<String, Object> m : dlbList){ | ||
| 3828 | + String lineCode = m.get("lineCode").toString(); | ||
| 3829 | + if(!(dlbMap.containsKey(lineCode))){ | ||
| 3830 | + dlbMap.put(lineCode, new BigDecimal("0")); | ||
| 3831 | + } | ||
| 3832 | + dlbMap.put(lineCode, dlbMap.get(lineCode).add(new BigDecimal(m.get("hd").toString()))); | ||
| 3833 | + } | ||
| 3834 | + | ||
| 3835 | + String qlbSql="select rq,ssgsdm,fgsdm,xlbm,linename,hn" | ||
| 3836 | + + " from bsth_c_qlb " | ||
| 3837 | + + " where rq = ? "; | ||
| 3838 | + List<Map<String, Object>> qlbList=jdbcTemplate.query(qlbSql, new Object[]{date}, | ||
| 3839 | + new RowMapper<Map<String, Object>>(){ | ||
| 3840 | + @Override | ||
| 3841 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 3842 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3843 | + m.put("lineCode", rs.getString("xlbm")); | ||
| 3844 | + m.put("hn", rs.getString("hn")); | ||
| 3845 | + return m; | ||
| 3846 | + } | ||
| 3847 | + }); | ||
| 3848 | + Map<String, BigDecimal> qlbMap = new HashMap<String, BigDecimal>(); | ||
| 3849 | + for(Map<String, Object> m : qlbList){ | ||
| 3850 | + String lineCode = m.get("lineCode").toString(); | ||
| 3851 | + if(!(qlbMap.containsKey(lineCode))){ | ||
| 3852 | + qlbMap.put(lineCode, new BigDecimal("0")); | ||
| 3853 | + } | ||
| 3854 | + qlbMap.put(lineCode, qlbMap.get(lineCode).add(new BigDecimal(m.get("hn").toString()))); | ||
| 3855 | + } | ||
| 3856 | + | ||
| 3857 | + | ||
| 3858 | + for(Map<String, Object> t : list){ | ||
| 3859 | + if(yyLine.contains(t.get("lineCode").toString())){ | ||
| 3860 | + String lineCode = t.get("lineCode").toString(); | ||
| 3861 | + Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 3862 | + resMap.put("date", t.get("date").toString()); | ||
| 3863 | + resMap.put("companyCode", t.get("gsdm").toString()); | ||
| 3864 | + resMap.put("companyName", BusinessCodeData.code2Name.get(t.get("gsdm").toString())); | ||
| 3865 | + resMap.put("brancheCompanyCode", t.get("fgsdm").toString()); | ||
| 3866 | + resMap.put("brancheCompanyName", BusinessCodeData.code2Name.get(t.get("gsdm").toString() | ||
| 3867 | + + "_" + t.get("fgsdm").toString())); | ||
| 3868 | + resMap.put("lineCode", t.get("lineCode").toString()); | ||
| 3869 | + resMap.put("lineName", t.get("lineName").toString()); | ||
| 3870 | + | ||
| 3871 | + resMap.put("jhcc", t.get("jhcc").toString()); | ||
| 3872 | + resMap.put("sjcc", t.get("sjcc").toString()); | ||
| 3873 | + resMap.put("ccl", t.get("ccl").toString()); | ||
| 3874 | + resMap.put("jhbc", t.get("jhbc").toString()); | ||
| 3875 | + resMap.put("sjbc", t.get("sjbc").toString()); | ||
| 3876 | + resMap.put("bczxl", t.get("bczxl").toString()); | ||
| 3877 | + resMap.put("jhsmbc", t.get("jhsmbcs").toString()); | ||
| 3878 | + resMap.put("sjsmzd", t.get("sjsmbczds").toString()); | ||
| 3879 | + resMap.put("smbzdl", t.get("smbczdl").toString()); | ||
| 3880 | + resMap.put("jhqqbc", t.get("jhszfcs").toString()); | ||
| 3881 | + resMap.put("sjqqzd", t.get("sjszfczds").toString()); | ||
| 3882 | + resMap.put("qqzzdl", t.get("szfczdl").toString()); | ||
| 3883 | + if(gpSet.contains(lineCode)){ | ||
| 3884 | + resMap.put("isPlate", "1"); | ||
| 3885 | + resMap.put("jhgpbc", t.get("jhszfcs").toString()); | ||
| 3886 | + resMap.put("sjgpzd", t.get("sjszfczds").toString()); | ||
| 3887 | + resMap.put("gpzdl", t.get("szfczdl").toString()); | ||
| 3888 | + } else { | ||
| 3889 | + resMap.put("isPlate", "0"); | ||
| 3890 | + resMap.put("jhgpbc", ""); | ||
| 3891 | + resMap.put("sjgpzd", ""); | ||
| 3892 | + resMap.put("gpzdl", ""); | ||
| 3893 | + } | ||
| 3894 | + | ||
| 3895 | + | ||
| 3896 | + List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date, lineCode); | ||
| 3897 | + List<ScheduleRealInfo> listSche = new ArrayList<ScheduleRealInfo>(); | ||
| 3898 | + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | ||
| 3899 | + BigscreenService bigscreenService = new BigscreenService(); | ||
| 3900 | + | ||
| 3901 | + long jh = 0, sj = 0, ljbc = 0, lbbc = 0; | ||
| 3902 | + for(ScheduleRealInfo s : findAll){ | ||
| 3903 | + if(!BigscreenService.isInOut(s) && !s.isCcService() | ||
| 3904 | + && s.getStatus() != -1 && s.getStatus() != 0){ | ||
| 3905 | + ++jh; | ||
| 3906 | + String sty = BigscreenService.decimalToBinary(s.getRfidState()); | ||
| 3907 | + Integer state = Integer.parseInt(sty); | ||
| 3908 | + if ((state & 4) == 4) { | ||
| 3909 | + ++sj; | ||
| 3910 | + } | ||
| 3911 | + } | ||
| 3912 | + | ||
| 3913 | +// long minFcsj = minFcsjs(s.getXlBm()); | ||
| 3914 | + long jhZdsjTime = timeFormat.parse(s.getRealExecDate() + " " + s.getZdsj()).getTime(); | ||
| 3915 | + String[] jhFcsj = s.getDfsj().split(":"); | ||
| 3916 | + String[] jhZdsj = s.getZdsj().split(":"); | ||
| 3917 | + Long jhFcsjL = Long.parseLong(jhFcsj[0]) * 60 + Long.parseLong(jhFcsj[1]); | ||
| 3918 | + Long jhZdsjL = Long.parseLong(jhZdsj[0]) * 60 + Long.parseLong(jhZdsj[1]); | ||
| 3919 | + if(jhZdsjL < jhFcsjL){ | ||
| 3920 | + jhZdsjTime += (1l * 1000*60*60*24); | ||
| 3921 | + } | ||
| 3922 | +// listSche.add(s); | ||
| 3923 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 3924 | + if (cts != null && cts.size() > 0) { | ||
| 3925 | + listSche.add(s); | ||
| 3926 | + list_s.add(s); | ||
| 3927 | + if (!BigscreenService.isInOut(s) && s.isSflj()){ | ||
| 3928 | + ++ljbc; | ||
| 3929 | + } | ||
| 3930 | + if (!BigscreenService.isInOut(s) && !s.isCcService() && s.getStatus() == -1) { | ||
| 3931 | + ++lbbc; | ||
| 3932 | + } | ||
| 3933 | + } else { | ||
| 3934 | + boolean fage = true; | ||
| 3935 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 3936 | + listSche.add(s); | ||
| 3937 | + list_s.add(s); | ||
| 3938 | + if (!BigscreenService.isInOut(s) && s.isSflj()){ | ||
| 3939 | + ++ljbc; | ||
| 3940 | + } | ||
| 3941 | + if (!BigscreenService.isInOut(s) && !s.isCcService() && s.getStatus() == -1) { | ||
| 3942 | + ++lbbc; | ||
| 3943 | + } | ||
| 3944 | + } | ||
| 3945 | + if(fage){ | ||
| 3946 | + if(s.getStatus() == -1 && newDatetime > jhZdsjTime){ | ||
| 3947 | + listSche.add(s); | ||
| 3948 | + } | ||
| 3949 | + } | ||
| 3950 | + } | ||
| 3951 | + } | ||
| 3952 | + resMap.put("jhqk", jh); | ||
| 3953 | + resMap.put("sjqk", sj); | ||
| 3954 | + resMap.put("qkl", jh>0?new BigDecimal(sj).divide(new BigDecimal(jh), | ||
| 3955 | + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | ||
| 3956 | + | ||
| 3957 | + double jhyygl = bigscreenService.culateJhgl(listSche); //计划营运公里 | ||
| 3958 | + double jhksgl = bigscreenService.culateJhJccgl(listSche); //计划空驶里程 | ||
| 3959 | + double jhzgl = Arith.add(jhyygl, jhksgl); //计划总里程=计划营运里程+计划空驶里程 | ||
| 3960 | + double sjgl = bigscreenService.culateSjgl(list_s); //实际营运公里(不含临加) | ||
| 3961 | + double sjljgl = bigscreenService.culateLjgl(listSche); //实际临加公里 | ||
| 3962 | + double sjyygl = Arith.add(sjgl, sjljgl); //实际营运公里(含临加) | ||
| 3963 | + double sjjccgl = bigscreenService.culateJccgl(list_s); | ||
| 3964 | + double sjksgl = bigscreenService.culateKsgl(list_s); | ||
| 3965 | + double zksgl = Arith.add(sjjccgl, sjksgl); //实际空驶里程(含临加) | ||
| 3966 | + double sjzgl = Arith.add(sjyygl, zksgl); //实际总公里(含临加) | ||
| 3967 | + double lz = bigscreenService.culateCJLC(listSche, "路阻"); | ||
| 3968 | + double dm = bigscreenService.culateCJLC(listSche, "吊慢"); | ||
| 3969 | + double gz = bigscreenService.culateCJLC(listSche, "故障"); | ||
| 3970 | + double jf = bigscreenService.culateCJLC(listSche, "纠纷"); | ||
| 3971 | + double zs = bigscreenService.culateCJLC(listSche, "肇事"); | ||
| 3972 | + double qr = bigscreenService.culateCJLC(listSche, "缺人"); | ||
| 3973 | + double qc = bigscreenService.culateCJLC(listSche, "缺车"); | ||
| 3974 | + double kx = bigscreenService.culateCJLC(listSche, "客稀"); | ||
| 3975 | + double qh = bigscreenService.culateCJLC(listSche, "气候"); | ||
| 3976 | + double yw = bigscreenService.culateCJLC(listSche, "援外"); | ||
| 3977 | + double lb_pc = bigscreenService.culateCJLC(listSche, "配车"); | ||
| 3978 | + double lb_by = bigscreenService.culateCJLC(listSche, "保养"); | ||
| 3979 | + double lb_cj = bigscreenService.culateCJLC(listSche, "抽减"); | ||
| 3980 | + double lb_qt = bigscreenService.culateCJLC(listSche, "其他"); | ||
| 3981 | + BigDecimal lbzgl = new BigDecimal(lz).add(new BigDecimal(dm)) | ||
| 3982 | + .add(new BigDecimal(gz)).add(new BigDecimal(jf)).add(new BigDecimal(zs)) | ||
| 3983 | + .add(new BigDecimal(qr)).add(new BigDecimal(qc)).add(new BigDecimal(kx)) | ||
| 3984 | + .add(new BigDecimal(qh)).add(new BigDecimal(yw)) | ||
| 3985 | + .add(new BigDecimal(lb_pc)).add(new BigDecimal(lb_by)) | ||
| 3986 | + .add(new BigDecimal(lb_cj)).add(new BigDecimal(lb_qt)); | ||
| 3987 | + | ||
| 3988 | + resMap.put("planMileageSum", jhzgl); //计划总里程=计划营运里程+计划空驶里程 | ||
| 3989 | + resMap.put("realMileageSum", sjzgl); //实际总里程=实际营运里程+实际空驶里程(含临加) | ||
| 3990 | + resMap.put("planMileageService", jhyygl); //计划营运公里 | ||
| 3991 | + resMap.put("planMileageEmpty", jhksgl); //计划空驶公里 | ||
| 3992 | + resMap.put("realMileageService", sjyygl); //实际营运公里(含临加) | ||
| 3993 | + resMap.put("realMileageEmpty", sjksgl); //实际空驶公里(含临加) | ||
| 3994 | + resMap.put("tempMileage", sjljgl); //临加公里 | ||
| 3995 | + resMap.put("tempBus", ljbc); //临加班次 | ||
| 3996 | + resMap.put("cancelMileage", lbzgl); //烂班公里 | ||
| 3997 | + resMap.put("cancelBus", lbbc); //烂班公里 | ||
| 3998 | + resMap.put("oil", ylbMap.get(lineCode)); //油耗 | ||
| 3999 | + resMap.put("electricity", dlbMap.get(lineCode)); //耗电 | ||
| 4000 | + resMap.put("hydrogen", qlbMap.get(lineCode)); //耗能(氢) | ||
| 4001 | + resList.add(resMap); | ||
| 4002 | + } | ||
| 4003 | + } | ||
| 4004 | + return resList; | ||
| 4005 | + } | ||
| 4006 | + | ||
| 4007 | + //查询指标异常的班次(临港大屏,给顾婷婷) | ||
| 4008 | + @GET | ||
| 4009 | + @Path("/findNotStandards/{date}") | ||
| 4010 | + public List<Map<String, Object>> findNotStandards(@PathParam("date") String date) throws ParseException { | ||
| 4011 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 4012 | + | ||
| 4013 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 4014 | + SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 4015 | + Date dateParse = dateFormat.parse(date); | ||
| 4016 | + long newDatetime = new Date().getTime() - (10l * 1000*60); | ||
| 4017 | + | ||
| 4018 | + String yyxlSql="SELECT line_code, start_station_name, end_station_name from bsth_c_line " | ||
| 4019 | + + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | ||
| 4020 | + List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | ||
| 4021 | + new RowMapper<Map<String, Object>>(){ | ||
| 4022 | + @Override | ||
| 4023 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 4024 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 4025 | + m.put("lineCode", rs.getString("line_code")); | ||
| 4026 | + m.put("startStationName", rs.getString("start_station_name")); | ||
| 4027 | + m.put("endStationName", rs.getString("end_station_name")); | ||
| 4028 | + return m; | ||
| 4029 | + } | ||
| 4030 | + }); | ||
| 4031 | + Map<String, Map<String, String>> yyLine = new HashMap<String, Map<String, String>>(); | ||
| 4032 | + for(Map<String, Object> t : yyxlList){ | ||
| 4033 | + if(t.get("lineCode") != null){ | ||
| 4034 | + Map<String, String> m = new HashMap<String, String>(); | ||
| 4035 | + m.put("startStationName", t.get("startStationName").toString()); | ||
| 4036 | + m.put("endStationName", t.get("endStationName").toString()); | ||
| 4037 | + yyLine.put(t.get("lineCode").toString(), m); | ||
| 4038 | + } | ||
| 4039 | + } | ||
| 4040 | + | ||
| 4041 | + String sqlMinYysj="select line, start_opt from bsth_c_line_config where " | ||
| 4042 | + + " id = (" | ||
| 4043 | + + "select max(id) from bsth_c_line_config " | ||
| 4044 | + + ")"; | ||
| 4045 | + List<Map<String, Object>> lineConfigList= jdbcTemplate.query(sqlMinYysj, | ||
| 4046 | + new RowMapper<Map<String, Object>>(){ | ||
| 4047 | + @Override | ||
| 4048 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 4049 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 4050 | + m.put("lineCode", rs.getString("line")); | ||
| 4051 | + m.put("startopt", rs.getString("start_opt")); | ||
| 4052 | + return m; | ||
| 4053 | + } | ||
| 4054 | + }); | ||
| 4055 | + Map<String, Long> lineStartopt = new HashMap<String, Long>(); | ||
| 4056 | + for(Map<String, Object> t : lineConfigList){ | ||
| 4057 | + String startopt = t.get("startopt").toString(); | ||
| 4058 | + String[] minSjs = startopt.split(":"); | ||
| 4059 | + Long minSj=Long.parseLong(minSjs[0])*60+Long.parseLong(minSjs[1]); | ||
| 4060 | + lineStartopt.put(t.get("lineCode").toString(), minSj); | ||
| 4061 | + } | ||
| 4062 | + | ||
| 4063 | + String gpLineSql = "select * from bsth_c_line_plate"; | ||
| 4064 | + List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | ||
| 4065 | + new RowMapper<Map<String, Object>>(){ | ||
| 4066 | + @Override | ||
| 4067 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 4068 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 4069 | + m.put("lineName", rs.getString("line_name")); | ||
| 4070 | + m.put("lineCode", rs.getString("line_code")); | ||
| 4071 | + return m; | ||
| 4072 | + } | ||
| 4073 | + }); | ||
| 4074 | + Set<String> gpSet = new HashSet<String>(); | ||
| 4075 | + for(Map<String, Object> t : gpLineList){ | ||
| 4076 | + if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | ||
| 4077 | + gpSet.add(t.get("lineCode").toString().trim()); | ||
| 4078 | + } | ||
| 4079 | + } | ||
| 4080 | + | ||
| 4081 | + List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date); | ||
| 4082 | + List<ScheduleRealInfo> listSche = new ArrayList<ScheduleRealInfo>(); | ||
| 4083 | + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | ||
| 4084 | + | ||
| 4085 | + Map<String, List<ScheduleRealInfo>> sm_listjh0 = new HashMap<String, List<ScheduleRealInfo>>(); | ||
| 4086 | + Map<String, List<ScheduleRealInfo>> sm_listjh1 = new HashMap<String, List<ScheduleRealInfo>>(); | ||
| 4087 | + Map<String, List<ScheduleRealInfo>> sm_listsj0 = new HashMap<String, List<ScheduleRealInfo>>(); | ||
| 4088 | + Map<String, List<ScheduleRealInfo>> sm_listsj1 = new HashMap<String, List<ScheduleRealInfo>>(); | ||
| 4089 | + | ||
| 4090 | + for(ScheduleRealInfo s : findAll){ | ||
| 4091 | + String lineCode = s.getXlBm(); | ||
| 4092 | + if(!yyLine.containsKey(lineCode)){ | ||
| 4093 | + continue; | ||
| 4094 | + } | ||
| 4095 | + long jhZdsjTime = timeFormat.parse(s.getRealExecDate() + " " + s.getZdsj()).getTime(); | ||
| 4096 | + String[] jhFcsj = s.getDfsj().split(":"); | ||
| 4097 | + String[] jhZdsj = s.getZdsj().split(":"); | ||
| 4098 | + Long jhFcsjL = Long.parseLong(jhFcsj[0]) * 60 + Long.parseLong(jhFcsj[1]); | ||
| 4099 | + Long jhZdsjL = Long.parseLong(jhZdsj[0]) * 60 + Long.parseLong(jhZdsj[1]); | ||
| 4100 | + if(jhZdsjL < jhFcsjL){ | ||
| 4101 | + jhZdsjTime += (1l * 1000*60*60*24); | ||
| 4102 | + } | ||
| 4103 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 4104 | + if (cts != null && cts.size() > 0) { | ||
| 4105 | + listSche.add(s); | ||
| 4106 | + list_s.add(s); | ||
| 4107 | + } else { | ||
| 4108 | + boolean fage = true; | ||
| 4109 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 4110 | + listSche.add(s); | ||
| 4111 | + list_s.add(s); | ||
| 4112 | + } | ||
| 4113 | + if(fage){ | ||
| 4114 | + if(s.getStatus() == -1 && newDatetime > jhZdsjTime){ | ||
| 4115 | + listSche.add(s); | ||
| 4116 | + } | ||
| 4117 | + } | ||
| 4118 | + } | ||
| 4119 | + | ||
| 4120 | + Long minFcsj = 120l; | ||
| 4121 | + if(lineStartopt.containsKey(lineCode)){ | ||
| 4122 | + minFcsj = lineStartopt.get(lineCode); | ||
| 4123 | + } | ||
| 4124 | + String[] fcsj = s.getFcsj().split(":"); | ||
| 4125 | + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 4126 | + Long fscjT = 0L; | ||
| 4127 | + if (fcsjL < minFcsj) { | ||
| 4128 | + Calendar calendar = new GregorianCalendar(); | ||
| 4129 | + calendar.setTime(s.getScheduleDate()); | ||
| 4130 | + calendar.add(calendar.DATE, 1); | ||
| 4131 | + Date dddd = calendar.getTime(); | ||
| 4132 | + try { | ||
| 4133 | + fscjT = timeFormat.parse(dateFormat.format(dddd) + " " + s.getFcsj()).getTime(); | ||
| 4134 | + } catch (ParseException e) { | ||
| 4135 | + // TODO Auto-generated catch block | ||
| 4136 | + e.printStackTrace(); | ||
| 4137 | + } | ||
| 4138 | + } else { | ||
| 4139 | + try { | ||
| 4140 | + fscjT = timeFormat.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 4141 | + } catch (ParseException e) { | ||
| 4142 | + // TODO Auto-generated catch block | ||
| 4143 | + e.printStackTrace(); | ||
| 4144 | + } | ||
| 4145 | + } | ||
| 4146 | + if (StringUtils.isEmpty(s.getFcsjActual())) { | ||
| 4147 | + s.setFcsjActualTime(0L); | ||
| 4148 | + s.setFcsjT(fscjT); | ||
| 4149 | + } else { | ||
| 4150 | + Long fcsjAcual = 0L; | ||
| 4151 | + try { | ||
| 4152 | + fcsjAcual = timeFormat.parse(s.getRealExecDate() + " " + s.getFcsjActual()).getTime(); | ||
| 4153 | + s.setFcsjActualTime(fcsjAcual); | ||
| 4154 | + s.setFcsjT(fscjT); | ||
| 4155 | + } catch (ParseException e) { | ||
| 4156 | + // TODO Auto-generated catch block | ||
| 4157 | + e.printStackTrace(); | ||
| 4158 | + } | ||
| 4159 | + } | ||
| 4160 | + | ||
| 4161 | + if(!isInOut(s) && !s.getBcType().equals("region")){ | ||
| 4162 | + if(!sm_listjh0.containsKey(lineCode)){ | ||
| 4163 | + sm_listjh0.put(lineCode, new ArrayList<ScheduleRealInfo>()); | ||
| 4164 | + } | ||
| 4165 | + if(!sm_listjh1.containsKey(lineCode)){ | ||
| 4166 | + sm_listjh1.put(lineCode, new ArrayList<ScheduleRealInfo>()); | ||
| 4167 | + } | ||
| 4168 | + if(!sm_listsj0.containsKey(lineCode)){ | ||
| 4169 | + sm_listsj0.put(lineCode, new ArrayList<ScheduleRealInfo>()); | ||
| 4170 | + } | ||
| 4171 | + if(!sm_listsj1.containsKey(lineCode)){ | ||
| 4172 | + sm_listsj1.put(lineCode, new ArrayList<ScheduleRealInfo>()); | ||
| 4173 | + } | ||
| 4174 | + List<ScheduleRealInfo> listjh0 = sm_listjh0.get(lineCode); | ||
| 4175 | + List<ScheduleRealInfo> listjh1 = sm_listjh1.get(lineCode); | ||
| 4176 | + List<ScheduleRealInfo> listsj0 = sm_listsj0.get(lineCode); | ||
| 4177 | + List<ScheduleRealInfo> listsj1 = sm_listsj1.get(lineCode); | ||
| 4178 | + if (!(s.isSflj())) { | ||
| 4179 | + if (s.getXlDir().equals("0")) { | ||
| 4180 | + listjh0.add(s); | ||
| 4181 | + } else { | ||
| 4182 | + listjh1.add(s); | ||
| 4183 | + } | ||
| 4184 | + } | ||
| 4185 | + | ||
| 4186 | + if(s.getFcsjActual() != null && s.getFcsjActual().trim().length() > 0){ | ||
| 4187 | + if (s.getXlDir().equals("0")) { | ||
| 4188 | + listsj0.add(s); | ||
| 4189 | + } else { | ||
| 4190 | + listsj1.add(s); | ||
| 4191 | + } | ||
| 4192 | + } | ||
| 4193 | + } | ||
| 4194 | + } | ||
| 4195 | + | ||
| 4196 | + Map<String, List<ScheduleRealInfo>> map_listjh0 = new HashMap<String, List<ScheduleRealInfo>>(); | ||
| 4197 | + Map<String, List<ScheduleRealInfo>> map_listjh1 = new HashMap<String, List<ScheduleRealInfo>>(); | ||
| 4198 | + Map<String, List<ScheduleRealInfo>> map_listsj0 = new HashMap<String, List<ScheduleRealInfo>>(); | ||
| 4199 | + Map<String, List<ScheduleRealInfo>> map_listsj1 = new HashMap<String, List<ScheduleRealInfo>>(); | ||
| 4200 | + | ||
| 4201 | + Map<String, Map<String, Object>> jhccMap = new HashMap<String, Map<String, Object>>(); | ||
| 4202 | + Set<String> sjccSet = new HashSet<String>(); | ||
| 4203 | + List<Map<String, Object>> bcList = new ArrayList<Map<String, Object>>(); | ||
| 4204 | + List<Map<String, Object>> smList = new ArrayList<Map<String, Object>>(); | ||
| 4205 | + List<Map<String, Object>> qqzList = new ArrayList<Map<String, Object>>(); | ||
| 4206 | + List<Map<String, Object>> gpqqzList = new ArrayList<Map<String, Object>>(); | ||
| 4207 | + for(ScheduleRealInfo s : listSche){ | ||
| 4208 | + String lineCode = s.getXlBm(); | ||
| 4209 | + String bcType = s.getBcType(); | ||
| 4210 | + if (!bcType.equals("in") && !bcType.equals("out") && !bcType.equals("ldks") && !s.isSflj()) { | ||
| 4211 | + String clZbh = s.getClZbh(); | ||
| 4212 | + String key = lineCode + "_" + clZbh; | ||
| 4213 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 4214 | + | ||
| 4215 | + | ||
| 4216 | + //出车率 | ||
| 4217 | + if(!jhccMap.containsKey(key)){ | ||
| 4218 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 4219 | + m.put("date", s.getScheduleDateStr()); | ||
| 4220 | + m.put("companyCode", s.getGsBm()); | ||
| 4221 | + m.put("companyName", s.getGsName()); | ||
| 4222 | + m.put("brancheCompanyCode", s.getFgsBm()); | ||
| 4223 | + m.put("brancheCompanyName", s.getFgsName()); | ||
| 4224 | + m.put("lineCode", s.getXlBm()); | ||
| 4225 | + m.put("lineName", s.getXlName()); | ||
| 4226 | + m.put("car", s.getClZbh()); | ||
| 4227 | + m.put("driverCode", s.getjGh()); | ||
| 4228 | + m.put("driverName", s.getjName()); | ||
| 4229 | + m.put("remark", s.getRemarks()!=null?s.getRemarks():""); | ||
| 4230 | + m.put("type", "计划出车率"); | ||
| 4231 | + jhccMap.put(key, m); | ||
| 4232 | + } | ||
| 4233 | + if (cts.isEmpty()) { | ||
| 4234 | + if (s.getStatus() != -1) { | ||
| 4235 | + sjccSet.add(key); | ||
| 4236 | + } | ||
| 4237 | + } else { | ||
| 4238 | + Iterator<ChildTaskPlan> it = cts.iterator(); | ||
| 4239 | + while (it.hasNext()) { | ||
| 4240 | + ChildTaskPlan childTaskPlan = it.next(); | ||
| 4241 | + if (childTaskPlan.getMileageType().equals("service") && !childTaskPlan.isDestroy() | ||
| 4242 | + && (!childTaskPlan.isNoClerk())) { | ||
| 4243 | + sjccSet.add(key); | ||
| 4244 | + } | ||
| 4245 | + } | ||
| 4246 | + } | ||
| 4247 | + | ||
| 4248 | + //班次执行率 | ||
| 4249 | + if ((cts != null && cts.size() > 0 && s.getStatus() != -1) | ||
| 4250 | + || (s.getFcsjActual() != null && s.getStatus() != -1)) { | ||
| 4251 | + //执行的班次 | ||
| 4252 | + } else { | ||
| 4253 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 4254 | + m.put("date", s.getScheduleDateStr()); | ||
| 4255 | + m.put("companyCode", s.getGsBm()); | ||
| 4256 | + m.put("companyName", s.getGsName()); | ||
| 4257 | + m.put("brancheCompanyCode", s.getFgsBm()); | ||
| 4258 | + m.put("brancheCompanyName", s.getFgsName()); | ||
| 4259 | + m.put("lineCode", s.getXlBm()); | ||
| 4260 | + m.put("lineName", s.getXlName()); | ||
| 4261 | + m.put("car", s.getClZbh()); | ||
| 4262 | + m.put("driverCode", s.getjGh()); | ||
| 4263 | + m.put("driverName", s.getjName()); | ||
| 4264 | + m.put("startTime", s.getFcsj()); | ||
| 4265 | + m.put("startStationName", s.getQdzName()); | ||
| 4266 | + m.put("remark", s.getRemarks()!=null?s.getRemarks():""); | ||
| 4267 | + m.put("type", "计划班次执行率"); | ||
| 4268 | + bcList.add(m); | ||
| 4269 | + } | ||
| 4270 | + } | ||
| 4271 | + | ||
| 4272 | + //首末班发车准点率 | ||
| 4273 | + if(!isInOut(s)){ | ||
| 4274 | + boolean flag=true; | ||
| 4275 | + String qdz = yyLine.get(lineCode).get("startStationName"); | ||
| 4276 | + String zdz = yyLine.get(lineCode).get("endStationName"); | ||
| 4277 | + | ||
| 4278 | + if(s.getBcType().equals("region")){ | ||
| 4279 | + if(s.getXlDir().equals("0")){ | ||
| 4280 | + if(!s.getQdzName().equals(qdz)) | ||
| 4281 | + flag=false; | ||
| 4282 | + }else{ | ||
| 4283 | + if(!s.getQdzName().equals(zdz)) | ||
| 4284 | + flag=false; | ||
| 4285 | + } | ||
| 4286 | + } | ||
| 4287 | + if(flag){ | ||
| 4288 | + if(!map_listjh0.containsKey(lineCode)){ | ||
| 4289 | + map_listjh0.put(lineCode, new ArrayList<ScheduleRealInfo>()); | ||
| 4290 | + } | ||
| 4291 | + if(!map_listjh1.containsKey(lineCode)){ | ||
| 4292 | + map_listjh1.put(lineCode, new ArrayList<ScheduleRealInfo>()); | ||
| 4293 | + } | ||
| 4294 | + if(!map_listsj0.containsKey(lineCode)){ | ||
| 4295 | + map_listsj0.put(lineCode, new ArrayList<ScheduleRealInfo>()); | ||
| 4296 | + } | ||
| 4297 | + if(!map_listsj1.containsKey(lineCode)){ | ||
| 4298 | + map_listsj1.put(lineCode, new ArrayList<ScheduleRealInfo>()); | ||
| 4299 | + } | ||
| 4300 | + List<ScheduleRealInfo> listjh0 = map_listjh0.get(lineCode); | ||
| 4301 | + List<ScheduleRealInfo> listjh1 = map_listjh1.get(lineCode); | ||
| 4302 | + List<ScheduleRealInfo> listsj0 = map_listsj0.get(lineCode); | ||
| 4303 | + List<ScheduleRealInfo> listsj1 = map_listsj1.get(lineCode); | ||
| 4304 | + | ||
| 4305 | + if (s.isSflj()) { | ||
| 4306 | + if (s.getXlDir().equals("0")) { | ||
| 4307 | + listsj0.add(s); | ||
| 4308 | + } else { | ||
| 4309 | + listsj1.add(s); | ||
| 4310 | + } | ||
| 4311 | + } else { | ||
| 4312 | + if (s.getXlDir().equals("0")) { | ||
| 4313 | + listsj0.add(s); | ||
| 4314 | + listjh0.add(s); | ||
| 4315 | + } else { | ||
| 4316 | + listsj1.add(s); | ||
| 4317 | + listjh1.add(s); | ||
| 4318 | + } | ||
| 4319 | + } | ||
| 4320 | + } | ||
| 4321 | + } | ||
| 4322 | + } | ||
| 4323 | + | ||
| 4324 | + //首末班发车准点率 | ||
| 4325 | + for(String lineCode : yyLine.keySet()){ | ||
| 4326 | + List<ScheduleRealInfo> listjh0 = sm_listjh0.get(lineCode)!=null?sm_listjh0.get(lineCode):new ArrayList<ScheduleRealInfo>(); | ||
| 4327 | + List<ScheduleRealInfo> listjh1 = sm_listjh1.get(lineCode)!=null?sm_listjh1.get(lineCode):new ArrayList<ScheduleRealInfo>(); | ||
| 4328 | + List<ScheduleRealInfo> listsj0 = sm_listsj0.get(lineCode)!=null?sm_listsj0.get(lineCode):new ArrayList<ScheduleRealInfo>(); | ||
| 4329 | + List<ScheduleRealInfo> listsj1 = sm_listsj1.get(lineCode)!=null?sm_listsj1.get(lineCode):new ArrayList<ScheduleRealInfo>(); | ||
| 4330 | + Collections.sort(listjh0, new ComparableJhfc()); | ||
| 4331 | + Collections.sort(listjh1, new ComparableJhfc()); | ||
| 4332 | + Collections.sort(listsj0, new ComparableAcual()); | ||
| 4333 | + Collections.sort(listsj1, new ComparableAcual()); | ||
| 4334 | + | ||
| 4335 | + //上行 | ||
| 4336 | + if(listjh0.size() > 0){ | ||
| 4337 | + ScheduleRealInfo jhsb = listjh0.get(0); //计划首班 | ||
| 4338 | + for(int f = 0; f < listjh0.size(); f++){ | ||
| 4339 | + jhsb = listjh0.get(f); //计划首班 | ||
| 4340 | + String bcType = jhsb.getBcType(); | ||
| 4341 | + List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhsb.getSpId()); | ||
| 4342 | + if(oList.size() > 0 && oList.get(0) != null | ||
| 4343 | + && oList.get(0).trim().length() > 0){ | ||
| 4344 | + bcType = oList.get(0).trim(); | ||
| 4345 | + } | ||
| 4346 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 4347 | + || bcType.equals("major") || isInOut(jhsb)){ | ||
| 4348 | + continue; | ||
| 4349 | + } | ||
| 4350 | + break; | ||
| 4351 | + } | ||
| 4352 | + if(jhsb.getFcsjT() < newDatetime){ | ||
| 4353 | + boolean flag = true; | ||
| 4354 | + for(int i = 0; i < listsj0.size(); i++){ | ||
| 4355 | + ScheduleRealInfo sjsb = listsj0.get(i); //实际首班 | ||
| 4356 | + String bcType = sjsb.getBcType(); | ||
| 4357 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 4358 | + || bcType.equals("major") || isInOut(sjsb)){ | ||
| 4359 | + continue; | ||
| 4360 | + } | ||
| 4361 | + long wd = sjsb.getFcsjActualTime() - jhsb.getFcsjT(); //误点,快1慢2 | ||
| 4362 | + if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | ||
| 4363 | + flag = false; | ||
| 4364 | + break; | ||
| 4365 | + } | ||
| 4366 | + } | ||
| 4367 | + if(flag){ | ||
| 4368 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 4369 | + m.put("date", jhsb.getScheduleDateStr()); | ||
| 4370 | + m.put("companyCode", jhsb.getGsBm()); | ||
| 4371 | + m.put("companyName", jhsb.getGsName()); | ||
| 4372 | + m.put("brancheCompanyCode", jhsb.getFgsBm()); | ||
| 4373 | + m.put("brancheCompanyName", jhsb.getFgsName()); | ||
| 4374 | + m.put("lineCode", jhsb.getXlBm()); | ||
| 4375 | + m.put("lineName", jhsb.getXlName()); | ||
| 4376 | + m.put("car", jhsb.getClZbh()); | ||
| 4377 | + m.put("driverCode", jhsb.getjGh()); | ||
| 4378 | + m.put("driverName", jhsb.getjName()); | ||
| 4379 | + m.put("startTime", jhsb.getFcsj()); | ||
| 4380 | + m.put("startTimeReal", jhsb.getZdsjActual()!=null?jhsb.getZdsjActual():""); | ||
| 4381 | + m.put("startStationName", jhsb.getQdzName()); | ||
| 4382 | + m.put("remark", jhsb.getRemarks()!=null?jhsb.getRemarks():""); | ||
| 4383 | + m.put("type", "首末班发车准点率"); | ||
| 4384 | + smList.add(m); | ||
| 4385 | + } | ||
| 4386 | + } | ||
| 4387 | + | ||
| 4388 | + if(listjh0.size() > 1){ | ||
| 4389 | + ScheduleRealInfo jhmb = listjh0.get(listjh0.size() - 1); //计划末班 | ||
| 4390 | + for(int l = listjh0.size() - 1; l >= 0; l--){ | ||
| 4391 | + jhmb = listjh0.get(l); //计划末班 | ||
| 4392 | + String bcType = jhmb.getBcType(); | ||
| 4393 | + List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhmb.getSpId()); | ||
| 4394 | + if(oList.size() > 0 && oList.get(0) != null | ||
| 4395 | + && oList.get(0).trim().length() > 0){ | ||
| 4396 | + bcType = oList.get(0).trim(); | ||
| 4397 | + } | ||
| 4398 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 4399 | + || bcType.equals("major") || isInOut(jhmb)){ | ||
| 4400 | + continue; | ||
| 4401 | + } | ||
| 4402 | + break; | ||
| 4403 | + } | ||
| 4404 | + if(jhmb.getFcsjT() < newDatetime){ | ||
| 4405 | + boolean flag = true; | ||
| 4406 | + for(int i = listsj0.size() - 1; i >= 0; i--){ | ||
| 4407 | + ScheduleRealInfo sjmb = listsj0.get(i); //实际末班 | ||
| 4408 | + String bcType = sjmb.getBcType(); | ||
| 4409 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 4410 | + || bcType.equals("major") || isInOut(sjmb)){ | ||
| 4411 | + continue; | ||
| 4412 | + } | ||
| 4413 | + long wd = sjmb.getFcsjActualTime() - jhmb.getFcsjT(); //误点,快1慢2 | ||
| 4414 | + if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | ||
| 4415 | + flag = false; | ||
| 4416 | + break; | ||
| 4417 | + } | ||
| 4418 | + } | ||
| 4419 | + if(flag){ | ||
| 4420 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 4421 | + m.put("date", jhmb.getScheduleDateStr()); | ||
| 4422 | + m.put("companyCode", jhmb.getGsBm()); | ||
| 4423 | + m.put("companyName", jhmb.getGsName()); | ||
| 4424 | + m.put("brancheCompanyCode", jhmb.getFgsBm()); | ||
| 4425 | + m.put("brancheCompanyName", jhmb.getFgsName()); | ||
| 4426 | + m.put("lineCode", jhmb.getXlBm()); | ||
| 4427 | + m.put("lineName", jhmb.getXlName()); | ||
| 4428 | + m.put("car", jhmb.getClZbh()); | ||
| 4429 | + m.put("driverCode", jhmb.getjGh()); | ||
| 4430 | + m.put("driverName", jhmb.getjName()); | ||
| 4431 | + m.put("startTime", jhmb.getFcsj()); | ||
| 4432 | + m.put("startTimeReal", jhmb.getZdsjActual()!=null?jhmb.getZdsjActual():""); | ||
| 4433 | + m.put("startStationName", jhmb.getQdzName()); | ||
| 4434 | + m.put("remark", jhmb.getRemarks()!=null?jhmb.getRemarks():""); | ||
| 4435 | + m.put("type", "首末班发车准点率"); | ||
| 4436 | + smList.add(m); | ||
| 4437 | + } | ||
| 4438 | + } | ||
| 4439 | + } | ||
| 4440 | + } | ||
| 4441 | + | ||
| 4442 | + //下行 | ||
| 4443 | + if(listjh1.size() > 0){ | ||
| 4444 | + ScheduleRealInfo jhsb = listjh1.get(0); //计划首班 | ||
| 4445 | + for(int f = 0; f < listjh1.size(); f++){ | ||
| 4446 | + jhsb = listjh1.get(f); //计划首班 | ||
| 4447 | + String bcType = jhsb.getBcType(); | ||
| 4448 | + List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhsb.getSpId()); | ||
| 4449 | + if(oList.size() > 0 && oList.get(0) != null | ||
| 4450 | + && oList.get(0).trim().length() > 0){ | ||
| 4451 | + bcType = oList.get(0).trim(); | ||
| 4452 | + } | ||
| 4453 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 4454 | + || bcType.equals("major") || isInOut(jhsb)){ | ||
| 4455 | + continue; | ||
| 4456 | + } | ||
| 4457 | + break; | ||
| 4458 | + } | ||
| 4459 | + if(jhsb.getFcsjT() < newDatetime){ | ||
| 4460 | + boolean flag = true; | ||
| 4461 | + for(int i = 0; i < listsj1.size(); i++){ | ||
| 4462 | + ScheduleRealInfo sjsb = listsj1.get(i); //实际首班 | ||
| 4463 | + String bcType = sjsb.getBcType(); | ||
| 4464 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 4465 | + || bcType.equals("major") || isInOut(sjsb)){ | ||
| 4466 | + continue; | ||
| 4467 | + } | ||
| 4468 | + long wd = sjsb.getFcsjActualTime() - jhsb.getFcsjT(); //误点,快1慢2 | ||
| 4469 | + if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | ||
| 4470 | + flag = false; | ||
| 4471 | + break; | ||
| 4472 | + } | ||
| 4473 | + } | ||
| 4474 | + if(flag){ | ||
| 4475 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 4476 | + m.put("date", jhsb.getScheduleDateStr()); | ||
| 4477 | + m.put("companyCode", jhsb.getGsBm()); | ||
| 4478 | + m.put("companyName", jhsb.getGsName()); | ||
| 4479 | + m.put("brancheCompanyCode", jhsb.getFgsBm()); | ||
| 4480 | + m.put("brancheCompanyName", jhsb.getFgsName()); | ||
| 4481 | + m.put("lineCode", jhsb.getXlBm()); | ||
| 4482 | + m.put("lineName", jhsb.getXlName()); | ||
| 4483 | + m.put("car", jhsb.getClZbh()); | ||
| 4484 | + m.put("driverCode", jhsb.getjGh()); | ||
| 4485 | + m.put("driverName", jhsb.getjName()); | ||
| 4486 | + m.put("startTime", jhsb.getFcsj()); | ||
| 4487 | + m.put("startTimeReal", jhsb.getZdsjActual()!=null?jhsb.getZdsjActual():""); | ||
| 4488 | + m.put("startStationName", jhsb.getQdzName()); | ||
| 4489 | + m.put("remark", jhsb.getRemarks()!=null?jhsb.getRemarks():""); | ||
| 4490 | + m.put("type", "首末班发车准点率"); | ||
| 4491 | + smList.add(m); | ||
| 4492 | + } | ||
| 4493 | + } | ||
| 4494 | + | ||
| 4495 | + if(listjh1.size() > 1){ | ||
| 4496 | + ScheduleRealInfo jhmb = listjh1.get(listjh1.size() - 1); //计划末班 | ||
| 4497 | + for(int l = listjh1.size() - 1; l >= 0; l--){ | ||
| 4498 | + jhmb = listjh1.get(l); //计划末班 | ||
| 4499 | + String bcType = jhmb.getBcType(); | ||
| 4500 | + List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhmb.getSpId()); | ||
| 4501 | + if(oList.size() > 0 && oList.get(0) != null | ||
| 4502 | + && oList.get(0).trim().length() > 0){ | ||
| 4503 | + bcType = oList.get(0).trim(); | ||
| 4504 | + } | ||
| 4505 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 4506 | + || bcType.equals("major") || isInOut(jhmb)){ | ||
| 4507 | + continue; | ||
| 4508 | + } | ||
| 4509 | + break; | ||
| 4510 | + } | ||
| 4511 | + if(jhmb.getFcsjT() < newDatetime){ | ||
| 4512 | + boolean flag = true; | ||
| 4513 | + for(int i = listsj1.size() - 1; i >= 0; i--){ | ||
| 4514 | + ScheduleRealInfo sjmb = listsj1.get(i); //实际末班 | ||
| 4515 | + String bcType = sjmb.getBcType(); | ||
| 4516 | + if(bcType.equals("region") || bcType.equals("venting") | ||
| 4517 | + || bcType.equals("major") || isInOut(sjmb)){ | ||
| 4518 | + continue; | ||
| 4519 | + } | ||
| 4520 | + long wd = sjmb.getFcsjActualTime() - jhmb.getFcsjT(); //误点,快1慢2 | ||
| 4521 | + if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | ||
| 4522 | + flag = false; | ||
| 4523 | + break; | ||
| 4524 | + } | ||
| 4525 | + } | ||
| 4526 | + if(flag){ | ||
| 4527 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 4528 | + m.put("date", jhmb.getScheduleDateStr()); | ||
| 4529 | + m.put("companyCode", jhmb.getGsBm()); | ||
| 4530 | + m.put("companyName", jhmb.getGsName()); | ||
| 4531 | + m.put("brancheCompanyCode", jhmb.getFgsBm()); | ||
| 4532 | + m.put("brancheCompanyName", jhmb.getFgsName()); | ||
| 4533 | + m.put("lineCode", jhmb.getXlBm()); | ||
| 4534 | + m.put("lineName", jhmb.getXlName()); | ||
| 4535 | + m.put("car", jhmb.getClZbh()); | ||
| 4536 | + m.put("driverCode", jhmb.getjGh()); | ||
| 4537 | + m.put("driverName", jhmb.getjName()); | ||
| 4538 | + m.put("startTime", jhmb.getFcsj()); | ||
| 4539 | + m.put("startTimeReal", jhmb.getZdsjActual()!=null?jhmb.getZdsjActual():""); | ||
| 4540 | + m.put("startStationName", jhmb.getQdzName()); | ||
| 4541 | + m.put("remark", jhmb.getRemarks()!=null?jhmb.getRemarks():""); | ||
| 4542 | + m.put("type", "首末班发车准点率"); | ||
| 4543 | + smList.add(m); | ||
| 4544 | + } | ||
| 4545 | + } | ||
| 4546 | + } | ||
| 4547 | + } | ||
| 4548 | + } | ||
| 4549 | + | ||
| 4550 | + //起讫站发车准点率,挂牌线路发车准点率 | ||
| 4551 | + for(String lineCode : yyLine.keySet()){ | ||
| 4552 | + List<ScheduleRealInfo> listjh0 = map_listjh0.get(lineCode)!=null?map_listjh0.get(lineCode):new ArrayList<ScheduleRealInfo>(); | ||
| 4553 | + List<ScheduleRealInfo> listjh1 = map_listjh1.get(lineCode)!=null?map_listjh1.get(lineCode):new ArrayList<ScheduleRealInfo>(); | ||
| 4554 | + List<ScheduleRealInfo> listsj0 = map_listsj0.get(lineCode)!=null?map_listsj0.get(lineCode):new ArrayList<ScheduleRealInfo>(); | ||
| 4555 | + List<ScheduleRealInfo> listsj1 = map_listsj1.get(lineCode)!=null?map_listsj1.get(lineCode):new ArrayList<ScheduleRealInfo>(); | ||
| 4556 | + Collections.sort(listjh0, new ComparableJhfc()); | ||
| 4557 | + Collections.sort(listjh1, new ComparableJhfc()); | ||
| 4558 | + Collections.sort(listsj0, new ComparableAcual()); | ||
| 4559 | + Collections.sort(listsj1, new ComparableAcual()); | ||
| 4560 | + for (int k = 0; k < listjh0.size(); k++) { | ||
| 4561 | + ScheduleRealInfo sJh = listjh0.get(k); | ||
| 4562 | + boolean flag = true; | ||
| 4563 | + if(!StringUtils.isEmpty(sJh.getFcsjActual())){ | ||
| 4564 | + long sjc = sJh.getFcsjActualTime() - sJh.getFcsjT(); | ||
| 4565 | + if (sjc >= -1l * 60 * 1000 && sjc <= 3l * 60 * 1000) { | ||
| 4566 | + flag = false; | ||
| 4567 | + continue; | ||
| 4568 | + } | ||
| 4569 | + } | ||
| 4570 | + for(ScheduleRealInfo sSj : listsj0){ | ||
| 4571 | + if(!StringUtils.isEmpty(sSj.getFcsjActual())){ | ||
| 4572 | + long sjc = sSj.getFcsjActualTime() - sJh.getFcsjT(); | ||
| 4573 | + if (sjc >= -1l * 60 * 1000 && sjc <= 3l * 60 * 1000) { | ||
| 4574 | + flag = false; | ||
| 4575 | + break; | ||
| 4576 | + } | ||
| 4577 | + } | ||
| 4578 | + } | ||
| 4579 | + if(flag){ | ||
| 4580 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 4581 | + m.put("date", sJh.getScheduleDateStr()); | ||
| 4582 | + m.put("companyCode", sJh.getGsBm()); | ||
| 4583 | + m.put("companyName", sJh.getGsName()); | ||
| 4584 | + m.put("brancheCompanyCode", sJh.getFgsBm()); | ||
| 4585 | + m.put("brancheCompanyName", sJh.getFgsName()); | ||
| 4586 | + m.put("lineCode", sJh.getXlBm()); | ||
| 4587 | + m.put("lineName", sJh.getXlName()); | ||
| 4588 | + m.put("car", sJh.getClZbh()); | ||
| 4589 | + m.put("driverCode", sJh.getjGh()); | ||
| 4590 | + m.put("driverName", sJh.getjName()); | ||
| 4591 | + m.put("startTime", sJh.getFcsj()); | ||
| 4592 | + m.put("startTimeReal", sJh.getFcsjActual()!=null?sJh.getFcsjActual():""); | ||
| 4593 | + m.put("startStationName", sJh.getQdzName()); | ||
| 4594 | + m.put("remark", sJh.getRemarks()!=null?sJh.getRemarks():""); | ||
| 4595 | + m.put("type", "起讫站发车准点率"); | ||
| 4596 | +// m.put("ft", sJh.getFcsjT()); | ||
| 4597 | +// m.put("fat", sJh.getFcsjActualTime()); | ||
| 4598 | +// m.put("sjc", sJh.getFcsjActualTime() - sJh.getFcsjT()); | ||
| 4599 | +// m.put("xx", (-1 * 60 * 1000) + " <> " + (3 * 60 * 1000)); | ||
| 4600 | +// long sjc = sJh.getFcsjActualTime() - sJh.getFcsjT(); | ||
| 4601 | +// m.put("flag1", sjc >= -1 * 60 * 1000); | ||
| 4602 | +// m.put("flag2", sjc <= 3 * 60 * 1000); | ||
| 4603 | +// m.put("flag3", sjc >= -1 * 60 * 1000 && sjc <= 3 * 60 * 1000); | ||
| 4604 | + qqzList.add(m); | ||
| 4605 | + if(gpSet.contains(lineCode)){ | ||
| 4606 | + Map<String, Object> gp = new HashMap<String, Object>(); | ||
| 4607 | + for(String key : m.keySet()){ | ||
| 4608 | + gp.put(key, m.get(key)); | ||
| 4609 | + } | ||
| 4610 | + gp.put("type", "挂牌线路发车准点率"); | ||
| 4611 | + gpqqzList.add(gp); | ||
| 4612 | + } | ||
| 4613 | + } | ||
| 4614 | + } | ||
| 4615 | + for (int k = 0; k < listjh1.size(); k++) { | ||
| 4616 | + ScheduleRealInfo sJh = listjh1.get(k); | ||
| 4617 | + boolean flag = true; | ||
| 4618 | + if(!StringUtils.isEmpty(sJh.getFcsjActual())){ | ||
| 4619 | + long sjc = sJh.getFcsjActualTime() - sJh.getFcsjT(); | ||
| 4620 | + if (sjc >= -1l * 60 * 1000 && sjc <= 3l * 60 * 1000) { | ||
| 4621 | + flag = false; | ||
| 4622 | + continue; | ||
| 4623 | + } | ||
| 4624 | + } | ||
| 4625 | + for(ScheduleRealInfo sSj : listsj1){ | ||
| 4626 | + if(!StringUtils.isEmpty(sSj.getFcsjActual())){ | ||
| 4627 | + long sjc = sSj.getFcsjActualTime() - sJh.getFcsjT(); | ||
| 4628 | + if (sjc >= -1l * 60 * 1000 && sjc <= 3l * 60 * 1000) { | ||
| 4629 | + flag = false; | ||
| 4630 | + break; | ||
| 4631 | + } | ||
| 4632 | + } | ||
| 4633 | + } | ||
| 4634 | + if(flag){ | ||
| 4635 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 4636 | + m.put("date", sJh.getScheduleDateStr()); | ||
| 4637 | + m.put("companyCode", sJh.getGsBm()); | ||
| 4638 | + m.put("companyName", sJh.getGsName()); | ||
| 4639 | + m.put("brancheCompanyCode", sJh.getFgsBm()); | ||
| 4640 | + m.put("brancheCompanyName", sJh.getFgsName()); | ||
| 4641 | + m.put("lineCode", sJh.getXlBm()); | ||
| 4642 | + m.put("lineName", sJh.getXlName()); | ||
| 4643 | + m.put("car", sJh.getClZbh()); | ||
| 4644 | + m.put("driverCode", sJh.getjGh()); | ||
| 4645 | + m.put("driverName", sJh.getjName()); | ||
| 4646 | + m.put("startTime", sJh.getFcsj()); | ||
| 4647 | + m.put("startTimeReal", sJh.getFcsjActual()!=null?sJh.getFcsjActual():""); | ||
| 4648 | + m.put("startStationName", sJh.getQdzName()); | ||
| 4649 | + m.put("remark", sJh.getRemarks()!=null?sJh.getRemarks():""); | ||
| 4650 | + m.put("type", "起讫站发车准点率"); | ||
| 4651 | + qqzList.add(m); | ||
| 4652 | + if(gpSet.contains(lineCode)){ | ||
| 4653 | + Map<String, Object> gp = new HashMap<String, Object>(); | ||
| 4654 | + for(String key : m.keySet()){ | ||
| 4655 | + gp.put(key, m.get(key)); | ||
| 4656 | + } | ||
| 4657 | + gp.put("type", "挂牌线路发车准点率"); | ||
| 4658 | + gpqqzList.add(gp); | ||
| 4659 | + } | ||
| 4660 | + } | ||
| 4661 | + } | ||
| 4662 | + } | ||
| 4663 | + | ||
| 4664 | + for(String key : jhccMap.keySet()){ | ||
| 4665 | + if(!sjccSet.contains(key)){ | ||
| 4666 | + resList.add(jhccMap.get(key)); | ||
| 4667 | + } | ||
| 4668 | + } | ||
| 4669 | + resList.addAll(bcList); | ||
| 4670 | + resList.addAll(smList); | ||
| 4671 | + resList.addAll(qqzList); | ||
| 4672 | + resList.addAll(gpqqzList); | ||
| 4673 | + | ||
| 4674 | + return resList; | ||
| 4675 | + } | ||
| 3602 | 4676 | ||
| 3603 | public List<Map<String, Object>> createMap(String type, String[] dates){ | 4677 | public List<Map<String, Object>> createMap(String type, String[] dates){ |
| 3604 | List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); | 4678 | List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); |
| @@ -3878,5 +4952,28 @@ public class BigscreenService { | @@ -3878,5 +4952,28 @@ public class BigscreenService { | ||
| 3878 | } | 4952 | } |
| 3879 | return str; | 4953 | return str; |
| 3880 | } | 4954 | } |
| 4955 | + | ||
| 4956 | + private Long minFcsjs(String lineCode){ | ||
| 4957 | + String minfcsj="02:00"; | ||
| 4958 | + String sqlMinYysj="select start_opt from bsth_c_line_config where " | ||
| 4959 | + + " id = (" | ||
| 4960 | + + "select max(id) from bsth_c_line_config where line = ? " | ||
| 4961 | + + ")"; | ||
| 4962 | + List<String> list= jdbcTemplate.query(sqlMinYysj, new Object[]{lineCode}, | ||
| 4963 | + new RowMapper<String>(){ | ||
| 4964 | + @Override | ||
| 4965 | + public String mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 4966 | + String startopt=rs.getString("start_opt"); | ||
| 4967 | + return startopt; | ||
| 4968 | + } | ||
| 4969 | + }); | ||
| 4970 | + if(list.size()>0){ | ||
| 4971 | + minfcsj=list.get(0); | ||
| 4972 | + } | ||
| 4973 | + String[] minSjs = minfcsj.split(":"); | ||
| 4974 | + //车辆最早发车时间 用了过滤超第二天0点的数据 | ||
| 4975 | + Long minSj=Long.parseLong(minSjs[0])*60+Long.parseLong(minSjs[1]); | ||
| 4976 | + return minSj; | ||
| 4977 | + } | ||
| 3881 | 4978 | ||
| 3882 | } | 4979 | } |