初始版本提交

This commit is contained in:
hzj
2025-07-03 14:21:15 +08:00
parent 3a239b5123
commit 0cf8bbc3d5
3 changed files with 36 additions and 51 deletions

View File

@@ -1,7 +1,12 @@
package com.njcn.gather.event.transientes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.gather.event.transientes.pojo.po.MsgEventInfo;
import java.util.List;
public interface MsgEventInfoService extends IService<MsgEventInfo> {
List<MsgEventInfo> getMsgByIds(List<String> ids);
}

View File

@@ -209,19 +209,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> warnEvent = eventdetails.stream().filter(temp -> temp.getEventvalue() >= 0.5&& temp.getEventvalue() <0.9).collect(Collectors.toList());
List<String> eventIds = eventdetails.stream().map(PqsEventdetail::getEventdetailIndex).collect(Collectors.toList());
//通知
List<MsgEventInfo> msgEventInfoList = new ArrayList<>();
if(!CollectionUtils.isEmpty(eventIds)){
if(eventIds.size()>1000){
List<List<String>> listEven = CollUtil.split(eventIds,1000);
for(List<String> pList: listEven){
List<MsgEventInfo> temp = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex,pList).list();
msgEventInfoList.addAll(temp);
}
}else {
List<MsgEventInfo> temp = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex,eventIds).list();
msgEventInfoList.addAll(temp);
}
}
List<MsgEventInfo> msgEventInfoList =msgEventInfoService.getMsgByIds(eventIds);
msgEventInfoList = msgEventInfoList.stream().sorted(Comparator.comparing(MsgEventInfo::getSendTime,Comparator.reverseOrder())).collect(Collectors.toList());
@@ -312,20 +301,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
if (Objects.equals(largeScreenCountParam.getEventtype(), 1)) {
List<String> eventIds = eventdetails.stream().map(PqsEventdetail::getEventdetailIndex).collect(Collectors.toList());
//通知
List<MsgEventInfo> msgEventInfoList = new ArrayList<>();
if(!CollectionUtils.isEmpty(eventIds)){
if(eventIds.size()>1000){
List<List<String>> listEven = CollUtil.split(eventIds,1000);
for(List<String> pList: listEven){
List<MsgEventInfo> temp = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex,pList).list();
msgEventInfoList.addAll(temp);
}
}else {
List<MsgEventInfo> temp = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex,eventIds).list();
msgEventInfoList.addAll(temp);
}
}
List<MsgEventInfo> msgEventInfoList =msgEventInfoService.getMsgByIds(eventIds);
// 使用 for 循环处理日期范围
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
EventTrendVO eventTrendVO = new EventTrendVO();
@@ -611,7 +587,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<String> eveIdndex = eventdetails.stream().map(PqsEventdetail::getEventdetailIndex).collect(Collectors.toList());
List<MsgEventInfo> temp = new ArrayList<>();
if(!CollectionUtils.isEmpty(eveIdndex)){
temp = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex,eveIdndex).list();
temp =msgEventInfoService.getMsgByIds(eveIdndex);
}
List<EventDetailVO> change = change(eventdetails,temp);
@@ -668,16 +645,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
}
List<String> eventIds = allEventList.stream().map(PqsEventdetail::getEventdetailIndex).collect(Collectors.toList());
if (eventIds.size() > 1000) {
List<List<String>> listEven = CollUtil.split(eventIds, 1000);
for (List<String> pList : listEven) {
List<MsgEventInfo> msgEventInfoList = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex, pList).list();
result.addAll(msgEventInfoList);
}
} else {
List<MsgEventInfo> msgEventInfoList = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex, eventIds).list();
result.addAll(msgEventInfoList);
}
result =msgEventInfoService.getMsgByIds(eventIds);
result = result.stream().sorted(Comparator.comparing(MsgEventInfo::getSendTime, Comparator.reverseOrder())).collect(Collectors.toList());
if (result.size() > 200) {
result = result.subList(0, 200);
@@ -775,19 +743,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqsEventdetail> warnEvent = eventdetails.stream().filter(temp -> temp.getEventvalue() >= 0.5&& temp.getEventvalue() <0.9).collect(Collectors.toList());
List<String> eventIds = eventdetails.stream().map(PqsEventdetail::getEventdetailIndex).collect(Collectors.toList());
//通知
List<MsgEventInfo> msgEventInfoList = new ArrayList<>();
if(!CollectionUtils.isEmpty(eventIds)){
if(eventIds.size()>1000){
List<List<String>> listEven = CollUtil.split(eventIds,1000);
for(List<String> pList: listEven){
List<MsgEventInfo> temp = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex,pList).list();
msgEventInfoList.addAll(temp);
}
}else {
List<MsgEventInfo> temp = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex,eventIds).list();
msgEventInfoList.addAll(temp);
}
}
List<MsgEventInfo> msgEventInfoList =msgEventInfoService.getMsgByIds(eventIds);
msgEventInfoList = msgEventInfoList.stream().sorted(Comparator.comparing(MsgEventInfo::getSendTime,Comparator.reverseOrder())).collect(Collectors.toList());

View File

@@ -1,10 +1,15 @@
package com.njcn.gather.event.transientes.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.gather.event.transientes.mapper.MsgEventInfoMapper;
import com.njcn.gather.event.transientes.pojo.po.MsgEventInfo;
import com.njcn.gather.event.transientes.service.MsgEventInfoService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: cdf
@@ -13,4 +18,22 @@ import org.springframework.stereotype.Service;
*/
@Service
public class MsgEventInfoServiceImpl extends ServiceImpl<MsgEventInfoMapper, MsgEventInfo> implements MsgEventInfoService {
@Override
public List<MsgEventInfo> getMsgByIds(List<String> ids) {
//通知
List<MsgEventInfo> msgEventInfoList = new ArrayList<>();
if(!CollectionUtils.isEmpty(ids)){
if(ids.size()>1000){
List<List<String>> listEven = CollUtil.split(ids,1000);
for(List<String> pList: listEven){
List<MsgEventInfo> temp = this.lambdaQuery().in(MsgEventInfo::getEventIndex,pList).list();
msgEventInfoList.addAll(temp);
}
}else {
List<MsgEventInfo> temp = this.lambdaQuery().in(MsgEventInfo::getEventIndex,ids).list();
msgEventInfoList.addAll(temp);
}
}
return msgEventInfoList;
}
}