1.谐波溯源算法

2.北京暂降平台
This commit is contained in:
2025-10-10 08:33:37 +08:00
parent 5c8088e808
commit 2b1a33aea0
16 changed files with 586 additions and 406 deletions

View File

@@ -195,6 +195,9 @@ public class HarmonicUpServiceImpl extends ServiceImpl<UpHarmonicDetailMapper,Up
// 1. 获取线路ID和台账基础信息
List<String> lineIds = commGeneralService.getRunLineIdsByDept(param.getDeptId());
if(CollUtil.isEmpty(lineIds)){
throw new BusinessException(CommonResponseEnum.FAIL,"当前部门未绑定监测点");
}
List<LedgerBaseInfo> ledgerBaseInfoList = ledgerScaleMapper.getLedgerBaseInfo(lineIds);
if (CollUtil.isEmpty(ledgerBaseInfoList)) {
@@ -558,10 +561,6 @@ public class HarmonicUpServiceImpl extends ServiceImpl<UpHarmonicDetailMapper,Up
.sorted(Comparator.comparing(AnomalyInfo::getTime))
.collect(Collectors.toList());
if(sortedAnomalies.get(0).getLineId().equals("9686e66738bab8516ff2c2e9fedc0518")){
System.out.println(555);
}
// 检查是否连续
List<List<AnomalyInfo>> infoList =findAllContinuousAnomalies(sortedAnomalies,ledgerBaseInfoMap);

View File

@@ -0,0 +1,25 @@
package com.njcn.product.advance.responsility.pojo.constant;
import lombok.Getter;
@Getter
public enum CalculationType {
PW_TYPE(0,"配网类型"),
SYSTEM_TYPE(1,"系统类型")
;
private final int code;
private final String description;
CalculationType(int code, String description) {
this.code = code;
this.description = description;
}
}

View File

@@ -25,5 +25,7 @@ public class RespDataDTO extends RespData implements Serializable {
private String lineName;
private Integer type;
}

View File

@@ -52,4 +52,9 @@ public class RespData extends BaseEntity {
*/
private Integer state;
/**
* 状态0/null:配网 1:系统)
*/
private Integer type;
}

View File

@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.product.advance.responsility.mapper.RespDataResultMapper;
import com.njcn.product.advance.responsility.pojo.constant.CalculationType;
import com.njcn.product.advance.responsility.pojo.dto.CustomerData;
import com.njcn.product.advance.responsility.pojo.dto.CustomerResponsibility;
import com.njcn.product.advance.responsility.pojo.dto.ResponsibilityResult;
@@ -48,11 +49,11 @@ public class RespDataResultServiceImpl extends ServiceImpl<RespDataResultMapper,
@Override
public List<ResponsibilityResult> displayHistoryData(String id, Integer time) {
List<ResponsibilityResult> responsibilityResults = new ArrayList<>();
if (Objects.isNull(time)) {
RespData respData = respDataService.getById(id);
String[] split = respData.getDataTimes().split(StrPool.COMMA);
//if (Objects.isNull(time)) {
RespData respDataQuery = respDataService.getById(id);
String[] split = respDataQuery.getDataTimes().split(StrPool.COMMA);
time = Integer.parseInt(split[0]);
}
//}
LambdaQueryWrapper<RespDataResult> respDataResultLambdaQueryWrapper = new LambdaQueryWrapper<>();
respDataResultLambdaQueryWrapper.eq(RespDataResult::getResDataId, id)
.eq(RespDataResult::getTime, time);
@@ -74,12 +75,17 @@ public class RespDataResultServiceImpl extends ServiceImpl<RespDataResultMapper,
InputStream userDetailStream = fileStorageUtil.getFileStream(respDataResult.getUserDetailData());
String userDetailStr = IoUtil.readUtf8(userDetailStream);
List<CustomerData> customerData = JSONArray.parseArray(userDetailStr, CustomerData.class);
responsibilityResult.setDatas(customerData);
//处理排名前10数据
InputStream respStream = fileStorageUtil.getFileStream(respDataResult.getUserResponsibility());
String respStr = IoUtil.readUtf8(respStream);
List<CustomerResponsibility> respData = JSONArray.parseArray(respStr, CustomerResponsibility.class);
if(Objects.nonNull(respDataQuery.getType()) && respDataQuery.getType().equals(CalculationType.SYSTEM_TYPE.getCode())){
customerData.forEach(item->item.setCustomerName(item.getCustomerName().substring(0,item.getCustomerName().indexOf("("))));
respData.forEach(item->item.setCustomerName(item.getCustomerName().substring(0,item.getCustomerName().indexOf("("))));
}
responsibilityResult.setResponsibilities(respData);
responsibilityResult.setDatas(customerData);
responsibilityResults.add(responsibilityResult);
}
}

View File

@@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.FileUtil;
import com.njcn.common.utils.PubUtils;
@@ -41,6 +42,7 @@ import com.njcn.product.advance.responsility.pojo.bo.RespCommon;
import com.njcn.product.advance.responsility.pojo.bo.RespHarmData;
import com.njcn.product.advance.responsility.pojo.bo.UserDataExcel;
import com.njcn.product.advance.responsility.pojo.constant.CalculationStatus;
import com.njcn.product.advance.responsility.pojo.constant.CalculationType;
import com.njcn.product.advance.responsility.pojo.dto.CustomerData;
import com.njcn.product.advance.responsility.pojo.dto.CustomerResponsibility;
import com.njcn.product.advance.responsility.pojo.dto.RespDataDTO;
@@ -121,6 +123,7 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
public final static int INTERVAL_TIME_1 = 1;
public final static int INTERVAL_TIME_3 = 3;
public final static int INTERVAL_TIME_5 = 5;
public final static int INTERVAL_TIME_10 = 10;
public final static int INTERVAL_TIME_15 = 15;
public final static int INTERVAL_TIME_30 = 30;
public final static int WINDOW_96 = 96;
@@ -453,8 +456,8 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
int pNode, pNum, win, harmNum;
float harmMk;
List<UserDataExcel> userDataExcels = new ArrayList<>();
if(Objects.nonNull(responsibilityCalculateParam.getSystemType()) && responsibilityCalculateParam.getSystemType()==1){
userDataExcels = test(responsibilityCalculateParam.getUserList(),responsibilityCalculateParam.getSearchBeginTime(),responsibilityCalculateParam.getSearchEndTime());
if(Objects.nonNull(responsibilityCalculateParam.getSystemType()) && responsibilityCalculateParam.getSystemType()==CalculationType.SYSTEM_TYPE.getCode()){
userDataExcels = sysMonitorDataGet(responsibilityCalculateParam.getUserList(),responsibilityCalculateParam.getSearchBeginTime(),responsibilityCalculateParam.getSearchEndTime());
}else {
userDataExcels = respUserDataService.getUserDataExcelList(responsibilityCalculateParam.getUserDataId());
@@ -618,6 +621,12 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
customerData.add(customerDataT);
}
}
if(Objects.nonNull(responsibilityCalculateParam.getSystemType()) && responsibilityCalculateParam.getSystemType()==CalculationType.SYSTEM_TYPE.getCode()){
customerData.forEach(item->item.setCustomerName(item.getCustomerName().substring(0,item.getCustomerName().indexOf("("))));
customerResponsibilities.forEach(item->item.setCustomerName(item.getCustomerName().substring(0,item.getCustomerName().indexOf("("))));
}
result.setDatas(customerData);
result.setTimeDatas(timeDatas);
result.setResponsibilities(customerResponsibilities);
@@ -643,6 +652,11 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
responsibilityData.setDataTimes(responsibilityCalculateParam.getTime().toString());
responsibilityData.setTimeWindow(timeWin);
responsibilityData.setState(DataStateEnum.ENABLE.getCode());
if(Objects.nonNull(responsibilityCalculateParam.getSystemType()) && responsibilityCalculateParam.getSystemType()==CalculationType.SYSTEM_TYPE.getCode()){
responsibilityData.setType(CalculationType.SYSTEM_TYPE.getCode());
}else {
responsibilityData.setType(CalculationType.PW_TYPE.getCode());
}
//进行插入操作
this.baseMapper.insert(responsibilityData);
} else {
@@ -1435,7 +1449,7 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
LineDetailDataVO lineDetailData = lineService.getLineDetailData(lineId);
int lineInterval = lineDetailData.getTimeInterval();
int userIntervalTime;
if (lineInterval == INTERVAL_TIME_1 || lineInterval == INTERVAL_TIME_3 || lineInterval == INTERVAL_TIME_5) {
if (lineInterval == INTERVAL_TIME_1 || lineInterval == INTERVAL_TIME_3 || lineInterval == INTERVAL_TIME_5 || lineInterval == INTERVAL_TIME_10) {
userIntervalTime = INTERVAL_TIME_15;
pNum = dateStr.size() * WINDOW_96;
} else {
@@ -1474,7 +1488,7 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
* 获取背景用户的下级用户及其数据
*/
public List<UserDataExcel> test(List<String> userList, String startTime, String endTime){
public List<UserDataExcel> sysMonitorDataGet(List<String> userList, String startTime, String endTime){
List<UserDataExcel> userDataExcelList = new ArrayList<>();
PHistoryHarmParam param = new PHistoryHarmParam();
param.setSearchBeginTime(startTime);
@@ -1485,7 +1499,9 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
List<DataHarmPowerP> result = new ArrayList<>();
collect.forEach((k,v)->{
LineDetailDataVO lineDetailData = lineService.getLineDetailData(k);
if(v.stream().mapToDouble(DataHarmPowerP::getP).min().getAsDouble() < 0){
throw new BusinessException(CommonResponseEnum.FAIL,lineDetailData.getLineName()+"功率数据异常");
}
//数据补全
List<DataHarmPowerP> dataHarmPowerPList = linearInterpolate(startTime.concat(InfluxDBTableConstant.START_TIME), endTime.concat(InfluxDBTableConstant.END_TIME), lineDetailData.getTimeInterval()*60, v);
//数据间隔转换成15分钟

View File

@@ -480,16 +480,9 @@ public class LedgerScaleServiceImpl implements LedgerScaleService {
InputStream respStream = fileStorageUtil.getFileStream(respDataResult.getUserResponsibility());
String respStr = IoUtil.readUtf8(respStream);
List<CustomerResponsibility> respData = JSONArray.parseArray(respStr, CustomerResponsibility.class);
List<String> userNos = respData.stream().map(it -> it.getCustomerName().substring(it.getCustomerName().indexOf("(") + 1, it.getCustomerName().indexOf(")"))).collect(Collectors.toList());
List<LedgerBaseInfo> ledgerBaseInfoList = lineMapper.queryMonitorByUser(userNos);
Map<String, LedgerBaseInfo> ledgerBaseInfoMap = ledgerBaseInfoList.stream().collect(Collectors.toMap(LedgerBaseInfo::getUserNo, Function.identity()));
respData.forEach(it -> {
String tem = it.getCustomerName().substring(it.getCustomerName().indexOf("(") + 1, it.getCustomerName().indexOf(")"));
if (ledgerBaseInfoMap.containsKey(tem)) {
LedgerBaseInfo ledgerBaseInfo = ledgerBaseInfoMap.get(tem);
it.setMonitorId(ledgerBaseInfo.getLineId());
}
it.setMonitorId(tem);
});
return respData;
}

View File

@@ -93,11 +93,6 @@ public class UserReportPO extends BaseEntity {
@TableField(value = "voltage_level")
private String voltageLevel;
/**
* 用户编号
*/
@TableField(value = "user_no")
private String userNo;
/**
* 工程名称

View File

@@ -242,6 +242,19 @@ public class LargeScreenCountController extends BaseController {
Page<EventDetailVO> result = largeScreenCountService.eventPage(largeScreenCountParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo
@PostMapping("/eventPageExport")
@ApiOperation("导出暂降事件报告")
@ApiImplicitParam(name = "largeScreenCountParam", value = "查询参数", required = true)
public HttpResult<List<EventDetailVO>> eventPageExport(@RequestBody LargeScreenCountParam largeScreenCountParam) {
String methodDescribe = getMethodDescribe("eventPageExport");
List<EventDetailVO> result = largeScreenCountService.eventPageExport(largeScreenCountParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo
@PostMapping("/devicePage")
@ApiOperation("终端分页查询")

View File

@@ -35,7 +35,6 @@ public class JwtRequestFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
System.out.println(55);
final String authorizationHeader = request.getHeader("Authorization");
String username = null;

View File

@@ -36,6 +36,8 @@ public class EventDetailVO {
private String pointname;
private String gdName;
private String busName;
private String busVoltageLevel;
private String devName;
private String persisttime;

View File

@@ -36,19 +36,25 @@ public class AuthController extends BaseController {
private final RedisUtil redisUtil;
@PostMapping("/cn_authenticate")
@ApiOperation("登录认证")
public HttpResult<AuthResponse> createAuthenticationToken(@RequestBody @Validated AuthRequest authRequest) {
String methodDescribe = getMethodDescribe("createAuthenticationToken");
//log.info("Authentication request - username: {}, password: {}",authRequest.getUsername(),authRequest.getPassword());
try {
boolean hasFlag = redisUtil.hasKey(eventRedisKey+authRequest.getUsername());
boolean hasFlag;
String pass;
//针对系统推送的认证特殊处理
if ("system_event".equals(authRequest.getUsername())) {
pass = authRequest.getPassword();
} else {
hasFlag = redisUtil.hasKey(eventRedisKey + authRequest.getUsername());
if (hasFlag) {
String pass = redisUtil.getRawValue(eventRedisKey+authRequest.getUsername());
pass = redisUtil.getRawValue(eventRedisKey + authRequest.getUsername());
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
// 执行认证,内部会调用 UserDetailsService 加载用户信息
Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(authRequest.getUsername(), pass));
@@ -67,9 +73,7 @@ public class AuthController extends BaseController {
authResponse.setToken(jwt);
authResponse.setDeptId(department);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, authResponse, methodDescribe);
}else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
} catch (Exception e) {
e.printStackTrace();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);

View File

@@ -33,7 +33,9 @@ public class MyUserDetailsService implements UserDetailsService {
if("system_event".equals(username)){
return new MyUserDetails("12345678910","system_event", "@#001njcnpqs","10001",
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encodedPassword = passwordEncoder.encode("@#001njcnpqs");
return new MyUserDetails("12345678910","system_event",encodedPassword,"10001",
new ArrayList<>());
}

View File

@@ -34,8 +34,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
//.antMatchers("/cn_authenticate","/ws/**","/accept/testEvent","/accept/eventMsg").permitAll() // 允许访问认证接口
.antMatchers("/**").permitAll() // 允许访问认证接口
.antMatchers("/cn_authenticate","/ws/**","/accept/testEvent","/accept/eventMsg").permitAll() // 允许访问认证接口
//.antMatchers("/**").permitAll() // 允许访问认证接口
.anyRequest().authenticated()
.and()
.sessionManagement()

View File

@@ -58,6 +58,9 @@ public interface LargeScreenCountService {
Page<EventDetailVO> eventPage(LargeScreenCountParam largeScreenCountParam);
List<EventDetailVO> eventPageExport(LargeScreenCountParam largeScreenCountParam);
Page<DeviceDTO> devicePage(LargeScreenCountParam largeScreenCountParam);
Page<EventDetailVO> userEventList(LargeScreenCountParam largeScreenCountParam);

View File

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.beust.ah.A;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
@@ -17,6 +18,8 @@ import com.njcn.product.event.devcie.mapper.*;
import com.njcn.product.event.devcie.pojo.dto.*;
import com.njcn.product.event.devcie.pojo.po.*;
import com.njcn.product.event.transientes.mapper.*;
import com.njcn.product.event.transientes.pojo.DicTreeEnum;
import com.njcn.product.event.transientes.pojo.enums.DicTypeEnum;
import com.njcn.product.event.transientes.pojo.param.LargeScreenCountParam;
import com.njcn.product.event.transientes.pojo.param.MessageEventFeedbackParam;
import com.njcn.product.event.transientes.pojo.po.PqsDepts;
@@ -42,6 +45,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -90,6 +94,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
private final PqSubstationMapper pqSubstationMapper;
private final PqDeviceDetailMapper pqDeviceDetailMapper;
private final PqsDicTreeMapper pqsDicTreeMapper;
private final PqsDicTypeMapper pqsDicTypeMapper;
@Value("${SYS_TYPE_ZT}")
private String sysTypeZt;
@@ -143,7 +149,6 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
long runLineCount = runLineList.stream().count();
ledgerCountVO.setAllSubCount(allSubCount);
ledgerCountVO.setAllDevCount(allDevCount);
ledgerCountVO.setAllLineCount(allLineCount);
@@ -200,8 +205,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
.le(PqsEventdetail::getEventvalue, msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime, msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid, listIds)
.orderByDesc(PqsEventdetail::getTimeid).list()
;
.orderByDesc(PqsEventdetail::getTimeid).list();
eventdetails.addAll(temp);
}
} else {
@@ -227,7 +231,6 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
msgEventInfoList = msgEventInfoList.stream().sorted(Comparator.comparing(MsgEventInfo::getSendTime, Comparator.reverseOrder())).collect(Collectors.toList());
List<PqsEventdetail> lookALarmEvent = aLarmEvent.stream().filter(temp -> Objects.equals(temp.getLookFlag(), 1)).collect(Collectors.toList());
List<PqsEventdetail> lookWarnEvent = warnEvent.stream().filter(temp -> Objects.equals(temp.getLookFlag(), 1)).collect(Collectors.toList());
List<MsgEventInfo> handleMsg = msgEventInfoList.stream().filter(temp -> Objects.equals(temp.getIsHandle(), 1)).collect(Collectors.toList());
@@ -257,7 +260,6 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
// alarmAnalysisVO.setLookNoticeEvent(handleMsg);
return alarmAnalysisVO;
}
@@ -344,7 +346,6 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
}
return eventTrendVOList;
}
@@ -750,8 +751,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
.le(PqsEventdetail::getEventvalue, msgEventConfigService.getEventValue())
.gt(PqsEventdetail::getPersisttime, msgEventConfigService.getEventDuration())
.in(PqsEventdetail::getLineid, listIds)
.orderByDesc(PqsEventdetail::getTimeid).list()
;
.orderByDesc(PqsEventdetail::getTimeid).list();
eventdetails.addAll(temp);
}
} else {
@@ -777,7 +777,6 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
msgEventInfoList = msgEventInfoList.stream().sorted(Comparator.comparing(MsgEventInfo::getSendTime, Comparator.reverseOrder())).collect(Collectors.toList());
List<PqsEventdetail> lookALarmEvent = aLarmEvent.stream().filter(temp -> Objects.equals(temp.getLookFlag(), 1)).collect(Collectors.toList());
List<PqsEventdetail> lookWarnEvent = warnEvent.stream().filter(temp -> Objects.equals(temp.getLookFlag(), 1)).collect(Collectors.toList());
List<MsgEventInfo> handleMsg = msgEventInfoList.stream().filter(temp -> Objects.equals(temp.getIsHandle(), 1)).collect(Collectors.toList());
@@ -807,7 +806,6 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
alarmAnalysisVO.setLookNoticeEvent(handleMsg);
return alarmAnalysisVO;
}
@@ -838,7 +836,6 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
}
List<String> eventType = msgEventConfigService.getEventType();
LambdaQueryWrapper<PqsEventdetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper
@@ -1003,6 +1000,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
}
return pqUserLedgerMapper.selectList(userWrapper);
}
@Override
public List<SubStationCountVO> substationCount(LargeScreenCountParam largeScreenCountParam) {
LocalDateTime startTime = largeScreenCountParam.getStartTime().atStartOfDay();
@@ -1225,6 +1223,126 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
returnpage.setTotal(list.getTotal());
return returnpage;
}
@Override
public List<EventDetailVO> eventPageExport(LargeScreenCountParam largeScreenCountParam) {
List<EventDetailVO> pqsEventdetailPage = new ArrayList<>();
LocalDateTime startTime = LocalDateTime.parse(largeScreenCountParam.getSearchBeginTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
LocalDateTime endTime = LocalDateTime.parse(largeScreenCountParam.getSearchEndTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
List<Integer> deptslineIds = commGeneralService.getLineIdsByRedis(largeScreenCountParam.getDeptId());
List<LedgerBaseInfoDTO> ledgerList = new ArrayList<>();
List<PqUserLedgerPO> pqUserLedgerPOList = new ArrayList<>();
List<PqUserLineAssPO> assList = new ArrayList<>();
LambdaQueryWrapper<PqsEventdetail> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper
.between(PqsEventdetail::getTimeid, startTime, endTime)
.gt(PqsEventdetail::getPersisttime, msgEventConfigService.getEventDuration())
.le(PqsEventdetail::getEventvalue, msgEventConfigService.getEventValue())
.orderByDesc(PqsEventdetail::getTimeid);
if (Objects.nonNull(largeScreenCountParam.getEventtype())) {
queryWrapper.eq(PqsEventdetail::getWavetype, largeScreenCountParam.getEventtype());
} else {
queryWrapper.in(PqsEventdetail::getWavetype, msgEventConfigService.getEventType());
}
if (Objects.nonNull(largeScreenCountParam.getEventDurationMin()) || Objects.nonNull(largeScreenCountParam.getEventDurationMax())) {
queryWrapper.gt(Objects.nonNull(largeScreenCountParam.getEventDurationMin()), PqsEventdetail::getPersisttime, largeScreenCountParam.getEventDurationMin());
queryWrapper.lt(Objects.nonNull(largeScreenCountParam.getEventDurationMax()), PqsEventdetail::getPersisttime, largeScreenCountParam.getEventDurationMax());
}
if (Objects.nonNull(largeScreenCountParam.getEventValueMin()) || Objects.nonNull(largeScreenCountParam.getEventValueMax())) {
queryWrapper.gt(Objects.nonNull(largeScreenCountParam.getEventValueMin()), PqsEventdetail::getEventvalue, largeScreenCountParam.getEventValueMin());
queryWrapper.lt(Objects.nonNull(largeScreenCountParam.getEventValueMax()), PqsEventdetail::getEventvalue, largeScreenCountParam.getEventValueMax());
}
if (StrUtil.isNotBlank(largeScreenCountParam.getSearchValue())) {
LambdaQueryWrapper<PqUserLedgerPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.select(PqUserLedgerPO::getId, PqUserLedgerPO::getCustomerName);
lambdaQueryWrapper.like(PqUserLedgerPO::getCustomerName, largeScreenCountParam.getSearchValue());
List<Integer> lineTemUserIds = new ArrayList<>();
pqUserLedgerPOList = pqUserLedgerMapper.selectList(lambdaQueryWrapper);
if (CollUtil.isNotEmpty(pqUserLedgerPOList)) {
List<String> userIds = pqUserLedgerPOList.stream().map(PqUserLedgerPO::getId).collect(Collectors.toList());
assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getUserIndex, userIds));
List<Integer> assIds = assList.stream().map(PqUserLineAssPO::getLineIndex).distinct().collect(Collectors.toList());
lineTemUserIds = deptslineIds.stream().filter(assIds::contains).collect(Collectors.toList());
}
ledgerList = pqLineService.getBaseLedger(deptslineIds, largeScreenCountParam.getSearchValue());
lineTemUserIds.addAll(ledgerList.stream().map(LedgerBaseInfoDTO::getLineId).collect(Collectors.toList()));
if (CollUtil.isEmpty(lineTemUserIds)) {
return pqsEventdetailPage;
}
if (lineTemUserIds.size() > 1000) {
List<List<Integer>> idPartitions = CollUtil.split(lineTemUserIds, 1000);
queryWrapper.and(ew -> {
for (List<Integer> pList : idPartitions) {
ew.or(w -> w.in(PqsEventdetail::getLineid, pList));
}
});
} else {
queryWrapper.in(PqsEventdetail::getLineid, lineTemUserIds);
}
} else {
if (deptslineIds.size() > 1000) {
List<List<Integer>> idPartitions = CollUtil.split(deptslineIds, 1000);
queryWrapper.and(ew -> {
for (List<Integer> pList : idPartitions) {
ew.or(w -> w.in(PqsEventdetail::getLineid, pList));
}
});
} else {
queryWrapper.in(PqsEventdetail::getLineid, deptslineIds);
}
}
List<PqsEventdetail> list = pqsEventdetailService.getBaseMapper().selectList(queryWrapper);
if (CollUtil.isEmpty(list)) {
return pqsEventdetailPage;
}
List<Integer> pageLineIds = list.stream().map(PqsEventdetail::getLineid).distinct().collect(Collectors.toList());
List<LedgerBaseInfoDTO> pageLedger = pqLineService.getBaseLedger(pageLineIds, null);
Map<Integer, LedgerBaseInfoDTO> ledgerBaseInfoDTOMap = pageLedger.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
List<PqUserLineAssPO> assLastList = pqUserLedgerMapper.getUserByParam(pageLineIds, null);
Map<Integer, List<String>> mapObj = assLastList.stream().collect(Collectors.groupingBy(PqUserLineAssPO::getLineIndex, Collectors.mapping(PqUserLineAssPO::getUserName, Collectors.toList())));
pqsEventdetailPage = list.stream().map(temp -> {
EventDetailVO eventDetailVO = new EventDetailVO();
eventDetailVO.setEventdetail_index(temp.getEventdetailIndex());
eventDetailVO.setTimeid(temp.getTimeid());
eventDetailVO.setMs(temp.getMs());
eventDetailVO.setWavetype(temp.getWavetype().toString());
eventDetailVO.setPersisttime(BigDecimal.valueOf(temp.getPersisttime() / 1000).setScale(3, RoundingMode.HALF_UP).toString());
eventDetailVO.setEventvalue(temp.getEventvalue());
eventDetailVO.setLookFlag(temp.getLookFlag());
eventDetailVO.setNoticeFlag(temp.getNoticeFlag());
if (ledgerBaseInfoDTOMap.containsKey(temp.getLineid())) {
LedgerBaseInfoDTO ledgerBaseInfoDTO = ledgerBaseInfoDTOMap.get(temp.getLineid());
eventDetailVO.setLineid(ledgerBaseInfoDTO.getLineId());
eventDetailVO.setPointname(ledgerBaseInfoDTO.getLineName());
eventDetailVO.setBdname(ledgerBaseInfoDTO.getStationName());
eventDetailVO.setGdName(ledgerBaseInfoDTO.getGdName());
eventDetailVO.setBusName(ledgerBaseInfoDTO.getBusBarName());
eventDetailVO.setObjName(ledgerBaseInfoDTO.getObjName());
}
String objName = "/";
if (mapObj.containsKey(eventDetailVO.getLineid())) {
objName = String.join(";", mapObj.get(eventDetailVO.getLineid()));
}
eventDetailVO.setObjName(objName);
return eventDetailVO;
}).collect(Collectors.toList());
return pqsEventdetailPage;
}
@Override
public Page<DeviceDTO> devicePage(LargeScreenCountParam largeScreenCountParam) {
TimeInterval timeInterval = new TimeInterval();
@@ -1534,6 +1652,4 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
}
}