Commit ae3be767880531d9a325ceb9fc860bbf06fc0c80
1 parent
c92c7a0e
1.解决一个问题
Showing
2 changed files
with
19 additions
and
3 deletions
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| @@ -13,6 +13,7 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; | @@ -13,6 +13,7 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 13 | import com.bsth.entity.schedule.SchedulePlanInfo; | 13 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| 14 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | 14 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 15 | import com.bsth.service.schedule.SchedulePlanInfoService; | 15 | import com.bsth.service.schedule.SchedulePlanInfoService; |
| 16 | +import com.bsth.util.ConfigUtil; | ||
| 16 | import com.bsth.websocket.handler.SendUtils; | 17 | import com.bsth.websocket.handler.SendUtils; |
| 17 | import com.google.common.collect.ArrayListMultimap; | 18 | import com.google.common.collect.ArrayListMultimap; |
| 18 | import com.google.common.collect.HashMultimap; | 19 | import com.google.common.collect.HashMultimap; |
| @@ -82,7 +83,7 @@ public class DayOfSchedule { | @@ -82,7 +83,7 @@ public class DayOfSchedule { | ||
| 82 | 83 | ||
| 83 | private static ScheduleComparator.DFSJ schDFSJComparator; | 84 | private static ScheduleComparator.DFSJ schDFSJComparator; |
| 84 | 85 | ||
| 85 | - private static Long sch_max_id=-1L; | 86 | + private static Long sch_max_id=Long.parseLong(ConfigUtil.get("auto_increment_offset")); |
| 86 | 87 | ||
| 87 | @Autowired | 88 | @Autowired |
| 88 | LineConfigData lineConfigData; | 89 | LineConfigData lineConfigData; |
| @@ -407,14 +408,27 @@ public class DayOfSchedule { | @@ -407,14 +408,27 @@ public class DayOfSchedule { | ||
| 407 | 408 | ||
| 408 | 409 | ||
| 409 | public synchronized long getId(){ | 410 | public synchronized long getId(){ |
| 410 | - if(sch_max_id==-1){ | 411 | + long temp = sch_max_id; |
| 412 | + if (sch_max_id < 0) { | ||
| 413 | + sch_max_id = schRepository.getMaxId(); | ||
| 414 | + if(null == sch_max_id) | ||
| 415 | + sch_max_id = 3000L;//留一点空间补数据用 | ||
| 416 | + if (temp == -1) { | ||
| 417 | + sch_max_id += sch_max_id % 2 == 0 ? 1 : 0; | ||
| 418 | + } else if (temp == -2) { | ||
| 419 | + sch_max_id += sch_max_id % 2 == 0 ? 0 : 1; | ||
| 420 | + } | ||
| 421 | + } else { | ||
| 422 | + sch_max_id += 2; | ||
| 423 | + } | ||
| 424 | + /*if(sch_max_id==-1){ | ||
| 411 | sch_max_id = schRepository.getMaxId(); | 425 | sch_max_id = schRepository.getMaxId(); |
| 412 | if(null == sch_max_id) | 426 | if(null == sch_max_id) |
| 413 | sch_max_id = 3000L;//留一点空间补数据用 | 427 | sch_max_id = 3000L;//留一点空间补数据用 |
| 414 | sch_max_id += 5; | 428 | sch_max_id += 5; |
| 415 | } | 429 | } |
| 416 | else | 430 | else |
| 417 | - sch_max_id ++; | 431 | + sch_max_id++;*/ |
| 418 | return sch_max_id; | 432 | return sch_max_id; |
| 419 | } | 433 | } |
| 420 | 434 |
src/main/resources/application-prod.properties
| @@ -29,3 +29,5 @@ spring.datasource.validation-query=select 1 | @@ -29,3 +29,5 @@ spring.datasource.validation-query=select 1 | ||
| 29 | http.gps.real.url= http://192.168.168.171:8080/transport_server/rtgps/ | 29 | http.gps.real.url= http://192.168.168.171:8080/transport_server/rtgps/ |
| 30 | ##\u6D88\u606F\u4E0B\u53D1 | 30 | ##\u6D88\u606F\u4E0B\u53D1 |
| 31 | http.send.directive = http://192.168.168.171:8080/transport_server/message/ | 31 | http.send.directive = http://192.168.168.171:8080/transport_server/message/ |
| 32 | +## increment offset | ||
| 33 | +auto_increment_offset= -1 |