Commit da438d8a9f7f21d63bcd0972ef90531df773c146
1 parent
b41e4c1a
update
Showing
25 changed files
with
363 additions
and
493 deletions
src/main/java/com/bsth/StartCommand.java
| ... | ... | @@ -8,7 +8,6 @@ import com.bsth.util.DateUtils; |
| 8 | 8 | import com.bsth.vehicle.common.CommonRefreshThread; |
| 9 | 9 | import com.bsth.vehicle.directive.thread.DirectivePersistenceThread; |
| 10 | 10 | import com.bsth.vehicle.directive.thread.FirstScheduleIssuedThread; |
| 11 | -import com.bsth.vehicle.directive.thread.RevertLineThread; | |
| 12 | 11 | import com.bsth.vehicle.gpsdata.GpsArrivalStationThread; |
| 13 | 12 | import com.bsth.vehicle.gpsdata.GpsRefreshThread; |
| 14 | 13 | import org.slf4j.Logger; |
| ... | ... | @@ -34,7 +33,7 @@ public class StartCommand implements CommandLineRunner{ |
| 34 | 33 | @Autowired |
| 35 | 34 | SecurityMetadataSourceService invocationSecurityMetadataSourceService; |
| 36 | 35 | |
| 37 | - public static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(8); | |
| 36 | + public static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(7); | |
| 38 | 37 | |
| 39 | 38 | @Autowired |
| 40 | 39 | GpsRefreshThread gpsRefreshThread; |
| ... | ... | @@ -50,8 +49,6 @@ public class StartCommand implements CommandLineRunner{ |
| 50 | 49 | GpsArrivalStationThread gpsArrivalStationThread; |
| 51 | 50 | @Autowired |
| 52 | 51 | FirstScheduleIssuedThread firstScheduleIssuedThread; |
| 53 | - @Autowired | |
| 54 | - RevertLineThread revertLineThread; | |
| 55 | 52 | |
| 56 | 53 | @Override |
| 57 | 54 | public void run(String... arg0){ |
| ... | ... | @@ -105,11 +102,6 @@ public class StartCommand implements CommandLineRunner{ |
| 105 | 102 | */ |
| 106 | 103 | //scheduler.scheduleWithFixedDelay(firstScheduleIssuedThread, 60 , 60 * 2, TimeUnit.SECONDS); |
| 107 | 104 | |
| 108 | - /** | |
| 109 | - * 还车线程(2分钟运行一次) | |
| 110 | - * 将借出的车刷回原线路 | |
| 111 | - */ | |
| 112 | - scheduler.scheduleWithFixedDelay(revertLineThread, 60 , 60 * 2 , TimeUnit.SECONDS); | |
| 113 | 105 | } catch (Exception e) { |
| 114 | 106 | e.printStackTrace(); |
| 115 | 107 | } | ... | ... |
src/main/java/com/bsth/controller/realcontrol/DeviceRevertLineController.java deleted
100644 → 0
| 1 | -package com.bsth.controller.realcontrol; | |
| 2 | - | |
| 3 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 4 | -import org.springframework.web.bind.annotation.RestController; | |
| 5 | - | |
| 6 | -import com.bsth.controller.BaseController; | |
| 7 | -import com.bsth.entity.realcontrol.DeviceRevertLine; | |
| 8 | - | |
| 9 | -@RestController | |
| 10 | -@RequestMapping("/deviceRevert") | |
| 11 | -public class DeviceRevertLineController extends BaseController<DeviceRevertLine, Integer>{ | |
| 12 | - | |
| 13 | -} |
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| ... | ... | @@ -56,8 +56,8 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 56 | 56 | */ |
| 57 | 57 | @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST) |
| 58 | 58 | public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks, |
| 59 | - @RequestParam String dfsj) { | |
| 60 | - return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj); | |
| 59 | + @RequestParam String dfsj, String clZbh, String jsy, String spy) { | |
| 60 | + return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, clZbh, jsy, spy); | |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| ... | ... | @@ -127,9 +127,9 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 127 | 127 | * 售票员 @throws |
| 128 | 128 | */ |
| 129 | 129 | @RequestMapping(value = "/adjust", method = RequestMethod.POST) |
| 130 | - public Map<String, Object> adjust(@RequestParam Long id, @RequestParam String nbbm, @RequestParam String jsy, | |
| 131 | - @RequestParam String spy) { | |
| 132 | - return scheduleRealInfoService.adjust(id, nbbm, jsy, spy); | |
| 130 | + public Map<String, Object> adjust(@RequestParam Long id, String nbbm, String jsy, | |
| 131 | + String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr) { | |
| 132 | + return scheduleRealInfoService.adjust(id, nbbm, jsy, spy, revertLine, borrowLine, borrowTimeStr, revertTimeStr); | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** | ... | ... |
src/main/java/com/bsth/entity/realcontrol/DeviceRevertLine.java deleted
100644 → 0
| 1 | -package com.bsth.entity.realcontrol; | |
| 2 | - | |
| 3 | -import java.util.Date; | |
| 4 | - | |
| 5 | -import javax.persistence.Column; | |
| 6 | -import javax.persistence.Entity; | |
| 7 | -import javax.persistence.GeneratedValue; | |
| 8 | -import javax.persistence.Id; | |
| 9 | -import javax.persistence.Table; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * | |
| 13 | - * @ClassName: VehicleRevertLine | |
| 14 | - * @Description: TODO(设备线路还原) | |
| 15 | - * @author PanZhao | |
| 16 | - * @date 2016年7月6日 下午5:31:13 | |
| 17 | - * | |
| 18 | - */ | |
| 19 | -@Entity | |
| 20 | -@Table(name = "bsth_v_line_revert") | |
| 21 | -public class DeviceRevertLine { | |
| 22 | - | |
| 23 | - @Id | |
| 24 | - @GeneratedValue | |
| 25 | - private Integer id; | |
| 26 | - | |
| 27 | - /** | |
| 28 | - * 车辆内部编码 | |
| 29 | - */ | |
| 30 | - private String nbbm; | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * 出借时间 | |
| 34 | - */ | |
| 35 | - private Long borrowTime; | |
| 36 | - | |
| 37 | - private String borrowTimeStr; | |
| 38 | - | |
| 39 | - /** | |
| 40 | - * 出借线路 | |
| 41 | - */ | |
| 42 | - private String borrowLine; | |
| 43 | - | |
| 44 | - /** | |
| 45 | - * 归还时间 | |
| 46 | - */ | |
| 47 | - private Long revertTime; | |
| 48 | - | |
| 49 | - private String revertTimeStr; | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * 归还线路 | |
| 53 | - */ | |
| 54 | - private String revertLine; | |
| 55 | - | |
| 56 | - /** 创建日期 */ | |
| 57 | - @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") | |
| 58 | - private Date createDate; | |
| 59 | - | |
| 60 | - /** 状态 1 已还车 */ | |
| 61 | - private Integer status; | |
| 62 | - | |
| 63 | - public Integer getId() { | |
| 64 | - return id; | |
| 65 | - } | |
| 66 | - | |
| 67 | - public void setId(Integer id) { | |
| 68 | - this.id = id; | |
| 69 | - } | |
| 70 | - | |
| 71 | - public String getNbbm() { | |
| 72 | - return nbbm; | |
| 73 | - } | |
| 74 | - | |
| 75 | - public void setNbbm(String nbbm) { | |
| 76 | - this.nbbm = nbbm; | |
| 77 | - } | |
| 78 | - | |
| 79 | - public String getBorrowLine() { | |
| 80 | - return borrowLine; | |
| 81 | - } | |
| 82 | - | |
| 83 | - public void setBorrowLine(String borrowLine) { | |
| 84 | - this.borrowLine = borrowLine; | |
| 85 | - } | |
| 86 | - | |
| 87 | - public String getRevertLine() { | |
| 88 | - return revertLine; | |
| 89 | - } | |
| 90 | - | |
| 91 | - public void setRevertLine(String revertLine) { | |
| 92 | - this.revertLine = revertLine; | |
| 93 | - } | |
| 94 | - | |
| 95 | - public Long getBorrowTime() { | |
| 96 | - return borrowTime; | |
| 97 | - } | |
| 98 | - | |
| 99 | - public void setBorrowTime(Long borrowTime) { | |
| 100 | - this.borrowTime = borrowTime; | |
| 101 | - } | |
| 102 | - | |
| 103 | - public String getBorrowTimeStr() { | |
| 104 | - return borrowTimeStr; | |
| 105 | - } | |
| 106 | - | |
| 107 | - public void setBorrowTimeStr(String borrowTimeStr) { | |
| 108 | - this.borrowTimeStr = borrowTimeStr; | |
| 109 | - } | |
| 110 | - | |
| 111 | - public Long getRevertTime() { | |
| 112 | - return revertTime; | |
| 113 | - } | |
| 114 | - | |
| 115 | - public void setRevertTime(Long revertTime) { | |
| 116 | - this.revertTime = revertTime; | |
| 117 | - } | |
| 118 | - | |
| 119 | - public String getRevertTimeStr() { | |
| 120 | - return revertTimeStr; | |
| 121 | - } | |
| 122 | - | |
| 123 | - public void setRevertTimeStr(String revertTimeStr) { | |
| 124 | - this.revertTimeStr = revertTimeStr; | |
| 125 | - } | |
| 126 | - | |
| 127 | - public Date getCreateDate() { | |
| 128 | - return createDate; | |
| 129 | - } | |
| 130 | - | |
| 131 | - public void setCreateDate(Date createDate) { | |
| 132 | - this.createDate = createDate; | |
| 133 | - } | |
| 134 | - | |
| 135 | - public Integer getStatus() { | |
| 136 | - return status; | |
| 137 | - } | |
| 138 | - | |
| 139 | - public void setStatus(Integer status) { | |
| 140 | - this.status = status; | |
| 141 | - } | |
| 142 | -} |
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
| ... | ... | @@ -151,8 +151,8 @@ public class ScheduleRealInfo { |
| 151 | 151 | |
| 152 | 152 | public void addRemarks(String remark){ |
| 153 | 153 | String newRem = this.getRemarks(); |
| 154 | - if(null == newRem) | |
| 155 | - newRem = ""; | |
| 154 | + if(null == newRem || newRem.trim() == "") | |
| 155 | + return; | |
| 156 | 156 | newRem += remark + ";"; |
| 157 | 157 | this.setRemarks(newRem); |
| 158 | 158 | } |
| ... | ... | @@ -587,6 +587,28 @@ public class ScheduleRealInfo { |
| 587 | 587 | /** |
| 588 | 588 | * |
| 589 | 589 | * @Title: setFcsjActualAll |
| 590 | + * @Description: TODO(设置实际发车时间) | |
| 591 | + * @throws | |
| 592 | + */ | |
| 593 | + public void setFcsjActualAll(Long t){ | |
| 594 | + this.fcsjActualTime = t; | |
| 595 | + this.fcsjActual = sdfHHmm.format(new Date(t)); | |
| 596 | + } | |
| 597 | + | |
| 598 | + /** | |
| 599 | + * | |
| 600 | + * @Title: setFcsjActualAll | |
| 601 | + * @Description: TODO(设置实际终点时间) | |
| 602 | + * @throws | |
| 603 | + */ | |
| 604 | + public void setZdsjActualAll(Long t){ | |
| 605 | + this.zdsjActualTime = t; | |
| 606 | + this.zdsjActual = sdfHHmm.format(new Date(t)); | |
| 607 | + } | |
| 608 | + | |
| 609 | + /** | |
| 610 | + * | |
| 611 | + * @Title: setFcsjActualAll | |
| 590 | 612 | * @Description: TODO(设置实际终点时间) |
| 591 | 613 | * @throws |
| 592 | 614 | */ | ... | ... |
src/main/java/com/bsth/repository/realcontrol/DeviceRevertLineRepository.java deleted
100644 → 0
| 1 | -package com.bsth.repository.realcontrol; | |
| 2 | - | |
| 3 | -import java.util.List; | |
| 4 | - | |
| 5 | -import org.springframework.data.jpa.repository.Query; | |
| 6 | -import org.springframework.stereotype.Repository; | |
| 7 | - | |
| 8 | -import com.bsth.entity.realcontrol.DeviceRevertLine; | |
| 9 | -import com.bsth.repository.BaseRepository; | |
| 10 | - | |
| 11 | -@Repository | |
| 12 | -public interface DeviceRevertLineRepository extends BaseRepository<DeviceRevertLine, Integer>{ | |
| 13 | - | |
| 14 | - @Query(value = "select dr from DeviceRevertLine dr where dr.revertTime > ?1 and dr.revertTime < ?2 and dr.status = ?3") | |
| 15 | - public List<DeviceRevertLine> findByDateAndStatus(Long st, Long et, Integer status); | |
| 16 | -} |
src/main/java/com/bsth/service/realcontrol/DeviceRevertLineService.java deleted
100644 → 0
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
| ... | ... | @@ -14,7 +14,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L |
| 14 | 14 | |
| 15 | 15 | Map<String, Collection<ScheduleRealInfo>> findByLines(String lines); |
| 16 | 16 | |
| 17 | - Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj); | |
| 17 | + Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj,String nbbm,String jsy,String spy); | |
| 18 | 18 | |
| 19 | 19 | Map<String, Object> destroy(String idsStr, int spaceAdjust, String remarks, String reason, int spaceNum); |
| 20 | 20 | |
| ... | ... | @@ -26,7 +26,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L |
| 26 | 26 | |
| 27 | 27 | List<Map<String, String>> sreachVehic(String nbbm); |
| 28 | 28 | |
| 29 | - Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy); | |
| 29 | + Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr); | |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * | ... | ... |
src/main/java/com/bsth/service/realcontrol/buffer/GetSchedulePlanThread.java
| ... | ... | @@ -48,13 +48,16 @@ public class GetSchedulePlanThread extends Thread{ |
| 48 | 48 | ScheduleBuffer.clear(); |
| 49 | 49 | |
| 50 | 50 | List<ScheduleRealInfo> realList = null; |
| 51 | - String dateStr = sdfyyyyMMdd.format(new Date()); | |
| 51 | + String dateStr = /*sdfyyyyMMdd.format(new Date())*/"2016-06-01"; | |
| 52 | 52 | Date cDate = sdfyyyyMMdd.parse(dateStr); |
| 53 | 53 | //查询数据库是否有今日排班 |
| 54 | 54 | int size = scheduleRealInfoRepository.countByDate(cDate); |
| 55 | 55 | if(size > 0){ |
| 56 | 56 | //从数据库恢复当日排班 |
| 57 | 57 | realList = scheduleRealInfoRepository.findByDate(cDate); |
| 58 | + logger.info("从数据库恢复当日排班 " + realList.size()); | |
| 59 | + //写入缓存 | |
| 60 | + ScheduleBuffer.init(realList); | |
| 58 | 61 | } |
| 59 | 62 | else{ |
| 60 | 63 | List<SchedulePlanInfo> list = schedulePlanInfoRepository.findByDate(cDate); |
| ... | ... | @@ -75,13 +78,12 @@ public class GetSchedulePlanThread extends Thread{ |
| 75 | 78 | item.setSpId(item.getId()); |
| 76 | 79 | item.setId(id ++);//设置ID |
| 77 | 80 | } |
| 81 | + | |
| 82 | + //写入缓存 | |
| 83 | + ScheduleBuffer.init(realList); | |
| 78 | 84 | //入库 |
| 79 | 85 | new BatchSaveUtils<ScheduleRealInfo>().saveList(realList, ScheduleRealInfo.class); |
| 80 | 86 | } |
| 81 | - | |
| 82 | - //写入缓存 | |
| 83 | - ScheduleBuffer.init(realList); | |
| 84 | - | |
| 85 | 87 | logger.info("获取当天实际排班计划数量:" + realList.size()); |
| 86 | 88 | }catch(Exception e){ |
| 87 | 89 | logger.error("",e); | ... | ... |
src/main/java/com/bsth/service/realcontrol/buffer/ScheduleBuffer.java
| ... | ... | @@ -108,7 +108,7 @@ public class ScheduleBuffer { |
| 108 | 108 | calcArrDateQd(code); |
| 109 | 109 | |
| 110 | 110 | //计算班次平均间隔 |
| 111 | - //calcAvgSpace(); | |
| 111 | + calcAvgSpace(); | |
| 112 | 112 | }catch(Exception e){ |
| 113 | 113 | logger.error("缓存排班数据失败...", e); |
| 114 | 114 | return -1; |
| ... | ... | @@ -148,7 +148,6 @@ public class ScheduleBuffer { |
| 148 | 148 | schSpaceMap.put(lineCode + "_0", sumUp / upList.size()); |
| 149 | 149 | schSpaceMap.put(lineCode + "_1", sumDown / downList.size()); |
| 150 | 150 | } |
| 151 | - System.out.println(schSpaceMap); | |
| 152 | 151 | } |
| 153 | 152 | |
| 154 | 153 | public static int put(ScheduleRealInfo sch){ |
| ... | ... | @@ -161,7 +160,10 @@ public class ScheduleBuffer { |
| 161 | 160 | vehLinkedMap.get(zbh).add(sch); |
| 162 | 161 | |
| 163 | 162 | //重新排序 |
| 164 | - Collections.sort(vehLinkedMap.get(zbh), scheduleComparator); | |
| 163 | + //Collections.sort(vehLinkedMap.get(zbh), scheduleComparator); | |
| 164 | + | |
| 165 | + //重新计算应到时间 | |
| 166 | + calcArrDateQd(vehLinkedMap.get(zbh)); | |
| 165 | 167 | return 0; |
| 166 | 168 | } |
| 167 | 169 | |
| ... | ... | @@ -213,6 +215,23 @@ public class ScheduleBuffer { |
| 213 | 215 | return finishLinkedMap.get(nbbm) == null ? 0 : finishLinkedMap.get(nbbm).size(); |
| 214 | 216 | } |
| 215 | 217 | |
| 218 | + public static void calcArrDateQd(List<ScheduleRealInfo> list){ | |
| 219 | + //排序 | |
| 220 | + Collections.sort(list, scheduleComparator); | |
| 221 | + int len = list.size(); | |
| 222 | + if(len == 0) | |
| 223 | + return; | |
| 224 | + | |
| 225 | + ScheduleRealInfo prve = list.get(0), curr; | |
| 226 | + for(int i = 1; i < len; i ++){ | |
| 227 | + curr = list.get(i); | |
| 228 | + if(prve.getZdzName().equals(curr.getQdzName())) | |
| 229 | + curr.setQdzArrDateJH(prve.getZdsj()); | |
| 230 | + | |
| 231 | + prve = curr; | |
| 232 | + } | |
| 233 | + } | |
| 234 | + | |
| 216 | 235 | /** |
| 217 | 236 | * |
| 218 | 237 | * @Title: calcArrDateQd |
| ... | ... | @@ -229,25 +248,8 @@ public class ScheduleBuffer { |
| 229 | 248 | |
| 230 | 249 | //链接班次 |
| 231 | 250 | Set<String> set = map.keySet(); |
| 232 | - List<ScheduleRealInfo> subList; | |
| 233 | - int len; | |
| 234 | - ScheduleRealInfo prve, curr; | |
| 235 | 251 | for(String k : set){ |
| 236 | - subList = map.get(k); | |
| 237 | - //排序 | |
| 238 | - Collections.sort(subList, scheduleComparator); | |
| 239 | - len = subList.size(); | |
| 240 | - if(len == 0) | |
| 241 | - continue; | |
| 242 | - | |
| 243 | - prve = subList.get(0); | |
| 244 | - for(int i = 1; i < len; i ++){ | |
| 245 | - curr = subList.get(i); | |
| 246 | - if(prve.getZdzName().equals(curr.getQdzName())) | |
| 247 | - curr.setQdzArrDateJH(prve.getZdsj()); | |
| 248 | - | |
| 249 | - prve = curr; | |
| 250 | - } | |
| 252 | + calcArrDateQd(map.get(k)); | |
| 251 | 253 | } |
| 252 | 254 | } |
| 253 | 255 | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/DeviceRevertLineServiceImpl.java deleted
100644 → 0
| 1 | -package com.bsth.service.realcontrol.impl; | |
| 2 | - | |
| 3 | -import java.text.ParseException; | |
| 4 | -import java.text.SimpleDateFormat; | |
| 5 | -import java.util.Date; | |
| 6 | -import java.util.Map; | |
| 7 | - | |
| 8 | -import org.slf4j.Logger; | |
| 9 | -import org.slf4j.LoggerFactory; | |
| 10 | -import org.springframework.stereotype.Service; | |
| 11 | - | |
| 12 | -import com.bsth.entity.realcontrol.DeviceRevertLine; | |
| 13 | -import com.bsth.service.impl.BaseServiceImpl; | |
| 14 | -import com.bsth.service.realcontrol.DeviceRevertLineService; | |
| 15 | - | |
| 16 | -@Service | |
| 17 | -public class DeviceRevertLineServiceImpl extends BaseServiceImpl<DeviceRevertLine, Integer> implements DeviceRevertLineService { | |
| 18 | - | |
| 19 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 20 | - | |
| 21 | - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm") | |
| 22 | - ,sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd") | |
| 23 | - ,sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 24 | - | |
| 25 | - @Override | |
| 26 | - public Map<String, Object> save(DeviceRevertLine t) { | |
| 27 | - | |
| 28 | - String dateStr = sdfyyyyMMdd.format(new Date()); | |
| 29 | - | |
| 30 | - try { | |
| 31 | - t.setStatus(0); | |
| 32 | - t.setBorrowTime(sdfyyyyMMddHHmm.parse(dateStr + " " + t.getBorrowTimeStr()).getTime()); | |
| 33 | - t.setRevertTime(sdfyyyyMMddHHmm.parse(dateStr + " " + t.getRevertTimeStr()).getTime()); | |
| 34 | - } catch (ParseException e) { | |
| 35 | - logger.error("", e); | |
| 36 | - } | |
| 37 | - return super.save(t); | |
| 38 | - } | |
| 39 | -} |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| 1 | 1 | package com.bsth.service.realcontrol.impl; |
| 2 | 2 | |
| 3 | 3 | import java.io.File; |
| 4 | +import java.text.ParseException; | |
| 4 | 5 | import java.text.SimpleDateFormat; |
| 5 | 6 | import java.util.ArrayList; |
| 6 | 7 | import java.util.Collection; |
| ... | ... | @@ -34,6 +35,7 @@ import com.bsth.service.impl.BaseServiceImpl; |
| 34 | 35 | import com.bsth.service.realcontrol.ScheduleRealInfoService; |
| 35 | 36 | import com.bsth.service.realcontrol.buffer.ScheduleBuffer; |
| 36 | 37 | import com.bsth.util.ReportUtils; |
| 38 | +import com.bsth.vehicle.BorrowCenter; | |
| 37 | 39 | import com.bsth.vehicle.common.CommonMapped; |
| 38 | 40 | import com.google.common.base.Splitter; |
| 39 | 41 | import com.google.common.collect.ArrayListMultimap; |
| ... | ... | @@ -52,6 +54,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 52 | 54 | |
| 53 | 55 | @Autowired |
| 54 | 56 | CarConfigInfoRepository carConfigInfoRepository; |
| 57 | + | |
| 58 | + @Autowired | |
| 59 | + BorrowCenter borrowCenter; | |
| 55 | 60 | |
| 56 | 61 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 57 | 62 | |
| ... | ... | @@ -71,7 +76,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 71 | 76 | } |
| 72 | 77 | |
| 73 | 78 | @Override |
| 74 | - public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj) { | |
| 79 | + public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String nbbm,String jsy,String spy) { | |
| 75 | 80 | Map<String, Object> map = new HashMap<>(); |
| 76 | 81 | try { |
| 77 | 82 | |
| ... | ... | @@ -79,12 +84,24 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 79 | 84 | schedule.setDfsjT(sdfMinute.parse(sdfMonth.format(new Date()) + " " + dfsj).getTime()); |
| 80 | 85 | schedule.setDfsj(dfsj); |
| 81 | 86 | schedule.addRemarks(remarks + ";"); |
| 87 | + schedule.setClZbh(nbbm); | |
| 88 | + if(jsy != null && jsy.indexOf("/") != -1){ | |
| 89 | + String[] jsyArray = jsy.split("/"); | |
| 90 | + schedule.setjGh(jsyArray[0]); | |
| 91 | + schedule.setjName(jsyArray[1]); | |
| 92 | + } | |
| 93 | + | |
| 94 | + if(spy != null && spy.indexOf("/") != -1){ | |
| 95 | + String[] spyArray = spy.split("/"); | |
| 96 | + schedule.setsGh(spyArray[0]); | |
| 97 | + schedule.setsName(spyArray[1]); | |
| 98 | + } | |
| 99 | + | |
| 82 | 100 | // 持久化到数据库 |
| 83 | 101 | ScheduleBuffer.persistentList.add(schedule); |
| 84 | 102 | |
| 85 | 103 | map.put("status", ResponseCode.SUCCESS); |
| 86 | - map.put("dfsj", dfsj); | |
| 87 | - map.put("remarks", schedule.getRemarks()); | |
| 104 | + map.put("t", schedule); | |
| 88 | 105 | } catch (Exception e) { |
| 89 | 106 | logger.error("", e); |
| 90 | 107 | map.put("status", ResponseCode.ERROR); |
| ... | ... | @@ -246,6 +263,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 246 | 263 | |
| 247 | 264 | // 加入缓存 |
| 248 | 265 | ScheduleBuffer.put(t); |
| 266 | + //将该临加之后的班次作为更新返回页面 | |
| 267 | + List<ScheduleRealInfo> list = ScheduleBuffer.vehLinkedMap.get(t.getClZbh()) | |
| 268 | + ,rsList = null; | |
| 269 | + | |
| 270 | + for(ScheduleRealInfo sch : list){ | |
| 271 | + if(sch.getId() == t.getId()) | |
| 272 | + rsList = new ArrayList<>(); | |
| 273 | + | |
| 274 | + if(rsList != null) | |
| 275 | + rsList.add(sch); | |
| 276 | + } | |
| 277 | + | |
| 278 | + map.put("ups", rsList); | |
| 249 | 279 | return map; |
| 250 | 280 | } |
| 251 | 281 | |
| ... | ... | @@ -281,10 +311,11 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 281 | 311 | } |
| 282 | 312 | |
| 283 | 313 | @Override |
| 284 | - public Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy) { | |
| 314 | + public Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr) { | |
| 285 | 315 | // 班次 |
| 286 | 316 | ScheduleRealInfo schedule = ScheduleBuffer.pkSchedulMap.get(id); |
| 287 | 317 | |
| 318 | + String rq = sdfMonth.format(new Date()); | |
| 288 | 319 | // 换车 |
| 289 | 320 | if (!StringUtils.isBlank(nbbm)) { |
| 290 | 321 | adjustCar(schedule, nbbm); |
| ... | ... | @@ -302,6 +333,26 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 302 | 333 | tempArray = Splitter.on("/").splitToList(spy); |
| 303 | 334 | adjustConductor(schedule, tempArray.get(0), tempArray.get(1)); |
| 304 | 335 | } |
| 336 | + | |
| 337 | + if(borrowLine != null && borrowTimeStr != null){ | |
| 338 | + try { | |
| 339 | + //跨线路借车 | |
| 340 | + Long t = sdfMinute.parse(rq + " " + borrowTimeStr).getTime(); | |
| 341 | + borrowCenter.put(nbbm, borrowLine, 0, t); | |
| 342 | + } catch (ParseException e) { | |
| 343 | + e.printStackTrace(); | |
| 344 | + } | |
| 345 | + } | |
| 346 | + | |
| 347 | + if(revertLine != null && revertTimeStr != null){ | |
| 348 | + //定时还车 | |
| 349 | + try { | |
| 350 | + Long t = sdfMinute.parse(rq + " " + revertTimeStr).getTime(); | |
| 351 | + borrowCenter.put(nbbm, revertLine, 1, t); | |
| 352 | + } catch (ParseException e) { | |
| 353 | + e.printStackTrace(); | |
| 354 | + } | |
| 355 | + } | |
| 305 | 356 | |
| 306 | 357 | ScheduleBuffer.persistentList.add(schedule); |
| 307 | 358 | |
| ... | ... | @@ -394,7 +445,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 394 | 445 | sch.setFcsjActualTime(sdfMinute.parse(rq + " " + fcsjActual).getTime()); |
| 395 | 446 | sch.setFcsjActual(fcsjActual); |
| 396 | 447 | sch.addRemarks(remarks); |
| 397 | - | |
| 448 | + //改变状态 | |
| 449 | + if(sch.getZdsjActual() == null) | |
| 450 | + sch.setStatus(1); | |
| 451 | + | |
| 398 | 452 | ScheduleBuffer.persistentList.add(sch); |
| 399 | 453 | rs.put("status", ResponseCode.SUCCESS); |
| 400 | 454 | rs.put("t", sch); |
| ... | ... | @@ -524,8 +578,20 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 524 | 578 | sch.setBcType(bcType); |
| 525 | 579 | sch.setClZbh(clZbh); |
| 526 | 580 | sch.setFcsjAll(fcsj); |
| 527 | - sch.setFcsjActualAll(fcsjActual); | |
| 528 | - sch.setZdsjActualAll(zdsjActual); | |
| 581 | + if(null == fcsjActual){ | |
| 582 | + sch.setFcsjActual(null); | |
| 583 | + sch.setFcsjActualTime(null); | |
| 584 | + } | |
| 585 | + else | |
| 586 | + sch.setFcsjActualAll(fcsjActual); | |
| 587 | + | |
| 588 | + if(null == zdsjActual){ | |
| 589 | + sch.setZdsjActual(null); | |
| 590 | + sch.setZdsjActualTime(null); | |
| 591 | + } | |
| 592 | + else | |
| 593 | + sch.setZdsjActualAll(zdsjActual); | |
| 594 | + | |
| 529 | 595 | sch.setjGh(jsy[0]); |
| 530 | 596 | sch.setjName(jsy[1]); |
| 531 | 597 | sch.setsGh(spy[0]); | ... | ... |
src/main/java/com/bsth/vehicle/BorrowCenter.java
0 → 100644
| 1 | +package com.bsth.vehicle; | |
| 2 | + | |
| 3 | +import java.util.concurrent.Executors; | |
| 4 | +import java.util.concurrent.ScheduledExecutorService; | |
| 5 | +import java.util.concurrent.TimeUnit; | |
| 6 | + | |
| 7 | +import org.slf4j.Logger; | |
| 8 | +import org.slf4j.LoggerFactory; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | +import com.bsth.vehicle.directive.service.DirectiveService; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * | |
| 16 | + * @ClassName: BorrowCenter | |
| 17 | + * @Description: TODO(借还车中心^_^) | |
| 18 | + * @author PanZhao | |
| 19 | + * @date 2016年7月12日 下午11:49:36 | |
| 20 | + * | |
| 21 | + */ | |
| 22 | +@Component | |
| 23 | +public class BorrowCenter { | |
| 24 | + | |
| 25 | + ScheduledExecutorService scheduler; | |
| 26 | + | |
| 27 | + @Autowired | |
| 28 | + DirectiveService directiveService; | |
| 29 | + | |
| 30 | + Logger logger = LoggerFactory.getLogger(BorrowCenter.class); | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 构造函数 | |
| 34 | + */ | |
| 35 | + public BorrowCenter() { | |
| 36 | + scheduler = Executors.newScheduledThreadPool(15); | |
| 37 | + } | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * | |
| 41 | + * @Title: put | |
| 42 | + * @param @param nbbm 车辆 | |
| 43 | + * @param @param lineCode 线路代码 | |
| 44 | + * @param @param type 0 借出,1归还 | |
| 45 | + * @param @param time 时间 | |
| 46 | + * @throws | |
| 47 | + */ | |
| 48 | + public void put(String nbbm, Integer lineCode, int type, Long time){ | |
| 49 | + Long t = System.currentTimeMillis(); | |
| 50 | + if(t >= time){ | |
| 51 | + //立即执行 | |
| 52 | + new Thread(new ChangeThread(nbbm, lineCode, type)).start(); | |
| 53 | + } | |
| 54 | + else{ | |
| 55 | + //定时线程 | |
| 56 | + scheduler.schedule(new ChangeThread(nbbm, lineCode, type), (time - t) / 1000, TimeUnit.SECONDS); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + | |
| 60 | + public class ChangeThread implements Runnable{ | |
| 61 | + String nbbm; | |
| 62 | + Integer lineCode; | |
| 63 | + int type; | |
| 64 | + | |
| 65 | + public ChangeThread(String nbbm, Integer lineCode, int type) { | |
| 66 | + this.nbbm = nbbm; | |
| 67 | + this.lineCode = lineCode; | |
| 68 | + this.type = type; | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public void run() { | |
| 73 | + logger.info("nbbm " + (type==0?"借出":"归还") + "线路代码 " + lineCode); | |
| 74 | + directiveService.lineChange(nbbm, lineCode); | |
| 75 | + } | |
| 76 | + } | |
| 77 | +} | ... | ... |
src/main/java/com/bsth/vehicle/directive/thread/RevertLineThread.java deleted
100644 → 0
| 1 | -package com.bsth.vehicle.directive.thread; | |
| 2 | - | |
| 3 | -import java.util.List; | |
| 4 | - | |
| 5 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 6 | -import org.springframework.stereotype.Component; | |
| 7 | - | |
| 8 | -import com.bsth.entity.realcontrol.DeviceRevertLine; | |
| 9 | -import com.bsth.repository.realcontrol.DeviceRevertLineRepository; | |
| 10 | -import com.bsth.vehicle.directive.service.DirectiveService; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * | |
| 14 | - * @ClassName: DeviceRevertLineThread | |
| 15 | - * @Description: TODO(设备线路还原线程, 将借出的车还原到原线路) | |
| 16 | - * @author PanZhao | |
| 17 | - * @date 2016年7月7日 上午11:30:38 | |
| 18 | - * | |
| 19 | - */ | |
| 20 | -@Component | |
| 21 | -public class RevertLineThread extends Thread{ | |
| 22 | - | |
| 23 | - @Autowired | |
| 24 | - DeviceRevertLineRepository deviceRevertLineRepository; | |
| 25 | - | |
| 26 | - @Autowired | |
| 27 | - DirectiveService directiveService; | |
| 28 | - | |
| 29 | - @Override | |
| 30 | - public void run() { | |
| 31 | - Long et = System.currentTimeMillis() | |
| 32 | - ,st = et - (1000 * 60 * 5); | |
| 33 | - | |
| 34 | - List<DeviceRevertLine> list = deviceRevertLineRepository.findByDateAndStatus(st, et, 0); | |
| 35 | - | |
| 36 | - if(list.size() == 0) | |
| 37 | - return; | |
| 38 | - | |
| 39 | - int code; | |
| 40 | - for(DeviceRevertLine revertLine : list){ | |
| 41 | - //还车 | |
| 42 | - code = directiveService.lineChange(revertLine.getNbbm(), Integer.parseInt(revertLine.getRevertLine())); | |
| 43 | - | |
| 44 | - if(code == 0){ | |
| 45 | - //改变状态 | |
| 46 | - revertLine.setStatus(1); | |
| 47 | - deviceRevertLineRepository.save(revertLine); | |
| 48 | - } | |
| 49 | - } | |
| 50 | - } | |
| 51 | -} |
src/main/java/com/bsth/vehicle/gpsdata/GpsArrivalStationThread.java
| ... | ... | @@ -9,7 +9,6 @@ import java.util.ArrayList; |
| 9 | 9 | import java.util.Calendar; |
| 10 | 10 | import java.util.Date; |
| 11 | 11 | import java.util.HashSet; |
| 12 | -import java.util.Iterator; | |
| 13 | 12 | import java.util.LinkedList; |
| 14 | 13 | import java.util.List; |
| 15 | 14 | import java.util.Set; |
| ... | ... | @@ -50,7 +49,7 @@ public class GpsArrivalStationThread extends Thread{ |
| 50 | 49 | @Autowired |
| 51 | 50 | RealControlSocketHandler socketHandler; |
| 52 | 51 | |
| 53 | - private static int diff = 1000 * 60 * 20; | |
| 52 | + Long diff = 1000 * 60 * 20L; | |
| 54 | 53 | |
| 55 | 54 | @Override |
| 56 | 55 | public void run() { |
| ... | ... | @@ -70,8 +69,7 @@ public class GpsArrivalStationThread extends Thread{ |
| 70 | 69 | |
| 71 | 70 | List<ArrivalInfo> rsList = null; |
| 72 | 71 | LinkedList<ScheduleRealInfo> linked = null; |
| 73 | - int[] status; | |
| 74 | - ScheduleRealInfo sch; | |
| 72 | + ArrivalInfo[] status; | |
| 75 | 73 | for(String nbbm : set){ |
| 76 | 74 | rsList = GpsArrivalDataBuffer.pops(nbbm); |
| 77 | 75 | //和该车辆未执行班次进行匹配 |
| ... | ... | @@ -79,28 +77,43 @@ public class GpsArrivalStationThread extends Thread{ |
| 79 | 77 | |
| 80 | 78 | if(null == linked || linked.size() == 0) |
| 81 | 79 | continue; |
| 82 | - //第一个未执行班次 | |
| 83 | - sch = linked.getFirst(); | |
| 84 | 80 | |
| 85 | - //匹配结果 | |
| 86 | - status = match(rsList, sch); | |
| 87 | - } | |
| 88 | - // | |
| 89 | - /*GpsArrivalDataBuffer.putAll(list); | |
| 90 | - //实际到离站和计划排班相匹配 | |
| 91 | - | |
| 92 | - Set<String> keySet = GpsArrivalDataBuffer.allMap.keySet(); | |
| 93 | - System.out.println("开始..."); | |
| 94 | - List<ScheduleRealInfo> schList; | |
| 95 | - for(String key : keySet){ | |
| 96 | - schList = extractSched(ScheduleBuffer.vehLinkedMap.get(key)); | |
| 97 | - if(null != schList) | |
| 98 | - match(GpsArrivalDataBuffer.allMap.get(key), schList); | |
| 81 | + try{ | |
| 82 | + for(ScheduleRealInfo schedule : linked){ | |
| 83 | + //匹配结果 | |
| 84 | + status = match(rsList, schedule); | |
| 85 | + | |
| 86 | + //发车 | |
| 87 | + if(status[0] != null){ | |
| 88 | + //班次状态改为正在执行 | |
| 89 | + schedule.setStatus(1); | |
| 90 | + ScheduleBuffer.persistentList.add(schedule); | |
| 91 | + //推送到页面 | |
| 92 | + sendFcsj(schedule); | |
| 93 | + | |
| 94 | + rsList.remove(status[0]); | |
| 95 | + } | |
| 96 | + | |
| 97 | + //到达终点 | |
| 98 | + if(status[1] != null){ | |
| 99 | + //完成当前班次 | |
| 100 | + ScheduleRealInfo nextSch = ScheduleBuffer.finishSch(schedule); | |
| 101 | + //到达终点,发送下一班次的调度指令 | |
| 102 | + int finish = ScheduleBuffer.getFinishSchNo(nextSch.getClZbh()); | |
| 103 | + directiveService.send60Dispatch(nextSch, finish); | |
| 104 | + //推送到页面 | |
| 105 | + sendZdsj(schedule, nextSch, finish); | |
| 106 | + | |
| 107 | + rsList.remove(status[1]); | |
| 108 | + } | |
| 109 | + } | |
| 110 | + }catch(Exception e){ | |
| 111 | + e.printStackTrace(); | |
| 112 | + } | |
| 99 | 113 | } |
| 100 | - System.out.println("结束...");*/ | |
| 101 | 114 | } |
| 102 | 115 | |
| 103 | - public int[] match(List<ArrivalInfo> arrList, ScheduleRealInfo sch){ | |
| 116 | + public ArrivalInfo[] match(List<ArrivalInfo> arrList, ScheduleRealInfo sch){ | |
| 104 | 117 | //进出分组 |
| 105 | 118 | List<ArrivalInfo> in = new ArrayList<>(), out = new ArrayList<>(); |
| 106 | 119 | for(ArrivalInfo arr : arrList){ |
| ... | ... | @@ -109,95 +122,46 @@ public class GpsArrivalStationThread extends Thread{ |
| 109 | 122 | else |
| 110 | 123 | out.add(arr); |
| 111 | 124 | } |
| 112 | - int s1 = 0, s2 = 0; | |
| 125 | + ArrivalInfo a1 = null, a2 = null; | |
| 113 | 126 | //匹配发车时间 |
| 114 | - if(sch.getFcsjActual() == null) | |
| 115 | - s1 = matchOut(arrList, sch); | |
| 127 | + if(sch.getFcsjActual() == null && sch.getFcsj() != null) | |
| 128 | + a1 = matchOut(out, sch); | |
| 116 | 129 | |
| 117 | 130 | //匹配终点时间 |
| 118 | - if(sch.getZdsjActual() == null) | |
| 119 | - s2 = matchIn(arrList, sch); | |
| 131 | + if(sch.getZdsjActual() == null && sch.getZdsj() != null) | |
| 132 | + a2 = matchIn(in, sch); | |
| 120 | 133 | |
| 121 | - return new int[]{s1,s2}; | |
| 134 | + return new ArrivalInfo[]{a1,a2}; | |
| 122 | 135 | } |
| 123 | 136 | |
| 124 | - public int matchOut(List<ArrivalInfo> arrList, ScheduleRealInfo sch){ | |
| 125 | - | |
| 137 | + public ArrivalInfo matchOut(List<ArrivalInfo> arrList, ScheduleRealInfo sch){ | |
| 138 | + Long space = /*ScheduleBuffer.schSpaceMap.get(sch.getXlBm() + "_" + sch.getXlDir())*/diff; | |
| 126 | 139 | for(ArrivalInfo arr : arrList){ |
| 127 | - if(arr.getStopNo().equals(sch.getQdzCode())){ | |
| 140 | + if(arr.getStopNo().equals(sch.getQdzCode()) | |
| 141 | + && Math.abs((arr.getTs() - sch.getFcsjT())) < space){ | |
| 142 | + sch.setFcsjActualAll(arr.getTs()); | |
| 143 | + | |
| 144 | + return arr; | |
| 128 | 145 | |
| 129 | 146 | } |
| 130 | 147 | } |
| 131 | - return 0; | |
| 148 | + return null; | |
| 132 | 149 | } |
| 133 | 150 | |
| 134 | - public int matchIn(List<ArrivalInfo> arrList, ScheduleRealInfo sch){ | |
| 135 | - return 0; | |
| 136 | - } | |
| 137 | - | |
| 138 | - | |
| 139 | - /** | |
| 140 | - * | |
| 141 | - * @Title: match | |
| 142 | - * @Description: TODO(实际和计划进行匹配) | |
| 143 | - * @param @param arrList 实际GPS到离站链表 | |
| 144 | - * @param @param schList 计划排班链表 | |
| 145 | - * @throws | |
| 146 | - */ | |
| 147 | - /*public void match(List<ArrivalInfo> arrList, List<ScheduleRealInfo> schList){ | |
| 148 | - Iterator<ScheduleRealInfo> schIterator = schList.iterator(); | |
| 149 | - | |
| 150 | - while(schIterator.hasNext()) | |
| 151 | - match(schIterator.next(), arrList); | |
| 152 | - }*/ | |
| 153 | - | |
| 154 | - | |
| 155 | - /*public void match(ScheduleRealInfo scInfo, List<ArrivalInfo> arrList){ | |
| 151 | + public ArrivalInfo matchIn(List<ArrivalInfo> arrList, ScheduleRealInfo sch){ | |
| 152 | + Long space = /*ScheduleBuffer.schSpaceMap.get(sch.getXlBm() + "_" + sch.getXlDir())*/diff; | |
| 156 | 153 | for(ArrivalInfo arr : arrList){ |
| 157 | - match(scInfo, arr); | |
| 158 | - } | |
| 159 | - }*/ | |
| 160 | - | |
| 161 | -/* public void match(ScheduleRealInfo scInfo, ArrivalInfo arr){ | |
| 162 | - try{ | |
| 163 | - //匹配起点 | |
| 164 | - matchStart(scInfo, arr); | |
| 165 | - | |
| 166 | - //匹配终点 | |
| 167 | - matchEnd(scInfo, arr); | |
| 168 | - }catch(Exception e){ | |
| 169 | - e.printStackTrace(); | |
| 170 | - } | |
| 171 | - }*/ | |
| 172 | - | |
| 173 | - /** | |
| 174 | - * | |
| 175 | - * @Title: matchStart | |
| 176 | - * @Description: TODO(匹配起点 出站时间) | |
| 177 | - * @param @param scInfo | |
| 178 | - * @throws | |
| 179 | - */ | |
| 180 | - public void matchStart(ScheduleRealInfo scInfo, ArrivalInfo arr){ | |
| 181 | - if(scInfo.getFcsjT() == null | |
| 182 | - || arr.getInOut() != 1 || scInfo.getFcsjActual() != null) | |
| 183 | - return; | |
| 184 | - | |
| 185 | - Long ts = arr.getTs(); | |
| 186 | - //起点站和发车时间比比较 | |
| 187 | - if(scInfo.getQdzCode().equals(arr.getStopNo()) | |
| 188 | - && Math.abs(scInfo.getFcsjT() - ts) < diff){ | |
| 189 | - scInfo.setFcsjActualTime(ts); | |
| 190 | - scInfo.setFcsjActual(sdf.format(ts)); | |
| 191 | - | |
| 192 | - System.out.println("成功匹配一个起点..."); | |
| 193 | - //班次状态改为正在执行 | |
| 194 | - scInfo.setStatus(1); | |
| 195 | - ScheduleBuffer.persistentList.add(scInfo); | |
| 196 | - //推送到页面 | |
| 197 | - sendFcsj(scInfo); | |
| 154 | + if(arr.getStopNo().equals(sch.getZdzCode()) | |
| 155 | + && Math.abs((arr.getTs() - sch.getZdsjT())) < space){ | |
| 156 | + sch.setZdsjActualAll(arr.getTs()); | |
| 157 | + | |
| 158 | + return arr; | |
| 159 | + } | |
| 198 | 160 | } |
| 161 | + return null; | |
| 199 | 162 | } |
| 200 | 163 | |
| 164 | + | |
| 201 | 165 | /** |
| 202 | 166 | * @Title: sendFcsj |
| 203 | 167 | * @Description: TODO(推送发车信息) |
| ... | ... | @@ -213,35 +177,6 @@ public class GpsArrivalStationThread extends Thread{ |
| 213 | 177 | } |
| 214 | 178 | |
| 215 | 179 | /** |
| 216 | - * | |
| 217 | - * @Title: matchEnd | |
| 218 | - * @Description: TODO(匹配终点 进站时间) | |
| 219 | - * @throws | |
| 220 | - */ | |
| 221 | - public void matchEnd(ScheduleRealInfo scInfo, ArrivalInfo arr){ | |
| 222 | - if(scInfo.getZdsjT() == null | |
| 223 | - || arr.getInOut() != 0 || scInfo.getZdsjActual() != null) | |
| 224 | - return; | |
| 225 | - | |
| 226 | - Long ts = arr.getTs(); | |
| 227 | - //终点站和发车时间比较 | |
| 228 | - if(scInfo.getZdzCode().equals(arr.getStopNo()) | |
| 229 | - && Math.abs(scInfo.getZdsjT() - ts) < diff){ | |
| 230 | - scInfo.setZdsjActualTime(ts); | |
| 231 | - scInfo.setZdsjActual(sdf.format(ts)); | |
| 232 | - | |
| 233 | - System.out.println("成功匹配一个终点..."); | |
| 234 | - //完成当前班次 | |
| 235 | - ScheduleRealInfo nextSch = ScheduleBuffer.finishSch(scInfo); | |
| 236 | - //到达终点,发送下一班次的调度指令 | |
| 237 | - int finish = ScheduleBuffer.getFinishSchNo(nextSch.getClZbh()); | |
| 238 | - directiveService.send60Dispatch(nextSch, finish); | |
| 239 | - //推送到页面 | |
| 240 | - sendZdsj(scInfo, nextSch, finish); | |
| 241 | - } | |
| 242 | - } | |
| 243 | - | |
| 244 | - /** | |
| 245 | 180 | * @Title: sendFcsj |
| 246 | 181 | * @Description: TODO(推送到达终点时间) |
| 247 | 182 | * @param @param schedule 班次 | ... | ... |
src/main/resources/application-dev.properties
| ... | ... | @@ -8,9 +8,9 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy |
| 8 | 8 | spring.jpa.database= MYSQL |
| 9 | 9 | spring.jpa.show-sql= true |
| 10 | 10 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver |
| 11 | -spring.datasource.url= jdbc:mysql://192.168.168.201:3306/control | |
| 11 | +spring.datasource.url= jdbc:mysql://127.0.0.1:3306/control | |
| 12 | 12 | spring.datasource.username= root |
| 13 | -spring.datasource.password= 123456 | |
| 13 | +spring.datasource.password= panzhao | |
| 14 | 14 | #DATASOURCE |
| 15 | 15 | spring.datasource.max-active=100 |
| 16 | 16 | spring.datasource.max-idle=8 | ... | ... |
src/main/resources/static/pages/control/line/child_pages/child_task.html
| ... | ... | @@ -441,14 +441,18 @@ $(function(){ |
| 441 | 441 | param.qdzName = searchStationName(route, param.qdzCode); |
| 442 | 442 | param.zdzName = searchStationName(route, param.zdzCode); |
| 443 | 443 | |
| 444 | + layer.msg('操作中...', {icon: 16,time:0}); | |
| 444 | 445 | $post('/realSchedule', param, function(rs){ |
| 445 | 446 | var sch = rs.t; |
| 446 | 447 | //前端缓存更新 |
| 447 | 448 | scheduleLineMap[param.xlBm][param.lpName].push(sch); |
| 448 | 449 | //刷新表格 |
| 449 | 450 | _alone.addScheduleToTable(sch); |
| 451 | + _alone.refreshScheduleArray(rs.ups); | |
| 452 | + | |
| 450 | 453 | //关闭弹出层 |
| 451 | 454 | layer.closeAll(); |
| 455 | + layer.alert('临加班次成功!',{icon:1, shift: 5}); | |
| 452 | 456 | }); |
| 453 | 457 | }); |
| 454 | 458 | ... | ... |
src/main/resources/static/pages/control/line/child_pages/vehicAndper_adjust.html
| ... | ... | @@ -192,13 +192,17 @@ |
| 192 | 192 | //驾驶员 |
| 193 | 193 | $.get('/realSchedule/driver', {lineCode: lineCode}, function(rs){ |
| 194 | 194 | rs.splice(0, 0, placeholder); |
| 195 | - initPinYinSelect2(wrap + ' select[name=jsy]', rs); | |
| 195 | + initPinYinSelect2(wrap + ' select[name=jsy]', rs, function(that){ | |
| 196 | + that.val(schedul.jGh + '/' + schedul.jName).change(); | |
| 197 | + }); | |
| 196 | 198 | |
| 197 | 199 | }); |
| 198 | 200 | //售票员 |
| 199 | 201 | $.get('/realSchedule/conductor', {lineCode: lineCode}, function(rs){ |
| 200 | 202 | rs.splice(0, 0, placeholder); |
| 201 | - initPinYinSelect2(wrap + ' select[name=spy]', rs); | |
| 203 | + initPinYinSelect2(wrap + ' select[name=spy]', rs, function(that){ | |
| 204 | + that.val(schedul.sGh + '/' + schedul.sName).change(); | |
| 205 | + }); | |
| 202 | 206 | }); |
| 203 | 207 | }; |
| 204 | 208 | |
| ... | ... | @@ -243,15 +247,14 @@ |
| 243 | 247 | idArray.push($(this).data('id')); |
| 244 | 248 | }); |
| 245 | 249 | |
| 250 | + if(!$("#borrowInfoPanel").is(":hidden")){ | |
| 251 | + params.borrowLine = lineSelect.val(); | |
| 252 | + } | |
| 246 | 253 | syncSubmit(idArray, params ,function(){ |
| 254 | + layer.closeAll(); | |
| 247 | 255 | layer.msg('操作完成!'); |
| 248 | 256 | //刷新表格 |
| 249 | 257 | refreshMainList(); |
| 250 | - //提交借车信息 | |
| 251 | - if(!$("#borrowInfoPanel").is(":hidden")){ | |
| 252 | - params.borrowLine = lineSelect.val(); | |
| 253 | - $post('/deviceRevert', params); | |
| 254 | - } | |
| 255 | 258 | }); |
| 256 | 259 | }); |
| 257 | 260 | }); | ... | ... |
src/main/resources/static/pages/control/line/css/lineControl.css
| ... | ... | @@ -1853,7 +1853,8 @@ a.task-item-success{ |
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | 1855 | select.form-control.custom-val-error, |
| 1856 | -input.form-control.custom-val-error{ | |
| 1856 | +input.form-control.custom-val-error, | |
| 1857 | +.select2-selection.custom-val-error{ | |
| 1857 | 1858 | border: 1px solid #e75555; |
| 1858 | 1859 | color: #e75555; |
| 1859 | 1860 | } | ... | ... |
src/main/resources/static/pages/control/line/js/data.js
src/main/resources/static/pages/control/line/js/drawSvg.js
| ... | ... | @@ -176,9 +176,11 @@ var drawSvg = (function(){ |
| 176 | 176 | |
| 177 | 177 | //画出GPS点 |
| 178 | 178 | drawVehicle: function(gpsArray){ |
| 179 | - | |
| 180 | 179 | for(var i = 0, gps; gps = gpsArray[i ++];){ |
| 181 | 180 | //drawGpsToSvg(gps, aloneSvgMapp[gps.lineId]); |
| 181 | + | |
| 182 | + //暂时先清空重新画 | |
| 183 | + homeSvgMapp[gps.lineId].select('g.gps-g-wrap').html(''); | |
| 182 | 184 | drawGpsToSvg(gps, homeSvgMapp[gps.lineId]); |
| 183 | 185 | } |
| 184 | 186 | ... | ... |
src/main/resources/static/pages/control/line/js/main.js
| ... | ... | @@ -59,12 +59,14 @@ |
| 59 | 59 | |
| 60 | 60 | //模拟图GPS刷新事件 |
| 61 | 61 | $('#tab_home').on('gps_refresh', function(e, add, up){ |
| 62 | - //附加班次信息 | |
| 63 | - addList = _data.attachSchedulInfo(add); | |
| 64 | - drawSvg.drawVehicle(addList); | |
| 62 | + //现在先每次全量画 | |
| 63 | + var list = _data.findAllGps(); | |
| 64 | + _data.attachSchedulInfo(list); | |
| 65 | + | |
| 66 | + drawSvg.drawVehicle(list); | |
| 65 | 67 | |
| 66 | 68 | //按线路分组 |
| 67 | - var listMap = groupByLine(addList); | |
| 69 | + var listMap = groupByLine(list); | |
| 68 | 70 | console.log('listMap', listMap); |
| 69 | 71 | for(var key in listMap){ |
| 70 | 72 | var htmlStr = template('home_table_temp', {list: listMap[key]}); | ... | ... |
src/main/resources/static/pages/control/line/js/rightMenu.js
| ... | ... | @@ -205,15 +205,17 @@ var _menu = (function() { |
| 205 | 205 | $('#outgoAdjustForm select[name=clZbh]').select2({data: rs}).val(schedul.clZbh).change(); |
| 206 | 206 | }); |
| 207 | 207 | |
| 208 | - $('#outgoAdjustForm button.confirm').one('click', function(){ | |
| 208 | + $('#outgoAdjustForm button.confirm').on('click', function(){ | |
| 209 | + var check = customFormValidate('#outgoAdjustForm'); | |
| 210 | + if(!check)return; | |
| 209 | 211 | |
| 210 | 212 | var params = $('#outgoAdjustForm').serializeJSON(); |
| 211 | 213 | $post('/realSchedule/outgoAdjust', params, function(rs){ |
| 212 | 214 | layer.close(index); |
| 213 | - schedul.dfsj = rs.dfsj; | |
| 214 | - schedul.remarks = rs.remarks; | |
| 215 | - _alone.refreshSchedule(schedul); | |
| 216 | - layer.msg('调整成功!'); | |
| 215 | + if(rs.t){ | |
| 216 | + layer.msg('调整成功!'); | |
| 217 | + _alone.refreshSchedule(rs.t); | |
| 218 | + } | |
| 217 | 219 | }); |
| 218 | 220 | }); |
| 219 | 221 | } |
| ... | ... | @@ -312,10 +314,8 @@ var _menu = (function() { |
| 312 | 314 | $('.confirm', '#realOutgoAdjust').on('click', function(){ |
| 313 | 315 | var params = $('#realOutgoAdjust').serializeJSON(); |
| 314 | 316 | if(!params.fcsjActual){ |
| 315 | - layer.msg('实发时刻不能为空');return; | |
| 316 | - } | |
| 317 | - if(!$.trim(params.remarks)){ | |
| 318 | - layer.msg('备注不能为空');return; | |
| 317 | + layer.msg('实发时刻不能为空'); | |
| 318 | + return; | |
| 319 | 319 | } |
| 320 | 320 | layer.close(index); |
| 321 | 321 | $post('/realSchedule/realOutAdjust', params |
| ... | ... | @@ -478,14 +478,12 @@ var _menu = (function() { |
| 478 | 478 | |
| 479 | 479 | }); |
| 480 | 480 | //售票员 |
| 481 | - $.get('/realSchedule/conductor', {lineCode: schedul.xlBm}, function(rs){ | |
| 482 | - initPinYinSelect2('#schinfoFineTune select[name=spy]' , rs, function(rs){ | |
| 483 | - initPinYinSelect2('#outgoAdjustForm select[name=spy]' , rs, function(that){ | |
| 484 | - //默认选中 | |
| 485 | - that.val(schedul.sGh + '/' + schedul.sName).change(); | |
| 486 | - }); | |
| 481 | + $.get('/realSchedule/conductor', {lineCode: schedul.xlBm}, function(rs){ | |
| 482 | + initPinYinSelect2('#schinfoFineTune select[name=spy]' , rs, function(that){ | |
| 483 | + //默认选中 | |
| 484 | + that.val(schedul.sGh + '/' + schedul.sName).change(); | |
| 487 | 485 | }); |
| 488 | - }); | |
| 486 | + }); | |
| 489 | 487 | //车辆 |
| 490 | 488 | $.get('/realSchedule/cars', {lineCode: schedul.xlBm}, function(rs){ |
| 491 | 489 | $('#schinfoFineTune select[name=clZbh]').select2({data: rs}).val(schedul.clZbh).change(); |
| ... | ... | @@ -502,10 +500,9 @@ var _menu = (function() { |
| 502 | 500 | //确定 |
| 503 | 501 | $('#schinfoFineTune button.confirm').on('click', function(){ |
| 504 | 502 | var params = $('form#schinfoFineTune').serializeJSON(); |
| 505 | - if(!$.trim(params.fcsj)){ | |
| 506 | - layer.msg('计发时间不能为空!'); | |
| 507 | - return; | |
| 508 | - } | |
| 503 | + | |
| 504 | + if(!customFormValidate('form#schinfoFineTune'))return; | |
| 505 | + | |
| 509 | 506 | $post('/realSchedule/schInfoFineTune', params, function(rs){ |
| 510 | 507 | layer.close(index); |
| 511 | 508 | if(rs.t) |
| ... | ... | @@ -542,5 +539,35 @@ var _menu = (function() { |
| 542 | 539 | layer.alert('服务器出现异常!', {icon: 2, title: '操作失败'}); |
| 543 | 540 | } |
| 544 | 541 | |
| 542 | + /** | |
| 543 | + * 自定义表单校验 | |
| 544 | + */ | |
| 545 | + function customFormValidate(f){ | |
| 546 | + var rs = true; | |
| 547 | + //所有可见的项 | |
| 548 | + var es = $('input,select', f); | |
| 549 | + | |
| 550 | + for(var i = 0, e; e = es[i++];){ | |
| 551 | + if($(e).attr('required') && ( $(e).val() == null || $(e).val() == '')){ | |
| 552 | + if($(e).hasClass('select2-hidden-accessible')) | |
| 553 | + $(e).next().find('.select2-selection').addClass('custom-val-error'); | |
| 554 | + else | |
| 555 | + $(e).addClass('custom-val-error'); | |
| 556 | + rs = false; | |
| 557 | + } | |
| 558 | + else{ | |
| 559 | + if($(e).hasClass('select2-hidden-accessible')) | |
| 560 | + $(e).next().find('.select2-selection').removeClass('custom-val-error'); | |
| 561 | + else | |
| 562 | + $(e).removeClass('custom-val-error'); | |
| 563 | + } | |
| 564 | + } | |
| 565 | + | |
| 566 | + if(!rs){ | |
| 567 | + layer.alert('数据完整性校验失败,请检查输入项', {icon: 2, title: '操作失败', shift: 5}); | |
| 568 | + } | |
| 569 | + return rs; | |
| 570 | + } | |
| 571 | + | |
| 545 | 572 | return menuObject; |
| 546 | 573 | })(); |
| 547 | 574 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/control/line/temps/alone_tp.html
| ... | ... | @@ -149,7 +149,7 @@ |
| 149 | 149 | {{/if}} |
| 150 | 150 | |
| 151 | 151 | <td class="hide-lt-1080" data-name="remarks"> |
| 152 | - {{if item.remarks != null}} | |
| 152 | + {{if item.remarks != null && item.length > 0}} | |
| 153 | 153 | <a class="remarks-popover" href="javascript:;" data-toggle="popover" data-content="{{item.remarks}}" >备注...</a> |
| 154 | 154 | {{/if}} |
| 155 | 155 | </td> |
| ... | ... | @@ -236,7 +236,7 @@ |
| 236 | 236 | <div class="form-custom-row"> |
| 237 | 237 | <div class="item"> |
| 238 | 238 | <span class="item-label" style="width: 80px;">车辆编码: </span> |
| 239 | - <select class="form-control" value="{{clZbh}}" name="clZbh"></select> | |
| 239 | + <select class="form-control" value="{{clZbh}}" required=1 name="clZbh"></select> | |
| 240 | 240 | </div> |
| 241 | 241 | <div class="item"> |
| 242 | 242 | <span class="item-label" style="width: 80px;">路 牌: </span> |
| ... | ... | @@ -251,14 +251,14 @@ |
| 251 | 251 | </div> |
| 252 | 252 | <div class="item"> |
| 253 | 253 | <span class="item-label" style="width: 80px;">预发时刻: </span> |
| 254 | - <input type="time" class="form-control" value="{{dfsj}}" name="dfsj"> | |
| 254 | + <input type="time" class="form-control" required=1 value="{{dfsj}}" name="dfsj"> | |
| 255 | 255 | </div> |
| 256 | 256 | </div> |
| 257 | 257 | |
| 258 | 258 | <div class="form-custom-row"> |
| 259 | 259 | <div class="item"> |
| 260 | 260 | <span class="item-label" style="width: 80px;">驾驶员: </span> |
| 261 | - <select class="form-control" value="{{jName}}" name="jsy"></select> | |
| 261 | + <select class="form-control" value="{{jName}}" required=1 name="jsy"></select> | |
| 262 | 262 | </div> |
| 263 | 263 | <div class="item"> |
| 264 | 264 | <span class="item-label" style="width: 80px;">售票员: </span> |
| ... | ... | @@ -370,7 +370,7 @@ |
| 370 | 370 | <div class="form-custom-row"> |
| 371 | 371 | <div class="item"> |
| 372 | 372 | <span class="item-label" style="width: 80px;">车辆编码: </span> |
| 373 | - <select class="form-control" value="{{clZbh}}" name="clZbh"></select> | |
| 373 | + <select class="form-control" value="{{clZbh}}" name="clZbh" required=1></select> | |
| 374 | 374 | </div> |
| 375 | 375 | <div class="item"> |
| 376 | 376 | <span class="item-label" style="width: 80px;">路 牌: </span> |
| ... | ... | @@ -381,18 +381,18 @@ |
| 381 | 381 | <div class="form-custom-row"> |
| 382 | 382 | <div class="item"> |
| 383 | 383 | <span class="item-label" style="width: 80px;">驾驶员: </span> |
| 384 | - <select class="form-control" value="{{jName}}" name="jsy"></select> | |
| 384 | + <select class="form-control" value="{{jName}}" name="jsy" required=1></select> | |
| 385 | 385 | </div> |
| 386 | 386 | <div class="item"> |
| 387 | 387 | <span class="item-label" style="width: 80px;">售票员: </span> |
| 388 | - <select class="form-control" value="{{sName}}" name="spy"></select> | |
| 388 | + <select class="form-control" value="{{sName}}" name="spy" ></select> | |
| 389 | 389 | </div> |
| 390 | 390 | </div> |
| 391 | 391 | |
| 392 | 392 | <div class="form-custom-row"> |
| 393 | 393 | <div class="item"> |
| 394 | 394 | <span class="item-label" style="width: 80px;">计发时刻: </span> |
| 395 | - <input type="time" class="form-control" value="{{fcsj}}" name="fcsj"> | |
| 395 | + <input type="time" class="form-control" value="{{fcsj}}" name="fcsj" required=1> | |
| 396 | 396 | </div> |
| 397 | 397 | <div class="item"> |
| 398 | 398 | <span class="item-label" style="width: 80px;">实际时刻: </span> | ... | ... |
src/main/resources/static/pages/control/line/temps/console.html
| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | <span class="log-item-text">{{data.nbbm}} {{text}}</span> |
| 8 | 8 | <span class="log-item-time">{{dateStr}}</span> |
| 9 | 9 | <span class="log-item-handle"> |
| 10 | - <button type="button" class="btn blue btn-sm">同意</button> | |
| 11 | - <button type="button" class="btn red btn-sm">不同意</button> | |
| 10 | + <!--<button type="button" class="btn blue btn-sm">同意</button> | |
| 11 | + <button type="button" class="btn red btn-sm">不同意</button>--> | |
| 12 | 12 | </span> |
| 13 | 13 | </div> |
| 14 | 14 | </script> |
| ... | ... | @@ -19,8 +19,8 @@ |
| 19 | 19 | <span class="log-item-text">执行班次 {{t.fcsj}}</span> |
| 20 | 20 | <span class="log-item-time">{{dataStr}}</span> |
| 21 | 21 | <span class="log-item-handle"> |
| 22 | - <a href="javascript:;" class="font-blue-steel log-close">确定</a> | |
| 23 | - <a href="javascript:;" class="font-red">地图</a> | |
| 22 | + <!--<a href="javascript:;" class="font-blue-steel log-close">确定</a> | |
| 23 | + <a href="javascript:;" class="font-red">地图</a>--> | |
| 24 | 24 | </span> |
| 25 | 25 | </div> |
| 26 | 26 | </script> |
| ... | ... | @@ -30,8 +30,8 @@ |
| 30 | 30 | <span class="log-item-text">{{t.zdsjActual}} {{t.clZbh}} 到达 {{t.zdzName}};已完成 {{finish}} 个班次;下一发车时间 {{nt.fcsj}};由{{nt.qdzName}} 发往 {{nt.zdzName}};应到{{nt.zdsj}}</span> |
| 31 | 31 | <span class="log-item-time">{{dataStr}}</span> |
| 32 | 32 | <span class="log-item-handle"> |
| 33 | - <a href="javascript:;" class="font-blue-steel log-close">确定</a> | |
| 34 | - <a href="javascript:;" class="font-red">地图</a> | |
| 33 | + <!--<a href="javascript:;" class="font-blue-steel log-close">确定</a> | |
| 34 | + <a href="javascript:;" class="font-red">地图</a>--> | |
| 35 | 35 | </span> |
| 36 | 36 | </div> |
| 37 | 37 | </script> |
| 38 | 38 | \ No newline at end of file | ... | ... |