refactor(service): 修改前置告警信息返回类型为专用VO

- 添加FrontWarnVo类用于封装前置告警信息
- 将getFrontWarnInfo方法的返回类型从Page<CsEventPO>改为Page<FrontWarnVo>
- 在实现类中创建新的Page<FrontWarnVo>对象并复制数据
- 使用BeanUtils将CsEventPO属性复制到FrontWarnVo对象
- 更新控制器中的返回类型以匹配新的VO类型
- 移除旧的FrontWarnVO类定义
This commit is contained in:
xy
2026-06-30 13:38:07 +08:00
parent ff3341549f
commit d84d91a241
4 changed files with 18 additions and 37 deletions

View File

@@ -1,32 +0,0 @@
package com.njcn.csharmonic.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author xy
*/
@Data
public class FrontWarnVO implements Serializable {
@ApiModelProperty("前置id")
private String frontId;
@ApiModelProperty("前置ip")
private String frontIp;
@ApiModelProperty("前置进程号")
private Integer processNo;
@ApiModelProperty("事件发生时间")
private String startTime;
@ApiModelProperty("告警描述")
private String tag;
@ApiModelProperty("告警码")
private Integer code;
}

View File

@@ -14,6 +14,7 @@ import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.pojo.vo.FrontWarnVo;
import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO;
import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.web.controller.BaseController;
@@ -89,9 +90,9 @@ public class EventUserController extends BaseController {
@PostMapping("/frontWarnInfo")
@ApiOperation("前置告警信息")
@ApiImplicitParam(name = "baseParam", value = "基础查询数据", required = true)
public HttpResult<Page<CsEventPO>> frontWarnInfo(@RequestBody CldWarnParam baseParam) {
public HttpResult<Page<FrontWarnVo>> frontWarnInfo(@RequestBody CldWarnParam baseParam) {
String methodDescribe = getMethodDescribe("frontWarnInfo");
Page<CsEventPO> list = csEventUserPOService.getFrontWarnInfo(baseParam);
Page<FrontWarnVo> list = csEventUserPOService.getFrontWarnInfo(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}

View File

@@ -9,6 +9,7 @@ import com.njcn.csharmonic.pojo.dto.UnReadEventDto;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.pojo.vo.FrontWarnVo;
import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO;
import com.njcn.web.pojo.param.BaseParam;
@@ -38,7 +39,7 @@ public interface CsEventUserPOService extends IService<CsEventUserPO>{
Page<EventDetailVO> queryEventPageWeb(CsEventUserQueryPage csEventUserQueryPage);
Page<CsEventPO> getFrontWarnInfo(CldWarnParam baseParam);
Page<FrontWarnVo> getFrontWarnInfo(CldWarnParam baseParam);
/**
* 查询用户事件列表

View File

@@ -27,6 +27,7 @@ import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.po.PqGovernPlan;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.pojo.vo.FrontWarnVo;
import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO;
import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.csharmonic.utils.DataChangeUtil;
@@ -556,7 +557,8 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
}
@Override
public Page<CsEventPO> getFrontWarnInfo(CldWarnParam baseParam) {
public Page<FrontWarnVo> getFrontWarnInfo(CldWarnParam baseParam) {
Page<FrontWarnVo> result = new Page<>(baseParam.getPageNum(), baseParam.getPageSize());
Page<CsEventPO> page = new Page<>(baseParam.getPageNum(), baseParam.getPageSize());
List<Node> nodeList = nodeFeignClient.nodeAllList().getData();
Map<String, Node> nodeMap = new HashMap<>();
@@ -588,8 +590,10 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
}
List<CsEventPO> records = page.getRecords();
if (CollUtil.isNotEmpty(records)) {
List<FrontWarnVo> frontWarnVos = new ArrayList<>();
Map<String, Node> finalNodeMap = nodeMap;
page.getRecords().forEach(item->{
FrontWarnVo vo = new FrontWarnVo();
//这边将前置名称放进lineId字段将前置IP放进wavePath字段进程号使用clDid
Node node = finalNodeMap.get(item.getDeviceId());
item.setLineId(Objects.isNull(node) ? null : node.getName());
@@ -602,9 +606,16 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
} else if (item.getLevel() == 7) {
item.setLevel(1);
}
BeanUtils.copyProperties(item, vo);
frontWarnVos.add(vo);
});
result.setRecords(frontWarnVos);
result.setTotal(page.getTotal());
result.setPages(page.getPages());
result.setCurrent(page.getCurrent());
result.setSize(page.getSize());
}
return page;
return result;
}
@Override