Commit 66b0b5d0abdac496bb92ae34867486c1e24dd31d
1 parent
dc701f72
1
Showing
20 changed files
with
658 additions
and
182 deletions
src/main/java/com/bsth/Application.java
| 1 | 1 | package com.bsth; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.data.SystemParamCache; |
| 4 | -import com.bsth.service.SystemParamService; | |
| 5 | 4 | import com.fasterxml.jackson.annotation.JsonInclude; |
| 6 | 5 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 7 | 6 | import com.fasterxml.jackson.databind.SerializationFeature; |
| ... | ... | @@ -23,7 +22,7 @@ import java.util.concurrent.ScheduledExecutorService; |
| 23 | 22 | @SpringBootApplication |
| 24 | 23 | public class Application extends SpringBootServletInitializer { |
| 25 | 24 | |
| 26 | - public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(21); | |
| 25 | + public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(30); | |
| 27 | 26 | |
| 28 | 27 | @Autowired |
| 29 | 28 | private SystemParamCache systemParamCache; | ... | ... |
src/main/java/com/bsth/XDApplication.java
| ... | ... | @@ -23,6 +23,7 @@ import com.bsth.data.schedule.thread.SchedulePstThread; |
| 23 | 23 | import com.bsth.data.schedule.thread.ScheduleRefreshThread; |
| 24 | 24 | import com.bsth.data.schedule.thread.SubmitToTrafficManage; |
| 25 | 25 | import com.bsth.data.zndd.ZnddThread; |
| 26 | +import com.bsth.data.zndd.ZnddTwoThread; | |
| 26 | 27 | import com.bsth.util.DateUtils; |
| 27 | 28 | import com.bsth.util.Tools; |
| 28 | 29 | import org.slf4j.Logger; |
| ... | ... | @@ -85,6 +86,9 @@ public class XDApplication implements CommandLineRunner { |
| 85 | 86 | FixedEnableVerionsThread fixedEnableVerionsThread;*/ |
| 86 | 87 | @Autowired |
| 87 | 88 | ZnddThread znddThread; |
| 89 | + | |
| 90 | + @Autowired | |
| 91 | + ZnddTwoThread ZnddtwoThread; | |
| 88 | 92 | @Autowired |
| 89 | 93 | SafeDrivDataLoadThread safeDrivDataLoadThread; |
| 90 | 94 | |
| ... | ... | @@ -145,8 +149,9 @@ public class XDApplication implements CommandLineRunner { |
| 145 | 149 | //dayOfSchedule.dataRecovery(); |
| 146 | 150 | |
| 147 | 151 | //智能调度 |
| 148 | - sexec.scheduleWithFixedDelay(znddThread, 60, 25, TimeUnit.SECONDS); | |
| 149 | - | |
| 152 | + sexec.scheduleWithFixedDelay(znddThread, 30, 30, TimeUnit.SECONDS); | |
| 153 | + //智能调度 | |
| 154 | + sexec.scheduleWithFixedDelay(ZnddtwoThread, 30, 60, TimeUnit.SECONDS); | |
| 150 | 155 | //安全驾驶 |
| 151 | 156 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); |
| 152 | 157 | |
| ... | ... | @@ -190,10 +195,14 @@ public class XDApplication implements CommandLineRunner { |
| 190 | 195 | public void prodInit(){ |
| 191 | 196 | log.info("prodInit..."); |
| 192 | 197 | ScheduledExecutorService sexec = Application.mainServices; |
| 198 | + | |
| 199 | + | |
| 193 | 200 | //安全驾驶 |
| 194 | 201 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); |
| 195 | 202 | //智能调度 |
| 196 | - sexec.scheduleWithFixedDelay(znddThread, 60, 25, TimeUnit.SECONDS); | |
| 203 | + sexec.scheduleWithFixedDelay(znddThread, 30, 30, TimeUnit.SECONDS); | |
| 204 | + //智能调度 | |
| 205 | + sexec.scheduleWithFixedDelay(ZnddtwoThread, 30, 120, TimeUnit.SECONDS); | |
| 197 | 206 | GpsDataLoaderThread.setFlag(-1); |
| 198 | 207 | /** 线调业务 */ |
| 199 | 208 | sexec.scheduleWithFixedDelay(scheduleRefreshThread, 10, 120, TimeUnit.SECONDS);//班次更新线程 |
| ... | ... | @@ -237,8 +246,11 @@ public class XDApplication implements CommandLineRunner { |
| 237 | 246 | ScheduledExecutorService sexec = Application.mainServices; |
| 238 | 247 | //安全驾驶 |
| 239 | 248 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); |
| 249 | + | |
| 250 | + //智能调度 | |
| 251 | + sexec.scheduleWithFixedDelay(znddThread, 30, 30, TimeUnit.SECONDS); | |
| 240 | 252 | //智能调度 |
| 241 | - sexec.scheduleWithFixedDelay(znddThread, 60, 25, TimeUnit.SECONDS); | |
| 253 | + sexec.scheduleWithFixedDelay(ZnddtwoThread, 30, 60, TimeUnit.SECONDS); | |
| 242 | 254 | GpsDataLoaderThread.setFlag(-1); |
| 243 | 255 | //dayOfSchedule.dataRecovery(); |
| 244 | 256 | /** 线调业务 */ |
| ... | ... | @@ -284,7 +296,7 @@ public class XDApplication implements CommandLineRunner { |
| 284 | 296 | //安全驾驶 |
| 285 | 297 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); |
| 286 | 298 | //智能调度 |
| 287 | - sexec.scheduleWithFixedDelay(znddThread, 15, 30, TimeUnit.SECONDS); | |
| 299 | + sexec.scheduleWithFixedDelay(znddThread, 15, 60, TimeUnit.SECONDS); | |
| 288 | 300 | |
| 289 | 301 | GpsDataLoaderThread.setFlag(-1); |
| 290 | 302 | /** 线调业务 */ | ... | ... |
src/main/java/com/bsth/controller/zndd/ZnddStatusController.java
| ... | ... | @@ -7,6 +7,7 @@ import com.bsth.service.zndd.ZnddStatusService; |
| 7 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | 8 | import org.springframework.web.bind.annotation.RequestMapping; |
| 9 | 9 | import org.springframework.web.bind.annotation.RequestMethod; |
| 10 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 10 | 11 | import org.springframework.web.bind.annotation.RestController; |
| 11 | 12 | |
| 12 | 13 | import java.util.HashMap; |
| ... | ... | @@ -34,4 +35,21 @@ public class ZnddStatusController extends BaseController<znddStatus, Integer> { |
| 34 | 35 | return result; |
| 35 | 36 | } |
| 36 | 37 | |
| 38 | + | |
| 39 | + /** | |
| 40 | + *新增类型 | |
| 41 | + * */ | |
| 42 | + @RequestMapping(value = "/update", method = RequestMethod.POST) | |
| 43 | + public Map<String, Object> update(@RequestParam Integer id, @RequestParam Integer openStatus) { | |
| 44 | + Map<String, Object> result = new HashMap<>(); | |
| 45 | + try { | |
| 46 | + znddStatusService.update(id,openStatus); | |
| 47 | + result.put("status", ResponseCode.SUCCESS); | |
| 48 | + } catch (Exception e) { | |
| 49 | + result.put("status", ResponseCode.ERROR); | |
| 50 | + result.put("msg", e.getMessage()); | |
| 51 | + } | |
| 52 | + return result; | |
| 53 | + } | |
| 54 | + | |
| 37 | 55 | } | ... | ... |
src/main/java/com/bsth/data/zndd/AutomaticSch.java
| 1 | 1 | package com.bsth.data.zndd; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.fastjson.JSON; |
| 4 | +import com.alibaba.fastjson.JSONArray; | |
| 4 | 5 | import com.alibaba.fastjson.JSONObject; |
| 5 | 6 | import com.alibaba.fastjson.TypeReference; |
| 6 | 7 | import com.bsth.data.BasicData; |
| ... | ... | @@ -26,7 +27,6 @@ import com.bsth.service.zndd.ZnddLoggerService; |
| 26 | 27 | import com.bsth.service.zndd.ZnddYuAnService; |
| 27 | 28 | import com.bsth.util.DateUtils; |
| 28 | 29 | import com.bsth.util.HttpClientUtils; |
| 29 | -import com.google.gson.Gson; | |
| 30 | 30 | import org.apache.commons.lang3.StringUtils; |
| 31 | 31 | import org.slf4j.Logger; |
| 32 | 32 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -89,15 +89,48 @@ public class AutomaticSch { |
| 89 | 89 | //满载 |
| 90 | 90 | public void mz(){ |
| 91 | 91 | try { |
| 92 | + StringBuilder sb = HttpClientUtils.get(urldkls); | |
| 93 | + List<Object> list = JSONArray.parseArray(String.valueOf(sb)); | |
| 94 | + for (Object b :list){ | |
| 95 | + Map m = (Map) b; | |
| 96 | + Integer num = Integer.parseInt(m.get("inside_num").toString()); | |
| 97 | + | |
| 98 | + int count= getPenum("MZ","0"); | |
| 99 | + if(num < count){//大间隔阈值 检测到超过15个人的时候推送 | |
| 100 | + return; | |
| 101 | + } | |
| 102 | + ScheduleRealInfo sr = dayOfSchedule.executeCurr(m.get("nbbm").toString()); //查询当前车辆执行班次 | |
| 103 | + GpsEntity gps = gpsRealData.get(m.get("sbbh").toString()); | |
| 104 | + Map msp = new HashMap(); | |
| 105 | + msp.put("lineCode",m.get("xlbm")); | |
| 106 | + msp.put("lineName",m.get("XLMC")); | |
| 107 | + msp.put("stationName",gps.getStationName()); | |
| 108 | + msp.put("rqStr",sdfMonth.format(new Date())); | |
| 109 | + msp.put("rq",sdfHHmm.format(new Date())); | |
| 110 | + msp.put("type","MZ"); | |
| 111 | + msp.put("xlDir",gps.getUpDown()); | |
| 112 | + msp.put("fcsj",""); | |
| 113 | + msp.put("clzbh",gps.getNbbm()); | |
| 114 | + msp.put("numType",num); | |
| 115 | + if (sr != null ) | |
| 116 | + msp.put("xlDir",sr.getXlDir()); | |
| 117 | + | |
| 118 | + if (gps != null ) | |
| 119 | + msp.put("station",gps.getStation().getCode()); | |
| 120 | + | |
| 121 | + ts(msp); | |
| 122 | + LogerWait("满载",sr); | |
| 123 | + } | |
| 92 | 124 | |
| 93 | - List<ScheduleRealInfo> sr = dayOfSchedule.findByBcType("W9G-041","normal"); | |
| 125 | + //测试使用 | |
| 126 | + /* List<ScheduleRealInfo> sr = dayOfSchedule.findByBcType("W9G-041","normal"); | |
| 94 | 127 | ts(addStationPeople(sr.get(5), "MZ", 0L));//第二种 设备未离线 出站时间内未出站 |
| 95 | 128 | |
| 96 | 129 | String chartStr = JSON.toJSONString(sr.get(5)); |
| 97 | - logger.info("满载--"+chartStr); | |
| 130 | + logger.info("满载--"+chartStr);*/ | |
| 98 | 131 | } |
| 99 | 132 | catch (Exception e){ |
| 100 | - logger.error("满载------------------",e); | |
| 133 | + logger.error("满载检测接口出错------------------",e); | |
| 101 | 134 | } |
| 102 | 135 | } |
| 103 | 136 | |
| ... | ... | @@ -126,15 +159,13 @@ public class AutomaticSch { |
| 126 | 159 | if (lg.getlGType() == 0) { |
| 127 | 160 | ts(ConvertDJK(lg, sch, "FCJG")); |
| 128 | 161 | SFMAP.put(lg.getId(), lg.getTsTime()); |
| 129 | - String chartStr = JSON.toJSONString(sch); | |
| 130 | - logger.info("发车大间隔--" + chartStr); | |
| 162 | + LogerWait("发车大间隔",sch); | |
| 131 | 163 | } |
| 132 | 164 | } else { |
| 133 | 165 | if (lg.getlGType() != 0) { |
| 134 | 166 | ts(ConvertDJK(lg, sch, "DJG")); |
| 135 | 167 | SFMAP.put(lg.getId(), lg.getTsTime()); |
| 136 | - String chartStr = JSON.toJSONString(sch); | |
| 137 | - logger.info("行车大间隔--" + chartStr); | |
| 168 | + LogerWait("行车大间隔",sch); | |
| 138 | 169 | } |
| 139 | 170 | } |
| 140 | 171 | } |
| ... | ... | @@ -200,16 +231,14 @@ public class AutomaticSch { |
| 200 | 231 | } |
| 201 | 232 | sr.setFcsjActual(sfsj); |
| 202 | 233 | ts(addStationPeople(sr, "SFTZ_1", 0L)); |
| 203 | - Gson gson = new Gson(); | |
| 204 | - String chartStr = gson.toJsonTree(sr).toString(); | |
| 205 | - logger.info("实发调整--" + chartStr); | |
| 234 | + LogerWait("实发调整",sr); | |
| 206 | 235 | } |
| 207 | 236 | } |
| 208 | 237 | } |
| 209 | 238 | } |
| 210 | 239 | |
| 211 | 240 | } |
| 212 | - }catch (Exception e){ | |
| 241 | + }catch (Throwable e){ | |
| 213 | 242 | logger.error("自动调度,实发未发推送失败---",e); |
| 214 | 243 | } |
| 215 | 244 | logger.warn("实发未发扫描结束"); |
| ... | ... | @@ -219,6 +248,7 @@ public class AutomaticSch { |
| 219 | 248 | public void sfCX(){ |
| 220 | 249 | //查询所有班次 |
| 221 | 250 | //remark 人工干预过的的不检测 |
| 251 | + logger.warn("实发撤销检测扫描开始"); | |
| 222 | 252 | try { |
| 223 | 253 | |
| 224 | 254 | Map<String, String> lineMap = BasicData.lineCode2NameMap; |
| ... | ... | @@ -251,23 +281,28 @@ public class AutomaticSch { |
| 251 | 281 | msp.put("schId_eq",t.getId()); |
| 252 | 282 | seiList = (List<SchEditInfo>) schEditInfoService.list(msp); |
| 253 | 283 | //有操作记录的跳过 |
| 254 | - if (seiList.size() > 0) | |
| 284 | + Boolean isCZ = false; | |
| 285 | + for(SchEditInfo e : seiList){ | |
| 286 | + if (e.getType().equals("FCXXWT") || e.getType().equals("DFTZ") || e.getType().equals("SFTZ")){ | |
| 287 | + isCZ = true; | |
| 288 | + } | |
| 289 | + } | |
| 290 | + if (isCZ) | |
| 255 | 291 | continue; |
| 256 | 292 | } |
| 257 | 293 | //异常实发 |
| 258 | 294 | ts(addStationPeople(t, "YCSF", 0l)); |
| 259 | - Gson gson = new Gson(); | |
| 260 | - String chartStr = gson.toJsonTree(t).toString(); | |
| 261 | - logger.info("实发撤销--" + chartStr); | |
| 295 | + LogerWait("实发撤销",t); | |
| 262 | 296 | } |
| 263 | 297 | } |
| 264 | 298 | } |
| 265 | 299 | |
| 266 | 300 | } |
| 267 | 301 | } |
| 268 | - }catch (Exception e){ | |
| 302 | + }catch (Throwable e){ | |
| 269 | 303 | logger.error("实发撤销推送接口出错-----------",e); |
| 270 | 304 | } |
| 305 | + logger.warn("实发撤销检测扫描结束"); | |
| 271 | 306 | } |
| 272 | 307 | |
| 273 | 308 | public Boolean isLines(String line) { |
| ... | ... | @@ -331,7 +366,7 @@ public class AutomaticSch { |
| 331 | 366 | /*}*/ |
| 332 | 367 | } |
| 333 | 368 | } |
| 334 | - }catch (Exception e){ | |
| 369 | + }catch (Throwable e){ | |
| 335 | 370 | logger.error("自动调度,指令重发---",e); |
| 336 | 371 | } |
| 337 | 372 | logger.warn("指令重发扫描结束"); |
| ... | ... | @@ -368,8 +403,7 @@ public class AutomaticSch { |
| 368 | 403 | if (basicData.nbbmCompanyPlateMap.get(prev.getClZbh()) != null && m.get("terminal").equals(basicData.nbbmCompanyPlateMap.get(prev.getClZbh()).replaceAll("-",""))){ |
| 369 | 404 | sch.setRemark(m.get("sj").toString()); |
| 370 | 405 | ts(addStationPeople(sch, "WD", 0L)); |
| 371 | - String chartStr = JSON.toJSONString(sch); | |
| 372 | - logger.info("误点--"+chartStr); | |
| 406 | + LogerWait("误点",sch); | |
| 373 | 407 | } |
| 374 | 408 | } |
| 375 | 409 | } |
| ... | ... | @@ -383,6 +417,69 @@ public class AutomaticSch { |
| 383 | 417 | } |
| 384 | 418 | |
| 385 | 419 | |
| 420 | + public void LogerWait(String type,ScheduleRealInfo sch){ | |
| 421 | + String chartStr = "id-"+sch.getId() +",xlName-"+sch.getXlName() + ",fcsj-"+sch.getFcsj() + ",FcsjActual-"+ sch.getFcsjActual()+",clzbh-" + sch.getClZbh(); | |
| 422 | + logger.info(type+"--" + chartStr); | |
| 423 | + } | |
| 424 | + | |
| 425 | + /** | |
| 426 | + *每辆车倒数第二个班次执行之前3分钟提示 | |
| 427 | + */ | |
| 428 | + public void TowdescSch(){ | |
| 429 | + logger.warn("末二班车执行方法开始"); | |
| 430 | + try { | |
| 431 | + //获取所有线路 | |
| 432 | + Map<String, String> lineMap = BasicData.lineCode2NameMap; | |
| 433 | + //findByNbbm车辆索引获取的班次 | |
| 434 | + Map<String, List<ScheduleRealInfo>> groupedByCity = new HashMap<>(); | |
| 435 | + if(System.currentTimeMillis() < DateUtils.getTimestamp() + (1000 * 60 * 60 * 20)){ | |
| 436 | + logger.info("未到8点----"+(DateUtils.getTimestamp() + (1000 * 60 * 60 * 20))); | |
| 437 | + return; | |
| 438 | + } | |
| 439 | + | |
| 440 | + for (Map.Entry<String, String> t : lineMap.entrySet()) { | |
| 441 | + List<ScheduleRealInfo> srList = dayOfSchedule.findByLineCode(t.getKey()); | |
| 442 | + Map<String, List<ScheduleRealInfo>> mapType = new HashMap(); | |
| 443 | + //所有车辆 | |
| 444 | + for (ScheduleRealInfo s : srList) { | |
| 445 | + if (mapType.get(s.getClZbh()) != null) | |
| 446 | + continue; | |
| 447 | + | |
| 448 | + List<ScheduleRealInfo> schadd = new ArrayList<>(); | |
| 449 | + //每辆车下的班次 | |
| 450 | + for (ScheduleRealInfo sch : srList) { | |
| 451 | + if (s.getClZbh().equals(sch.getClZbh())) { | |
| 452 | + schadd.add(sch); | |
| 453 | + } | |
| 454 | + } | |
| 455 | + mapType.put(s.getClZbh(), schadd); | |
| 456 | + } | |
| 457 | + //判断倒数第二个班次是否快要发车 | |
| 458 | + for (String key : mapType.keySet()) { | |
| 459 | + List<ScheduleRealInfo> carList = mapType.get(key); | |
| 460 | + Collections.sort(carList, new ScheduleComparator.FCSJ()); | |
| 461 | + //倒数第二个班次保证数量超过两条 | |
| 462 | + ScheduleRealInfo scht = carList.size() >= 2 ? carList.get(carList.size() - 2) : null; | |
| 463 | + if (scht == null) | |
| 464 | + continue; | |
| 465 | + | |
| 466 | + if (scht.getDfsjT() > DateUtils.getTimestamp() + (1000 * 60 * 60 * 20) && | |
| 467 | + scht.getDfsjT() - System.currentTimeMillis() < (1000* 60 * 4) && | |
| 468 | + scht.getDfsjT() - System.currentTimeMillis() >= (1000* 60 *3)) { | |
| 469 | + //推送一下 | |
| 470 | + ts(addStationPeople(scht,"DESCTWO",0l)); | |
| 471 | + | |
| 472 | + LogerWait("末二班车推送",scht); | |
| 473 | + } | |
| 474 | + } | |
| 475 | + } | |
| 476 | + | |
| 477 | + }catch (Exception e){ | |
| 478 | + logger.error("(倒数第二班车)末二班车执行方法出错"+ e); | |
| 479 | + } | |
| 480 | + } | |
| 481 | + | |
| 482 | + | |
| 386 | 483 | |
| 387 | 484 | public void ts(Map m) throws ParseException { |
| 388 | 485 | |
| ... | ... | @@ -425,16 +522,6 @@ public class AutomaticSch { |
| 425 | 522 | return sp; |
| 426 | 523 | } |
| 427 | 524 | |
| 428 | - //大间隔数据转换 | |
| 429 | - public Map ConvertDKL(Map m){ | |
| 430 | - Map sp = new HashMap(); | |
| 431 | - sp.put("uuid",UUID()); | |
| 432 | - sp.put("lineCode",m.get("lineCode")); | |
| 433 | - sp.put("lineName",m.get("lineName")); | |
| 434 | - sp.put("rqStr",sdf.format(new Date())); | |
| 435 | - sp.put("rq",sdfHHmm.format(new Date())); //检测到时间 | |
| 436 | - return sp; | |
| 437 | - } | |
| 438 | 525 | |
| 439 | 526 | |
| 440 | 527 | //转换 | ... | ... |
src/main/java/com/bsth/data/zndd/OutEntrance.java
| ... | ... | @@ -107,7 +107,7 @@ public class OutEntrance { |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
| 110 | - //查询班次情况自动回复 | |
| 110 | + //查询班次情况自动回复 --拥堵 | |
| 111 | 111 | //当前日期 |
| 112 | 112 | List<Map> dzList = carMonitor.carMonitor(ssLogger.getLineCode(), ssLogger.getDir(), ssLogger.getStation()); //信息发布接口 |
| 113 | 113 | if (dzList.size() > 0){ |
| ... | ... | @@ -123,23 +123,25 @@ public class OutEntrance { |
| 123 | 123 | rtn.put("message",s+"亲爱的乘客,我们的调度员已接收到通知,车辆预计还有"+dzList.get(0).get("sj")+"抵达,请稍等片刻"); |
| 124 | 124 | }else { |
| 125 | 125 | //第一个班次 |
| 126 | - //所有应发未到的班次 | |
| 126 | + //所有应发未到的班次--晚点的情况 | |
| 127 | 127 | Collection<ScheduleRealInfo> all = LateAdjustHandle.allLateSch(); |
| 128 | 128 | for (ScheduleRealInfo schc : all) { |
| 129 | - Long schId = (Long) dzList.get(0).get("schId"); | |
| 130 | - ScheduleRealInfo sch = null; | |
| 131 | - if (schId != null) | |
| 132 | - sch = dayOfSchedule.get(schId); | |
| 133 | - | |
| 134 | - ScheduleRealInfo prev = dayOfSchedule.prev(sch); | |
| 135 | - List<Map> dzLists = carMonitor.carMonitor(prev.getXlBm(), prev.getXlDir(), prev.getZdzCode()); //信息发布接口 | |
| 136 | - for (Map mst : dzLists) { | |
| 137 | - //匹配到当前车辆 | |
| 138 | - if (basicData.nbbmCompanyPlateMap.get(prev.getClZbh()) != null && mst.get("terminal").equals(basicData.nbbmCompanyPlateMap.get(prev.getClZbh()).replaceAll("-", ""))) { | |
| 139 | - if (sch.getXlBm().equals(schc.getXlBm())) { | |
| 140 | - rtn.put("message", "非常抱歉,车辆因路上交通拥堵,预计还需要" + m.get("sj").toString() + "抵达,请稍等片刻"); | |
| 141 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 142 | - return rtn; | |
| 129 | + if(schc.getXlBm().equals(m.get("lineCode"))) { | |
| 130 | + Long schId = schc.getId(); | |
| 131 | + ScheduleRealInfo sch = null; | |
| 132 | + if (schId != null) | |
| 133 | + sch = dayOfSchedule.get(schId); | |
| 134 | + | |
| 135 | + ScheduleRealInfo prev = dayOfSchedule.prev(sch); | |
| 136 | + List<Map> dzLists = carMonitor.carMonitor(prev.getXlBm(), prev.getXlDir(), prev.getZdzCode()); //信息发布接口 | |
| 137 | + for (Map mst : dzLists) { | |
| 138 | + //匹配到当前车辆 | |
| 139 | + if (basicData.nbbmCompanyPlateMap.get(prev.getClZbh()) != null && mst.get("terminal").equals(basicData.nbbmCompanyPlateMap.get(prev.getClZbh()).replaceAll("-", ""))) { | |
| 140 | + if (sch.getXlBm().equals(schc.getXlBm())) { | |
| 141 | + rtn.put("message", "非常抱歉,车辆因路上交通拥堵,预计还需要" + mst.get("sj").toString() + "抵达,请稍等片刻"); | |
| 142 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 143 | + return rtn; | |
| 144 | + } | |
| 143 | 145 | } |
| 144 | 146 | } |
| 145 | 147 | } |
| ... | ... | @@ -147,7 +149,7 @@ public class OutEntrance { |
| 147 | 149 | |
| 148 | 150 | |
| 149 | 151 | |
| 150 | - //筛选方向 | |
| 152 | + //筛选方向 -- 正常班次未到发车时间 | |
| 151 | 153 | List<ScheduleRealInfo> rs = dayOfSchedule.findByLineAndUpDown(ssLogger.getLineCode(),Integer.parseInt(ssLogger.getDir())); |
| 152 | 154 | if(rs.size()>0){ |
| 153 | 155 | //排序 | ... | ... |
src/main/java/com/bsth/data/zndd/ZnddThread.java
| ... | ... | @@ -62,12 +62,6 @@ public class ZnddThread extends Thread{ |
| 62 | 62 | //automaticSch.dfTz();//大间隔 |
| 63 | 63 | for (znddStatus zs : znddStatusList) { |
| 64 | 64 | if (zs.getOpenStatus() != null && zs.getOpenStatus().equals("0")) { |
| 65 | - //预案5个 | |
| 66 | - if (zs.getType().equals("fcjg")) { | |
| 67 | - automaticSch.dfTz(0); | |
| 68 | - logger.info("发车间隔执行完毕"); | |
| 69 | - } | |
| 70 | - | |
| 71 | 65 | if (zs.getType().equals("sftz")) { |
| 72 | 66 | automaticSch.sftz();//实发未发 |
| 73 | 67 | logger.info("实发执行完毕"); |
| ... | ... | @@ -76,26 +70,13 @@ public class ZnddThread extends Thread{ |
| 76 | 70 | automaticSch.sfCX();// 异常实发 - 实发撤销 |
| 77 | 71 | logger.info("异常实发执行完毕"); |
| 78 | 72 | } |
| 79 | - if (zs.getType().equals("zlcf")){ | |
| 80 | - automaticSch.drivresponse(); | |
| 81 | - logger.info("设备重发执行完毕"); | |
| 82 | - } | |
| 83 | - if (zs.getType().equals("wd")){ | |
| 84 | - automaticSch.wd(); | |
| 85 | - logger.info("误点执行完毕"); | |
| 86 | - } | |
| 87 | - if (zs.getType().equals("djg")){ | |
| 88 | - automaticSch.dfTz(1); | |
| 89 | - logger.info("行车大间隔执行完毕"); | |
| 90 | - } | |
| 91 | - if (zs.getType().equals("mz")){ | |
| 92 | - automaticSch.mz(); | |
| 93 | - logger.info("满载执行完毕"); | |
| 94 | - } | |
| 95 | - | |
| 73 | + if (zs.getType().equals("zlcf")){ | |
| 74 | + automaticSch.drivresponse(); | |
| 75 | + logger.info("设备重发执行完毕"); | |
| 76 | + } | |
| 96 | 77 | } |
| 97 | 78 | } |
| 98 | - }catch (Exception e){ | |
| 79 | + }catch (Throwable e){ | |
| 99 | 80 | logger.info("智能调度线程——————",e); |
| 100 | 81 | } |
| 101 | 82 | ... | ... |
src/main/java/com/bsth/data/zndd/ZnddTwoThread.java
0 → 100644
| 1 | +package com.bsth.data.zndd; | |
| 2 | + | |
| 3 | +import com.bsth.data.LineConfigData; | |
| 4 | +import com.bsth.data.gpsdata_v2.GpsRealData; | |
| 5 | +import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 6 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 7 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | +import com.bsth.entity.zndd.znddStatus; | |
| 9 | +import com.bsth.repository.StationRouteRepository; | |
| 10 | +import com.bsth.repository.zndd.ZnddStatusRepository; | |
| 11 | +import org.slf4j.Logger; | |
| 12 | +import org.slf4j.LoggerFactory; | |
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | +import org.springframework.stereotype.Component; | |
| 15 | + | |
| 16 | +import java.text.ParseException; | |
| 17 | +import java.text.SimpleDateFormat; | |
| 18 | +import java.util.Comparator; | |
| 19 | +import java.util.HashMap; | |
| 20 | +import java.util.List; | |
| 21 | +import java.util.Map; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * 调度预案 发车间隔、误点、大间隔、满载、大客流 | |
| 25 | + */ | |
| 26 | +@Component | |
| 27 | +public class ZnddTwoThread extends Thread{ | |
| 28 | + | |
| 29 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 30 | + /*@Autowired | |
| 31 | + StationPeopleLoggerRepository stationPeopleLoggerRepository;*/ | |
| 32 | + @Autowired | |
| 33 | + DayOfSchedule dayOfSchedule; | |
| 34 | + @Autowired | |
| 35 | + LineConfigData lineConfs; | |
| 36 | + @Autowired | |
| 37 | + GpsRealData gpsRealData; | |
| 38 | + @Autowired | |
| 39 | + StationRouteRepository stationRouteRepository; | |
| 40 | + @Autowired | |
| 41 | + OutEntrance outEntrance; | |
| 42 | + @Autowired | |
| 43 | + AutomaticSch automaticSch; | |
| 44 | + | |
| 45 | + @Autowired | |
| 46 | + ZnddStatusRepository znddStatusRepository; | |
| 47 | + | |
| 48 | + static Map<String,List> ZNDDTYPEMAP = new HashMap<>(); //已经推送过的检测 | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + private static SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 54 | + private static SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"); | |
| 55 | + private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 56 | + @Override | |
| 57 | + public void run() { | |
| 58 | + try { | |
| 59 | + List<znddStatus> znddStatusList = (List<znddStatus>) znddStatusRepository.findAll(); | |
| 60 | + | |
| 61 | + for (znddStatus zs : znddStatusList) { | |
| 62 | + if (zs.getOpenStatus() != null && zs.getOpenStatus().equals("0")) { | |
| 63 | + //预案5个 | |
| 64 | + if (zs.getType().equals("fcjg")) { | |
| 65 | + automaticSch.dfTz(0); | |
| 66 | + logger.info("发车间隔执行完毕"); | |
| 67 | + } | |
| 68 | + if (zs.getType().equals("wd")) { | |
| 69 | + automaticSch.wd(); | |
| 70 | + logger.info("误点执行完毕"); | |
| 71 | + } | |
| 72 | + if (zs.getType().equals("djg")) { | |
| 73 | + automaticSch.dfTz(1); | |
| 74 | + logger.info("行车大间隔执行完毕"); | |
| 75 | + } | |
| 76 | + if (zs.getType().equals("mz")) { | |
| 77 | + automaticSch.mz(); | |
| 78 | + logger.info("满载执行完毕"); | |
| 79 | + } | |
| 80 | + if (zs.getType().equals("desctwo")) { | |
| 81 | + automaticSch.TowdescSch(); | |
| 82 | + logger.info("末二班车"); | |
| 83 | + } | |
| 84 | + } | |
| 85 | + } | |
| 86 | + | |
| 87 | + | |
| 88 | + } catch (Exception e) { | |
| 89 | + logger.info("智能调度线程——————", e); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + //满载 | |
| 93 | + /* public void MZ(){ | |
| 94 | + try { | |
| 95 | + StringBuilder sb = HttpClientUtils.get(url); | |
| 96 | + List<Object> list = JSONArray.parseArray(String.valueOf(sb)); | |
| 97 | + for (Object b :list){ | |
| 98 | + Map m = (Map) b; | |
| 99 | + Integer num = Integer.parseInt(m.get("inside_num").toString()); | |
| 100 | + if (num >= 15){ //大间隔阈值 检测到超过15个人的时候推送 | |
| 101 | + ScheduleRealInfo sr = dayOfSchedule.executeCurr(m.get("nbbm").toString()); //查询当前车辆执行班次 | |
| 102 | + GpsEntity gps = gpsRealData.get(m.get("sbbh").toString()); | |
| 103 | + Map msp = new HashMap(); | |
| 104 | + msp.put("lineCode",m.get("xlbm")); | |
| 105 | + msp.put("lineName",m.get("xlmc")); | |
| 106 | + msp.put("stationName",gps.getStationName()); | |
| 107 | + msp.put("rqStr",sdfMonth.format(new Date())); | |
| 108 | + msp.put("rq",sdfHHmm.format(new Date())); | |
| 109 | + msp.put("type","MZ"); | |
| 110 | + msp.put("numType",num); | |
| 111 | + if (sr != null ) | |
| 112 | + msp.put("xlDir",sr.getXlDir()); | |
| 113 | + | |
| 114 | + if (gps != null ) | |
| 115 | + msp.put("station",gps.getStation().getCode()); | |
| 116 | + | |
| 117 | + ts(msp); | |
| 118 | + } | |
| 119 | + } | |
| 120 | + | |
| 121 | + }catch (Exception e){ | |
| 122 | + logger.error("满载检测接口出错-----------",e); | |
| 123 | + } | |
| 124 | + }*/ | |
| 125 | + public void ts(Map m) throws ParseException { | |
| 126 | + outEntrance.Znddjk(m);//测试推送 | |
| 127 | + } | |
| 128 | + /* public void ts(Map m) throws ParseException { | |
| 129 | + //记录存一下 --超过当前时间的是否推送? | |
| 130 | + String st = m.get("lineCode")+"_"+m.get("type")+"_"+m.get("rqStr"); | |
| 131 | + Long sj = sdf.parse(m.get("rqStr").toString() +" "+ m.get("rq")).getTime(); | |
| 132 | + List<Long> list = new ArrayList(); | |
| 133 | + //111_DJG_2024-06-24 | |
| 134 | + if (ZNDDTYPEMAP.get(st) != null ) { | |
| 135 | + list = ZNDDTYPEMAP.get(st); | |
| 136 | + int i = 0; | |
| 137 | + for (Long s : list){ | |
| 138 | + if (Math.abs(s - sj) > (60 * 60 * 1000)){ | |
| 139 | + i ++ ; | |
| 140 | + } | |
| 141 | + } | |
| 142 | + if (i == list.size()){ | |
| 143 | + list.add(sj); | |
| 144 | + ZNDDTYPEMAP.put(st,list);//存记录 | |
| 145 | + outEntrance.Znddjk(m);//推送 | |
| 146 | + } | |
| 147 | + return; | |
| 148 | + }else { | |
| 149 | + list.add(sj); | |
| 150 | + ZNDDTYPEMAP.put(st,list);//存记录 | |
| 151 | + outEntrance.Znddjk(m);//推送 | |
| 152 | + } | |
| 153 | + | |
| 154 | + } | |
| 155 | + | |
| 156 | +*/ | |
| 157 | + | |
| 158 | + /* //发车间隔 | |
| 159 | + public void FCJG(){ | |
| 160 | + try { | |
| 161 | + //无数据情况下 查看发车间隔配置数据是否正常bsth_c_calc_interval | |
| 162 | + List<CalcIntervalDetail> fcjgList = userCarCountHandler.calcLast(); | |
| 163 | + if (fcjgList!= null && !fcjgList.isEmpty()){ | |
| 164 | + for (CalcIntervalDetail cd : fcjgList){ | |
| 165 | + Map sp = new HashMap(); | |
| 166 | + sp.put("lineCode",cd.getLineCode()); | |
| 167 | + sp.put("lineName",cd.getLineName()); | |
| 168 | + sp.put("rqStr",cd.getDate()); | |
| 169 | + sp.put("rq",cd.getSjfc2()); | |
| 170 | + sp.put("type","FCJG"); | |
| 171 | + sp.put("xlDir",cd.getXlDir()); | |
| 172 | + sp.put("numType",cd.getSubTime()); | |
| 173 | + sp.put("fcsj",cd.getSjfc2()); | |
| 174 | + sp.put("stationName",cd.getStation()); | |
| 175 | + ts(sp); | |
| 176 | + } | |
| 177 | + } | |
| 178 | + }catch (Exception e){ | |
| 179 | + logger.error("发车间隔检测出现出错-----------",e); | |
| 180 | + } | |
| 181 | + } | |
| 182 | +*/ | |
| 183 | + | |
| 184 | + //转换 | |
| 185 | + public Map addStationPeople(ScheduleRealInfo info,String type,Long sst,String sj) throws ParseException{ | |
| 186 | + Map sp = new HashMap(); | |
| 187 | + sp.put("lineCode",info.getXlBm()); | |
| 188 | + sp.put("lineName",info.getXlName() ); | |
| 189 | + sp.put("rqStr",info.getScheduleDateStr()); | |
| 190 | + sp.put("rq",new java.sql.Date(sdf.parse((info.getScheduleDateStr()+" " + sj)).getTime())); //检测到时间 | |
| 191 | + sp.put("type",type); | |
| 192 | + sp.put("xlDir",info.getXlDir()); | |
| 193 | + sp.put("numType",sst); | |
| 194 | + return sp; | |
| 195 | + } | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + //排序 | |
| 200 | + public static class GpsComp implements Comparator<GpsEntity> { | |
| 201 | + @Override | |
| 202 | + public int compare(GpsEntity o1, GpsEntity o2) { | |
| 203 | + return Integer.parseInt(o1.getRemark()) - Integer.parseInt(o2.getRemark()); | |
| 204 | + } | |
| 205 | + } | |
| 206 | + | |
| 207 | +} | |
| 208 | + | ... | ... |
src/main/java/com/bsth/data/zndd/voice/VoiceUtil.java
| 1 | -package com.bsth.data.zndd.voice; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 5 | -import com.sun.media.sound.WaveFileReader; | |
| 6 | -import com.sun.media.sound.WaveFileWriter; | |
| 7 | -import org.slf4j.Logger; | |
| 8 | -import org.slf4j.LoggerFactory; | |
| 9 | -import org.springframework.util.Assert; | |
| 10 | -import org.springframework.util.StringUtils; | |
| 11 | -import org.vosk.LibVosk; | |
| 12 | -import org.vosk.LogLevel; | |
| 13 | -import org.vosk.Model; | |
| 14 | -import org.vosk.Recognizer; | |
| 15 | - | |
| 16 | -import javax.sound.sampled.*; | |
| 17 | -import java.io.*; | |
| 18 | -import java.nio.file.Files; | |
| 19 | -import java.nio.file.Paths; | |
| 20 | - | |
| 21 | -public class VoiceUtil { | |
| 22 | - /* @Value("${leenleda.vosk.model}") | |
| 23 | - private String VOSKMODELPATH;*/ | |
| 24 | - | |
| 25 | - Logger log = LoggerFactory.getLogger(this.getClass()); | |
| 26 | - public String getWord(String filePath) throws IOException, UnsupportedAudioFileException { | |
| 27 | - Assert.isTrue(StringUtils.hasLength("D:\\pcm\\vosk-model-small-cn-0.22"), "无效的VOS模块!"); | |
| 28 | - byte[] bytes = Files.readAllBytes(Paths.get(filePath)); | |
| 29 | - // 转换为16KHZ | |
| 30 | - reSamplingAndSave(bytes, filePath); | |
| 31 | - File f = new File(filePath); | |
| 32 | - RandomAccessFile rdf = null; | |
| 33 | - rdf = new RandomAccessFile(f, "r"); | |
| 34 | - log.info("声音尺寸:{}", toInt(read(rdf, 4, 4))); | |
| 35 | - log.info("音频格式:{}", toShort(read(rdf, 20, 2))); | |
| 36 | - short track = toShort(read(rdf, 22, 2)); | |
| 37 | - log.info("1 单声道 2 双声道: {}", track); | |
| 38 | - log.info("采样率、音频采样级别 16000 = 16KHz: {}", toInt(read(rdf, 24, 4))); | |
| 39 | - log.info("每秒波形的数据量:{}", toShort(read(rdf, 22, 2))); | |
| 40 | - log.info("采样帧的大小:{}", toShort(read(rdf, 32, 2))); | |
| 41 | - log.info("采样位数:{}", toShort(read(rdf, 34, 2))); | |
| 42 | - rdf.close(); | |
| 43 | - LibVosk.setLogLevel(LogLevel.WARNINGS); | |
| 44 | - try ( | |
| 45 | - Model model = new Model("D:\\pcm\\vosk-model-small-cn-0.22"); | |
| 46 | - InputStream ais = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream(filePath))); | |
| 47 | - // 采样率为音频采样率的声道倍数 | |
| 48 | - Recognizer recognizer = new Recognizer(model, 16000 * track)) { | |
| 49 | - | |
| 50 | - recognizer.setWords(true); | |
| 51 | - | |
| 52 | - String result = recognizer.getFinalResult(); | |
| 53 | - log.info("识别结果:{}", result); | |
| 54 | - if (StringUtils.hasLength(result)) { | |
| 55 | - JSONObject jsonObject = JSON.parseObject(result); | |
| 56 | - return jsonObject.getString("text").replace(" ", ""); | |
| 57 | - } | |
| 58 | - return ""; | |
| 59 | - } | |
| 60 | - | |
| 61 | - | |
| 62 | - | |
| 63 | - } | |
| 64 | - | |
| 65 | - public static int toInt(byte[] b) { | |
| 66 | - return (((b[3] & 0xff) << 24) + ((b[2] & 0xff) << 16) + ((b[1] & 0xff) << 8) + ((b[0] & 0xff) << 0)); | |
| 67 | - } | |
| 68 | - | |
| 69 | - public static short toShort(byte[] b) { | |
| 70 | - return (short) ((b[1] << 8) + (b[0] << 0)); | |
| 71 | - } | |
| 72 | - | |
| 73 | - public static byte[] read(RandomAccessFile rdf, int pos, int length) throws IOException { | |
| 74 | - rdf.seek(pos); | |
| 75 | - byte result[] = new byte[length]; | |
| 76 | - for (int i = 0; i < length; i++) { | |
| 77 | - result[i] = rdf.readByte(); | |
| 78 | - } | |
| 79 | - return result; | |
| 80 | - } | |
| 81 | - | |
| 82 | - public static void reSamplingAndSave(byte[] data, String path) throws IOException, UnsupportedAudioFileException { | |
| 83 | - WaveFileReader reader = new WaveFileReader(); | |
| 84 | - AudioInputStream audioIn = reader.getAudioInputStream(new ByteArrayInputStream(data)); | |
| 85 | - AudioFormat srcFormat = audioIn.getFormat(); | |
| 86 | - int targetSampleRate = 16000; | |
| 87 | - AudioFormat dstFormat = new AudioFormat(srcFormat.getEncoding(), | |
| 88 | - targetSampleRate, | |
| 89 | - srcFormat.getSampleSizeInBits(), | |
| 90 | - srcFormat.getChannels(), | |
| 91 | - srcFormat.getFrameSize(), | |
| 92 | - srcFormat.getFrameRate(), | |
| 93 | - srcFormat.isBigEndian()); | |
| 94 | - AudioInputStream convertedIn = AudioSystem.getAudioInputStream(dstFormat, audioIn); | |
| 95 | - File file = new File(path); | |
| 96 | - WaveFileWriter writer = new WaveFileWriter(); | |
| 97 | - writer.write(convertedIn, AudioFileFormat.Type.WAVE, file); | |
| 98 | - } | |
| 99 | -} | |
| 100 | 1 | \ No newline at end of file |
| 2 | +//package com.bsth.data.zndd.voice; | |
| 3 | +// | |
| 4 | +//import com.alibaba.fastjson.JSON; | |
| 5 | +//import com.alibaba.fastjson.JSONObject; | |
| 6 | +//import com.sun.media.sound.WaveFileReader; | |
| 7 | +//import com.sun.media.sound.WaveFileWriter; | |
| 8 | +//import org.slf4j.Logger; | |
| 9 | +//import org.slf4j.LoggerFactory; | |
| 10 | +//import org.springframework.util.Assert; | |
| 11 | +//import org.springframework.util.StringUtils; | |
| 12 | +//import org.vosk.LibVosk; | |
| 13 | +//import org.vosk.LogLevel; | |
| 14 | +//import org.vosk.Model; | |
| 15 | +//import org.vosk.Recognizer; | |
| 16 | +// | |
| 17 | +//import javax.sound.sampled.*; | |
| 18 | +//import java.io.*; | |
| 19 | +//import java.nio.file.Files; | |
| 20 | +//import java.nio.file.Paths; | |
| 21 | +// | |
| 22 | +//public class VoiceUtil { | |
| 23 | +// /* @Value("${leenleda.vosk.model}") | |
| 24 | +// private String VOSKMODELPATH;*/ | |
| 25 | +// | |
| 26 | +// Logger log = LoggerFactory.getLogger(this.getClass()); | |
| 27 | +// public String getWord(String filePath) throws IOException, UnsupportedAudioFileException { | |
| 28 | +// Assert.isTrue(StringUtils.hasLength("D:\\pcm\\vosk-model-small-cn-0.22"), "无效的VOS模块!"); | |
| 29 | +// byte[] bytes = Files.readAllBytes(Paths.get(filePath)); | |
| 30 | +// // 转换为16KHZ | |
| 31 | +// reSamplingAndSave(bytes, filePath); | |
| 32 | +// File f = new File(filePath); | |
| 33 | +// RandomAccessFile rdf = null; | |
| 34 | +// rdf = new RandomAccessFile(f, "r"); | |
| 35 | +// log.info("声音尺寸:{}", toInt(read(rdf, 4, 4))); | |
| 36 | +// log.info("音频格式:{}", toShort(read(rdf, 20, 2))); | |
| 37 | +// short track = toShort(read(rdf, 22, 2)); | |
| 38 | +// log.info("1 单声道 2 双声道: {}", track); | |
| 39 | +// log.info("采样率、音频采样级别 16000 = 16KHz: {}", toInt(read(rdf, 24, 4))); | |
| 40 | +// log.info("每秒波形的数据量:{}", toShort(read(rdf, 22, 2))); | |
| 41 | +// log.info("采样帧的大小:{}", toShort(read(rdf, 32, 2))); | |
| 42 | +// log.info("采样位数:{}", toShort(read(rdf, 34, 2))); | |
| 43 | +// rdf.close(); | |
| 44 | +// LibVosk.setLogLevel(LogLevel.WARNINGS); | |
| 45 | +// try ( | |
| 46 | +// Model model = new Model("D:\\pcm\\vosk-model-small-cn-0.22"); | |
| 47 | +// InputStream ais = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream(filePath))); | |
| 48 | +// // 采样率为音频采样率的声道倍数 | |
| 49 | +// Recognizer recognizer = new Recognizer(model, 16000 * track)) { | |
| 50 | +// | |
| 51 | +// recognizer.setWords(true); | |
| 52 | +// | |
| 53 | +// String result = recognizer.getFinalResult(); | |
| 54 | +// log.info("识别结果:{}", result); | |
| 55 | +// if (StringUtils.hasLength(result)) { | |
| 56 | +// JSONObject jsonObject = JSON.parseObject(result); | |
| 57 | +// return jsonObject.getString("text").replace(" ", ""); | |
| 58 | +// } | |
| 59 | +// return ""; | |
| 60 | +// } | |
| 61 | +// | |
| 62 | +// | |
| 63 | +// | |
| 64 | +// } | |
| 65 | +// | |
| 66 | +// public static int toInt(byte[] b) { | |
| 67 | +// return (((b[3] & 0xff) << 24) + ((b[2] & 0xff) << 16) + ((b[1] & 0xff) << 8) + ((b[0] & 0xff) << 0)); | |
| 68 | +// } | |
| 69 | +// | |
| 70 | +// public static short toShort(byte[] b) { | |
| 71 | +// return (short) ((b[1] << 8) + (b[0] << 0)); | |
| 72 | +// } | |
| 73 | +// | |
| 74 | +// public static byte[] read(RandomAccessFile rdf, int pos, int length) throws IOException { | |
| 75 | +// rdf.seek(pos); | |
| 76 | +// byte result[] = new byte[length]; | |
| 77 | +// for (int i = 0; i < length; i++) { | |
| 78 | +// result[i] = rdf.readByte(); | |
| 79 | +// } | |
| 80 | +// return result; | |
| 81 | +// } | |
| 82 | +// | |
| 83 | +// public static void reSamplingAndSave(byte[] data, String path) throws IOException, UnsupportedAudioFileException { | |
| 84 | +// WaveFileReader reader = new WaveFileReader(); | |
| 85 | +// AudioInputStream audioIn = reader.getAudioInputStream(new ByteArrayInputStream(data)); | |
| 86 | +// AudioFormat srcFormat = audioIn.getFormat(); | |
| 87 | +// int targetSampleRate = 16000; | |
| 88 | +// AudioFormat dstFormat = new AudioFormat(srcFormat.getEncoding(), | |
| 89 | +// targetSampleRate, | |
| 90 | +// srcFormat.getSampleSizeInBits(), | |
| 91 | +// srcFormat.getChannels(), | |
| 92 | +// srcFormat.getFrameSize(), | |
| 93 | +// srcFormat.getFrameRate(), | |
| 94 | +// srcFormat.isBigEndian()); | |
| 95 | +// AudioInputStream convertedIn = AudioSystem.getAudioInputStream(dstFormat, audioIn); | |
| 96 | +// File file = new File(path); | |
| 97 | +// WaveFileWriter writer = new WaveFileWriter(); | |
| 98 | +// writer.write(convertedIn, AudioFileFormat.Type.WAVE, file); | |
| 99 | +// }*/ | |
| 100 | +//} | |
| 101 | 101 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/entity/zndd/znddStatus.java
src/main/java/com/bsth/repository/zndd/ZnddStatusRepository.java
| ... | ... | @@ -2,10 +2,20 @@ package com.bsth.repository.zndd; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.entity.zndd.znddStatus; |
| 4 | 4 | import com.bsth.repository.BaseRepository; |
| 5 | +import org.springframework.data.jpa.repository.Modifying; | |
| 6 | +import org.springframework.data.jpa.repository.Query; | |
| 5 | 7 | import org.springframework.stereotype.Repository; |
| 8 | +import org.springframework.transaction.annotation.Transactional; | |
| 6 | 9 | |
| 7 | 10 | |
| 8 | 11 | @Repository |
| 9 | 12 | public interface ZnddStatusRepository extends BaseRepository<znddStatus, Integer> { |
| 13 | + | |
| 14 | + | |
| 15 | + @Transactional | |
| 16 | + @Modifying | |
| 17 | + @Query(value="UPDATE zndd_status SET " + | |
| 18 | + "open_status = ?2 WHERE id = ?1", nativeQuery=true) | |
| 19 | + void update(Integer id, Integer openStatus); | |
| 10 | 20 | |
| 11 | 21 | } | ... | ... |
src/main/java/com/bsth/service/zndd/ZnddStatusService.java
src/main/java/com/bsth/service/zndd/impl/ZnddStatusServiceImpl.java
| ... | ... | @@ -17,4 +17,8 @@ public class ZnddStatusServiceImpl extends BaseServiceImpl<znddStatus, Integer> |
| 17 | 17 | public void add(znddStatus zs){ |
| 18 | 18 | znddStatusRepository.save(zs); |
| 19 | 19 | } |
| 20 | + | |
| 21 | + public void update(Integer id,Integer openStatus){ | |
| 22 | + znddStatusRepository.update(id,openStatus); | |
| 23 | + } | |
| 20 | 24 | } | ... | ... |
src/main/resources/static/pages/permission/authorize_all/user_auth.html
| ... | ... | @@ -82,6 +82,7 @@ |
| 82 | 82 | <li><label><input class="uk-checkbox" type="checkbox" data-event="tts_config"> TTS</label></li> |
| 83 | 83 | <li><label><input class="uk-checkbox" type="checkbox" data-event="signal_state"> 信号标记</label></li> |
| 84 | 84 | <li><label><input class="uk-checkbox" type="checkbox" data-event="kl_config"> 客流信息</label></li> |
| 85 | + <li><label><input class="uk-checkbox" type="checkbox" data-event="zndd_status"> 智能调度开关</label></li> | |
| 85 | 86 | </ul> |
| 86 | 87 | </div> |
| 87 | 88 | <div> | ... | ... |
src/main/resources/static/real_control_v2/css/north.css
src/main/resources/static/real_control_v2/js/data/json/north_toolbar.json
src/main/resources/static/real_control_v2/js/north/toolbar.js
| ... | ... | @@ -147,6 +147,11 @@ var gb_northToolbar = (function () { |
| 147 | 147 | kl_config: function () { |
| 148 | 148 | open_modal('/real_control_v2/fragments/north/nav/kl_config.html', {}, modal_opts); |
| 149 | 149 | }, |
| 150 | + | |
| 151 | + zndd_status: function () { | |
| 152 | + open_modal('/real_control_v2/zndd/zndd_status.html', {}, modal_opts); | |
| 153 | + }, | |
| 154 | + | |
| 150 | 155 | // bcgxsj_config: function () { |
| 151 | 156 | // open_modal('/real_control_v2/fragments/north/nav/line_config/bcgxsj_config.html', {}, modal_opts); |
| 152 | 157 | // }, | ... | ... |
src/main/resources/static/real_control_v2/js/zndd/data_zndd.js
| 1 | 1 | var gb_dataZndd = (function (){ |
| 2 | 2 | |
| 3 | 3 | var max = 3; |
| 4 | + var max_s = 5; | |
| 4 | 5 | var $pop =$('.multi_plat_msg_pop_zndd'); |
| 5 | 6 | |
| 6 | 7 | var codes = { |
| ... | ... | @@ -11,6 +12,7 @@ var gb_dataZndd = (function (){ |
| 11 | 12 | 'DKL': '大客流', |
| 12 | 13 | 'YCSF':'异常实发', |
| 13 | 14 | 'SFTZ_1': '实发未发,信号异常', |
| 15 | + 'DESCTWO':'末二班车即将发车' | |
| 14 | 16 | }; |
| 15 | 17 | |
| 16 | 18 | |
| ... | ... | @@ -41,9 +43,15 @@ var gb_dataZndd = (function (){ |
| 41 | 43 | return; |
| 42 | 44 | } |
| 43 | 45 | |
| 46 | + if (data.type == 'DESCTWO'){ | |
| 47 | + configurecell(); | |
| 48 | + return; | |
| 49 | + } | |
| 50 | + | |
| 51 | + | |
| 44 | 52 | configure(); |
| 45 | 53 | |
| 46 | - //配置 随到随发 配置div方案 | |
| 54 | + //定时方案 | |
| 47 | 55 | function configure(){ |
| 48 | 56 | |
| 49 | 57 | var htmlStr = template('zndd_plat_msg_template_config', data); |
| ... | ... | @@ -65,6 +73,17 @@ var gb_dataZndd = (function (){ |
| 65 | 73 | |
| 66 | 74 | //gb_tts.audition(msg, 1.2); //语音播报 |
| 67 | 75 | } |
| 76 | + //无定时器方案 | |
| 77 | + function configurecell(){ | |
| 78 | + var htmlStr = template('zndd_plat_msg_template_config_s', data); | |
| 79 | + var items = $pop.find('.multi_plat_config_s'), | |
| 80 | + len = items.length; | |
| 81 | + | |
| 82 | + if (len >= max_s) | |
| 83 | + $pop.find('.multi_plat_config_s:lt(' + (len - max_s) + ')').remove(); | |
| 84 | + | |
| 85 | + $pop.append(htmlStr); | |
| 86 | + } | |
| 68 | 87 | |
| 69 | 88 | function configureDkl(){ |
| 70 | 89 | var htmlStr = template('zndd_plat_msg_template_dkl', data); | ... | ... |
src/main/resources/static/real_control_v2/main.html
| ... | ... | @@ -318,7 +318,22 @@ |
| 318 | 318 | </div> |
| 319 | 319 | </div> |
| 320 | 320 | </div> |
| 321 | +</script> | |
| 322 | +<script id="zndd_plat_msg_template_config_s" type="text/html"> | |
| 321 | 323 | |
| 324 | + <div class="multi_plat_config_s"> | |
| 325 | + <div class="msg-popup warning-color"> | |
| 326 | + <div class="msg-times" style="cursor: pointer;">×</div> | |
| 327 | + <div class="centerSpace msg-title"> | |
| 328 | + <div>自动调度消息-待确认</div> | |
| 329 | + <div class="msg-date-info">{{datarq}}</div> | |
| 330 | + </div> | |
| 331 | + <div class="popup-msg-content"> | |
| 332 | + <i class="fa fa-info-circle" aria-hidden="true"></i> | |
| 333 | + <span>{{lineName}} {{xlDir ==0 ?'上行':'下行'}} {{clzbh}} {{fcsj}} 出现 {{types}}</span> | |
| 334 | + </div> | |
| 335 | + </div> | |
| 336 | + </div> | |
| 322 | 337 | </script> |
| 323 | 338 | <script id="sjZ-divs-temp" type="text/html"> |
| 324 | 339 | |
| ... | ... | @@ -406,7 +421,7 @@ |
| 406 | 421 | </div> |
| 407 | 422 | <div class="popup-msg-contents" > |
| 408 | 423 | <button class="uk-button uk-button-primary images" data-image="{{image}}" value="{{dir}}">查看图片</button> |
| 409 | - <button class="uk-button uk-button-primary ljbc" data-uuid="{{uuid}}" data-linecode="{{sch.xlBm}}" data-id="{{sch.id}}">临加班次</button> | |
| 424 | + <button class="uk-button uk-button-primary ljbc" data-uuid="{{uuid}}" data-linecode="{{sch.xlBm}}" data-id="{{sch.id}}">选择方案</button> | |
| 410 | 425 | </div> |
| 411 | 426 | </div> |
| 412 | 427 | </div> | ... | ... |
src/main/resources/static/real_control_v2/zndd/type/dkl.html
| ... | ... | @@ -574,7 +574,7 @@ |
| 574 | 574 | <div class="uk-grid"> |
| 575 | 575 | <div class="uk-width-4-2"> |
| 576 | 576 | <div class="uk-form-row"> |
| 577 | - <h3>大客流情况</h3> | |
| 577 | + <h3 style="font-weight: 700;">大客流情况</h3> | |
| 578 | 578 | </div> |
| 579 | 579 | </div> |
| 580 | 580 | </div> |
| ... | ... | @@ -609,7 +609,7 @@ |
| 609 | 609 | <div class="uk-grid"> |
| 610 | 610 | <div class="uk-width-4-2"> |
| 611 | 611 | <div class="uk-form-row"> |
| 612 | - <h3>站点图片</h3> | |
| 612 | + <h3 style="font-weight: 700;">站点图片</h3> | |
| 613 | 613 | </div> |
| 614 | 614 | </div> |
| 615 | 615 | </div> |
| ... | ... | @@ -630,7 +630,7 @@ |
| 630 | 630 | <div class="uk-grid"> |
| 631 | 631 | <div class="uk-width-4-2"> |
| 632 | 632 | <div class="uk-form-row"> |
| 633 | - <label class="uk-form-labels" ><h3>空闲车辆/人员/班次结束时间</h3></label> | |
| 633 | + <label class="uk-form-labels" ><h3 style="font-weight: 700;">空闲车辆/人员/班次结束时间</h3></label> | |
| 634 | 634 | <div id="nbbms"> |
| 635 | 635 | </div> |
| 636 | 636 | </div> | ... | ... |
src/main/resources/static/real_control_v2/zndd/zndd_status.html
0 → 100644
| 1 | +<div class="uk-modal ct-form-modal" id="tts-config-modal"> | |
| 2 | + <div class="uk-modal-dialog" style="width: 530px;"> | |
| 3 | + <a href="" class="uk-modal-close uk-close"></a> | |
| 4 | + <div class="uk-modal-header"> | |
| 5 | + <h2>智能调度开关</h2></div> | |
| 6 | + | |
| 7 | + <p style="border-bottom: 1px solid #efefef;color: grey;padding-bottom: 9px;"> | |
| 8 | + <small> | |
| 9 | + <i class="uk-icon-question-circle"> </i> | |
| 10 | + 设置项将会调整所有线路配置,请谨慎调整</small> | |
| 11 | + </p> | |
| 12 | + | |
| 13 | + <div class="zndd_su ct-fixed-table"> | |
| 14 | + | |
| 15 | + <table class="ct-fixed-table uk-table uk-table-hover"> | |
| 16 | + <thead> | |
| 17 | + <tr> | |
| 18 | + <th style="width: 8%;">序号</th> | |
| 19 | + <th style="width: 10%;">名称</th> | |
| 20 | + <th style="width: 10%;">状态</th> | |
| 21 | + <th style="width: 8%;">开关</th> | |
| 22 | + </tr> | |
| 23 | + </thead> | |
| 24 | + <tbody> | |
| 25 | + </tbody> | |
| 26 | + </table> | |
| 27 | + </div> | |
| 28 | + | |
| 29 | + </div> | |
| 30 | + | |
| 31 | + <script> | |
| 32 | + (function() { | |
| 33 | + | |
| 34 | + list(); | |
| 35 | + })(); | |
| 36 | + | |
| 37 | + function list(){ | |
| 38 | + $(".zndd_su tbody").html(""); | |
| 39 | + $.get('/znnd_status/all', null, function(data){ | |
| 40 | + var tbodyHtml = template('zndd_list_all',{list:data}); | |
| 41 | + $(".zndd_su tbody").html(tbodyHtml); | |
| 42 | + }) | |
| 43 | + } | |
| 44 | + | |
| 45 | + | |
| 46 | + function opencloseStatus(el,status){ | |
| 47 | + debugger | |
| 48 | + var id = parseInt($(el).val()); | |
| 49 | + var json ={ | |
| 50 | + id : id, | |
| 51 | + openStatus : status | |
| 52 | + } | |
| 53 | + $.post('/znnd_status/update', json, function(data){ | |
| 54 | + if (data.status == "SUCCESS"){ | |
| 55 | + notify_succ('调整成功!'); | |
| 56 | + list(); | |
| 57 | + } | |
| 58 | + | |
| 59 | + }) | |
| 60 | + | |
| 61 | + } | |
| 62 | + | |
| 63 | + </script> | |
| 64 | + | |
| 65 | + <script type="text/html" id="zndd_list_all"> | |
| 66 | + {{each list as obj i}} | |
| 67 | + <tr> | |
| 68 | + <td>{{i +1 }}</td> | |
| 69 | + <td>{{obj.name}}</td> | |
| 70 | + <td> | |
| 71 | + {{if obj.openStatus == 0}} | |
| 72 | + <div class="uk-badge uk-badge-danger"> 开</div> | |
| 73 | + {{else}} | |
| 74 | + <div class="uk-badge uk-badge-danger"> 关</div> | |
| 75 | + {{/if}} | |
| 76 | + </td> | |
| 77 | + | |
| 78 | + <td> | |
| 79 | + {{if obj.openStatus == 0}} | |
| 80 | + <button class="btn btn-sm btn-outline filter-submit margin-bottom" value="{{obj.id}}" onclick="opencloseStatus(this,1)"> | |
| 81 | + <i class="fa fa-search" ></i> 关闭</button> | |
| 82 | + {{else}} | |
| 83 | + <button class="btn btn-sm btn-outline filter-submit margin-bottom" value="{{obj.id}}" onclick="opencloseStatus(this,0)"> | |
| 84 | + <i class="fa fa-search"></i> 开启</button> | |
| 85 | + {{/if}} | |
| 86 | + </td> | |
| 87 | + </tr> | |
| 88 | + {{/each}} | |
| 89 | + | |
| 90 | + </script> | |
| 91 | +</div> | |
| 92 | + | ... | ... |