Commit fb2312f198703894b8f801c5efe7ba107b51a16d
1 parent
cbdc12e2
1.修复历史修正班次时不同角色的日期范围问题
Showing
5 changed files
with
37 additions
and
29 deletions
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| ... | ... | @@ -20,6 +20,7 @@ import com.bsth.entity.sys.Role; |
| 20 | 20 | import com.bsth.entity.sys.SysUser; |
| 21 | 21 | import com.bsth.security.util.SecurityUtils; |
| 22 | 22 | import com.bsth.util.HttpClientUtils; |
| 23 | +import com.bsth.util.PrivilegeUtils; | |
| 23 | 24 | import com.bsth.util.ReportUtils; |
| 24 | 25 | import com.bsth.util.db.DBUtils_MS; |
| 25 | 26 | import com.bsth.util.db.DBUtils_control; |
| ... | ... | @@ -627,7 +628,7 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 627 | 628 | @RequestMapping("dateArray") |
| 628 | 629 | public List<String> dateArray(@RequestParam(defaultValue = "0") int c){ |
| 629 | 630 | List<String> rs = new ArrayList<>(); |
| 630 | - int days = SystemParam.getHistorySaveDays(); | |
| 631 | + int days = PrivilegeUtils.getHistoryEditDays(); | |
| 631 | 632 | |
| 632 | 633 | long t = System.currentTimeMillis(); |
| 633 | 634 | if (c != 1) { | ... | ... |
src/main/java/com/bsth/entity/SystemParam.java
| ... | ... | @@ -65,19 +65,4 @@ public class SystemParam { |
| 65 | 65 | public void setRemark(String remark) { |
| 66 | 66 | this.remark = remark; |
| 67 | 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 | - } | |
| 83 | 68 | } | ... | ... |
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
| ... | ... | @@ -16,6 +16,7 @@ import java.util.Set; |
| 16 | 16 | |
| 17 | 17 | import javax.transaction.Transactional; |
| 18 | 18 | |
| 19 | +import com.bsth.util.PrivilegeUtils; | |
| 19 | 20 | import org.apache.commons.lang3.StringEscapeUtils; |
| 20 | 21 | import org.apache.commons.lang3.StringUtils; |
| 21 | 22 | import org.slf4j.Logger; |
| ... | ... | @@ -1606,7 +1607,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1606 | 1607 | // TODO Auto-generated method stub |
| 1607 | 1608 | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); |
| 1608 | 1609 | |
| 1609 | - int days = SystemParam.getHistorySaveDays(); | |
| 1610 | + int days = PrivilegeUtils.getHistoryEditDays(); | |
| 1610 | 1611 | |
| 1611 | 1612 | String rq=map.get("rq").toString(); |
| 1612 | 1613 | String gsbm=map.get("ssgsdm_like").toString(); | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -30,6 +30,7 @@ import java.util.concurrent.*; |
| 30 | 30 | import java.util.regex.Pattern; |
| 31 | 31 | |
| 32 | 32 | import com.bsth.entity.*; |
| 33 | +import com.bsth.util.*; | |
| 33 | 34 | import org.apache.commons.io.IOUtils; |
| 34 | 35 | import org.apache.commons.lang3.StringEscapeUtils; |
| 35 | 36 | import org.apache.commons.lang3.StringUtils; |
| ... | ... | @@ -115,16 +116,6 @@ import com.bsth.service.report.ReportService; |
| 115 | 116 | import com.bsth.service.schedule.SchedulePlanInfoService; |
| 116 | 117 | import com.bsth.service.sys.DictionaryService; |
| 117 | 118 | import com.bsth.service.sys.DutyEmployeeService; |
| 118 | -import com.bsth.util.Arith; | |
| 119 | -import com.bsth.util.ComparableChild; | |
| 120 | -import com.bsth.util.ComparableLp; | |
| 121 | -import com.bsth.util.ComparableReal; | |
| 122 | -import com.bsth.util.ConfigUtil; | |
| 123 | -import com.bsth.util.DateUtils; | |
| 124 | -import com.bsth.util.ReportRelatedUtils; | |
| 125 | -import com.bsth.util.ReportUtils; | |
| 126 | -import com.bsth.util.TimeUtils; | |
| 127 | -import com.bsth.util.TransGPS; | |
| 128 | 119 | import com.bsth.websocket.handler.SendUtils; |
| 129 | 120 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 130 | 121 | import com.github.stuxuhai.jpinyin.PinyinException; |
| ... | ... | @@ -623,7 +614,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 623 | 614 | DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); |
| 624 | 615 | long today = formatter.parseMillis(new DateTime().toString("yyyy-MM-dd")), scheduleDate = formatter.parseMillis(t.getScheduleDateStr()); |
| 625 | 616 | String clZbh = t.getClZbh(), lpName = t.getLpName(); |
| 626 | - if (today < scheduleDate || today - scheduleDate > 86400000 * SystemParam.getHistorySaveDays()) { | |
| 617 | + if (today < scheduleDate || today - scheduleDate > 86400000 * PrivilegeUtils.getHistoryEditDays()) { | |
| 627 | 618 | rs.put("status", ResponseCode.ERROR); |
| 628 | 619 | rs.put("msg", "无效的调度日期"); |
| 629 | 620 | return rs; |
| ... | ... | @@ -4676,7 +4667,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 4676 | 4667 | // 检查调度日期 |
| 4677 | 4668 | DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); |
| 4678 | 4669 | long today = formatter.parseMillis(new DateTime().toString("yyyy-MM-dd")), scheduleDate = formatter.parseMillis(oldSch.getScheduleDateStr()); |
| 4679 | - if (today < scheduleDate || today - scheduleDate > 86400000 * SystemParam.getHistorySaveDays()) { | |
| 4670 | + if (today < scheduleDate || today - scheduleDate > 86400000 * PrivilegeUtils.getHistoryEditDays()) { | |
| 4680 | 4671 | rs.put("status", ResponseCode.ERROR); |
| 4681 | 4672 | rs.put("msg", "无效的调度日期"); |
| 4682 | 4673 | return rs; | ... | ... |
src/main/java/com/bsth/util/PrivilegeUtils.java
0 → 100644
| 1 | +package com.bsth.util; | |
| 2 | + | |
| 3 | +import com.bsth.common.Constants; | |
| 4 | +import com.bsth.data.BasicData; | |
| 5 | +import com.bsth.entity.SystemParam; | |
| 6 | +import com.bsth.entity.sys.Role; | |
| 7 | +import com.bsth.security.util.SecurityUtils; | |
| 8 | + | |
| 9 | +import java.util.Set; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * @author Hill | |
| 13 | + */ | |
| 14 | +public class PrivilegeUtils { | |
| 15 | + | |
| 16 | + public static int getHistoryEditDays() { | |
| 17 | + Set<Role> roles = SecurityUtils.getCurrentUser().getRoles(); | |
| 18 | + SystemParam param = BasicData.getSystemParam().get(Constants.SPECIAL_ROLES); | |
| 19 | + int days = 4; | |
| 20 | + if (param != null && param.getValue() != null) { | |
| 21 | + for (Role role : roles) { | |
| 22 | + if (param.getValue().contains(String.format(",%s,", role.getCodeName()))) { | |
| 23 | + days = 5; | |
| 24 | + } | |
| 25 | + } | |
| 26 | + } | |
| 27 | + | |
| 28 | + return days; | |
| 29 | + } | |
| 30 | +} | ... | ... |