Commit f70387461f505d0610c9c2cfa90cbbd722349c48

Authored by 王通
1 parent 955698c0

1.修复历史修正班次时不同角色的日期范围问题

src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
... ... @@ -627,16 +627,7 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo,
627 627 @RequestMapping("dateArray")
628 628 public List<String> dateArray(@RequestParam(defaultValue = "0") int c){
629 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 = 4;
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   - }
  630 + int days = SystemParam.getHistorySaveDays();
640 631  
641 632 long t = System.currentTimeMillis();
642 633 if (c != 1) {
... ...
src/main/java/com/bsth/entity/SystemParam.java
1 1 package com.bsth.entity;
2 2  
  3 +import com.bsth.common.Constants;
  4 +import com.bsth.data.BasicData;
  5 +import com.bsth.entity.sys.Role;
  6 +import com.bsth.security.util.SecurityUtils;
  7 +
3 8 import javax.persistence.*;
  9 +import java.util.Set;
4 10  
5 11 /**
6 12 * @author Hill
... ... @@ -59,4 +65,19 @@ public class SystemParam {
59 65 public void setRemark(String remark) {
60 66 this.remark = remark;
61 67 }
  68 +
  69 + public static int getHistorySaveDays() {
  70 + Set<Role> roles = SecurityUtils.getCurrentUser().getRoles();
  71 + SystemParam param = BasicData.getSystemParam().get(Constants.SPECIAL_ROLES);
  72 + int days = 4;
  73 + if (param != null && param.getValue() != null) {
  74 + for (Role role : roles) {
  75 + if (param.getValue().contains(String.format(",%s,", role.getCodeName()))) {
  76 + days = 5;
  77 + }
  78 + }
  79 + }
  80 +
  81 + return days;
  82 + }
62 83 }
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -29,6 +29,7 @@ import java.util.Set;
29 29 import java.util.concurrent.*;
30 30 import java.util.regex.Pattern;
31 31  
  32 +import com.bsth.entity.*;
32 33 import org.apache.commons.io.IOUtils;
33 34 import org.apache.commons.lang3.StringEscapeUtils;
34 35 import org.apache.commons.lang3.StringUtils;
... ... @@ -67,10 +68,6 @@ import com.bsth.data.schedule.edit_logs.loggers.FcxxwtLogger;
67 68 import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
68 69 import com.bsth.data.schedule.late_adjust.LateAdjustHandle;
69 70 import com.bsth.data.utils.CustomStringUtils;
70   -import com.bsth.entity.CarDevice;
71   -import com.bsth.entity.Cars;
72   -import com.bsth.entity.Line;
73   -import com.bsth.entity.Personnel;
74 71 import com.bsth.entity.calc.CalcInterval;
75 72 import com.bsth.entity.calc.CalcStatistics;
76 73 import com.bsth.entity.oil.Dlb;
... ... @@ -626,7 +623,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
626 623 DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd");
627 624 long today = formatter.parseMillis(new DateTime().toString("yyyy-MM-dd")), scheduleDate = formatter.parseMillis(t.getScheduleDateStr());
628 625 String clZbh = t.getClZbh(), lpName = t.getLpName();
629   - if (today < scheduleDate || today - scheduleDate > 259200000) {
  626 + if (today < scheduleDate || today - scheduleDate > 86400000 * SystemParam.getHistorySaveDays()) {
630 627 rs.put("status", ResponseCode.ERROR);
631 628 rs.put("msg", "无效的调度日期");
632 629 return rs;
... ... @@ -4679,7 +4676,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4679 4676 // 检查调度日期
4680 4677 DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd");
4681 4678 long today = formatter.parseMillis(new DateTime().toString("yyyy-MM-dd")), scheduleDate = formatter.parseMillis(oldSch.getScheduleDateStr());
4682   - if (today < scheduleDate || today - scheduleDate > 259200000) {
  4679 + if (today < scheduleDate || today - scheduleDate > 86400000 * SystemParam.getHistorySaveDays()) {
4683 4680 rs.put("status", ResponseCode.ERROR);
4684 4681 rs.put("msg", "无效的调度日期");
4685 4682 return rs;
... ...