Commit da0d597f1c4c8530f4749431fe03d93b5b40b4d6
1 parent
9460dd02
1.master_base
Showing
9 changed files
with
5 additions
and
7380 deletions
src/main/java/com/bsth/CXFConfig.java
| ... | ... | @@ -10,13 +10,9 @@ import com.bsth.server_rs.base_info.person.PersonRestService; |
| 10 | 10 | import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService; |
| 11 | 11 | import com.bsth.server_rs.base_info.section.LD_SectionRestService; |
| 12 | 12 | import com.bsth.server_rs.base_info.station.StationRestService; |
| 13 | -import com.bsth.server_rs.bigdata.BigdataService; | |
| 14 | -import com.bsth.server_rs.bigdata.BigscreenService; | |
| 15 | 13 | import com.bsth.server_rs.departure.DepartureRestService; |
| 16 | 14 | import com.bsth.server_rs.destroy.DestroyDetailRestService; |
| 17 | 15 | import com.bsth.server_rs.directive.DirectiveRestService; |
| 18 | -import com.bsth.server_rs.dks.DksRestService; | |
| 19 | -import com.bsth.server_rs.electric.ElectricService; | |
| 20 | 16 | import com.bsth.server_rs.exception.AesExceptionMapper; |
| 21 | 17 | import com.bsth.server_rs.gps.GpsRestService; |
| 22 | 18 | import com.bsth.server_rs.logs.RealLogRestService; |
| ... | ... | @@ -118,12 +114,6 @@ public class CXFConfig { |
| 118 | 114 | @Autowired |
| 119 | 115 | LD_RoadSpeedRestService ld_roadSpeedRestService; |
| 120 | 116 | @Autowired |
| 121 | - ElectricService electricService; | |
| 122 | - @Autowired | |
| 123 | - BigdataService bigdataService; | |
| 124 | - @Autowired | |
| 125 | - BigscreenService bigscreenService; | |
| 126 | - @Autowired | |
| 127 | 117 | StaffViewRealService staffViewRealService; |
| 128 | 118 | @Autowired |
| 129 | 119 | RateService rateService; |
| ... | ... | @@ -134,8 +124,6 @@ public class CXFConfig { |
| 134 | 124 | @Autowired |
| 135 | 125 | private DepartureRestService departureRestService; |
| 136 | 126 | @Autowired |
| 137 | - private DksRestService dksRestService; | |
| 138 | - @Autowired | |
| 139 | 127 | private WhiteIpRestService whiteIpRestService; |
| 140 | 128 | @Autowired |
| 141 | 129 | private ManHoursRestService manHoursRestService; |
| ... | ... | @@ -160,15 +148,11 @@ public class CXFConfig { |
| 160 | 148 | realLogRestService, |
| 161 | 149 | directiveRestService, |
| 162 | 150 | ld_roadSpeedRestService, |
| 163 | - electricService, | |
| 164 | 151 | staffViewRealService, |
| 165 | - bigdataService, | |
| 166 | - bigscreenService, | |
| 167 | 152 | rateService, |
| 168 | 153 | destroyDetailRestService, |
| 169 | 154 | carparkRestService, |
| 170 | 155 | departureRestService, |
| 171 | - dksRestService, | |
| 172 | 156 | whiteIpRestService, |
| 173 | 157 | manHoursRestService, |
| 174 | 158 | ioCarparkRestService)); | ... | ... |
src/main/java/com/bsth/server_rs/bigdata/BigdataService.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.bigdata; | |
| 2 | - | |
| 3 | -import java.math.BigDecimal; | |
| 4 | -import java.math.RoundingMode; | |
| 5 | -import java.sql.ResultSet; | |
| 6 | -import java.sql.SQLException; | |
| 7 | -import java.text.DecimalFormat; | |
| 8 | -import java.text.ParseException; | |
| 9 | -import java.text.SimpleDateFormat; | |
| 10 | -import java.util.ArrayList; | |
| 11 | -import java.util.Calendar; | |
| 12 | -import java.util.Collections; | |
| 13 | -import java.util.Comparator; | |
| 14 | -import java.util.Date; | |
| 15 | -import java.util.HashMap; | |
| 16 | -import java.util.HashSet; | |
| 17 | -import java.util.List; | |
| 18 | -import java.util.Map; | |
| 19 | -import java.util.Set; | |
| 20 | - | |
| 21 | -import javax.ws.rs.GET; | |
| 22 | -import javax.ws.rs.Path; | |
| 23 | -import javax.ws.rs.PathParam; | |
| 24 | -import javax.ws.rs.Produces; | |
| 25 | -import javax.ws.rs.core.MediaType; | |
| 26 | - | |
| 27 | -import org.slf4j.Logger; | |
| 28 | -import org.slf4j.LoggerFactory; | |
| 29 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 30 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 31 | -import org.springframework.jdbc.core.RowMapper; | |
| 32 | -import org.springframework.stereotype.Component; | |
| 33 | - | |
| 34 | -import com.alibaba.fastjson.JSON; | |
| 35 | -import com.alibaba.fastjson.JSONObject; | |
| 36 | -import com.bsth.common.BusinessCodeData; | |
| 37 | -import com.bsth.entity.CalcInvestigateMonth; | |
| 38 | -import com.bsth.entity.ChildTaskPlan; | |
| 39 | -import com.bsth.entity.DestroySituation; | |
| 40 | -import com.bsth.entity.ElecInfo; | |
| 41 | -import com.bsth.entity.OilInfo; | |
| 42 | -import com.bsth.entity.ScheduleRealInfo; | |
| 43 | -import com.bsth.repository.CalcInvestigateMonthRepository; | |
| 44 | -import com.bsth.repository.DestroySituationRepository; | |
| 45 | -import com.bsth.repository.ElecInfoRepository; | |
| 46 | -import com.bsth.repository.OilInfoRepository; | |
| 47 | -import com.bsth.repository.ScheduleRealInfoRepository; | |
| 48 | -import com.bsth.server_rs.base_info.car.buffer.CarBufferData; | |
| 49 | -import com.bsth.util.Arith; | |
| 50 | - | |
| 51 | -@Component | |
| 52 | -@Path("/bigdata") | |
| 53 | -@Produces({MediaType.APPLICATION_JSON}) | |
| 54 | -public class BigdataService { | |
| 55 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 56 | - | |
| 57 | - @Autowired | |
| 58 | - JdbcTemplate jdbcTemplate; | |
| 59 | - | |
| 60 | - @Autowired | |
| 61 | - private DestroySituationRepository destroySituationRepository; | |
| 62 | - | |
| 63 | - @Autowired | |
| 64 | - private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 65 | - | |
| 66 | - @Autowired | |
| 67 | - private OilInfoRepository oilInfoRepository; | |
| 68 | - | |
| 69 | - @Autowired | |
| 70 | - private ElecInfoRepository elecInfoRepository; | |
| 71 | - | |
| 72 | - @Autowired | |
| 73 | - private CalcInvestigateMonthRepository calcInvestigateMonthRepository; | |
| 74 | - | |
| 75 | - | |
| 76 | - DecimalFormat df = new DecimalFormat("0.00"); | |
| 77 | - | |
| 78 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 79 | - | |
| 80 | - /* | |
| 81 | - * 线路接口开始 | |
| 82 | - */ | |
| 83 | - | |
| 84 | - private static String getNature(String natureCode){ | |
| 85 | - String natureName=""; | |
| 86 | - if("lj".equals(natureCode)){ | |
| 87 | - natureName="路救"; | |
| 88 | - }else if("bc".equals(natureCode)){ | |
| 89 | - natureName="备车"; | |
| 90 | - }else if("dbc".equals(natureCode)){ | |
| 91 | - natureName="定班车"; | |
| 92 | - }else if("yxl".equals(natureCode)){ | |
| 93 | - natureName="夜宵路"; | |
| 94 | - }else if("cgxl".equals(natureCode)){ | |
| 95 | - natureName="常规线路"; | |
| 96 | - }else if("gjxl".equals(natureCode)){ | |
| 97 | - natureName="过江线路"; | |
| 98 | - }else if("csbs".equals(natureCode)){ | |
| 99 | - natureName="穿梭巴士"; | |
| 100 | - }else if("tyxl".equals(natureCode)){ | |
| 101 | - natureName="特约线路"; | |
| 102 | - }else if("cctxl".equals(natureCode)){ | |
| 103 | - natureName="村村通线路"; | |
| 104 | - }else if("qt".equals(natureCode)){ | |
| 105 | - natureName="其他"; | |
| 106 | - }else { | |
| 107 | - natureName=""; | |
| 108 | - } | |
| 109 | - return natureName; | |
| 110 | - } | |
| 111 | - | |
| 112 | - private static String getGs(String gs){ | |
| 113 | - String name=""; | |
| 114 | - if("05".equals(gs)){ | |
| 115 | - name="杨高公司"; | |
| 116 | - }else if("22".equals(gs)){ | |
| 117 | - name="金高公司"; | |
| 118 | - }else if("26".equals(gs)){ | |
| 119 | - name="南汇公司"; | |
| 120 | - }else if("55".equals(gs)){ | |
| 121 | - name="上南公司"; | |
| 122 | - }else{ | |
| 123 | - name=""; | |
| 124 | - } | |
| 125 | - return name; | |
| 126 | - } | |
| 127 | - | |
| 128 | - private static String getState(String carState){ | |
| 129 | - if(carState.equals("1")){ | |
| 130 | - return "在册未在用"; | |
| 131 | - }else if(carState.equals("2")){ | |
| 132 | - return "在册在用"; | |
| 133 | - }else if(carState.equals("3")){ | |
| 134 | - return "报废审核中"; | |
| 135 | - }else if(carState.equals("4")){ | |
| 136 | - return "报废待更新"; | |
| 137 | - }else if(carState.equals("5")){ | |
| 138 | - return "报废已更新"; | |
| 139 | - }else{ | |
| 140 | - return ""; | |
| 141 | - } | |
| 142 | - } | |
| 143 | - public Map<String, Long> getEndtime(String date){ | |
| 144 | - Map<String, Long> map=new HashMap<String,Long>(); | |
| 145 | - String sql="select xl,endtime from bsth_c_calc_count " | |
| 146 | - + " where date='"+date+"' "; | |
| 147 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 148 | - new RowMapper<Map<String, Object>>(){ | |
| 149 | - @Override | |
| 150 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 151 | - Map<String, Object> m=new HashMap<String, Object>(); | |
| 152 | - m.put("line", rs.getString("xl")); | |
| 153 | - m.put("endtime", rs.getString("endtime")); | |
| 154 | - return m; | |
| 155 | - } | |
| 156 | - }); | |
| 157 | - for (int i = 0; i < list.size(); i++) { | |
| 158 | - map.put(list.get(i).get("line").toString(), | |
| 159 | - Long.parseLong(list.get(i).get("endtime").toString())); | |
| 160 | - } | |
| 161 | - return map; | |
| 162 | - } | |
| 163 | - @GET | |
| 164 | - @Path("/line/all") | |
| 165 | - public List<Map<String, Object>> findLineAll(){ | |
| 166 | - String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level," | |
| 167 | - + " a.shanghai_linecode, a.nature from " | |
| 168 | - + " bsth_c_line a left join bsth_c_line_config b " | |
| 169 | - + " on a.id=b.line where " | |
| 170 | - + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 " | |
| 171 | - + " and a.remove=0 "; | |
| 172 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 173 | - new RowMapper<Map<String, Object>>(){ | |
| 174 | - @Override | |
| 175 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 176 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 177 | - m.put("state", rs.getString("start_opt")); | |
| 178 | - m.put("company", rs.getString("company")); | |
| 179 | - m.put("companyName", getGs(rs.getString("company"))); | |
| 180 | - m.put("lineCode",rs.getString("line_code")); | |
| 181 | - m.put("name", rs.getString("name")); | |
| 182 | - m.put("level", rs.getString("level")); | |
| 183 | - m.put("shanghaiLinecode", rs.getString("shanghai_linecode")); | |
| 184 | - m.put("nature", getNature(rs.getString("nature"))); | |
| 185 | - return m; | |
| 186 | - } | |
| 187 | - }); | |
| 188 | - Date d=new Date(); | |
| 189 | - SimpleDateFormat hm=new SimpleDateFormat("HH:mm"); | |
| 190 | - SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd"); | |
| 191 | - | |
| 192 | - String qqrq=ymd.format(d); | |
| 193 | - String qqsj=hm.format(d); | |
| 194 | - String qqsjs[]=qqsj.split(":"); | |
| 195 | - Date nDate=new Date(); | |
| 196 | - Calendar calendar = Calendar.getInstance(); | |
| 197 | - calendar.setTime(nDate); | |
| 198 | - calendar.add(Calendar.DAY_OF_MONTH, -1); | |
| 199 | - Date dBefore = calendar.getTime(); | |
| 200 | - String qqrqbefore =ymd.format(dBefore); | |
| 201 | - int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]); | |
| 202 | - Map<String, Long> endMap1=getEndtime(qqrqbefore); | |
| 203 | - Map<String, Long> endMap2=getEndtime(qqrq); | |
| 204 | - | |
| 205 | - for (int i = 0; i < list.size(); i++) { | |
| 206 | - Map<String, Object> m=list.get(i); | |
| 207 | - int fcsjtime=0; | |
| 208 | - if(m.get("state")!=null){ | |
| 209 | - String start_opt[]=m.get("state").toString().split(":"); | |
| 210 | - fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]); | |
| 211 | - } | |
| 212 | - //请求时间小于翻班时间 营运日期当做请求日期的前一天。 | |
| 213 | - long maxtime=d.getTime(); | |
| 214 | - String yyzt=""; | |
| 215 | - if(qqsjtime<fcsjtime){ | |
| 216 | - if(endMap1.get(m.get("lineCode").toString())!=null){ | |
| 217 | - if(endMap1.get(m.get("lineCode").toString())>=maxtime){ | |
| 218 | - yyzt="营运"; | |
| 219 | - }else{ | |
| 220 | - yyzt="未营运"; | |
| 221 | - } | |
| 222 | - }else{ | |
| 223 | - yyzt="未营运"; | |
| 224 | - } | |
| 225 | - }else{ | |
| 226 | - if(endMap2.get(m.get("lineCode").toString())!=null){ | |
| 227 | - if(endMap2.get(m.get("lineCode").toString())>=maxtime){ | |
| 228 | - yyzt="营运"; | |
| 229 | - }else{ | |
| 230 | - yyzt="未营运"; | |
| 231 | - } | |
| 232 | - }else{ | |
| 233 | - yyzt="未营运"; | |
| 234 | - } | |
| 235 | - } | |
| 236 | - m.put("state", yyzt); | |
| 237 | - } | |
| 238 | - return list; | |
| 239 | - } | |
| 240 | - | |
| 241 | - | |
| 242 | - @GET | |
| 243 | - @Path("/line/company/{companyId}") | |
| 244 | - public List<Map<String, Object>> findLineByCompany(@PathParam("companyId") String companyId) { | |
| 245 | - String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level," | |
| 246 | - + " a.shanghai_linecode, a.nature from " | |
| 247 | - + " bsth_c_line a left join bsth_c_line_config b " | |
| 248 | - + " on a.id=b.line where " | |
| 249 | - + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 " | |
| 250 | - + " and a.remove=0 and a.company = '"+companyId+"'"; | |
| 251 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 252 | - new RowMapper<Map<String, Object>>(){ | |
| 253 | - @Override | |
| 254 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 255 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 256 | - m.put("state", rs.getString("start_opt")); | |
| 257 | - m.put("company", rs.getString("company")); | |
| 258 | - m.put("companyName", getGs(rs.getString("company"))); | |
| 259 | - m.put("lineCode",rs.getString("line_code")); | |
| 260 | - m.put("name", rs.getString("name")); | |
| 261 | - m.put("level", rs.getString("level")); | |
| 262 | - m.put("shanghaiLinecode", rs.getString("shanghai_linecode")); | |
| 263 | - m.put("nature", getNature(rs.getString("nature"))); | |
| 264 | - return m; | |
| 265 | - } | |
| 266 | - }); | |
| 267 | - Date d=new Date(); | |
| 268 | - SimpleDateFormat hm=new SimpleDateFormat("HH:mm"); | |
| 269 | - SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd"); | |
| 270 | - | |
| 271 | - String qqrq=ymd.format(d); | |
| 272 | - String qqsj=hm.format(d); | |
| 273 | - String qqsjs[]=qqsj.split(":"); | |
| 274 | - Date nDate=new Date(); | |
| 275 | - Calendar calendar = Calendar.getInstance(); | |
| 276 | - calendar.setTime(nDate); | |
| 277 | - calendar.add(Calendar.DAY_OF_MONTH, -1); | |
| 278 | - Date dBefore = calendar.getTime(); | |
| 279 | - String qqrqbefore =ymd.format(dBefore); | |
| 280 | - int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]); | |
| 281 | - Map<String, Long> endMap1=getEndtime(qqrqbefore); | |
| 282 | - Map<String, Long> endMap2=getEndtime(qqrq); | |
| 283 | - | |
| 284 | - for (int i = 0; i < list.size(); i++) { | |
| 285 | - Map<String, Object> m=list.get(i); | |
| 286 | - int fcsjtime=0; | |
| 287 | - if(m.get("state")!=null){ | |
| 288 | - String start_opt[]=m.get("state").toString().split(":"); | |
| 289 | - fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]); | |
| 290 | - } | |
| 291 | - //请求时间小于翻班时间 营运日期当做请求日期的前一天。 | |
| 292 | - long maxtime=d.getTime(); | |
| 293 | - String yyzt=""; | |
| 294 | - if(qqsjtime<fcsjtime){ | |
| 295 | - if(endMap1.get(m.get("lineCode").toString())!=null){ | |
| 296 | - if(endMap1.get(m.get("lineCode").toString())>=maxtime){ | |
| 297 | - yyzt="营运"; | |
| 298 | - }else{ | |
| 299 | - yyzt="未营运"; | |
| 300 | - } | |
| 301 | - }else{ | |
| 302 | - yyzt="未营运"; | |
| 303 | - } | |
| 304 | - }else{ | |
| 305 | - if(endMap2.get(m.get("lineCode").toString())!=null){ | |
| 306 | - if(endMap2.get(m.get("lineCode").toString())>=maxtime){ | |
| 307 | - yyzt="营运"; | |
| 308 | - }else{ | |
| 309 | - yyzt="未营运"; | |
| 310 | - } | |
| 311 | - }else{ | |
| 312 | - yyzt="未营运"; | |
| 313 | - } | |
| 314 | - } | |
| 315 | - m.put("state", yyzt); | |
| 316 | - } | |
| 317 | - return list; | |
| 318 | - } | |
| 319 | - | |
| 320 | - @GET | |
| 321 | - @Path("/line/{lineCode}") | |
| 322 | - public List<Map<String, Object>> findLineByCode(@PathParam("lineCode") String lineCode) { | |
| 323 | - String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level," | |
| 324 | - + " a.shanghai_linecode, a.nature from " | |
| 325 | - + " bsth_c_line a left join bsth_c_line_config b " | |
| 326 | - + " on a.id=b.line where " | |
| 327 | - + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 " | |
| 328 | - + " and a.remove=0 and a.line_code = '"+lineCode+"'"; | |
| 329 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 330 | - new RowMapper<Map<String, Object>>(){ | |
| 331 | - @Override | |
| 332 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 333 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 334 | - m.put("state", rs.getString("start_opt")); | |
| 335 | - m.put("company", rs.getString("company")); | |
| 336 | - m.put("companyName", getGs(rs.getString("company"))); | |
| 337 | - m.put("lineCode",rs.getString("line_code")); | |
| 338 | - m.put("name", rs.getString("name")); | |
| 339 | - m.put("level", rs.getString("level")); | |
| 340 | - m.put("shanghaiLinecode", rs.getString("shanghai_linecode")); | |
| 341 | - m.put("nature", getNature(rs.getString("nature"))); | |
| 342 | - return m; | |
| 343 | - } | |
| 344 | - }); | |
| 345 | - Date d=new Date(); | |
| 346 | - SimpleDateFormat hm=new SimpleDateFormat("HH:mm"); | |
| 347 | - SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd"); | |
| 348 | - | |
| 349 | - String qqrq=ymd.format(d); | |
| 350 | - String qqsj=hm.format(d); | |
| 351 | - String qqsjs[]=qqsj.split(":"); | |
| 352 | - Date nDate=new Date(); | |
| 353 | - Calendar calendar = Calendar.getInstance(); | |
| 354 | - calendar.setTime(nDate); | |
| 355 | - calendar.add(Calendar.DAY_OF_MONTH, -1); | |
| 356 | - Date dBefore = calendar.getTime(); | |
| 357 | - String qqrqbefore =ymd.format(dBefore); | |
| 358 | - int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]); | |
| 359 | - Map<String, Long> endMap1=getEndtime(qqrqbefore); | |
| 360 | - Map<String, Long> endMap2=getEndtime(qqrq); | |
| 361 | - | |
| 362 | - for (int i = 0; i < list.size(); i++) { | |
| 363 | - Map<String, Object> m=list.get(i); | |
| 364 | - int fcsjtime=0; | |
| 365 | - if(m.get("state")!=null){ | |
| 366 | - String start_opt[]=m.get("state").toString().split(":"); | |
| 367 | - fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]); | |
| 368 | - } | |
| 369 | - //请求时间小于翻班时间 营运日期当做请求日期的前一天。 | |
| 370 | - long maxtime=d.getTime(); | |
| 371 | - String yyzt=""; | |
| 372 | - if(qqsjtime<fcsjtime){ | |
| 373 | - if(endMap1.get(m.get("lineCode").toString())!=null){ | |
| 374 | - if(endMap1.get(m.get("lineCode").toString())>=maxtime){ | |
| 375 | - yyzt="营运"; | |
| 376 | - }else{ | |
| 377 | - yyzt="未营运"; | |
| 378 | - } | |
| 379 | - }else{ | |
| 380 | - yyzt="未营运"; | |
| 381 | - } | |
| 382 | - }else{ | |
| 383 | - if(endMap2.get(m.get("lineCode").toString())!=null){ | |
| 384 | - if(endMap2.get(m.get("lineCode").toString())>=maxtime){ | |
| 385 | - yyzt="营运"; | |
| 386 | - }else{ | |
| 387 | - yyzt="未营运"; | |
| 388 | - } | |
| 389 | - }else{ | |
| 390 | - yyzt="未营运"; | |
| 391 | - } | |
| 392 | - } | |
| 393 | - m.put("state", yyzt); | |
| 394 | - } | |
| 395 | - return list; | |
| 396 | - } | |
| 397 | - | |
| 398 | - @GET | |
| 399 | - @Path("/line/level/{level}") | |
| 400 | - public List<Map<String, Object>> findLineByLevle(@PathParam("level") String level) { | |
| 401 | - String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level," | |
| 402 | - + " a.shanghai_linecode, a.nature from " | |
| 403 | - + " bsth_c_line a left join bsth_c_line_config b " | |
| 404 | - + " on a.id=b.line where " | |
| 405 | - + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 " | |
| 406 | - + " and a.remove=0 and a.level = '"+level+"'"; | |
| 407 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 408 | - new RowMapper<Map<String, Object>>(){ | |
| 409 | - @Override | |
| 410 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 411 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 412 | - m.put("state", rs.getString("start_opt")); | |
| 413 | - m.put("company", rs.getString("company")); | |
| 414 | - m.put("companyName", getGs(rs.getString("company"))); | |
| 415 | - m.put("lineCode",rs.getString("line_code")); | |
| 416 | - m.put("name", rs.getString("name")); | |
| 417 | - m.put("level", rs.getString("level")); | |
| 418 | - m.put("shanghaiLinecode", rs.getString("shanghai_linecode")); | |
| 419 | - m.put("nature", getNature(rs.getString("nature"))); | |
| 420 | - return m; | |
| 421 | - } | |
| 422 | - }); | |
| 423 | - Date d=new Date(); | |
| 424 | - SimpleDateFormat hm=new SimpleDateFormat("HH:mm"); | |
| 425 | - SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd"); | |
| 426 | - | |
| 427 | - String qqrq=ymd.format(d); | |
| 428 | - String qqsj=hm.format(d); | |
| 429 | - String qqsjs[]=qqsj.split(":"); | |
| 430 | - Date nDate=new Date(); | |
| 431 | - Calendar calendar = Calendar.getInstance(); | |
| 432 | - calendar.setTime(nDate); | |
| 433 | - calendar.add(Calendar.DAY_OF_MONTH, -1); | |
| 434 | - Date dBefore = calendar.getTime(); | |
| 435 | - String qqrqbefore =ymd.format(dBefore); | |
| 436 | - int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]); | |
| 437 | - Map<String, Long> endMap1=getEndtime(qqrqbefore); | |
| 438 | - Map<String, Long> endMap2=getEndtime(qqrq); | |
| 439 | - | |
| 440 | - for (int i = 0; i < list.size(); i++) { | |
| 441 | - Map<String, Object> m=list.get(i); | |
| 442 | - int fcsjtime=0; | |
| 443 | - if(m.get("state")!=null){ | |
| 444 | - String start_opt[]=m.get("state").toString().split(":"); | |
| 445 | - fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]); | |
| 446 | - } | |
| 447 | - //请求时间小于翻班时间 营运日期当做请求日期的前一天。 | |
| 448 | - long maxtime=d.getTime(); | |
| 449 | - String yyzt=""; | |
| 450 | - if(qqsjtime<fcsjtime){ | |
| 451 | - if(endMap1.get(m.get("lineCode").toString())!=null){ | |
| 452 | - if(endMap1.get(m.get("lineCode").toString())>=maxtime){ | |
| 453 | - yyzt="营运"; | |
| 454 | - }else{ | |
| 455 | - yyzt="未营运"; | |
| 456 | - } | |
| 457 | - }else{ | |
| 458 | - yyzt="未营运"; | |
| 459 | - } | |
| 460 | - }else{ | |
| 461 | - if(endMap2.get(m.get("lineCode").toString())!=null){ | |
| 462 | - if(endMap2.get(m.get("lineCode").toString())>=maxtime){ | |
| 463 | - yyzt="营运"; | |
| 464 | - }else{ | |
| 465 | - yyzt="未营运"; | |
| 466 | - } | |
| 467 | - }else{ | |
| 468 | - yyzt="未营运"; | |
| 469 | - } | |
| 470 | - } | |
| 471 | - m.put("state", yyzt); | |
| 472 | - } | |
| 473 | - return list; | |
| 474 | - } | |
| 475 | - /* | |
| 476 | - * 线路接口结束 | |
| 477 | - */ | |
| 478 | - | |
| 479 | - | |
| 480 | - /* | |
| 481 | - * 线路配车接口开始 | |
| 482 | - */ | |
| 483 | - @GET | |
| 484 | - @Path("/lineCar/{type}/date/{date}") | |
| 485 | - public List<Map<String, Object>> findLineCarByDate(@PathParam("type") String type,@PathParam("date") String date) { | |
| 486 | - String sql=""; | |
| 487 | - if(type.equals("all")){ | |
| 488 | - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhccz as jhcc,t.sjcc" | |
| 489 | - + " from bsth_c_calc_count t where t.date='"+date+"'"; | |
| 490 | - } | |
| 491 | - if(type.equals("actual")){ | |
| 492 | - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhcc as jhcc,t.sjcc" | |
| 493 | - + " from bsth_c_calc_count t where t.date='"+date+"'"; | |
| 494 | - } | |
| 495 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 496 | - new RowMapper<Map<String, Object>>(){ | |
| 497 | - @Override | |
| 498 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 499 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 500 | - m.put("date", rs.getString("date")); | |
| 501 | - m.put("company", rs.getString("gsdm")); | |
| 502 | - m.put("companyName", getGs(rs.getString("gsdm"))); | |
| 503 | - m.put("lineCode",rs.getString("xl")); | |
| 504 | - m.put("lineName", rs.getString("xl_name")); | |
| 505 | - m.put("jhcc", rs.getString("jhcc")); | |
| 506 | - m.put("sjcc", rs.getString("sjcc")); | |
| 507 | - return m; | |
| 508 | - } | |
| 509 | - }); | |
| 510 | - | |
| 511 | - return list; | |
| 512 | - } | |
| 513 | - | |
| 514 | - | |
| 515 | - @GET | |
| 516 | - @Path("/lineCar/{type}/date/{date}/line/{line}") | |
| 517 | - public List<Map<String, Object>> findLineCarByDateLine(@PathParam("type") String type,@PathParam("date") String date, | |
| 518 | - @PathParam("line") String line) { | |
| 519 | - String sql=""; | |
| 520 | - if(type.equals("all")){ | |
| 521 | - sql="select t.gsdm,t.xl,t.xl_name,t.jhccz as jhcc,t.sjcc" | |
| 522 | - + " from bsth_c_calc_count t where t.date='"+date+"'" | |
| 523 | - + " and xl ='"+line+"'"; | |
| 524 | - } | |
| 525 | - if(type.equals("actual")){ | |
| 526 | - sql="select t.gsdm,t.xl,t.xl_name,t.jhcc as jhcc,t.sjcc" | |
| 527 | - + " from bsth_c_calc_count t where t.date='"+date+"'" | |
| 528 | - + " and xl ='"+line+"'"; | |
| 529 | - | |
| 530 | - } | |
| 531 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 532 | - new RowMapper<Map<String, Object>>(){ | |
| 533 | - @Override | |
| 534 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 535 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 536 | - m.put("company", rs.getString("gsdm")); | |
| 537 | - m.put("companyName", getGs(rs.getString("gsdm"))); | |
| 538 | - m.put("lineCode",rs.getString("xl")); | |
| 539 | - m.put("lineName", rs.getString("xl_name")); | |
| 540 | - m.put("jhcc", rs.getString("jhcc")); | |
| 541 | - m.put("sjcc", rs.getString("sjcc")); | |
| 542 | - return m; | |
| 543 | - } | |
| 544 | - }); | |
| 545 | - | |
| 546 | - return list; | |
| 547 | - } | |
| 548 | - | |
| 549 | - /* | |
| 550 | - * 线路配车接口结束 | |
| 551 | - */ | |
| 552 | - | |
| 553 | - /* | |
| 554 | - * 线路配人接口开始 | |
| 555 | - */ | |
| 556 | - @GET | |
| 557 | - @Path("/linePerson/{type}/date/{date}") | |
| 558 | - public List<Map<String, Object>> findLinePersonByDate(@PathParam("type") String type,@PathParam("date") String date) { | |
| 559 | - String sql=""; | |
| 560 | - if(type.equals("all")){ | |
| 561 | - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprz as jhpr,t.sjpr" | |
| 562 | - + " from bsth_c_calc_count t where t.date='"+date+"'"; | |
| 563 | - } | |
| 564 | - if(type.equals("actual")){ | |
| 565 | - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprss as jhpr,t.sjpr" | |
| 566 | - + " from bsth_c_calc_count t where t.date='"+date+"'"; | |
| 567 | - } | |
| 568 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 569 | - new RowMapper<Map<String, Object>>(){ | |
| 570 | - @Override | |
| 571 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 572 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 573 | - m.put("date", rs.getString("date")); | |
| 574 | - m.put("company", rs.getString("gsdm")); | |
| 575 | - m.put("companyName", getGs(rs.getString("gsdm"))); | |
| 576 | - m.put("lineCode",rs.getString("xl")); | |
| 577 | - m.put("lineName", rs.getString("xl_name")); | |
| 578 | - String jhpr=rs.getString("jhpr"); | |
| 579 | - m.put("jhjsy", jhpr.split("/")[0]); | |
| 580 | - m.put("jhspy", jhpr.split("/")[1]); | |
| 581 | - String sjpr= rs.getString("sjpr"); | |
| 582 | - m.put("sjjsy", sjpr.split("/")[0]); | |
| 583 | - m.put("sjspy", sjpr.split("/")[1]); | |
| 584 | - return m; | |
| 585 | - } | |
| 586 | - }); | |
| 587 | - | |
| 588 | - return list; | |
| 589 | - } | |
| 590 | - | |
| 591 | - | |
| 592 | - @GET | |
| 593 | - @Path("/linePerson/{type}/date/{date}/line/{line}") | |
| 594 | - public List<Map<String, Object>> findLinePersonByDateLine(@PathParam("type") String type,@PathParam("date") String date, | |
| 595 | - @PathParam("line") String line) { | |
| 596 | - String sql=""; | |
| 597 | - if(type.equals("all")){ | |
| 598 | - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprz as jhpr,t.sjpr" | |
| 599 | - + " from bsth_c_calc_count t where t.date='"+date+"'" | |
| 600 | - + " and xl ='"+line+"'"; | |
| 601 | - } | |
| 602 | - if(type.equals("actual")){ | |
| 603 | - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprss as jhpr,t.sjpr" | |
| 604 | - + " from bsth_c_calc_count t where t.date='"+date+"'" | |
| 605 | - + " and xl ='"+line+"'"; | |
| 606 | - } | |
| 607 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 608 | - new RowMapper<Map<String, Object>>(){ | |
| 609 | - @Override | |
| 610 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 611 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 612 | - m.put("date", rs.getString("date")); | |
| 613 | - m.put("company", rs.getString("gsdm")); | |
| 614 | - m.put("companyName", getGs(rs.getString("gsdm"))); | |
| 615 | - m.put("lineCode",rs.getString("xl")); | |
| 616 | - m.put("lineName", rs.getString("xl_name")); | |
| 617 | - String jhpr=rs.getString("jhpr"); | |
| 618 | - m.put("jhjsy", jhpr.split("/")[0]); | |
| 619 | - m.put("jhspy", jhpr.split("/")[1]); | |
| 620 | - String sjpr= rs.getString("sjpr"); | |
| 621 | - m.put("sjjsy", sjpr.split("/")[0]); | |
| 622 | - m.put("sjspy", sjpr.split("/")[1]); | |
| 623 | - return m; | |
| 624 | - } | |
| 625 | - }); | |
| 626 | - | |
| 627 | - return list; | |
| 628 | - } | |
| 629 | - | |
| 630 | - | |
| 631 | - | |
| 632 | - | |
| 633 | - /* | |
| 634 | - * 线路配人接口结束 | |
| 635 | - */ | |
| 636 | - | |
| 637 | - | |
| 638 | - /* | |
| 639 | - * 线路班次接口开始 | |
| 640 | - */ | |
| 641 | - @GET | |
| 642 | - @Path("/lineBc/{type}/date/{date}") | |
| 643 | - public List<Map<String, Object>> findLineBcByDate(@PathParam("type") String type, | |
| 644 | - @PathParam("date") String date) { | |
| 645 | - String sql=""; | |
| 646 | - if(type.equals("all")){ | |
| 647 | - sql="select t.gsdm,t.xl,t.xl_name,t.jhbcz as jhbc,t.jhzgfbcz as jhzgfbc," | |
| 648 | - + " t.jhwgfbcz as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t" | |
| 649 | - + " where t.date='"+date+"'"; | |
| 650 | - } | |
| 651 | - if(type.equals("actual")){ | |
| 652 | - sql="select t.gsdm,t.xl,t.xl_name,t.jhbc as jhbc,t.jhzgfbcss as jhzgfbc," | |
| 653 | - + " t.jhwgfbcss as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t" | |
| 654 | - + " where t.date='"+date+"'"; | |
| 655 | - } | |
| 656 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 657 | - new RowMapper<Map<String, Object>>(){ | |
| 658 | - @Override | |
| 659 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 660 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 661 | - m.put("company", rs.getString("gsdm")); | |
| 662 | - m.put("companyName", getGs(rs.getString("gsdm"))); | |
| 663 | - m.put("lineCode",rs.getString("xl")); | |
| 664 | - m.put("lineName", rs.getString("xl_name")); | |
| 665 | - m.put("jhbc", rs.getString("jhbc")); | |
| 666 | - m.put("jhzgfbc", rs.getString("jhzgfbc")); | |
| 667 | - m.put("jhwgfbc", rs.getString("jhwgfbc")); | |
| 668 | - m.put("sjbc", rs.getString("sjbc")); | |
| 669 | - m.put("sjzgfbc", rs.getString("sjzgfbc")); | |
| 670 | - m.put("sjwgfbc", rs.getString("sjwgfbc")); | |
| 671 | - return m; | |
| 672 | - } | |
| 673 | - }); | |
| 674 | - return list; | |
| 675 | - } | |
| 676 | - | |
| 677 | - | |
| 678 | - @GET | |
| 679 | - @Path("/lineBc/{type}/date/{date}/line/{line}") | |
| 680 | - public List<Map<String, Object>> findLineBcByDateLine(@PathParam("type") String type, | |
| 681 | - @PathParam("date") String date,@PathParam("line") String line) { | |
| 682 | - String sql=""; | |
| 683 | - if(type.equals("all")){ | |
| 684 | - sql="select t.gsdm,t.xl,t.xl_name,t.jhbcz as jhbc,t.jhzgfbcz as jhzgfbc," | |
| 685 | - + " t.jhwgfbcz as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t " | |
| 686 | - + " where t.date='"+date+"' and xl='"+line+"'"; | |
| 687 | - } | |
| 688 | - if(type.equals("actual")){ | |
| 689 | - sql="select t.gsdm,t.xl,t.xl_name,t.jhbc as jhbc,t.jhzgfbcss as jhzgfbc," | |
| 690 | - + " t.jhwgfbcss as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t" | |
| 691 | - + " where t.date='"+date+"' and xl='"+line+"'"; | |
| 692 | - } | |
| 693 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 694 | - new RowMapper<Map<String, Object>>(){ | |
| 695 | - @Override | |
| 696 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 697 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 698 | - m.put("company", rs.getString("gsdm")); | |
| 699 | - m.put("companyName", getGs(rs.getString("gsdm"))); | |
| 700 | - m.put("lineCode",rs.getString("xl")); | |
| 701 | - m.put("lineName", rs.getString("xl_name")); | |
| 702 | - m.put("jhbc", rs.getString("jhbc")); | |
| 703 | - m.put("jhzgfbc", rs.getString("jhzgfbc")); | |
| 704 | - m.put("jhwgfbc", rs.getString("jhwgfbc")); | |
| 705 | - m.put("sjbc", rs.getString("sjbc")); | |
| 706 | - m.put("sjzgfbc", rs.getString("sjzgfbc")); | |
| 707 | - m.put("sjwgfbc", rs.getString("sjwgfbc")); | |
| 708 | - return m; | |
| 709 | - } | |
| 710 | - }); | |
| 711 | - return list; | |
| 712 | - } | |
| 713 | - | |
| 714 | - /* | |
| 715 | - * 线路班次接口结束 | |
| 716 | - */ | |
| 717 | - | |
| 718 | - /* | |
| 719 | - * 线路里程接口开始 | |
| 720 | - */ | |
| 721 | - | |
| 722 | - @GET | |
| 723 | - @Path("/lineLc/{type}/date/{date}") | |
| 724 | - public List<Map<String, Object>> findLineLcByDate(@PathParam("type") String type, | |
| 725 | - @PathParam("date") String date) { | |
| 726 | - String sql=""; | |
| 727 | - if(type.equals("all")){ | |
| 728 | - sql="select t.gsdm,t.xl,t.xl_name,t.jhzglz as jhzlc,t.jhyylcz as jhyylc," | |
| 729 | - + " t.jhkslcz as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t" | |
| 730 | - + " where t.date='"+date+"'"; | |
| 731 | - } | |
| 732 | - if(type.equals("actual")){ | |
| 733 | - sql="select t.gsdm,t.xl,t.xl_name,t.jhzgl as jhzlc,t.jhyylc as jhyylc," | |
| 734 | - + " t.jhkslc as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t" | |
| 735 | - + " where t.date='"+date+"'"; | |
| 736 | - } | |
| 737 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 738 | - new RowMapper<Map<String, Object>>(){ | |
| 739 | - @Override | |
| 740 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 741 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 742 | - m.put("company", rs.getString("gsdm")); | |
| 743 | - m.put("companyName", getGs(rs.getString("gsdm"))); | |
| 744 | - m.put("lineCode",rs.getString("xl")); | |
| 745 | - m.put("lineName", rs.getString("xl_name")); | |
| 746 | - m.put("jhzlc", rs.getString("jhzlc")); | |
| 747 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 748 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 749 | - m.put("sjzlc", rs.getString("sjzlc")); | |
| 750 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 751 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 752 | - if(Double.parseDouble(rs.getString("jhzlc"))>0){ | |
| 753 | - double zlczxl=Double.parseDouble(rs.getString("sjzlc"))/Double.parseDouble(rs.getString("jhzlc")); | |
| 754 | - m.put("zlczxl",df.format(zlczxl*100)+"%"); | |
| 755 | - }else{ | |
| 756 | - m.put("zlczxl","0.00%"); | |
| 757 | - | |
| 758 | - } | |
| 759 | - if(Double.parseDouble(rs.getString("jhyylc"))>0){ | |
| 760 | - double yylczxl=Double.parseDouble(rs.getString("sjyylc"))/Double.parseDouble(rs.getString("jhyylc")); | |
| 761 | - m.put("yylczxl",df.format(yylczxl*100)+"%"); | |
| 762 | - }else{ | |
| 763 | - m.put("yylczxl","0.00%"); | |
| 764 | - } | |
| 765 | - return m; | |
| 766 | - } | |
| 767 | - }); | |
| 768 | - return list; | |
| 769 | - } | |
| 770 | - | |
| 771 | - | |
| 772 | - @GET | |
| 773 | - @Path("/lineLc/{type}/date/{date}/line/{line}") | |
| 774 | - public List<Map<String, Object>> findLineLcByDateLine(@PathParam("type") String type, | |
| 775 | - @PathParam("date") String date,@PathParam("line") String line) { | |
| 776 | - String sql=""; | |
| 777 | - if(type.equals("all")){ | |
| 778 | - sql="select t.gsdm,t.xl,t.xl_name,t.jhzglz as jhzlc,t.jhyylcz as jhyylc," | |
| 779 | - + " t.jhkslcz as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t" | |
| 780 | - + " where t.date='"+date+"' and xl ='"+line+"'"; | |
| 781 | - } | |
| 782 | - if(type.equals("actual")){ | |
| 783 | - sql="select t.gsdm,t.xl,t.xl_name,t.jhzgl as jhzlc,t.jhyylc as jhyylc," | |
| 784 | - + " t.jhkslc as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t" | |
| 785 | - + " where t.date='"+date+"' and xl ='"+line+"'"; | |
| 786 | - } | |
| 787 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 788 | - new RowMapper<Map<String, Object>>(){ | |
| 789 | - @Override | |
| 790 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 791 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 792 | - m.put("company", rs.getString("gsdm")); | |
| 793 | - m.put("companyName", getGs(rs.getString("gsdm"))); | |
| 794 | - m.put("lineCode",rs.getString("xl")); | |
| 795 | - m.put("lineName", rs.getString("xl_name")); | |
| 796 | - m.put("jhzlc", rs.getString("jhzlc")); | |
| 797 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 798 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 799 | - m.put("sjzlc", rs.getString("sjzlc")); | |
| 800 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 801 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 802 | - if(Double.parseDouble(rs.getString("jhzlc"))>0){ | |
| 803 | - double zlczxl=Double.parseDouble(rs.getString("sjzlc"))/Double.parseDouble(rs.getString("jhzlc")); | |
| 804 | - m.put("zlczxl",df.format(zlczxl*100)+"%"); | |
| 805 | - }else{ | |
| 806 | - m.put("zlczxl","0.00%"); | |
| 807 | - | |
| 808 | - } | |
| 809 | - if(Double.parseDouble(rs.getString("jhyylc"))>0){ | |
| 810 | - double yylczxl=Double.parseDouble(rs.getString("sjyylc"))/Double.parseDouble(rs.getString("jhyylc")); | |
| 811 | - m.put("yylczxl",df.format(yylczxl*100)+"%"); | |
| 812 | - }else{ | |
| 813 | - m.put("yylczxl","0.00%"); | |
| 814 | - } | |
| 815 | - return m; | |
| 816 | - } | |
| 817 | - }); | |
| 818 | - return list; | |
| 819 | - } | |
| 820 | - /* | |
| 821 | - * 线路里程接口结束 | |
| 822 | - */ | |
| 823 | - | |
| 824 | - | |
| 825 | - /* | |
| 826 | - * 班次执行率连续三天不满93%推送 | |
| 827 | - */ | |
| 828 | - @GET | |
| 829 | - @Path("/abnormal/executionRate/date/{date}") | |
| 830 | - public List<Map<String, Object>> executionRate(@PathParam("date") String date) { | |
| 831 | - String sql="select gs_name,show_date,xl_bm,xl_name from bsth_c_calc_push t" | |
| 832 | - + " where t.date='"+date+"' and push_type in ('1','3')"; | |
| 833 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 834 | - new RowMapper<Map<String, Object>>(){ | |
| 835 | - @Override | |
| 836 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 837 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 838 | - m.put("companyName", rs.getString("gs_name")); | |
| 839 | - m.put("lineCode",rs.getString("xl_bm")); | |
| 840 | - m.put("lineName", rs.getString("xl_name")); | |
| 841 | - m.put("showDate", rs.getString("show_date")); | |
| 842 | - return m; | |
| 843 | - } | |
| 844 | - }); | |
| 845 | - return list; | |
| 846 | - } | |
| 847 | - /* | |
| 848 | - * 首末班发车连续三天不准点 | |
| 849 | - */ | |
| 850 | - @GET | |
| 851 | - @Path("/abnormal/firstAndLast/date/{date}") | |
| 852 | - public List<Map<String, Object>> firstAndLast(@PathParam("date") String date) { | |
| 853 | - String sql="select gs_name,show_date,xl_bm,xl_name from bsth_c_calc_push t" | |
| 854 | - + " where t.date='"+date+"' and push_type in ('2','3')"; | |
| 855 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 856 | - new RowMapper<Map<String, Object>>(){ | |
| 857 | - @Override | |
| 858 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 859 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 860 | - m.put("companyName", rs.getString("gs_name")); | |
| 861 | - m.put("lineCode",rs.getString("xl_bm")); | |
| 862 | - m.put("lineName", rs.getString("xl_name")); | |
| 863 | - m.put("showDate", rs.getString("show_date")); | |
| 864 | - return m; | |
| 865 | - } | |
| 866 | - }); | |
| 867 | - return list; | |
| 868 | - } | |
| 869 | - | |
| 870 | - /* | |
| 871 | - * 车辆数据接口开始 | |
| 872 | - */ | |
| 873 | - | |
| 874 | - @GET | |
| 875 | - @Path("/car/all") | |
| 876 | - public List<Map<String, Object>> findCar() { | |
| 877 | - String carStr= GetHttpInterface.getHttpInterface("http://58.247.254.118:8076/cars/getAllCarsInterface"); | |
| 878 | - //车辆库资料资料 | |
| 879 | - List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr); | |
| 880 | - //调度系统车辆资料 | |
| 881 | - String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars"; | |
| 882 | - List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql, | |
| 883 | - new RowMapper<Map<String, Object>>(){ | |
| 884 | - @Override | |
| 885 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 886 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 887 | - m.put("equipment_code", rs.getString("equipment_code")); | |
| 888 | - m.put("insideCode", rs.getString("inside_code")); | |
| 889 | - m.put("supplier_name",rs.getString("supplier_name")); | |
| 890 | - return m; | |
| 891 | - } | |
| 892 | - }); | |
| 893 | - for (int i = 0; i < clkList.size(); i++) { | |
| 894 | - Map<String, Object> m1=clkList.get(i); | |
| 895 | - String carCode=m1.get("car_code").toString(); | |
| 896 | - m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString())); | |
| 897 | - for (int j = 0; j < ddkList.size(); j++) { | |
| 898 | - Map<String, Object> m2=ddkList.get(j); | |
| 899 | - String insideCode=m2.get("insideCode").toString(); | |
| 900 | - if(carCode.equals(insideCode)){ | |
| 901 | - m1.put("equipment_code", m2.get("equipment_code")); | |
| 902 | - m1.put("supplier_name", m2.get("supplier_name")); | |
| 903 | - } | |
| 904 | - | |
| 905 | - } | |
| 906 | - } | |
| 907 | - return clkList; | |
| 908 | - } | |
| 909 | - | |
| 910 | - | |
| 911 | - @GET | |
| 912 | - @Path("/car/company/{companyId}") | |
| 913 | - public List<Map<String, Object>> findCarByCompany(@PathParam("companyId") String companyId) { | |
| 914 | - String carStr= GetHttpInterface. | |
| 915 | - getHttpInterface("http://58.247.254.118:8076/cars/getAllCarsInterface?company="+companyId); | |
| 916 | - //车辆库资料资料 | |
| 917 | - List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr); | |
| 918 | - //调度系统车辆资料 | |
| 919 | - String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars where business_code='"+companyId+"'"; | |
| 920 | - List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql, | |
| 921 | - new RowMapper<Map<String, Object>>(){ | |
| 922 | - @Override | |
| 923 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 924 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 925 | - m.put("equipment_code", rs.getString("equipment_code")); | |
| 926 | - m.put("insideCode", rs.getString("inside_code")); | |
| 927 | - m.put("supplier_name",rs.getString("supplier_name")); | |
| 928 | - return m; | |
| 929 | - } | |
| 930 | - }); | |
| 931 | - for (int i = 0; i < clkList.size(); i++) { | |
| 932 | - Map<String, Object> m1=clkList.get(i); | |
| 933 | - String carCode=m1.get("car_code").toString(); | |
| 934 | - m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString())); | |
| 935 | - for (int j = 0; j < ddkList.size(); j++) { | |
| 936 | - Map<String, Object> m2=ddkList.get(j); | |
| 937 | - String insideCode=m2.get("insideCode").toString(); | |
| 938 | - if(carCode.equals(insideCode)){ | |
| 939 | - m1.put("equipment_code", m2.get("equipment_code")); | |
| 940 | - m1.put("supplier_name", m2.get("supplier_name")); | |
| 941 | - } | |
| 942 | - | |
| 943 | - } | |
| 944 | - } | |
| 945 | - return clkList; | |
| 946 | - } | |
| 947 | - | |
| 948 | - @GET | |
| 949 | - @Path("/car/code/{carCode}") | |
| 950 | - public List<Map<String, Object>> findCarByCode(@PathParam("carCode") String carCode) { | |
| 951 | - String carStr= GetHttpInterface. | |
| 952 | - getHttpInterface("http://58.247.254.118:8076/cars/getAllCarsInterface?car_code="+carCode); | |
| 953 | - //车辆库资料资料 | |
| 954 | - List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr); | |
| 955 | - //调度系统车辆资料 | |
| 956 | - String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars where inside_code='"+carCode+"'"; | |
| 957 | - List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql, | |
| 958 | - new RowMapper<Map<String, Object>>(){ | |
| 959 | - @Override | |
| 960 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 961 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 962 | - m.put("equipment_code", rs.getString("equipment_code")); | |
| 963 | - m.put("insideCode", rs.getString("inside_code")); | |
| 964 | - m.put("supplier_name",rs.getString("supplier_name")); | |
| 965 | - return m; | |
| 966 | - } | |
| 967 | - }); | |
| 968 | - | |
| 969 | - for (int i = 0; i < clkList.size(); i++) { | |
| 970 | - Map<String, Object> m1=clkList.get(i); | |
| 971 | - String code=m1.get("car_code").toString().trim(); | |
| 972 | - m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString())); | |
| 973 | - for (int j = 0; j < ddkList.size(); j++) { | |
| 974 | - Map<String, Object> m2=ddkList.get(j); | |
| 975 | - String insideCode=m2.get("insideCode").toString().trim(); | |
| 976 | - if(code.equals(insideCode)){ | |
| 977 | - m1.put("equipment_code", m2.get("equipment_code")); | |
| 978 | - m1.put("supplier_name", m2.get("supplier_name")); | |
| 979 | - } | |
| 980 | - | |
| 981 | - } | |
| 982 | - } | |
| 983 | - return clkList; | |
| 984 | - } | |
| 985 | - /* | |
| 986 | - * 车辆数据接口结束 | |
| 987 | - */ | |
| 988 | - | |
| 989 | - /* | |
| 990 | - * 事故数据接口开始 | |
| 991 | - */ | |
| 992 | - @GET | |
| 993 | - @Path("/accident/startTime/{startTime}/endTime/{endTime}") | |
| 994 | - public List<Map<String, Object>> findAccident(@PathParam("startTime") String startTime, | |
| 995 | - @PathParam("endTime") String endTime) { | |
| 996 | - String accidentAll= GetHttpInterface.getHttpInterface("http://180.168.57.114:9019/pdsafe/LineSms/getAccidentSubmitAll.do?" | |
| 997 | - + "submitDateBegin="+startTime+"&submitDateEnd="+endTime); | |
| 998 | - List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(accidentAll); | |
| 999 | - return list; | |
| 1000 | - } | |
| 1001 | - | |
| 1002 | - | |
| 1003 | - /* | |
| 1004 | - * 事故数据接口结束 | |
| 1005 | - */ | |
| 1006 | - | |
| 1007 | - /* | |
| 1008 | - *安全驾驶接口开始 | |
| 1009 | - */ | |
| 1010 | - @GET | |
| 1011 | - @Path("/safedriving/starDate/{starDate}/endDate/{endDate}") | |
| 1012 | - public List<Map<String, Object>> findSafedriving(@PathParam("starDate") String starDate, | |
| 1013 | - @PathParam("endDate") String endDate) { | |
| 1014 | - String accidentAll= GetHttpInterface.getHttpInterface("http://211.95.61.66:9006/safedriving/safedrivingInterface?StarTime="+starDate+"&EndTime="+endDate); | |
| 1015 | - List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(accidentAll); | |
| 1016 | - return list; | |
| 1017 | - } | |
| 1018 | - @GET | |
| 1019 | - @Path("/safedriving/starDate/{starDate}/endDate/{endDate}/line/{line}") | |
| 1020 | - public List<Map<String, Object>> findSafedrivingByLine(@PathParam("starDate") String starDate, | |
| 1021 | - @PathParam("endDate") String endDate,@PathParam("line") String line) { | |
| 1022 | - String accidentAll= GetHttpInterface.getHttpInterface("http://211.95.61.66:9006/safedriving/safedrivingInterface?StarTime="+starDate+"&EndTime="+endDate | |
| 1023 | - +"&LineId="+line); | |
| 1024 | - List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(accidentAll); | |
| 1025 | - return list; | |
| 1026 | - } | |
| 1027 | - /* | |
| 1028 | - *安全驾驶接口结束 | |
| 1029 | - */ | |
| 1030 | - | |
| 1031 | - | |
| 1032 | - /** | |
| 1033 | - * 闵行线路班次里程 | |
| 1034 | - * | |
| 1035 | - * | |
| 1036 | - * | |
| 1037 | - */ | |
| 1038 | - | |
| 1039 | - @GET | |
| 1040 | - @Path("/findByAll/starDate/{starDate}/endDate/{endDate}/line/{line}") | |
| 1041 | - public List<Map<String, Object>> findMinhang(@PathParam("starDate") String starDate, | |
| 1042 | - @PathParam("endDate") String endDate,@PathParam("line") String line) { | |
| 1043 | - String sql="select xl,xl_name,date,jhszfcs,sjszfczds,jhbc,sjbc,jhcc,sjcc," | |
| 1044 | - + " jhyylc,sjyylc,jhkslc,sjkslc,jhssgfbcs,sjgfbcs,jhssdgbcs," | |
| 1045 | - + " sjdgbcs from bsth_c_calc_count " | |
| 1046 | - + " where date>='"+starDate+"' and date<= '"+endDate+"'"; | |
| 1047 | - if(!line.equals("all")){ | |
| 1048 | - sql +=" and xl='"+line+"'"; | |
| 1049 | - } | |
| 1050 | - | |
| 1051 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1052 | - new RowMapper<Map<String, Object>>(){ | |
| 1053 | - @Override | |
| 1054 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1055 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1056 | - m.put("lineCode",rs.getString("xl")); | |
| 1057 | - m.put("lineName", rs.getString("xl_name")); | |
| 1058 | - m.put("date", rs.getString("date")); | |
| 1059 | - m.put("jhszfcs", rs.getString("jhszfcs")); | |
| 1060 | - m.put("sjszfczds", rs.getString("sjszfczds")); | |
| 1061 | - m.put("jhbc", rs.getString("jhbc")); | |
| 1062 | - m.put("sjbc", rs.getString("sjbc")); | |
| 1063 | - m.put("jhcc", rs.getString("jhcc")); | |
| 1064 | - m.put("sjcc", rs.getString("sjcc")); | |
| 1065 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 1066 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 1067 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 1068 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 1069 | - m.put("jhgfbcs", rs.getString("jhssgfbcs")); | |
| 1070 | - m.put("sjgfbcs", rs.getString("sjgfbcs")); | |
| 1071 | - m.put("jhdgbcs", rs.getString("jhssdgbcs")); | |
| 1072 | - m.put("sjdgbcs", rs.getString("sjdgbcs")); | |
| 1073 | - return m; | |
| 1074 | - } | |
| 1075 | - }); | |
| 1076 | - return list; | |
| 1077 | - } | |
| 1078 | - | |
| 1079 | - /** | |
| 1080 | - * 赵冲需要的数据接口 | |
| 1081 | - * | |
| 1082 | - */ | |
| 1083 | - @GET | |
| 1084 | - @Path("/findByCompany/{company}/date/{date}") | |
| 1085 | - public List<Map<String, Object>> findByCompany(@PathParam("company") String company, | |
| 1086 | - @PathParam("date") String date) { | |
| 1087 | - String sql="select t.company as gs_code,t.date,SUM(t.jhcczgf) as jhccs ,SUM(t.sjcczgf) as ccs,AVG(ccl) as ccl" | |
| 1088 | - + " ,SUM(t.sjzgl*1000)/1000 as sum_mileage ,SUM(jcgl*1000)/1000 as airpor_mileage " | |
| 1089 | - + " from (select a.line_code,b.date,a.company,b.jhcczgf,b.sjcczgf," | |
| 1090 | - + " round(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0)),3) as ccl,c.sjzgl ," | |
| 1091 | - + " ifnull(d.sjzgl,0) as jcgl from bsth_c_line a LEFT JOIN " | |
| 1092 | - + " (SELECT * from bsth_c_calc_sheet where date='"+date+"') b on a.line_code=b.xl" | |
| 1093 | - + " left join (select * from bsth_c_calc_count where date='"+date+"') c on a.line_code=c.xl " | |
| 1094 | - + " left join (select * from bsth_c_calc_count where date='"+date+"' " | |
| 1095 | - + " and xl_name like '%机场%') d on a.line_code=d.xl " | |
| 1096 | - + " where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl')) t " | |
| 1097 | - + " where t.date is not null "; | |
| 1098 | - if(!company.equals("all")){ | |
| 1099 | - sql +=" and t.company='"+company+"'"; | |
| 1100 | - } | |
| 1101 | - sql +=" group by t.company,t.date"; | |
| 1102 | - | |
| 1103 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1104 | - new RowMapper<Map<String, Object>>(){ | |
| 1105 | - @Override | |
| 1106 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1107 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1108 | - m.put("gs_name", getGs(rs.getString("gs_code"))); | |
| 1109 | - m.put("gs_code",rs.getString("gs_code")); | |
| 1110 | - m.put("date", rs.getString("date")); | |
| 1111 | - m.put("jhccs", rs.getString("jhccs")); | |
| 1112 | - m.put("ccs", rs.getString("ccs")); | |
| 1113 | - m.put("ccl", rs.getString("ccl")); | |
| 1114 | - m.put("sum_mileage", rs.getString("sum_mileage")); | |
| 1115 | - m.put("airpor_mileage", rs.getString("airpor_mileage")); | |
| 1116 | - return m; | |
| 1117 | - } | |
| 1118 | - }); | |
| 1119 | - return list; | |
| 1120 | - } | |
| 1121 | - @GET | |
| 1122 | - @Path("/findTarget/gs/{gs}/fgs/{fgs}/date/{date}") | |
| 1123 | - public List<Map<String, Object>> findTarget(@PathParam("gs") String gs,@PathParam("fgs") String fgs, | |
| 1124 | - @PathParam("date") String date) { | |
| 1125 | - SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); | |
| 1126 | - String d=sdf.format(new Date()); | |
| 1127 | - String sql=""; | |
| 1128 | - if(gs.equals("all")){ | |
| 1129 | - sql ="select x.gsdm,'' as fgsdm,x.smb_zdl,x.zgf_ccl,y.yylc_zxl,y.szfc_zdl,y.bc_zxl from (" | |
| 1130 | - + " select b.gsdm,round(avg(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0))),3)* 100 as zgf_ccl," | |
| 1131 | - + " round(avg(ifnull(b.smbfczdl,0)),3) as smb_zdl from " | |
| 1132 | - + " bsth_c_calc_sheet b where b.date like '%"+date+"%' and b.date<'"+d+"' " | |
| 1133 | - + " and b.xl in(select a.line_code from bsth_c_line a where " | |
| 1134 | - + " a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) group by b.gsdm ) x " | |
| 1135 | - + " left join (select c.gsdm,round(avg(if(CONVERT(c.yylczxl,DECIMAL(9,2))>100,100,c.yylczxl)),3) as yylc_zxl," | |
| 1136 | - + " round(avg(if(CONVERT(c.szfczdl,DECIMAL(9,2))>100,100,c.szfczdl)),3) as szfc_zdl," | |
| 1137 | - + " round(avg(if(CONVERT(c.bczxl,DECIMAL(9,2))>100,100,c.bczxl)),3) as bc_zxl " | |
| 1138 | - + " from bsth_c_calc_count c where c.date like '%"+date+"%' and c.date<'"+d+"' and " | |
| 1139 | - + " c.xl in(select a.line_code from bsth_c_line a where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) " | |
| 1140 | - + " group by c.gsdm ) y on x.gsdm=y.gsdm where 1=1 "; | |
| 1141 | - | |
| 1142 | - }else{ | |
| 1143 | - sql ="select x.gsdm,x.fgsdm,x.smb_zdl,x.zgf_ccl,y.yylc_zxl,y.szfc_zdl,y.bc_zxl from (" | |
| 1144 | - + " select b.gsdm,b.fgsdm,round(avg(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0))),3) * 100 as zgf_ccl," | |
| 1145 | - + " round(avg(ifnull(b.smbfczdl,0)),3) as smb_zdl from " | |
| 1146 | - + " bsth_c_calc_sheet b where b.date like '%"+date+"%' and b.date<'"+d+"' " | |
| 1147 | - + " and b.xl in(select a.line_code from bsth_c_line a where " | |
| 1148 | - + " a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) group by b.gsdm,b.fgsdm ) x " | |
| 1149 | - + " left join (select c.gsdm,c.fgsdm,round(avg(if(CONVERT(c.yylczxl,DECIMAL(9,2))>100,100,c.yylczxl)),3) as yylc_zxl," | |
| 1150 | - + " round(avg(if(CONVERT(c.szfczdl,DECIMAL(9,2))>100,100,c.szfczdl)),3) as szfc_zdl," | |
| 1151 | - + " round(avg(if(CONVERT(c.bczxl,DECIMAL(9,2))>100,100,c.bczxl)),3) as bc_zxl " | |
| 1152 | - + " from bsth_c_calc_count c where c.date like '%"+date+"%' and c.date <'"+d+"' and " | |
| 1153 | - + " c.xl in(select a.line_code from bsth_c_line a where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) " | |
| 1154 | - + " group by c.gsdm,c.fgsdm ) y on x.gsdm=y.gsdm and x.fgsdm=y.fgsdm where 1=1 "; | |
| 1155 | - | |
| 1156 | - } | |
| 1157 | - if(!gs.equals("all")){ | |
| 1158 | - sql += " and x.gsdm='"+gs+"'"; | |
| 1159 | - } | |
| 1160 | - | |
| 1161 | - if(!fgs.equals("all")){ | |
| 1162 | - sql += " and x.fgsdm='"+fgs+"'"; | |
| 1163 | - } | |
| 1164 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1165 | - new RowMapper<Map<String, Object>>(){ | |
| 1166 | - @Override | |
| 1167 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1168 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1169 | - m.put("gsdm", getGs(rs.getString("gsdm"))); | |
| 1170 | - m.put("fgsdm",rs.getString("fgsdm")); | |
| 1171 | - m.put("smb_zdl", rs.getString("smb_zdl")); | |
| 1172 | - m.put("zgf_ccl", rs.getString("zgf_ccl")); | |
| 1173 | - m.put("yylc_zxl", rs.getString("yylc_zxl")); | |
| 1174 | - m.put("szfc_zdl", rs.getString("szfc_zdl")); | |
| 1175 | - m.put("bc_zxl", rs.getString("bc_zxl")); | |
| 1176 | - return m; | |
| 1177 | - } | |
| 1178 | - }); | |
| 1179 | - return list; | |
| 1180 | - } | |
| 1181 | - | |
| 1182 | - | |
| 1183 | - /** | |
| 1184 | - *公司内部使用数据 | |
| 1185 | - * | |
| 1186 | - *班次里程基础数据接口 | |
| 1187 | - */ | |
| 1188 | - @GET | |
| 1189 | - @Path("/basicData/starDate/{starDate}/endDate/{endDate}/line/{line}") | |
| 1190 | - public List<Map<String, Object>> basicData(@PathParam("starDate") String starDate, | |
| 1191 | - @PathParam("endDate") String endDate,@PathParam("line") String line) { | |
| 1192 | - String sql="select gsdm,fgsdm,xl,xl_name,date,jhbc,sjbc," | |
| 1193 | - + " jhyylc,sjyylc,jhkslc,sjkslc,jhgfbcsz,sjgfbcs,jhdgbcsz," | |
| 1194 | - + " sjdgbcs from bsth_c_calc_count " | |
| 1195 | - + " where date>='"+starDate+"' and date<= '"+endDate+"'"; | |
| 1196 | - if(!line.equals("all")){ | |
| 1197 | - sql +=" and xl='"+line+"'"; | |
| 1198 | - } | |
| 1199 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1200 | - new RowMapper<Map<String, Object>>(){ | |
| 1201 | - @Override | |
| 1202 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1203 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1204 | - m.put("gsdm",rs.getString("gsdm")); | |
| 1205 | - m.put("fgsdm",rs.getString("fgsdm")); | |
| 1206 | - m.put("lineCode",rs.getString("xl")); | |
| 1207 | - m.put("lineName", rs.getString("xl_name")); | |
| 1208 | - m.put("date", rs.getString("date")); | |
| 1209 | - m.put("jhbc", rs.getString("jhbc")); | |
| 1210 | - m.put("sjbc", rs.getString("sjbc")); | |
| 1211 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 1212 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 1213 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 1214 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 1215 | - m.put("jhgfbcs", rs.getString("jhgfbcsz")); | |
| 1216 | - m.put("sjgfbcs", rs.getString("sjgfbcs")); | |
| 1217 | - m.put("jhdgbcs", rs.getString("jhdgbcsz")); | |
| 1218 | - m.put("sjdgbcs", rs.getString("sjdgbcs")); | |
| 1219 | - return m; | |
| 1220 | - } | |
| 1221 | - }); | |
| 1222 | - return list; | |
| 1223 | - } | |
| 1224 | - | |
| 1225 | - @GET | |
| 1226 | - @Path("/targetData/starDate/{starDate}/endDate/{endDate}/line/{line}") | |
| 1227 | - public List<Map<String, Object>> targetData(@PathParam("starDate") String starDate, | |
| 1228 | - @PathParam("endDate") String endDate,@PathParam("line") String line) { | |
| 1229 | - String sql="select gsdm,fgsdm,date,xl,xl_name,szfczdl,smbfczdl," | |
| 1230 | - + " round(if(ifnull(sjcczgf/jhcczgf,0)>1,1,ifnull(sjcczgf/jhcczgf,0)),3) * 100 as zgfccl , " | |
| 1231 | - + " round(if(ifnull(sjcc/jhcc,0)>1,1,ifnull(sjcc/jhcc,0)),3) * 100 as ccl from bsth_c_calc_sheet " | |
| 1232 | - + " where date>='"+starDate+"' and date<= '"+endDate+"'"; | |
| 1233 | - if(!line.equals("all")){ | |
| 1234 | - sql +=" and xl='"+line+"'"; | |
| 1235 | - } | |
| 1236 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1237 | - new RowMapper<Map<String, Object>>(){ | |
| 1238 | - @Override | |
| 1239 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1240 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1241 | - m.put("gsdm",rs.getString("gsdm")); | |
| 1242 | - m.put("fgsdm",rs.getString("fgsdm")); | |
| 1243 | - m.put("lineCode",rs.getString("xl")); | |
| 1244 | - m.put("lineName", rs.getString("xl_name")); | |
| 1245 | - m.put("date", rs.getString("date")); | |
| 1246 | - m.put("szfczdl", rs.getString("szfczdl")); | |
| 1247 | - m.put("smbfczdl", rs.getString("smbfczdl")); | |
| 1248 | - m.put("zgfccl", rs.getString("zgfccl")); | |
| 1249 | - m.put("ccl", rs.getString("ccl")); | |
| 1250 | - return m; | |
| 1251 | - } | |
| 1252 | - }); | |
| 1253 | - return list; | |
| 1254 | - } | |
| 1255 | - | |
| 1256 | - @GET | |
| 1257 | - @Path("/departureTime/starDate/{starDate}/endDate/{endDate}/line/{line}") | |
| 1258 | - public List<Map<String, Object>> departureTime(@PathParam("starDate") String starDate, | |
| 1259 | - @PathParam("endDate") String endDate,@PathParam("line") String line) { | |
| 1260 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 1261 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 1262 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 1263 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 1264 | - + " jhszfcs,sjszfczds,szfczdl," | |
| 1265 | - + " create_date from bsth_c_calc_count " | |
| 1266 | - + " where date>='"+starDate+"' and date<= '"+endDate+"'"; | |
| 1267 | - if(!line.equals("all")){ | |
| 1268 | - sql +=" and xl='"+line+"'"; | |
| 1269 | - } | |
| 1270 | - | |
| 1271 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1272 | - new RowMapper<Map<String, Object>>(){ | |
| 1273 | - @Override | |
| 1274 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1275 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1276 | - m.put("lineCode",rs.getString("xl")); | |
| 1277 | - m.put("lineName", rs.getString("xl_name")); | |
| 1278 | - m.put("date", rs.getString("date")); | |
| 1279 | - | |
| 1280 | - m.put("jhbc", rs.getString("jhbc")); | |
| 1281 | - m.put("sjbc", rs.getString("sjbc")); | |
| 1282 | - m.put("bczxl", rs.getString("bczxl")); | |
| 1283 | - m.put("jhbcz", rs.getString("jhbcz")); | |
| 1284 | - | |
| 1285 | - m.put("jhcc", rs.getString("jhcc")); | |
| 1286 | - m.put("sjcc", rs.getString("sjcc")); | |
| 1287 | - m.put("ccl", rs.getString("ccl")); | |
| 1288 | - m.put("jhccz", rs.getString("jhccz")); | |
| 1289 | - | |
| 1290 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 1291 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 1292 | - m.put("jhyylcz", rs.getString("jhyylcz")); | |
| 1293 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 1294 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 1295 | - m.put("jhkslcz", rs.getString("jhkslcz")); | |
| 1296 | - | |
| 1297 | - m.put("jhgfbcs", rs.getString("jhssgfbcs")); | |
| 1298 | - m.put("sjgfbcs", rs.getString("sjgfbcs")); | |
| 1299 | - m.put("jhgfbcsz", rs.getString("jhgfbcsz")); | |
| 1300 | - m.put("jhdgbcs", rs.getString("jhssdgbcs")); | |
| 1301 | - m.put("sjdgbcs", rs.getString("sjdgbcs")); | |
| 1302 | - m.put("jhdgbcsz", rs.getString("jhdgbcsz")); | |
| 1303 | - | |
| 1304 | - m.put("jhsmbcs", rs.getString("jhsmbcs")); | |
| 1305 | - m.put("sjsmbczds", rs.getString("sjsmbczds")); | |
| 1306 | - m.put("smbczdl", rs.getString("smbczdl")); | |
| 1307 | - m.put("jhsmbcsz", rs.getString("jhsmbcsz")); | |
| 1308 | - m.put("sjsmbczdsz", rs.getString("sjsmbczdsz")); | |
| 1309 | - m.put("smbczdlz", rs.getString("smbczdlz")); | |
| 1310 | - | |
| 1311 | - m.put("jhszfcs", rs.getString("jhszfcs")); | |
| 1312 | - m.put("sjszfczds", rs.getString("sjszfczds")); | |
| 1313 | - m.put("szfczdl", rs.getString("szfczdl")); | |
| 1314 | - | |
| 1315 | - Date date = new Date(); | |
| 1316 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 1317 | - m.put("createDate", sdf.format(date)); | |
| 1318 | - return m; | |
| 1319 | - } | |
| 1320 | - }); | |
| 1321 | - return list; | |
| 1322 | - } | |
| 1323 | - | |
| 1324 | - /** | |
| 1325 | - * 给安全系统的接口,实际排班中的肇事烂班班次(用作事故登记) | |
| 1326 | - * @param starDate | |
| 1327 | - * @param endDate | |
| 1328 | - * @return | |
| 1329 | - * @throws ParseException | |
| 1330 | - */ | |
| 1331 | - @GET | |
| 1332 | - @Path("/getScheduleAccident/startDate/{startDate}/endDate/{endDate}") | |
| 1333 | - public List<Map<String, Object>> getScheduleAccident(@PathParam("startDate") String startDate, | |
| 1334 | - @PathParam("endDate") String endDate) throws ParseException { | |
| 1335 | - String sql="select gs_bm,fgs_bm,real_exec_date,fcsj,fcsj_actual,xl_name,j_gh,j_name,cl_zbh,car_plate,remarks " | |
| 1336 | - + " from bsth_c_s_sp_info_real r left join bsth_c_cars c on r.cl_zbh = c.inside_code " | |
| 1337 | - + " where schedule_date_str >= ? and schedule_date_str <= ? " | |
| 1338 | - + " and ((adjust_exps like '%肇事%' and status = '-1') " | |
| 1339 | - + " or (schedule_date_str < '2021-09-13' and (remarks = '肇事' " | |
| 1340 | - + " or remarks like '%;肇事%' or remarks like '%肇事;%' or remarks like '%肇事,%')) " | |
| 1341 | - + " or (schedule_date_str >= '2021-09-13' and (remarks like '%<肇事>%' " | |
| 1342 | - + " or remarks like '%<肇事>%'))) " | |
| 1343 | - + " order by real_exec_date, schedule_date_str, fcsj"; | |
| 1344 | - | |
| 1345 | - List<Map<String, Object>> list=(List<Map<String, Object>>) jdbcTemplate.query(sql, | |
| 1346 | - new Object[] {startDate, endDate}, | |
| 1347 | - new RowMapper<Map<String, Object>>(){ | |
| 1348 | - @Override | |
| 1349 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1350 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1351 | - m.put("gs_bm",rs.getString("gs_bm")); | |
| 1352 | - m.put("fgs_bm",rs.getString("fgs_bm")); | |
| 1353 | - m.put("real_exec_date",rs.getString("real_exec_date")); | |
| 1354 | - m.put("fcsj", rs.getString("fcsj")); | |
| 1355 | - m.put("fcsj_actual", rs.getString("fcsj_actual")); | |
| 1356 | - m.put("xl_name", rs.getString("xl_name")); | |
| 1357 | - m.put("j_gh", rs.getString("j_gh")); | |
| 1358 | - m.put("j_name", rs.getString("j_name")); | |
| 1359 | - m.put("cl_zbh", rs.getString("cl_zbh")); | |
| 1360 | - m.put("car_plate", rs.getString("car_plate")); | |
| 1361 | - m.put("remarks", rs.getString("remarks")); | |
| 1362 | - return m; | |
| 1363 | - } | |
| 1364 | - }); | |
| 1365 | - | |
| 1366 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 1367 | - Date d1 = sdf.parse(startDate); | |
| 1368 | - Date d2 = sdf.parse(endDate); | |
| 1369 | - while(d1.getTime() <= d2.getTime()){ | |
| 1370 | - String rq = sdf.format(d1); | |
| 1371 | - List<DestroySituation> destroys = destroySituationRepository.findByDateAndReason(rq, "肇事"); | |
| 1372 | - for(DestroySituation ds : destroys){ | |
| 1373 | - ScheduleRealInfo s = scheduleRealInfoRepository.findOne(Long.parseLong(ds.getIdsStr().split(",")[0])); | |
| 1374 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 1375 | - m.put("gs_bm", ds.getGsBm()); | |
| 1376 | - m.put("fgs_bm", ds.getFgsBm()); | |
| 1377 | - m.put("real_exec_date", rq); | |
| 1378 | - m.put("fcsj", s==null?"00:00":(s.getFcsj()!=null&&s.getFcsj().trim().length()>0?s.getFcsj():"")); | |
| 1379 | - m.put("fcsj_actual", s==null?"00:00":(s.getFcsjActual()!=null&&s.getFcsjActual().trim().length()>0?s.getFcsjActual():"")); | |
| 1380 | - m.put("xl_name", ds.getLineName()); | |
| 1381 | - m.put("j_gh", ds.getjGh()); | |
| 1382 | - m.put("j_name", s==null?"":(s.getjName()!=null&&s.getjName().trim().length()>0?s.getjName():"")); | |
| 1383 | - m.put("cl_zbh", ds.getNbbm()); | |
| 1384 | - m.put("car_plate", CarBufferData.findOne(ds.getNbbm()).getCarPlate()); | |
| 1385 | - m.put("remarks", (s==null?"":(s.getQdzName()+"->"+s.getZdzName()+";"))+ds.getRemark()); | |
| 1386 | - list.add(m); | |
| 1387 | - } | |
| 1388 | - | |
| 1389 | - d1.setTime(d1.getTime() + 1l*1000*60*60*24); | |
| 1390 | - } | |
| 1391 | - | |
| 1392 | - Collections.sort(list, new Comparator<Map<String, Object>>() { | |
| 1393 | - @Override | |
| 1394 | - public int compare(Map<String, Object> c1, Map<String, Object> c2) { | |
| 1395 | -// int i1 = Integer.valueOf(c1.get("count").toString()); | |
| 1396 | -// int i2 = Integer.valueOf(c2.get("count").toString()); | |
| 1397 | - String str1 = c1.get("real_exec_date").toString() + (c1.get("fcsj").toString().length()>0?c1.get("fcsj").toString():"00:00"); | |
| 1398 | - String str2 = c2.get("real_exec_date").toString() + (c2.get("fcsj").toString().length()>0?c2.get("fcsj").toString():"00:00"); | |
| 1399 | - Long long1 = Long.valueOf(str1.replaceAll(" ", "").replaceAll("-", "").replaceAll(":", "")); | |
| 1400 | - Long long2 = Long.valueOf(str2.replaceAll(" ", "").replaceAll("-", "").replaceAll(":", "")); | |
| 1401 | - | |
| 1402 | - long diff = long1 - long2; | |
| 1403 | - if (diff > 0) { | |
| 1404 | - return 1; | |
| 1405 | - }else if (diff < 0) { | |
| 1406 | - return -1; | |
| 1407 | - } | |
| 1408 | - return 0; //相等为0 | |
| 1409 | - } | |
| 1410 | - }); | |
| 1411 | - | |
| 1412 | - return list; | |
| 1413 | - } | |
| 1414 | - | |
| 1415 | - /** | |
| 1416 | - * 给机务(徐铉、郑鑫)按车辆统计营运公里 | |
| 1417 | - * @param starDate | |
| 1418 | - * @param endDate | |
| 1419 | - * @return | |
| 1420 | - * @throws ParseException | |
| 1421 | - */ | |
| 1422 | - @GET | |
| 1423 | - @Path("/mileageByVehicle/startDate/{startDate}/endDate/{endDate}") | |
| 1424 | - public List<Map<String, Object>> mileageByVehicle(@PathParam("startDate") String starDate, | |
| 1425 | - @PathParam("endDate") String endDate) throws ParseException { | |
| 1426 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 1427 | - | |
| 1428 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 1429 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 1430 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 1431 | - new RowMapper<Map<String, Object>>(){ | |
| 1432 | - @Override | |
| 1433 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1434 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1435 | - m.put("lineCode", rs.getString("line_code")); | |
| 1436 | - return m; | |
| 1437 | - } | |
| 1438 | - }); | |
| 1439 | - Set<String> yyLine = new HashSet<String>(); | |
| 1440 | - for(Map<String, Object> t : yyxlList){ | |
| 1441 | - if(t.get("lineCode") != null){ | |
| 1442 | - yyLine.add(t.get("lineCode").toString()); | |
| 1443 | - } | |
| 1444 | - } | |
| 1445 | - | |
| 1446 | - BigscreenService bigscreenService = new BigscreenService(); | |
| 1447 | - List<ScheduleRealInfo> dataList = scheduleRealInfoRepository.findScheduleByDates(starDate, endDate); | |
| 1448 | - Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>(); | |
| 1449 | - List<String> keyList = new ArrayList<String>(); | |
| 1450 | - | |
| 1451 | - for(ScheduleRealInfo s : dataList){ | |
| 1452 | - if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 1453 | - String dateStr = s.getScheduleDateStr(); | |
| 1454 | - String gsBm = s.getGsBm(); | |
| 1455 | - String fgsBm = s.getFgsBm(); | |
| 1456 | - String xlName = s.getXlName(); | |
| 1457 | - String cl = s.getClZbh(); | |
| 1458 | - String key = dateStr + "/" + gsBm + "/" + fgsBm + "/" + xlName + "/" + cl; | |
| 1459 | - if(!(keyMap.containsKey(key))){ | |
| 1460 | - keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | |
| 1461 | - keyList.add(key); | |
| 1462 | - } | |
| 1463 | - keyMap.get(key).add(s); | |
| 1464 | - } | |
| 1465 | - } | |
| 1466 | - | |
| 1467 | - for(String key : keyList){ | |
| 1468 | - List<ScheduleRealInfo> list = keyMap.get(key); | |
| 1469 | - List<ScheduleRealInfo> listSche = new ArrayList<ScheduleRealInfo>();//全部班次 | |
| 1470 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();//已执行班次 | |
| 1471 | - for(ScheduleRealInfo s : list){ | |
| 1472 | - listSche.add(s); | |
| 1473 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 1474 | - if (cts != null && cts.size() > 0) { | |
| 1475 | - list_s.add(s); | |
| 1476 | - } else { | |
| 1477 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 1478 | - list_s.add(s); | |
| 1479 | - } | |
| 1480 | - } | |
| 1481 | - } | |
| 1482 | - | |
| 1483 | - double sjgl = bigscreenService.culateSjgl(list_s);//实际营运公里(不含临加) | |
| 1484 | - double sjljgl = bigscreenService.culateLjgl(listSche);//实际临加公里 | |
| 1485 | - double sjyygl = Arith.add(sjgl, sjljgl);//实际营运公里 | |
| 1486 | - double sjjccgl = bigscreenService.culateJccgl(list_s); | |
| 1487 | - double sjksgl = bigscreenService.culateKsgl(list_s); | |
| 1488 | - double zksgl = Arith.add(sjjccgl, sjksgl);//实际空驶总公里 | |
| 1489 | - | |
| 1490 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 1491 | - String[] split = key.split("/"); | |
| 1492 | - m.put("date", split[0]); | |
| 1493 | - m.put("companyCode", split[1]); | |
| 1494 | - m.put("brancheCompanyCode", split[2]); | |
| 1495 | - m.put("lineName", split[3]); | |
| 1496 | - m.put("car", split[4]); | |
| 1497 | - m.put("businessMileage", sjyygl); | |
| 1498 | - m.put("emptyMileage", zksgl); | |
| 1499 | - resList.add(m); | |
| 1500 | - } | |
| 1501 | - | |
| 1502 | - return resList; | |
| 1503 | - } | |
| 1504 | - | |
| 1505 | - //全部挂牌线路 | |
| 1506 | - @GET | |
| 1507 | - @Path("/findLinePlate/all") | |
| 1508 | - public List<Map<String, Object>> findLinePlate() { | |
| 1509 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 1510 | - String gpLineSql = "select * from bsth_c_line_plate"; | |
| 1511 | - List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | |
| 1512 | - new RowMapper<Map<String, Object>>(){ | |
| 1513 | - @Override | |
| 1514 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1515 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1516 | - m.put("lineName", rs.getString("line_name")); | |
| 1517 | - m.put("lineCode", rs.getString("line_code")); | |
| 1518 | - return m; | |
| 1519 | - } | |
| 1520 | - }); | |
| 1521 | - | |
| 1522 | - for(Map<String, Object> t : gpLineList){ | |
| 1523 | - if(t.get("lineCode") == null || t.get("lineCode").toString().trim().length() == 0){ | |
| 1524 | - t.put("lineCode", ""); | |
| 1525 | - } | |
| 1526 | - resList.add(t); | |
| 1527 | - } | |
| 1528 | - return resList; | |
| 1529 | - } | |
| 1530 | - | |
| 1531 | - //人车班次里程预统计查询 | |
| 1532 | - @GET | |
| 1533 | - @Path("/findWaybill/startDate/{startDate}/endDate/{endDate}") | |
| 1534 | - public List<Map<String, Object>> findWaybill(@PathParam("startDate") String startDate, | |
| 1535 | - @PathParam("endDate") String endDate) { | |
| 1536 | - String sql = "select * from calc_waybill where rq_str >= ? and rq_str <= ?"; | |
| 1537 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1538 | - new Object[] {startDate, endDate}, | |
| 1539 | - new RowMapper<Map<String, Object>>(){ | |
| 1540 | - @Override | |
| 1541 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1542 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1543 | - m.put("gsdm", rs.getString("gsdm")); | |
| 1544 | - m.put("gsname", rs.getString("gsname")); | |
| 1545 | - m.put("fgsdm", rs.getString("fgsdm")); | |
| 1546 | - m.put("fgsname", rs.getString("fgsname")); | |
| 1547 | - m.put("rqStr", rs.getString("rq_str")); | |
| 1548 | - m.put("xl", rs.getString("xl")); | |
| 1549 | - m.put("xlName", rs.getString("xl_name")); | |
| 1550 | - m.put("cl", rs.getString("cl")); | |
| 1551 | - m.put("lp", rs.getString("lp")); | |
| 1552 | - m.put("jGh", rs.getString("j_gh")); | |
| 1553 | - m.put("jName", rs.getString("j_name")); | |
| 1554 | - m.put("sGh", rs.getString("s_gh")); | |
| 1555 | - m.put("sName", rs.getString("s_name")); | |
| 1556 | - m.put("jhyybc", rs.getInt("jhyybc")); | |
| 1557 | - m.put("jhyybczgf", rs.getInt("jhyybczgf")); | |
| 1558 | - m.put("jhyybcwgf", rs.getInt("jhyybcwgf")); | |
| 1559 | - m.put("jhfyybc", rs.getInt("jhfyybc")); | |
| 1560 | - m.put("jhyylc", rs.getDouble("jhyylc")); | |
| 1561 | - m.put("jhfyylc", rs.getDouble("jhfyylc")); | |
| 1562 | - m.put("sjyybc", rs.getInt("sjyybc")); | |
| 1563 | - m.put("sjyybczgf", rs.getInt("sjyybczgf")); | |
| 1564 | - m.put("sjyybcwgf", rs.getInt("sjyybcwgf")); | |
| 1565 | - m.put("sjfyybc", rs.getInt("sjfyybc")); | |
| 1566 | - m.put("sjyylc", rs.getDouble("sjyylc")); | |
| 1567 | - m.put("sjfyylc", rs.getDouble("sjfyylc")); | |
| 1568 | - m.put("ljbc", rs.getInt("ljbc")); | |
| 1569 | - m.put("ljbczgf", rs.getInt("ljbczgf")); | |
| 1570 | - m.put("ljbcwgf", rs.getInt("ljbcwgf")); | |
| 1571 | - m.put("ljyylc", rs.getDouble("ljyylc")); | |
| 1572 | - m.put("ljfyylc", rs.getDouble("ljfyylc")); | |
| 1573 | - m.put("lbbc", rs.getInt("lbbc")); | |
| 1574 | - m.put("lblc", rs.getDouble("lblc")); | |
| 1575 | - m.put("lblcLz", rs.getDouble("lblc_lz")); | |
| 1576 | - m.put("lblcDm", rs.getDouble("lblc_dm")); | |
| 1577 | - m.put("lblcGz", rs.getDouble("lblc_gz")); | |
| 1578 | - m.put("lblcJf", rs.getDouble("lblc_jf")); | |
| 1579 | - m.put("lblcZs", rs.getDouble("lblc_zs")); | |
| 1580 | - m.put("lblcQr", rs.getDouble("lblc_qr")); | |
| 1581 | - m.put("lblcQc", rs.getDouble("lblc_qc")); | |
| 1582 | - m.put("lblcKx", rs.getDouble("lblc_kx")); | |
| 1583 | - m.put("lblcQh", rs.getDouble("lblc_qh")); | |
| 1584 | - m.put("lblcYw", rs.getDouble("lblc_yw")); | |
| 1585 | - m.put("lblcQt", rs.getDouble("lblc_qt")); | |
| 1586 | - m.put("fzbc", rs.getInt("fzbc")); | |
| 1587 | - m.put("fzbczgf", rs.getInt("fzbczgf")); | |
| 1588 | - m.put("fzbcwgf", rs.getInt("fzbcwgf")); | |
| 1589 | - m.put("dtbc", rs.getInt("dtbc")); | |
| 1590 | - m.put("dtbczgf", rs.getInt("dtbczgf")); | |
| 1591 | - m.put("dtbcwgf", rs.getInt("dtbcwgf")); | |
| 1592 | - return m; | |
| 1593 | - } | |
| 1594 | - }); | |
| 1595 | - | |
| 1596 | - return list; | |
| 1597 | - } | |
| 1598 | - | |
| 1599 | - //人车里程预统计查询(预计給上电科) | |
| 1600 | - @GET | |
| 1601 | - @Path("/findKilometre/startDate/{startDate}/endDate/{endDate}") | |
| 1602 | - public List<Map<String, Object>> findKilometre(@PathParam("startDate") String startDate, | |
| 1603 | - @PathParam("endDate") String endDate) { | |
| 1604 | - String sql = "select * from calc_waybill where rq_str >= ? and rq_str <= ?"; | |
| 1605 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1606 | - new Object[] {startDate, endDate}, | |
| 1607 | - new RowMapper<Map<String, Object>>(){ | |
| 1608 | - @Override | |
| 1609 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1610 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1611 | - m.put("gsdm", rs.getString("gsdm")); | |
| 1612 | - m.put("gsname", rs.getString("gsname")); | |
| 1613 | - m.put("fgsdm", rs.getString("fgsdm")); | |
| 1614 | - m.put("fgsname", rs.getString("fgsname")); | |
| 1615 | - m.put("rqStr", rs.getString("rq_str")); | |
| 1616 | - m.put("xl", rs.getString("xl")); | |
| 1617 | - m.put("xlName", rs.getString("xl_name")); | |
| 1618 | - m.put("cl", rs.getString("cl")); | |
| 1619 | - m.put("lp", rs.getString("lp")); | |
| 1620 | - m.put("jGh", rs.getString("j_gh")); | |
| 1621 | - m.put("jName", rs.getString("j_name")); | |
| 1622 | - m.put("sGh", rs.getString("s_gh")); | |
| 1623 | - m.put("sName", rs.getString("s_name")); | |
| 1624 | - m.put("jhyylc", rs.getDouble("jhyylc")); | |
| 1625 | - m.put("jhfyylc", rs.getDouble("jhfyylc")); | |
| 1626 | - m.put("sjyylc", rs.getDouble("sjyylc")); | |
| 1627 | - m.put("sjfyylc", rs.getDouble("sjfyylc")); | |
| 1628 | - m.put("ljyylc", rs.getDouble("ljyylc")); | |
| 1629 | - m.put("ljfyylc", rs.getDouble("ljfyylc")); | |
| 1630 | - return m; | |
| 1631 | - } | |
| 1632 | - }); | |
| 1633 | - | |
| 1634 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 1635 | - for(Map<String, Object> m : list){ | |
| 1636 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 1637 | - BigDecimal jhyylc = new BigDecimal(m.get("jhyylc")!=null?m.get("jhyylc").toString():"0"); | |
| 1638 | - BigDecimal jhfyylc = new BigDecimal(m.get("jhfyylc")!=null?m.get("jhfyylc").toString():"0"); | |
| 1639 | - BigDecimal sjyylc = new BigDecimal(m.get("sjyylc")!=null?m.get("sjyylc").toString():"0"); | |
| 1640 | - BigDecimal sjfyylc = new BigDecimal(m.get("sjfyylc")!=null?m.get("sjfyylc").toString():"0"); | |
| 1641 | - BigDecimal ljyylc = new BigDecimal(m.get("ljyylc")!=null?m.get("ljyylc").toString():"0"); | |
| 1642 | - BigDecimal ljfyylc = new BigDecimal(m.get("ljfyylc")!=null?m.get("ljfyylc").toString():"0"); | |
| 1643 | - resMap.put("planAll", jhyylc.add(jhfyylc)); | |
| 1644 | - resMap.put("realAll", sjyylc.add(sjfyylc).add(ljyylc).add(ljfyylc)); | |
| 1645 | - resMap.put("planService", jhyylc); | |
| 1646 | - resMap.put("planNonService", jhfyylc); | |
| 1647 | - resMap.put("RealService", sjyylc.add(ljyylc)); | |
| 1648 | - resMap.put("RealNonService", sjfyylc.add(ljfyylc)); | |
| 1649 | - resMap.put("companyCode", m.get("gsdm")); | |
| 1650 | - resMap.put("companyName", m.get("gsname")); | |
| 1651 | - resMap.put("branchCompanyCode", m.get("fgsdm")); | |
| 1652 | - resMap.put("branchCompanyName", m.get("fgsname")); | |
| 1653 | - resMap.put("date", m.get("rqStr")); | |
| 1654 | - resMap.put("lineCode", m.get("xl")); | |
| 1655 | - resMap.put("lineName", m.get("xlName")); | |
| 1656 | - resMap.put("car", m.get("cl")); | |
| 1657 | - resMap.put("guideboard", m.get("lp")); | |
| 1658 | - resMap.put("driverCode", m.get("jGh")); | |
| 1659 | - resMap.put("driverName", m.get("jName")); | |
| 1660 | - resMap.put("conductorCode", m.get("sGh")); | |
| 1661 | - resMap.put("conductorName", m.get("sName")); | |
| 1662 | - resList.add(resMap); | |
| 1663 | - } | |
| 1664 | - | |
| 1665 | - return resList; | |
| 1666 | - } | |
| 1667 | - | |
| 1668 | - //单日每车油耗电耗 | |
| 1669 | - @GET | |
| 1670 | - @Path("/findCarEnergySupplement/{date}") | |
| 1671 | - public Map<String, Object> findWaybill(@PathParam("date") String date) { | |
| 1672 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 1673 | - | |
| 1674 | - date = date + " 00:00:00"; | |
| 1675 | - | |
| 1676 | - String ylbSql = "select nbbm, sum(yh) yh from bsth_c_ylb where rq = str_to_date(?, '%Y-%m-%d') group by nbbm"; | |
| 1677 | - List<Map<String, Object>> ylbList=jdbcTemplate.query(ylbSql, | |
| 1678 | - new Object[] {date}, | |
| 1679 | - new RowMapper<Map<String, Object>>(){ | |
| 1680 | - @Override | |
| 1681 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1682 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1683 | - m.put("car", rs.getString("nbbm")); | |
| 1684 | - m.put("liters", new BigDecimal(rs.getDouble("yh")).setScale(2, RoundingMode.HALF_UP)); | |
| 1685 | - return m; | |
| 1686 | - } | |
| 1687 | - }); | |
| 1688 | - | |
| 1689 | - String dlbSql = "select nbbm, sum(hd) hd from bsth_c_dlb where rq = str_to_date(?, '%Y-%m-%d') group by nbbm"; | |
| 1690 | - List<Map<String, Object>> dlbList=jdbcTemplate.query(dlbSql, | |
| 1691 | - new Object[] {date}, | |
| 1692 | - new RowMapper<Map<String, Object>>(){ | |
| 1693 | - @Override | |
| 1694 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1695 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1696 | - m.put("car", rs.getString("nbbm")); | |
| 1697 | - m.put("degrees", new BigDecimal(rs.getDouble("hd")).setScale(2, RoundingMode.HALF_UP)); | |
| 1698 | - return m; | |
| 1699 | - } | |
| 1700 | - }); | |
| 1701 | - | |
| 1702 | - resMap.put("oilList", ylbList); | |
| 1703 | - resMap.put("electricList", dlbList); | |
| 1704 | - return resMap; | |
| 1705 | - } | |
| 1706 | - | |
| 1707 | - /** | |
| 1708 | - * 给安全系统,按驾驶员统计公里 | |
| 1709 | - * @param starDate | |
| 1710 | - * @param endDate | |
| 1711 | - * @return | |
| 1712 | - * @throws ParseException | |
| 1713 | - */ | |
| 1714 | - @GET | |
| 1715 | - @Path("/mileageByDriver/startDate/{startDate}/endDate/{endDate}") | |
| 1716 | - public List<Map<String, Object>> mileageByDriver(@PathParam("startDate") String starDate, | |
| 1717 | - @PathParam("endDate") String endDate) throws ParseException { | |
| 1718 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 1719 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 1720 | - Date date1 = sdf.parse(starDate); | |
| 1721 | - Date date2 = sdf.parse(endDate); | |
| 1722 | - | |
| 1723 | - String yyxlSql="SELECT gsdm, gsname, fgsdm, fgsname, rq_str, xl_name, j_gh, j_name," | |
| 1724 | - + " sjyylc, sjfyylc, ljyylc, ljfyylc" | |
| 1725 | - + " from calc_waybill" | |
| 1726 | - + " where rq between ? and ?"; | |
| 1727 | - List<Map<String, Object>> calcList=jdbcTemplate.query(yyxlSql, new Object[]{date1, date2}, | |
| 1728 | - new RowMapper<Map<String, Object>>(){ | |
| 1729 | - @Override | |
| 1730 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1731 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1732 | - m.put("gsdm", rs.getString("gsdm")); | |
| 1733 | - m.put("gsname", rs.getString("gsname")); | |
| 1734 | - m.put("fgsdm", rs.getString("fgsdm")); | |
| 1735 | - m.put("fgsname", rs.getString("fgsname")); | |
| 1736 | - m.put("rq_str", rs.getString("rq_str")); | |
| 1737 | - m.put("xl_name", rs.getString("xl_name")); | |
| 1738 | - m.put("j_gh", rs.getString("j_gh")); | |
| 1739 | - m.put("j_name", rs.getString("j_name")); | |
| 1740 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 1741 | - m.put("sjfyylc", rs.getString("sjfyylc")); | |
| 1742 | - m.put("ljyylc", rs.getString("ljyylc")); | |
| 1743 | - m.put("ljfyylc", rs.getString("ljfyylc")); | |
| 1744 | - return m; | |
| 1745 | - } | |
| 1746 | - }); | |
| 1747 | - | |
| 1748 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | |
| 1749 | - for(Map<String, Object> m : calcList){ | |
| 1750 | - String rqStr = m.get("rq_str").toString(); | |
| 1751 | - String gsdm = m.get("gsdm").toString(); | |
| 1752 | - String fgsdm = m.get("fgsdm").toString(); | |
| 1753 | - String gh = m.get("j_gh").toString(); | |
| 1754 | - String name = m.get("j_name").toString(); | |
| 1755 | - String key = rqStr + "/" + gsdm + "/" + fgsdm + "/" + gh + "/" + name; | |
| 1756 | - if(!keyMap.containsKey(key)){ | |
| 1757 | - Map<String, Object> temp = new HashMap<String, Object>(); | |
| 1758 | - temp.put("date", rqStr); | |
| 1759 | - temp.put("company", gsdm); | |
| 1760 | - temp.put("brancheCompany", fgsdm); | |
| 1761 | - temp.put("gh", gh); | |
| 1762 | - temp.put("name", name); | |
| 1763 | - temp.put("mileage", "0"); | |
| 1764 | - keyMap.put(key, temp); | |
| 1765 | - } | |
| 1766 | - Map<String, Object> temp = keyMap.get(key); | |
| 1767 | - BigDecimal mileage = new BigDecimal(temp.get("mileage").toString()); | |
| 1768 | - BigDecimal sjyylc = new BigDecimal(m.get("sjyylc").toString()); | |
| 1769 | - BigDecimal sjfyylc = new BigDecimal(m.get("sjfyylc").toString()); | |
| 1770 | - BigDecimal ljyylc = new BigDecimal(m.get("ljyylc").toString()); | |
| 1771 | - BigDecimal ljfyylc = new BigDecimal(m.get("ljfyylc").toString()); | |
| 1772 | - temp.put("mileage", mileage.add(sjyylc).add(sjfyylc).add(ljyylc).add(ljfyylc)); | |
| 1773 | - } | |
| 1774 | - | |
| 1775 | - for(String key : keyMap.keySet()){ | |
| 1776 | - Map<String, Object> m = keyMap.get(key); | |
| 1777 | - resList.add(m); | |
| 1778 | - } | |
| 1779 | - | |
| 1780 | - return resList; | |
| 1781 | - } | |
| 1782 | - | |
| 1783 | - /** | |
| 1784 | - * 车辆的班次里程与油电耗(给郑鑫) | |
| 1785 | - * @param date | |
| 1786 | - * @return | |
| 1787 | - * @throws ParseException | |
| 1788 | - */ | |
| 1789 | - @GET | |
| 1790 | - @Path("/scheduleAndMileage/date/{date}") | |
| 1791 | - public List<Map<String, Object>> scheduleAndMileage(@PathParam("date") String date) throws ParseException { | |
| 1792 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 1793 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 1794 | - Date rq = sdf.parse(date); | |
| 1795 | - | |
| 1796 | - String xlSql="SELECT line_code, name, nature, ifnull(warrant_car, '') warrant_car" | |
| 1797 | - + " from bsth_c_line where name is not null and name != ''"; | |
| 1798 | - List<Map<String, Object>> xlList=jdbcTemplate.query(xlSql, | |
| 1799 | - new RowMapper<Map<String, Object>>(){ | |
| 1800 | - @Override | |
| 1801 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1802 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1803 | - m.put("lineCode", rs.getString("line_code")); | |
| 1804 | - m.put("lineName", rs.getString("name")); | |
| 1805 | - m.put("nature", rs.getString("nature")); | |
| 1806 | - m.put("warrantCar", rs.getString("warrant_car")); | |
| 1807 | - return m; | |
| 1808 | - } | |
| 1809 | - }); | |
| 1810 | - Set<String> yyLine = new HashSet<String>(); | |
| 1811 | - Map<String, Object> allLineMap = new HashMap<String, Object>(); | |
| 1812 | - Map<String, String> warrantCarMap = new HashMap<String, String>(); | |
| 1813 | - for(Map<String, Object> t : xlList){ | |
| 1814 | - if(t.get("lineCode") != null){ | |
| 1815 | - allLineMap.put(t.get("lineCode").toString(), t.get("lineName").toString()); | |
| 1816 | - warrantCarMap.put(t.get("lineCode").toString(), t.get("warrantCar").toString()); | |
| 1817 | - String nature = t.get("nature")!=null?t.get("nature").toString():""; | |
| 1818 | - if("yxl".equals(nature) || "cgxl".equals(nature) || "gjxl".equals(nature) | |
| 1819 | - || "csbs".equals(nature) || "cctxl".equals(nature)){ | |
| 1820 | - yyLine.add(t.get("lineCode").toString()); | |
| 1821 | - } | |
| 1822 | - } | |
| 1823 | - } | |
| 1824 | - | |
| 1825 | - String sql="SELECT gsdm, gsname, fgsdm, fgsname, rq_str, xl, xl_name, cl," | |
| 1826 | - + " jhyybc, jhfyybc, sjyybc, sjfyybc, ljbc, jhyylc, jhfyylc," | |
| 1827 | - + " sjyylc, sjfyylc, ljyylc, ljfyylc" | |
| 1828 | - + " from calc_waybill" | |
| 1829 | - + " where rq = ? "; | |
| 1830 | - List<Map<String, Object>> calcList=jdbcTemplate.query(sql, new Object[]{rq}, | |
| 1831 | - new RowMapper<Map<String, Object>>(){ | |
| 1832 | - @Override | |
| 1833 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1834 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1835 | - m.put("gsdm", rs.getString("gsdm")); | |
| 1836 | - m.put("gsname", rs.getString("gsname")); | |
| 1837 | - m.put("fgsdm", rs.getString("fgsdm")); | |
| 1838 | - m.put("fgsname", rs.getString("fgsname")); | |
| 1839 | - m.put("rq_str", rs.getString("rq_str")); | |
| 1840 | - m.put("xl", rs.getString("xl")); | |
| 1841 | - m.put("xl_name", rs.getString("xl_name")); | |
| 1842 | - m.put("cl", rs.getString("cl")); | |
| 1843 | - m.put("jhyybc", rs.getString("jhyybc")); | |
| 1844 | - m.put("jhfyybc", rs.getString("jhfyybc")); | |
| 1845 | - m.put("sjyybc", rs.getString("sjyybc")); | |
| 1846 | - m.put("sjfyybc", rs.getString("sjfyybc")); | |
| 1847 | - m.put("ljbc", rs.getString("ljbc")); | |
| 1848 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 1849 | - m.put("jhfyylc", rs.getString("jhfyylc")); | |
| 1850 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 1851 | - m.put("sjfyylc", rs.getString("sjfyylc")); | |
| 1852 | - m.put("ljyylc", rs.getString("ljyylc")); | |
| 1853 | - m.put("ljfyylc", rs.getString("ljfyylc")); | |
| 1854 | - return m; | |
| 1855 | - } | |
| 1856 | - }); | |
| 1857 | - | |
| 1858 | - String cclSql = "select date,gsdm,fgsdm,xl,xl_name,jhcc,sjcc,ccl,jhbc,sjbc,bczxl from bsth_c_calc_count " | |
| 1859 | - + " where date = ? "; | |
| 1860 | - | |
| 1861 | - List<Map<String, Object>> cclList=jdbcTemplate.query(cclSql, new Object[]{date}, | |
| 1862 | - new RowMapper<Map<String, Object>>(){ | |
| 1863 | - @Override | |
| 1864 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1865 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1866 | - m.put("date", rs.getString("date")); | |
| 1867 | - m.put("gsdm", rs.getString("gsdm")); | |
| 1868 | - m.put("fgsdm", rs.getString("fgsdm")); | |
| 1869 | - m.put("xl", rs.getString("xl")); | |
| 1870 | - m.put("xlName", rs.getString("xl_name")); | |
| 1871 | - m.put("jhcc", rs.getString("jhcc")); | |
| 1872 | - m.put("sjcc", rs.getString("sjcc")); | |
| 1873 | - m.put("ccl", rs.getString("ccl")); | |
| 1874 | - m.put("jhbc", rs.getString("jhbc")); | |
| 1875 | - m.put("sjbc", rs.getString("sjbc")); | |
| 1876 | - m.put("bczxl", rs.getString("bczxl")); | |
| 1877 | - return m; | |
| 1878 | - } | |
| 1879 | - }); | |
| 1880 | - Map<String, Map<String, Object>> xlMap = new HashMap<String, Map<String, Object>>(); | |
| 1881 | - Map<String, List> carsMap = new HashMap<String, List>(); | |
| 1882 | - for(Map<String, Object> m : cclList){ | |
| 1883 | - String rqStr = m.get("date").toString(); | |
| 1884 | - String gsdm = m.get("gsdm").toString(); | |
| 1885 | - String fgsdm = m.get("fgsdm").toString(); | |
| 1886 | - String xl = m.get("xl").toString(); | |
| 1887 | - String key = rqStr + "/" + gsdm + "/" + fgsdm + "/" + xl; | |
| 1888 | - m.put("gsName", BusinessCodeData.code2Name.get(gsdm)); | |
| 1889 | - m.put("fgsName", BusinessCodeData.code2Name.get(gsdm + "_" + fgsdm)); | |
| 1890 | -// m.put("cars", new ArrayList()); | |
| 1891 | - xlMap.put(key, m); | |
| 1892 | - carsMap.put(key, new ArrayList()); | |
| 1893 | - } | |
| 1894 | - | |
| 1895 | - List<OilInfo> OilInfoList = oilInfoRepository.findByDate(rq); | |
| 1896 | - List<ElecInfo> ElecInfoList = elecInfoRepository.findByDate(rq); | |
| 1897 | - | |
| 1898 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | |
| 1899 | - for(Map<String, Object> m : calcList){ | |
| 1900 | - String rqStr = m.get("rq_str").toString(); | |
| 1901 | - String gsdm = m.get("gsdm").toString(); | |
| 1902 | - String fgsdm = m.get("fgsdm").toString(); | |
| 1903 | - String xl = m.get("xl").toString(); | |
| 1904 | - String cl = m.get("cl").toString(); | |
| 1905 | - String key = rqStr + "/" + gsdm + "/" + fgsdm + "/" + xl + "/" + cl; | |
| 1906 | - if(!keyMap.containsKey(key)){ | |
| 1907 | - Map<String, Object> m1 = new HashMap<String, Object>(); | |
| 1908 | - m1.put("oil", 0); | |
| 1909 | - m1.put("elec", 0); | |
| 1910 | - keyMap.put(key, m1); | |
| 1911 | - } | |
| 1912 | - Map<String, Object> m1 = keyMap.get(key); | |
| 1913 | - m1.put("date", rqStr); | |
| 1914 | - m1.put("gsdm", gsdm); | |
| 1915 | - m1.put("gsName", m.get("gsname")!=null?m.get("gsname").toString():""); | |
| 1916 | - m1.put("fgsdm", fgsdm); | |
| 1917 | - m1.put("fgsName", m.get("fgsname")!=null?m.get("fgsname").toString():""); | |
| 1918 | - m1.put("xl", xl); | |
| 1919 | - m1.put("xlName", m.get("xl_name")!=null?m.get("xl_name").toString():""); | |
| 1920 | - m1.put("cl", cl); | |
| 1921 | - m1.put("jhbc", new BigDecimal(m1.get("jhbc")!=null?m1.get("jhbc").toString():"0").add( | |
| 1922 | - new BigDecimal(m.get("jhyybc")!=null?m.get("jhyybc").toString():"0")).add( | |
| 1923 | - new BigDecimal(m.get("jhfyybc")!=null?m.get("jhfyybc").toString():"0"))); | |
| 1924 | - m1.put("sjbc", new BigDecimal(m1.get("sjbc")!=null?m1.get("sjbc").toString():"0").add( //实际班次+临加班次=总实际班次 | |
| 1925 | - new BigDecimal(m.get("sjyybc")!=null?m.get("sjyybc").toString():"0")).add( | |
| 1926 | - new BigDecimal(m.get("sjfyybc")!=null?m.get("sjfyybc").toString():"0")).add( | |
| 1927 | - new BigDecimal(m.get("ljbc")!=null?m.get("ljbc").toString():"0"))); | |
| 1928 | - m1.put("jhyygl", new BigDecimal(m1.get("jhyygl")!=null?m1.get("jhyygl").toString():"0").add( | |
| 1929 | - new BigDecimal(m.get("jhyylc")!=null?m.get("jhyylc").toString():"0"))); | |
| 1930 | - m1.put("jhksgl", new BigDecimal(m1.get("jhksgl")!=null?m1.get("jhksgl").toString():"0").add( | |
| 1931 | - new BigDecimal(m.get("jhfyylc")!=null?m.get("jhfyylc").toString():"0"))); | |
| 1932 | - m1.put("sjyygl", new BigDecimal(m1.get("sjyygl")!=null?m1.get("sjyygl").toString():"0").add( | |
| 1933 | - new BigDecimal(m.get("sjyylc")!=null?m.get("sjyylc").toString():"0")).add( | |
| 1934 | - new BigDecimal(m.get("ljyylc")!=null?m.get("ljyylc").toString():"0"))); | |
| 1935 | - m1.put("sjksgl", new BigDecimal(m1.get("sjksgl")!=null?m1.get("sjksgl").toString():"0").add( | |
| 1936 | - new BigDecimal(m.get("sjfyylc")!=null?m.get("sjfyylc").toString():"0")).add( | |
| 1937 | - new BigDecimal(m.get("ljfyylc")!=null?m.get("ljfyylc").toString():"0"))); | |
| 1938 | - } | |
| 1939 | - | |
| 1940 | - for(OilInfo oil : OilInfoList){ | |
| 1941 | - if(oil.getXlbm() == null || oil.getXlbm().trim().length() == 0){ | |
| 1942 | - continue; | |
| 1943 | - } | |
| 1944 | - String rqStr = sdf.format(oil.getRq()); | |
| 1945 | - String gsdm = oil.getSsgsdm(); | |
| 1946 | - String fgsdm = oil.getFgsdm(); | |
| 1947 | - String xl = oil.getXlbm(); | |
| 1948 | - String cl = oil.getNbbm(); | |
| 1949 | - String key = rqStr + "/" + gsdm + "/" + fgsdm + "/" + xl + "/" + cl; | |
| 1950 | - if(!keyMap.containsKey(key)){ | |
| 1951 | - Map<String, Object> m1 = new HashMap<String, Object>(); | |
| 1952 | - m1.put("jhbc", 0); | |
| 1953 | - m1.put("sjbc", 0); | |
| 1954 | - m1.put("jhyygl", 0); | |
| 1955 | - m1.put("jhksgl", 0); | |
| 1956 | - m1.put("sjyygl", 0); | |
| 1957 | - m1.put("sjksgl", 0); | |
| 1958 | - m1.put("oil", 0); | |
| 1959 | - m1.put("elec", 0); | |
| 1960 | - keyMap.put(key, m1); | |
| 1961 | - } | |
| 1962 | - Map<String, Object> m1 = keyMap.get(key); | |
| 1963 | - m1.put("date", rqStr); | |
| 1964 | - m1.put("gsdm", gsdm); | |
| 1965 | - m1.put("fgsdm", fgsdm); | |
| 1966 | - m1.put("xl", xl); | |
| 1967 | - m1.put("cl", cl); | |
| 1968 | - m1.put("oil", new BigDecimal(m1.get("oil")!=null?m1.get("oil").toString():"0").add( | |
| 1969 | - new BigDecimal(oil.getYh()!=null?oil.getYh().toString():"0"))); | |
| 1970 | - } | |
| 1971 | - | |
| 1972 | - for(ElecInfo elec : ElecInfoList){ | |
| 1973 | - if(elec.getXlbm() == null || elec.getXlbm().trim().length() == 0){ | |
| 1974 | - continue; | |
| 1975 | - } | |
| 1976 | - String rqStr = sdf.format(elec.getRq()); | |
| 1977 | - String gsdm = elec.getSsgsdm(); | |
| 1978 | - String fgsdm = elec.getFgsdm(); | |
| 1979 | - String xl = elec.getXlbm(); | |
| 1980 | - String cl = elec.getNbbm(); | |
| 1981 | - String key = rqStr + "/" + gsdm + "/" + fgsdm + "/" + xl + "/" + cl; | |
| 1982 | - if(!keyMap.containsKey(key)){ | |
| 1983 | - Map<String, Object> m1 = new HashMap<String, Object>(); | |
| 1984 | - m1.put("jhbc", 0); | |
| 1985 | - m1.put("sjbc", 0); | |
| 1986 | - m1.put("jhyygl", 0); | |
| 1987 | - m1.put("jhksgl", 0); | |
| 1988 | - m1.put("sjyygl", 0); | |
| 1989 | - m1.put("sjksgl", 0); | |
| 1990 | - m1.put("oil", 0); | |
| 1991 | - m1.put("elec", 0); | |
| 1992 | - keyMap.put(key, m1); | |
| 1993 | - } | |
| 1994 | - Map<String, Object> m1 = keyMap.get(key); | |
| 1995 | - m1.put("date", rqStr); | |
| 1996 | - m1.put("gsdm", gsdm); | |
| 1997 | - m1.put("fgsdm", fgsdm); | |
| 1998 | - m1.put("xl", xl); | |
| 1999 | - m1.put("cl", cl); | |
| 2000 | - m1.put("elec", new BigDecimal(m1.get("elec")!=null?m1.get("elec").toString():"0").add( | |
| 2001 | - new BigDecimal(elec.getHd()!=null?elec.getHd().toString():"0"))); | |
| 2002 | - } | |
| 2003 | - | |
| 2004 | - for(String key : keyMap.keySet()){ | |
| 2005 | - Map<String, Object> m = keyMap.get(key); | |
| 2006 | - if(!m.containsKey("gsName") || m.get("gsName").toString().trim().length() == 0){ | |
| 2007 | - m.put("gsName", BusinessCodeData.code2Name.get(m.get("gsdm").toString())); | |
| 2008 | - } | |
| 2009 | - if(!m.containsKey("fgsName") || m.get("fgsName").toString().trim().length() == 0){ | |
| 2010 | - m.put("fgsName", BusinessCodeData.code2Name.get(m.get("gsdm").toString() + "_" | |
| 2011 | - + m.get("fgsdm").toString())); | |
| 2012 | - } | |
| 2013 | - if(!m.containsKey("xlName") || m.get("xlName").toString().trim().length() == 0){ | |
| 2014 | - if(!allLineMap.containsKey(m.get("xl").toString())){ | |
| 2015 | - continue; | |
| 2016 | - } | |
| 2017 | - m.put("xlName", allLineMap.get(m.get("xl").toString())); | |
| 2018 | - } | |
| 2019 | -// if(new BigDecimal(m.get("jhyygl").toString()).compareTo(new BigDecimal("0")) == 1){ | |
| 2020 | -// m.put("jhcc", 1); | |
| 2021 | -// } else { | |
| 2022 | -// m.put("jhcc", 0); | |
| 2023 | -// } | |
| 2024 | -// if(new BigDecimal(m.get("sjyygl").toString()).compareTo(new BigDecimal("0")) == 1){ | |
| 2025 | -// m.put("sjcc", 1); | |
| 2026 | -// } else { | |
| 2027 | -// m.put("sjcc", 0); | |
| 2028 | -// } | |
| 2029 | - m.put("jhzgl", new BigDecimal(m.get("jhyygl").toString()).add(new BigDecimal(m.get("jhksgl").toString()))); | |
| 2030 | - m.put("sjzgl", new BigDecimal(m.get("sjyygl").toString()).add(new BigDecimal(m.get("sjksgl").toString()))); | |
| 2031 | - | |
| 2032 | - String rqStr = m.get("date").toString(); | |
| 2033 | - String gsdm = m.get("gsdm").toString(); | |
| 2034 | - String fgsdm = m.get("fgsdm").toString(); | |
| 2035 | - String xl = m.get("xl").toString(); | |
| 2036 | - String xlKey = rqStr + "/" + gsdm + "/" + fgsdm + "/" + xl; | |
| 2037 | - if(!carsMap.containsKey(xlKey)){ | |
| 2038 | - Map<String, Object> temp = new HashMap<String, Object>(); | |
| 2039 | - temp.put("date", rqStr); | |
| 2040 | - temp.put("gsdm", gsdm); | |
| 2041 | - temp.put("fgsdm", fgsdm); | |
| 2042 | - temp.put("xl", xl); | |
| 2043 | - temp.put("gsName", m.get("gsName").toString()); | |
| 2044 | - temp.put("fgsName", m.get("fgsName").toString()); | |
| 2045 | - temp.put("xlName", m.get("xlName").toString()); | |
| 2046 | - temp.put("jhcc", 0); | |
| 2047 | - temp.put("sjcc", 0); | |
| 2048 | - temp.put("ccl", 0); | |
| 2049 | - temp.put("jhbc", 0); | |
| 2050 | - temp.put("sjbc", 0); | |
| 2051 | - temp.put("bczxl", 0); | |
| 2052 | - xlMap.put(xlKey, temp); | |
| 2053 | - carsMap.put(xlKey, new ArrayList()); | |
| 2054 | - } | |
| 2055 | - carsMap.get(xlKey).add(m); | |
| 2056 | - } | |
| 2057 | - | |
| 2058 | - for(String key : xlMap.keySet()){ | |
| 2059 | - Map<String, Object> m = xlMap.get(key); | |
| 2060 | - m.put("cars", carsMap.get(key)); | |
| 2061 | - String xl = m.get("xl").toString(); | |
| 2062 | - if(!yyLine.contains(xl)){ | |
| 2063 | - continue; | |
| 2064 | - } | |
| 2065 | - if(warrantCarMap.containsKey(xl)){ | |
| 2066 | - m.put("warrantCar", warrantCarMap.get(xl)); | |
| 2067 | - } else { | |
| 2068 | - m.put("warrantCar", ""); | |
| 2069 | - } | |
| 2070 | - resList.add(m); | |
| 2071 | - } | |
| 2072 | - | |
| 2073 | - return resList; | |
| 2074 | - } | |
| 2075 | - | |
| 2076 | - /** | |
| 2077 | - * 浦东公交线路调查表(给郑鑫) | |
| 2078 | - * @param date | |
| 2079 | - * @return | |
| 2080 | - * @throws ParseException | |
| 2081 | - */ | |
| 2082 | - @GET | |
| 2083 | - @Path("/calcInvestigateMonth/month/{month}/{gs}/{fgs}/{line}") | |
| 2084 | - public List<JSONObject> calcInvestigateMonth(@PathParam("month") String month, | |
| 2085 | - @PathParam("gs") String gs, @PathParam("fgs") String fgs, | |
| 2086 | - @PathParam("line") String line) throws ParseException { | |
| 2087 | - List<JSONObject> resList = new ArrayList<JSONObject>(); | |
| 2088 | - | |
| 2089 | - String xlSql="SELECT line_code, name, nature from bsth_c_line"; | |
| 2090 | - List<Map<String, Object>> xlList=jdbcTemplate.query(xlSql, | |
| 2091 | - new RowMapper<Map<String, Object>>(){ | |
| 2092 | - @Override | |
| 2093 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2094 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2095 | - m.put("lineCode", rs.getString("line_code")); | |
| 2096 | - m.put("lineName", rs.getString("name")); | |
| 2097 | - m.put("nature", rs.getString("nature")); | |
| 2098 | - return m; | |
| 2099 | - } | |
| 2100 | - }); | |
| 2101 | - Set<String> yyLine = new HashSet<String>(); | |
| 2102 | - for(Map<String, Object> t : xlList){ | |
| 2103 | - if(t.get("lineCode") != null){ | |
| 2104 | - String nature = t.get("nature")!=null?t.get("nature").toString():""; | |
| 2105 | - if("yxl".equals(nature) || "cgxl".equals(nature) || "gjxl".equals(nature) | |
| 2106 | - || "csbs".equals(nature) || "cctxl".equals(nature)){ | |
| 2107 | - yyLine.add(t.get("lineCode").toString()); | |
| 2108 | - } | |
| 2109 | - } | |
| 2110 | - } | |
| 2111 | - | |
| 2112 | - if(gs == null || gs.trim().length() == 0){ //公司编码别传空值,就让传all代表全部 | |
| 2113 | - gs = "xxxx"; | |
| 2114 | - } | |
| 2115 | - if("all".equals(gs.trim())){ | |
| 2116 | - gs = ""; | |
| 2117 | - } | |
| 2118 | - if(fgs == null || fgs.trim().length() == 0){ //分公司编码别传空值,就让传all代表全部 | |
| 2119 | - fgs = "xxxx"; | |
| 2120 | - } | |
| 2121 | - if("all".equals(fgs.trim())){ | |
| 2122 | - fgs = ""; | |
| 2123 | - } | |
| 2124 | - | |
| 2125 | - List<CalcInvestigateMonth> list = new ArrayList<CalcInvestigateMonth>(); | |
| 2126 | - if(line != null && !"all".equals(line.trim())){ | |
| 2127 | - list = calcInvestigateMonthRepository.findByMonthAndLine(month, line); | |
| 2128 | - } else if(gs != null && gs.length() > 0){ | |
| 2129 | - list = calcInvestigateMonthRepository.findByMonth(month, gs, fgs); | |
| 2130 | - } else { | |
| 2131 | - list = calcInvestigateMonthRepository.findByMonth(month); | |
| 2132 | - } | |
| 2133 | - | |
| 2134 | - for(CalcInvestigateMonth c : list){ | |
| 2135 | - if(yyLine.contains(c.getXl())){ | |
| 2136 | - JSONObject jsonObject = (JSONObject)JSON.toJSON(c); | |
| 2137 | - jsonObject.put("gsName", BusinessCodeData.code2Name.get(jsonObject.get("gsbm").toString())); | |
| 2138 | - jsonObject.put("fgsName", BusinessCodeData.code2Name.get(jsonObject.get("gsbm").toString() | |
| 2139 | - + "_" + jsonObject.get("fgsbm").toString())); | |
| 2140 | - resList.add(jsonObject); | |
| 2141 | - } | |
| 2142 | - } | |
| 2143 | - | |
| 2144 | - return resList; | |
| 2145 | - } | |
| 2146 | - | |
| 2147 | -} |
src/main/java/com/bsth/server_rs/bigdata/BigscreenService.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.bigdata; | |
| 2 | - | |
| 3 | -import java.math.BigDecimal; | |
| 4 | -import java.sql.ResultSet; | |
| 5 | -import java.sql.SQLException; | |
| 6 | -import java.text.DecimalFormat; | |
| 7 | -import java.text.ParseException; | |
| 8 | -import java.text.SimpleDateFormat; | |
| 9 | -import java.util.ArrayList; | |
| 10 | -import java.util.Calendar; | |
| 11 | -import java.util.Collections; | |
| 12 | -import java.util.Comparator; | |
| 13 | -import java.util.Date; | |
| 14 | -import java.util.GregorianCalendar; | |
| 15 | -import java.util.HashMap; | |
| 16 | -import java.util.HashSet; | |
| 17 | -import java.util.Iterator; | |
| 18 | -import java.util.List; | |
| 19 | -import java.util.Map; | |
| 20 | -import java.util.Set; | |
| 21 | - | |
| 22 | -import javax.ws.rs.GET; | |
| 23 | -import javax.ws.rs.Path; | |
| 24 | -import javax.ws.rs.PathParam; | |
| 25 | -import javax.ws.rs.Produces; | |
| 26 | -import javax.ws.rs.core.MediaType; | |
| 27 | - | |
| 28 | -import org.apache.commons.lang.StringUtils; | |
| 29 | -import org.slf4j.Logger; | |
| 30 | -import org.slf4j.LoggerFactory; | |
| 31 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 32 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 33 | -import org.springframework.jdbc.core.RowMapper; | |
| 34 | -import org.springframework.stereotype.Component; | |
| 35 | - | |
| 36 | -import com.alibaba.fastjson.JSON; | |
| 37 | -import com.alibaba.fastjson.JSONObject; | |
| 38 | -import com.bsth.entity.ChildTaskPlan; | |
| 39 | -import com.bsth.entity.ScheduleRealInfo; | |
| 40 | -import com.bsth.repository.ScheduleRealInfoRepository; | |
| 41 | -import com.bsth.util.Arith; | |
| 42 | - | |
| 43 | -@Component | |
| 44 | -@Path("/bigscreen") | |
| 45 | -@Produces({MediaType.APPLICATION_JSON}) | |
| 46 | -public class BigscreenService { | |
| 47 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 48 | - | |
| 49 | - @Autowired | |
| 50 | - JdbcTemplate jdbcTemplate; | |
| 51 | - | |
| 52 | - @Autowired | |
| 53 | - ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 54 | - | |
| 55 | - DecimalFormat df = new DecimalFormat("0.###"); | |
| 56 | - | |
| 57 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 58 | - | |
| 59 | - SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |
| 60 | - | |
| 61 | - /* | |
| 62 | - * 线路接口开始 | |
| 63 | - */ | |
| 64 | - private static String getNature(String natureCode){ | |
| 65 | - String natureName=""; | |
| 66 | - if("lj".equals(natureCode)){ | |
| 67 | - natureName="路救"; | |
| 68 | - }else if("bc".equals(natureCode)){ | |
| 69 | - natureName="备车"; | |
| 70 | - }else if("dbc".equals(natureCode)){ | |
| 71 | - natureName="定班车"; | |
| 72 | - }else if("yxl".equals(natureCode)){ | |
| 73 | - natureName="夜宵路"; | |
| 74 | - }else if("cgxl".equals(natureCode)){ | |
| 75 | - natureName="常规线路"; | |
| 76 | - }else if("gjxl".equals(natureCode)){ | |
| 77 | - natureName="过江线路"; | |
| 78 | - }else if("csbs".equals(natureCode)){ | |
| 79 | - natureName="穿梭巴士"; | |
| 80 | - }else if("tyxl".equals(natureCode)){ | |
| 81 | - natureName="特约线路"; | |
| 82 | - }else if("cctxl".equals(natureCode)){ | |
| 83 | - natureName="村村通线路"; | |
| 84 | - }else if("qt".equals(natureCode)){ | |
| 85 | - natureName="其他"; | |
| 86 | - }else { | |
| 87 | - natureName=""; | |
| 88 | - } | |
| 89 | - return natureName; | |
| 90 | - } | |
| 91 | - | |
| 92 | - private static String getGs(String gs){ | |
| 93 | - String name=""; | |
| 94 | - if("05".equals(gs)){ | |
| 95 | - name="杨高公司"; | |
| 96 | - }else if("22".equals(gs)){ | |
| 97 | - name="金高公司"; | |
| 98 | - }else if("26".equals(gs)){ | |
| 99 | - name="南汇公司"; | |
| 100 | - }else if("55".equals(gs)){ | |
| 101 | - name="上南公司"; | |
| 102 | - }else{ | |
| 103 | - name=""; | |
| 104 | - } | |
| 105 | - return name; | |
| 106 | - } | |
| 107 | - | |
| 108 | - private static String getState(String carState){ | |
| 109 | - if(carState.equals("1")){ | |
| 110 | - return "在册未在用"; | |
| 111 | - }else if(carState.equals("2")){ | |
| 112 | - return "在册在用"; | |
| 113 | - }else if(carState.equals("3")){ | |
| 114 | - return "报废审核中"; | |
| 115 | - }else if(carState.equals("4")){ | |
| 116 | - return "报废待更新"; | |
| 117 | - }else if(carState.equals("5")){ | |
| 118 | - return "报废已更新"; | |
| 119 | - }else{ | |
| 120 | - return ""; | |
| 121 | - } | |
| 122 | - } | |
| 123 | - | |
| 124 | - public static boolean isInOut(ScheduleRealInfo s){ | |
| 125 | - boolean fage=false; | |
| 126 | - if(s.getBcType().equals("in")){ | |
| 127 | - fage=true; | |
| 128 | - } | |
| 129 | - if(s.getBcType().equals("out")){ | |
| 130 | - fage=true; | |
| 131 | - } | |
| 132 | - if(s.getBcType().equals("ldks")){ | |
| 133 | - fage=true; | |
| 134 | - } | |
| 135 | - return fage; | |
| 136 | - } | |
| 137 | - | |
| 138 | - public static boolean isInOut(String bcType){ | |
| 139 | - boolean fage=false; | |
| 140 | - if(bcType.equals("in")){ | |
| 141 | - fage=true; | |
| 142 | - } | |
| 143 | - if(bcType.equals("out")){ | |
| 144 | - fage=true; | |
| 145 | - } | |
| 146 | - if(bcType.equals("ldks")){ | |
| 147 | - fage=true; | |
| 148 | - } | |
| 149 | - return fage; | |
| 150 | - } | |
| 151 | - | |
| 152 | - public Map<String, Long> getEndtime(String date){ | |
| 153 | - Map<String, Long> map=new HashMap<String,Long>(); | |
| 154 | - String sql="select xl,endtime from bsth_c_calc_count " | |
| 155 | - + " where date='"+date+"' "; | |
| 156 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 157 | - new RowMapper<Map<String, Object>>(){ | |
| 158 | - @Override | |
| 159 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 160 | - Map<String, Object> m=new HashMap<String, Object>(); | |
| 161 | - m.put("line", rs.getString("xl")); | |
| 162 | - m.put("endtime", rs.getString("endtime")); | |
| 163 | - return m; | |
| 164 | - } | |
| 165 | - }); | |
| 166 | - for (int i = 0; i < list.size(); i++) { | |
| 167 | - map.put(list.get(i).get("line").toString(), | |
| 168 | - Long.parseLong(list.get(i).get("endtime").toString())); | |
| 169 | - } | |
| 170 | - return map; | |
| 171 | - } | |
| 172 | - | |
| 173 | - /**给大屏的线路数、班次、里程汇总接口 | |
| 174 | - * | |
| 175 | - */ | |
| 176 | - @GET | |
| 177 | - @Path("/selectData/getBigScreen") | |
| 178 | - public JSONObject getBigScreen(){ | |
| 179 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 180 | - | |
| 181 | - int day = 8;//天数 | |
| 182 | - | |
| 183 | - Date dd = new Date(); | |
| 184 | - String date = sd.format(dd); //yyyy-MM-dd 当天 | |
| 185 | - Date dd2 = new Date(); | |
| 186 | - dd2.setTime(dd.getTime() - ((long)(day-1))*1000*60*60*24); | |
| 187 | - String date2 = sd.format(dd2); //yyyy-MM-dd 7天前(加上当天就是取8天数据) | |
| 188 | - | |
| 189 | - String[] dates = new String[day]; | |
| 190 | - Map<String, Integer> datesMap = new HashMap<String, Integer>(); | |
| 191 | - | |
| 192 | - for(int i = 0; i < day; i++){ | |
| 193 | - Date tempDate = new Date(); | |
| 194 | - tempDate.setTime(dd2.getTime() + ((long)i)*1000*60*60*24); | |
| 195 | - String format = sd.format(tempDate); | |
| 196 | - dates[i] = format; | |
| 197 | - datesMap.put(format, i); | |
| 198 | - } | |
| 199 | - | |
| 200 | - String gpLineSql = "select * from bsth_c_line_plate"; | |
| 201 | - List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | |
| 202 | - new RowMapper<Map<String, Object>>(){ | |
| 203 | - @Override | |
| 204 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 205 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 206 | - m.put("lineName", rs.getString("line_name")); | |
| 207 | - m.put("lineCode", rs.getString("line_code")); | |
| 208 | - return m; | |
| 209 | - } | |
| 210 | - }); | |
| 211 | - | |
| 212 | - Set<String> gpSet = new HashSet<String>(); | |
| 213 | - for(Map<String, Object> t : gpLineList){ | |
| 214 | - if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | |
| 215 | - gpSet.add(t.get("lineCode").toString().trim()); | |
| 216 | - } | |
| 217 | - } | |
| 218 | - | |
| 219 | - String lineSql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level," | |
| 220 | - + " a.shanghai_linecode, a.nature from " | |
| 221 | - + " bsth_c_line a left join bsth_c_line_config b " | |
| 222 | - + " on a.id=b.line where " | |
| 223 | - + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 " | |
| 224 | - + " and a.remove=0 and a.nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 225 | - List<Map<String, Object>> lineList=jdbcTemplate.query(lineSql, | |
| 226 | - new RowMapper<Map<String, Object>>(){ | |
| 227 | - @Override | |
| 228 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 229 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 230 | - m.put("state", rs.getString("start_opt")); | |
| 231 | - m.put("company", rs.getString("company")); | |
| 232 | - m.put("companyName", getGs(rs.getString("company"))); | |
| 233 | - m.put("lineCode",rs.getString("line_code")); | |
| 234 | - m.put("name", rs.getString("name")); | |
| 235 | - m.put("level", rs.getString("level")); | |
| 236 | - m.put("shanghaiLinecode", rs.getString("shanghai_linecode")); | |
| 237 | - m.put("nature", getNature(rs.getString("nature"))); | |
| 238 | - return m; | |
| 239 | - } | |
| 240 | - }); | |
| 241 | - | |
| 242 | - int level1 = 0, level2 = 0; | |
| 243 | - for(Map<String, Object> t : lineList){ | |
| 244 | - if(t.get("level") != null){ | |
| 245 | - if("1".equals(t.get("level").toString())){ | |
| 246 | - ++level1; | |
| 247 | - } else if("2".equals(t.get("level").toString())){ | |
| 248 | - ++level2; | |
| 249 | - } | |
| 250 | - } | |
| 251 | - } | |
| 252 | - | |
| 253 | - | |
| 254 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 255 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 256 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 257 | - new RowMapper<Map<String, Object>>(){ | |
| 258 | - @Override | |
| 259 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 260 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 261 | - m.put("lineCode", rs.getString("line_code")); | |
| 262 | - return m; | |
| 263 | - } | |
| 264 | - }); | |
| 265 | - Set<String> yyLine = new HashSet<String>(); | |
| 266 | - for(Map<String, Object> t : yyxlList){ | |
| 267 | - if(t.get("lineCode") != null){ | |
| 268 | - yyLine.add(t.get("lineCode").toString()); | |
| 269 | - } | |
| 270 | - } | |
| 271 | - | |
| 272 | - | |
| 273 | - List<String> objList = new ArrayList<String>(); | |
| 274 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 275 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 276 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 277 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 278 | - + " jhszfcs,sjszfczds,szfczdl,create_date" | |
| 279 | - + " from bsth_c_calc_count where gsdm != '77'" | |
| 280 | - + " and date >= ? and date <= ?"; | |
| 281 | - objList.add(date2); | |
| 282 | - objList.add(date); | |
| 283 | - | |
| 284 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 285 | - objList.toArray(), | |
| 286 | - new RowMapper<Map<String, Object>>(){ | |
| 287 | - @Override | |
| 288 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 289 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 290 | - m.put("lineCode",rs.getString("xl")); | |
| 291 | - m.put("lineName", rs.getString("xl_name")); | |
| 292 | - m.put("date", rs.getString("date")); | |
| 293 | - | |
| 294 | - m.put("jhbc", rs.getString("jhbc")); | |
| 295 | - m.put("sjbc", rs.getString("sjbc")); | |
| 296 | - m.put("bczxl", rs.getString("bczxl")); | |
| 297 | - m.put("jhbcz", rs.getString("jhbcz")); | |
| 298 | - | |
| 299 | - m.put("jhcc", rs.getString("jhcc")); | |
| 300 | - m.put("sjcc", rs.getString("sjcc")); | |
| 301 | - m.put("ccl", rs.getString("ccl")); | |
| 302 | - m.put("jhccz", rs.getString("jhccz")); | |
| 303 | - | |
| 304 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 305 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 306 | - m.put("jhyylcz", rs.getString("jhyylcz")); | |
| 307 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 308 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 309 | - m.put("jhkslcz", rs.getString("jhkslcz")); | |
| 310 | - | |
| 311 | - m.put("jhgfbcs", rs.getString("jhssgfbcs")); | |
| 312 | - m.put("sjgfbcs", rs.getString("sjgfbcs")); | |
| 313 | - m.put("jhgfbcsz", rs.getString("jhgfbcsz")); | |
| 314 | - m.put("jhdgbcs", rs.getString("jhssdgbcs")); | |
| 315 | - m.put("sjdgbcs", rs.getString("sjdgbcs")); | |
| 316 | - m.put("jhdgbcsz", rs.getString("jhdgbcsz")); | |
| 317 | - | |
| 318 | - m.put("jhsmbcs", rs.getString("jhsmbcs")); | |
| 319 | - m.put("sjsmbczds", rs.getString("sjsmbczds")); | |
| 320 | - m.put("smbczdl", rs.getString("smbczdl")); | |
| 321 | - m.put("jhsmbcsz", rs.getString("jhsmbcsz")); | |
| 322 | - m.put("sjsmbczdsz", rs.getString("sjsmbczdsz")); | |
| 323 | - m.put("smbczdlz", rs.getString("smbczdlz")); | |
| 324 | - | |
| 325 | - m.put("jhszfcs", rs.getString("jhszfcs")); | |
| 326 | - m.put("sjszfczds", rs.getString("sjszfczds")); | |
| 327 | - m.put("szfczdl", rs.getString("szfczdl")); | |
| 328 | - | |
| 329 | - Date date = new Date(); | |
| 330 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 331 | - m.put("createDate", sdf.format(date)); | |
| 332 | - return m; | |
| 333 | - } | |
| 334 | - }); | |
| 335 | - | |
| 336 | - List<Map<String, Object>> bcDetail = new ArrayList<Map<String,Object>>(); | |
| 337 | - List<Map<String, Object>> smDetail = new ArrayList<Map<String,Object>>(); | |
| 338 | - List<Map<String, Object>> qqDetail = new ArrayList<Map<String,Object>>(); | |
| 339 | - List<Map<String, Object>> gpDetail = new ArrayList<Map<String,Object>>(); | |
| 340 | - | |
| 341 | - List<Map<String, Object>> ccList = createMap("计划出车率", dates); | |
| 342 | - List<Map<String, Object>> bcList = createMap("计划班次执行率", dates); | |
| 343 | - List<Map<String, Object>> smList = createMap("首末班发车准点率", dates); | |
| 344 | - List<Map<String, Object>> qqList = createMap("起讫站发车准点率", dates); | |
| 345 | - List<Map<String, Object>> gpList = createMap("挂牌线路发车准点率", dates); | |
| 346 | - List<Map<String, Object>> qkList = createMap("签卡率", dates); | |
| 347 | - | |
| 348 | - long sjbcs_z = 0l;//实时总班次 | |
| 349 | - BigDecimal yygl_z = new BigDecimal(0);//实时总营运里程 | |
| 350 | - long jhcc = 0, sjcc = 0, jhbc = 0, sjbc = 0, jhsmbc = 0, sjsmbc = 0, | |
| 351 | - jhqqbc = 0, sjqqzd = 0, jhgpqqbc = 0, sjgpqqzd = 0, bcs_qk = 0, qks = 0; | |
| 352 | - | |
| 353 | - for(Map<String, Object> t : list){ | |
| 354 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 355 | - String d = t.get("date").toString(); | |
| 356 | - if(date.equals(d)){ | |
| 357 | - sjbcs_z += Long.valueOf(t.get("sjbc").toString()); | |
| 358 | - yygl_z = yygl_z.add(new BigDecimal(t.get("sjyylc").toString())); | |
| 359 | - | |
| 360 | - jhcc += Long.valueOf(t.get("jhccz").toString()); | |
| 361 | - sjcc += Long.valueOf(t.get("sjcc").toString()); | |
| 362 | - jhbc += Long.valueOf(t.get("jhbc").toString()); | |
| 363 | - sjbc += Long.valueOf(t.get("sjbc").toString()); | |
| 364 | - jhsmbc += Long.valueOf(t.get("jhsmbcs").toString()); | |
| 365 | - sjsmbc += Long.valueOf(t.get("sjsmbczds").toString()); | |
| 366 | - jhqqbc += Long.valueOf(t.get("jhszfcs").toString()); | |
| 367 | - sjqqzd += Long.valueOf(t.get("sjszfczds").toString()); | |
| 368 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 369 | - jhgpqqbc += Long.valueOf(t.get("jhszfcs").toString()); | |
| 370 | - sjgpqqzd += Long.valueOf(t.get("sjszfczds").toString()); | |
| 371 | - } | |
| 372 | - | |
| 373 | - Map<String, Object> bc = new HashMap<String, Object>(); | |
| 374 | - bc.put("type", "班次执行详情"); | |
| 375 | - bc.put("lineName", t.get("lineName").toString()); | |
| 376 | - bc.put("jh", t.get("jhbc").toString()); | |
| 377 | - bc.put("sj", t.get("sjbc").toString()); | |
| 378 | - bcDetail.add(bc); | |
| 379 | - | |
| 380 | - Map<String, Object> sm = new HashMap<String, Object>(); | |
| 381 | - sm.put("type", "首站发车详情"); | |
| 382 | - sm.put("lineName", t.get("lineName").toString()); | |
| 383 | - sm.put("jh", t.get("jhsmbcs").toString()); | |
| 384 | - sm.put("sj", t.get("sjsmbczds").toString()); | |
| 385 | - smDetail.add(sm); | |
| 386 | - | |
| 387 | - Map<String, Object> qq = new HashMap<String, Object>(); | |
| 388 | - qq.put("type", "起讫站发车准点详情"); | |
| 389 | - qq.put("lineName", t.get("lineName").toString()); | |
| 390 | - qq.put("jh", t.get("jhszfcs").toString()); | |
| 391 | - qq.put("sj", t.get("sjszfczds").toString()); | |
| 392 | - qqDetail.add(qq); | |
| 393 | - | |
| 394 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 395 | - Map<String, Object> gp = new HashMap<String, Object>(); | |
| 396 | - gp.put("type", "挂牌线路发车准点详情"); | |
| 397 | - gp.put("lineName", t.get("lineName").toString()); | |
| 398 | - gp.put("jh", t.get("jhszfcs").toString()); | |
| 399 | - gp.put("sj", t.get("sjszfczds").toString()); | |
| 400 | - gpDetail.add(gp); | |
| 401 | - } | |
| 402 | - } | |
| 403 | - | |
| 404 | - Map<String, Object> ccMap = ccList.get(datesMap.get(d)); | |
| 405 | - Map<String, Object> bcMap = bcList.get(datesMap.get(d)); | |
| 406 | - Map<String, Object> smMap = smList.get(datesMap.get(d)); | |
| 407 | - Map<String, Object> qqMap = qqList.get(datesMap.get(d)); | |
| 408 | - Map<String, Object> gpMap = gpList.get(datesMap.get(d)); | |
| 409 | - | |
| 410 | - ccMap.put("jh", Long.valueOf(ccMap.get("jh").toString()) + Long.valueOf(t.get("jhccz").toString())); | |
| 411 | - ccMap.put("sj", Long.valueOf(ccMap.get("sj").toString()) + Long.valueOf(t.get("sjcc").toString())); | |
| 412 | - bcMap.put("jh", Long.valueOf(bcMap.get("jh").toString()) + Long.valueOf(t.get("jhbc").toString())); | |
| 413 | - bcMap.put("sj", Long.valueOf(bcMap.get("sj").toString()) + Long.valueOf(t.get("sjbc").toString())); | |
| 414 | - smMap.put("jh", Long.valueOf(smMap.get("jh").toString()) + Long.valueOf(t.get("jhsmbcs").toString())); | |
| 415 | - smMap.put("sj", Long.valueOf(smMap.get("sj").toString()) + Long.valueOf(t.get("sjsmbczds").toString())); | |
| 416 | - qqMap.put("jh", Long.valueOf(qqMap.get("jh").toString()) + Long.valueOf(t.get("jhszfcs").toString())); | |
| 417 | - qqMap.put("sj", Long.valueOf(qqMap.get("sj").toString()) + Long.valueOf(t.get("sjszfczds").toString())); | |
| 418 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 419 | - gpMap.put("jh", Long.valueOf(gpMap.get("jh").toString()) + Long.valueOf(t.get("jhszfcs").toString())); | |
| 420 | - gpMap.put("sj", Long.valueOf(gpMap.get("sj").toString()) + Long.valueOf(t.get("sjszfczds").toString())); | |
| 421 | - } | |
| 422 | - | |
| 423 | - } | |
| 424 | - } | |
| 425 | - | |
| 426 | - | |
| 427 | - //计算签卡率 | |
| 428 | - for(String d : dates){ | |
| 429 | - if(d!=null && d.trim().length() > 0){ | |
| 430 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(d); | |
| 431 | - Map<String, Object> qkMap = qkList.get(datesMap.get(d)); | |
| 432 | - long jh = 0, sj = 0; | |
| 433 | - for(ScheduleRealInfo s : findAll){ | |
| 434 | - if(!("77".equals(s.getGsBm())) && s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 435 | - if(!isInOut(s) && !s.isCcService() && s.getStatus() != -1 && s.getStatus() != 0){ | |
| 436 | - ++jh; | |
| 437 | - String sty = decimalToBinary(s.getRfidState()); | |
| 438 | - Integer state = Integer.parseInt(sty); | |
| 439 | - if ((state & 4) == 4) { | |
| 440 | - ++sj; | |
| 441 | - } | |
| 442 | - } | |
| 443 | - } | |
| 444 | - } | |
| 445 | - qkMap.put("jh", jh); | |
| 446 | - qkMap.put("sj", sj); | |
| 447 | - | |
| 448 | - if(date.equals(d)){ | |
| 449 | - bcs_qk = jh; | |
| 450 | - qks = sj; | |
| 451 | - } | |
| 452 | - } | |
| 453 | - } | |
| 454 | - | |
| 455 | - | |
| 456 | - List<Map<String, Object>> zxlList = new ArrayList<Map<String, Object>>(); | |
| 457 | - zxlList.addAll(ccList); | |
| 458 | - zxlList.addAll(bcList); | |
| 459 | - zxlList.addAll(smList); | |
| 460 | - zxlList.addAll(qqList); | |
| 461 | - zxlList.addAll(gpList); | |
| 462 | - zxlList.addAll(qkList); | |
| 463 | - | |
| 464 | - List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | |
| 465 | - detailsList.addAll(bcDetail); | |
| 466 | - detailsList.addAll(smDetail); | |
| 467 | - detailsList.addAll(qqDetail); | |
| 468 | - detailsList.addAll(gpDetail); | |
| 469 | - | |
| 470 | - for(Map<String, Object> t : zxlList){ | |
| 471 | - if(t.get("jh") != null && Long.valueOf(t.get("jh").toString()).longValue() > 0l){ | |
| 472 | - t.put("ratio", new BigDecimal(t.get("sj").toString()).divide(new BigDecimal(t.get("jh").toString()), | |
| 473 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue()); | |
| 474 | - } else { | |
| 475 | - t.put("ratio", "0"); | |
| 476 | - } | |
| 477 | - } | |
| 478 | - | |
| 479 | - List<Map<String, Object>> glList = new ArrayList<Map<String, Object>>(); | |
| 480 | - | |
| 481 | - Date dd1 = new Date(); | |
| 482 | - dd1.setTime(dd.getTime() - 1l*1000*60*60*24); | |
| 483 | - String date1 = sd.format(dd1); //前一天 | |
| 484 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date1); | |
| 485 | - List<ScheduleRealInfo> listSche = new ArrayList<ScheduleRealInfo>(); | |
| 486 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | |
| 487 | - for(ScheduleRealInfo s : findAll){ | |
| 488 | - if(!("77".equals(s.getGsBm())) && s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 489 | - listSche.add(s); | |
| 490 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 491 | - if (cts != null && cts.size() > 0) { | |
| 492 | - list_s.add(s); | |
| 493 | - } else { | |
| 494 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 495 | - list_s.add(s); | |
| 496 | - } | |
| 497 | - } | |
| 498 | - } | |
| 499 | - } | |
| 500 | - double jhyygl = culateJhgl(listSche);//计划营运公里 | |
| 501 | - double jhjccgl = culateJhJccgl(listSche); | |
| 502 | - double jhzgl = Arith.add(jhyygl, jhjccgl); | |
| 503 | - double sjgl = culateSjgl(list_s);//实际营运公里(不含临加) | |
| 504 | - double sjljgl = culateLjgl(listSche);//实际临加公里 | |
| 505 | - double sjyygl = Arith.add(sjgl, sjljgl);//实际营运公里 | |
| 506 | - double sjjccgl = culateJccgl(list_s); | |
| 507 | - double sjksgl = culateKsgl(list_s); | |
| 508 | - double zksgl = Arith.add(sjjccgl, sjksgl); | |
| 509 | - double sjzgl = Arith.add(sjyygl, zksgl);//实际总公里 | |
| 510 | - double lz = culateCJLC(listSche, "路阻"); | |
| 511 | - double dm = culateCJLC(listSche, "吊慢"); | |
| 512 | - double gz = culateCJLC(listSche, "故障"); | |
| 513 | - double jf = culateCJLC(listSche, "纠纷"); | |
| 514 | - double zs = culateCJLC(listSche, "肇事"); | |
| 515 | - double qr = culateCJLC(listSche, "缺人"); | |
| 516 | - double qc = culateCJLC(listSche, "缺车"); | |
| 517 | - double qrqc = Arith.add(qr, qc);//缺人缺车 | |
| 518 | - double kx = culateCJLC(listSche, "客稀"); | |
| 519 | - double qh = culateCJLC(listSche, "气候"); | |
| 520 | - double yw = culateCJLC(listSche, "援外"); | |
| 521 | - double lb_pc = culateCJLC(listSche, "配车"); | |
| 522 | - double lb_by = culateCJLC(listSche, "保养"); | |
| 523 | - double lb_cj = culateCJLC(listSche, "抽减"); | |
| 524 | - double lb_qt = culateCJLC(listSche, "其他"); | |
| 525 | - double qt = Arith.add(Arith.add(lb_pc, lb_by), Arith.add(lb_cj, lb_qt));//其他 | |
| 526 | - | |
| 527 | - Map<String, Object> jhzglMap = new HashMap<String, Object>(); | |
| 528 | - jhzglMap.put("name", "计划总公里"); | |
| 529 | - jhzglMap.put("value", jhzgl); | |
| 530 | - glList.add(jhzglMap); | |
| 531 | - Map<String, Object> sjzglMap = new HashMap<String, Object>(); | |
| 532 | - sjzglMap.put("name", "实际总公里"); | |
| 533 | - sjzglMap.put("value", sjzgl); | |
| 534 | - glList.add(sjzglMap); | |
| 535 | - Map<String, Object> lzMap = new HashMap<String, Object>(); | |
| 536 | - lzMap.put("name", "路阻"); | |
| 537 | - lzMap.put("value", lz); | |
| 538 | - glList.add(lzMap); | |
| 539 | - Map<String, Object> dmMap = new HashMap<String, Object>(); | |
| 540 | - dmMap.put("name", "吊慢"); | |
| 541 | - dmMap.put("value", dm); | |
| 542 | - glList.add(dmMap); | |
| 543 | - Map<String, Object> gzMap = new HashMap<String, Object>(); | |
| 544 | - gzMap.put("name", "故障"); | |
| 545 | - gzMap.put("value", gz); | |
| 546 | - glList.add(gzMap); | |
| 547 | - Map<String, Object> jfMap = new HashMap<String, Object>(); | |
| 548 | - jfMap.put("name", "纠纷"); | |
| 549 | - jfMap.put("value", jf); | |
| 550 | - glList.add(jfMap); | |
| 551 | - Map<String, Object> zsMap = new HashMap<String, Object>(); | |
| 552 | - zsMap.put("name", "肇事"); | |
| 553 | - zsMap.put("value", zs); | |
| 554 | - glList.add(zsMap); | |
| 555 | - Map<String, Object> qrqcMap = new HashMap<String, Object>(); | |
| 556 | - qrqcMap.put("name", "缺人缺车"); | |
| 557 | - qrqcMap.put("value", qrqc); | |
| 558 | - glList.add(qrqcMap); | |
| 559 | - Map<String, Object> kxMap = new HashMap<String, Object>(); | |
| 560 | - kxMap.put("name", "客稀"); | |
| 561 | - kxMap.put("value", kx); | |
| 562 | - glList.add(kxMap); | |
| 563 | - Map<String, Object> qhMap = new HashMap<String, Object>(); | |
| 564 | - qhMap.put("name", "气候"); | |
| 565 | - qhMap.put("value", qh); | |
| 566 | - glList.add(qhMap); | |
| 567 | - Map<String, Object> ywMap = new HashMap<String, Object>(); | |
| 568 | - ywMap.put("name", "援外"); | |
| 569 | - ywMap.put("value", yw); | |
| 570 | - glList.add(ywMap); | |
| 571 | - Map<String, Object> qtMap = new HashMap<String, Object>(); | |
| 572 | - qtMap.put("name", "其他"); | |
| 573 | - qtMap.put("value", qt); | |
| 574 | - glList.add(qtMap); | |
| 575 | - | |
| 576 | - | |
| 577 | - resMap.put("lineCount", lineList.size()); | |
| 578 | - resMap.put("level1Count", level1); | |
| 579 | - resMap.put("level2Count", level2); | |
| 580 | - resMap.put("sjbcs", sjbcs_z); | |
| 581 | - resMap.put("sjlcs", yygl_z.doubleValue()); | |
| 582 | - | |
| 583 | - resMap.put("ccl", jhcc>0?new BigDecimal(sjcc).divide(new BigDecimal(jhcc), | |
| 584 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 585 | - resMap.put("bczxl", jhbc>0?new BigDecimal(sjbc).divide(new BigDecimal(jhbc), | |
| 586 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 587 | - resMap.put("smbzdl", jhsmbc>0?new BigDecimal(sjsmbc).divide(new BigDecimal(jhsmbc), | |
| 588 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 589 | - resMap.put("qqzzdl", jhqqbc>0?new BigDecimal(sjqqzd).divide(new BigDecimal(jhqqbc), | |
| 590 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 591 | - resMap.put("gpzdl", jhgpqqbc>0?new BigDecimal(sjgpqqzd).divide(new BigDecimal(jhgpqqbc), | |
| 592 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 593 | - resMap.put("qkl", bcs_qk>0?new BigDecimal(qks).divide(new BigDecimal(bcs_qk), | |
| 594 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 595 | - | |
| 596 | - resMap.put("ratioList", zxlList); | |
| 597 | - | |
| 598 | - resMap.put("detailsList", detailsList); | |
| 599 | - | |
| 600 | - resMap.put("mileageList", glList); | |
| 601 | - | |
| 602 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 603 | - } | |
| 604 | - | |
| 605 | - /**给大屏的线路数、班次、里程汇总接口 | |
| 606 | - * 按直属公司查询 | |
| 607 | - */ | |
| 608 | - @GET | |
| 609 | - @Path("/selectData/getBigScreen/{gsdm}") | |
| 610 | - public JSONObject getBigScreen(@PathParam("gsdm") String gsdm){ | |
| 611 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 612 | - | |
| 613 | - int day = 8;//天数 | |
| 614 | - | |
| 615 | - Date dd = new Date(); | |
| 616 | - String date = sd.format(dd); //yyyy-MM-dd 当天 | |
| 617 | - Date dd2 = new Date(); | |
| 618 | - dd2.setTime(dd.getTime() - ((long)(day-1))*1000*60*60*24); | |
| 619 | - String date2 = sd.format(dd2); //yyyy-MM-dd 7天前(加上当天就是取8天数据) | |
| 620 | - | |
| 621 | - String[] dates = new String[day]; | |
| 622 | - Map<String, Integer> datesMap = new HashMap<String, Integer>(); | |
| 623 | - | |
| 624 | - for(int i = 0; i < day; i++){ | |
| 625 | - Date tempDate = new Date(); | |
| 626 | - tempDate.setTime(dd2.getTime() + ((long)i)*1000*60*60*24); | |
| 627 | - String format = sd.format(tempDate); | |
| 628 | - dates[i] = format; | |
| 629 | - datesMap.put(format, i); | |
| 630 | - } | |
| 631 | - | |
| 632 | - String gpLineSql = "select * from bsth_c_line_plate"; | |
| 633 | - List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | |
| 634 | - new RowMapper<Map<String, Object>>(){ | |
| 635 | - @Override | |
| 636 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 637 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 638 | - m.put("lineName", rs.getString("line_name")); | |
| 639 | - m.put("lineCode", rs.getString("line_code")); | |
| 640 | - return m; | |
| 641 | - } | |
| 642 | - }); | |
| 643 | - | |
| 644 | - Set<String> gpSet = new HashSet<String>(); | |
| 645 | - for(Map<String, Object> t : gpLineList){ | |
| 646 | - if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | |
| 647 | - gpSet.add(t.get("lineCode").toString().trim()); | |
| 648 | - } | |
| 649 | - } | |
| 650 | - | |
| 651 | - String lineSql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level," | |
| 652 | - + " a.shanghai_linecode, a.nature from " | |
| 653 | - + " bsth_c_line a left join bsth_c_line_config b " | |
| 654 | - + " on a.id=b.line where " | |
| 655 | - + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 " | |
| 656 | - + " and a.remove=0 and a.nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 657 | - List<Map<String, Object>> lineList=jdbcTemplate.query(lineSql, | |
| 658 | - new RowMapper<Map<String, Object>>(){ | |
| 659 | - @Override | |
| 660 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 661 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 662 | - m.put("state", rs.getString("start_opt")); | |
| 663 | - m.put("company", rs.getString("company")); | |
| 664 | - m.put("companyName", getGs(rs.getString("company"))); | |
| 665 | - m.put("lineCode",rs.getString("line_code")); | |
| 666 | - m.put("name", rs.getString("name")); | |
| 667 | - m.put("level", rs.getString("level")); | |
| 668 | - m.put("shanghaiLinecode", rs.getString("shanghai_linecode")); | |
| 669 | - m.put("nature", getNature(rs.getString("nature"))); | |
| 670 | - return m; | |
| 671 | - } | |
| 672 | - }); | |
| 673 | - | |
| 674 | - int level1 = 0, level2 = 0, lineCount = 0; | |
| 675 | - for(Map<String, Object> t : lineList){ | |
| 676 | - if(t.containsKey("company") && t.get("company").toString().trim().equals(gsdm)){ | |
| 677 | - ++lineCount; | |
| 678 | - if(t.get("level") != null){ | |
| 679 | - if("1".equals(t.get("level").toString())){ | |
| 680 | - ++level1; | |
| 681 | - } else if("2".equals(t.get("level").toString())){ | |
| 682 | - ++level2; | |
| 683 | - } | |
| 684 | - } | |
| 685 | - } | |
| 686 | - } | |
| 687 | - | |
| 688 | - | |
| 689 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 690 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 691 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 692 | - new RowMapper<Map<String, Object>>(){ | |
| 693 | - @Override | |
| 694 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 695 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 696 | - m.put("lineCode", rs.getString("line_code")); | |
| 697 | - return m; | |
| 698 | - } | |
| 699 | - }); | |
| 700 | - Set<String> yyLine = new HashSet<String>(); | |
| 701 | - for(Map<String, Object> t : yyxlList){ | |
| 702 | - if(t.get("lineCode") != null){ | |
| 703 | - yyLine.add(t.get("lineCode").toString()); | |
| 704 | - } | |
| 705 | - } | |
| 706 | - | |
| 707 | - | |
| 708 | - List<String> objList = new ArrayList<String>(); | |
| 709 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 710 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 711 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 712 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 713 | - + " jhszfcs,sjszfczds,szfczdl,create_date" | |
| 714 | - + " from bsth_c_calc_count " | |
| 715 | - + " where date >= ? and date <= ? and gsdm = ?"; | |
| 716 | - objList.add(date2); | |
| 717 | - objList.add(date); | |
| 718 | - objList.add(gsdm); | |
| 719 | - | |
| 720 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 721 | - objList.toArray(), | |
| 722 | - new RowMapper<Map<String, Object>>(){ | |
| 723 | - @Override | |
| 724 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 725 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 726 | - m.put("lineCode",rs.getString("xl")); | |
| 727 | - m.put("lineName", rs.getString("xl_name")); | |
| 728 | - m.put("date", rs.getString("date")); | |
| 729 | - | |
| 730 | - m.put("jhbc", rs.getString("jhbc")); | |
| 731 | - m.put("sjbc", rs.getString("sjbc")); | |
| 732 | - m.put("bczxl", rs.getString("bczxl")); | |
| 733 | - m.put("jhbcz", rs.getString("jhbcz")); | |
| 734 | - | |
| 735 | - m.put("jhcc", rs.getString("jhcc")); | |
| 736 | - m.put("sjcc", rs.getString("sjcc")); | |
| 737 | - m.put("ccl", rs.getString("ccl")); | |
| 738 | - m.put("jhccz", rs.getString("jhccz")); | |
| 739 | - | |
| 740 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 741 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 742 | - m.put("jhyylcz", rs.getString("jhyylcz")); | |
| 743 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 744 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 745 | - m.put("jhkslcz", rs.getString("jhkslcz")); | |
| 746 | - | |
| 747 | - m.put("jhgfbcs", rs.getString("jhssgfbcs")); | |
| 748 | - m.put("sjgfbcs", rs.getString("sjgfbcs")); | |
| 749 | - m.put("jhgfbcsz", rs.getString("jhgfbcsz")); | |
| 750 | - m.put("jhdgbcs", rs.getString("jhssdgbcs")); | |
| 751 | - m.put("sjdgbcs", rs.getString("sjdgbcs")); | |
| 752 | - m.put("jhdgbcsz", rs.getString("jhdgbcsz")); | |
| 753 | - | |
| 754 | - m.put("jhsmbcs", rs.getString("jhsmbcs")); | |
| 755 | - m.put("sjsmbczds", rs.getString("sjsmbczds")); | |
| 756 | - m.put("smbczdl", rs.getString("smbczdl")); | |
| 757 | - m.put("jhsmbcsz", rs.getString("jhsmbcsz")); | |
| 758 | - m.put("sjsmbczdsz", rs.getString("sjsmbczdsz")); | |
| 759 | - m.put("smbczdlz", rs.getString("smbczdlz")); | |
| 760 | - | |
| 761 | - m.put("jhszfcs", rs.getString("jhszfcs")); | |
| 762 | - m.put("sjszfczds", rs.getString("sjszfczds")); | |
| 763 | - m.put("szfczdl", rs.getString("szfczdl")); | |
| 764 | - | |
| 765 | - Date date = new Date(); | |
| 766 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 767 | - m.put("createDate", sdf.format(date)); | |
| 768 | - return m; | |
| 769 | - } | |
| 770 | - }); | |
| 771 | - | |
| 772 | - List<Map<String, Object>> bcDetail = new ArrayList<Map<String,Object>>(); | |
| 773 | - List<Map<String, Object>> smDetail = new ArrayList<Map<String,Object>>(); | |
| 774 | - List<Map<String, Object>> qqDetail = new ArrayList<Map<String,Object>>(); | |
| 775 | - List<Map<String, Object>> gpDetail = new ArrayList<Map<String,Object>>(); | |
| 776 | - | |
| 777 | - List<Map<String, Object>> ccList = createMap("计划出车率", dates); | |
| 778 | - List<Map<String, Object>> bcList = createMap("计划班次执行率", dates); | |
| 779 | - List<Map<String, Object>> smList = createMap("首末班发车准点率", dates); | |
| 780 | - List<Map<String, Object>> qqList = createMap("起讫站发车准点率", dates); | |
| 781 | - List<Map<String, Object>> gpList = createMap("挂牌线路发车准点率", dates); | |
| 782 | - List<Map<String, Object>> qkList = createMap("签卡率", dates); | |
| 783 | - | |
| 784 | - long sjbcs_z = 0l;//实时总班次 | |
| 785 | - BigDecimal yygl_z = new BigDecimal(0);//实时总营运里程 | |
| 786 | - long jhcc = 0, sjcc = 0, jhbc = 0, sjbc = 0, jhsmbc = 0, sjsmbc = 0, | |
| 787 | - jhqqbc = 0, sjqqzd = 0, jhgpqqbc = 0, sjgpqqzd = 0, bcs_qk = 0, qks = 0; | |
| 788 | - | |
| 789 | - for(Map<String, Object> t : list){ | |
| 790 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 791 | - String d = t.get("date").toString(); | |
| 792 | - if(date.equals(d)){ | |
| 793 | - sjbcs_z += Long.valueOf(t.get("sjbc").toString()); | |
| 794 | - yygl_z = yygl_z.add(new BigDecimal(t.get("sjyylc").toString())); | |
| 795 | - | |
| 796 | - jhcc += Long.valueOf(t.get("jhccz").toString()); | |
| 797 | - sjcc += Long.valueOf(t.get("sjcc").toString()); | |
| 798 | - jhbc += Long.valueOf(t.get("jhbc").toString()); | |
| 799 | - sjbc += Long.valueOf(t.get("sjbc").toString()); | |
| 800 | - jhsmbc += Long.valueOf(t.get("jhsmbcs").toString()); | |
| 801 | - sjsmbc += Long.valueOf(t.get("sjsmbczds").toString()); | |
| 802 | - jhqqbc += Long.valueOf(t.get("jhszfcs").toString()); | |
| 803 | - sjqqzd += Long.valueOf(t.get("sjszfczds").toString()); | |
| 804 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 805 | - jhgpqqbc += Long.valueOf(t.get("jhszfcs").toString()); | |
| 806 | - sjgpqqzd += Long.valueOf(t.get("sjszfczds").toString()); | |
| 807 | - } | |
| 808 | - | |
| 809 | - Map<String, Object> bc = new HashMap<String, Object>(); | |
| 810 | - bc.put("type", "班次执行详情"); | |
| 811 | - bc.put("lineName", t.get("lineName").toString()); | |
| 812 | - bc.put("jh", t.get("jhbc").toString()); | |
| 813 | - bc.put("sj", t.get("sjbc").toString()); | |
| 814 | - bcDetail.add(bc); | |
| 815 | - | |
| 816 | - Map<String, Object> sm = new HashMap<String, Object>(); | |
| 817 | - sm.put("type", "首站发车详情"); | |
| 818 | - sm.put("lineName", t.get("lineName").toString()); | |
| 819 | - sm.put("jh", t.get("jhsmbcs").toString()); | |
| 820 | - sm.put("sj", t.get("sjsmbczds").toString()); | |
| 821 | - smDetail.add(sm); | |
| 822 | - | |
| 823 | - Map<String, Object> qq = new HashMap<String, Object>(); | |
| 824 | - qq.put("type", "起讫站发车准点详情"); | |
| 825 | - qq.put("lineName", t.get("lineName").toString()); | |
| 826 | - qq.put("jh", t.get("jhszfcs").toString()); | |
| 827 | - qq.put("sj", t.get("sjszfczds").toString()); | |
| 828 | - qqDetail.add(qq); | |
| 829 | - | |
| 830 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 831 | - Map<String, Object> gp = new HashMap<String, Object>(); | |
| 832 | - gp.put("type", "挂牌线路发车准点详情"); | |
| 833 | - gp.put("lineName", t.get("lineName").toString()); | |
| 834 | - gp.put("jh", t.get("jhszfcs").toString()); | |
| 835 | - gp.put("sj", t.get("sjszfczds").toString()); | |
| 836 | - gpDetail.add(gp); | |
| 837 | - } | |
| 838 | - } | |
| 839 | - | |
| 840 | - Map<String, Object> ccMap = ccList.get(datesMap.get(d)); | |
| 841 | - Map<String, Object> bcMap = bcList.get(datesMap.get(d)); | |
| 842 | - Map<String, Object> smMap = smList.get(datesMap.get(d)); | |
| 843 | - Map<String, Object> qqMap = qqList.get(datesMap.get(d)); | |
| 844 | - Map<String, Object> gpMap = gpList.get(datesMap.get(d)); | |
| 845 | - | |
| 846 | - ccMap.put("jh", Long.valueOf(ccMap.get("jh").toString()) + Long.valueOf(t.get("jhccz").toString())); | |
| 847 | - ccMap.put("sj", Long.valueOf(ccMap.get("sj").toString()) + Long.valueOf(t.get("sjcc").toString())); | |
| 848 | - bcMap.put("jh", Long.valueOf(bcMap.get("jh").toString()) + Long.valueOf(t.get("jhbc").toString())); | |
| 849 | - bcMap.put("sj", Long.valueOf(bcMap.get("sj").toString()) + Long.valueOf(t.get("sjbc").toString())); | |
| 850 | - smMap.put("jh", Long.valueOf(smMap.get("jh").toString()) + Long.valueOf(t.get("jhsmbcs").toString())); | |
| 851 | - smMap.put("sj", Long.valueOf(smMap.get("sj").toString()) + Long.valueOf(t.get("sjsmbczds").toString())); | |
| 852 | - qqMap.put("jh", Long.valueOf(qqMap.get("jh").toString()) + Long.valueOf(t.get("jhszfcs").toString())); | |
| 853 | - qqMap.put("sj", Long.valueOf(qqMap.get("sj").toString()) + Long.valueOf(t.get("sjszfczds").toString())); | |
| 854 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 855 | - gpMap.put("jh", Long.valueOf(gpMap.get("jh").toString()) + Long.valueOf(t.get("jhszfcs").toString())); | |
| 856 | - gpMap.put("sj", Long.valueOf(gpMap.get("sj").toString()) + Long.valueOf(t.get("sjszfczds").toString())); | |
| 857 | - } | |
| 858 | - | |
| 859 | - } | |
| 860 | - } | |
| 861 | - | |
| 862 | - | |
| 863 | - //计算签卡率 | |
| 864 | - for(String d : dates){ | |
| 865 | - if(d!=null && d.trim().length() > 0){ | |
| 866 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(d); | |
| 867 | - Map<String, Object> qkMap = qkList.get(datesMap.get(d)); | |
| 868 | - long jh = 0, sj = 0; | |
| 869 | - for(ScheduleRealInfo s : findAll){ | |
| 870 | - if(s.getGsBm() != null && s.getGsBm().trim().equals(gsdm)){ | |
| 871 | - if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 872 | - if(!isInOut(s) && !s.isCcService() && s.getStatus() != -1 && s.getStatus() != 0){ | |
| 873 | - ++jh; | |
| 874 | - String sty = decimalToBinary(s.getRfidState()); | |
| 875 | - Integer state = Integer.parseInt(sty); | |
| 876 | - if ((state & 4) == 4) { | |
| 877 | - ++sj; | |
| 878 | - } | |
| 879 | - } | |
| 880 | - } | |
| 881 | - } | |
| 882 | - } | |
| 883 | - qkMap.put("jh", jh); | |
| 884 | - qkMap.put("sj", sj); | |
| 885 | - | |
| 886 | - if(date.equals(d)){ | |
| 887 | - bcs_qk = jh; | |
| 888 | - qks = sj; | |
| 889 | - } | |
| 890 | - } | |
| 891 | - } | |
| 892 | - | |
| 893 | - | |
| 894 | - List<Map<String, Object>> zxlList = new ArrayList<Map<String, Object>>(); | |
| 895 | - zxlList.addAll(ccList); | |
| 896 | - zxlList.addAll(bcList); | |
| 897 | - zxlList.addAll(smList); | |
| 898 | - zxlList.addAll(qqList); | |
| 899 | - zxlList.addAll(gpList); | |
| 900 | - zxlList.addAll(qkList); | |
| 901 | - | |
| 902 | - List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | |
| 903 | - detailsList.addAll(bcDetail); | |
| 904 | - detailsList.addAll(smDetail); | |
| 905 | - detailsList.addAll(qqDetail); | |
| 906 | - detailsList.addAll(gpDetail); | |
| 907 | - | |
| 908 | - for(Map<String, Object> t : zxlList){ | |
| 909 | - if(t.get("jh") != null && Long.valueOf(t.get("jh").toString()).longValue() > 0l){ | |
| 910 | - t.put("ratio", new BigDecimal(t.get("sj").toString()).divide(new BigDecimal(t.get("jh").toString()), | |
| 911 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue()); | |
| 912 | - } else { | |
| 913 | - t.put("ratio", "0"); | |
| 914 | - } | |
| 915 | - } | |
| 916 | - | |
| 917 | - List<Map<String, Object>> glList = new ArrayList<Map<String, Object>>(); | |
| 918 | - | |
| 919 | - Date dd1 = new Date(); | |
| 920 | - dd1.setTime(dd.getTime() - 1l*1000*60*60*24); | |
| 921 | - String date1 = sd.format(dd1); //前一天 | |
| 922 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date1); | |
| 923 | - List<ScheduleRealInfo> listSche = new ArrayList<ScheduleRealInfo>(); | |
| 924 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | |
| 925 | - for(ScheduleRealInfo s : findAll){ | |
| 926 | - if(s.getGsBm() != null && s.getGsBm().trim().equals(gsdm)){ | |
| 927 | - if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 928 | - listSche.add(s); | |
| 929 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 930 | - if (cts != null && cts.size() > 0) { | |
| 931 | - list_s.add(s); | |
| 932 | - } else { | |
| 933 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 934 | - list_s.add(s); | |
| 935 | - } | |
| 936 | - } | |
| 937 | - } | |
| 938 | - } | |
| 939 | - } | |
| 940 | - double jhyygl = culateJhgl(listSche);//计划营运公里 | |
| 941 | - double jhjccgl = culateJhJccgl(listSche); | |
| 942 | - double jhzgl = Arith.add(jhyygl, jhjccgl); | |
| 943 | - double sjgl = culateSjgl(list_s);//实际营运公里(不含临加) | |
| 944 | - double sjljgl = culateLjgl(listSche);//实际临加公里 | |
| 945 | - double sjyygl = Arith.add(sjgl, sjljgl);//实际营运公里 | |
| 946 | - double sjjccgl = culateJccgl(list_s); | |
| 947 | - double sjksgl = culateKsgl(list_s); | |
| 948 | - double zksgl = Arith.add(sjjccgl, sjksgl); | |
| 949 | - double sjzgl = Arith.add(sjyygl, zksgl);//实际总公里 | |
| 950 | - double lz = culateCJLC(listSche, "路阻"); | |
| 951 | - double dm = culateCJLC(listSche, "吊慢"); | |
| 952 | - double gz = culateCJLC(listSche, "故障"); | |
| 953 | - double jf = culateCJLC(listSche, "纠纷"); | |
| 954 | - double zs = culateCJLC(listSche, "肇事"); | |
| 955 | - double qr = culateCJLC(listSche, "缺人"); | |
| 956 | - double qc = culateCJLC(listSche, "缺车"); | |
| 957 | - double qrqc = Arith.add(qr, qc);//缺人缺车 | |
| 958 | - double kx = culateCJLC(listSche, "客稀"); | |
| 959 | - double qh = culateCJLC(listSche, "气候"); | |
| 960 | - double yw = culateCJLC(listSche, "援外"); | |
| 961 | - double lb_pc = culateCJLC(listSche, "配车"); | |
| 962 | - double lb_by = culateCJLC(listSche, "保养"); | |
| 963 | - double lb_cj = culateCJLC(listSche, "抽减"); | |
| 964 | - double lb_qt = culateCJLC(listSche, "其他"); | |
| 965 | - double qt = Arith.add(Arith.add(lb_pc, lb_by), Arith.add(lb_cj, lb_qt));//其他 | |
| 966 | - | |
| 967 | - Map<String, Object> jhzglMap = new HashMap<String, Object>(); | |
| 968 | - jhzglMap.put("name", "计划总公里"); | |
| 969 | - jhzglMap.put("value", jhzgl); | |
| 970 | - glList.add(jhzglMap); | |
| 971 | - Map<String, Object> sjzglMap = new HashMap<String, Object>(); | |
| 972 | - sjzglMap.put("name", "实际总公里"); | |
| 973 | - sjzglMap.put("value", sjzgl); | |
| 974 | - glList.add(sjzglMap); | |
| 975 | - Map<String, Object> lzMap = new HashMap<String, Object>(); | |
| 976 | - lzMap.put("name", "路阻"); | |
| 977 | - lzMap.put("value", lz); | |
| 978 | - glList.add(lzMap); | |
| 979 | - Map<String, Object> dmMap = new HashMap<String, Object>(); | |
| 980 | - dmMap.put("name", "吊慢"); | |
| 981 | - dmMap.put("value", dm); | |
| 982 | - glList.add(dmMap); | |
| 983 | - Map<String, Object> gzMap = new HashMap<String, Object>(); | |
| 984 | - gzMap.put("name", "故障"); | |
| 985 | - gzMap.put("value", gz); | |
| 986 | - glList.add(gzMap); | |
| 987 | - Map<String, Object> jfMap = new HashMap<String, Object>(); | |
| 988 | - jfMap.put("name", "纠纷"); | |
| 989 | - jfMap.put("value", jf); | |
| 990 | - glList.add(jfMap); | |
| 991 | - Map<String, Object> zsMap = new HashMap<String, Object>(); | |
| 992 | - zsMap.put("name", "肇事"); | |
| 993 | - zsMap.put("value", zs); | |
| 994 | - glList.add(zsMap); | |
| 995 | - Map<String, Object> qrqcMap = new HashMap<String, Object>(); | |
| 996 | - qrqcMap.put("name", "缺人缺车"); | |
| 997 | - qrqcMap.put("value", qrqc); | |
| 998 | - glList.add(qrqcMap); | |
| 999 | - Map<String, Object> kxMap = new HashMap<String, Object>(); | |
| 1000 | - kxMap.put("name", "客稀"); | |
| 1001 | - kxMap.put("value", kx); | |
| 1002 | - glList.add(kxMap); | |
| 1003 | - Map<String, Object> qhMap = new HashMap<String, Object>(); | |
| 1004 | - qhMap.put("name", "气候"); | |
| 1005 | - qhMap.put("value", qh); | |
| 1006 | - glList.add(qhMap); | |
| 1007 | - Map<String, Object> ywMap = new HashMap<String, Object>(); | |
| 1008 | - ywMap.put("name", "援外"); | |
| 1009 | - ywMap.put("value", yw); | |
| 1010 | - glList.add(ywMap); | |
| 1011 | - Map<String, Object> qtMap = new HashMap<String, Object>(); | |
| 1012 | - qtMap.put("name", "其他"); | |
| 1013 | - qtMap.put("value", qt); | |
| 1014 | - glList.add(qtMap); | |
| 1015 | - | |
| 1016 | - | |
| 1017 | - resMap.put("lineCount", lineCount); | |
| 1018 | - resMap.put("level1Count", level1); | |
| 1019 | - resMap.put("level2Count", level2); | |
| 1020 | - resMap.put("sjbcs", sjbcs_z); | |
| 1021 | - resMap.put("sjlcs", yygl_z.doubleValue()); | |
| 1022 | - | |
| 1023 | - resMap.put("ccl", jhcc>0?new BigDecimal(sjcc).divide(new BigDecimal(jhcc), | |
| 1024 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1025 | - resMap.put("bczxl", jhbc>0?new BigDecimal(sjbc).divide(new BigDecimal(jhbc), | |
| 1026 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1027 | - resMap.put("smbzdl", jhsmbc>0?new BigDecimal(sjsmbc).divide(new BigDecimal(jhsmbc), | |
| 1028 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1029 | - resMap.put("qqzzdl", jhqqbc>0?new BigDecimal(sjqqzd).divide(new BigDecimal(jhqqbc), | |
| 1030 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1031 | - resMap.put("gpzdl", jhgpqqbc>0?new BigDecimal(sjgpqqzd).divide(new BigDecimal(jhgpqqbc), | |
| 1032 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1033 | - resMap.put("qkl", bcs_qk>0?new BigDecimal(qks).divide(new BigDecimal(bcs_qk), | |
| 1034 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1035 | - | |
| 1036 | - resMap.put("ratioList", zxlList); | |
| 1037 | - | |
| 1038 | - resMap.put("detailsList", detailsList); | |
| 1039 | - | |
| 1040 | - resMap.put("mileageList", glList); | |
| 1041 | - | |
| 1042 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 1043 | - } | |
| 1044 | - | |
| 1045 | - /**给大屏按日期查线路指标 | |
| 1046 | - * | |
| 1047 | - */ | |
| 1048 | - @GET | |
| 1049 | - @Path("/selectData/getScheduleStatistics/{date}") | |
| 1050 | - public JSONObject getScheduleStatistics(@PathParam("date") String date){ | |
| 1051 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 1052 | - | |
| 1053 | - String gpLineSql = "select * from bsth_c_line_plate"; | |
| 1054 | - List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | |
| 1055 | - new RowMapper<Map<String, Object>>(){ | |
| 1056 | - @Override | |
| 1057 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1058 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1059 | - m.put("lineName", rs.getString("line_name")); | |
| 1060 | - m.put("lineCode", rs.getString("line_code")); | |
| 1061 | - return m; | |
| 1062 | - } | |
| 1063 | - }); | |
| 1064 | - | |
| 1065 | - Set<String> gpSet = new HashSet<String>(); | |
| 1066 | - for(Map<String, Object> t : gpLineList){ | |
| 1067 | - if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | |
| 1068 | - gpSet.add(t.get("lineCode").toString().trim()); | |
| 1069 | - } | |
| 1070 | - } | |
| 1071 | - | |
| 1072 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 1073 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 1074 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 1075 | - new RowMapper<Map<String, Object>>(){ | |
| 1076 | - @Override | |
| 1077 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1078 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1079 | - m.put("lineCode", rs.getString("line_code")); | |
| 1080 | - return m; | |
| 1081 | - } | |
| 1082 | - }); | |
| 1083 | - Set<String> yyLine = new HashSet<String>(); | |
| 1084 | - for(Map<String, Object> t : yyxlList){ | |
| 1085 | - if(t.get("lineCode") != null){ | |
| 1086 | - yyLine.add(t.get("lineCode").toString()); | |
| 1087 | - } | |
| 1088 | - } | |
| 1089 | - | |
| 1090 | - | |
| 1091 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 1092 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 1093 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 1094 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 1095 | - + " jhszfcs,sjszfczds,szfczdl,create_date" | |
| 1096 | - + " from bsth_c_calc_count " | |
| 1097 | - + " where date = ? and gsdm != '77'"; | |
| 1098 | - | |
| 1099 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, new Object[]{date}, | |
| 1100 | - new RowMapper<Map<String, Object>>(){ | |
| 1101 | - @Override | |
| 1102 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1103 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1104 | - m.put("lineCode",rs.getString("xl")); | |
| 1105 | - m.put("lineName", rs.getString("xl_name")); | |
| 1106 | - m.put("date", rs.getString("date")); | |
| 1107 | - | |
| 1108 | - m.put("jhbc", rs.getString("jhbc")); | |
| 1109 | - m.put("sjbc", rs.getString("sjbc")); | |
| 1110 | - m.put("bczxl", rs.getString("bczxl")); | |
| 1111 | - m.put("jhbcz", rs.getString("jhbcz")); | |
| 1112 | - | |
| 1113 | - m.put("jhcc", rs.getString("jhcc")); | |
| 1114 | - m.put("sjcc", rs.getString("sjcc")); | |
| 1115 | - m.put("ccl", rs.getString("ccl")); | |
| 1116 | - m.put("jhccz", rs.getString("jhccz")); | |
| 1117 | - | |
| 1118 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 1119 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 1120 | - m.put("jhyylcz", rs.getString("jhyylcz")); | |
| 1121 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 1122 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 1123 | - m.put("jhkslcz", rs.getString("jhkslcz")); | |
| 1124 | - | |
| 1125 | - m.put("jhgfbcs", rs.getString("jhssgfbcs")); | |
| 1126 | - m.put("sjgfbcs", rs.getString("sjgfbcs")); | |
| 1127 | - m.put("jhgfbcsz", rs.getString("jhgfbcsz")); | |
| 1128 | - m.put("jhdgbcs", rs.getString("jhssdgbcs")); | |
| 1129 | - m.put("sjdgbcs", rs.getString("sjdgbcs")); | |
| 1130 | - m.put("jhdgbcsz", rs.getString("jhdgbcsz")); | |
| 1131 | - | |
| 1132 | - m.put("jhsmbcs", rs.getString("jhsmbcs")); | |
| 1133 | - m.put("sjsmbczds", rs.getString("sjsmbczds")); | |
| 1134 | - m.put("smbczdl", rs.getString("smbczdl")); | |
| 1135 | - m.put("jhsmbcsz", rs.getString("jhsmbcsz")); | |
| 1136 | - m.put("sjsmbczdsz", rs.getString("sjsmbczdsz")); | |
| 1137 | - m.put("smbczdlz", rs.getString("smbczdlz")); | |
| 1138 | - | |
| 1139 | - m.put("jhszfcs", rs.getString("jhszfcs")); | |
| 1140 | - m.put("sjszfczds", rs.getString("sjszfczds")); | |
| 1141 | - m.put("szfczdl", rs.getString("szfczdl")); | |
| 1142 | - | |
| 1143 | - Date date = new Date(); | |
| 1144 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 1145 | - m.put("createDate", sdf.format(date)); | |
| 1146 | - return m; | |
| 1147 | - } | |
| 1148 | - }); | |
| 1149 | - | |
| 1150 | - List<Map<String, Object>> ccDetail = new ArrayList<Map<String,Object>>(); | |
| 1151 | - List<Map<String, Object>> bcDetail = new ArrayList<Map<String,Object>>(); | |
| 1152 | - List<Map<String, Object>> smDetail = new ArrayList<Map<String,Object>>(); | |
| 1153 | - List<Map<String, Object>> qqDetail = new ArrayList<Map<String,Object>>(); | |
| 1154 | - List<Map<String, Object>> gpDetail = new ArrayList<Map<String,Object>>(); | |
| 1155 | - List<Map<String, Object>> qkDetail = new ArrayList<Map<String,Object>>(); | |
| 1156 | - | |
| 1157 | - long sjbcs_z = 0l;//实时总班次 | |
| 1158 | - BigDecimal yygl_z = new BigDecimal(0);//实时总营运里程 | |
| 1159 | - long jhcc = 0, sjcc = 0, jhbc = 0, sjbc = 0, jhsmbc = 0, sjsmbc = 0, | |
| 1160 | - jhqqbc = 0, sjqqzd = 0, jhgpqqbc = 0, sjgpqqzd = 0, bcs_qk = 0, qks = 0; | |
| 1161 | - | |
| 1162 | - for(Map<String, Object> t : list){ | |
| 1163 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 1164 | - sjbcs_z += Long.valueOf(t.get("sjbc").toString()); | |
| 1165 | - yygl_z = yygl_z.add(new BigDecimal(t.get("sjyylc").toString())); | |
| 1166 | - | |
| 1167 | - jhcc += Long.valueOf(t.get("jhccz").toString()); | |
| 1168 | - sjcc += Long.valueOf(t.get("sjcc").toString()); | |
| 1169 | - jhbc += Long.valueOf(t.get("jhbc").toString()); | |
| 1170 | - sjbc += Long.valueOf(t.get("sjbc").toString()); | |
| 1171 | - jhsmbc += Long.valueOf(t.get("jhsmbcs").toString()); | |
| 1172 | - sjsmbc += Long.valueOf(t.get("sjsmbczds").toString()); | |
| 1173 | - jhqqbc += Long.valueOf(t.get("jhszfcs").toString()); | |
| 1174 | - sjqqzd += Long.valueOf(t.get("sjszfczds").toString()); | |
| 1175 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 1176 | - jhgpqqbc += Long.valueOf(t.get("jhszfcs").toString()); | |
| 1177 | - sjgpqqzd += Long.valueOf(t.get("sjszfczds").toString()); | |
| 1178 | - } | |
| 1179 | - | |
| 1180 | - Map<String, Object> cc = new HashMap<String, Object>(); | |
| 1181 | - cc.put("type", "线路出车详情"); | |
| 1182 | - cc.put("lineName", t.get("lineName").toString()); | |
| 1183 | - cc.put("jh", t.get("jhcc").toString()); | |
| 1184 | - cc.put("sj", t.get("sjcc").toString()); | |
| 1185 | - ccDetail.add(cc); | |
| 1186 | - | |
| 1187 | - Map<String, Object> bc = new HashMap<String, Object>(); | |
| 1188 | - bc.put("type", "班次执行详情"); | |
| 1189 | - bc.put("lineName", t.get("lineName").toString()); | |
| 1190 | - bc.put("jh", t.get("jhbc").toString()); | |
| 1191 | - bc.put("sj", t.get("sjbc").toString()); | |
| 1192 | - bcDetail.add(bc); | |
| 1193 | - | |
| 1194 | - Map<String, Object> sm = new HashMap<String, Object>(); | |
| 1195 | - sm.put("type", "首站发车详情"); | |
| 1196 | - sm.put("lineName", t.get("lineName").toString()); | |
| 1197 | - sm.put("jh", t.get("jhsmbcs").toString()); | |
| 1198 | - sm.put("sj", t.get("sjsmbczds").toString()); | |
| 1199 | - smDetail.add(sm); | |
| 1200 | - | |
| 1201 | - Map<String, Object> qq = new HashMap<String, Object>(); | |
| 1202 | - qq.put("type", "起讫站发车准点详情"); | |
| 1203 | - qq.put("lineName", t.get("lineName").toString()); | |
| 1204 | - qq.put("jh", t.get("jhszfcs").toString()); | |
| 1205 | - qq.put("sj", t.get("sjszfczds").toString()); | |
| 1206 | - qqDetail.add(qq); | |
| 1207 | - | |
| 1208 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 1209 | - Map<String, Object> gp = new HashMap<String, Object>(); | |
| 1210 | - gp.put("type", "挂牌线路发车准点详情"); | |
| 1211 | - gp.put("lineName", t.get("lineName").toString()); | |
| 1212 | - gp.put("jh", t.get("jhszfcs").toString()); | |
| 1213 | - gp.put("sj", t.get("sjszfczds").toString()); | |
| 1214 | - gpDetail.add(gp); | |
| 1215 | - } | |
| 1216 | - } | |
| 1217 | - } | |
| 1218 | - | |
| 1219 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | |
| 1220 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date); | |
| 1221 | - for(ScheduleRealInfo s : findAll){ | |
| 1222 | - if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 1223 | - if(!isInOut(s) && !s.isCcService() && s.getStatus() != -1 && s.getStatus() != 0){ | |
| 1224 | - String xlName = s.getXlName(); | |
| 1225 | - if(!(keyMap.containsKey(xlName))){ | |
| 1226 | - Map<String, Object> qk = new HashMap<String, Object>(); | |
| 1227 | - qk.put("type", "线路签卡详情"); | |
| 1228 | - qk.put("lineName", xlName); | |
| 1229 | - qk.put("jh", 0); | |
| 1230 | - qk.put("sj", 0); | |
| 1231 | - keyMap.put(xlName, qk); | |
| 1232 | - qkDetail.add(qk); | |
| 1233 | - } | |
| 1234 | - Map<String, Object> qk = keyMap.get(xlName); | |
| 1235 | - qk.put("jh", Long.valueOf(qk.get("jh").toString()) + 1); | |
| 1236 | - ++bcs_qk; | |
| 1237 | - String sty = decimalToBinary(s.getRfidState()); | |
| 1238 | - Integer state = Integer.parseInt(sty); | |
| 1239 | - if ((state & 4) == 4) { | |
| 1240 | - qk.put("sj", Long.valueOf(qk.get("sj").toString()) + 1); | |
| 1241 | - ++qks; | |
| 1242 | - } | |
| 1243 | - } | |
| 1244 | - } | |
| 1245 | - } | |
| 1246 | - | |
| 1247 | - List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | |
| 1248 | - detailsList.addAll(ccDetail); | |
| 1249 | - detailsList.addAll(bcDetail); | |
| 1250 | - detailsList.addAll(smDetail); | |
| 1251 | - detailsList.addAll(qqDetail); | |
| 1252 | - detailsList.addAll(gpDetail); | |
| 1253 | - detailsList.addAll(qkDetail); | |
| 1254 | - | |
| 1255 | - resMap.put("ccl", jhcc>0?new BigDecimal(sjcc).divide(new BigDecimal(jhcc), | |
| 1256 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1257 | - resMap.put("bczxl", jhbc>0?new BigDecimal(sjbc).divide(new BigDecimal(jhbc), | |
| 1258 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1259 | - resMap.put("smbzdl", jhsmbc>0?new BigDecimal(sjsmbc).divide(new BigDecimal(jhsmbc), | |
| 1260 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1261 | - resMap.put("qqzzdl", jhqqbc>0?new BigDecimal(sjqqzd).divide(new BigDecimal(jhqqbc), | |
| 1262 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1263 | - resMap.put("gpzdl", jhgpqqbc>0?new BigDecimal(sjgpqqzd).divide(new BigDecimal(jhgpqqbc), | |
| 1264 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1265 | - resMap.put("qkl", bcs_qk>0?new BigDecimal(qks).divide(new BigDecimal(bcs_qk), | |
| 1266 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 1267 | - | |
| 1268 | - resMap.put("detailsList", detailsList); | |
| 1269 | - | |
| 1270 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 1271 | - } | |
| 1272 | - | |
| 1273 | - /**给电科手机端查线路指标(出车率) | |
| 1274 | - * | |
| 1275 | - */ | |
| 1276 | - @GET | |
| 1277 | - @Path("/selectData/getDepartureBus/{company}/{branchCompany}") | |
| 1278 | - public JSONObject getDepartureBus(@PathParam("company") String company, | |
| 1279 | - @PathParam("branchCompany") String branchCompany){ | |
| 1280 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 1281 | - String date = sd.format(new Date()); | |
| 1282 | - String gs = "", fgs = ""; | |
| 1283 | - if(company.trim().length() > 0 && !("all".equals(company.trim()))){ | |
| 1284 | - gs = company.trim(); | |
| 1285 | - } | |
| 1286 | - if(branchCompany.trim().length() > 0 && !("all".equals(branchCompany.trim()))){ | |
| 1287 | - fgs = branchCompany.trim(); | |
| 1288 | - } | |
| 1289 | - | |
| 1290 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 1291 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 1292 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 1293 | - new RowMapper<Map<String, Object>>(){ | |
| 1294 | - @Override | |
| 1295 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1296 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1297 | - m.put("lineCode", rs.getString("line_code")); | |
| 1298 | - return m; | |
| 1299 | - } | |
| 1300 | - }); | |
| 1301 | - Set<String> yyLine = new HashSet<String>(); | |
| 1302 | - for(Map<String, Object> t : yyxlList){ | |
| 1303 | - if(t.get("lineCode") != null){ | |
| 1304 | - yyLine.add(t.get("lineCode").toString()); | |
| 1305 | - } | |
| 1306 | - } | |
| 1307 | - | |
| 1308 | - List<String> objList = new ArrayList<String>(); | |
| 1309 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 1310 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 1311 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 1312 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 1313 | - + " jhszfcs,sjszfczds,szfczdl,create_date" | |
| 1314 | - + " from bsth_c_calc_count " | |
| 1315 | - + " where date = ? and gsdm != '77'"; | |
| 1316 | - objList.add(date); | |
| 1317 | - if(fgs.length() > 0){ | |
| 1318 | - sql +=" and gsdm = ? and fgsdm = ?"; | |
| 1319 | - objList.add(gs); | |
| 1320 | - objList.add(fgs); | |
| 1321 | - } else if(gs.length() > 0){ | |
| 1322 | - sql +=" and gsdm = ?"; | |
| 1323 | - objList.add(gs); | |
| 1324 | - } | |
| 1325 | - | |
| 1326 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1327 | - objList.toArray(), | |
| 1328 | - new RowMapper<Map<String, Object>>(){ | |
| 1329 | - @Override | |
| 1330 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1331 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1332 | - m.put("lineCode",rs.getString("xl")); | |
| 1333 | - m.put("lineName", rs.getString("xl_name")); | |
| 1334 | - m.put("date", rs.getString("date")); | |
| 1335 | - | |
| 1336 | - m.put("jhcc", rs.getString("jhcc")); | |
| 1337 | - m.put("sjcc", rs.getString("sjcc")); | |
| 1338 | - m.put("jhccz", rs.getString("jhccz")); | |
| 1339 | - | |
| 1340 | - Date date = new Date(); | |
| 1341 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 1342 | - m.put("createDate", sdf.format(date)); | |
| 1343 | - return m; | |
| 1344 | - } | |
| 1345 | - }); | |
| 1346 | - | |
| 1347 | - List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | |
| 1348 | - | |
| 1349 | - long jh = 0, sj = 0; | |
| 1350 | - | |
| 1351 | - for(Map<String, Object> t : list){ | |
| 1352 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 1353 | - | |
| 1354 | - Long plan = Long.valueOf(t.get("jhccz").toString()); | |
| 1355 | - Long real = Long.valueOf(t.get("sjcc").toString()); | |
| 1356 | - | |
| 1357 | - jh += plan; | |
| 1358 | - sj += real; | |
| 1359 | - | |
| 1360 | - Map<String, Object> detail = new HashMap<String, Object>(); | |
| 1361 | - detail.put("lineName", t.get("lineName").toString()); | |
| 1362 | - detail.put("plan", plan); | |
| 1363 | - detail.put("real", real); | |
| 1364 | - detail.put("ratio", plan>0?new BigDecimal(real*100l).divide( | |
| 1365 | - new BigDecimal(plan), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1366 | - detailsList.add(detail); | |
| 1367 | - } | |
| 1368 | - } | |
| 1369 | - | |
| 1370 | - resMap.put("plan", jh); | |
| 1371 | - resMap.put("real", sj); | |
| 1372 | - resMap.put("ratio", jh>0?new BigDecimal(sj*100l).divide( | |
| 1373 | - new BigDecimal(jh), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1374 | - | |
| 1375 | - resMap.put("detailsList", detailsList); | |
| 1376 | - | |
| 1377 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 1378 | - } | |
| 1379 | - | |
| 1380 | - /**给电科手机端查线路指标(班次执行率) | |
| 1381 | - * | |
| 1382 | - */ | |
| 1383 | - @GET | |
| 1384 | - @Path("/selectData/getFinishScheduleBus/{company}/{branchCompany}") | |
| 1385 | - public JSONObject getFinishScheduleBus(@PathParam("company") String company, | |
| 1386 | - @PathParam("branchCompany") String branchCompany){ | |
| 1387 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 1388 | - String date = sd.format(new Date()); | |
| 1389 | - String gs = "", fgs = ""; | |
| 1390 | - if(company.trim().length() > 0 && !("all".equals(company.trim()))){ | |
| 1391 | - gs = company.trim(); | |
| 1392 | - } | |
| 1393 | - if(branchCompany.trim().length() > 0 && !("all".equals(branchCompany.trim()))){ | |
| 1394 | - fgs = branchCompany.trim(); | |
| 1395 | - } | |
| 1396 | - | |
| 1397 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 1398 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 1399 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 1400 | - new RowMapper<Map<String, Object>>(){ | |
| 1401 | - @Override | |
| 1402 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1403 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1404 | - m.put("lineCode", rs.getString("line_code")); | |
| 1405 | - return m; | |
| 1406 | - } | |
| 1407 | - }); | |
| 1408 | - Set<String> yyLine = new HashSet<String>(); | |
| 1409 | - for(Map<String, Object> t : yyxlList){ | |
| 1410 | - if(t.get("lineCode") != null){ | |
| 1411 | - yyLine.add(t.get("lineCode").toString()); | |
| 1412 | - } | |
| 1413 | - } | |
| 1414 | - | |
| 1415 | - List<String> objList = new ArrayList<String>(); | |
| 1416 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 1417 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 1418 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 1419 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 1420 | - + " jhszfcs,sjszfczds,szfczdl,create_date" | |
| 1421 | - + " from bsth_c_calc_count " | |
| 1422 | - + " where date = ? and gsdm != '77'"; | |
| 1423 | - objList.add(date); | |
| 1424 | - if(fgs.length() > 0){ | |
| 1425 | - sql +=" and gsdm = ? and fgsdm = ?"; | |
| 1426 | - objList.add(gs); | |
| 1427 | - objList.add(fgs); | |
| 1428 | - } else if(gs.length() > 0){ | |
| 1429 | - sql +=" and gsdm = ?"; | |
| 1430 | - objList.add(gs); | |
| 1431 | - } | |
| 1432 | - | |
| 1433 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1434 | - objList.toArray(), | |
| 1435 | - new RowMapper<Map<String, Object>>(){ | |
| 1436 | - @Override | |
| 1437 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1438 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1439 | - m.put("lineCode",rs.getString("xl")); | |
| 1440 | - m.put("lineName", rs.getString("xl_name")); | |
| 1441 | - m.put("date", rs.getString("date")); | |
| 1442 | - | |
| 1443 | - m.put("jhbc", rs.getString("jhbc")); | |
| 1444 | - m.put("sjbc", rs.getString("sjbc")); | |
| 1445 | - | |
| 1446 | - Date date = new Date(); | |
| 1447 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 1448 | - m.put("createDate", sdf.format(date)); | |
| 1449 | - return m; | |
| 1450 | - } | |
| 1451 | - }); | |
| 1452 | - | |
| 1453 | - List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | |
| 1454 | - | |
| 1455 | - long jh = 0, sj = 0; | |
| 1456 | - | |
| 1457 | - for(Map<String, Object> t : list){ | |
| 1458 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 1459 | - | |
| 1460 | - Long plan = Long.valueOf(t.get("jhbc").toString()); | |
| 1461 | - Long real = Long.valueOf(t.get("sjbc").toString()); | |
| 1462 | - | |
| 1463 | - jh += plan; | |
| 1464 | - sj += real; | |
| 1465 | - | |
| 1466 | - Map<String, Object> detail = new HashMap<String, Object>(); | |
| 1467 | - detail.put("lineName", t.get("lineName").toString()); | |
| 1468 | - detail.put("plan", plan); | |
| 1469 | - detail.put("real", real); | |
| 1470 | - detail.put("ratio", plan>0?new BigDecimal(real*100l).divide( | |
| 1471 | - new BigDecimal(plan), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1472 | - detailsList.add(detail); | |
| 1473 | - } | |
| 1474 | - } | |
| 1475 | - | |
| 1476 | - resMap.put("plan", jh); | |
| 1477 | - resMap.put("real", sj); | |
| 1478 | - resMap.put("ratio", jh>0?new BigDecimal(sj*100l).divide( | |
| 1479 | - new BigDecimal(jh), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1480 | - | |
| 1481 | - resMap.put("detailsList", detailsList); | |
| 1482 | - | |
| 1483 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 1484 | - } | |
| 1485 | - | |
| 1486 | - /**给电科手机端查线路指标(首末班车发车准点率) | |
| 1487 | - * | |
| 1488 | - */ | |
| 1489 | - @GET | |
| 1490 | - @Path("/selectData/getBeginAndEnd/{company}/{branchCompany}") | |
| 1491 | - public JSONObject getBeginAndEnd(@PathParam("company") String company, | |
| 1492 | - @PathParam("branchCompany") String branchCompany){ | |
| 1493 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 1494 | - String date = sd.format(new Date()); | |
| 1495 | - String gs = "", fgs = ""; | |
| 1496 | - if(company.trim().length() > 0 && !("all".equals(company.trim()))){ | |
| 1497 | - gs = company.trim(); | |
| 1498 | - } | |
| 1499 | - if(branchCompany.trim().length() > 0 && !("all".equals(branchCompany.trim()))){ | |
| 1500 | - fgs = branchCompany.trim(); | |
| 1501 | - } | |
| 1502 | - | |
| 1503 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 1504 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 1505 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 1506 | - new RowMapper<Map<String, Object>>(){ | |
| 1507 | - @Override | |
| 1508 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1509 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1510 | - m.put("lineCode", rs.getString("line_code")); | |
| 1511 | - return m; | |
| 1512 | - } | |
| 1513 | - }); | |
| 1514 | - Set<String> yyLine = new HashSet<String>(); | |
| 1515 | - for(Map<String, Object> t : yyxlList){ | |
| 1516 | - if(t.get("lineCode") != null){ | |
| 1517 | - yyLine.add(t.get("lineCode").toString()); | |
| 1518 | - } | |
| 1519 | - } | |
| 1520 | - | |
| 1521 | - List<String> objList = new ArrayList<String>(); | |
| 1522 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 1523 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 1524 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 1525 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 1526 | - + " jhszfcs,sjszfczds,szfczdl,create_date" | |
| 1527 | - + " from bsth_c_calc_count " | |
| 1528 | - + " where date = ? and gsdm != '77'"; | |
| 1529 | - objList.add(date); | |
| 1530 | - if(fgs.length() > 0){ | |
| 1531 | - sql +=" and gsdm = ? and fgsdm = ?"; | |
| 1532 | - objList.add(gs); | |
| 1533 | - objList.add(fgs); | |
| 1534 | - } else if(gs.length() > 0){ | |
| 1535 | - sql +=" and gsdm = ?"; | |
| 1536 | - objList.add(gs); | |
| 1537 | - } | |
| 1538 | - | |
| 1539 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1540 | - objList.toArray(), | |
| 1541 | - new RowMapper<Map<String, Object>>(){ | |
| 1542 | - @Override | |
| 1543 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1544 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1545 | - m.put("lineCode",rs.getString("xl")); | |
| 1546 | - m.put("lineName", rs.getString("xl_name")); | |
| 1547 | - m.put("date", rs.getString("date")); | |
| 1548 | - | |
| 1549 | - m.put("jhsmbcs", rs.getString("jhsmbcs")); | |
| 1550 | - m.put("sjsmbczds", rs.getString("sjsmbczds")); | |
| 1551 | - | |
| 1552 | - Date date = new Date(); | |
| 1553 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 1554 | - m.put("createDate", sdf.format(date)); | |
| 1555 | - return m; | |
| 1556 | - } | |
| 1557 | - }); | |
| 1558 | - | |
| 1559 | - List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | |
| 1560 | - | |
| 1561 | - long jh = 0, sj = 0; | |
| 1562 | - | |
| 1563 | - for(Map<String, Object> t : list){ | |
| 1564 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 1565 | - | |
| 1566 | - Long plan = Long.valueOf(t.get("jhsmbcs").toString()); | |
| 1567 | - Long real = Long.valueOf(t.get("sjsmbczds").toString()); | |
| 1568 | - | |
| 1569 | - jh += plan; | |
| 1570 | - sj += real; | |
| 1571 | - | |
| 1572 | - Map<String, Object> detail = new HashMap<String, Object>(); | |
| 1573 | - detail.put("lineName", t.get("lineName").toString()); | |
| 1574 | - detail.put("plan", plan); | |
| 1575 | - detail.put("real", real); | |
| 1576 | - detail.put("ratio", plan>0?new BigDecimal(real*100l).divide( | |
| 1577 | - new BigDecimal(plan), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1578 | - detailsList.add(detail); | |
| 1579 | - } | |
| 1580 | - } | |
| 1581 | - | |
| 1582 | - resMap.put("plan", jh); | |
| 1583 | - resMap.put("real", sj); | |
| 1584 | - resMap.put("ratio", jh>0?new BigDecimal(sj*100l).divide( | |
| 1585 | - new BigDecimal(jh), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1586 | - | |
| 1587 | - resMap.put("detailsList", detailsList); | |
| 1588 | - | |
| 1589 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 1590 | - } | |
| 1591 | - | |
| 1592 | - /**给电科手机端查线路指标(起讫站发车准点率) | |
| 1593 | - * | |
| 1594 | - */ | |
| 1595 | - @GET | |
| 1596 | - @Path("/selectData/getPunctualBus/{company}/{branchCompany}") | |
| 1597 | - public JSONObject getPunctualBus(@PathParam("company") String company, | |
| 1598 | - @PathParam("branchCompany") String branchCompany){ | |
| 1599 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 1600 | - String date = sd.format(new Date()); | |
| 1601 | - String gs = "", fgs = ""; | |
| 1602 | - if(company.trim().length() > 0 && !("all".equals(company.trim()))){ | |
| 1603 | - gs = company.trim(); | |
| 1604 | - } | |
| 1605 | - if(branchCompany.trim().length() > 0 && !("all".equals(branchCompany.trim()))){ | |
| 1606 | - fgs = branchCompany.trim(); | |
| 1607 | - } | |
| 1608 | - | |
| 1609 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 1610 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 1611 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 1612 | - new RowMapper<Map<String, Object>>(){ | |
| 1613 | - @Override | |
| 1614 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1615 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1616 | - m.put("lineCode", rs.getString("line_code")); | |
| 1617 | - return m; | |
| 1618 | - } | |
| 1619 | - }); | |
| 1620 | - Set<String> yyLine = new HashSet<String>(); | |
| 1621 | - for(Map<String, Object> t : yyxlList){ | |
| 1622 | - if(t.get("lineCode") != null){ | |
| 1623 | - yyLine.add(t.get("lineCode").toString()); | |
| 1624 | - } | |
| 1625 | - } | |
| 1626 | - | |
| 1627 | - List<String> objList = new ArrayList<String>(); | |
| 1628 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 1629 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 1630 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 1631 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 1632 | - + " jhszfcs,sjszfczds,szfczdl,create_date" | |
| 1633 | - + " from bsth_c_calc_count " | |
| 1634 | - + " where date = ? and gsdm != '77'"; | |
| 1635 | - objList.add(date); | |
| 1636 | - if(fgs.length() > 0){ | |
| 1637 | - sql +=" and gsdm = ? and fgsdm = ?"; | |
| 1638 | - objList.add(gs); | |
| 1639 | - objList.add(fgs); | |
| 1640 | - } else if(gs.length() > 0){ | |
| 1641 | - sql +=" and gsdm = ?"; | |
| 1642 | - objList.add(gs); | |
| 1643 | - } | |
| 1644 | - | |
| 1645 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1646 | - objList.toArray(), | |
| 1647 | - new RowMapper<Map<String, Object>>(){ | |
| 1648 | - @Override | |
| 1649 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1650 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1651 | - m.put("lineCode",rs.getString("xl")); | |
| 1652 | - m.put("lineName", rs.getString("xl_name")); | |
| 1653 | - m.put("date", rs.getString("date")); | |
| 1654 | - | |
| 1655 | - m.put("jhszfcs", rs.getString("jhszfcs")); | |
| 1656 | - m.put("sjszfczds", rs.getString("sjszfczds")); | |
| 1657 | - | |
| 1658 | - Date date = new Date(); | |
| 1659 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 1660 | - m.put("createDate", sdf.format(date)); | |
| 1661 | - return m; | |
| 1662 | - } | |
| 1663 | - }); | |
| 1664 | - | |
| 1665 | - List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | |
| 1666 | - | |
| 1667 | - long jh = 0, sj = 0; | |
| 1668 | - | |
| 1669 | - for(Map<String, Object> t : list){ | |
| 1670 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 1671 | - | |
| 1672 | - Long plan = Long.valueOf(t.get("jhszfcs").toString()); | |
| 1673 | - Long real = Long.valueOf(t.get("sjszfczds").toString()); | |
| 1674 | - | |
| 1675 | - jh += plan; | |
| 1676 | - sj += real; | |
| 1677 | - | |
| 1678 | - Map<String, Object> detail = new HashMap<String, Object>(); | |
| 1679 | - detail.put("lineName", t.get("lineName").toString()); | |
| 1680 | - detail.put("plan", plan); | |
| 1681 | - detail.put("real", real); | |
| 1682 | - detail.put("ratio", plan>0?new BigDecimal(real*100l).divide( | |
| 1683 | - new BigDecimal(plan), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1684 | - detailsList.add(detail); | |
| 1685 | - } | |
| 1686 | - } | |
| 1687 | - | |
| 1688 | - resMap.put("plan", jh); | |
| 1689 | - resMap.put("real", sj); | |
| 1690 | - resMap.put("ratio", jh>0?new BigDecimal(sj*100l).divide( | |
| 1691 | - new BigDecimal(jh), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1692 | - | |
| 1693 | - resMap.put("detailsList", detailsList); | |
| 1694 | - | |
| 1695 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 1696 | - } | |
| 1697 | - | |
| 1698 | - /**给电科手机端查线路指标(挂牌线路发车准点率) | |
| 1699 | - * | |
| 1700 | - */ | |
| 1701 | - @GET | |
| 1702 | - @Path("/selectData/getPlateLineBus/{company}/{branchCompany}") | |
| 1703 | - public JSONObject getPlateLineBus(@PathParam("company") String company, | |
| 1704 | - @PathParam("branchCompany") String branchCompany){ | |
| 1705 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 1706 | - | |
| 1707 | - String gpLineSql = "select * from bsth_c_line_plate"; | |
| 1708 | - List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | |
| 1709 | - new RowMapper<Map<String, Object>>(){ | |
| 1710 | - @Override | |
| 1711 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1712 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1713 | - m.put("lineName", rs.getString("line_name")); | |
| 1714 | - m.put("lineCode", rs.getString("line_code")); | |
| 1715 | - return m; | |
| 1716 | - } | |
| 1717 | - }); | |
| 1718 | - | |
| 1719 | - Set<String> gpSet = new HashSet<String>(); | |
| 1720 | - for(Map<String, Object> t : gpLineList){ | |
| 1721 | - if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | |
| 1722 | - gpSet.add(t.get("lineCode").toString().trim()); | |
| 1723 | - } | |
| 1724 | - } | |
| 1725 | - | |
| 1726 | - String date = sd.format(new Date()); | |
| 1727 | - String gs = "", fgs = ""; | |
| 1728 | - if(company.trim().length() > 0 && !("all".equals(company.trim()))){ | |
| 1729 | - gs = company.trim(); | |
| 1730 | - } | |
| 1731 | - if(branchCompany.trim().length() > 0 && !("all".equals(branchCompany.trim()))){ | |
| 1732 | - fgs = branchCompany.trim(); | |
| 1733 | - } | |
| 1734 | - | |
| 1735 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 1736 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 1737 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 1738 | - new RowMapper<Map<String, Object>>(){ | |
| 1739 | - @Override | |
| 1740 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1741 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1742 | - m.put("lineCode", rs.getString("line_code")); | |
| 1743 | - return m; | |
| 1744 | - } | |
| 1745 | - }); | |
| 1746 | - Set<String> yyLine = new HashSet<String>(); | |
| 1747 | - for(Map<String, Object> t : yyxlList){ | |
| 1748 | - if(t.get("lineCode") != null){ | |
| 1749 | - yyLine.add(t.get("lineCode").toString()); | |
| 1750 | - } | |
| 1751 | - } | |
| 1752 | - | |
| 1753 | - List<String> objList = new ArrayList<String>(); | |
| 1754 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 1755 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 1756 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 1757 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 1758 | - + " jhszfcs,sjszfczds,szfczdl,create_date" | |
| 1759 | - + " from bsth_c_calc_count " | |
| 1760 | - + " where date = ? and gsdm != '77'"; | |
| 1761 | - objList.add(date); | |
| 1762 | - if(fgs.length() > 0){ | |
| 1763 | - sql +=" and gsdm = ? and fgsdm = ?"; | |
| 1764 | - objList.add(gs); | |
| 1765 | - objList.add(fgs); | |
| 1766 | - } else if(gs.length() > 0){ | |
| 1767 | - sql +=" and gsdm = ?"; | |
| 1768 | - objList.add(gs); | |
| 1769 | - } | |
| 1770 | - | |
| 1771 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 1772 | - objList.toArray(), | |
| 1773 | - new RowMapper<Map<String, Object>>(){ | |
| 1774 | - @Override | |
| 1775 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1776 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1777 | - m.put("lineCode",rs.getString("xl")); | |
| 1778 | - m.put("lineName", rs.getString("xl_name")); | |
| 1779 | - m.put("date", rs.getString("date")); | |
| 1780 | - | |
| 1781 | - m.put("jhszfcs", rs.getString("jhszfcs")); | |
| 1782 | - m.put("sjszfczds", rs.getString("sjszfczds")); | |
| 1783 | - | |
| 1784 | - Date date = new Date(); | |
| 1785 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 1786 | - m.put("createDate", sdf.format(date)); | |
| 1787 | - return m; | |
| 1788 | - } | |
| 1789 | - }); | |
| 1790 | - | |
| 1791 | - List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | |
| 1792 | - | |
| 1793 | - long jh = 0, sj = 0; | |
| 1794 | - | |
| 1795 | - for(Map<String, Object> t : list){ | |
| 1796 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 1797 | - | |
| 1798 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 1799 | - | |
| 1800 | - Long plan = Long.valueOf(t.get("jhszfcs").toString()); | |
| 1801 | - Long real = Long.valueOf(t.get("sjszfczds").toString()); | |
| 1802 | - | |
| 1803 | - jh += plan; | |
| 1804 | - sj += real; | |
| 1805 | - | |
| 1806 | - Map<String, Object> detail = new HashMap<String, Object>(); | |
| 1807 | - detail.put("lineName", t.get("lineName").toString()); | |
| 1808 | - detail.put("plan", plan); | |
| 1809 | - detail.put("real", real); | |
| 1810 | - detail.put("ratio", plan>0?new BigDecimal(real*100l).divide( | |
| 1811 | - new BigDecimal(plan), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1812 | - detailsList.add(detail); | |
| 1813 | - } | |
| 1814 | - } | |
| 1815 | - } | |
| 1816 | - | |
| 1817 | - resMap.put("plan", jh); | |
| 1818 | - resMap.put("real", sj); | |
| 1819 | - resMap.put("ratio", jh>0?new BigDecimal(sj*100l).divide( | |
| 1820 | - new BigDecimal(jh), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1821 | - | |
| 1822 | - resMap.put("detailsList", detailsList); | |
| 1823 | - | |
| 1824 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 1825 | - } | |
| 1826 | - | |
| 1827 | - /**给电科手机端查线路指标(签卡率) | |
| 1828 | - * | |
| 1829 | - */ | |
| 1830 | - @GET | |
| 1831 | - @Path("/selectData/getCardSigning/{company}/{branchCompany}") | |
| 1832 | - public JSONObject getCardSigning(@PathParam("company") String company, | |
| 1833 | - @PathParam("branchCompany") String branchCompany){ | |
| 1834 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 1835 | - String date = sd.format(new Date()); | |
| 1836 | - String gs = "", fgs = ""; | |
| 1837 | - if(company.trim().length() > 0 && !("all".equals(company.trim()))){ | |
| 1838 | - gs = company.trim(); | |
| 1839 | - } | |
| 1840 | - if(branchCompany.trim().length() > 0 && !("all".equals(branchCompany.trim()))){ | |
| 1841 | - fgs = branchCompany.trim(); | |
| 1842 | - } | |
| 1843 | - | |
| 1844 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 1845 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 1846 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 1847 | - new RowMapper<Map<String, Object>>(){ | |
| 1848 | - @Override | |
| 1849 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1850 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1851 | - m.put("lineCode", rs.getString("line_code")); | |
| 1852 | - return m; | |
| 1853 | - } | |
| 1854 | - }); | |
| 1855 | - Set<String> yyLine = new HashSet<String>(); | |
| 1856 | - for(Map<String, Object> t : yyxlList){ | |
| 1857 | - if(t.get("lineCode") != null){ | |
| 1858 | - yyLine.add(t.get("lineCode").toString()); | |
| 1859 | - } | |
| 1860 | - } | |
| 1861 | - | |
| 1862 | - List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | |
| 1863 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | |
| 1864 | - | |
| 1865 | - long jh = 0, sj = 0; | |
| 1866 | - | |
| 1867 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date); | |
| 1868 | - for(ScheduleRealInfo s : findAll){ | |
| 1869 | - if(s.getGsBm() != null && s.getFgsBm() != null){ | |
| 1870 | - if("77".equals(s.getGsBm())){ | |
| 1871 | - continue; | |
| 1872 | - } | |
| 1873 | - if(fgs.length() > 0){ | |
| 1874 | - if(!(s.getGsBm().equals(gs)) || !(s.getFgsBm().equals(gs))){ | |
| 1875 | - continue; | |
| 1876 | - } | |
| 1877 | - } else if(gs.length() > 0){ | |
| 1878 | - if(!(s.getGsBm().equals(gs))){ | |
| 1879 | - continue; | |
| 1880 | - } | |
| 1881 | - } | |
| 1882 | - if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 1883 | - if(!isInOut(s) && !s.isCcService() && s.getStatus() != -1 && s.getStatus() != 0){ | |
| 1884 | - long plan = 0, real = 0; | |
| 1885 | - ++plan; | |
| 1886 | - ++jh; | |
| 1887 | - String sty = decimalToBinary(s.getRfidState()); | |
| 1888 | - Integer state = Integer.parseInt(sty); | |
| 1889 | - if ((state & 4) == 4) { | |
| 1890 | - ++real; | |
| 1891 | - ++sj; | |
| 1892 | - } | |
| 1893 | - if(!(keyMap.containsKey(s.getXlBm()))){ | |
| 1894 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 1895 | - m = new HashMap<String, Object>(); | |
| 1896 | - m.put("lineName", s.getXlName()); | |
| 1897 | - m.put("plan", "0"); | |
| 1898 | - m.put("real", "0"); | |
| 1899 | - keyMap.put(s.getXlBm(), m); | |
| 1900 | - detailsList.add(m); | |
| 1901 | - } | |
| 1902 | - Map<String, Object> m = keyMap.get(s.getXlBm()); | |
| 1903 | - m.put("plan", Long.valueOf(m.get("plan").toString()) + plan); | |
| 1904 | - m.put("real", Long.valueOf(m.get("real").toString()) + real); | |
| 1905 | - } | |
| 1906 | - } | |
| 1907 | - } | |
| 1908 | - } | |
| 1909 | - | |
| 1910 | - for(Map<String, Object> m : detailsList){ | |
| 1911 | - long plan = Long.valueOf(m.get("plan").toString()); | |
| 1912 | - long real = Long.valueOf(m.get("real").toString()); | |
| 1913 | - m.put("ratio", plan>0?new BigDecimal(real*100l).divide( | |
| 1914 | - new BigDecimal(plan), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1915 | - } | |
| 1916 | - | |
| 1917 | - resMap.put("plan", jh); | |
| 1918 | - resMap.put("real", sj); | |
| 1919 | - resMap.put("ratio", jh>0?new BigDecimal(sj*100l).divide( | |
| 1920 | - new BigDecimal(jh), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | |
| 1921 | - | |
| 1922 | - resMap.put("detailsList", detailsList); | |
| 1923 | - | |
| 1924 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 1925 | - } | |
| 1926 | - | |
| 1927 | - @GET | |
| 1928 | - @Path("/selectData/attendance") | |
| 1929 | - public JSONObject attendance(){ | |
| 1930 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 1931 | - SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 1932 | - | |
| 1933 | - int day = 7;//天数 | |
| 1934 | - | |
| 1935 | - Date dd = new Date(); | |
| 1936 | - String date = sd.format(dd); //yyyy-MM-dd 当天 | |
| 1937 | - Date dd2 = new Date(); | |
| 1938 | - dd2.setTime(dd.getTime() - ((long)(day-1))*1000*60*60*24); | |
| 1939 | - String date2 = sd.format(dd2); //yyyy-MM-dd 6天前(加上当天就是取7天数据) | |
| 1940 | - | |
| 1941 | - String[] dates = new String[day]; | |
| 1942 | - Map<String, Integer> datesMap = new HashMap<String, Integer>(); | |
| 1943 | - | |
| 1944 | - for(int i = 0; i < day; i++){ | |
| 1945 | - Date tempDate = new Date(); | |
| 1946 | - tempDate.setTime(dd2.getTime() + ((long)i)*1000*60*60*24); | |
| 1947 | - String format = sd.format(tempDate); | |
| 1948 | - dates[i] = format; | |
| 1949 | - datesMap.put(format, i); | |
| 1950 | - } | |
| 1951 | - | |
| 1952 | - | |
| 1953 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 1954 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 1955 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 1956 | - new RowMapper<Map<String, Object>>(){ | |
| 1957 | - @Override | |
| 1958 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 1959 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 1960 | - m.put("lineCode", rs.getString("line_code")); | |
| 1961 | - return m; | |
| 1962 | - } | |
| 1963 | - }); | |
| 1964 | - Set<String> yyLine = new HashSet<String>(); | |
| 1965 | - for(Map<String, Object> t : yyxlList){ | |
| 1966 | - if(t.get("lineCode") != null){ | |
| 1967 | - yyLine.add(t.get("lineCode").toString()); | |
| 1968 | - } | |
| 1969 | - } | |
| 1970 | - | |
| 1971 | - | |
| 1972 | - List<Map<String, Object>> attList = new ArrayList<Map<String, Object>>(); | |
| 1973 | - List<Map<String, Object>> lackList = new ArrayList<Map<String, Object>>(); | |
| 1974 | - Set<String> lackSet = new HashSet<String>(); | |
| 1975 | - | |
| 1976 | - for(int i = 0; i < dates.length; i++){ | |
| 1977 | - Set<String> jhSet = new HashSet<String>(); | |
| 1978 | - Set<String> sjSet = new HashSet<String>(); | |
| 1979 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(dates[i]); | |
| 1980 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | |
| 1981 | - for(ScheduleRealInfo s : findAll){ | |
| 1982 | - if(!("77".equals(s.getGsBm())) && s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 1983 | - if(!isInOut(s)){ | |
| 1984 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 1985 | - if (cts != null && cts.size() > 0) { | |
| 1986 | - list_s.add(s); | |
| 1987 | - } else { | |
| 1988 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 1989 | - list_s.add(s); | |
| 1990 | - } | |
| 1991 | - } | |
| 1992 | - | |
| 1993 | - if(!s.isSflj() && !s.isCcService()){ | |
| 1994 | - jhSet.add(s.getjGh() + "/" + s.getjName()); | |
| 1995 | - } | |
| 1996 | - } | |
| 1997 | - } | |
| 1998 | - } | |
| 1999 | - | |
| 2000 | - for(ScheduleRealInfo s : list_s){ | |
| 2001 | - if(!(s.getStatus() == -1)){ | |
| 2002 | - sjSet.add(s.getjGh() + "/" + s.getjName()); | |
| 2003 | - } | |
| 2004 | - } | |
| 2005 | - | |
| 2006 | - for(ScheduleRealInfo s : findAll){ | |
| 2007 | - try { | |
| 2008 | - if(!("77".equals(s.getGsBm())) && s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 2009 | - if (s.isSflj() || isInOut(s)){ | |
| 2010 | - continue; | |
| 2011 | - } | |
| 2012 | - | |
| 2013 | - String time = s.getRealExecDate() + " " + s.getFcsj(); | |
| 2014 | - Date d = dateTime.parse(time); | |
| 2015 | - if(dd.getTime() - d.getTime() < 300000l){ //只取当前时间5分钟前的数据 | |
| 2016 | - continue; | |
| 2017 | - } | |
| 2018 | - | |
| 2019 | - Set<ChildTaskPlan> cts; | |
| 2020 | - cts = s.getcTasks(); | |
| 2021 | - //有子任务 | |
| 2022 | - if (cts != null && cts.size() > 0) { | |
| 2023 | - for(ChildTaskPlan c : cts){ | |
| 2024 | - if(c.getMileageType().equals("service") && c.getCcId() == null){ | |
| 2025 | - if(c.isDestroy() && (c.getDestroyReason()==null? "" : c.getDestroyReason()).equals("缺人")){ | |
| 2026 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 2027 | - m.put("gsName", s.getGsName()); | |
| 2028 | - m.put("lineName", s.getXlName()); | |
| 2029 | - m.put("driverCode", s.getjGh()); | |
| 2030 | - m.put("driverName", s.getjName()); | |
| 2031 | - m.put("cl", s.getClZbh()); | |
| 2032 | - m.put("date", s.getRealExecDate()); | |
| 2033 | - m.put("time", c.getStartDate()); | |
| 2034 | - if(c.getRemarks() != null && c.getRemarks().trim().length() > 0){ | |
| 2035 | - m.put("explain", c.getRemarks()); | |
| 2036 | - } else { | |
| 2037 | - m.put("explain", s.getRemarks()!=null?s.getRemarks():""); | |
| 2038 | - } | |
| 2039 | - | |
| 2040 | - String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName(); | |
| 2041 | - if(lackSet.add(str)){ | |
| 2042 | - lackList.add(m); | |
| 2043 | - } | |
| 2044 | - } | |
| 2045 | - } | |
| 2046 | - } | |
| 2047 | - } | |
| 2048 | - //主任务烂班 | |
| 2049 | - else if(s.getStatus() == -1 && s.getAdjustExps().equals("缺人")){ | |
| 2050 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 2051 | - m.put("gsName", s.getGsName()); | |
| 2052 | - m.put("lineName", s.getXlName()); | |
| 2053 | - m.put("driverCode", s.getjGh()); | |
| 2054 | - m.put("driverName", s.getjName()); | |
| 2055 | - m.put("cl", s.getClZbh()); | |
| 2056 | - m.put("date", s.getRealExecDate()); | |
| 2057 | - m.put("time", s.getFcsj()); | |
| 2058 | - m.put("explain", s.getRemarks()!=null?s.getRemarks():""); | |
| 2059 | - | |
| 2060 | - String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName(); | |
| 2061 | - if(lackSet.add(str)){ | |
| 2062 | - lackList.add(m); | |
| 2063 | - } | |
| 2064 | - } | |
| 2065 | - } | |
| 2066 | - } catch (Exception e) { | |
| 2067 | - // TODO: handle exception | |
| 2068 | - e.printStackTrace(); | |
| 2069 | - } | |
| 2070 | - } | |
| 2071 | - | |
| 2072 | - Map<String, Object> att = new HashMap<String, Object>(); | |
| 2073 | - att.put("date", dates[i]); | |
| 2074 | - att.put("jh", jhSet.size()); | |
| 2075 | - att.put("sj", sjSet.size()); | |
| 2076 | - attList.add(att); | |
| 2077 | - } | |
| 2078 | - | |
| 2079 | - String gpLineSql = "select p.company_code, count(1) jsy" | |
| 2080 | - + " from (select e.jsy from bsth_c_s_ecinfo e" | |
| 2081 | - + " where e.is_cancel = 0 group by e.jsy) a" | |
| 2082 | - + " left join bsth_c_personnel p on a.jsy = p.id" | |
| 2083 | - + " group by p.company_code"; | |
| 2084 | - List<Map<String, Object>> ecList=jdbcTemplate.query(gpLineSql, | |
| 2085 | - new RowMapper<Map<String, Object>>(){ | |
| 2086 | - @Override | |
| 2087 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2088 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2089 | - m.put("company", rs.getString("company_code")); | |
| 2090 | - m.put("jsy", rs.getString("jsy")); | |
| 2091 | - return m; | |
| 2092 | - } | |
| 2093 | - }); | |
| 2094 | - | |
| 2095 | - List<Map<String, Object>> jsyList = new ArrayList<Map<String, Object>>(); | |
| 2096 | - Map<String, Object> ygMap = new HashMap<String, Object>(); | |
| 2097 | - ygMap.put("company", "杨高"); | |
| 2098 | - ygMap.put("jsy", "0"); | |
| 2099 | - Map<String, Object> snMap = new HashMap<String, Object>(); | |
| 2100 | - snMap.put("company", "上南"); | |
| 2101 | - snMap.put("jsy", "0"); | |
| 2102 | - Map<String, Object> jgMap = new HashMap<String, Object>(); | |
| 2103 | - jgMap.put("company", "金高"); | |
| 2104 | - jgMap.put("jsy", "0"); | |
| 2105 | - Map<String, Object> nhMap = new HashMap<String, Object>(); | |
| 2106 | - nhMap.put("company", "南汇"); | |
| 2107 | - nhMap.put("jsy", "0"); | |
| 2108 | - for(Map<String, Object> m : ecList){ //顺序:杨高,上南,金高,南汇 | |
| 2109 | - if("05".equals(m.get("company").toString())){ | |
| 2110 | -// m.put("company", "杨高"); | |
| 2111 | - ygMap.put("jsy", m.get("jsy").toString()); | |
| 2112 | - } | |
| 2113 | - if("55".equals(m.get("company").toString())){ | |
| 2114 | -// m.put("company", "上南"); | |
| 2115 | - snMap.put("jsy", m.get("jsy").toString()); | |
| 2116 | - } | |
| 2117 | - if("22".equals(m.get("company").toString())){ | |
| 2118 | -// m.put("company", "金高"); | |
| 2119 | - jgMap.put("jsy", m.get("jsy").toString()); | |
| 2120 | - } | |
| 2121 | - if("26".equals(m.get("company").toString())){ | |
| 2122 | -// m.put("company", "南汇"); | |
| 2123 | - nhMap.put("jsy", m.get("jsy").toString()); | |
| 2124 | - } | |
| 2125 | - } | |
| 2126 | - jsyList.add(ygMap); | |
| 2127 | - jsyList.add(snMap); | |
| 2128 | - jsyList.add(jgMap); | |
| 2129 | - jsyList.add(nhMap); | |
| 2130 | - | |
| 2131 | - String xlSql = "select a.jsy, b.spy, c.cl from" | |
| 2132 | - + " (select count(1) jsy from (select a.jsy from bsth_c_s_ecinfo a where a.is_cancel = 0 and a.spy is not null and a.jsy is not null group by jsy) a) a" | |
| 2133 | - + " LEFT JOIN" | |
| 2134 | - + " (select count(1) spy from (select b.spy from bsth_c_s_ecinfo b where b.is_cancel = 0 and b.spy is not null group by spy) b) b" | |
| 2135 | - + " on 1=1" | |
| 2136 | - + " LEFT JOIN" | |
| 2137 | - + " (select count(1) cl from (select c.cl from bsth_c_s_ccinfo c where c.is_cancel = 0 and c.cl is not null and c.xl in(select e.xl from bsth_c_s_ecinfo e where e.is_cancel = 0 and e.spy is not null) group by c.cl) c) c" | |
| 2138 | - + " on 1=1"; | |
| 2139 | - List<Map<String, Object>> xlConfigList=jdbcTemplate.query(xlSql, | |
| 2140 | - new RowMapper<Map<String, Object>>(){ | |
| 2141 | - @Override | |
| 2142 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2143 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2144 | - m.put("jsy", rs.getString("jsy")); | |
| 2145 | - m.put("spy", rs.getString("spy")); | |
| 2146 | - m.put("cl", rs.getString("cl")); | |
| 2147 | - return m; | |
| 2148 | - } | |
| 2149 | - }); | |
| 2150 | - long jsy = 0l, spy = 0l, cl = 0l; | |
| 2151 | - for(Map<String, Object> t : xlConfigList){ | |
| 2152 | - if(t.get("jsy") != null){ | |
| 2153 | - jsy += Long.valueOf(t.get("jsy").toString()); | |
| 2154 | - } | |
| 2155 | - if(t.get("spy") != null){ | |
| 2156 | - spy += Long.valueOf(t.get("spy").toString()); | |
| 2157 | - } | |
| 2158 | - if(t.get("cl") != null){ | |
| 2159 | - cl += Long.valueOf(t.get("cl").toString()); | |
| 2160 | - } | |
| 2161 | - } | |
| 2162 | - | |
| 2163 | - resMap.put("jsyList", jsyList); | |
| 2164 | - resMap.put("attList", attList); | |
| 2165 | - resMap.put("lackList", lackList); | |
| 2166 | - resMap.put("salesmanJsy", jsy); | |
| 2167 | - resMap.put("salesmanSpy", spy); | |
| 2168 | - resMap.put("salesmanCl", cl); | |
| 2169 | - | |
| 2170 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 2171 | - } | |
| 2172 | - | |
| 2173 | - @GET | |
| 2174 | - @Path("/selectData/attendance/{gsdm}") | |
| 2175 | - public JSONObject attendance(@PathParam("gsdm") String gsdm){ | |
| 2176 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 2177 | - SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 2178 | - | |
| 2179 | - int day = 7;//天数 | |
| 2180 | - | |
| 2181 | - Date dd = new Date(); | |
| 2182 | - String date = sd.format(dd); //yyyy-MM-dd 当天 | |
| 2183 | - Date dd2 = new Date(); | |
| 2184 | - dd2.setTime(dd.getTime() - ((long)(day-1))*1000*60*60*24); | |
| 2185 | - String date2 = sd.format(dd2); //yyyy-MM-dd 6天前(加上当天就是取7天数据) | |
| 2186 | - | |
| 2187 | - String[] dates = new String[day]; | |
| 2188 | - Map<String, Integer> datesMap = new HashMap<String, Integer>(); | |
| 2189 | - | |
| 2190 | - for(int i = 0; i < day; i++){ | |
| 2191 | - Date tempDate = new Date(); | |
| 2192 | - tempDate.setTime(dd2.getTime() + ((long)i)*1000*60*60*24); | |
| 2193 | - String format = sd.format(tempDate); | |
| 2194 | - dates[i] = format; | |
| 2195 | - datesMap.put(format, i); | |
| 2196 | - } | |
| 2197 | - | |
| 2198 | - | |
| 2199 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 2200 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 2201 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 2202 | - new RowMapper<Map<String, Object>>(){ | |
| 2203 | - @Override | |
| 2204 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2205 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2206 | - m.put("lineCode", rs.getString("line_code")); | |
| 2207 | - return m; | |
| 2208 | - } | |
| 2209 | - }); | |
| 2210 | - Set<String> yyLine = new HashSet<String>(); | |
| 2211 | - for(Map<String, Object> t : yyxlList){ | |
| 2212 | - if(t.get("lineCode") != null){ | |
| 2213 | - yyLine.add(t.get("lineCode").toString()); | |
| 2214 | - } | |
| 2215 | - } | |
| 2216 | - | |
| 2217 | - | |
| 2218 | - List<Map<String, Object>> attList = new ArrayList<Map<String, Object>>(); | |
| 2219 | - List<Map<String, Object>> lackList = new ArrayList<Map<String, Object>>(); | |
| 2220 | - Set<String> lackSet = new HashSet<String>(); | |
| 2221 | - | |
| 2222 | - for(int i = 0; i < dates.length; i++){ | |
| 2223 | - Set<String> jhSet = new HashSet<String>(); | |
| 2224 | - Set<String> sjSet = new HashSet<String>(); | |
| 2225 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(dates[i]); | |
| 2226 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | |
| 2227 | - for(ScheduleRealInfo s : findAll){ | |
| 2228 | - if(s.getGsBm() != null && s.getGsBm().equals(gsdm)){//直属公司 | |
| 2229 | - if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 2230 | - if(!isInOut(s)){ | |
| 2231 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 2232 | - if (cts != null && cts.size() > 0) { | |
| 2233 | - list_s.add(s); | |
| 2234 | - } else { | |
| 2235 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 2236 | - list_s.add(s); | |
| 2237 | - } | |
| 2238 | - } | |
| 2239 | - | |
| 2240 | - if(!s.isSflj() && !s.isCcService()){ | |
| 2241 | - jhSet.add(s.getjGh() + "/" + s.getjName()); | |
| 2242 | - } | |
| 2243 | - } | |
| 2244 | - } | |
| 2245 | - } | |
| 2246 | - } | |
| 2247 | - | |
| 2248 | - for(ScheduleRealInfo s : list_s){ | |
| 2249 | - if(!(s.getStatus() == -1)){ | |
| 2250 | - sjSet.add(s.getjGh() + "/" + s.getjName()); | |
| 2251 | - } | |
| 2252 | - } | |
| 2253 | - | |
| 2254 | - for(ScheduleRealInfo s : findAll){ | |
| 2255 | - try { | |
| 2256 | - if(s.getGsBm() != null && s.getGsBm().equals(gsdm)){//直属公司 | |
| 2257 | - if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 2258 | - if (s.isSflj() || isInOut(s)){ | |
| 2259 | - continue; | |
| 2260 | - } | |
| 2261 | - | |
| 2262 | - String time = s.getRealExecDate() + " " + s.getFcsj(); | |
| 2263 | - Date d = dateTime.parse(time); | |
| 2264 | - if(dd.getTime() - d.getTime() < 300000l){ //只取当前时间5分钟前的数据 | |
| 2265 | - continue; | |
| 2266 | - } | |
| 2267 | - | |
| 2268 | - Set<ChildTaskPlan> cts; | |
| 2269 | - cts = s.getcTasks(); | |
| 2270 | - //有子任务 | |
| 2271 | - if (cts != null && cts.size() > 0) { | |
| 2272 | - for(ChildTaskPlan c : cts){ | |
| 2273 | - if(c.getMileageType().equals("service") && c.getCcId() == null){ | |
| 2274 | - if(c.isDestroy() && (c.getDestroyReason()==null? "" : c.getDestroyReason()).equals("缺人")){ | |
| 2275 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 2276 | - m.put("gsName", s.getGsName()); | |
| 2277 | - m.put("lineName", s.getXlName()); | |
| 2278 | - m.put("driverCode", s.getjGh()); | |
| 2279 | - m.put("driverName", s.getjName()); | |
| 2280 | - m.put("cl", s.getClZbh()); | |
| 2281 | - m.put("date", s.getRealExecDate()); | |
| 2282 | - m.put("time", c.getStartDate()); | |
| 2283 | - if(c.getRemarks() != null && c.getRemarks().trim().length() > 0){ | |
| 2284 | - m.put("explain", c.getRemarks()); | |
| 2285 | - } else { | |
| 2286 | - m.put("explain", s.getRemarks()!=null?s.getRemarks():""); | |
| 2287 | - } | |
| 2288 | - | |
| 2289 | - String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName(); | |
| 2290 | - if(lackSet.add(str)){ | |
| 2291 | - lackList.add(m); | |
| 2292 | - } | |
| 2293 | - } | |
| 2294 | - } | |
| 2295 | - } | |
| 2296 | - } | |
| 2297 | - //主任务烂班 | |
| 2298 | - else if(s.getStatus() == -1 && s.getAdjustExps().equals("缺人")){ | |
| 2299 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 2300 | - m.put("gsName", s.getGsName()); | |
| 2301 | - m.put("lineName", s.getXlName()); | |
| 2302 | - m.put("driverCode", s.getjGh()); | |
| 2303 | - m.put("driverName", s.getjName()); | |
| 2304 | - m.put("cl", s.getClZbh()); | |
| 2305 | - m.put("date", s.getRealExecDate()); | |
| 2306 | - m.put("time", s.getFcsj()); | |
| 2307 | - m.put("explain", s.getRemarks()!=null?s.getRemarks():""); | |
| 2308 | - | |
| 2309 | - String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName(); | |
| 2310 | - if(lackSet.add(str)){ | |
| 2311 | - lackList.add(m); | |
| 2312 | - } | |
| 2313 | - } | |
| 2314 | - } | |
| 2315 | - } | |
| 2316 | - } catch (Exception e) { | |
| 2317 | - // TODO: handle exception | |
| 2318 | - } | |
| 2319 | - } | |
| 2320 | - | |
| 2321 | - Map<String, Object> att = new HashMap<String, Object>(); | |
| 2322 | - att.put("date", dates[i]); | |
| 2323 | - att.put("jh", jhSet.size()); | |
| 2324 | - att.put("sj", sjSet.size()); | |
| 2325 | - attList.add(att); | |
| 2326 | - } | |
| 2327 | - | |
| 2328 | - String gpLineSql = "select p.branche_company_code, b.business_name, count(1) jsy" | |
| 2329 | - + " from (select e.jsy from bsth_c_s_ecinfo e" | |
| 2330 | - + " where e.is_cancel = 0 group by e.jsy) a" | |
| 2331 | - + " left join bsth_c_personnel p on a.jsy = p.id" | |
| 2332 | - + " left join bsth_c_business b on p.company_code = b.up_code" | |
| 2333 | - + " and p.branche_company_code = b.business_code" | |
| 2334 | - + " where p.company_code = ?" | |
| 2335 | - + " group by p.branche_company_code, b.business_name" | |
| 2336 | - + " order by p.branche_company_code"; | |
| 2337 | - List<Map<String, Object>> ecList=jdbcTemplate.query(gpLineSql, new Object[]{gsdm}, | |
| 2338 | - new RowMapper<Map<String, Object>>(){ | |
| 2339 | - @Override | |
| 2340 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2341 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2342 | - m.put("company", rs.getString("branche_company_code")); | |
| 2343 | - m.put("companyName", rs.getString("business_name")); | |
| 2344 | - m.put("jsy", rs.getString("jsy")); | |
| 2345 | - return m; | |
| 2346 | - } | |
| 2347 | - }); | |
| 2348 | - | |
| 2349 | - List<Integer> keyList = new ArrayList<Integer>(); | |
| 2350 | - Map<Integer, Map<String, Object>> keyMap = new HashMap<Integer, Map<String, Object>>(); | |
| 2351 | - List<Map<String, Object>> jsyList = new ArrayList<Map<String, Object>>(); | |
| 2352 | - for(Map<String, Object> m : ecList){ | |
| 2353 | - if(m.get("company") != null && m.get("company").toString().trim().length() > 0){ | |
| 2354 | - Integer i = Integer.valueOf(m.get("company").toString().trim()); | |
| 2355 | - if(!keyMap.containsKey(i)){ | |
| 2356 | - Map<String, Object> temp = new HashMap<String, Object>(); | |
| 2357 | - temp.put("company", m.get("companyName").toString()); | |
| 2358 | - temp.put("jsy", m.get("jsy").toString()); | |
| 2359 | - keyMap.put(i, temp); | |
| 2360 | - keyList.add(i); | |
| 2361 | - jsyList.add(temp); | |
| 2362 | - } | |
| 2363 | - } | |
| 2364 | - } | |
| 2365 | - | |
| 2366 | - String xlSql = "select a.jsy, b.spy, c.cl from" | |
| 2367 | - + " (select count(1) jsy from (select a.jsy from bsth_c_s_ecinfo a" | |
| 2368 | - + " left join bsth_c_personnel p on a.jsy=p.id where a.is_cancel = 0" | |
| 2369 | - + " and a.spy is not null and a.jsy is not null" | |
| 2370 | - + " and p.company_code = ?" | |
| 2371 | - + " group by jsy) a) a" | |
| 2372 | - + " LEFT JOIN" | |
| 2373 | - + " (select count(1) spy from (select b.spy from bsth_c_s_ecinfo b" | |
| 2374 | - + " left join bsth_c_personnel p on b.spy=p.id where b.is_cancel = 0" | |
| 2375 | - + " and b.spy is not null and p.company_code = ?" | |
| 2376 | - + " group by spy) b) b" | |
| 2377 | - + " on 1=1" | |
| 2378 | - + " LEFT JOIN" | |
| 2379 | - + " (select count(1) cl from (select c.cl from bsth_c_s_ccinfo c" | |
| 2380 | - + " left join bsth_c_cars car on c.cl=car.id where c.is_cancel = 0" | |
| 2381 | - + " and c.cl is not null and car.business_code = ?" | |
| 2382 | - + " and c.xl in(select e.xl from bsth_c_s_ecinfo e" | |
| 2383 | - + " where e.is_cancel = 0 and e.spy is not null) group by c.cl) c) c" | |
| 2384 | - + " on 1=1"; | |
| 2385 | - List<Map<String, Object>> xlConfigList=jdbcTemplate.query(xlSql, new Object[]{gsdm, gsdm, gsdm}, | |
| 2386 | - new RowMapper<Map<String, Object>>(){ | |
| 2387 | - @Override | |
| 2388 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2389 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2390 | - m.put("jsy", rs.getString("jsy")); | |
| 2391 | - m.put("spy", rs.getString("spy")); | |
| 2392 | - m.put("cl", rs.getString("cl")); | |
| 2393 | - return m; | |
| 2394 | - } | |
| 2395 | - }); | |
| 2396 | - long jsy = 0l, spy = 0l, cl = 0l; | |
| 2397 | - for(Map<String, Object> t : xlConfigList){ | |
| 2398 | - if(t.get("jsy") != null){ | |
| 2399 | - jsy += Long.valueOf(t.get("jsy").toString()); | |
| 2400 | - } | |
| 2401 | - if(t.get("spy") != null){ | |
| 2402 | - spy += Long.valueOf(t.get("spy").toString()); | |
| 2403 | - } | |
| 2404 | - if(t.get("cl") != null){ | |
| 2405 | - cl += Long.valueOf(t.get("cl").toString()); | |
| 2406 | - } | |
| 2407 | - } | |
| 2408 | - | |
| 2409 | - resMap.put("jsyList", jsyList); | |
| 2410 | - resMap.put("attList", attList); | |
| 2411 | - resMap.put("lackList", lackList); | |
| 2412 | - resMap.put("salesmanJsy", jsy); | |
| 2413 | - resMap.put("salesmanSpy", spy); | |
| 2414 | - resMap.put("salesmanCl", cl); | |
| 2415 | - | |
| 2416 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 2417 | - } | |
| 2418 | - | |
| 2419 | - /** 按月份查询统计指标 */ | |
| 2420 | - @GET | |
| 2421 | - @Path("/selectData/getMonthly/{month}") | |
| 2422 | - public JSONObject getMonthly(@PathParam("month") String month){ | |
| 2423 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 2424 | - | |
| 2425 | - String gpLineSql = "select * from bsth_c_line_plate"; | |
| 2426 | - List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | |
| 2427 | - new RowMapper<Map<String, Object>>(){ | |
| 2428 | - @Override | |
| 2429 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2430 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2431 | - m.put("lineName", rs.getString("line_name")); | |
| 2432 | - m.put("lineCode", rs.getString("line_code")); | |
| 2433 | - return m; | |
| 2434 | - } | |
| 2435 | - }); | |
| 2436 | - | |
| 2437 | - Set<String> gpSet = new HashSet<String>(); | |
| 2438 | - for(Map<String, Object> t : gpLineList){ | |
| 2439 | - if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | |
| 2440 | - gpSet.add(t.get("lineCode").toString().trim()); | |
| 2441 | - } | |
| 2442 | - } | |
| 2443 | - | |
| 2444 | - | |
| 2445 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 2446 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 2447 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 2448 | - new RowMapper<Map<String, Object>>(){ | |
| 2449 | - @Override | |
| 2450 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2451 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2452 | - m.put("lineCode", rs.getString("line_code")); | |
| 2453 | - return m; | |
| 2454 | - } | |
| 2455 | - }); | |
| 2456 | - Set<String> yyLine = new HashSet<String>(); | |
| 2457 | - for(Map<String, Object> t : yyxlList){ | |
| 2458 | - if(t.get("lineCode") != null){ | |
| 2459 | - yyLine.add(t.get("lineCode").toString()); | |
| 2460 | - } | |
| 2461 | - } | |
| 2462 | - | |
| 2463 | - | |
| 2464 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 2465 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 2466 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 2467 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 2468 | - + " jhszfcs,sjszfczds,szfczdl,jhzgl,sjzgl,create_date" | |
| 2469 | - + " from bsth_c_calc_count " | |
| 2470 | - + " where date like '%"+month+"%' and gsdm != '77'"; | |
| 2471 | - | |
| 2472 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 2473 | - new RowMapper<Map<String, Object>>(){ | |
| 2474 | - @Override | |
| 2475 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2476 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2477 | - m.put("lineCode",rs.getString("xl")); | |
| 2478 | - m.put("lineName", rs.getString("xl_name")); | |
| 2479 | - m.put("date", rs.getString("date")); | |
| 2480 | - | |
| 2481 | - m.put("jhbc", rs.getString("jhbc")); | |
| 2482 | - m.put("sjbc", rs.getString("sjbc")); | |
| 2483 | - m.put("bczxl", rs.getString("bczxl")); | |
| 2484 | - m.put("jhbcz", rs.getString("jhbcz")); | |
| 2485 | - | |
| 2486 | - m.put("jhcc", rs.getString("jhcc")); | |
| 2487 | - m.put("sjcc", rs.getString("sjcc")); | |
| 2488 | - m.put("ccl", rs.getString("ccl")); | |
| 2489 | - m.put("jhccz", rs.getString("jhccz")); | |
| 2490 | - | |
| 2491 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 2492 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 2493 | - m.put("jhyylcz", rs.getString("jhyylcz")); | |
| 2494 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 2495 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 2496 | - m.put("jhkslcz", rs.getString("jhkslcz")); | |
| 2497 | - | |
| 2498 | - m.put("jhgfbcs", rs.getString("jhssgfbcs")); | |
| 2499 | - m.put("sjgfbcs", rs.getString("sjgfbcs")); | |
| 2500 | - m.put("jhgfbcsz", rs.getString("jhgfbcsz")); | |
| 2501 | - m.put("jhdgbcs", rs.getString("jhssdgbcs")); | |
| 2502 | - m.put("sjdgbcs", rs.getString("sjdgbcs")); | |
| 2503 | - m.put("jhdgbcsz", rs.getString("jhdgbcsz")); | |
| 2504 | - | |
| 2505 | - m.put("jhsmbcs", rs.getString("jhsmbcs")); | |
| 2506 | - m.put("sjsmbczds", rs.getString("sjsmbczds")); | |
| 2507 | - m.put("smbczdl", rs.getString("smbczdl")); | |
| 2508 | - m.put("jhsmbcsz", rs.getString("jhsmbcsz")); | |
| 2509 | - m.put("sjsmbczdsz", rs.getString("sjsmbczdsz")); | |
| 2510 | - m.put("smbczdlz", rs.getString("smbczdlz")); | |
| 2511 | - | |
| 2512 | - m.put("jhszfcs", rs.getString("jhszfcs")); | |
| 2513 | - m.put("sjszfczds", rs.getString("sjszfczds")); | |
| 2514 | - m.put("szfczdl", rs.getString("szfczdl")); | |
| 2515 | - | |
| 2516 | - m.put("jhzgl", rs.getString("jhzgl")); | |
| 2517 | - m.put("sjzgl", rs.getString("sjzgl")); | |
| 2518 | - | |
| 2519 | - Date date = new Date(); | |
| 2520 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 2521 | - m.put("createDate", sdf.format(date)); | |
| 2522 | - return m; | |
| 2523 | - } | |
| 2524 | - }); | |
| 2525 | - | |
| 2526 | - | |
| 2527 | - BigDecimal jhzgl = new BigDecimal(0), sjzgl = new BigDecimal(0);// | |
| 2528 | - long jhcc = 0, sjcc = 0, jhbc = 0, sjbc = 0, jhsmbc = 0, sjsmbc = 0, | |
| 2529 | - jhqqbc = 0, sjqqzd = 0, jhgpqqbc = 0, sjgpqqzd = 0; | |
| 2530 | - | |
| 2531 | - for(Map<String, Object> t : list){ | |
| 2532 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 2533 | - | |
| 2534 | - jhzgl = jhzgl.add(new BigDecimal(t.get("jhzgl").toString())); | |
| 2535 | - sjzgl = sjzgl.add(new BigDecimal(t.get("sjzgl").toString())); | |
| 2536 | - | |
| 2537 | - jhcc += Long.valueOf(t.get("jhccz").toString()); | |
| 2538 | - sjcc += Long.valueOf(t.get("sjcc").toString()); | |
| 2539 | - jhbc += Long.valueOf(t.get("jhbc").toString()); | |
| 2540 | - sjbc += Long.valueOf(t.get("sjbc").toString()); | |
| 2541 | - jhsmbc += Long.valueOf(t.get("jhsmbcs").toString()); | |
| 2542 | - sjsmbc += Long.valueOf(t.get("sjsmbczds").toString()); | |
| 2543 | - jhqqbc += Long.valueOf(t.get("jhszfcs").toString()); | |
| 2544 | - sjqqzd += Long.valueOf(t.get("sjszfczds").toString()); | |
| 2545 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 2546 | - jhgpqqbc += Long.valueOf(t.get("jhszfcs").toString()); | |
| 2547 | - sjgpqqzd += Long.valueOf(t.get("sjszfczds").toString()); | |
| 2548 | - } | |
| 2549 | - | |
| 2550 | - } | |
| 2551 | - } | |
| 2552 | - | |
| 2553 | - resMap.put("date", month); | |
| 2554 | - | |
| 2555 | - resMap.put("jhzgl", df.format(jhzgl)); | |
| 2556 | - resMap.put("sjzgl", df.format(sjzgl)); | |
| 2557 | - resMap.put("jhcc", jhcc); | |
| 2558 | - resMap.put("sjcc", sjcc); | |
| 2559 | - resMap.put("jhbc", jhbc); | |
| 2560 | - resMap.put("sjbc", sjbc); | |
| 2561 | - resMap.put("jhsm", jhsmbc); | |
| 2562 | - resMap.put("sjsm", sjsmbc); | |
| 2563 | - resMap.put("jhqq", jhqqbc); | |
| 2564 | - resMap.put("sjqq", sjqqzd); | |
| 2565 | - resMap.put("jhgp", jhgpqqbc); | |
| 2566 | - resMap.put("sjgp", sjgpqqzd); | |
| 2567 | - | |
| 2568 | - resMap.put("glzxl", jhzgl.doubleValue()>0?sjzgl.divide(jhzgl, | |
| 2569 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2570 | - resMap.put("ccl", jhcc>0?new BigDecimal(sjcc).divide(new BigDecimal(jhcc), | |
| 2571 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2572 | - resMap.put("bczxl", jhbc>0?new BigDecimal(sjbc).divide(new BigDecimal(jhbc), | |
| 2573 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2574 | - resMap.put("smbzdl", jhbc>0?new BigDecimal(sjsmbc).divide(new BigDecimal(jhsmbc), | |
| 2575 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2576 | - resMap.put("qqzzdl", jhbc>0?new BigDecimal(sjqqzd).divide(new BigDecimal(jhqqbc), | |
| 2577 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2578 | - resMap.put("gpzdl", jhbc>0?new BigDecimal(sjgpqqzd).divide(new BigDecimal(jhgpqqbc), | |
| 2579 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2580 | - | |
| 2581 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 2582 | - } | |
| 2583 | - | |
| 2584 | - /** 按月份查询直属公司统计指标 */ | |
| 2585 | - @GET | |
| 2586 | - @Path("/selectData/getMonthly/{gsdm}/{month}") | |
| 2587 | - public JSONObject getMonthly(@PathParam("gsdm") String gsdm, @PathParam("month") String month){ | |
| 2588 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 2589 | - | |
| 2590 | - String gpLineSql = "select * from bsth_c_line_plate"; | |
| 2591 | - List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | |
| 2592 | - new RowMapper<Map<String, Object>>(){ | |
| 2593 | - @Override | |
| 2594 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2595 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2596 | - m.put("lineName", rs.getString("line_name")); | |
| 2597 | - m.put("lineCode", rs.getString("line_code")); | |
| 2598 | - return m; | |
| 2599 | - } | |
| 2600 | - }); | |
| 2601 | - | |
| 2602 | - Set<String> gpSet = new HashSet<String>(); | |
| 2603 | - for(Map<String, Object> t : gpLineList){ | |
| 2604 | - if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | |
| 2605 | - gpSet.add(t.get("lineCode").toString().trim()); | |
| 2606 | - } | |
| 2607 | - } | |
| 2608 | - | |
| 2609 | - | |
| 2610 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 2611 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 2612 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 2613 | - new RowMapper<Map<String, Object>>(){ | |
| 2614 | - @Override | |
| 2615 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2616 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2617 | - m.put("lineCode", rs.getString("line_code")); | |
| 2618 | - return m; | |
| 2619 | - } | |
| 2620 | - }); | |
| 2621 | - Set<String> yyLine = new HashSet<String>(); | |
| 2622 | - for(Map<String, Object> t : yyxlList){ | |
| 2623 | - if(t.get("lineCode") != null){ | |
| 2624 | - yyLine.add(t.get("lineCode").toString()); | |
| 2625 | - } | |
| 2626 | - } | |
| 2627 | - | |
| 2628 | - | |
| 2629 | - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 2630 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 2631 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 2632 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 2633 | - + " jhszfcs,sjszfczds,szfczdl,jhzgl,sjzgl,create_date" | |
| 2634 | - + " from bsth_c_calc_count " | |
| 2635 | - + " where gsdm = '"+gsdm+"' and date like '%"+month+"%'"; | |
| 2636 | - | |
| 2637 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, | |
| 2638 | - new RowMapper<Map<String, Object>>(){ | |
| 2639 | - @Override | |
| 2640 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2641 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2642 | - m.put("lineCode",rs.getString("xl")); | |
| 2643 | - m.put("lineName", rs.getString("xl_name")); | |
| 2644 | - m.put("date", rs.getString("date")); | |
| 2645 | - | |
| 2646 | - m.put("jhbc", rs.getString("jhbc")); | |
| 2647 | - m.put("sjbc", rs.getString("sjbc")); | |
| 2648 | - m.put("bczxl", rs.getString("bczxl")); | |
| 2649 | - m.put("jhbcz", rs.getString("jhbcz")); | |
| 2650 | - | |
| 2651 | - m.put("jhcc", rs.getString("jhcc")); | |
| 2652 | - m.put("sjcc", rs.getString("sjcc")); | |
| 2653 | - m.put("ccl", rs.getString("ccl")); | |
| 2654 | - m.put("jhccz", rs.getString("jhccz")); | |
| 2655 | - | |
| 2656 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 2657 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 2658 | - m.put("jhyylcz", rs.getString("jhyylcz")); | |
| 2659 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 2660 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 2661 | - m.put("jhkslcz", rs.getString("jhkslcz")); | |
| 2662 | - | |
| 2663 | - m.put("jhgfbcs", rs.getString("jhssgfbcs")); | |
| 2664 | - m.put("sjgfbcs", rs.getString("sjgfbcs")); | |
| 2665 | - m.put("jhgfbcsz", rs.getString("jhgfbcsz")); | |
| 2666 | - m.put("jhdgbcs", rs.getString("jhssdgbcs")); | |
| 2667 | - m.put("sjdgbcs", rs.getString("sjdgbcs")); | |
| 2668 | - m.put("jhdgbcsz", rs.getString("jhdgbcsz")); | |
| 2669 | - | |
| 2670 | - m.put("jhsmbcs", rs.getString("jhsmbcs")); | |
| 2671 | - m.put("sjsmbczds", rs.getString("sjsmbczds")); | |
| 2672 | - m.put("smbczdl", rs.getString("smbczdl")); | |
| 2673 | - m.put("jhsmbcsz", rs.getString("jhsmbcsz")); | |
| 2674 | - m.put("sjsmbczdsz", rs.getString("sjsmbczdsz")); | |
| 2675 | - m.put("smbczdlz", rs.getString("smbczdlz")); | |
| 2676 | - | |
| 2677 | - m.put("jhszfcs", rs.getString("jhszfcs")); | |
| 2678 | - m.put("sjszfczds", rs.getString("sjszfczds")); | |
| 2679 | - m.put("szfczdl", rs.getString("szfczdl")); | |
| 2680 | - | |
| 2681 | - m.put("jhzgl", rs.getString("jhzgl")); | |
| 2682 | - m.put("sjzgl", rs.getString("sjzgl")); | |
| 2683 | - | |
| 2684 | - Date date = new Date(); | |
| 2685 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 2686 | - m.put("createDate", sdf.format(date)); | |
| 2687 | - return m; | |
| 2688 | - } | |
| 2689 | - }); | |
| 2690 | - | |
| 2691 | - | |
| 2692 | - BigDecimal jhzgl = new BigDecimal(0), sjzgl = new BigDecimal(0);// | |
| 2693 | - long jhcc = 0, sjcc = 0, jhbc = 0, sjbc = 0, jhsmbc = 0, sjsmbc = 0, | |
| 2694 | - jhqqbc = 0, sjqqzd = 0, jhgpqqbc = 0, sjgpqqzd = 0; | |
| 2695 | - | |
| 2696 | - for(Map<String, Object> t : list){ | |
| 2697 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 2698 | - | |
| 2699 | - jhzgl = jhzgl.add(new BigDecimal(t.get("jhzgl").toString())); | |
| 2700 | - sjzgl = sjzgl.add(new BigDecimal(t.get("sjzgl").toString())); | |
| 2701 | - | |
| 2702 | - jhcc += Long.valueOf(t.get("jhccz").toString()); | |
| 2703 | - sjcc += Long.valueOf(t.get("sjcc").toString()); | |
| 2704 | - jhbc += Long.valueOf(t.get("jhbc").toString()); | |
| 2705 | - sjbc += Long.valueOf(t.get("sjbc").toString()); | |
| 2706 | - jhsmbc += Long.valueOf(t.get("jhsmbcs").toString()); | |
| 2707 | - sjsmbc += Long.valueOf(t.get("sjsmbczds").toString()); | |
| 2708 | - jhqqbc += Long.valueOf(t.get("jhszfcs").toString()); | |
| 2709 | - sjqqzd += Long.valueOf(t.get("sjszfczds").toString()); | |
| 2710 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 2711 | - jhgpqqbc += Long.valueOf(t.get("jhszfcs").toString()); | |
| 2712 | - sjgpqqzd += Long.valueOf(t.get("sjszfczds").toString()); | |
| 2713 | - } | |
| 2714 | - | |
| 2715 | - } | |
| 2716 | - } | |
| 2717 | - | |
| 2718 | - resMap.put("date", month); | |
| 2719 | - | |
| 2720 | - resMap.put("jhzgl", df.format(jhzgl)); | |
| 2721 | - resMap.put("sjzgl", df.format(sjzgl)); | |
| 2722 | - resMap.put("jhcc", jhcc); | |
| 2723 | - resMap.put("sjcc", sjcc); | |
| 2724 | - resMap.put("jhbc", jhbc); | |
| 2725 | - resMap.put("sjbc", sjbc); | |
| 2726 | - resMap.put("jhsm", jhsmbc); | |
| 2727 | - resMap.put("sjsm", sjsmbc); | |
| 2728 | - resMap.put("jhqq", jhqqbc); | |
| 2729 | - resMap.put("sjqq", sjqqzd); | |
| 2730 | - resMap.put("jhgp", jhgpqqbc); | |
| 2731 | - resMap.put("sjgp", sjgpqqzd); | |
| 2732 | - | |
| 2733 | - resMap.put("glzxl", jhzgl.doubleValue()>0?sjzgl.divide(jhzgl, | |
| 2734 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2735 | - resMap.put("ccl", jhcc>0?new BigDecimal(sjcc).divide(new BigDecimal(jhcc), | |
| 2736 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2737 | - resMap.put("bczxl", jhbc>0?new BigDecimal(sjbc).divide(new BigDecimal(jhbc), | |
| 2738 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2739 | - resMap.put("smbzdl", jhsmbc>0?new BigDecimal(sjsmbc).divide(new BigDecimal(jhsmbc), | |
| 2740 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2741 | - resMap.put("qqzzdl", jhqqbc>0?new BigDecimal(sjqqzd).divide(new BigDecimal(jhqqbc), | |
| 2742 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2743 | - resMap.put("gpzdl", jhgpqqbc>0?new BigDecimal(sjgpqqzd).divide(new BigDecimal(jhgpqqbc), | |
| 2744 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2745 | - | |
| 2746 | - return JSON.parseObject(JSON.toJSONString(resMap)); | |
| 2747 | - } | |
| 2748 | - | |
| 2749 | - /** 按日期查询四家直属公司统计指标 */ | |
| 2750 | - @GET | |
| 2751 | - @Path("/selectData/getCompanyData/{date}") | |
| 2752 | - public List<Map<String, Object>> getCompanyData(@PathParam("date") String date){ | |
| 2753 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 2754 | - | |
| 2755 | -// String date = sd.format(new Date()); | |
| 2756 | - | |
| 2757 | - String gpLineSql = "select * from bsth_c_line_plate"; | |
| 2758 | - List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | |
| 2759 | - new RowMapper<Map<String, Object>>(){ | |
| 2760 | - @Override | |
| 2761 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2762 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2763 | - m.put("lineName", rs.getString("line_name")); | |
| 2764 | - m.put("lineCode", rs.getString("line_code")); | |
| 2765 | - return m; | |
| 2766 | - } | |
| 2767 | - }); | |
| 2768 | - | |
| 2769 | - Set<String> gpSet = new HashSet<String>(); | |
| 2770 | - for(Map<String, Object> t : gpLineList){ | |
| 2771 | - if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | |
| 2772 | - gpSet.add(t.get("lineCode").toString().trim()); | |
| 2773 | - } | |
| 2774 | - } | |
| 2775 | - | |
| 2776 | - | |
| 2777 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 2778 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 2779 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 2780 | - new RowMapper<Map<String, Object>>(){ | |
| 2781 | - @Override | |
| 2782 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2783 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2784 | - m.put("lineCode", rs.getString("line_code")); | |
| 2785 | - return m; | |
| 2786 | - } | |
| 2787 | - }); | |
| 2788 | - Set<String> yyLine = new HashSet<String>(); | |
| 2789 | - for(Map<String, Object> t : yyxlList){ | |
| 2790 | - if(t.get("lineCode") != null){ | |
| 2791 | - yyLine.add(t.get("lineCode").toString()); | |
| 2792 | - } | |
| 2793 | - } | |
| 2794 | - | |
| 2795 | - | |
| 2796 | - String gsSql="SELECT business_name, business_code from bsth_c_business "; | |
| 2797 | - List<Map<String, Object>> gsList=jdbcTemplate.query(gsSql, | |
| 2798 | - new RowMapper<Map<String, Object>>(){ | |
| 2799 | - @Override | |
| 2800 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2801 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2802 | - m.put("name", rs.getString("business_name")!=null?rs.getString("business_name"):""); | |
| 2803 | - m.put("code", rs.getString("business_code")!=null?rs.getString("business_code"):""); | |
| 2804 | - return m; | |
| 2805 | - } | |
| 2806 | - }); | |
| 2807 | - final Map<String, String> gsMap = new HashMap<String, String>(); | |
| 2808 | - for(Map<String, Object> t : gsList){ | |
| 2809 | - if(t.get("code") != null && t.get("name") != null){ | |
| 2810 | - gsMap.put(t.get("code").toString(), t.get("name").toString().substring(0, 2)); | |
| 2811 | - } | |
| 2812 | - } | |
| 2813 | - | |
| 2814 | - | |
| 2815 | - String sql="select gsdm,xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | |
| 2816 | - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | |
| 2817 | - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | |
| 2818 | - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | |
| 2819 | - + " jhszfcs,sjszfczds,szfczdl,jhzgl,sjzgl,create_date" | |
| 2820 | - + " from bsth_c_calc_count " | |
| 2821 | - + " where date = ? and gsdm != '77'"; | |
| 2822 | - | |
| 2823 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, new Object[]{date}, | |
| 2824 | - new RowMapper<Map<String, Object>>(){ | |
| 2825 | - @Override | |
| 2826 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 2827 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 2828 | - m.put("gs",rs.getString("gsdm")!=null?gsMap.get(rs.getString("gsdm")):""); | |
| 2829 | - m.put("lineCode",rs.getString("xl")); | |
| 2830 | - m.put("lineName", rs.getString("xl_name")); | |
| 2831 | - m.put("date", rs.getString("date")); | |
| 2832 | - | |
| 2833 | - m.put("jhbc", rs.getString("jhbc")); | |
| 2834 | - m.put("sjbc", rs.getString("sjbc")); | |
| 2835 | - m.put("bczxl", rs.getString("bczxl")); | |
| 2836 | - m.put("jhbcz", rs.getString("jhbcz")); | |
| 2837 | - | |
| 2838 | - m.put("jhcc", rs.getString("jhcc")); | |
| 2839 | - m.put("sjcc", rs.getString("sjcc")); | |
| 2840 | - m.put("ccl", rs.getString("ccl")); | |
| 2841 | - m.put("jhccz", rs.getString("jhccz")); | |
| 2842 | - | |
| 2843 | - m.put("jhyylc", rs.getString("jhyylc")); | |
| 2844 | - m.put("sjyylc", rs.getString("sjyylc")); | |
| 2845 | - m.put("jhyylcz", rs.getString("jhyylcz")); | |
| 2846 | - m.put("jhkslc", rs.getString("jhkslc")); | |
| 2847 | - m.put("sjkslc", rs.getString("sjkslc")); | |
| 2848 | - m.put("jhkslcz", rs.getString("jhkslcz")); | |
| 2849 | - | |
| 2850 | - m.put("jhgfbcs", rs.getString("jhssgfbcs")); | |
| 2851 | - m.put("sjgfbcs", rs.getString("sjgfbcs")); | |
| 2852 | - m.put("jhgfbcsz", rs.getString("jhgfbcsz")); | |
| 2853 | - m.put("jhdgbcs", rs.getString("jhssdgbcs")); | |
| 2854 | - m.put("sjdgbcs", rs.getString("sjdgbcs")); | |
| 2855 | - m.put("jhdgbcsz", rs.getString("jhdgbcsz")); | |
| 2856 | - | |
| 2857 | - m.put("jhsmbcs", rs.getString("jhsmbcs")); | |
| 2858 | - m.put("sjsmbczds", rs.getString("sjsmbczds")); | |
| 2859 | - m.put("smbczdl", rs.getString("smbczdl")); | |
| 2860 | - m.put("jhsmbcsz", rs.getString("jhsmbcsz")); | |
| 2861 | - m.put("sjsmbczdsz", rs.getString("sjsmbczdsz")); | |
| 2862 | - m.put("smbczdlz", rs.getString("smbczdlz")); | |
| 2863 | - | |
| 2864 | - m.put("jhszfcs", rs.getString("jhszfcs")); | |
| 2865 | - m.put("sjszfczds", rs.getString("sjszfczds")); | |
| 2866 | - m.put("szfczdl", rs.getString("szfczdl")); | |
| 2867 | - | |
| 2868 | - m.put("jhzgl", rs.getString("jhzgl")); | |
| 2869 | - m.put("sjzgl", rs.getString("sjzgl")); | |
| 2870 | - | |
| 2871 | - Date date = new Date(); | |
| 2872 | - date.setTime(rs.getTimestamp("create_date").getTime()); | |
| 2873 | - m.put("createDate", sdf.format(date)); | |
| 2874 | - return m; | |
| 2875 | - } | |
| 2876 | - }); | |
| 2877 | - | |
| 2878 | - | |
| 2879 | - Map<String, Integer> sortMap = new HashMap<String, Integer>(); | |
| 2880 | - sortMap.put("杨高", 0); | |
| 2881 | - sortMap.put("上南", 1); | |
| 2882 | - sortMap.put("金高", 2); | |
| 2883 | - sortMap.put("南汇", 3); | |
| 2884 | - sortMap.put("浦交", 4); | |
| 2885 | - Map<String, Object> ygMap = new HashMap<String, Object>(); | |
| 2886 | - ygMap.put("gs", "杨高"); | |
| 2887 | - resList.add(ygMap); | |
| 2888 | - Map<String, Object> snMap = new HashMap<String, Object>(); | |
| 2889 | - snMap.put("gs", "上南"); | |
| 2890 | - resList.add(snMap); | |
| 2891 | - Map<String, Object> jgMap = new HashMap<String, Object>(); | |
| 2892 | - jgMap.put("gs", "金高"); | |
| 2893 | - resList.add(jgMap); | |
| 2894 | - Map<String, Object> nhMap = new HashMap<String, Object>(); | |
| 2895 | - nhMap.put("gs", "南汇"); | |
| 2896 | - resList.add(nhMap); | |
| 2897 | - Map<String, Object> pjMap = new HashMap<String, Object>(); | |
| 2898 | - pjMap.put("gs", "浦交"); | |
| 2899 | - resList.add(pjMap); | |
| 2900 | - | |
| 2901 | - | |
| 2902 | - for(Map<String, Object> t : list){ | |
| 2903 | - if(yyLine.contains(t.get("lineCode").toString())){ | |
| 2904 | - if(sortMap.get(t.get("gs")) != null){ | |
| 2905 | - Map<String, Object> m = resList.get(sortMap.get(t.get("gs"))); | |
| 2906 | - mapPut(m, "jhcc", t.get("jhccz").toString()); | |
| 2907 | - mapPut(m, "sjcc", t.get("sjcc").toString()); | |
| 2908 | - mapPut(m, "jhbc", t.get("jhbc").toString()); | |
| 2909 | - mapPut(m, "sjbc", t.get("sjbc").toString()); | |
| 2910 | - mapPut(m, "jhsmbc", t.get("jhsmbcs").toString()); | |
| 2911 | - mapPut(m, "sjsmbc", t.get("sjsmbczds").toString()); | |
| 2912 | - mapPut(m, "jhqqbc", t.get("jhszfcs").toString()); | |
| 2913 | - mapPut(m, "sjqqzd", t.get("sjszfczds").toString()); | |
| 2914 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 2915 | - mapPut(m, "jhgpqqbc", t.get("jhszfcs").toString()); | |
| 2916 | - mapPut(m, "sjgpqqzd", t.get("sjszfczds").toString()); | |
| 2917 | - } | |
| 2918 | - mapPut(m, "jhzgl", t.get("jhzgl").toString()); | |
| 2919 | - mapPut(m, "sjzgl", t.get("sjzgl").toString()); | |
| 2920 | - } | |
| 2921 | - | |
| 2922 | - mapPut(pjMap, "jhcc", t.get("jhccz").toString()); | |
| 2923 | - mapPut(pjMap, "sjcc", t.get("sjcc").toString()); | |
| 2924 | - mapPut(pjMap, "jhbc", t.get("jhbc").toString()); | |
| 2925 | - mapPut(pjMap, "sjbc", t.get("sjbc").toString()); | |
| 2926 | - mapPut(pjMap, "jhsmbc", t.get("jhsmbcs").toString()); | |
| 2927 | - mapPut(pjMap, "sjsmbc", t.get("sjsmbczds").toString()); | |
| 2928 | - mapPut(pjMap, "jhqqbc", t.get("jhszfcs").toString()); | |
| 2929 | - mapPut(pjMap, "sjqqzd", t.get("sjszfczds").toString()); | |
| 2930 | - if(gpSet.contains(t.get("lineCode").toString())){ | |
| 2931 | - mapPut(pjMap, "jhgpqqbc", t.get("jhszfcs").toString()); | |
| 2932 | - mapPut(pjMap, "sjgpqqzd", t.get("sjszfczds").toString()); | |
| 2933 | - } | |
| 2934 | - mapPut(pjMap, "jhzgl", t.get("jhzgl").toString()); | |
| 2935 | - mapPut(pjMap, "sjzgl", t.get("sjzgl").toString()); | |
| 2936 | - } | |
| 2937 | - } | |
| 2938 | - | |
| 2939 | - | |
| 2940 | - //计算签卡率 | |
| 2941 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date); | |
| 2942 | - long jh = 0, sj = 0; | |
| 2943 | - for(ScheduleRealInfo s : findAll){ | |
| 2944 | - if(!("77".equals(s.getGsBm())) && s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 2945 | - if(!isInOut(s) && !s.isCcService() && s.getStatus() != -1 && s.getStatus() != 0){ | |
| 2946 | - if(s.getGsBm()!=null && sortMap.get(gsMap.get(s.getGsBm()!=null?s.getGsBm():"")) != null){ | |
| 2947 | - Map<String, Object> m = resList.get(sortMap.get(gsMap.get(s.getGsBm()))); | |
| 2948 | - ++jh; | |
| 2949 | - mapPut(m, "bcs", 1); | |
| 2950 | - String sty = decimalToBinary(s.getRfidState()); | |
| 2951 | - Integer state = Integer.parseInt(sty); | |
| 2952 | - if ((state & 4) == 4) { | |
| 2953 | - ++sj; | |
| 2954 | - mapPut(m, "qks", 1); | |
| 2955 | - } | |
| 2956 | - } | |
| 2957 | - } | |
| 2958 | - } | |
| 2959 | - } | |
| 2960 | - mapPut(pjMap, "bcs", jh); | |
| 2961 | - mapPut(pjMap, "qks", sj); | |
| 2962 | - | |
| 2963 | - | |
| 2964 | - for(Map<String, Object> m : resList){ | |
| 2965 | - m.put("date", date); | |
| 2966 | - | |
| 2967 | - m.put("glzxl", new BigDecimal(m.get("jhzgl").toString()).doubleValue()>0? | |
| 2968 | - new BigDecimal(m.get("sjzgl").toString()).divide(new BigDecimal(m.get("jhzgl").toString()), | |
| 2969 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2970 | - m.put("ccl", new BigDecimal(m.get("jhcc").toString()).doubleValue()>0? | |
| 2971 | - new BigDecimal(m.get("sjcc").toString()).divide(new BigDecimal(m.get("jhcc").toString()), | |
| 2972 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2973 | - m.put("bczxl", new BigDecimal(m.get("jhbc").toString()).doubleValue()>0? | |
| 2974 | - new BigDecimal(m.get("sjbc").toString()).divide(new BigDecimal(m.get("jhbc").toString()), | |
| 2975 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2976 | - m.put("smbzdl", new BigDecimal(m.get("jhsmbc").toString()).doubleValue()>0? | |
| 2977 | - new BigDecimal(m.get("sjsmbc").toString()).divide(new BigDecimal(m.get("jhsmbc").toString()), | |
| 2978 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2979 | - m.put("qqzzdl", new BigDecimal(m.get("jhqqbc").toString()).doubleValue()>0? | |
| 2980 | - new BigDecimal(m.get("sjqqzd").toString()).divide(new BigDecimal(m.get("jhqqbc").toString()), | |
| 2981 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2982 | - m.put("gpzdl", new BigDecimal(m.get("jhgpqqbc").toString()).doubleValue()>0? | |
| 2983 | - new BigDecimal(m.get("sjgpqqzd").toString()).divide(new BigDecimal(m.get("jhgpqqbc").toString()), | |
| 2984 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2985 | - m.put("qkl", new BigDecimal(m.get("bcs")!=null?m.get("bcs").toString():"0").doubleValue()>0? | |
| 2986 | - new BigDecimal(m.get("qks")!=null?m.get("qks").toString():"0").divide(new BigDecimal(m.get("bcs").toString()), | |
| 2987 | - 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0"); | |
| 2988 | - } | |
| 2989 | - | |
| 2990 | - return resList; | |
| 2991 | - } | |
| 2992 | - | |
| 2993 | - /** 报备登记查询接口 */ | |
| 2994 | - @GET | |
| 2995 | - @Path("/selectData/getReport/startDate/{startDate}/endDate/{endDate}") | |
| 2996 | - public List<Map<String, Object>> getReport(@PathParam("startDate") String starDate, | |
| 2997 | - @PathParam("endDate") String endDate){ | |
| 2998 | - Date d1 = new Date(), d2 = new Date(); | |
| 2999 | - try{ | |
| 3000 | - SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |
| 3001 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 3002 | - d1 = sd.parse(starDate); | |
| 3003 | - d2 = sd.parse(endDate); | |
| 3004 | - d2.setTime(d2.getTime() + (1l*1000*60*60*24 - 1)); | |
| 3005 | - starDate = sdf.format(d1); | |
| 3006 | - endDate = sdf.format(d2); | |
| 3007 | - }catch(ParseException e){ | |
| 3008 | - // TODO Auto-generated catch block | |
| 3009 | - e.printStackTrace(); | |
| 3010 | - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | |
| 3011 | - Map<String, Object> result = new HashMap<String, Object>(); | |
| 3012 | - result.put("msg", "参数日期格式错误"); | |
| 3013 | - list.add(result); | |
| 3014 | - return list; | |
| 3015 | - } | |
| 3016 | - String sql="SELECT ID,REPORT_TYPE,REPORT_GS,REPORT_FGS,REPORT_GSNAME,REPORT_FGSNAME," | |
| 3017 | - + " REPORT_DATE,REPORT_BBR,REPORT_XL,REPORT_XLNAME,REPORT_STATION,REPORT_DWSBBM," | |
| 3018 | - + " REPORT_DWSBSJ,REPORT_YWSJ,REPORT_SMBWD,REPORT_DJGSJ,REPORT_DJGYY,REPORT_TFSJ," | |
| 3019 | - + " REPORT_YXSJ,REPORT_YXBC,REPORT_TZCS,REPORT_SGBH,REPORT_ZBH,REPORT_PZH,REPORT_JSY," | |
| 3020 | - + " REPORT_SGSJ,REPORT_SGDD,REPORT_XSFX,REPORT_SGDX,REPORT_DXPZH,REPORT_SGGK," | |
| 3021 | - + " REPORT_SSRS,REPORT_SWRS,REPORT_BGR,REPORT_BGRDH,REPORT_BZ,REPORT_ROAD,STATUS," | |
| 3022 | - + " CREATE_BY,CREATE_DATE,UPDATE_BY,UPDATE_DATE" | |
| 3023 | - + " from bsth_t_report " | |
| 3024 | - + " where REPORT_DATE >= ? and REPORT_DATE <= ?"; | |
| 3025 | - List<Map<String, Object>> list=jdbcTemplate.query(sql, new Object[]{starDate, endDate}, | |
| 3026 | - new RowMapper<Map<String, Object>>(){ | |
| 3027 | - @Override | |
| 3028 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 3029 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 3030 | - m.put("ID", rs.getString("ID")); | |
| 3031 | - m.put("REPORT_TYPE", rs.getString("REPORT_TYPE")); | |
| 3032 | - m.put("REPORT_GS", rs.getString("REPORT_GS")); | |
| 3033 | - m.put("REPORT_FGS",rs.getString("REPORT_FGS")); | |
| 3034 | - m.put("REPORT_GSNAME",rs.getString("REPORT_GSNAME")); | |
| 3035 | - m.put("REPORT_FGSNAME",rs.getString("REPORT_FGSNAME")); | |
| 3036 | - m.put("REPORT_DATE",rs.getString("REPORT_DATE")); | |
| 3037 | - m.put("REPORT_BBR",rs.getString("REPORT_BBR")); | |
| 3038 | - m.put("REPORT_XL",rs.getString("REPORT_XL")); | |
| 3039 | - m.put("REPORT_XLNAME",rs.getString("REPORT_XLNAME")); | |
| 3040 | - m.put("REPORT_STATION",rs.getString("REPORT_STATION")); | |
| 3041 | - m.put("REPORT_DWSBBM",rs.getString("REPORT_DWSBBM")); | |
| 3042 | - m.put("REPORT_DWSBSJ",rs.getString("REPORT_DWSBSJ")); | |
| 3043 | - m.put("REPORT_YWSJ",rs.getString("REPORT_YWSJ")); | |
| 3044 | - m.put("REPORT_SMBWD",rs.getString("REPORT_SMBWD")); | |
| 3045 | - m.put("REPORT_DJGSJ",rs.getString("REPORT_DJGSJ")); | |
| 3046 | - m.put("REPORT_DJGYY",rs.getString("REPORT_DJGYY")); | |
| 3047 | - m.put("REPORT_TFSJ",rs.getString("REPORT_TFSJ")); | |
| 3048 | - m.put("REPORT_YXSJ",rs.getString("REPORT_YXSJ")); | |
| 3049 | - m.put("REPORT_YXBC",rs.getString("REPORT_YXBC")); | |
| 3050 | - m.put("REPORT_TZCS",rs.getString("REPORT_TZCS")); | |
| 3051 | - m.put("REPORT_SGBH",rs.getString("REPORT_SGBH")); | |
| 3052 | - m.put("REPORT_ZBH",rs.getString("REPORT_ZBH")); | |
| 3053 | - m.put("REPORT_PZH",rs.getString("REPORT_PZH")); | |
| 3054 | - m.put("REPORT_JSY",rs.getString("REPORT_JSY")); | |
| 3055 | - m.put("REPORT_SGSJ",rs.getString("REPORT_SGSJ")); | |
| 3056 | - m.put("REPORT_SGDD",rs.getString("REPORT_SGDD")); | |
| 3057 | - m.put("REPORT_XSFX", rs.getString("REPORT_XSFX")); | |
| 3058 | - m.put("REPORT_SGDX", rs.getString("REPORT_SGDX")); | |
| 3059 | - m.put("REPORT_DXPZH", rs.getString("REPORT_DXPZH")); | |
| 3060 | - m.put("REPORT_SGGK", rs.getString("REPORT_SGGK")); | |
| 3061 | - m.put("REPORT_SSRS", rs.getString("REPORT_SSRS")); | |
| 3062 | - m.put("REPORT_SWRS", rs.getString("REPORT_SWRS")); | |
| 3063 | - m.put("REPORT_BGR", rs.getString("REPORT_BGR")); | |
| 3064 | - m.put("REPORT_BGRDH", rs.getString("REPORT_BGRDH")); | |
| 3065 | - m.put("REPORT_BZ", rs.getString("REPORT_BZ")); | |
| 3066 | - m.put("REPORT_ROAD", rs.getString("REPORT_ROAD")); | |
| 3067 | - m.put("STATUS", rs.getString("STATUS")); | |
| 3068 | - m.put("CREATE_BY", rs.getString("CREATE_BY")); | |
| 3069 | - m.put("CREATE_DATE", rs.getString("CREATE_DATE")); | |
| 3070 | - m.put("UPDATE_BY", rs.getString("UPDATE_BY")); | |
| 3071 | - m.put("UPDATE_DATE", rs.getString("UPDATE_DATE")); | |
| 3072 | - return m; | |
| 3073 | - } | |
| 3074 | - }); | |
| 3075 | - | |
| 3076 | - return list; | |
| 3077 | - } | |
| 3078 | - | |
| 3079 | - /** 按日期查询所有线路大间隔情况 */ | |
| 3080 | - @GET | |
| 3081 | - @Path("/selectData/getLineInterval/{date}") | |
| 3082 | - public List<Map<String, Object>> getLineInterval(@PathParam("date") String date){ | |
| 3083 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 3084 | - | |
| 3085 | - String gsSql="SELECT business_name, business_code, up_code from bsth_c_business "; | |
| 3086 | - List<Map<String, Object>> gsList=jdbcTemplate.query(gsSql, | |
| 3087 | - new RowMapper<Map<String, Object>>(){ | |
| 3088 | - @Override | |
| 3089 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 3090 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 3091 | - m.put("name", rs.getString("business_name")!=null?rs.getString("business_name"):""); | |
| 3092 | - m.put("code", rs.getString("business_code")!=null?rs.getString("business_code"):""); | |
| 3093 | - m.put("upCode", rs.getString("up_code")!=null?rs.getString("up_code"):""); | |
| 3094 | - return m; | |
| 3095 | - } | |
| 3096 | - }); | |
| 3097 | - | |
| 3098 | - Map<String, Object> gsMap = new HashMap<String, Object>(); | |
| 3099 | - Map<String, Object> fgsMap = new HashMap<String, Object>(); | |
| 3100 | - for(Map<String, Object> m : gsList){ | |
| 3101 | - if(m.get("upCode") != null && m.get("upCode").toString().trim().length() > 0 | |
| 3102 | - && !("0".equals(m.get("upCode").toString().trim()))){ | |
| 3103 | - if("88".equals(m.get("upCode").toString().trim())){ | |
| 3104 | - gsMap.put(m.get("code").toString(), m.get("name").toString()); | |
| 3105 | - } else { | |
| 3106 | - fgsMap.put(m.get("code").toString()+"_"+m.get("upCode").toString(), m.get("name").toString()); | |
| 3107 | - } | |
| 3108 | - } | |
| 3109 | - } | |
| 3110 | - | |
| 3111 | - String calcIntervalSql = "select * from bsth_c_calc_interval where date = ? and sfyy = 1 and gsbm != '77'"; | |
| 3112 | - List<Map<String, Object>> calcIntervalList=jdbcTemplate.query(calcIntervalSql, | |
| 3113 | - new Object[]{date}, | |
| 3114 | - new RowMapper<Map<String, Object>>(){ | |
| 3115 | - @Override | |
| 3116 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 3117 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 3118 | - m.put("gsbm", rs.getString("gsbm")); | |
| 3119 | - m.put("fgsbm", rs.getString("fgsbm")); | |
| 3120 | - m.put("date", rs.getString("date")); | |
| 3121 | - m.put("xlBm", rs.getString("xl_bm")); | |
| 3122 | - m.put("xlName", rs.getString("xl_name")); | |
| 3123 | - m.put("level", rs.getString("level")); | |
| 3124 | - return m; | |
| 3125 | - } | |
| 3126 | - }); | |
| 3127 | - | |
| 3128 | - String calcIntervalDetailSql = "select * from bsth_c_calc_interval_detail where date = ?"; | |
| 3129 | - List<Map<String, Object>> calcIntervalDetailList=jdbcTemplate.query(calcIntervalDetailSql, | |
| 3130 | - new Object[]{date}, | |
| 3131 | - new RowMapper<Map<String, Object>>(){ | |
| 3132 | - @Override | |
| 3133 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 3134 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 3135 | - m.put("date", rs.getString("date")); | |
| 3136 | - m.put("xlBm", rs.getString("line_code")); | |
| 3137 | - m.put("xlName", rs.getString("line_name")); | |
| 3138 | - m.put("level", rs.getString("level")); | |
| 3139 | - m.put("station", rs.getString("station")); | |
| 3140 | - m.put("jhfc1", rs.getString("jhfc1")); | |
| 3141 | - m.put("sjfc1", rs.getString("sjfc1")); | |
| 3142 | - m.put("jhfc2", rs.getString("jhfc2")); | |
| 3143 | - m.put("sjfc2", rs.getString("sjfc2")); | |
| 3144 | - m.put("subTime", rs.getString("sub_time")); | |
| 3145 | - m.put("remark", rs.getString("remark")); | |
| 3146 | - return m; | |
| 3147 | - } | |
| 3148 | - }); | |
| 3149 | - | |
| 3150 | - Map<String, Map<String, Object>> calcIntervalMap = new HashMap<String, Map<String, Object>>(); | |
| 3151 | - | |
| 3152 | - for(Map<String, Object> m : calcIntervalList){ | |
| 3153 | - calcIntervalMap.put(m.get("xlBm").toString(), m); | |
| 3154 | - } | |
| 3155 | - | |
| 3156 | - for(Map<String, Object> m : calcIntervalDetailList){ | |
| 3157 | - String xlBm = m.get("xlBm").toString(); | |
| 3158 | - if(calcIntervalMap.containsKey(xlBm)){ | |
| 3159 | - Map<String, Object> map = calcIntervalMap.get(xlBm); | |
| 3160 | - m.put("gs", gsMap.get(map.get("gsbm").toString())); | |
| 3161 | - m.put("fgs", fgsMap.get(map.get("fgsbm").toString() + "_" + map.get("gsbm").toString())); | |
| 3162 | - resList.add(m); | |
| 3163 | - } | |
| 3164 | - } | |
| 3165 | - | |
| 3166 | - return resList; | |
| 3167 | - } | |
| 3168 | - | |
| 3169 | - /** 按日期(加前7天共8天)查询所有线路大间隔次数 */ | |
| 3170 | - @GET | |
| 3171 | - @Path("/selectData/getLastWeekIntervalSum/{date}") | |
| 3172 | - public List<Map<String, Object>> getLastWeekIntervalSum(@PathParam("date") String date) throws ParseException{ | |
| 3173 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 3174 | - | |
| 3175 | - String gsSql="SELECT business_name, business_code, up_code from bsth_c_business "; | |
| 3176 | - List<Map<String, Object>> gsList=jdbcTemplate.query(gsSql, | |
| 3177 | - new RowMapper<Map<String, Object>>(){ | |
| 3178 | - @Override | |
| 3179 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 3180 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 3181 | - m.put("name", rs.getString("business_name")!=null?rs.getString("business_name"):""); | |
| 3182 | - m.put("code", rs.getString("business_code")!=null?rs.getString("business_code"):""); | |
| 3183 | - m.put("upCode", rs.getString("up_code")!=null?rs.getString("up_code"):""); | |
| 3184 | - return m; | |
| 3185 | - } | |
| 3186 | - }); | |
| 3187 | - Map<String, Object> gsMap = new HashMap<String, Object>(); | |
| 3188 | - for(Map<String, Object> m : gsList){ | |
| 3189 | - if(m.get("upCode") != null && m.get("upCode").toString().trim().length() > 0 | |
| 3190 | - && !("0".equals(m.get("upCode").toString().trim()))){ | |
| 3191 | - if("88".equals(m.get("upCode").toString().trim())){ | |
| 3192 | - gsMap.put(m.get("code").toString(), m.get("name").toString()); | |
| 3193 | - } | |
| 3194 | - } | |
| 3195 | - } | |
| 3196 | - | |
| 3197 | - String[] gsS = {gsMap.get("05").toString(), gsMap.get("55").toString(), gsMap.get("22").toString(), gsMap.get("26").toString()}; | |
| 3198 | - String[] levelS = {"A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "D", "E"}; | |
| 3199 | - List<String> keyList = new ArrayList<String>(); | |
| 3200 | - for(String gs : gsS){ | |
| 3201 | - for(String level : levelS){ | |
| 3202 | - keyList.add(gs + "_" + level); | |
| 3203 | - } | |
| 3204 | - } | |
| 3205 | - | |
| 3206 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 3207 | - for(long l = 7l; l >= 0l; l--){ | |
| 3208 | - Date d = sdf.parse(date); | |
| 3209 | - d.setTime(d.getTime() - l*1000*60*60*24); | |
| 3210 | - String date1 = sdf.format(d); | |
| 3211 | - | |
| 3212 | - String calcIntervalSql = "select * from bsth_c_calc_interval where date = ? and sfyy = 1 and gsbm != '77'"; | |
| 3213 | - List<Map<String, Object>> calcIntervalList=jdbcTemplate.query(calcIntervalSql, | |
| 3214 | - new Object[]{date1}, | |
| 3215 | - new RowMapper<Map<String, Object>>(){ | |
| 3216 | - @Override | |
| 3217 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 3218 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 3219 | - m.put("gsbm", rs.getString("gsbm")); | |
| 3220 | - m.put("fgsbm", rs.getString("fgsbm")); | |
| 3221 | - m.put("date", rs.getString("date")); | |
| 3222 | - m.put("level", rs.getString("level")); | |
| 3223 | - m.put("djgAll", rs.getString("djg_all")); | |
| 3224 | - m.put("djgZgf", rs.getString("djg_zgf")); | |
| 3225 | - m.put("djgWgf", rs.getString("djg_wgf")); | |
| 3226 | - m.put("djgDg", rs.getString("djg_dg")); | |
| 3227 | - return m; | |
| 3228 | - } | |
| 3229 | - }); | |
| 3230 | - | |
| 3231 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | |
| 3232 | - for(Map<String, Object> m : calcIntervalList){ | |
| 3233 | - String gsName = gsMap.get(m.get("gsbm").toString()).toString(); | |
| 3234 | - String level = m.get("level").toString(); | |
| 3235 | - String key = gsName + "_" + level; | |
| 3236 | - if(!(keyMap.containsKey(key))){ | |
| 3237 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 3238 | - map.put("date", date1); | |
| 3239 | - map.put("gs", gsName); | |
| 3240 | - map.put("level", level); | |
| 3241 | - map.put("djgAll", 0); | |
| 3242 | - map.put("djgZgf", 0); | |
| 3243 | - map.put("djgWgf", 0); | |
| 3244 | - map.put("djgDg", 0); | |
| 3245 | - keyMap.put(key, map); | |
| 3246 | - } | |
| 3247 | - if(m.get("djgAll") != null && m.get("djgAll").toString().trim().length() > 0 | |
| 3248 | - && Long.valueOf(m.get("djgAll").toString()) > 0l){ | |
| 3249 | - Map<String, Object> map = keyMap.get(key); | |
| 3250 | - map.put("djgAll", Long.valueOf(map.get("djgAll").toString()) + Long.valueOf(m.get("djgAll").toString())); | |
| 3251 | - map.put("djgZgf", Long.valueOf(map.get("djgZgf").toString()) + Long.valueOf(m.get("djgZgf").toString())); | |
| 3252 | - map.put("djgWgf", Long.valueOf(map.get("djgWgf").toString()) + Long.valueOf(m.get("djgWgf").toString())); | |
| 3253 | - map.put("djgDg", Long.valueOf(map.get("djgDg").toString()) + Long.valueOf(m.get("djgDg").toString())); | |
| 3254 | - } | |
| 3255 | - } | |
| 3256 | - | |
| 3257 | - for(String key : keyList){ | |
| 3258 | - if(keyMap.containsKey(key)){ | |
| 3259 | - resList.add(keyMap.get(key)); | |
| 3260 | - } | |
| 3261 | - } | |
| 3262 | - } | |
| 3263 | - | |
| 3264 | - return resList; | |
| 3265 | - } | |
| 3266 | - | |
| 3267 | - /** 按日期查询所有线路首班末班班次数 */ | |
| 3268 | - @GET | |
| 3269 | - @Path("/selectData/getFirstAndLast/{date}") | |
| 3270 | - public List<Map<String, Object>> getFirstAndLast(@PathParam("date") String date){ | |
| 3271 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 3272 | - | |
| 3273 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 3274 | - SimpleDateFormat sdf_ = new SimpleDateFormat("yyyy-MM-dd"); | |
| 3275 | - DecimalFormat df = new DecimalFormat("0.00"); | |
| 3276 | - Date createDate = new Date(); | |
| 3277 | - String sfss = "1"; //是否实时;=1为实时。 | |
| 3278 | - | |
| 3279 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 3280 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 3281 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 3282 | - new RowMapper<Map<String, Object>>(){ | |
| 3283 | - @Override | |
| 3284 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 3285 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 3286 | - m.put("lineCode", rs.getString("line_code")); | |
| 3287 | - return m; | |
| 3288 | - } | |
| 3289 | - }); | |
| 3290 | - | |
| 3291 | - //key:线路编码;value:每日营运开始时间 | |
| 3292 | - Map<String, Long> yyLine = new HashMap<String, Long>(); | |
| 3293 | - for(Map<String, Object> t : yyxlList){ | |
| 3294 | - if(t.get("lineCode") != null){ | |
| 3295 | - String lineCode = t.get("lineCode").toString(); | |
| 3296 | -// yyLine.add(t.get("lineCode").toString()); | |
| 3297 | - String minfcsj="02:00"; | |
| 3298 | - String sqlMinYysj="select start_opt from bsth_c_line_config where " | |
| 3299 | - + " id = (" | |
| 3300 | - + "select max(id) from bsth_c_line_config where line = ?" | |
| 3301 | - + ")"; | |
| 3302 | - List<String> list= jdbcTemplate.query(sqlMinYysj, | |
| 3303 | - new Object[]{lineCode}, | |
| 3304 | - new RowMapper<String>(){ | |
| 3305 | - @Override | |
| 3306 | - public String mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 3307 | - String startopt=rs.getString("start_opt"); | |
| 3308 | - return startopt; | |
| 3309 | - } | |
| 3310 | - }); | |
| 3311 | - if(list.size()>0){ | |
| 3312 | - minfcsj=list.get(0); | |
| 3313 | - } | |
| 3314 | - String[] minSjs = minfcsj.split(":"); | |
| 3315 | - //车辆最早发车时间 用来过滤超第二天0点的数据 | |
| 3316 | - Long minSj=Long.parseLong(minSjs[0])*60+Long.parseLong(minSjs[1]); | |
| 3317 | - | |
| 3318 | - yyLine.put(lineCode, minSj); | |
| 3319 | - } | |
| 3320 | - } | |
| 3321 | - | |
| 3322 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date); | |
| 3323 | - Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>(); | |
| 3324 | - Map<String, Map<String, Object>> lineXX = new HashMap<String, Map<String, Object>>(); | |
| 3325 | - for(ScheduleRealInfo s : findAll){ | |
| 3326 | -// if(s.getBcType().equals("region") || s.getBcType().equals("venting") | |
| 3327 | -// || s.getBcType().equals("major") || isInOut(s)){ | |
| 3328 | - if(s.getBcType().equals("region") || isInOut(s)){ | |
| 3329 | - continue; //区间班次、直放班次、放站班次与空驶班次不做首末班统计 | |
| 3330 | - } | |
| 3331 | - if(!("77".equals(s.getGsBm())) && yyLine.containsKey(s.getXlBm())){ //只统计营运线路 | |
| 3332 | - if(!(keyMap.containsKey(s.getXlBm()))){ | |
| 3333 | - keyMap.put(s.getXlBm(), new ArrayList<ScheduleRealInfo>()); | |
| 3334 | - } | |
| 3335 | - keyMap.get(s.getXlBm()).add(s); | |
| 3336 | - | |
| 3337 | - if(!(lineXX.containsKey(s.getXlBm()))){ | |
| 3338 | - lineXX.put(s.getXlBm(), new HashMap<String, Object>()); | |
| 3339 | - } | |
| 3340 | - Map<String, Object> xx = lineXX.get(s.getXlBm()); | |
| 3341 | - if(!(xx.containsKey("lineName")) && s.getXlName() != null && s.getXlName().trim().length() > 0){ | |
| 3342 | - xx.put("lineName", s.getXlName()); | |
| 3343 | - } | |
| 3344 | - if(!(xx.containsKey("gsBm")) && s.getGsBm() != null && s.getGsBm().trim().length() > 0){ | |
| 3345 | - xx.put("gsBm", s.getGsBm()); | |
| 3346 | - } | |
| 3347 | - if(!(xx.containsKey("gsName")) && s.getGsName() != null && s.getGsName().trim().length() > 0){ | |
| 3348 | - xx.put("gsName", s.getGsName()); | |
| 3349 | - } | |
| 3350 | - if(!(xx.containsKey("fgsBm")) && s.getFgsBm() != null && s.getFgsBm().trim().length() > 0){ | |
| 3351 | - xx.put("fgsBm", s.getFgsBm()); | |
| 3352 | - } | |
| 3353 | - if(!(xx.containsKey("fgsName")) && s.getFgsName() != null && s.getFgsName().trim().length() > 0){ | |
| 3354 | - xx.put("fgsName", s.getFgsName()); | |
| 3355 | - } | |
| 3356 | - } | |
| 3357 | - } | |
| 3358 | - | |
| 3359 | - for(String lineCode : keyMap.keySet()){ | |
| 3360 | - List<ScheduleRealInfo> listjh0 = new ArrayList<ScheduleRealInfo>(); | |
| 3361 | - List<ScheduleRealInfo> listjh1 = new ArrayList<ScheduleRealInfo>(); | |
| 3362 | - List<ScheduleRealInfo> listsj0 = new ArrayList<ScheduleRealInfo>(); | |
| 3363 | - List<ScheduleRealInfo> listsj1 = new ArrayList<ScheduleRealInfo>(); | |
| 3364 | - Long minFcsj = yyLine.get(lineCode); | |
| 3365 | - for(ScheduleRealInfo s : keyMap.get(lineCode)){ | |
| 3366 | - String[] fcsj = s.getFcsj().split(":"); | |
| 3367 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | |
| 3368 | - Long fscjT = 0L; | |
| 3369 | - if (fcsjL < minFcsj) { | |
| 3370 | - Calendar calendar = new GregorianCalendar(); | |
| 3371 | - calendar.setTime(s.getScheduleDate()); | |
| 3372 | - calendar.add(calendar.DATE, 1); | |
| 3373 | - Date d = calendar.getTime(); | |
| 3374 | - try { | |
| 3375 | - fscjT = sdf.parse(sdf_.format(d) + " " + s.getFcsj()).getTime(); | |
| 3376 | - } catch (ParseException e) { | |
| 3377 | - // TODO Auto-generated catch block | |
| 3378 | - e.printStackTrace(); | |
| 3379 | - } | |
| 3380 | - } else { | |
| 3381 | - try { | |
| 3382 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | |
| 3383 | - } catch (ParseException e) { | |
| 3384 | - // TODO Auto-generated catch block | |
| 3385 | - e.printStackTrace(); | |
| 3386 | - } | |
| 3387 | - } | |
| 3388 | - | |
| 3389 | - if (StringUtils.isEmpty(s.getFcsjActual())) { | |
| 3390 | - s.setFcsjActualTime(0L); | |
| 3391 | - s.setFcsjT(fscjT); | |
| 3392 | - } else { | |
| 3393 | - Long fcsjAcual = 0L; | |
| 3394 | - try { | |
| 3395 | - fcsjAcual = sdf.parse(s.getRealExecDate() + " " + s.getFcsjActual()).getTime(); | |
| 3396 | - if(fcsjAcual - fscjT > (20l*60*60*1000)){//如果实发比计发大20小时则认为日期有误,如实发在次日,计发为00:00,实发为23:59 | |
| 3397 | - fcsjAcual -= 1l*24*60*60*1000; | |
| 3398 | - } if(fscjT - fcsjAcual > (20l*60*60*1000)){ | |
| 3399 | - fcsjAcual += 1l*24*60*60*1000; | |
| 3400 | - } | |
| 3401 | - s.setFcsjActualTime(fcsjAcual); | |
| 3402 | - s.setFcsjT(fscjT); | |
| 3403 | - } catch (ParseException e) { | |
| 3404 | - // TODO Auto-generated catch block | |
| 3405 | - e.printStackTrace(); | |
| 3406 | - } | |
| 3407 | - } | |
| 3408 | - | |
| 3409 | - if (!(s.isSflj())) { | |
| 3410 | - if (s.getXlDir().equals("0")) { | |
| 3411 | - listjh0.add(s); | |
| 3412 | - } else { | |
| 3413 | - listjh1.add(s); | |
| 3414 | - } | |
| 3415 | - } | |
| 3416 | - | |
| 3417 | - if(s.getFcsjActual() != null && s.getFcsjActual().trim().length() > 0){ | |
| 3418 | - if (s.getXlDir().equals("0")) { | |
| 3419 | - listsj0.add(s); | |
| 3420 | - } else { | |
| 3421 | - listsj1.add(s); | |
| 3422 | - } | |
| 3423 | - } | |
| 3424 | - } | |
| 3425 | - | |
| 3426 | - Collections.sort(listjh0, new ComparableJhfc()); | |
| 3427 | - Collections.sort(listjh1, new ComparableJhfc()); | |
| 3428 | - Collections.sort(listsj0, new ComparableAcual()); | |
| 3429 | - Collections.sort(listsj1, new ComparableAcual()); | |
| 3430 | - int jhFirst = 0, jhLast = 0, sjzdFirst = 0, sjzdLast = 0; | |
| 3431 | - | |
| 3432 | - //上行 | |
| 3433 | - if(listjh0.size() > 0){ | |
| 3434 | - ScheduleRealInfo jhsb = listjh0.get(0); //计划首班 | |
| 3435 | - for(int f = 0; f < listjh0.size(); f++){ | |
| 3436 | - jhsb = listjh0.get(f); //计划首班 | |
| 3437 | - String bcType = jhsb.getBcType(); | |
| 3438 | - List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhsb.getSpId()); | |
| 3439 | - if(oList.size() > 0 && oList.get(0) != null | |
| 3440 | - && oList.get(0).trim().length() > 0){ | |
| 3441 | - bcType = oList.get(0).trim(); | |
| 3442 | - } | |
| 3443 | - if(bcType.equals("region") || bcType.equals("venting") | |
| 3444 | - || bcType.equals("major") || isInOut(bcType)){ | |
| 3445 | - continue; | |
| 3446 | - } | |
| 3447 | - break; | |
| 3448 | - } | |
| 3449 | - if("1".equals(sfss) ? createDate.getTime() > jhsb.getFcsjT() : true){ | |
| 3450 | - jhFirst++; | |
| 3451 | - for(int i = 0; i < listsj0.size(); i++){ | |
| 3452 | - ScheduleRealInfo sjsb = listsj0.get(i); //实际首班 | |
| 3453 | - String bcType = sjsb.getBcType(); | |
| 3454 | - if(bcType.equals("region") || bcType.equals("venting") | |
| 3455 | - || bcType.equals("major") || isInOut(bcType)){ | |
| 3456 | - continue; | |
| 3457 | - } | |
| 3458 | - long wd = sjsb.getFcsjActualTime() - jhsb.getFcsjT(); //误点,快1慢2 | |
| 3459 | - if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | |
| 3460 | - sjzdFirst++; | |
| 3461 | - break; | |
| 3462 | - } | |
| 3463 | - } | |
| 3464 | - } | |
| 3465 | - | |
| 3466 | - if(listjh0.size() > 1){ | |
| 3467 | - ScheduleRealInfo jhmb = listjh0.get(listjh0.size() - 1); //计划末班 | |
| 3468 | - for(int l = listjh0.size() - 1; l >= 0; l--){ | |
| 3469 | - jhmb = listjh0.get(l); //计划首班 | |
| 3470 | - String bcType = jhmb.getBcType(); | |
| 3471 | - List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhmb.getSpId()); | |
| 3472 | - if(oList.size() > 0 && oList.get(0) != null | |
| 3473 | - && oList.get(0).trim().length() > 0){ | |
| 3474 | - bcType = oList.get(0).trim(); | |
| 3475 | - } | |
| 3476 | - if(bcType.equals("region") || bcType.equals("venting") | |
| 3477 | - || bcType.equals("major") || isInOut(bcType)){ | |
| 3478 | - continue; | |
| 3479 | - } | |
| 3480 | - break; | |
| 3481 | - } | |
| 3482 | - if("1".equals(sfss) ? createDate.getTime() > jhmb.getFcsjT() : true){ | |
| 3483 | - jhLast++; | |
| 3484 | - for(int i = listsj0.size() - 1; i >= 0; i--){ | |
| 3485 | - ScheduleRealInfo sjmb = listsj0.get(i); //实际末班 | |
| 3486 | - String bcType = sjmb.getBcType(); | |
| 3487 | - if(bcType.equals("region") || bcType.equals("venting") | |
| 3488 | - || bcType.equals("major") || isInOut(bcType)){ | |
| 3489 | - continue; | |
| 3490 | - } | |
| 3491 | - long wd = sjmb.getFcsjActualTime() - jhmb.getFcsjT(); //误点,快1慢2 | |
| 3492 | - if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | |
| 3493 | - sjzdLast++; | |
| 3494 | - break; | |
| 3495 | - } | |
| 3496 | - } | |
| 3497 | - } | |
| 3498 | - } | |
| 3499 | - } | |
| 3500 | - | |
| 3501 | - //下行 | |
| 3502 | - if(listjh1.size() > 0){ | |
| 3503 | - ScheduleRealInfo jhsb = listjh1.get(0); //计划首班 | |
| 3504 | - for(int f = 0; f < listjh1.size(); f++){ | |
| 3505 | - jhsb = listjh1.get(f); //计划首班 | |
| 3506 | - String bcType = jhsb.getBcType(); | |
| 3507 | - List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhsb.getSpId()); | |
| 3508 | - if(oList.size() > 0 && oList.get(0) != null | |
| 3509 | - && oList.get(0).trim().length() > 0){ | |
| 3510 | - bcType = oList.get(0).trim(); | |
| 3511 | - } | |
| 3512 | - if(bcType.equals("region") || bcType.equals("venting") | |
| 3513 | - || bcType.equals("major") || isInOut(bcType)){ | |
| 3514 | - continue; | |
| 3515 | - } | |
| 3516 | - break; | |
| 3517 | - } | |
| 3518 | - if("1".equals(sfss) ? createDate.getTime() > jhsb.getFcsjT() : true){ | |
| 3519 | - jhFirst++; | |
| 3520 | - for(int i = 0; i < listsj1.size(); i++){ | |
| 3521 | - ScheduleRealInfo sjsb = listsj1.get(i); //实际首班 | |
| 3522 | - String bcType = sjsb.getBcType(); | |
| 3523 | - if(bcType.equals("region") || bcType.equals("venting") | |
| 3524 | - || bcType.equals("major") || isInOut(bcType)){ | |
| 3525 | - continue; | |
| 3526 | - } | |
| 3527 | - long wd = sjsb.getFcsjActualTime() - jhsb.getFcsjT(); //误点,快1慢2 | |
| 3528 | - if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | |
| 3529 | - sjzdFirst++; | |
| 3530 | - break; | |
| 3531 | - } | |
| 3532 | - } | |
| 3533 | - } | |
| 3534 | - | |
| 3535 | - if(listjh1.size() > 1){ | |
| 3536 | - ScheduleRealInfo jhmb = listjh1.get(listjh1.size() - 1); //计划末班 | |
| 3537 | - for(int l = listjh1.size() - 1; l >= 0; l--){ | |
| 3538 | - jhmb = listjh1.get(l); //计划首班 | |
| 3539 | - String bcType = jhmb.getBcType(); | |
| 3540 | - List<String> oList = scheduleRealInfoRepository.findoOriginalType(jhmb.getSpId()); | |
| 3541 | - if(oList.size() > 0 && oList.get(0) != null | |
| 3542 | - && oList.get(0).trim().length() > 0){ | |
| 3543 | - bcType = oList.get(0).trim(); | |
| 3544 | - } | |
| 3545 | - if(bcType.equals("region") || bcType.equals("venting") | |
| 3546 | - || bcType.equals("major") || isInOut(bcType)){ | |
| 3547 | - continue; | |
| 3548 | - } | |
| 3549 | - break; | |
| 3550 | - } | |
| 3551 | - if("1".equals(sfss) ? createDate.getTime() > jhmb.getFcsjT() : true){ | |
| 3552 | - jhLast++; | |
| 3553 | - for(int i = listsj1.size() - 1; i >= 0; i--){ | |
| 3554 | - ScheduleRealInfo sjmb = listsj1.get(i); //实际末班 | |
| 3555 | - String bcType = sjmb.getBcType(); | |
| 3556 | - if(bcType.equals("region") || bcType.equals("venting") | |
| 3557 | - || bcType.equals("major") || isInOut(bcType)){ | |
| 3558 | - continue; | |
| 3559 | - } | |
| 3560 | - long wd = sjmb.getFcsjActualTime() - jhmb.getFcsjT(); //误点,快1慢2 | |
| 3561 | - if(-1l * 1000 * 60 <= wd && wd <= 2l * 1000 * 60){ | |
| 3562 | - sjzdLast++; | |
| 3563 | - break; | |
| 3564 | - } | |
| 3565 | - } | |
| 3566 | - } | |
| 3567 | - } | |
| 3568 | - } | |
| 3569 | - | |
| 3570 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 3571 | - map.put("lineCode", lineCode); | |
| 3572 | - Map<String, Object> xx = lineXX.get(lineCode); | |
| 3573 | - map.put("lineName", xx!=null&&xx.get("lineName")!=null?xx.get("lineName"):""); | |
| 3574 | - map.put("gsBm", xx!=null&&xx.get("gsBm")!=null?xx.get("gsBm"):""); | |
| 3575 | - map.put("gsName", xx!=null&&xx.get("gsName")!=null?xx.get("gsName"):""); | |
| 3576 | - map.put("fgsBm", xx!=null&&xx.get("fgsBm")!=null?xx.get("fgsBm"):""); | |
| 3577 | - map.put("fgsName", xx!=null&&xx.get("fgsName")!=null?xx.get("fgsName"):""); | |
| 3578 | - map.put("planFirst", jhFirst); | |
| 3579 | - map.put("planLast", jhLast); | |
| 3580 | - map.put("realFirst", sjzdFirst); | |
| 3581 | - map.put("realLast", sjzdLast); | |
| 3582 | - int jhbc = jhFirst + jhLast; | |
| 3583 | - int sjzdbc = sjzdFirst + sjzdLast; | |
| 3584 | - if(jhbc > 0){ | |
| 3585 | - double zdl = (sjzdbc * 1.0) / (jhbc * 1.0) * 100; | |
| 3586 | - map.put("zdl", df.format(zdl)); | |
| 3587 | - } else { | |
| 3588 | - map.put("zdl", "0"); | |
| 3589 | - } | |
| 3590 | - if(jhFirst > 0){ | |
| 3591 | - double zdlFirst = (sjzdFirst * 1.0) / (jhFirst * 1.0) * 100; | |
| 3592 | - map.put("zdlFirst", df.format(zdlFirst)); | |
| 3593 | - } else { | |
| 3594 | - map.put("zdlFirst", "0"); | |
| 3595 | - } | |
| 3596 | - if(jhLast > 0){ | |
| 3597 | - double zdlLast = (sjzdLast * 1.0) / (jhLast * 1.0) * 100; | |
| 3598 | - map.put("zdlLast", df.format(zdlLast)); | |
| 3599 | - } else { | |
| 3600 | - map.put("zdlLast", "0"); | |
| 3601 | - } | |
| 3602 | - | |
| 3603 | - resList.add(map); | |
| 3604 | - | |
| 3605 | - } | |
| 3606 | - | |
| 3607 | - return resList; | |
| 3608 | - } | |
| 3609 | - | |
| 3610 | - /** 按日期查询出车的早未到情况 */ | |
| 3611 | - @GET | |
| 3612 | - @Path("/selectData/getNotYet/{date}") | |
| 3613 | - public Map<String, Object> getNotYet(@PathParam("date") String date){ | |
| 3614 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 3615 | - | |
| 3616 | - String yyxlSql="SELECT line_code from bsth_c_line " | |
| 3617 | - + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | |
| 3618 | - List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | |
| 3619 | - new RowMapper<Map<String, Object>>(){ | |
| 3620 | - @Override | |
| 3621 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 3622 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 3623 | - m.put("lineCode", rs.getString("line_code")); | |
| 3624 | - return m; | |
| 3625 | - } | |
| 3626 | - }); | |
| 3627 | - Set<String> yyLine = new HashSet<String>(); | |
| 3628 | - for(Map<String, Object> t : yyxlList){ | |
| 3629 | - if(t.get("lineCode") != null){ | |
| 3630 | - yyLine.add(t.get("lineCode").toString()); | |
| 3631 | - } | |
| 3632 | - } | |
| 3633 | - | |
| 3634 | - String sqlMinYysj="select line, start_opt from bsth_c_line_config where " | |
| 3635 | - + " id in (select max(id) from bsth_c_line_config group by line)"; | |
| 3636 | - List<Map<String, Object>> minfcsjList = jdbcTemplate.query(sqlMinYysj, | |
| 3637 | - new RowMapper<Map<String, Object>>(){ | |
| 3638 | - @Override | |
| 3639 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 3640 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 3641 | - map.put("line", rs.getString("line")!=null?rs.getString("line"):""); | |
| 3642 | - map.put("minfcsj", rs.getString("start_opt")!=null?rs.getString("start_opt"):"02:00"); | |
| 3643 | - return map; | |
| 3644 | - } | |
| 3645 | - }); | |
| 3646 | - | |
| 3647 | - Map<String, Object> minfcsjMap = new HashMap<String, Object>(); | |
| 3648 | - for(Map<String, Object> map : minfcsjList){ | |
| 3649 | - minfcsjMap.put(map.get("line").toString(), map.get("minfcsj").toString()); | |
| 3650 | - } | |
| 3651 | - | |
| 3652 | - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); | |
| 3653 | - String format = sdf.format(new Date()); | |
| 3654 | - | |
| 3655 | - List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date); | |
| 3656 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | |
| 3657 | - Map<String, ScheduleRealInfo> scheduleMap = new HashMap<String, ScheduleRealInfo>(); | |
| 3658 | - for(ScheduleRealInfo s : findAll){ | |
| 3659 | - if(!("77".equals(s.getGsBm())) && s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | |
| 3660 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 3661 | - if (cts != null && cts.size() > 0) { | |
| 3662 | - list_s.add(s); | |
| 3663 | - } else if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 3664 | - list_s.add(s); | |
| 3665 | - } else if(s.getStatus() != 0){ | |
| 3666 | - list_s.add(s); | |
| 3667 | - } | |
| 3668 | - } | |
| 3669 | - } | |
| 3670 | - | |
| 3671 | - for(ScheduleRealInfo s : list_s){ | |
| 3672 | - if(!isInOut(s) && !s.isCcService()){ | |
| 3673 | - String[] split = s.getFcsj().split(":"); | |
| 3674 | - Long time = Long.valueOf(split[0]) * 60 + Long.valueOf(split[1]); | |
| 3675 | - String minfcsj = minfcsjMap.get(s.getXlBm())!=null?minfcsjMap.get(s.getXlBm()).toString():"02:00"; | |
| 3676 | - String[] split_min = minfcsj.trim().split(":"); | |
| 3677 | - Long min = Long.valueOf(split_min[0]) * 60 + Long.valueOf(split_min[1]); | |
| 3678 | - if(time < min){ | |
| 3679 | - time += 1440; | |
| 3680 | - } | |
| 3681 | - s.setFcsjT(time); | |
| 3682 | - String cl = s.getClZbh(); | |
| 3683 | - if(scheduleMap.containsKey(cl)){ | |
| 3684 | - ScheduleRealInfo s2 = scheduleMap.get(cl); | |
| 3685 | - if(time < s2.getFcsjT()){ | |
| 3686 | - scheduleMap.put(cl, s); | |
| 3687 | - } | |
| 3688 | - } else { | |
| 3689 | - scheduleMap.put(cl, s); | |
| 3690 | - } | |
| 3691 | - } | |
| 3692 | - } | |
| 3693 | - | |
| 3694 | - List<ScheduleRealInfo> notYetList = new ArrayList<ScheduleRealInfo>(); | |
| 3695 | - | |
| 3696 | - long sum = scheduleMap.keySet().size(), zwd = 0;//早未到数 | |
| 3697 | - long yg_z = 0, sn_z = 0, jg_z = 0, nh_z = 0; | |
| 3698 | - long yg_zwd = 0, sn_zwd = 0, jg_zwd = 0, nh_zwd = 0; | |
| 3699 | - for(String key : scheduleMap.keySet()){ | |
| 3700 | - ScheduleRealInfo s = scheduleMap.get(key); | |
| 3701 | - if("05".equals(s.getGsBm())){ | |
| 3702 | - yg_z += 1; | |
| 3703 | - } else if("55".equals(s.getGsBm())){ | |
| 3704 | - sn_z += 1; | |
| 3705 | - } else if("22".equals(s.getGsBm())){ | |
| 3706 | - jg_z += 1; | |
| 3707 | - } else if("26".equals(s.getGsBm())){ | |
| 3708 | - nh_z += 1; | |
| 3709 | - } | |
| 3710 | - if("缺人".equals(s.getAdjustExps())){ | |
| 3711 | - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | |
| 3712 | - list.add(s); | |
| 3713 | - BigDecimal sjgl = new BigDecimal(culateSjgl(list)); | |
| 3714 | - BigDecimal ljgl = new BigDecimal(culateLjgl(list)); | |
| 3715 | - BigDecimal zero = new BigDecimal(0.0); | |
| 3716 | - if(sjgl.compareTo(zero) == 0 && ljgl.compareTo(zero) == 0){ | |
| 3717 | - zwd += 1; | |
| 3718 | - if("05".equals(s.getGsBm())){ | |
| 3719 | - yg_zwd += 1; | |
| 3720 | - } else if("55".equals(s.getGsBm())){ | |
| 3721 | - sn_zwd += 1; | |
| 3722 | - } else if("22".equals(s.getGsBm())){ | |
| 3723 | - jg_zwd += 1; | |
| 3724 | - } else if("26".equals(s.getGsBm())){ | |
| 3725 | - nh_zwd += 1; | |
| 3726 | - } | |
| 3727 | - notYetList.add(s); | |
| 3728 | - } | |
| 3729 | - } | |
| 3730 | - } | |
| 3731 | - | |
| 3732 | - resMap.put("sum", sum); | |
| 3733 | - resMap.put("notYet", zwd); | |
| 3734 | - resMap.put("sum_05", yg_z); | |
| 3735 | - resMap.put("notYet_05", yg_zwd); | |
| 3736 | - resMap.put("sum_55", sn_z); | |
| 3737 | - resMap.put("notYet_55", sn_zwd); | |
| 3738 | - resMap.put("sum_22", jg_z); | |
| 3739 | - resMap.put("notYet_22", jg_zwd); | |
| 3740 | - resMap.put("sum_26", nh_z); | |
| 3741 | - resMap.put("notYet_26", nh_zwd); | |
| 3742 | - resMap.put("notYetList", notYetList); | |
| 3743 | - return resMap; | |
| 3744 | - } | |
| 3745 | - | |
| 3746 | -// public static void main(String[] args){ | |
| 3747 | -// | |
| 3748 | -// } | |
| 3749 | - | |
| 3750 | - public List<Map<String, Object>> createMap(String type, String[] dates){ | |
| 3751 | - List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); | |
| 3752 | - | |
| 3753 | - for(int i = 0; i < dates.length; i++){ | |
| 3754 | - Map<String, Object> tempMap = new HashMap<String, Object>(); | |
| 3755 | - tempMap.put("type", type); | |
| 3756 | - String[] split = dates[i].split("-"); | |
| 3757 | - tempMap.put("date", split[1] + "/" + split[2]); | |
| 3758 | - tempMap.put("jh", "0"); | |
| 3759 | - tempMap.put("sj", "0"); | |
| 3760 | - mapList.add(tempMap); | |
| 3761 | - } | |
| 3762 | - | |
| 3763 | - return mapList; | |
| 3764 | - } | |
| 3765 | - | |
| 3766 | - public void mapPut(Map<String, Object> m, String key, Object value){ | |
| 3767 | - if(m.get(key) != null){ | |
| 3768 | - m.put(key, new BigDecimal(m.get(key).toString()).add(new BigDecimal(value.toString()))); | |
| 3769 | - } else { | |
| 3770 | - m.put(key, value); | |
| 3771 | - } | |
| 3772 | - } | |
| 3773 | - | |
| 3774 | - /**计划营运公里*/ | |
| 3775 | - public double culateJhgl(List<ScheduleRealInfo> lists) { | |
| 3776 | - // TODO Auto-generated method stub | |
| 3777 | - double jhgl=0; | |
| 3778 | - for (int i = 0; i < lists.size(); i++) { | |
| 3779 | - ScheduleRealInfo scheduleRealInfo=lists.get(i); | |
| 3780 | - if (!isInOut(scheduleRealInfo)) { | |
| 3781 | - if(!scheduleRealInfo.isSflj() && !scheduleRealInfo.isCcService()){ | |
| 3782 | - jhgl=Arith.add(jhgl,scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig()); | |
| 3783 | - } | |
| 3784 | - } | |
| 3785 | - } | |
| 3786 | - return jhgl; | |
| 3787 | - } | |
| 3788 | - | |
| 3789 | - /**实际营运公里(不包含临加)*/ | |
| 3790 | - public double culateSjgl(List<ScheduleRealInfo> lists) { | |
| 3791 | - // TODO Auto-generated method stub | |
| 3792 | - double sjgl=0; | |
| 3793 | - for (int i = 0; i < lists.size(); i++) { | |
| 3794 | - ScheduleRealInfo scheduleRealInfo=lists.get(i); | |
| 3795 | - if (!isInOut(scheduleRealInfo)) { | |
| 3796 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 3797 | - if(!scheduleRealInfo.isSflj()){ | |
| 3798 | - if(childTaskPlans.isEmpty()){ | |
| 3799 | - if(!(scheduleRealInfo.getStatus() == -1)){ | |
| 3800 | - double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig(); | |
| 3801 | - double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc(); | |
| 3802 | - if(jhlc-jhlcOrig>0){ | |
| 3803 | - sjgl=Arith.add(sjgl,jhlcOrig); | |
| 3804 | - }else{ | |
| 3805 | - sjgl=Arith.add(sjgl,jhlc); | |
| 3806 | - } | |
| 3807 | - } | |
| 3808 | - }else{ | |
| 3809 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 3810 | - while (it.hasNext()) { | |
| 3811 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 3812 | - if(childTaskPlan.getMileageType().equals("service") | |
| 3813 | - &&"正常".equals(childTaskPlan.getType1()) | |
| 3814 | - && childTaskPlan.getCcId()==null){ | |
| 3815 | - if (!childTaskPlan.isDestroy()) { | |
| 3816 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 3817 | - sjgl=Arith.add(sjgl,jhgl); | |
| 3818 | - } | |
| 3819 | - } | |
| 3820 | - } | |
| 3821 | - } | |
| 3822 | - } | |
| 3823 | - } | |
| 3824 | - } | |
| 3825 | - return sjgl; | |
| 3826 | - } | |
| 3827 | - | |
| 3828 | - /**临加公里*/ | |
| 3829 | - public double culateLjgl(List<ScheduleRealInfo> lists) { | |
| 3830 | - // TODO Auto-generated method stub | |
| 3831 | - double ljgl=0; | |
| 3832 | - for (int i = 0; i < lists.size(); i++) { | |
| 3833 | - ScheduleRealInfo scheduleRealInfo=lists.get(i); | |
| 3834 | - if (!isInOut(scheduleRealInfo)) { | |
| 3835 | - if(!(scheduleRealInfo.getStatus() == -1)){ | |
| 3836 | - if(scheduleRealInfo.isSflj()){ | |
| 3837 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 3838 | - if(childTaskPlans.isEmpty()){ | |
| 3839 | - ljgl=Arith.add(ljgl,scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 3840 | - }else{ | |
| 3841 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 3842 | - while (it.hasNext()) { | |
| 3843 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 3844 | - if(childTaskPlan.getMileageType().equals("service") | |
| 3845 | - && childTaskPlan.getCcId()==null){ | |
| 3846 | - if (!childTaskPlan.isDestroy()) { | |
| 3847 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 3848 | - ljgl=Arith.add(ljgl,jhgl); | |
| 3849 | - } | |
| 3850 | - } | |
| 3851 | - } | |
| 3852 | - } | |
| 3853 | - }else{ | |
| 3854 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 3855 | - if(childTaskPlans.isEmpty()){ | |
| 3856 | - double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc(); | |
| 3857 | - double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig(); | |
| 3858 | - double zjlc=Arith.sub(jhlc, jhlcOrig); | |
| 3859 | - if(zjlc>0){ | |
| 3860 | - ljgl=Arith.add(zjlc, ljgl); | |
| 3861 | - } | |
| 3862 | - }else{ | |
| 3863 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 3864 | - while (it.hasNext()) { | |
| 3865 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 3866 | - if("service".equals(childTaskPlan.getMileageType()) | |
| 3867 | - && "临加".equals(childTaskPlan.getType1()) | |
| 3868 | - && childTaskPlan.getCcId()==null){ | |
| 3869 | - if (!childTaskPlan.isDestroy()) { | |
| 3870 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 3871 | - ljgl=Arith.add(ljgl,jhgl); | |
| 3872 | - } | |
| 3873 | - } | |
| 3874 | - } | |
| 3875 | - } | |
| 3876 | - } | |
| 3877 | - } | |
| 3878 | - } | |
| 3879 | - } | |
| 3880 | - return ljgl; | |
| 3881 | - } | |
| 3882 | - | |
| 3883 | - /**烂班(少驶)公里*/ | |
| 3884 | - public double culateCJLC(List<ScheduleRealInfo> list, String item) { | |
| 3885 | - // TODO Auto-generated method stub | |
| 3886 | - double sum = 0; | |
| 3887 | - Set<ChildTaskPlan> cts; | |
| 3888 | - for(ScheduleRealInfo sch : list){ | |
| 3889 | - if (sch.isSflj()) | |
| 3890 | - continue; | |
| 3891 | - cts = sch.getcTasks(); | |
| 3892 | - if(isInOut(sch)) | |
| 3893 | - continue; | |
| 3894 | - //有子任务 | |
| 3895 | - if (cts != null && cts.size() > 0) { | |
| 3896 | - for(ChildTaskPlan c : cts){ | |
| 3897 | - if(c.getCcId()==null){ | |
| 3898 | - if(c.getMileageType().equals("service")){ | |
| 3899 | - if(item.equals("其他")){ | |
| 3900 | - if(c.isDestroy() && | |
| 3901 | - ((c.getDestroyReason()==null?"": c.getDestroyReason()).equals(item)|| | |
| 3902 | - (c.getDestroyReason()==null?"": c.getDestroyReason()).equals(""))) | |
| 3903 | - sum = Arith.add(sum, c.getMileage()); | |
| 3904 | - }else{ | |
| 3905 | - if(c.isDestroy() && (c.getDestroyReason()==null?"": c.getDestroyReason()).equals(item)) | |
| 3906 | - sum = Arith.add(sum, c.getMileage()); | |
| 3907 | - } | |
| 3908 | - } | |
| 3909 | - } | |
| 3910 | - } | |
| 3911 | - } | |
| 3912 | - | |
| 3913 | - //主任务烂班 | |
| 3914 | - else if(sch.getStatus() == -1 && !sch.isCcService()){ | |
| 3915 | - if(sch.getAdjustExps().equals(item) || | |
| 3916 | - (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))){ | |
| 3917 | - sum = Arith.add(sum, sch.getJhlcOrig()); | |
| 3918 | - } | |
| 3919 | - } | |
| 3920 | - else if(item.equals("其他")){ | |
| 3921 | - double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc()); | |
| 3922 | - if(diff > 0){ | |
| 3923 | - sum = Arith.add(sum, diff); | |
| 3924 | - } | |
| 3925 | - } | |
| 3926 | - } | |
| 3927 | - return sum; | |
| 3928 | - } | |
| 3929 | - | |
| 3930 | - /**计划空驶公里*/ | |
| 3931 | - public double culateJhJccgl(List<ScheduleRealInfo> lists) { | |
| 3932 | - // TODO Auto-generated method stub | |
| 3933 | - double jcclc =0; | |
| 3934 | - for (int i = 0; i < lists.size(); i++) { | |
| 3935 | - ScheduleRealInfo scheduleRealInfo=lists.get(i); | |
| 3936 | - if(!scheduleRealInfo.isSflj() && !scheduleRealInfo.isCcService()){ | |
| 3937 | - if (isInOut(scheduleRealInfo)) { | |
| 3938 | - jcclc =Arith.add(jcclc, scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig()); | |
| 3939 | - } | |
| 3940 | - } | |
| 3941 | - } | |
| 3942 | - return jcclc; | |
| 3943 | - } | |
| 3944 | - | |
| 3945 | - /**实际进出场空驶*/ | |
| 3946 | - public double culateJccgl(List<ScheduleRealInfo> lists) { | |
| 3947 | - // TODO Auto-generated method stub | |
| 3948 | - double jcclc =0; | |
| 3949 | - for (int i = 0; i < lists.size(); i++) { | |
| 3950 | - ScheduleRealInfo scheduleRealInfo=lists.get(i); | |
| 3951 | - if (isInOut(scheduleRealInfo)) { | |
| 3952 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 3953 | - if(childTaskPlans.isEmpty()){ | |
| 3954 | - if(!(scheduleRealInfo.getStatus() == -1)){ | |
| 3955 | - jcclc =Arith.add(jcclc, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 3956 | - } | |
| 3957 | - }else{ | |
| 3958 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 3959 | - while (it.hasNext()) { | |
| 3960 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 3961 | - if(childTaskPlan.getMileageType().equals("empty") | |
| 3962 | - && childTaskPlan.getCcId()==null){ | |
| 3963 | - if (!childTaskPlan.isDestroy()) { | |
| 3964 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 3965 | - jcclc=Arith.add(jcclc,jhgl); | |
| 3966 | - } | |
| 3967 | - } | |
| 3968 | - } | |
| 3969 | - } | |
| 3970 | - } | |
| 3971 | - } | |
| 3972 | - return jcclc; | |
| 3973 | - } | |
| 3974 | - | |
| 3975 | - /**实际非进出场空驶公里*/ | |
| 3976 | - public double culateKsgl(List<ScheduleRealInfo> lists) { | |
| 3977 | - // TODO Auto-generated method stub | |
| 3978 | - double ksgl =0; | |
| 3979 | - for (int i = 0; i < lists.size(); i++) { | |
| 3980 | - ScheduleRealInfo scheduleRealInfo=lists.get(i); | |
| 3981 | - if (!isInOut(scheduleRealInfo)) { | |
| 3982 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 3983 | - if(!childTaskPlans.isEmpty()){ | |
| 3984 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 3985 | - while (it.hasNext()) { | |
| 3986 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 3987 | - if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 3988 | - if (!childTaskPlan.isDestroy()) { | |
| 3989 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 3990 | - ksgl=Arith.add(ksgl,jhgl); | |
| 3991 | - } | |
| 3992 | - } | |
| 3993 | - } | |
| 3994 | - } | |
| 3995 | - } | |
| 3996 | - } | |
| 3997 | - return ksgl; | |
| 3998 | - } | |
| 3999 | - | |
| 4000 | - class ComparableJhfc implements Comparator<ScheduleRealInfo>{ | |
| 4001 | - | |
| 4002 | - @Override | |
| 4003 | - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | |
| 4004 | - // TODO Auto-generated method stub | |
| 4005 | - return o1.getFcsjT().compareTo(o2.getFcsjT()); | |
| 4006 | - } | |
| 4007 | - } | |
| 4008 | - class ComparableAcual implements Comparator<ScheduleRealInfo>{ | |
| 4009 | - | |
| 4010 | - @Override | |
| 4011 | - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | |
| 4012 | - // TODO Auto-generated method stub | |
| 4013 | - return o1.getFcsjActualTime().compareTo(o2.getFcsjActualTime()); | |
| 4014 | - } | |
| 4015 | - } | |
| 4016 | - | |
| 4017 | - public static String decimalToBinary(int n) { | |
| 4018 | - String str = ""; | |
| 4019 | - if(n == 0){ | |
| 4020 | - return str = "0"; | |
| 4021 | - } | |
| 4022 | - while (n != 0) { | |
| 4023 | - str = n % 2 + str; | |
| 4024 | - n = n / 2; | |
| 4025 | - } | |
| 4026 | - return str; | |
| 4027 | - } | |
| 4028 | - | |
| 4029 | -} |
src/main/java/com/bsth/server_rs/bigdata/GetHttpInterface.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.bigdata; | |
| 2 | - | |
| 3 | -import java.io.BufferedReader; | |
| 4 | -import java.io.InputStreamReader; | |
| 5 | -import java.net.HttpURLConnection; | |
| 6 | -import java.net.URL; | |
| 7 | -import java.net.URLDecoder; | |
| 8 | -import java.security.MessageDigest; | |
| 9 | -import java.security.NoSuchAlgorithmException; | |
| 10 | -import java.util.Date; | |
| 11 | -import java.util.List; | |
| 12 | -import java.util.Map; | |
| 13 | - | |
| 14 | -import com.alibaba.fastjson.JSONObject; | |
| 15 | - | |
| 16 | -public class GetHttpInterface { | |
| 17 | - // 调用http接口获取数据 | |
| 18 | - public static String getHttpInterface(String path){ | |
| 19 | - System.out.println("调用开始"); | |
| 20 | - BufferedReader in = null; | |
| 21 | - StringBuffer result = null; | |
| 22 | - try { | |
| 23 | - URL url = new URL(path); | |
| 24 | - //打开和url之间的连接 | |
| 25 | - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | |
| 26 | - connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); | |
| 27 | - connection.setRequestProperty("Charset", "utf-8"); | |
| 28 | - connection.connect(); | |
| 29 | - | |
| 30 | - result = new StringBuffer(); | |
| 31 | - //读取URL的响应 | |
| 32 | - in = new BufferedReader(new InputStreamReader( | |
| 33 | - connection.getInputStream())); | |
| 34 | - String line; | |
| 35 | - while ((line = in.readLine()) != null) { | |
| 36 | - | |
| 37 | - result.append(line); | |
| 38 | - } | |
| 39 | - // System.out.println(result.toString()); | |
| 40 | - return result.toString(); | |
| 41 | - } catch (Exception e) { | |
| 42 | - e.printStackTrace(); | |
| 43 | - }finally { | |
| 44 | - try { | |
| 45 | - if (in != null) { | |
| 46 | - in.close(); | |
| 47 | - } | |
| 48 | - } catch (Exception e2) { | |
| 49 | - e2.printStackTrace(); | |
| 50 | - } | |
| 51 | - } | |
| 52 | - return null; | |
| 53 | - } | |
| 54 | - | |
| 55 | -} |
src/main/java/com/bsth/server_rs/dks/BusMileage.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.dks; | |
| 2 | - | |
| 3 | -public class BusMileage { | |
| 4 | - | |
| 5 | - /** | |
| 6 | - * | |
| 7 | - */ | |
| 8 | - private String scheduleDate; | |
| 9 | - | |
| 10 | - /** | |
| 11 | - * 内部编码 | |
| 12 | - */ | |
| 13 | - private String nbbm; | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * 计划里程 | |
| 17 | - */ | |
| 18 | - private Double jhlc; | |
| 19 | - | |
| 20 | - /** | |
| 21 | - * 实际计划里程 | |
| 22 | - */ | |
| 23 | - private Double sjjhlc; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * 实际出场里程 | |
| 27 | - */ | |
| 28 | - private Double sjcclc; | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * 实际进场里程 | |
| 32 | - */ | |
| 33 | - private Double sjjclc; | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * 营运里程 | |
| 37 | - */ | |
| 38 | - private Double yylc; | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * 空驶里程 | |
| 42 | - */ | |
| 43 | - private Double kslc; | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * 抽减里程 | |
| 47 | - */ | |
| 48 | - private Double cjlc; | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * 烂班里程 | |
| 52 | - */ | |
| 53 | - private Double lblc; | |
| 54 | - | |
| 55 | - /** | |
| 56 | - * 增加里程 | |
| 57 | - */ | |
| 58 | - private Double zjlc; | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * 总里程 | |
| 62 | - */ | |
| 63 | - private Double zlc; | |
| 64 | - | |
| 65 | - /** | |
| 66 | - * 油耗 | |
| 67 | - */ | |
| 68 | - private Double yh; | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * 电耗 | |
| 72 | - */ | |
| 73 | - private Double dh; | |
| 74 | - | |
| 75 | - private String company; | |
| 76 | - | |
| 77 | - private String companyCode; | |
| 78 | - | |
| 79 | - public String getScheduleDate() { | |
| 80 | - return scheduleDate; | |
| 81 | - } | |
| 82 | - | |
| 83 | - public void setScheduleDate(String scheduleDate) { | |
| 84 | - this.scheduleDate = scheduleDate; | |
| 85 | - } | |
| 86 | - | |
| 87 | - public String getNbbm() { | |
| 88 | - return nbbm; | |
| 89 | - } | |
| 90 | - | |
| 91 | - public void setNbbm(String nbbm) { | |
| 92 | - this.nbbm = nbbm; | |
| 93 | - } | |
| 94 | - | |
| 95 | - public Double getJhlc() { | |
| 96 | - return jhlc; | |
| 97 | - } | |
| 98 | - | |
| 99 | - public void setJhlc(Double jhlc) { | |
| 100 | - this.jhlc = jhlc; | |
| 101 | - } | |
| 102 | - | |
| 103 | - public Double getSjjhlc() { | |
| 104 | - return sjjhlc; | |
| 105 | - } | |
| 106 | - | |
| 107 | - public void setSjjhlc(Double sjjhlc) { | |
| 108 | - this.sjjhlc = sjjhlc; | |
| 109 | - } | |
| 110 | - | |
| 111 | - public Double getSjcclc() { | |
| 112 | - return sjcclc; | |
| 113 | - } | |
| 114 | - | |
| 115 | - public void setSjcclc(Double sjcclc) { | |
| 116 | - this.sjcclc = sjcclc; | |
| 117 | - } | |
| 118 | - | |
| 119 | - public Double getSjjclc() { | |
| 120 | - return sjjclc; | |
| 121 | - } | |
| 122 | - | |
| 123 | - public void setSjjclc(Double sjjclc) { | |
| 124 | - this.sjjclc = sjjclc; | |
| 125 | - } | |
| 126 | - | |
| 127 | - public Double getYylc() { | |
| 128 | - return yylc; | |
| 129 | - } | |
| 130 | - | |
| 131 | - public void setYylc(Double yylc) { | |
| 132 | - this.yylc = yylc; | |
| 133 | - } | |
| 134 | - | |
| 135 | - public Double getKslc() { | |
| 136 | - return kslc; | |
| 137 | - } | |
| 138 | - | |
| 139 | - public void setKslc(Double kslc) { | |
| 140 | - this.kslc = kslc; | |
| 141 | - } | |
| 142 | - | |
| 143 | - public Double getCjlc() { | |
| 144 | - return cjlc; | |
| 145 | - } | |
| 146 | - | |
| 147 | - public void setCjlc(Double cjlc) { | |
| 148 | - this.cjlc = cjlc; | |
| 149 | - } | |
| 150 | - | |
| 151 | - public Double getLblc() { | |
| 152 | - return lblc; | |
| 153 | - } | |
| 154 | - | |
| 155 | - public void setLblc(Double lblc) { | |
| 156 | - this.lblc = lblc; | |
| 157 | - } | |
| 158 | - | |
| 159 | - public Double getZjlc() { | |
| 160 | - return zjlc; | |
| 161 | - } | |
| 162 | - | |
| 163 | - public void setZjlc(Double zjlc) { | |
| 164 | - this.zjlc = zjlc; | |
| 165 | - } | |
| 166 | - | |
| 167 | - public Double getZlc() { | |
| 168 | - return zlc; | |
| 169 | - } | |
| 170 | - | |
| 171 | - public void setZlc(Double zlc) { | |
| 172 | - this.zlc = zlc; | |
| 173 | - } | |
| 174 | - | |
| 175 | - public Double getYh() { | |
| 176 | - return yh; | |
| 177 | - } | |
| 178 | - | |
| 179 | - public void setYh(Double yh) { | |
| 180 | - this.yh = yh; | |
| 181 | - } | |
| 182 | - | |
| 183 | - public Double getDh() { | |
| 184 | - return dh; | |
| 185 | - } | |
| 186 | - | |
| 187 | - public void setDh(Double dh) { | |
| 188 | - this.dh = dh; | |
| 189 | - } | |
| 190 | - | |
| 191 | - public String getCompany() { | |
| 192 | - return company; | |
| 193 | - } | |
| 194 | - | |
| 195 | - public void setCompany(String company) { | |
| 196 | - this.company = company; | |
| 197 | - } | |
| 198 | - | |
| 199 | - public String getCompanyCode() { | |
| 200 | - return companyCode; | |
| 201 | - } | |
| 202 | - | |
| 203 | - public void setCompanyCode(String companyCode) { | |
| 204 | - this.companyCode = companyCode; | |
| 205 | - } | |
| 206 | -} |
src/main/java/com/bsth/server_rs/dks/DksRestService.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.dks; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.bsth.common.BusinessCodeData; | |
| 5 | -import com.bsth.entity.ElecInfo; | |
| 6 | -import com.bsth.entity.OilInfo; | |
| 7 | -import com.bsth.entity.SchedulePlanInfo; | |
| 8 | -import com.bsth.entity.ScheduleRealInfo; | |
| 9 | -import com.bsth.redis.ElecRedisService; | |
| 10 | -import com.bsth.redis.OilRedisService; | |
| 11 | -import com.bsth.redis.ScheduleRedisService; | |
| 12 | -import com.bsth.repository.SchedulePlanInfoRepository; | |
| 13 | -import com.bsth.repository.ScheduleRealInfoRepository; | |
| 14 | -import com.bsth.server_rs.base_info.line.Line; | |
| 15 | -import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | |
| 16 | -import com.bsth.server_ws.util.ScheduleCalculator; | |
| 17 | -import com.bsth.util.Arith; | |
| 18 | -import com.google.common.collect.ArrayListMultimap; | |
| 19 | -import org.joda.time.DateTime; | |
| 20 | -import org.joda.time.format.DateTimeFormat; | |
| 21 | -import org.slf4j.Logger; | |
| 22 | -import org.slf4j.LoggerFactory; | |
| 23 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 24 | -import org.springframework.jdbc.core.BatchPreparedStatementSetter; | |
| 25 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 26 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 27 | -import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 28 | -import org.springframework.scheduling.annotation.EnableScheduling; | |
| 29 | -import org.springframework.scheduling.annotation.Scheduled; | |
| 30 | -import org.springframework.stereotype.Component; | |
| 31 | -import org.springframework.transaction.TransactionDefinition; | |
| 32 | -import org.springframework.transaction.TransactionStatus; | |
| 33 | -import org.springframework.transaction.support.DefaultTransactionDefinition; | |
| 34 | -import org.springframework.util.StringUtils; | |
| 35 | - | |
| 36 | -import javax.ws.rs.*; | |
| 37 | -import javax.ws.rs.core.MediaType; | |
| 38 | -import java.sql.PreparedStatement; | |
| 39 | -import java.sql.SQLException; | |
| 40 | -import java.util.*; | |
| 41 | - | |
| 42 | -/** | |
| 43 | - * @author Hill | |
| 44 | - * @date 2021-09 | |
| 45 | - */ | |
| 46 | -@Component | |
| 47 | -@EnableScheduling | |
| 48 | -@Path("/dks") | |
| 49 | -@Produces({MediaType.APPLICATION_JSON}) | |
| 50 | -public class DksRestService { | |
| 51 | - | |
| 52 | - private final static Logger log = LoggerFactory.getLogger(DksRestService.class); | |
| 53 | - | |
| 54 | - @Autowired | |
| 55 | - private JdbcTemplate jdbcTemplate; | |
| 56 | - | |
| 57 | - @Autowired | |
| 58 | - private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 59 | - | |
| 60 | - @Autowired | |
| 61 | - private SchedulePlanInfoRepository schedulePlanInfoRepository; | |
| 62 | - | |
| 63 | - @Autowired | |
| 64 | - private ScheduleRedisService scheduleRedisService; | |
| 65 | - | |
| 66 | - @Autowired | |
| 67 | - private OilRedisService oilRedisService; | |
| 68 | - | |
| 69 | - @Autowired | |
| 70 | - private ElecRedisService elecRedisService; | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * 根据日期统计数据重新计算 | |
| 74 | - * @param rq | |
| 75 | - */ | |
| 76 | - @GET | |
| 77 | - @Path("/reCompute/{rq}") | |
| 78 | - public void reStatisticalComputation(@PathParam("rq") String rq) { | |
| 79 | - DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(rq); | |
| 80 | - planComputation(dateTime); | |
| 81 | - realComputation(dateTime); | |
| 82 | - carMileageComputation(dateTime); | |
| 83 | - } | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * | |
| 87 | - */ | |
| 88 | - private List<LineServiceConfigVo> reGroup(List<LineServiceConfig> configs, String month) { | |
| 89 | - List<LineServiceConfigVo> result = new ArrayList<>(); | |
| 90 | - String oldLineCode = ""; | |
| 91 | - LineServiceConfigVo vo = null; | |
| 92 | - for (int i = 0, len = configs.size();i < len;i++) { | |
| 93 | - LineServiceConfig config = configs.get(i); | |
| 94 | - if (i == 0) { | |
| 95 | - oldLineCode = config.getLineCode(); | |
| 96 | - vo = new LineServiceConfigVo(); | |
| 97 | - vo.setLineName(config.getLineName()); | |
| 98 | - vo.setMonth(month); | |
| 99 | - vo.setConductorFirstCount(config.getConductorCount()); | |
| 100 | - vo.setDriverFirstCount(config.getDriverCount()); | |
| 101 | - } else if (i == len - 1) { | |
| 102 | - result.add(vo); | |
| 103 | - } else { | |
| 104 | - if (!oldLineCode.equals(config.getLineCode())) { | |
| 105 | - oldLineCode = config.getLineCode(); | |
| 106 | - result.add(vo); | |
| 107 | - vo = new LineServiceConfigVo(); | |
| 108 | - vo.setLineName(config.getLineName()); | |
| 109 | - vo.setMonth(month); | |
| 110 | - vo.setConductorFirstCount(config.getConductorCount()); | |
| 111 | - vo.setDriverFirstCount(config.getDriverCount()); | |
| 112 | - } | |
| 113 | - } | |
| 114 | - vo.setConductorLastCount(config.getConductorCount()); | |
| 115 | - vo.setDriverLastCount(config.getDriverCount()); | |
| 116 | - } | |
| 117 | - | |
| 118 | - return result; | |
| 119 | - } | |
| 120 | - | |
| 121 | - /** | |
| 122 | - * 计划司售配档数 | |
| 123 | - * @param month | |
| 124 | - */ | |
| 125 | - @GET | |
| 126 | - @Path("/plan/{month}") | |
| 127 | - public List<LineServiceConfigVo> plan(@PathParam("month") String month) { | |
| 128 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 129 | - return reGroup(configs, month); | |
| 130 | - } | |
| 131 | - | |
| 132 | - /** | |
| 133 | - * 实际司售配档数 | |
| 134 | - * @param month | |
| 135 | - */ | |
| 136 | - @GET | |
| 137 | - @Path("/actual/{month}") | |
| 138 | - public List<LineServiceConfigVo> actual(@PathParam("month") String month) { | |
| 139 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 140 | - return reGroup(configs, month); | |
| 141 | - } | |
| 142 | - | |
| 143 | - /** | |
| 144 | - * 计划配车数 | |
| 145 | - * @param month | |
| 146 | - */ | |
| 147 | - @GET | |
| 148 | - @Path("/bus/plan/{month}") | |
| 149 | - public List<BusVo> busPlan(@PathParam("month") String month) { | |
| 150 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 151 | - List<BusVo> result = new ArrayList<>(); | |
| 152 | - String oldLineCode = ""; | |
| 153 | - BusVo vo = null; | |
| 154 | - int max = 0; | |
| 155 | - for (int i = 0, len = configs.size();i < len;i++) { | |
| 156 | - LineServiceConfig config = configs.get(i); | |
| 157 | - if (i == 0) { | |
| 158 | - oldLineCode = config.getLineCode(); | |
| 159 | - vo = new BusVo(); | |
| 160 | - vo.setLineName(config.getLineName()); | |
| 161 | - vo.setMonth(month); | |
| 162 | - vo.setBusFirstCount(config.getCarCount()); | |
| 163 | - } else if (!oldLineCode.equals(config.getLineCode())) { | |
| 164 | - oldLineCode = config.getLineCode(); | |
| 165 | - vo.setBusMaxCount(max); | |
| 166 | - result.add(vo); | |
| 167 | - max = 0; | |
| 168 | - vo = new BusVo(); | |
| 169 | - vo.setLineName(config.getLineName()); | |
| 170 | - vo.setMonth(month); | |
| 171 | - vo.setBusFirstCount(config.getCarCount()); | |
| 172 | - } | |
| 173 | - max = Math.max(max, config.getCarCount()); | |
| 174 | - if (i == len - 1) { | |
| 175 | - vo.setBusMaxCount(max); | |
| 176 | - result.add(vo); | |
| 177 | - } | |
| 178 | - vo.setBusLastCount(config.getCarCount()); | |
| 179 | - } | |
| 180 | - | |
| 181 | - return result; | |
| 182 | - } | |
| 183 | - | |
| 184 | - /** | |
| 185 | - * 实际配车数 | |
| 186 | - * @param month | |
| 187 | - */ | |
| 188 | - @GET | |
| 189 | - @Path("/bus/{month}") | |
| 190 | - public List<BusVo> bus(@PathParam("month") String month) { | |
| 191 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 192 | - List<BusVo> result = new ArrayList<>(); | |
| 193 | - String oldLineCode = ""; | |
| 194 | - BusVo vo = null; | |
| 195 | - int max = 0; | |
| 196 | - for (int i = 0, len = configs.size();i < len;i++) { | |
| 197 | - LineServiceConfig config = configs.get(i); | |
| 198 | - if (i == 0) { | |
| 199 | - oldLineCode = config.getLineCode(); | |
| 200 | - vo = new BusVo(); | |
| 201 | - vo.setLineName(config.getLineName()); | |
| 202 | - vo.setMonth(month); | |
| 203 | - vo.setBusFirstCount(config.getCarCount()); | |
| 204 | - } else if (!oldLineCode.equals(config.getLineCode())) { | |
| 205 | - oldLineCode = config.getLineCode(); | |
| 206 | - vo.setBusMaxCount(max); | |
| 207 | - result.add(vo); | |
| 208 | - max = 0; | |
| 209 | - vo = new BusVo(); | |
| 210 | - vo.setLineName(config.getLineName()); | |
| 211 | - vo.setMonth(month); | |
| 212 | - vo.setBusFirstCount(config.getCarCount()); | |
| 213 | - } | |
| 214 | - max = Math.max(max, config.getCarCount()); | |
| 215 | - if (i == len - 1) { | |
| 216 | - vo.setBusMaxCount(max); | |
| 217 | - result.add(vo); | |
| 218 | - } | |
| 219 | - vo.setBusLastCount(config.getCarCount()); | |
| 220 | - } | |
| 221 | - | |
| 222 | - return result; | |
| 223 | - } | |
| 224 | - | |
| 225 | - /** | |
| 226 | - * 车辆公里、油耗数据 | |
| 227 | - * @param month | |
| 228 | - */ | |
| 229 | - @GET | |
| 230 | - @Path("/mileage/{month}") | |
| 231 | - public List<BusMileageVo> mileage(@PathParam("month") String month) { | |
| 232 | - List<BusMileage> mileages = jdbcTemplate.query("select company, company_code, nbbm, schedule_month schedule_date, sum(zlc) zlc, sum(yh) yh, sum(dh) dh from control_interface.bsth_t_mileage where schedule_month = ? group by company, company_code, nbbm, schedule_month", new Object[]{ month }, BeanPropertyRowMapper.newInstance(BusMileage.class)); | |
| 233 | - List<BusMileageVo> result = new ArrayList<>(); | |
| 234 | - for (BusMileage mileage : mileages) { | |
| 235 | - BusMileageVo vo = new BusMileageVo(); | |
| 236 | - vo.setMonth(mileage.getScheduleDate()); | |
| 237 | - vo.setInsideCode(mileage.getNbbm()); | |
| 238 | - vo.setTotalMileage(mileage.getZlc()); | |
| 239 | - vo.setOilConsume(mileage.getYh()); | |
| 240 | - vo.setElectricConsume(mileage.getDh()); | |
| 241 | - vo.setCompany(mileage.getCompany()); | |
| 242 | - vo.setCompanyCode(mileage.getCompanyCode()); | |
| 243 | - | |
| 244 | - result.add(vo); | |
| 245 | - } | |
| 246 | - | |
| 247 | - return result; | |
| 248 | - } | |
| 249 | - | |
| 250 | - @Scheduled(cron = "0 0/25 23 * * ?") | |
| 251 | - public void statisticalComputation() { | |
| 252 | - log.info("执行电科所接口数据统计计算"); | |
| 253 | - DateTime dateTime = DateTime.now().plusDays(1); | |
| 254 | - try { | |
| 255 | - for (int i = 0;i < 3;i++) { | |
| 256 | - dateTime = dateTime.minusDays(1); | |
| 257 | - planComputation(dateTime); | |
| 258 | - realComputation(dateTime); | |
| 259 | - carMileageComputation(dateTime); | |
| 260 | - } | |
| 261 | - } catch (Exception e) { | |
| 262 | - e.printStackTrace(); | |
| 263 | - } | |
| 264 | - } | |
| 265 | - | |
| 266 | - /** | |
| 267 | - * 计划排班中的线路司售配档数 | |
| 268 | - */ | |
| 269 | - private void planComputation(DateTime dateTime) { | |
| 270 | - // 记录实际线路司售配档情况 | |
| 271 | - List<SchedulePlanInfo> schedulePlanInfos = schedulePlanInfoRepository.findByDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(dateTime.toString("yyyy-MM-dd")).toDate()); | |
| 272 | - Set<String> lineCodes = new HashSet<>(); | |
| 273 | - Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>(); | |
| 274 | - final List<LineServiceConfig> objects = new ArrayList<>(); | |
| 275 | - for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) { | |
| 276 | - String lineCode = schedulePlanInfo.getXlBm(); | |
| 277 | - lineCodes.add(lineCode); | |
| 278 | - Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode); | |
| 279 | - if (conductors == null) { | |
| 280 | - conductors = new HashSet<>(); | |
| 281 | - line2conductors.put(lineCode, conductors); | |
| 282 | - } | |
| 283 | - if (drivers == null) { | |
| 284 | - drivers = new HashSet<>(); | |
| 285 | - line2drivers.put(lineCode, drivers); | |
| 286 | - } | |
| 287 | - if (cars == null) { | |
| 288 | - cars = new HashSet<>(); | |
| 289 | - line2cars.put(lineCode, cars); | |
| 290 | - } | |
| 291 | - if (!StringUtils.isEmpty(schedulePlanInfo.getsGh())) { | |
| 292 | - conductors.add(schedulePlanInfo.getsGh()); | |
| 293 | - } | |
| 294 | - drivers.add(schedulePlanInfo.getjGh()); | |
| 295 | - cars.add(schedulePlanInfo.getClZbh()); | |
| 296 | - } | |
| 297 | - for (String lineCode : lineCodes) { | |
| 298 | - LineServiceConfig object = new LineServiceConfig(); | |
| 299 | - Line line = LineBufferData.findOne(lineCode); | |
| 300 | - object.setLineCode(lineCode); | |
| 301 | - object.setLineName(line == null ? "" : line.getName()); | |
| 302 | - object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); | |
| 303 | - object.setConductorCount(line2conductors.get(lineCode).size()); | |
| 304 | - object.setDriverCount(line2drivers.get(lineCode).size()); | |
| 305 | - object.setCarCount(line2cars.get(lineCode).size()); | |
| 306 | - | |
| 307 | - objects.add(object); | |
| 308 | - } | |
| 309 | - | |
| 310 | - //编程式事务 | |
| 311 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 312 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 313 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 314 | - TransactionStatus status = tran.getTransaction(def); | |
| 315 | - | |
| 316 | - try { | |
| 317 | - jdbcTemplate.update("delete from control_interface.bsth_t_plan where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 318 | - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_plan (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 319 | - @Override | |
| 320 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 321 | - LineServiceConfig object = objects.get(i); | |
| 322 | - ps.setString(1, object.getLineCode()); | |
| 323 | - ps.setString(2, object.getLineName()); | |
| 324 | - ps.setString(3, object.getScheduleDate()); | |
| 325 | - ps.setInt(4, object.getConductorCount()); | |
| 326 | - ps.setInt(5, object.getDriverCount()); | |
| 327 | - ps.setInt(6, object.getCarCount()); | |
| 328 | - } | |
| 329 | - | |
| 330 | - @Override | |
| 331 | - public int getBatchSize() { | |
| 332 | - return objects.size(); | |
| 333 | - } | |
| 334 | - }); | |
| 335 | - tran.commit(status); | |
| 336 | - } catch (Exception e) { | |
| 337 | - tran.rollback(status); | |
| 338 | - } | |
| 339 | - } | |
| 340 | - | |
| 341 | - /** | |
| 342 | - * 实际排班中的线路司售配档数 | |
| 343 | - */ | |
| 344 | - private void realComputation(DateTime dateTime) { | |
| 345 | - // 记录实际线路司售配档情况 | |
| 346 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.findAll(dateTime.toString("yyyy-MM-dd")); | |
| 347 | - Set<String> lineCodes = new HashSet<>(); | |
| 348 | - Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>(); | |
| 349 | - final List<LineServiceConfig> objects = new ArrayList<>(); | |
| 350 | - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | |
| 351 | - // 烂班班次不计入配档数 | |
| 352 | - if (scheduleRealInfo.getStatus() == -1) { continue; } | |
| 353 | - String lineCode = scheduleRealInfo.getXlBm(); | |
| 354 | - lineCodes.add(lineCode); | |
| 355 | - Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode); | |
| 356 | - if (conductors == null) { | |
| 357 | - conductors = new HashSet<>(); | |
| 358 | - line2conductors.put(lineCode, conductors); | |
| 359 | - } | |
| 360 | - if (drivers == null) { | |
| 361 | - drivers = new HashSet<>(); | |
| 362 | - line2drivers.put(lineCode, drivers); | |
| 363 | - } | |
| 364 | - if (cars == null) { | |
| 365 | - cars = new HashSet<>(); | |
| 366 | - line2cars.put(lineCode, cars); | |
| 367 | - } | |
| 368 | - if (!StringUtils.isEmpty(scheduleRealInfo.getsGh())) { | |
| 369 | - conductors.add(scheduleRealInfo.getsGh()); | |
| 370 | - } | |
| 371 | - drivers.add(scheduleRealInfo.getjGh()); | |
| 372 | - cars.add(scheduleRealInfo.getClZbh()); | |
| 373 | - } | |
| 374 | - for (String lineCode : lineCodes) { | |
| 375 | - LineServiceConfig object = new LineServiceConfig(); | |
| 376 | - Line line = LineBufferData.findOne(lineCode); | |
| 377 | - object.setLineCode(lineCode); | |
| 378 | - object.setLineName(line == null ? "" : line.getName()); | |
| 379 | - object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); | |
| 380 | - object.setConductorCount(line2conductors.get(lineCode).size()); | |
| 381 | - object.setDriverCount(line2drivers.get(lineCode).size()); | |
| 382 | - object.setCarCount(line2cars.get(lineCode).size()); | |
| 383 | - | |
| 384 | - objects.add(object); | |
| 385 | - } | |
| 386 | - | |
| 387 | - //编程式事务 | |
| 388 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 389 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 390 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 391 | - TransactionStatus status = tran.getTransaction(def); | |
| 392 | - try { | |
| 393 | - jdbcTemplate.update("delete from control_interface.bsth_t_real where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 394 | - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_real (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 395 | - @Override | |
| 396 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 397 | - LineServiceConfig object = objects.get(i); | |
| 398 | - ps.setString(1, object.getLineCode()); | |
| 399 | - ps.setString(2, object.getLineName()); | |
| 400 | - ps.setString(3, object.getScheduleDate()); | |
| 401 | - ps.setInt(4, object.getConductorCount()); | |
| 402 | - ps.setInt(5, object.getDriverCount()); | |
| 403 | - ps.setInt(6, object.getCarCount()); | |
| 404 | - } | |
| 405 | - | |
| 406 | - @Override | |
| 407 | - public int getBatchSize() { | |
| 408 | - return objects.size(); | |
| 409 | - } | |
| 410 | - }); | |
| 411 | - tran.commit(status); | |
| 412 | - } catch (Exception e) { | |
| 413 | - tran.rollback(status); | |
| 414 | - } | |
| 415 | - } | |
| 416 | - | |
| 417 | - private void carMileageComputation(final DateTime dateTime) { | |
| 418 | - String rq = dateTime.toString("yyyy-MM-dd"); | |
| 419 | - // 实际排班信息 | |
| 420 | - ArrayListMultimap<String, ScheduleRealInfo> nbbm2schedules = scheduleRedisService.findByDate(rq); | |
| 421 | - // 油耗信息 | |
| 422 | - ArrayListMultimap<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq); | |
| 423 | - //电耗信息 | |
| 424 | - ArrayListMultimap<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq); | |
| 425 | - Set<String> nbbms = nbbm2schedules.keySet(); | |
| 426 | - final List<BusMileage> busMileages = new ArrayList<>(); | |
| 427 | - Set<String> keys = new HashSet<String>(); //保存已添加的车号 | |
| 428 | - for (String nbbm : nbbms) { | |
| 429 | - List<ScheduleRealInfo> scheduleRealInfos = nbbm2schedules.get(nbbm); | |
| 430 | - if (scheduleRealInfos.size() == 0) { | |
| 431 | - continue; | |
| 432 | - } | |
| 433 | - ScheduleRealInfo scheduleRealInfo = scheduleRealInfos.get(0); | |
| 434 | - BusMileage busMileage = new BusMileage(); | |
| 435 | - busMileage.setScheduleDate(rq); | |
| 436 | - busMileage.setNbbm(nbbm); | |
| 437 | - busMileage.setJhlc(ScheduleCalculator.calcJHLC(scheduleRealInfos)); | |
| 438 | - busMileage.setSjjhlc(ScheduleCalculator.calcSJLC(scheduleRealInfos)); | |
| 439 | - busMileage.setSjcclc(ScheduleCalculator.calcCCLC(scheduleRealInfos)); | |
| 440 | - busMileage.setSjjclc(ScheduleCalculator.calcJCLC(scheduleRealInfos)); | |
| 441 | - busMileage.setYylc(ScheduleCalculator.calcYYLC(scheduleRealInfos)); | |
| 442 | - busMileage.setKslc(ScheduleCalculator.calcKSLC(scheduleRealInfos)); | |
| 443 | - busMileage.setCjlc(ScheduleCalculator.calcCJLC(scheduleRealInfos)); | |
| 444 | - busMileage.setLblc(ScheduleCalculator.calcLBLC(scheduleRealInfos)); | |
| 445 | - busMileage.setZjlc(ScheduleCalculator.calcZJLC(scheduleRealInfos)); | |
| 446 | - busMileage.setZlc(ScheduleCalculator.calcZLC(scheduleRealInfos)); | |
| 447 | - List<OilInfo> oilInfos = oilInfoMap.get(nbbm); | |
| 448 | - List<ElecInfo> elecInfos = elecInfoMap.get(nbbm); | |
| 449 | - Double yh = 0.0, dh = 0.0; | |
| 450 | - for (OilInfo oilInfo : oilInfos) { | |
| 451 | - if(scheduleRealInfo.getGsBm().equals(oilInfo.getSsgsdm())){ | |
| 452 | - yh = Arith.add(yh, oilInfo.getYh()); | |
| 453 | - } | |
| 454 | - } | |
| 455 | - for (ElecInfo elecInfo : elecInfos) { | |
| 456 | - if(scheduleRealInfo.getGsBm().equals(elecInfo.getSsgsdm())){ | |
| 457 | - dh = Arith.add(dh, elecInfo.getHd()); | |
| 458 | - } | |
| 459 | - } | |
| 460 | - busMileage.setYh(yh); | |
| 461 | - busMileage.setDh(dh); | |
| 462 | - busMileage.setCompany(scheduleRealInfo.getGsName()); | |
| 463 | - busMileage.setCompanyCode(scheduleRealInfo.getGsBm()); | |
| 464 | - | |
| 465 | - busMileages.add(busMileage); | |
| 466 | - keys.add(busMileage.getCompanyCode() + "_" + nbbm); | |
| 467 | - } | |
| 468 | - | |
| 469 | - for(String nbbm : oilInfoMap.keys()){ //有加油没路单的车。 | |
| 470 | - Set<String> gs_Set = new HashSet<String>(); | |
| 471 | - for (OilInfo oilInfo : oilInfoMap.get(nbbm)) { | |
| 472 | - gs_Set.add(oilInfo.getSsgsdm()); | |
| 473 | - } | |
| 474 | - for(String gs : gs_Set){ | |
| 475 | - if(keys.contains(gs + "_" + nbbm)){ | |
| 476 | - continue; | |
| 477 | - } | |
| 478 | - BusMileage busMileage = new BusMileage(); | |
| 479 | - busMileage.setScheduleDate(rq); | |
| 480 | - busMileage.setNbbm(nbbm); | |
| 481 | - busMileage.setJhlc(0d); | |
| 482 | - busMileage.setSjjhlc(0d); | |
| 483 | - busMileage.setSjcclc(0d); | |
| 484 | - busMileage.setSjjclc(0d); | |
| 485 | - busMileage.setYylc(0d); | |
| 486 | - busMileage.setKslc(0d); | |
| 487 | - busMileage.setCjlc(0d); | |
| 488 | - busMileage.setLblc(0d); | |
| 489 | - busMileage.setZjlc(0d); | |
| 490 | - busMileage.setZlc(0d); | |
| 491 | - List<OilInfo> oilInfos = oilInfoMap.get(nbbm); | |
| 492 | - List<ElecInfo> elecInfos = elecInfoMap.containsKey(nbbm)?elecInfoMap.get(nbbm):new ArrayList<ElecInfo>(); | |
| 493 | - Double yh = 0.0, dh = 0.0; | |
| 494 | - for (OilInfo oilInfo : oilInfos) { | |
| 495 | - if(gs.equals(oilInfo.getSsgsdm())){ | |
| 496 | - yh = Arith.add(yh, oilInfo.getYh()); | |
| 497 | - } | |
| 498 | - } | |
| 499 | - for (ElecInfo elecInfo : elecInfos) { | |
| 500 | - if(gs.equals(elecInfo.getSsgsdm())){ | |
| 501 | - dh = Arith.add(dh, elecInfo.getHd()); | |
| 502 | - } | |
| 503 | - } | |
| 504 | - busMileage.setYh(yh); | |
| 505 | - busMileage.setDh(dh); | |
| 506 | - busMileage.setCompany(BusinessCodeData.code2Name.get(gs)); | |
| 507 | - busMileage.setCompanyCode(gs); | |
| 508 | - | |
| 509 | - busMileages.add(busMileage); | |
| 510 | - keys.add(busMileage.getCompanyCode() + "_" + nbbm); | |
| 511 | - } | |
| 512 | - } | |
| 513 | - | |
| 514 | - for(String nbbm : elecInfoMap.keys()){ //有加电没路单的车。 | |
| 515 | - Set<String> gs_Set = new HashSet<String>(); | |
| 516 | - for (ElecInfo elecInfo : elecInfoMap.get(nbbm)) { | |
| 517 | - gs_Set.add(elecInfo.getSsgsdm()); | |
| 518 | - } | |
| 519 | - for(String gs : gs_Set){ | |
| 520 | - if(keys.contains(gs + "_" + nbbm)){ | |
| 521 | - continue; | |
| 522 | - } | |
| 523 | - BusMileage busMileage = new BusMileage(); | |
| 524 | - busMileage.setScheduleDate(rq); | |
| 525 | - busMileage.setNbbm(nbbm); | |
| 526 | - busMileage.setJhlc(0d); | |
| 527 | - busMileage.setSjjhlc(0d); | |
| 528 | - busMileage.setSjcclc(0d); | |
| 529 | - busMileage.setSjjclc(0d); | |
| 530 | - busMileage.setYylc(0d); | |
| 531 | - busMileage.setKslc(0d); | |
| 532 | - busMileage.setCjlc(0d); | |
| 533 | - busMileage.setLblc(0d); | |
| 534 | - busMileage.setZjlc(0d); | |
| 535 | - busMileage.setZlc(0d); | |
| 536 | - List<ElecInfo> elecInfos = elecInfoMap.get(nbbm); | |
| 537 | - Double yh = 0.0, dh = 0.0; | |
| 538 | - for (ElecInfo elecInfo : elecInfos) { | |
| 539 | - if(gs.equals(elecInfo.getSsgsdm())){ | |
| 540 | - dh = Arith.add(dh, elecInfo.getHd()); | |
| 541 | - } | |
| 542 | - } | |
| 543 | - busMileage.setYh(yh); | |
| 544 | - busMileage.setDh(dh); | |
| 545 | - busMileage.setCompany(BusinessCodeData.code2Name.get(gs)); | |
| 546 | - busMileage.setCompanyCode(gs); | |
| 547 | - | |
| 548 | - busMileages.add(busMileage); | |
| 549 | - keys.add(busMileage.getCompanyCode() + "_" + nbbm); | |
| 550 | - } | |
| 551 | - } | |
| 552 | - | |
| 553 | - //编程式事务 | |
| 554 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 555 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 556 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 557 | - TransactionStatus status = tran.getTransaction(def); | |
| 558 | - try { | |
| 559 | - jdbcTemplate.update("delete from control_interface.bsth_t_mileage where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 560 | - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_mileage (schedule_date,nbbm,jhlc,sjjhlc,sjcclc,sjjclc,yylc,kslc,cjlc,lblc,zjlc,zlc,yh,dh,schedule_month,company,company_code) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 561 | - @Override | |
| 562 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 563 | - BusMileage busMileage = busMileages.get(i); | |
| 564 | - ps.setString(1, busMileage.getScheduleDate()); | |
| 565 | - ps.setString(2, busMileage.getNbbm()); | |
| 566 | - ps.setDouble(3, busMileage.getJhlc()); | |
| 567 | - ps.setDouble(4, busMileage.getSjjhlc()); | |
| 568 | - ps.setDouble(5, busMileage.getSjcclc()); | |
| 569 | - ps.setDouble(6, busMileage.getSjjclc()); | |
| 570 | - ps.setDouble(7, busMileage.getYylc()); | |
| 571 | - ps.setDouble(8, busMileage.getKslc()); | |
| 572 | - ps.setDouble(9, busMileage.getCjlc()); | |
| 573 | - ps.setDouble(10, busMileage.getLblc()); | |
| 574 | - ps.setDouble(11, busMileage.getZjlc()); | |
| 575 | - ps.setDouble(12, busMileage.getZlc()); | |
| 576 | - ps.setDouble(13, busMileage.getYh()); | |
| 577 | - ps.setDouble(14, busMileage.getDh()); | |
| 578 | - ps.setString(15, dateTime.toString("yyyy-MM")); | |
| 579 | - ps.setString(16, busMileage.getCompany()); | |
| 580 | - ps.setString(17, busMileage.getCompanyCode()); | |
| 581 | - } | |
| 582 | - | |
| 583 | - @Override | |
| 584 | - public int getBatchSize() { | |
| 585 | - return busMileages.size(); | |
| 586 | - } | |
| 587 | - }); | |
| 588 | - tran.commit(status); | |
| 589 | - } catch (Exception e) { | |
| 590 | - tran.rollback(status); | |
| 591 | - } | |
| 592 | - } | |
| 593 | - | |
| 594 | - /** | |
| 595 | - * 线路司售配档对象 | |
| 596 | - */ | |
| 597 | - private final static class LineServiceConfigVo { | |
| 598 | - | |
| 599 | - private String lineName; | |
| 600 | - | |
| 601 | - private String month; | |
| 602 | - | |
| 603 | - private Integer driverFirstCount; | |
| 604 | - | |
| 605 | - private Integer driverLastCount; | |
| 606 | - | |
| 607 | - private Integer conductorFirstCount; | |
| 608 | - | |
| 609 | - private Integer conductorLastCount; | |
| 610 | - | |
| 611 | - public String getLineName() { | |
| 612 | - return lineName; | |
| 613 | - } | |
| 614 | - | |
| 615 | - public void setLineName(String lineName) { | |
| 616 | - this.lineName = lineName; | |
| 617 | - } | |
| 618 | - | |
| 619 | - public String getMonth() { | |
| 620 | - return month; | |
| 621 | - } | |
| 622 | - | |
| 623 | - public void setMonth(String month) { | |
| 624 | - this.month = month; | |
| 625 | - } | |
| 626 | - | |
| 627 | - public Integer getDriverFirstCount() { | |
| 628 | - return driverFirstCount; | |
| 629 | - } | |
| 630 | - | |
| 631 | - public void setDriverFirstCount(Integer driverFirstCount) { | |
| 632 | - this.driverFirstCount = driverFirstCount; | |
| 633 | - } | |
| 634 | - | |
| 635 | - public Integer getDriverLastCount() { | |
| 636 | - return driverLastCount; | |
| 637 | - } | |
| 638 | - | |
| 639 | - public void setDriverLastCount(Integer driverLastCount) { | |
| 640 | - this.driverLastCount = driverLastCount; | |
| 641 | - } | |
| 642 | - | |
| 643 | - public Integer getConductorFirstCount() { | |
| 644 | - return conductorFirstCount; | |
| 645 | - } | |
| 646 | - | |
| 647 | - public void setConductorFirstCount(Integer conductorFirstCount) { | |
| 648 | - this.conductorFirstCount = conductorFirstCount; | |
| 649 | - } | |
| 650 | - | |
| 651 | - public Integer getConductorLastCount() { | |
| 652 | - return conductorLastCount; | |
| 653 | - } | |
| 654 | - | |
| 655 | - public void setConductorLastCount(Integer conductorLastCount) { | |
| 656 | - this.conductorLastCount = conductorLastCount; | |
| 657 | - } | |
| 658 | - } | |
| 659 | - | |
| 660 | - /** | |
| 661 | - * 车辆配档对象 | |
| 662 | - */ | |
| 663 | - private final static class BusVo { | |
| 664 | - | |
| 665 | - private String lineName; | |
| 666 | - | |
| 667 | - private String month; | |
| 668 | - | |
| 669 | - private Integer busFirstCount; | |
| 670 | - | |
| 671 | - private Integer busLastCount; | |
| 672 | - | |
| 673 | - private Integer busMaxCount; | |
| 674 | - | |
| 675 | - public String getLineName() { | |
| 676 | - return lineName; | |
| 677 | - } | |
| 678 | - | |
| 679 | - public void setLineName(String lineName) { | |
| 680 | - this.lineName = lineName; | |
| 681 | - } | |
| 682 | - | |
| 683 | - public String getMonth() { | |
| 684 | - return month; | |
| 685 | - } | |
| 686 | - | |
| 687 | - public void setMonth(String month) { | |
| 688 | - this.month = month; | |
| 689 | - } | |
| 690 | - | |
| 691 | - public Integer getBusFirstCount() { | |
| 692 | - return busFirstCount; | |
| 693 | - } | |
| 694 | - | |
| 695 | - public void setBusFirstCount(Integer busFirstCount) { | |
| 696 | - this.busFirstCount = busFirstCount; | |
| 697 | - } | |
| 698 | - | |
| 699 | - public Integer getBusLastCount() { | |
| 700 | - return busLastCount; | |
| 701 | - } | |
| 702 | - | |
| 703 | - public void setBusLastCount(Integer busLastCount) { | |
| 704 | - this.busLastCount = busLastCount; | |
| 705 | - } | |
| 706 | - | |
| 707 | - public Integer getBusMaxCount() { | |
| 708 | - return busMaxCount; | |
| 709 | - } | |
| 710 | - | |
| 711 | - public void setBusMaxCount(Integer busMaxCount) { | |
| 712 | - this.busMaxCount = busMaxCount; | |
| 713 | - } | |
| 714 | - } | |
| 715 | - | |
| 716 | - /** | |
| 717 | - * 车辆公里、油耗对象 | |
| 718 | - */ | |
| 719 | - private final static class BusMileageVo { | |
| 720 | - | |
| 721 | - private String insideCode; | |
| 722 | - | |
| 723 | - private String month; | |
| 724 | - | |
| 725 | - private Double totalMileage; | |
| 726 | - | |
| 727 | - private Double oilConsume; | |
| 728 | - | |
| 729 | - private Double electricConsume; | |
| 730 | - | |
| 731 | - private String company; | |
| 732 | - | |
| 733 | - private String companyCode; | |
| 734 | - | |
| 735 | - public String getInsideCode() { | |
| 736 | - return insideCode; | |
| 737 | - } | |
| 738 | - | |
| 739 | - public void setInsideCode(String insideCode) { | |
| 740 | - this.insideCode = insideCode; | |
| 741 | - } | |
| 742 | - | |
| 743 | - public String getMonth() { | |
| 744 | - return month; | |
| 745 | - } | |
| 746 | - | |
| 747 | - public void setMonth(String month) { | |
| 748 | - this.month = month; | |
| 749 | - } | |
| 750 | - | |
| 751 | - public Double getTotalMileage() { | |
| 752 | - return totalMileage; | |
| 753 | - } | |
| 754 | - | |
| 755 | - public void setTotalMileage(Double totalMileage) { | |
| 756 | - this.totalMileage = totalMileage; | |
| 757 | - } | |
| 758 | - | |
| 759 | - public Double getOilConsume() { | |
| 760 | - return oilConsume; | |
| 761 | - } | |
| 762 | - | |
| 763 | - public void setOilConsume(Double oilConsume) { | |
| 764 | - this.oilConsume = oilConsume; | |
| 765 | - } | |
| 766 | - | |
| 767 | - public Double getElectricConsume() { | |
| 768 | - return electricConsume; | |
| 769 | - } | |
| 770 | - | |
| 771 | - public void setElectricConsume(Double electricConsume) { | |
| 772 | - this.electricConsume = electricConsume; | |
| 773 | - } | |
| 774 | - | |
| 775 | - public String getCompany() { | |
| 776 | - return company; | |
| 777 | - } | |
| 778 | - | |
| 779 | - public void setCompany(String company) { | |
| 780 | - this.company = company; | |
| 781 | - } | |
| 782 | - | |
| 783 | - public String getCompanyCode() { | |
| 784 | - return companyCode; | |
| 785 | - } | |
| 786 | - | |
| 787 | - public void setCompanyCode(String companyCode) { | |
| 788 | - this.companyCode = companyCode; | |
| 789 | - } | |
| 790 | - } | |
| 791 | -} |
src/main/java/com/bsth/server_rs/dks/LineServiceConfig.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.dks; | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * 线路运营司、售、车辆配档信息 | |
| 5 | - * @author Hill | |
| 6 | - */ | |
| 7 | -public class LineServiceConfig { | |
| 8 | - | |
| 9 | - private String lineCode; | |
| 10 | - | |
| 11 | - private String lineName; | |
| 12 | - | |
| 13 | - private String month; | |
| 14 | - | |
| 15 | - private String scheduleDate; | |
| 16 | - | |
| 17 | - private int driverCount; | |
| 18 | - | |
| 19 | - private int conductorCount; | |
| 20 | - | |
| 21 | - private int carCount; | |
| 22 | - | |
| 23 | - public String getLineCode() { | |
| 24 | - return lineCode; | |
| 25 | - } | |
| 26 | - | |
| 27 | - public void setLineCode(String lineCode) { | |
| 28 | - this.lineCode = lineCode; | |
| 29 | - } | |
| 30 | - | |
| 31 | - public String getLineName() { | |
| 32 | - return lineName; | |
| 33 | - } | |
| 34 | - | |
| 35 | - public void setLineName(String lineName) { | |
| 36 | - this.lineName = lineName; | |
| 37 | - } | |
| 38 | - | |
| 39 | - public String getMonth() { | |
| 40 | - return month; | |
| 41 | - } | |
| 42 | - | |
| 43 | - public void setMonth(String month) { | |
| 44 | - this.month = month; | |
| 45 | - } | |
| 46 | - | |
| 47 | - public String getScheduleDate() { | |
| 48 | - return scheduleDate; | |
| 49 | - } | |
| 50 | - | |
| 51 | - public void setScheduleDate(String scheduleDate) { | |
| 52 | - this.scheduleDate = scheduleDate; | |
| 53 | - } | |
| 54 | - | |
| 55 | - public int getDriverCount() { | |
| 56 | - return driverCount; | |
| 57 | - } | |
| 58 | - | |
| 59 | - public void setDriverCount(int driverCount) { | |
| 60 | - this.driverCount = driverCount; | |
| 61 | - } | |
| 62 | - | |
| 63 | - public int getConductorCount() { | |
| 64 | - return conductorCount; | |
| 65 | - } | |
| 66 | - | |
| 67 | - public void setConductorCount(int conductorCount) { | |
| 68 | - this.conductorCount = conductorCount; | |
| 69 | - } | |
| 70 | - | |
| 71 | - public int getCarCount() { | |
| 72 | - return carCount; | |
| 73 | - } | |
| 74 | - | |
| 75 | - public void setCarCount(int carCount) { | |
| 76 | - this.carCount = carCount; | |
| 77 | - } | |
| 78 | -} |
src/main/java/com/bsth/server_rs/electric/ElectricService.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.electric; | |
| 2 | - | |
| 3 | -import com.bsth.server_ws.electric_oil.entity.Electric; | |
| 4 | -import org.slf4j.Logger; | |
| 5 | -import org.slf4j.LoggerFactory; | |
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 8 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 9 | -import org.springframework.stereotype.Component; | |
| 10 | - | |
| 11 | -import javax.ws.rs.GET; | |
| 12 | -import javax.ws.rs.Path; | |
| 13 | -import javax.ws.rs.PathParam; | |
| 14 | -import javax.ws.rs.Produces; | |
| 15 | -import javax.ws.rs.core.MediaType; | |
| 16 | -import java.util.List; | |
| 17 | - | |
| 18 | -/** | |
| 19 | - * Created by panzhao on 2018/3/27. | |
| 20 | - */ | |
| 21 | -@Component | |
| 22 | -@Path("/electric") | |
| 23 | -@Produces({MediaType.APPLICATION_JSON}) | |
| 24 | -public class ElectricService { | |
| 25 | - | |
| 26 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 27 | - | |
| 28 | - @Autowired | |
| 29 | - JdbcTemplate jdbcTemplate; | |
| 30 | - | |
| 31 | - @GET | |
| 32 | - @Path("/{company}/{rq}") | |
| 33 | - public List<Electric> list(@PathParam("company") String company, @PathParam("rq") String rq){ | |
| 34 | - List<Electric> list = null; | |
| 35 | - try { | |
| 36 | - //从数据库查询 | |
| 37 | - //list = jdbcTemplate.query("select fgs_bm,fgs_name,gs_bm,gs_name,jdl,jdz,remarks,rq,creater_date,nbbm,jsy from bsth_c_jdl where gs_bm="+company+" and rq='"+rq+"'" | |
| 38 | - // , BeanPropertyRowMapper.newInstance(Electric.class)); | |
| 39 | - list = jdbcTemplate.query("select fgsdm as fgs_bm,c.business_name as fgs_name,ssgsdm as gs_bm,b.business_name as gs_name,cdl as jdl,'' as jdz,'' as remarks,rq,createtime as create_date,nbbm,'' as jsy from (select fgsdm,ssgsdm,sum(cdl * 1000) / 1000 as cdl,rq,max(createtime) as createtime,nbbm from bsth_c_dlb where rq = '" + rq + "' GROUP BY fgsdm,ssgsdm,rq,nbbm) a left join bsth_c_business b on a.ssgsdm = b.business_code LEFT JOIN bsth_c_business c on concat(a.ssgsdm, '_', a.fgsdm) = concat(c.up_code, '_', c.business_code) where ssgsdm="+company | |
| 40 | - , BeanPropertyRowMapper.newInstance(Electric.class)); | |
| 41 | - }catch (Exception e){ | |
| 42 | - logger.error("", e); | |
| 43 | - } | |
| 44 | - return list; | |
| 45 | - } | |
| 46 | -} |
src/main/resources/application-cloud.properties
| 1 | -server.port=9089 | |
| 1 | +server.port=19089 | |
| 2 | 2 | management.port= 9001 |
| 3 | 3 | management.address= 127.0.0.1 |
| 4 | 4 | |
| ... | ... | @@ -12,10 +12,10 @@ spring.datasource.url= jdbc:mysql://192.170.100.132/control?useUnicode=true&char |
| 12 | 12 | spring.datasource.username= root |
| 13 | 13 | spring.datasource.password= root2jsp |
| 14 | 14 | #DATASOURCE |
| 15 | -spring.datasource.max-active=100 | |
| 16 | -spring.datasource.max-idle=8 | |
| 17 | -spring.datasource.min-idle=8 | |
| 18 | -spring.datasource.initial-size=3 | |
| 15 | +spring.datasource.max-active=8 | |
| 16 | +spring.datasource.max-idle=4 | |
| 17 | +spring.datasource.min-idle=1 | |
| 18 | +spring.datasource.initial-size=4 | |
| 19 | 19 | |
| 20 | 20 | spring.datasource.test-on-borrow=true |
| 21 | 21 | spring.datasource.test-on-connect=true |
| ... | ... | @@ -29,13 +29,6 @@ spring.redis.host=192.170.100.250 |
| 29 | 29 | spring.redis.password=bsth_control_001 |
| 30 | 30 | spring.redis.port=28008 |
| 31 | 31 | |
| 32 | -#kafka | |
| 33 | -spring.kafka.bootstrap-servers=112.64.45.145:19093,112.64.45.145:19094,112.64.45.145:19095,112.64.45.145:19096 | |
| 34 | -spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer | |
| 35 | -spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer | |
| 36 | -spring.kafka.producer.buffer-memory=33554432 | |
| 37 | -spring.kafka.producer.acks=all | |
| 38 | - | |
| 39 | 32 | http.control.service_data_url= https://192.170.100.54:9088/companyService |
| 40 | 33 | http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki |
| 41 | 34 | ... | ... |