Commit 6b58a05ac2cb9e783824d0debf02a74239442e61
1 parent
d00e297b
1.浦交历史路单修改时间,T+(3或5),
Showing
8 changed files
with
148 additions
and
9 deletions
src/main/java/com/bsth/common/Constants.java
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
| ... | ... | @@ -343,4 +343,17 @@ public class AdminUtilsController { |
| 343 | 343 | |
| 344 | 344 | return "error"; |
| 345 | 345 | } |
| 346 | + | |
| 347 | + @RequestMapping("/reloadSystemParam") | |
| 348 | + public String reloadSystemParam() { | |
| 349 | + Map<String, Object> result = new HashMap<>(); | |
| 350 | + try { | |
| 351 | + basicDataLoader.loadSystemParam(); | |
| 352 | + return "success"; | |
| 353 | + } catch (Exception e) { | |
| 354 | + e.printStackTrace(); | |
| 355 | + } | |
| 356 | + | |
| 357 | + return "error"; | |
| 358 | + } | |
| 346 | 359 | } |
| 347 | 360 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| ... | ... | @@ -11,9 +11,12 @@ import java.sql.PreparedStatement; |
| 11 | 11 | import java.sql.ResultSet; |
| 12 | 12 | import java.util.*; |
| 13 | 13 | |
| 14 | +import com.bsth.common.Constants; | |
| 14 | 15 | import com.bsth.data.forecast.entity.ArrivalEntity; |
| 15 | 16 | import com.bsth.data.maintenance_plan.MaintenancePlan; |
| 16 | 17 | import com.bsth.data.maintenance_plan.MtPlanCenter; |
| 18 | +import com.bsth.entity.SystemParam; | |
| 19 | +import com.bsth.entity.sys.Role; | |
| 17 | 20 | import com.bsth.entity.sys.SysUser; |
| 18 | 21 | import com.bsth.security.util.SecurityUtils; |
| 19 | 22 | import com.bsth.util.HttpClientUtils; |
| ... | ... | @@ -624,11 +627,22 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 624 | 627 | @RequestMapping("dateArray") |
| 625 | 628 | public List<String> dateArray(@RequestParam(defaultValue = "0") int c){ |
| 626 | 629 | List<String> rs = new ArrayList<>(); |
| 630 | + Set<Role> roles = SecurityUtils.getCurrentUser().getRoles(); | |
| 631 | + SystemParam param = BasicData.getSystemParam().get(Constants.SPECIAL_ROLES); | |
| 632 | + int days = 3; | |
| 633 | + if (param != null && param.getValue() != null) { | |
| 634 | + for (Role role : roles) { | |
| 635 | + if (param.getValue().contains(String.format(",%s,", role.getCodeName()))) { | |
| 636 | + days = 5; | |
| 637 | + } | |
| 638 | + } | |
| 639 | + } | |
| 627 | 640 | |
| 628 | 641 | long t = System.currentTimeMillis(); |
| 629 | - if(c != 1) | |
| 642 | + if (c != 1) { | |
| 630 | 643 | t -= (ONE_DAY + (1000 * 60 * 60 * 6)); |
| 631 | - for(int i = 0; i < 3; i ++){ | |
| 644 | + } | |
| 645 | + for (int i = 1; i < days; i++) { | |
| 632 | 646 | rs.add(fmtyyyyMMdd.print(t)); |
| 633 | 647 | t -= ONE_DAY; |
| 634 | 648 | } | ... | ... |
src/main/java/com/bsth/data/BasicData.java
| ... | ... | @@ -13,6 +13,7 @@ import java.util.Map; |
| 13 | 13 | import java.util.Set; |
| 14 | 14 | |
| 15 | 15 | import com.bsth.entity.*; |
| 16 | +import com.bsth.repository.*; | |
| 16 | 17 | import org.apache.commons.lang3.StringUtils; |
| 17 | 18 | import org.slf4j.Logger; |
| 18 | 19 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -25,13 +26,6 @@ import com.bsth.data.gpsdata_v2.cache.GeoCacheData; |
| 25 | 26 | import com.bsth.data.pinyin.PersionPinYinBuffer; |
| 26 | 27 | import com.bsth.entity.calc.CalcInterval; |
| 27 | 28 | import com.bsth.entity.schedule.CarConfigInfo; |
| 28 | -import com.bsth.repository.BusinessRepository; | |
| 29 | -import com.bsth.repository.CarParkRepository; | |
| 30 | -import com.bsth.repository.CarsRepository; | |
| 31 | -import com.bsth.repository.LineRepository; | |
| 32 | -import com.bsth.repository.PersonnelRepository; | |
| 33 | -import com.bsth.repository.StationRepository; | |
| 34 | -import com.bsth.repository.StationRouteRepository; | |
| 35 | 29 | import com.bsth.repository.calc.CalcIntervalRepository; |
| 36 | 30 | import com.bsth.repository.schedule.CarConfigInfoRepository; |
| 37 | 31 | import com.google.common.collect.BiMap; |
| ... | ... | @@ -106,6 +100,8 @@ public class BasicData { |
| 106 | 100 | |
| 107 | 101 | public static List<WhiteIp> whiteIpList; |
| 108 | 102 | |
| 103 | + private static Map<String, SystemParam> key2param = new HashMap<>(); | |
| 104 | + | |
| 109 | 105 | static Logger logger = LoggerFactory.getLogger(BasicData.class); |
| 110 | 106 | |
| 111 | 107 | public static String getStationNameByCode(String code, String prefix){ |
| ... | ... | @@ -164,6 +160,9 @@ public class BasicData { |
| 164 | 160 | @Autowired |
| 165 | 161 | CalcIntervalRepository calcIntervalRepository; |
| 166 | 162 | |
| 163 | + @Autowired | |
| 164 | + private SystemParamRepository systemParamRepository; | |
| 165 | + | |
| 167 | 166 | @Override |
| 168 | 167 | public void run() { |
| 169 | 168 | loadAllData(); |
| ... | ... | @@ -195,6 +194,7 @@ public class BasicData { |
| 195 | 194 | logger.info("load geo cache..,"); |
| 196 | 195 | geoCacheData.loadData(); |
| 197 | 196 | station2ParkBuffer.saveAll(); |
| 197 | + loadSystemParam(); | |
| 198 | 198 | logger.info("加载基础数据成功!,"); |
| 199 | 199 | } catch (Exception e) { |
| 200 | 200 | logger.error("加载基础数据时出现异常,", e); |
| ... | ... | @@ -451,6 +451,22 @@ public class BasicData { |
| 451 | 451 | |
| 452 | 452 | lineDate2Level = result; |
| 453 | 453 | } |
| 454 | + | |
| 455 | + /** | |
| 456 | + * 加载系统配置参数 | |
| 457 | + */ | |
| 458 | + public void loadSystemParam() { | |
| 459 | + Map<String, SystemParam> key2param = new HashMap<>(); | |
| 460 | + Iterator<SystemParam> systemParamIterator = systemParamRepository.findAll().iterator(); | |
| 461 | + while (systemParamIterator.hasNext()) { | |
| 462 | + SystemParam systemParam = systemParamIterator.next(); | |
| 463 | + key2param.put(systemParam.getKey(), systemParam); | |
| 464 | + } | |
| 465 | + | |
| 466 | + if (key2param.size() > 0) { | |
| 467 | + BasicData.key2param = key2param; | |
| 468 | + } | |
| 469 | + } | |
| 454 | 470 | } |
| 455 | 471 | |
| 456 | 472 | @Component |
| ... | ... | @@ -487,4 +503,8 @@ public class BasicData { |
| 487 | 503 | whiteIpList = result; |
| 488 | 504 | } |
| 489 | 505 | } |
| 506 | + | |
| 507 | + public static Map<String, SystemParam> getSystemParam() { | |
| 508 | + return key2param; | |
| 509 | + } | |
| 490 | 510 | } | ... | ... |
src/main/java/com/bsth/entity/SystemParam.java
0 → 100644
| 1 | +package com.bsth.entity; | |
| 2 | + | |
| 3 | +import javax.persistence.*; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * @author Hill | |
| 7 | + */ | |
| 8 | +@Entity | |
| 9 | +@Table(name = "bsth_c_sys_param") | |
| 10 | +public class SystemParam { | |
| 11 | + | |
| 12 | + @Id | |
| 13 | + @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| 14 | + private Integer id; | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 键名(唯一) | |
| 18 | + */ | |
| 19 | + private String key; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 值 | |
| 23 | + */ | |
| 24 | + private String value; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 备注 | |
| 28 | + */ | |
| 29 | + private String remark; | |
| 30 | + | |
| 31 | + public Integer getId() { | |
| 32 | + return id; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setId(Integer id) { | |
| 36 | + this.id = id; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public String getKey() { | |
| 40 | + return key; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void setKey(String key) { | |
| 44 | + this.key = key; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public String getValue() { | |
| 48 | + return value; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public void setValue(String value) { | |
| 52 | + this.value = value; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public String getRemark() { | |
| 56 | + return remark; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public void setRemark(String remark) { | |
| 60 | + this.remark = remark; | |
| 61 | + } | |
| 62 | +} | ... | ... |
src/main/java/com/bsth/repository/SystemParamRepository.java
0 → 100644
src/main/java/com/bsth/service/SystemParamService.java
0 → 100644
src/main/java/com/bsth/service/impl/SystemParamServiceImpl.java
0 → 100644