feat(service): 实现分页功能并优化设备权限管理
- 在控制器层添加分页支持,将返回类型从 List 修改为 Page - 实现服务层分页逻辑,集成 MyBatis Plus 分页插件 - 重构设备权限管理逻辑,区分超级管理员、普通用户和游客权限 - 添加营销用户和工程用户的特殊权限处理机制 - 迁移事件查询逻辑到统一的事件用户服务中 - 移除过时的设备用户映射器接口和 XML 查询方法 - 为暂降事件报告添加动态文件名生成功能 - 修复时间范围计算中的日期边界问题 - 优化台账树结构以支持多层级权限过滤 - 统计未读事件数量的查询逻辑优化
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csreport.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
@@ -71,9 +72,9 @@ public class CsAppReportController extends BaseController {
|
||||
@PostMapping("/getApplicationReport")
|
||||
@ApiOperation("查询暂态报告申请记录")
|
||||
@ApiImplicitParam(name = "param", value = "事件查询参数", required = true)
|
||||
public HttpResult<List<ReportEventVO>> getApplicationReportList(@RequestBody LineParamDTO param) {
|
||||
public HttpResult<Page<ReportEventVO>> getApplicationReportList(@RequestBody LineParamDTO param) {
|
||||
String methodDescribe = getMethodDescribe("getApplicationReportList");
|
||||
List<ReportEventVO> result = csAppReportService.getApplicationReportList(param);
|
||||
Page<ReportEventVO> result = csAppReportService.getApplicationReportList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.csreport.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
||||
import com.njcn.csreport.pojo.po.CsAppReport;
|
||||
@@ -24,7 +25,7 @@ public interface ICsAppReportService extends IService<CsAppReport> {
|
||||
|
||||
void applicationReport(LineParamDTO param);
|
||||
|
||||
List<ReportEventVO> getApplicationReportList(LineParamDTO param);
|
||||
Page<ReportEventVO> getApplicationReportList(LineParamDTO param);
|
||||
|
||||
Boolean createEventReport(String id);
|
||||
|
||||
|
||||
@@ -3,10 +3,12 @@ package com.njcn.csreport.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
@@ -22,7 +24,9 @@ import com.njcn.csharmonic.api.SysExcelRelationFeignClient;
|
||||
import com.njcn.csharmonic.enums.CsHarmonicResponseEnum;
|
||||
import com.njcn.csharmonic.pojo.param.StatSubstationBizBaseParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
import com.njcn.csharmonic.pojo.po.RStatLimitRateDPO;
|
||||
import com.njcn.csharmonic.pojo.vo.HarmonicVO;
|
||||
import com.njcn.csreport.mapper.CsAppReportMapper;
|
||||
import com.njcn.csreport.pojo.po.CsAppReport;
|
||||
import com.njcn.csreport.pojo.vo.ReportEventVO;
|
||||
@@ -52,10 +56,11 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -97,12 +102,11 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
if (param.getTimeType() == 0) {
|
||||
timeRanges = splitIntoDays(startLocalDate, endLocalDate);
|
||||
} else {
|
||||
timeRanges = splitIntoMonths(startLocalDate, endLocalDate);
|
||||
timeRanges = splitIntoMonthsForCurrentYear(endLocalDate);
|
||||
}
|
||||
|
||||
String queryStartTime = timeRanges.get(timeRanges.size() - 1).end.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
String queryEndTime = timeRanges.get(0).start.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
|
||||
String queryStartTime = timeRanges.get(timeRanges.size() - 1).start.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
String queryEndTime = timeRanges.get(0).end.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
|
||||
StatSubstationBizBaseParam rStatLimitQueryParam = new StatSubstationBizBaseParam();
|
||||
rStatLimitQueryParam.setIds(Collections.singletonList(param.getLineId()));
|
||||
@@ -200,7 +204,11 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReportEventVO> getApplicationReportList(LineParamDTO param) {
|
||||
public Page<ReportEventVO> getApplicationReportList(LineParamDTO param) {
|
||||
Page<ReportEventVO> page = new Page<>();
|
||||
Page<CsAppReport> page1 = new Page<> (param.getPageNum(), param.getPageSize());
|
||||
|
||||
|
||||
List<ReportEventVO> result = new ArrayList<>();
|
||||
LambdaQueryWrapper<CsAppReport> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.between(CsAppReport::getCreateTime, param.getStartTime(), param.getEndTime())
|
||||
@@ -211,7 +219,11 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
if (!userVO.getType().equals(UserType.SUPER_ADMINISTRATOR) && !userVO.getType().equals(UserType.ADMINISTRATOR)) {
|
||||
queryWrapper.eq(CsAppReport::getCreateBy, userVO.getId());
|
||||
}
|
||||
List<CsAppReport> list = this.list(queryWrapper);
|
||||
Page<CsAppReport> page2 = this.baseMapper.selectPage(page1,queryWrapper);
|
||||
BeanUtil.copyProperties(page2, page);
|
||||
List<CsAppReport> list = page2.getRecords();
|
||||
|
||||
// List<CsAppReport> list = this.list(queryWrapper);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
list.forEach(item->{
|
||||
ReportEventVO vo = new ReportEventVO();
|
||||
@@ -235,9 +247,10 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
vo.setEngineeringName(devDetailDTO.getEngineeringName());
|
||||
|
||||
result.add(vo);
|
||||
page.setRecords(result);
|
||||
});
|
||||
}
|
||||
return result;
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,6 +284,7 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
List<CsLinePO> lineList = csLineFeignClient.queryLineById(lineIdList).getData();
|
||||
Map<String,CsLinePO> lineMap = lineList.stream().collect(Collectors.toMap(CsLinePO::getLineId, item->item));
|
||||
Map<String, AreaLineInfoVO> map = new HashMap<>();
|
||||
AtomicReference<String> lineName = new AtomicReference<>();
|
||||
eventList.forEach(item->{
|
||||
CsLinePO po = lineMap.get(item.getLineId());
|
||||
AreaLineInfoVO vo = new AreaLineInfoVO();
|
||||
@@ -281,6 +295,7 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
vo.setIp(devDetailDTO.getDevMac());
|
||||
vo.setLineId(po.getLineId());
|
||||
vo.setNum(Objects.isNull(po.getLineNo())?po.getClDid():po.getLineNo());
|
||||
lineName.set(po.getName());
|
||||
vo.setLineName(po.getName());
|
||||
vo.setPt1(po.getPtRatio().intValue());
|
||||
vo.setPt2(Objects.isNull(po.getPt2Ratio())?1:po.getPt2Ratio().intValue());
|
||||
@@ -290,7 +305,8 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
map.put(item.getId(),vo);
|
||||
});
|
||||
//step2: 生成事件报告
|
||||
String filePath = commMonitorEventReportService.saveStableEventReport(eventIdList,map);
|
||||
String fileName = "暂降事件报告_" + lineName.get() + LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN)) + ".docx";
|
||||
String filePath = commMonitorEventReportService.saveStableEventReport(eventIdList,map,fileName);
|
||||
//step3: 存储文件服务器
|
||||
report.setFilePath(filePath);
|
||||
return this.updateById(report);
|
||||
@@ -382,39 +398,27 @@ public class CsAppReportServiceImpl extends ServiceImpl<CsAppReportMapper, CsApp
|
||||
return ranges;
|
||||
}
|
||||
|
||||
private List<TimeRange> splitIntoWeeks(LocalDate startDate, LocalDate endDate) {
|
||||
List<TimeRange> weekRanges = new java.util.ArrayList<>();
|
||||
LocalDate currentStart = startDate;
|
||||
private List<TimeRange> splitIntoMonthsForCurrentYear(LocalDate endDate) {
|
||||
List<TimeRange> timeRanges = new ArrayList<>();
|
||||
LocalDate now = LocalDate.now();
|
||||
int currentYear = now.getYear();
|
||||
|
||||
while (!currentStart.isAfter(endDate)) {
|
||||
LocalDate currentEnd = currentStart.with(DayOfWeek.SUNDAY);
|
||||
if (currentEnd.isAfter(endDate)) {
|
||||
currentEnd = endDate;
|
||||
for (int month = now.getMonthValue(); month >= 1; month--) {
|
||||
LocalDate monthStart = LocalDate.of(currentYear, month, 1);
|
||||
LocalDate monthEnd;
|
||||
|
||||
if (month == now.getMonthValue()) {
|
||||
monthEnd = now;
|
||||
} else {
|
||||
monthEnd = monthStart.withDayOfMonth(monthStart.lengthOfMonth());
|
||||
}
|
||||
weekRanges.add(new TimeRange(currentStart, currentEnd));
|
||||
currentStart = currentEnd.plusDays(1);
|
||||
|
||||
timeRanges.add(new TimeRange(monthStart, monthEnd));
|
||||
}
|
||||
|
||||
return weekRanges;
|
||||
}
|
||||
|
||||
|
||||
private List<TimeRange> splitIntoMonths(LocalDate startDate, LocalDate endDate) {
|
||||
List<TimeRange> timeRanges = new java.util.ArrayList<>();
|
||||
LocalDate currentStart = startDate.withDayOfMonth(1);
|
||||
|
||||
while (!currentStart.isAfter(endDate)) {
|
||||
LocalDate currentEnd = currentStart.withDayOfMonth(currentStart.lengthOfMonth());
|
||||
if (currentEnd.isAfter(endDate)) {
|
||||
currentEnd = endDate;
|
||||
}
|
||||
timeRanges.add(new TimeRange(currentStart, currentEnd));
|
||||
currentStart = currentEnd.plusDays(1);
|
||||
}
|
||||
|
||||
return timeRanges;
|
||||
}
|
||||
|
||||
|
||||
//fixme 代码较为冗余,后期可以采用反射的方式进行优化
|
||||
private String buildOverLimitDesc(List<RStatLimitRateDPO> dataList) {
|
||||
String tag = "";
|
||||
|
||||
Reference in New Issue
Block a user