|
@@ -70,25 +70,25 @@ public class AuthorizeRtkServiceImpl extends ServiceImpl<IAuthorizeRtkMapper, Au
|
|
|
|
|
|
DateTime startDate = DateUtil.parse(startTime);
|
|
|
DateTime endDate = DateUtil.parse(endTime);
|
|
|
- if(rtkDevice.getValidStartTime() != null && rtkDevice.getValidEndTime() != null){
|
|
|
|
|
|
- if(startDate.isBefore(rtkDevice.getValidStartTime())){
|
|
|
- throw new BusinessException(ResultCode.RTK_TIME_ERROR);
|
|
|
- }
|
|
|
- if(endDate.isBefore(rtkDevice.getValidEndTime())){
|
|
|
- throw new BusinessException(ResultCode.RTK_TIME_ERROR);
|
|
|
- }
|
|
|
-
|
|
|
- if(DateUtil.isIn(startDate,rtkDevice.getValidStartTime(),rtkDevice.getValidEndTime())){
|
|
|
- throw new BusinessException(ResultCode.RTK_TIME_ERROR);
|
|
|
- }
|
|
|
- if(DateUtil.isIn(endDate,rtkDevice.getValidStartTime(),rtkDevice.getValidEndTime())){
|
|
|
- throw new BusinessException(ResultCode.RTK_TIME_ERROR);
|
|
|
+ List<AuthorizeRtk> authorizeRtks = this.getByRtkId(rtkDevice.getId());
|
|
|
+ if(authorizeRtks != null && !authorizeRtks.isEmpty()){
|
|
|
+ for (AuthorizeRtk db : authorizeRtks) {
|
|
|
+ if(startDate.isBefore(db.getValidStartTime())){
|
|
|
+ throw new BusinessException(ResultCode.RTK_TIME_ERROR);
|
|
|
+ }
|
|
|
+ if(endDate.isBefore(db.getValidEndTime())){
|
|
|
+ throw new BusinessException(ResultCode.RTK_TIME_ERROR);
|
|
|
+ }
|
|
|
+ if(DateUtil.isIn(startDate,db.getValidStartTime(),db.getValidEndTime())){
|
|
|
+ throw new BusinessException(ResultCode.RTK_TIME_ERROR);
|
|
|
+ }
|
|
|
+ if(DateUtil.isIn(endDate,db.getValidStartTime(),db.getValidEndTime())){
|
|
|
+ throw new BusinessException(ResultCode.RTK_TIME_ERROR);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- rtkDeviceService.updateValidTime(rtkDevice.getId(),startTime,endTime);
|
|
|
|
|
|
authorizeRtk.setValidStartTime(startDate);
|
|
|
authorizeRtk.setValidEndTime(endDate);
|
|
@@ -143,18 +143,11 @@ public class AuthorizeRtkServiceImpl extends ServiceImpl<IAuthorizeRtkMapper, Au
|
|
|
Page<AuthorizeRtk> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
Set<Long> sysIds = page.getRecords().stream().map(AuthorizeRtk::getSysUserId).collect(Collectors.toSet());
|
|
|
HashMap<Long, SysUser> userMap = sysUserService.getByIds(sysIds);
|
|
|
- Set<String> rtkCodes = page.getRecords().stream().map(AuthorizeRtk::getRtkSnCode).collect(Collectors.toSet());
|
|
|
- HashMap<String, RtkDevice> rtkMap = rtkDeviceService.getByRtkSnCodeList(rtkCodes);
|
|
|
for (AuthorizeRtk record : page.getRecords()) {
|
|
|
SysUser sysUser = userMap.get(record.getSysUserId());
|
|
|
if(sysUser != null){
|
|
|
record.setSysUserName(sysUser.getNickName());
|
|
|
}
|
|
|
- RtkDevice rtkDevice = rtkMap.get(record.getRtkSnCode());
|
|
|
- if(rtkDevice!= null){
|
|
|
- record.setSgRtkSn(rtkDevice.getSgRtkSn());
|
|
|
- record.setCameraSn(rtkDevice.getCameraSn());
|
|
|
- }
|
|
|
}
|
|
|
return page;
|
|
|
}
|
|
@@ -186,10 +179,37 @@ public class AuthorizeRtkServiceImpl extends ServiceImpl<IAuthorizeRtkMapper, Au
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
- public List<AuthorizeRtk> getByRtkCode(String rtkSnCode) {
|
|
|
+ public List<AuthorizeRtk> getByRtkId(Integer rtkId) {
|
|
|
LambdaQueryWrapper<AuthorizeRtk> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(AuthorizeRtk::getRtkSnCode,rtkSnCode);
|
|
|
+ wrapper.eq(AuthorizeRtk::getRtkDeviceId,rtkId);
|
|
|
+ wrapper.orderByDesc(AuthorizeRtk::getId);
|
|
|
return this.list(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HashMap<Integer, AuthorizeRtk> getByRtkIds(List<Integer> ids) {
|
|
|
+ HashMap<Integer, AuthorizeRtk> map = new HashMap<>();
|
|
|
+ if(ids == null || ids.isEmpty()){
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<AuthorizeRtk> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(AuthorizeRtk::getRtkDeviceId,ids);
|
|
|
+ wrapper.orderByDesc(AuthorizeRtk::getId);
|
|
|
+ List<AuthorizeRtk> list = this.list(wrapper);
|
|
|
+
|
|
|
+ for (AuthorizeRtk authorizeRtk : list) {
|
|
|
+ if(map.get(authorizeRtk.getRtkDeviceId()) == null){
|
|
|
+ map.put(authorizeRtk.getRtkDeviceId(),authorizeRtk);
|
|
|
+ }else {
|
|
|
+ AuthorizeRtk authorizeRtk1 = map.get(authorizeRtk.getRtkDeviceId());
|
|
|
+ if(authorizeRtk.getId() > authorizeRtk1.getId()){
|
|
|
+ map.put(authorizeRtk.getRtkDeviceId(),authorizeRtk);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
}
|