Commit 9daf4a0ee4bbc13d37f3b5ed07e92b740e43aed8
1 parent
9485a38e
update...
Showing
7 changed files
with
46 additions
and
12 deletions
src/main/java/com/bsth/data/gpsdata_v2/cache/GpsCacheData.java
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| ... | ... | @@ -71,6 +71,8 @@ public class DayOfSchedule { |
| 71 | 71 | // 排序器 |
| 72 | 72 | private static ScheduleComparator.FCSJ schFCSJComparator; |
| 73 | 73 | |
| 74 | + private static Long sch_max_id=-1L; | |
| 75 | + | |
| 74 | 76 | @Autowired |
| 75 | 77 | LineConfigData lineConfigData; |
| 76 | 78 | |
| ... | ... | @@ -330,11 +332,13 @@ public class DayOfSchedule { |
| 330 | 332 | // 转换为实际排班 |
| 331 | 333 | realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class); |
| 332 | 334 | |
| 335 | + Date d = new Date(); | |
| 333 | 336 | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); |
| 334 | 337 | String fcsj; |
| 335 | 338 | for (ScheduleRealInfo sch : realList) { |
| 336 | 339 | sch.setScheduleDateStr(fmtyyyyMMdd.print(sch.getScheduleDate().getTime())); |
| 337 | 340 | sch.setRealExecDate(sch.getScheduleDateStr()); |
| 341 | + sch.setCreateDate(d); | |
| 338 | 342 | |
| 339 | 343 | if (StringUtils.isEmpty(sch.getFcsj())) |
| 340 | 344 | sch.setFcsj("00:00"); |
| ... | ... | @@ -383,21 +387,28 @@ public class DayOfSchedule { |
| 383 | 387 | return realList; |
| 384 | 388 | } |
| 385 | 389 | |
| 390 | + | |
| 391 | + public synchronized long getId(){ | |
| 392 | + if(sch_max_id==-1){ | |
| 393 | + sch_max_id = schRepository.getMaxId(); | |
| 394 | + if(null == sch_max_id) | |
| 395 | + sch_max_id = 3000L;//留一点空间补数据用 | |
| 396 | + sch_max_id += 5; | |
| 397 | + } | |
| 398 | + else | |
| 399 | + sch_max_id ++; | |
| 400 | + return sch_max_id; | |
| 401 | + } | |
| 402 | + | |
| 386 | 403 | /** |
| 387 | 404 | * @Title: batchSave |
| 388 | 405 | * @Description: TODO(批量入库) |
| 389 | 406 | */ |
| 390 | 407 | private void batchSave(List<ScheduleRealInfo> list) { |
| 391 | - // 查询数据库最大ID | |
| 392 | - Long id = schRepository.getMaxId(); | |
| 393 | - if (null == id) | |
| 394 | - id = 0L; | |
| 395 | - id++; | |
| 396 | - | |
| 397 | 408 | SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); |
| 398 | 409 | for (ScheduleRealInfo item : list) { |
| 399 | 410 | item.setSpId(item.getId());// 保留原始的计划ID |
| 400 | - item.setId(id++);// 设置ID | |
| 411 | + item.setId(getId());// 设置ID | |
| 401 | 412 | item.setScheduleDateStr(sdfyyyyMMdd.format(item.getScheduleDate())); |
| 402 | 413 | } |
| 403 | 414 | |
| ... | ... | @@ -1107,4 +1118,16 @@ public class DayOfSchedule { |
| 1107 | 1118 | schAttrCalculator.calcQdzTimePlan(new ArrayList<ScheduleRealInfo>(map.get(k))); |
| 1108 | 1119 | } |
| 1109 | 1120 | } |
| 1121 | + | |
| 1122 | + public int dbCount(String lineCode, String currSchDate) { | |
| 1123 | + int count = -1; | |
| 1124 | + | |
| 1125 | + try{ | |
| 1126 | + count = jdbcTemplate.queryForObject("select count(*) from bsth_c_s_sp_info_real where schedule_date='"+currSchDate+"' and xl_bm='"+lineCode+"'", java.lang.Integer.class); | |
| 1127 | + | |
| 1128 | + }catch (Exception e){ | |
| 1129 | + logger.error("", e); | |
| 1130 | + } | |
| 1131 | + return count; | |
| 1132 | + } | |
| 1110 | 1133 | } |
| 1111 | 1134 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/schedule/thread/ScheduleRefreshThread.java
| ... | ... | @@ -56,7 +56,7 @@ public class ScheduleRefreshThread extends Thread{ |
| 56 | 56 | |
| 57 | 57 | if(oldSchDate == null || !oldSchDate.equals(currSchDate)){ |
| 58 | 58 | |
| 59 | - logger.info(lineCode + "开始翻班, " + currSchDate); | |
| 59 | + //logger.info(lineCode + "开始翻班, " + currSchDate); | |
| 60 | 60 | |
| 61 | 61 | try{ |
| 62 | 62 | //清除指令数据 |
| ... | ... | @@ -74,6 +74,14 @@ public class ScheduleRefreshThread extends Thread{ |
| 74 | 74 | //重载排班数据 |
| 75 | 75 | dayOfSchedule.reloadSch(lineCode, currSchDate, false); |
| 76 | 76 | logger.info(lineCode + "翻班完成, " + currSchDate + " -班次数量:" + dayOfSchedule.findByLineCode(lineCode).size()); |
| 77 | + | |
| 78 | + | |
| 79 | + //校验一下数据库和缓存的数据 | |
| 80 | + int dbCount = dayOfSchedule.dbCount(lineCode, currSchDate); | |
| 81 | + logger.info(lineCode + " 数据库数量:" + dbCount); | |
| 82 | + if(dbCount != dayOfSchedule.findByLineCode(lineCode).size()){ | |
| 83 | + logger.error("异常异常异常,,数据库和缓存数量不一致," + lineCode); | |
| 84 | + } | |
| 77 | 85 | } |
| 78 | 86 | }catch (Exception e){ |
| 79 | 87 | logger.error("班次更新失败!! -" + lineCode, e); | ... | ... |
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
src/main/java/com/bsth/service/realcontrol/impl/ChildTaskPlanServiceImpl.java
| ... | ... | @@ -18,6 +18,7 @@ import org.springframework.jdbc.core.JdbcTemplate; |
| 18 | 18 | import org.springframework.stereotype.Service; |
| 19 | 19 | |
| 20 | 20 | import javax.transaction.Transactional; |
| 21 | +import java.util.Date; | |
| 21 | 22 | import java.util.HashMap; |
| 22 | 23 | import java.util.Map; |
| 23 | 24 | |
| ... | ... | @@ -78,7 +79,7 @@ public class ChildTaskPlanServiceImpl extends BaseServiceImpl<ChildTaskPlan, Lon |
| 78 | 79 | ccServiceSch.setScheduleDateStr(sch.getScheduleDateStr()); |
| 79 | 80 | ccServiceSch.setRealExecDate(sch.getRealExecDate()); |
| 80 | 81 | |
| 81 | - ccServiceSch.setId(null); | |
| 82 | + ccServiceSch.setId(dayOfSchedule.getId()); | |
| 82 | 83 | ccServiceSch.setSpId(null); |
| 83 | 84 | ccServiceSch.setClZbh(t.getNbbm()); |
| 84 | 85 | ccServiceSch.setCcService(true); |
| ... | ... | @@ -96,6 +97,7 @@ public class ChildTaskPlanServiceImpl extends BaseServiceImpl<ChildTaskPlan, Lon |
| 96 | 97 | ccServiceSch.setZdsjActual(ccServiceSch.getZdsj()); |
| 97 | 98 | ccServiceSch.setRemarks(t.getRemarks()); |
| 98 | 99 | ccServiceSch.setStatus(2); |
| 100 | + ccServiceSch.setCreateDate(new Date()); | |
| 99 | 101 | if("1".equals(t.getType2())){ |
| 100 | 102 | ccServiceSch.setBcType("normal"); |
| 101 | 103 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -503,6 +503,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 503 | 503 | return rs; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | + t.setId(dayOfSchedule.getId()); | |
| 506 | 507 | //实时入库 |
| 507 | 508 | rs = super.save(t); |
| 508 | 509 | } catch (Exception e) { |
| ... | ... | @@ -603,6 +604,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 603 | 604 | return rs; |
| 604 | 605 | } |
| 605 | 606 | |
| 607 | + t.setId(dayOfSchedule.getId()); | |
| 606 | 608 | //实时入库 |
| 607 | 609 | super.save(t); |
| 608 | 610 | ... | ... |
src/main/resources/static/real_control_v2/fragments/north/nav/history_sch/h_add_temp_sch.html
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | <div class="uk-form-row"> |
| 31 | 31 | <label class="uk-form-label">班次类型</label> |
| 32 | 32 | <div class="uk-form-controls"> |
| 33 | - <select class="form-control nt-dictionary" name="bcType" data-code="{{bcType}}" | |
| 33 | + <select class="form-control nt-dictionary" required name="bcType" data-code="{{bcType}}" | |
| 34 | 34 | data-group=ScheduleType></select> |
| 35 | 35 | </div> |
| 36 | 36 | </div> | ... | ... |