Commit e802a702780abf8e90bce013f8abc57b3a0d6bda
1 parent
d4bea770
按日期查线路班次执行率接口
Showing
2 changed files
with
214 additions
and
7 deletions
src/main/java/com/bsth/server_rs/bigdata/BigdataService.java
| @@ -7,6 +7,8 @@ import java.text.ParseException; | @@ -7,6 +7,8 @@ import java.text.ParseException; | ||
| 7 | import java.text.SimpleDateFormat; | 7 | import java.text.SimpleDateFormat; |
| 8 | import java.util.ArrayList; | 8 | import java.util.ArrayList; |
| 9 | import java.util.Calendar; | 9 | import java.util.Calendar; |
| 10 | +import java.util.Collections; | ||
| 11 | +import java.util.Comparator; | ||
| 10 | import java.util.Date; | 12 | import java.util.Date; |
| 11 | import java.util.HashMap; | 13 | import java.util.HashMap; |
| 12 | import java.util.HashSet; | 14 | import java.util.HashSet; |
| @@ -1314,11 +1316,13 @@ public class BigdataService { | @@ -1314,11 +1316,13 @@ public class BigdataService { | ||
| 1314 | @PathParam("endDate") String endDate) throws ParseException { | 1316 | @PathParam("endDate") String endDate) throws ParseException { |
| 1315 | String sql="select gs_bm,fgs_bm,real_exec_date,fcsj,fcsj_actual,xl_name,j_gh,j_name,cl_zbh,car_plate,remarks " | 1317 | String sql="select gs_bm,fgs_bm,real_exec_date,fcsj,fcsj_actual,xl_name,j_gh,j_name,cl_zbh,car_plate,remarks " |
| 1316 | + " from bsth_c_s_sp_info_real r left join bsth_c_cars c on r.cl_zbh = c.inside_code " | 1318 | + " from bsth_c_s_sp_info_real r left join bsth_c_cars c on r.cl_zbh = c.inside_code " |
| 1317 | - + " where schedule_date_str>='"+startDate+"' and schedule_date_str<= '"+endDate+"' " | ||
| 1318 | - + " and adjust_exps like '%肇事%' and status = '-1' " | 1319 | + + " where schedule_date_str >= ? and schedule_date_str <= ? " |
| 1320 | + + " and ((adjust_exps like '%肇事%' and status = '-1') " | ||
| 1321 | + + " or remarks = '肇事' or remarks like '%;肇事%' or remarks like '%肇事;%') " | ||
| 1319 | + " order by real_exec_date, schedule_date_str, fcsj"; | 1322 | + " order by real_exec_date, schedule_date_str, fcsj"; |
| 1320 | 1323 | ||
| 1321 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | 1324 | + List<Map<String, Object>> list=(List<Map<String, Object>>) jdbcTemplate.query(sql, |
| 1325 | + new Object[] {startDate, endDate}, | ||
| 1322 | new RowMapper<Map<String, Object>>(){ | 1326 | new RowMapper<Map<String, Object>>(){ |
| 1323 | @Override | 1327 | @Override |
| 1324 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | 1328 | public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { |
| @@ -1360,9 +1364,30 @@ public class BigdataService { | @@ -1360,9 +1364,30 @@ public class BigdataService { | ||
| 1360 | m.put("remarks", (s==null?"":(s.getQdzName()+"->"+s.getZdzName()+";"))+ds.getRemark()); | 1364 | m.put("remarks", (s==null?"":(s.getQdzName()+"->"+s.getZdzName()+";"))+ds.getRemark()); |
| 1361 | list.add(m); | 1365 | list.add(m); |
| 1362 | } | 1366 | } |
| 1367 | + | ||
| 1363 | d1.setTime(d1.getTime() + 1l*1000*60*60*24); | 1368 | d1.setTime(d1.getTime() + 1l*1000*60*60*24); |
| 1364 | } | 1369 | } |
| 1365 | 1370 | ||
| 1371 | + Collections.sort(list, new Comparator<Map<String, Object>>() { | ||
| 1372 | + @Override | ||
| 1373 | + public int compare(Map<String, Object> c1, Map<String, Object> c2) { | ||
| 1374 | +// int i1 = Integer.valueOf(c1.get("count").toString()); | ||
| 1375 | +// int i2 = Integer.valueOf(c2.get("count").toString()); | ||
| 1376 | + String str1 = c1.get("real_exec_date").toString() + (c1.get("fcsj").toString().length()>0?c1.get("fcsj").toString():"00:00"); | ||
| 1377 | + String str2 = c2.get("real_exec_date").toString() + (c2.get("fcsj").toString().length()>0?c2.get("fcsj").toString():"00:00"); | ||
| 1378 | + Long long1 = Long.valueOf(str1.replaceAll(" ", "").replaceAll("-", "").replaceAll(":", "")); | ||
| 1379 | + Long long2 = Long.valueOf(str2.replaceAll(" ", "").replaceAll("-", "").replaceAll(":", "")); | ||
| 1380 | + | ||
| 1381 | + long diff = long1 - long2; | ||
| 1382 | + if (diff > 0) { | ||
| 1383 | + return 1; | ||
| 1384 | + }else if (diff < 0) { | ||
| 1385 | + return -1; | ||
| 1386 | + } | ||
| 1387 | + return 0; //相等为0 | ||
| 1388 | + } | ||
| 1389 | + }); | ||
| 1390 | + | ||
| 1366 | return list; | 1391 | return list; |
| 1367 | } | 1392 | } |
| 1368 | 1393 | ||
| @@ -1406,8 +1431,10 @@ public class BigdataService { | @@ -1406,8 +1431,10 @@ public class BigdataService { | ||
| 1406 | if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | 1431 | if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 |
| 1407 | String dateStr = s.getScheduleDateStr(); | 1432 | String dateStr = s.getScheduleDateStr(); |
| 1408 | String gsBm = s.getGsBm(); | 1433 | String gsBm = s.getGsBm(); |
| 1434 | + String fgsBm = s.getFgsBm(); | ||
| 1435 | + String xlName = s.getXlName(); | ||
| 1409 | String cl = s.getClZbh(); | 1436 | String cl = s.getClZbh(); |
| 1410 | - String key = dateStr + "/" + gsBm + "/" + cl; | 1437 | + String key = dateStr + "/" + gsBm + "/" + fgsBm + "/" + xlName + "/" + cl; |
| 1411 | if(!(keyMap.containsKey(key))){ | 1438 | if(!(keyMap.containsKey(key))){ |
| 1412 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | 1439 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); |
| 1413 | keyList.add(key); | 1440 | keyList.add(key); |
| @@ -1440,9 +1467,12 @@ public class BigdataService { | @@ -1440,9 +1467,12 @@ public class BigdataService { | ||
| 1440 | double zksgl = Arith.add(sjjccgl, sjksgl);//实际空驶总公里 | 1467 | double zksgl = Arith.add(sjjccgl, sjksgl);//实际空驶总公里 |
| 1441 | 1468 | ||
| 1442 | Map<String, Object> m = new HashMap<String, Object>(); | 1469 | Map<String, Object> m = new HashMap<String, Object>(); |
| 1443 | - m.put("date", key.split("/")[0]); | ||
| 1444 | - m.put("companyCode", key.split("/")[1]); | ||
| 1445 | - m.put("car", key.split("/")[2]); | 1470 | + String[] split = key.split("/"); |
| 1471 | + m.put("date", split[0]); | ||
| 1472 | + m.put("companyCode", split[1]); | ||
| 1473 | + m.put("brancheCompanyCode", split[2]); | ||
| 1474 | + m.put("lineName", split[3]); | ||
| 1475 | + m.put("car", split[4]); | ||
| 1446 | m.put("businessMileage", sjyygl); | 1476 | m.put("businessMileage", sjyygl); |
| 1447 | m.put("emptyMileage", zksgl); | 1477 | m.put("emptyMileage", zksgl); |
| 1448 | resList.add(m); | 1478 | resList.add(m); |
src/main/java/com/bsth/server_rs/bigdata/BigscreenService.java
| @@ -1032,6 +1032,183 @@ public class BigscreenService { | @@ -1032,6 +1032,183 @@ public class BigscreenService { | ||
| 1032 | return JSON.parseObject(JSON.toJSONString(resMap)); | 1032 | return JSON.parseObject(JSON.toJSONString(resMap)); |
| 1033 | } | 1033 | } |
| 1034 | 1034 | ||
| 1035 | + /**给大屏按日期查线路指标 | ||
| 1036 | + * | ||
| 1037 | + */ | ||
| 1038 | + @GET | ||
| 1039 | + @Path("/selectData/getScheduleStatistics/{date}") | ||
| 1040 | + public JSONObject getScheduleStatistics(@PathParam("date") String date){ | ||
| 1041 | + Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 1042 | + | ||
| 1043 | + String gpLineSql = "select * from bsth_c_line_plate"; | ||
| 1044 | + List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | ||
| 1045 | + new RowMapper<Map<String, Object>>(){ | ||
| 1046 | + @Override | ||
| 1047 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 1048 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 1049 | + m.put("lineName", rs.getString("line_name")); | ||
| 1050 | + m.put("lineCode", rs.getString("line_code")); | ||
| 1051 | + return m; | ||
| 1052 | + } | ||
| 1053 | + }); | ||
| 1054 | + | ||
| 1055 | + Set<String> gpSet = new HashSet<String>(); | ||
| 1056 | + for(Map<String, Object> t : gpLineList){ | ||
| 1057 | + if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | ||
| 1058 | + gpSet.add(t.get("lineCode").toString().trim()); | ||
| 1059 | + } | ||
| 1060 | + } | ||
| 1061 | + | ||
| 1062 | + String yyxlSql="SELECT line_code from bsth_c_line " | ||
| 1063 | + + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | ||
| 1064 | + List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | ||
| 1065 | + new RowMapper<Map<String, Object>>(){ | ||
| 1066 | + @Override | ||
| 1067 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 1068 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 1069 | + m.put("lineCode", rs.getString("line_code")); | ||
| 1070 | + return m; | ||
| 1071 | + } | ||
| 1072 | + }); | ||
| 1073 | + Set<String> yyLine = new HashSet<String>(); | ||
| 1074 | + for(Map<String, Object> t : yyxlList){ | ||
| 1075 | + if(t.get("lineCode") != null){ | ||
| 1076 | + yyLine.add(t.get("lineCode").toString()); | ||
| 1077 | + } | ||
| 1078 | + } | ||
| 1079 | + | ||
| 1080 | + String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | ||
| 1081 | + + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | ||
| 1082 | + + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | ||
| 1083 | + + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | ||
| 1084 | + + " jhszfcs,sjszfczds,szfczdl,create_date" | ||
| 1085 | + + " from bsth_c_calc_count " | ||
| 1086 | + + " where date = ? "; | ||
| 1087 | + | ||
| 1088 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, new Object[]{date}, | ||
| 1089 | + new RowMapper<Map<String, Object>>(){ | ||
| 1090 | + @Override | ||
| 1091 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 1092 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 1093 | + m.put("lineCode",rs.getString("xl")); | ||
| 1094 | + m.put("lineName", rs.getString("xl_name")); | ||
| 1095 | + m.put("date", rs.getString("date")); | ||
| 1096 | + | ||
| 1097 | + m.put("jhbc", rs.getString("jhbc")); | ||
| 1098 | + m.put("sjbc", rs.getString("sjbc")); | ||
| 1099 | + m.put("bczxl", rs.getString("bczxl")); | ||
| 1100 | + m.put("jhbcz", rs.getString("jhbcz")); | ||
| 1101 | + | ||
| 1102 | + m.put("jhcc", rs.getString("jhcc")); | ||
| 1103 | + m.put("sjcc", rs.getString("sjcc")); | ||
| 1104 | + m.put("ccl", rs.getString("ccl")); | ||
| 1105 | + m.put("jhccz", rs.getString("jhccz")); | ||
| 1106 | + | ||
| 1107 | + m.put("jhyylc", rs.getString("jhyylc")); | ||
| 1108 | + m.put("sjyylc", rs.getString("sjyylc")); | ||
| 1109 | + m.put("jhyylcz", rs.getString("jhyylcz")); | ||
| 1110 | + m.put("jhkslc", rs.getString("jhkslc")); | ||
| 1111 | + m.put("sjkslc", rs.getString("sjkslc")); | ||
| 1112 | + m.put("jhkslcz", rs.getString("jhkslcz")); | ||
| 1113 | + | ||
| 1114 | + m.put("jhgfbcs", rs.getString("jhssgfbcs")); | ||
| 1115 | + m.put("sjgfbcs", rs.getString("sjgfbcs")); | ||
| 1116 | + m.put("jhgfbcsz", rs.getString("jhgfbcsz")); | ||
| 1117 | + m.put("jhdgbcs", rs.getString("jhssdgbcs")); | ||
| 1118 | + m.put("sjdgbcs", rs.getString("sjdgbcs")); | ||
| 1119 | + m.put("jhdgbcsz", rs.getString("jhdgbcsz")); | ||
| 1120 | + | ||
| 1121 | + m.put("jhsmbcs", rs.getString("jhsmbcs")); | ||
| 1122 | + m.put("sjsmbczds", rs.getString("sjsmbczds")); | ||
| 1123 | + m.put("smbczdl", rs.getString("smbczdl")); | ||
| 1124 | + m.put("jhsmbcsz", rs.getString("jhsmbcsz")); | ||
| 1125 | + m.put("sjsmbczdsz", rs.getString("sjsmbczdsz")); | ||
| 1126 | + m.put("smbczdlz", rs.getString("smbczdlz")); | ||
| 1127 | + | ||
| 1128 | + m.put("jhszfcs", rs.getString("jhszfcs")); | ||
| 1129 | + m.put("sjszfczds", rs.getString("sjszfczds")); | ||
| 1130 | + m.put("szfczdl", rs.getString("szfczdl")); | ||
| 1131 | + | ||
| 1132 | + Date date = new Date(); | ||
| 1133 | + date.setTime(rs.getTimestamp("create_date").getTime()); | ||
| 1134 | + m.put("createDate", sdf.format(date)); | ||
| 1135 | + return m; | ||
| 1136 | + } | ||
| 1137 | + }); | ||
| 1138 | + | ||
| 1139 | + List<Map<String, Object>> bcDetail = new ArrayList<Map<String,Object>>(); | ||
| 1140 | + List<Map<String, Object>> qqDetail = new ArrayList<Map<String,Object>>(); | ||
| 1141 | + List<Map<String, Object>> gpDetail = new ArrayList<Map<String,Object>>(); | ||
| 1142 | + | ||
| 1143 | + long sjbcs_z = 0l;//实时总班次 | ||
| 1144 | + BigDecimal yygl_z = new BigDecimal(0);//实时总营运里程 | ||
| 1145 | + long jhcc = 0, sjcc = 0, jhbc = 0, sjbc = 0, jhsmbc = 0, sjsmbc = 0, | ||
| 1146 | + jhqqbc = 0, sjqqzd = 0, jhgpqqbc = 0, sjgpqqzd = 0; | ||
| 1147 | + | ||
| 1148 | + for(Map<String, Object> t : list){ | ||
| 1149 | + if(yyLine.contains(t.get("lineCode").toString())){ | ||
| 1150 | + sjbcs_z += Long.valueOf(t.get("sjbc").toString()); | ||
| 1151 | + yygl_z = yygl_z.add(new BigDecimal(t.get("sjyylc").toString())); | ||
| 1152 | + | ||
| 1153 | + jhcc += Long.valueOf(t.get("jhccz").toString()); | ||
| 1154 | + sjcc += Long.valueOf(t.get("sjcc").toString()); | ||
| 1155 | + jhbc += Long.valueOf(t.get("jhbc").toString()); | ||
| 1156 | + sjbc += Long.valueOf(t.get("sjbc").toString()); | ||
| 1157 | + jhsmbc += Long.valueOf(t.get("jhsmbcs").toString()); | ||
| 1158 | + sjsmbc += Long.valueOf(t.get("sjsmbczds").toString()); | ||
| 1159 | + jhqqbc += Long.valueOf(t.get("jhszfcs").toString()); | ||
| 1160 | + sjqqzd += Long.valueOf(t.get("sjszfczds").toString()); | ||
| 1161 | + if(gpSet.contains(t.get("lineCode").toString())){ | ||
| 1162 | + jhgpqqbc += Long.valueOf(t.get("jhszfcs").toString()); | ||
| 1163 | + sjgpqqzd += Long.valueOf(t.get("sjszfczds").toString()); | ||
| 1164 | + } | ||
| 1165 | + | ||
| 1166 | + Map<String, Object> bc = new HashMap<String, Object>(); | ||
| 1167 | + bc.put("type", "班次执行详情"); | ||
| 1168 | + bc.put("lineName", t.get("lineName").toString()); | ||
| 1169 | + bc.put("jh", t.get("jhbc").toString()); | ||
| 1170 | + bc.put("sj", t.get("sjbc").toString()); | ||
| 1171 | + bcDetail.add(bc); | ||
| 1172 | + | ||
| 1173 | + Map<String, Object> qq = new HashMap<String, Object>(); | ||
| 1174 | + qq.put("type", "起讫站发车准点详情"); | ||
| 1175 | + qq.put("lineName", t.get("lineName").toString()); | ||
| 1176 | + qq.put("jh", t.get("jhszfcs").toString()); | ||
| 1177 | + qq.put("sj", t.get("sjszfczds").toString()); | ||
| 1178 | + qqDetail.add(qq); | ||
| 1179 | + | ||
| 1180 | + if(gpSet.contains(t.get("lineCode").toString())){ | ||
| 1181 | + Map<String, Object> gp = new HashMap<String, Object>(); | ||
| 1182 | + gp.put("type", "挂牌线路发车准点详情"); | ||
| 1183 | + gp.put("lineName", t.get("lineName").toString()); | ||
| 1184 | + gp.put("jh", t.get("jhszfcs").toString()); | ||
| 1185 | + gp.put("sj", t.get("sjszfczds").toString()); | ||
| 1186 | + gpDetail.add(gp); | ||
| 1187 | + } | ||
| 1188 | + } | ||
| 1189 | + } | ||
| 1190 | + | ||
| 1191 | + List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | ||
| 1192 | + detailsList.addAll(bcDetail); | ||
| 1193 | + detailsList.addAll(qqDetail); | ||
| 1194 | + detailsList.addAll(gpDetail); | ||
| 1195 | + | ||
| 1196 | + resMap.put("ccl", jhcc>0?new BigDecimal(sjcc).divide(new BigDecimal(jhcc), | ||
| 1197 | + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | ||
| 1198 | + resMap.put("bczxl", jhbc>0?new BigDecimal(sjbc).divide(new BigDecimal(jhbc), | ||
| 1199 | + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | ||
| 1200 | + resMap.put("smbzdl", jhsmbc>0?new BigDecimal(sjsmbc).divide(new BigDecimal(jhsmbc), | ||
| 1201 | + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | ||
| 1202 | + resMap.put("qqzzdl", jhqqbc>0?new BigDecimal(sjqqzd).divide(new BigDecimal(jhqqbc), | ||
| 1203 | + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | ||
| 1204 | + resMap.put("gpzdl", jhgpqqbc>0?new BigDecimal(sjgpqqzd).divide(new BigDecimal(jhgpqqbc), | ||
| 1205 | + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | ||
| 1206 | + | ||
| 1207 | + resMap.put("detailsList", detailsList); | ||
| 1208 | + | ||
| 1209 | + return JSON.parseObject(JSON.toJSONString(resMap)); | ||
| 1210 | + } | ||
| 1211 | + | ||
| 1035 | @GET | 1212 | @GET |
| 1036 | @Path("/selectData/attendance") | 1213 | @Path("/selectData/attendance") |
| 1037 | public JSONObject attendance(){ | 1214 | public JSONObject attendance(){ |