1、app消息数据查询重构

2、app消息已读未读方法重构
3、其余辅助功能添加
This commit is contained in:
xy
2026-04-01 20:28:04 +08:00
parent 33da822317
commit dbe09d70f4
59 changed files with 1529 additions and 711 deletions

View File

@@ -152,6 +152,16 @@ public class CsEventController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateEventById")
@ApiOperation("修改事件信息(修改文件)")
@ApiImplicitParam(name = "id", value = "事件id", required = true)
public HttpResult<Boolean> updateEventById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("updateEventById");
Boolean result = csEventPOService.updateEventById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEventByTime")
@ApiOperation("根据时间获取无波形的暂态事件")

View File

@@ -10,7 +10,6 @@ import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
*
@@ -27,7 +26,13 @@ public interface CsEventUserPOMapper extends BaseMapper<CsEventUserPO> {
List<EventDetailVO> queryUserEventList(@Param("csEventUserQueryParam") CsEventUserQueryParam csEventUserQueryParam, @Param("devIds") List<String> devIds, @Param("flag") Boolean flag);
Page<EventDetailVO> queryEventpage(Page<EventDetailVO> returnpage, @Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage, @Param("devIds") List<String> devIds, @Param("flag") Boolean flag);
// Page<EventDetailVO> queryEventpage(Page<EventDetailVO> returnpage, @Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage, @Param("devIds") List<String> devIds, @Param("flag") Boolean flag);
/**
* app事件查询
*/
Page<EventDetailVO> queryEventpage(Page<EventDetailVO> returnpage, @Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage, @Param("devIds") List<String> devIds);
Page<EventDetailVO> queryEventPageWeb(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("devIds") List<String> collect);
}

View File

@@ -87,17 +87,73 @@
</select>
<!-- <select id="queryEventpage" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">-->
<!-- select DISTINCT a.event_id id,-->
<!-- <if test="flag">-->
<!-- a.status status,-->
<!-- </if>-->
<!-- <if test="!flag">-->
<!-- 1 status,-->
<!-- </if>-->
<!-- b.device_id deviceId,b.line_id lineId,b.code code,b.start_time startTime,b.amplitude,b.persist_time,-->
<!-- round(b.amplitude,2) evtParamVVaDepth,round(b.persist_time,2) evtParamTm,b.tag tag ,b.wave_path wavePath,b.phase evtParamPhase,b.location evtParamPosition,b.instant_pics,b.rms_pics , b.type type,b.level level,b.location location,d.name lineName-->
<!-- from cs_event_user a inner join cs_event b on a.event_id=b.id inner join cs_equipment_delivery c on b.device_id=c.id inner join cs_line d on d.device_id=b.device_id and d.clDid=b.cl_did where 1=1-->
<!-- and b.process=c.process-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.endTime != null and csEventUserQueryPage.endTime !=''">-->
<!-- AND DATE(b.start_time) &lt;= DATE(#{csEventUserQueryPage.endTime})-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.startTime != null and csEventUserQueryPage.startTime !=''">-->
<!-- AND DATE(b.start_time) &gt;= DATE(#{csEventUserQueryPage.startTime})-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.target != null and csEventUserQueryPage.target.size()>0">-->
<!-- and b.tag in-->
<!-- <foreach collection="csEventUserQueryPage.target" index="index" item="item" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- and b.device_id in-->
<!-- <foreach collection="devIds" index="index" item="item" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != null and csEventUserQueryPage.type !=''">-->
<!-- AND b.type =#{ csEventUserQueryPage.type}-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''">-->
<!-- AND b.level IN-->
<!-- <foreach collection="csEventUserQueryPage.level.split(',')" item="level" open="(" separator="," close=")">-->
<!-- #{level}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.status != null and csEventUserQueryPage.status !=''">-->
<!-- AND a.status =#{ csEventUserQueryPage.status}-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.userId != null and csEventUserQueryPage.userId !=''">-->
<!-- and a.user_id=#{ csEventUserQueryPage.userId}-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.sortField != null">-->
<!-- <choose>-->
<!-- <when test="csEventUserQueryPage.sortField == 0">-->
<!-- order by b.start_time desc-->
<!-- </when>-->
<!-- <when test="csEventUserQueryPage.sortField == 1">-->
<!-- order by b.amplitude desc-->
<!-- </when>-->
<!-- <when test="csEventUserQueryPage.sortField == 2">-->
<!-- order by b.persist_time desc-->
<!-- </when>-->
<!-- <otherwise>-->
<!-- order by b.start_time desc-->
<!-- </otherwise>-->
<!-- </choose>-->
<!-- </if>-->
<!-- </select>-->
<select id="queryEventpage" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">
select DISTINCT a.event_id id,
<if test="flag">
a.status status,
</if>
<if test="!flag">
1 status,
</if>
b.device_id deviceId,b.line_id lineId,b.code code,
b.start_time startTime, b.amplitude evtParamVVaDepth,b.persist_time evtParamTm,b.tag tag ,b.wave_path wavePath,b.instant_pics,b.rms_pics , b.type type,b.level level,b.location location,d.name lineName
from cs_event_user a inner join cs_event b on a.event_id=b.id inner join cs_equipment_delivery c on b.device_id=c.id inner join cs_line d on d.device_id=b.device_id and d.clDid=b.cl_did where 1=1
select DISTINCT b.id,b.device_id deviceId,b.line_id lineId,b.code code,b.start_time startTime,b.amplitude,b.persist_time,
round(b.amplitude,2) evtParamVVaDepth,round(b.persist_time,2) evtParamTm,b.phase evtParamPhase,b.location evtParamPosition,
b.tag tag ,b.wave_path wavePath,b.instant_pics,b.rms_pics , b.type type,b.level level,b.location location,d.name lineName
from cs_event b inner join cs_equipment_delivery c on b.device_id=c.id inner join cs_line d on d.device_id=b.device_id and d.clDid=b.cl_did where 1=1
and b.process=c.process
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.endTime != null and csEventUserQueryPage.endTime !=''">
AND DATE(b.start_time) &lt;= DATE(#{csEventUserQueryPage.endTime})
@@ -106,7 +162,6 @@
AND DATE(b.start_time) &gt;= DATE(#{csEventUserQueryPage.startTime})
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.target != null and csEventUserQueryPage.target.size()>0">
and b.tag in
<foreach collection="csEventUserQueryPage.target" index="index" item="item" open="(" separator="," close=")">
#{item}
@@ -116,6 +171,9 @@
<foreach collection="devIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.lineId != null and csEventUserQueryPage.lineId !=''">
AND b.line_id = #{csEventUserQueryPage.lineId}
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != null and csEventUserQueryPage.type !=''">
AND b.type =#{ csEventUserQueryPage.type}
</if>
@@ -125,12 +183,6 @@
#{level}
</foreach>
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.status != null and csEventUserQueryPage.status !=''">
AND a.status =#{ csEventUserQueryPage.status}
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.userId != null and csEventUserQueryPage.userId !=''">
and a.user_id=#{ csEventUserQueryPage.userId}
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.sortField != null">
<choose>
<when test="csEventUserQueryPage.sortField == 0">
@@ -147,6 +199,7 @@
</otherwise>
</choose>
</if>
</select>
<select id="queryEventPageWeb" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">

View File

@@ -66,6 +66,8 @@ public interface CsEventPOService extends IService<CsEventPO>{
void addCldEvent(CldEventParam param);
Boolean updateEventById(String id);
List<CsEventPO> getEventByTime(List<String> lineList, String startTime, String endTime);
List<EventStatisticsVo> getEventStatistics(CsEventUserQueryParam param);

View File

@@ -71,7 +71,7 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
if (CollectionUtil.isNotEmpty(devLedger)) {
List<String> ownerDevList = csCommTerminalFeignClient.getDevIdsByUser(RequestUtil.getUserIndex()).getData();
List<String> devList = devLedger.stream().map(CsLedger::getPid).collect(Collectors.toList());
List<String> devList = devLedger.stream().map(CsLedger::getPid).distinct().collect(Collectors.toList());
// 取 ownerDevList 和 devList 的交集
if (CollectionUtil.isNotEmpty(ownerDevList)) {
@@ -108,7 +108,7 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
.collect(Collectors.toList());
alarmVO.setWarnNums(matchedDevIds.size());
alarmVO.setDevIds(matchedDevIds);
alarmVO.setIsRead(userEvents.stream().filter(item1->item1.getEventId().equals(alarm.getId())).findFirst().map(CsEventUserPO::getStatus).orElse(0));
alarmVO.setIsRead(userEvents.stream().filter(item1->item1.getEventId().equals(alarm.getId())).findFirst().map(CsEventUserPO::getStatus).orElse(1));
return alarmVO;
})
.filter(alarmVO -> alarmVO.getWarnNums() > 0)

View File

@@ -402,6 +402,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
eventPo.setProcess(4);
eventPo.setPersistTime(param.getDuration());
eventPo.setAmplitude(param.getAmplitude() * 100);
eventPo.setPhase(param.getPhase());
this.baseMapper.insert(eventPo);
//influxDB数据录入
List<String> records = new ArrayList<String>();
@@ -479,6 +480,24 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
}
}
@Override
public Boolean updateEventById(String id) {
boolean result = false;
CsEventPO po = this.baseMapper.selectById(id);
if (po != null) {
LambdaQueryWrapper<RmpEventDetailPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RmpEventDetailPO::getEventId,id);
RmpEventDetailPO po2 = wlRmpEventDetailMapper.selectOne(wrapper);
po2.setWavePath(po2.getWavePath());
po2.setFileFlag(1);
int row = wlRmpEventDetailMapper.updateById(po2);
if (row > 0) {
result = true;
}
}
return result;
}
public List<String> getEventUser(String devId,boolean isAdmin) {
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
@@ -538,6 +557,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
rmpEventDetailPO.setEventDescribe(getTag(param.getEventType()));
rmpEventDetailPO.setPhase(param.getPhase());
rmpEventDetailPO.setDealFlag(0);
rmpEventDetailPO.setFileFlag(0);
wlRmpEventDetailMapper.insert(rmpEventDetailPO);
}

View File

@@ -41,8 +41,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -229,7 +227,6 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
@Override
public Page<EventDetailVO> queryEventpage(CsEventUserQueryPage csEventUserQueryPage) {
Page<EventDetailVO> returnpage = new Page<> (csEventUserQueryPage.getPageNum ( ), csEventUserQueryPage.getPageSize ( ));
Boolean flag =Boolean.TRUE;
csEventUserQueryPage.setUserId(RequestUtil.getUserIndex());
String role = RequestUtil.getUserRole();
@@ -322,119 +319,243 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
if (CollectionUtils.isEmpty(collect)) {
return returnpage;
}
returnpage = this.getBaseMapper().queryEventpage(returnpage, csEventUserQueryPage, collect, flag);
// 先获取原始记录
List<EventDetailVO> originalRecords = returnpage.getRecords();
if (CollectionUtil.isNotEmpty(originalRecords)) {
// 过滤出满足 lineId 条件的记录
List<EventDetailVO> filteredRecords = new ArrayList<>();
for (EventDetailVO temp : originalRecords) {
// 如果没有传 lineId 或者 lineId 匹配,则处理该记录
if (StringUtil.isBlank(csEventUserQueryPage.getLineId())
|| Objects.equals(temp.getLineId(), csEventUserQueryPage.getLineId())) {
DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData();
temp.setEquipmentName(devDetail.getEquipmentName());
temp.setProjectId(devDetail.getProjectId());
temp.setProjectName(devDetail.getProjectName());
temp.setEngineeringid(devDetail.getEngineeringid());
temp.setEngineeringName(devDetail.getEngineeringName());
EleEpdPqd ele = epdFeignClient.findByName(temp.getTag()).getData();
temp.setShowName(Objects.isNull(ele) ? temp.getTag() : ele.getShowName());
temp.setCode(Objects.isNull(ele) ? null : ele.getDefaultValue());
if (Objects.equals(csEventUserQueryPage.getType(), "0")) {
List<EleEvtParm> data1 = eleEvtFeignClient.queryByPid(ele.getId()).getData();
List<EventDataSetDTO> eventDataSetDTOS = new ArrayList<>();
for (EleEvtParm eleEvtParm : data1) {
EventDataSetDTO eventDataSetDTO = new EventDataSetDTO();
BeanUtils.copyProperties(eleEvtParm, eventDataSetDTO);
if (Objects.equals(eventDataSetDTO.getName(), "Evt_Param_Position")) {
continue;
}
EventDataSetDTO evtData = evtDataService.getEventDataSet("evt_data", temp.getId(), eleEvtParm.getName());
if (evtData == null) {
eventDataSetDTO.setValue("-");
} else {
if (Objects.equals(eleEvtParm.getName(), "Evt_Param_VVaDepth") || Objects.equals(eleEvtParm.getName(), "Evt_Param_Tm")) {
BigDecimal bd = new BigDecimal(evtData.getValue());
bd = bd.setScale(2, RoundingMode.HALF_UP);
eventDataSetDTO.setValue(Optional.ofNullable(bd.toString()).orElse("-"));
} else {
eventDataSetDTO.setValue(Optional.ofNullable(evtData.getValue()).orElse("-"));
}
}
eventDataSetDTOS.add(eventDataSetDTO);
}
temp.setDataSet(eventDataSetDTOS);
List<EventDataSetDTO> evtParamVVaDepth = eventDataSetDTOS.stream()
.filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_VVaDepth"))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(evtParamVVaDepth)) {
temp.setEvtParamVVaDepth("-");
} else {
if (Objects.equals(evtParamVVaDepth.get(0).getValue(),"-")) {
temp.setEvtParamVVaDepth("-");
} else {
BigDecimal bd = new BigDecimal(evtParamVVaDepth.get(0).getValue());
bd = bd.setScale(2, RoundingMode.HALF_UP);
temp.setEvtParamVVaDepth(bd + (Objects.isNull(evtParamVVaDepth.get(0).getUnit()) ? "" : evtParamVVaDepth.get(0).getUnit()));
}
}
List<EventDataSetDTO> evtParamPosition = eventDataSetDTOS.stream()
.filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Position"))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(evtParamPosition)) {
temp.setEvtParamPosition("-");
} else {
temp.setEvtParamPosition(evtParamPosition.get(0).getValue());
}
if (Objects.equals(temp.getEvtParamPosition(), "-")) {
if (!Objects.isNull(temp.getLocation())) {
temp.setEvtParamPosition(Objects.equals(temp.getLocation(), "grid") ? "电网侧" : "负载侧");
}
}
List<EventDataSetDTO> evtParamTm = eventDataSetDTOS.stream()
.filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Tm"))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(evtParamTm)) {
temp.setEvtParamTm("-");
} else {
if (Objects.equals(evtParamTm.get(0).getValue(),"-")) {
temp.setEvtParamTm("-");
} else {
BigDecimal bd = new BigDecimal(evtParamTm.get(0).getValue());
bd = bd.setScale(2, RoundingMode.HALF_UP);
temp.setEvtParamTm(bd + (Objects.isNull(evtParamTm.get(0).getUnit()) ? "" : evtParamTm.get(0).getUnit()));
}
}
List<EventDataSetDTO> evtParamPhase = eventDataSetDTOS.stream()
.filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Phase"))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(evtParamPhase)) {
temp.setEvtParamPhase("-");
} else {
temp.setEvtParamPhase(evtParamPhase.get(0).getValue()
+ (Objects.isNull(evtParamPhase.get(0).getUnit()) ? "" : evtParamPhase.get(0).getUnit()));
}
}
// 将处理后的记录添加到结果列表
filteredRecords.add(temp);
}
}
// 清空原来的记录,加入过滤后的记录
returnpage.setRecords(filteredRecords);
returnpage = this.getBaseMapper().queryEventpage(returnpage, csEventUserQueryPage, collect);
if (CollectionUtil.isNotEmpty(returnpage.getRecords())) {
List<String> ids = returnpage.getRecords().stream().map(EventDetailVO::getId).collect(Collectors.toList());
List<CsEventUserPO> userEvents = this.queryEventListByUserId(RequestUtil.getUserIndex(),ids);
returnpage.getRecords().forEach(temp -> {
//台账信息
DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData();
temp.setEquipmentName(devDetail.getEquipmentName());
temp.setProjectId(devDetail.getProjectId());
temp.setProjectName(devDetail.getProjectName());
temp.setEngineeringid(devDetail.getEngineeringid());
temp.setEngineeringName(devDetail.getEngineeringName());
//监测位置
temp.setEvtParamPosition(Objects.equals(temp.getLocation(), "grid") ? "电网侧" : "负载侧");
//暂态事件类型
EleEpdPqd ele = epdFeignClient.findByName(temp.getTag()).getData();
temp.setShowName(Objects.isNull(ele) ? temp.getTag() : ele.getShowName());
temp.setCode(Objects.isNull(ele) ? null : ele.getDefaultValue());
//匹配已读/未读状态
temp.setStatus(userEvents.stream().filter(item1->item1.getEventId().equals(temp.getId())).findFirst().map(CsEventUserPO::getStatus).orElse(1));
});
}
return returnpage;
}
// @Override
// public Page<EventDetailVO> queryEventpage(CsEventUserQueryPage csEventUserQueryPage) {
// Page<EventDetailVO> returnpage = new Page<> (csEventUserQueryPage.getPageNum ( ), csEventUserQueryPage.getPageSize ( ));
//
// csEventUserQueryPage.setUserId(RequestUtil.getUserIndex());
// String role = RequestUtil.getUserRole();
// if(Objects.equals(role, LogInfo.UNKNOWN_ROLE)){
// return returnpage;
// }
// List<String> strings = JSONArray.parseArray(role, String.class);
// if(CollectionUtils.isEmpty(strings)){
// return returnpage;
// }
// role=strings.get(0);
// if( Objects.equals(role, AppRoleEnum.APP_VIP_USER.getCode())&&Objects.equals(csEventUserQueryPage.getType(),"3")){
// csEventUserQueryPage.setLevel("3");
// }
//
// List<CsLedgerVO> data = csLedgerFeignClient.lineTree().getData();
// if (CollectionUtils.isEmpty(data)) {
// return returnpage;
// }
//
// // 获取第一层节点(根节点),从第二层开始才是真正的工程
// List<CsLedgerVO> firstLevelNodes = new ArrayList<>();
// for (CsLedgerVO rootNode : data) {
// List<CsLedgerVO> children = rootNode.getChildren();
// if (CollectionUtil.isNotEmpty(children)) {
// firstLevelNodes.addAll(children);
// }
// }
//
// if (CollectionUtils.isEmpty(firstLevelNodes)) {
// return returnpage;
// }
//
// // 缓存查询条件到局部变量
// String engineeringId = csEventUserQueryPage.getEngineeringid();
// String projectId = csEventUserQueryPage.getProjectId();
// String deviceId = csEventUserQueryPage.getDeviceId();
// String lineId = csEventUserQueryPage.getLineId();
//
// // 从第二层开始遍历:工程 -> 项目 -> 设备 -> 监测点
// List<String> collect = new ArrayList<>();
// for (CsLedgerVO engineering : firstLevelNodes) {
// // 过滤工程
// if (StringUtil.isNotBlank(engineeringId)
// && !Objects.equals(engineering.getId(), engineeringId)) {
// continue;
// }
//
// List<CsLedgerVO> projects = engineering.getChildren();
// if (CollectionUtils.isEmpty(projects)) {
// continue;
// }
//
// for (CsLedgerVO project : projects) {
// // 过滤项目
// if (StringUtil.isNotBlank(projectId)
// && !Objects.equals(project.getId(), projectId)) {
// continue;
// }
//
// List<CsLedgerVO> devices = project.getChildren();
// if (CollectionUtils.isEmpty(devices)) {
// continue;
// }
//
// for (CsLedgerVO device : devices) {
// // 过滤设备
// if (StringUtil.isNotBlank(deviceId)
// && !Objects.equals(device.getId(), deviceId)) {
// continue;
// }
//
// // 如果传了监测点 ID需要进一步过滤
// if (StringUtil.isNotBlank(lineId)) {
// List<CsLedgerVO> lines = device.getChildren();
// if (CollectionUtil.isNotEmpty(lines)) {
// boolean hasLine = lines.stream()
// .anyMatch(line -> Objects.equals(line.getId(), lineId));
// if (hasLine) {
// collect.add(device.getId());
// }
// }
// } else {
// // 没有传监测点 ID直接添加设备 ID
// collect.add(device.getId());
// }
// }
// }
// }
// if (CollectionUtils.isEmpty(collect)) {
// return returnpage;
// }
// //如果是游客用户,没有消息推送的数据,展示设备的所有数据
// if(strings.contains(AppRoleEnum.TOURIST.getCode())){
// returnpage = this.getBaseMapper().queryTouristEvent(returnpage, csEventUserQueryPage, collect, false);
// } else {
// returnpage = this.getBaseMapper().queryEventpage(returnpage, csEventUserQueryPage, collect, true);
// }
// // 先获取原始记录
// List<EventDetailVO> originalRecords = returnpage.getRecords();
// if (CollectionUtil.isNotEmpty(originalRecords)) {
// // 过滤出满足 lineId 条件的记录
// List<EventDetailVO> filteredRecords = new ArrayList<>();
// for (EventDetailVO temp : originalRecords) {
// // 如果没有传 lineId 或者 lineId 匹配,则处理该记录
// if (StringUtil.isBlank(csEventUserQueryPage.getLineId())
// || Objects.equals(temp.getLineId(), csEventUserQueryPage.getLineId())) {
//
// DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData();
// temp.setEquipmentName(devDetail.getEquipmentName());
// temp.setProjectId(devDetail.getProjectId());
// temp.setProjectName(devDetail.getProjectName());
// temp.setEngineeringid(devDetail.getEngineeringid());
// temp.setEngineeringName(devDetail.getEngineeringName());
//
// EleEpdPqd ele = epdFeignClient.findByName(temp.getTag()).getData();
// temp.setShowName(Objects.isNull(ele) ? temp.getTag() : ele.getShowName());
// temp.setCode(Objects.isNull(ele) ? null : ele.getDefaultValue());
//
// if (Objects.equals(csEventUserQueryPage.getType(), "0")) {
// List<EleEvtParm> data1 = eleEvtFeignClient.queryByPid(ele.getId()).getData();
// List<EventDataSetDTO> eventDataSetDTOS = new ArrayList<>();
// for (EleEvtParm eleEvtParm : data1) {
// EventDataSetDTO eventDataSetDTO = new EventDataSetDTO();
// BeanUtils.copyProperties(eleEvtParm, eventDataSetDTO);
// if (Objects.equals(eventDataSetDTO.getName(), "Evt_Param_Position")) {
// continue;
// }
// EventDataSetDTO evtData = evtDataService.getEventDataSet("evt_data", temp.getId(), eleEvtParm.getName());
// if (evtData == null) {
// eventDataSetDTO.setValue("-");
// } else {
// if (Objects.equals(eleEvtParm.getName(), "Evt_Param_VVaDepth") || Objects.equals(eleEvtParm.getName(), "Evt_Param_Tm")) {
// BigDecimal bd = new BigDecimal(evtData.getValue());
// bd = bd.setScale(2, RoundingMode.HALF_UP);
// eventDataSetDTO.setValue(Optional.ofNullable(bd.toString()).orElse("-"));
// } else {
// eventDataSetDTO.setValue(Optional.ofNullable(evtData.getValue()).orElse("-"));
// }
// }
// eventDataSetDTOS.add(eventDataSetDTO);
// }
// temp.setDataSet(eventDataSetDTOS);
//
// List<EventDataSetDTO> evtParamVVaDepth = eventDataSetDTOS.stream()
// .filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_VVaDepth"))
// .collect(Collectors.toList());
//
// if (CollectionUtil.isEmpty(evtParamVVaDepth)) {
// temp.setEvtParamVVaDepth("-");
// } else {
// if (Objects.equals(evtParamVVaDepth.get(0).getValue(),"-")) {
// temp.setEvtParamVVaDepth("-");
// } else {
// BigDecimal bd = new BigDecimal(evtParamVVaDepth.get(0).getValue());
// bd = bd.setScale(2, RoundingMode.HALF_UP);
// temp.setEvtParamVVaDepth(bd + (Objects.isNull(evtParamVVaDepth.get(0).getUnit()) ? "" : evtParamVVaDepth.get(0).getUnit()));
// }
// }
//
// List<EventDataSetDTO> evtParamPosition = eventDataSetDTOS.stream()
// .filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Position"))
// .collect(Collectors.toList());
// if (CollectionUtil.isEmpty(evtParamPosition)) {
// temp.setEvtParamPosition("-");
// } else {
// temp.setEvtParamPosition(evtParamPosition.get(0).getValue());
// }
// if (Objects.equals(temp.getEvtParamPosition(), "-")) {
// if (!Objects.isNull(temp.getLocation())) {
// temp.setEvtParamPosition(Objects.equals(temp.getLocation(), "grid") ? "电网侧" : "负载侧");
// }
// }
//
// List<EventDataSetDTO> evtParamTm = eventDataSetDTOS.stream()
// .filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Tm"))
// .collect(Collectors.toList());
// if (CollectionUtil.isEmpty(evtParamTm)) {
// temp.setEvtParamTm("-");
// } else {
// if (Objects.equals(evtParamTm.get(0).getValue(),"-")) {
// temp.setEvtParamTm("-");
// } else {
// BigDecimal bd = new BigDecimal(evtParamTm.get(0).getValue());
// bd = bd.setScale(2, RoundingMode.HALF_UP);
// temp.setEvtParamTm(bd + (Objects.isNull(evtParamTm.get(0).getUnit()) ? "" : evtParamTm.get(0).getUnit()));
// }
// }
//
// List<EventDataSetDTO> evtParamPhase = eventDataSetDTOS.stream()
// .filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Phase"))
// .collect(Collectors.toList());
// if (CollectionUtil.isEmpty(evtParamPhase)) {
// temp.setEvtParamPhase("-");
// } else {
// temp.setEvtParamPhase(evtParamPhase.get(0).getValue()
// + (Objects.isNull(evtParamPhase.get(0).getUnit()) ? "" : evtParamPhase.get(0).getUnit()));
// }
// }
// // 将处理后的记录添加到结果列表
// filteredRecords.add(temp);
// }
// }
// // 清空原来的记录,加入过滤后的记录
// returnpage.setRecords(filteredRecords);
// }
// return returnpage;
// }
@Override
public Page<EventDetailVO> queryEventPageWeb(CsEventUserQueryPage csEventUserQueryPage) {
Page<EventDetailVO> returnpage = new Page<> (csEventUserQueryPage.getPageNum ( ), csEventUserQueryPage.getPageSize ( ));

View File

@@ -65,15 +65,16 @@ public class CsHarmonicServiceImpl extends ServiceImpl<CsHarmonicMapper, CsHarmo
.filter(ownerList::contains)
.distinct()
.collect(Collectors.toList());
} else {
combinedLineIds = lineIds;
}
LambdaQueryWrapper<CsHarmonic> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(CsHarmonic::getLineId, combinedLineIds)
.ge(StrUtil.isNotBlank(param.getTime()), CsHarmonic::getTime, PublicDataUtils.calculateMonthStart(param.getTime()))
.le(StrUtil.isNotBlank(param.getTime()), CsHarmonic::getTime, PublicDataUtils.calculateMonthEnd(param.getTime()))
.orderByDesc(CsHarmonic::getTime);
List<CsHarmonic> list = list(queryWrapper);
List<CsHarmonic> list = new ArrayList<>();
if (CollectionUtil.isNotEmpty(combinedLineIds)) {
LambdaQueryWrapper<CsHarmonic> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(CsHarmonic::getLineId, combinedLineIds)
.ge(StrUtil.isNotBlank(param.getTime()), CsHarmonic::getTime, PublicDataUtils.calculateMonthStart(param.getTime()))
.le(StrUtil.isNotBlank(param.getTime()), CsHarmonic::getTime, PublicDataUtils.calculateMonthEnd(param.getTime()))
.orderByDesc(CsHarmonic::getTime);
list = list(queryWrapper);
}
if (CollectionUtil.isNotEmpty(list)) {
//获取所有台账数据
List<CsLedgerVO> ledgers = csLedgerFeignClient.getAllLedger().getData();
@@ -102,7 +103,7 @@ public class CsHarmonicServiceImpl extends ServiceImpl<CsHarmonicMapper, CsHarmo
lineHarmonicDetail.setLineName(ledger.getName());
lineHarmonicDetail.setStatisticsDate(item.getTime());
lineHarmonicDetail.setOverLimitDesc(item.getTag());
lineHarmonicDetail.setIsRead(userEvents.stream().filter(item1->item1.getEventId().equals(item.getId())).findFirst().map(CsEventUserPO::getStatus).orElse(0));
lineHarmonicDetail.setIsRead(userEvents.stream().filter(item1->item1.getEventId().equals(item.getId())).findFirst().map(CsEventUserPO::getStatus).orElse(1));
lineHarmonicDetails.add(lineHarmonicDetail);
});
vo.setList(lineHarmonicDetails);

View File

@@ -8,7 +8,6 @@ import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm;
import com.njcn.csdevice.pojo.po.CsUserPins;
import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.pojo.vo.EngineeringHomePageVO;
import com.njcn.csharmonic.pojo.dto.UnReadEventDto;
import com.njcn.csharmonic.service.CsEventUserPOService;
@@ -41,25 +40,36 @@ public class HomePageServiceImpl implements HomePageService {
List<EngineeringHomePageVO> result = new ArrayList<>();
List<CsEngineeringVO> engineeringList = engineeringFeignClient.queryEngineering(new CsEngineeringQueryParm()).getData();
if (CollectionUtils.isNotEmpty(engineeringList)) {
// 提取所有工程 ID
List<String> engineeringIds = engineeringList.stream().map(CsEngineeringVO::getId).collect(Collectors.toList());
//根据工程获取设备信息
// 批量获取所有工程的设备信息
List<DevDetailDTO> devList = csLedgerFeignClient.getDevInfoByEngineerIds(engineeringIds).getData();
Map<String, List<DevDetailDTO>> devMap = devList.stream().collect(Collectors.groupingBy(DevDetailDTO::getEngineeringid));
//获取未读事件
Map<String, List<DevDetailDTO>> devMap = Objects.isNull(devList) ? new HashMap<>() :
devList.stream().collect(Collectors.groupingBy(DevDetailDTO::getEngineeringid));
// 获取未读事件
List<UnReadEventDto> unReadEventList = csEventUserPOService.queryEngineeringEventCount(RequestUtil.getUserIndex());
Map<String, List<UnReadEventDto>> unReadEventMap = unReadEventList.stream().collect(Collectors.groupingBy(UnReadEventDto::getDeviceId));
engineeringList.forEach(item->{
Map<String, List<UnReadEventDto>> unReadEventMap = Objects.isNull(unReadEventList) ? new HashMap<>() :
unReadEventList.stream().collect(Collectors.groupingBy(UnReadEventDto::getDeviceId));
// 遍历工程列表,从内存中获取设备数据
engineeringList.forEach(item -> {
EngineeringHomePageVO vo = new EngineeringHomePageVO();
vo.setEngineeringId(item.getId());
vo.setEngineeringName(item.getName());
// 从 Map 中获取该工程的设备列表 (无设备时为 null 或空列表)
List<DevDetailDTO> devs = devMap.get(item.getId());
vo.setDevTotal(Objects.isNull(devs) ? 0:devs.size());
vo.setDevTotal(Objects.isNull(devs) ? 0 : devs.size());
long status1Count = devs == null ? 0 : devs.stream().filter(d -> d.getRunStatus() == 1).count();
long status2Count = devs == null ? 0 : devs.stream().filter(d -> d.getRunStatus() == 2).count();
vo.setOnlineDevTotal((int) status2Count);
vo.setOfflineDevTotal((int) status1Count);
vo.setSort(item.getSort());
//未读的告警数量
// 未读的告警数量
int alarmTotal = Objects.isNull(devs) ? 0 : devs.stream()
.map(DevDetailDTO::getEquipmentId)
.filter(Objects::nonNull)
@@ -71,10 +81,11 @@ public class HomePageServiceImpl implements HomePageService {
})
.sum();
vo.setAlarmTotal(alarmTotal);
result.add(vo);
});
//获取用户是否有置顶的工程
// 获取用户是否有置顶的工程
List<CsUserPins> pinList = csUserPinsFeignClient.getPinToTopList().getData();
if (CollectionUtils.isNotEmpty(pinList)) {
List<String> targetIdList = pinList.stream()
@@ -107,5 +118,4 @@ public class HomePageServiceImpl implements HomePageService {
return result;
}
}