feat(alarm): 添加告警统计功能并优化设备管理
- 在AlarmVO中新增interruptCounts和warnCounts字段用于统计通信中断和终端告警次数 - 在CsAlarmServiceImpl中实现告警次数统计逻辑,解析告警事件数据并计算各类告警数量 - 重构CsEventUserPOServiceImpl中的查询逻辑,优化暂态事件详细信息查询接口 - 在CsEquipmentDeliveryServiceImpl中集成事件查询功能,实时获取设备告警状态 - 优化数据库查询语句,改进事件查询的排序和过滤逻辑
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package com.njcn.csharmonic.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csharmonic.param.CsHarmonicPlanParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
|
||||
import com.njcn.csharmonic.service.ICsHarmonicPlanService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 稳态指标方案 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/csHarmonicPlan")
|
||||
@Api(tags = "稳态指标方案")
|
||||
@AllArgsConstructor
|
||||
public class CsHarmonicPlanController extends BaseController {
|
||||
|
||||
private final ICsHarmonicPlanService csHarmonicPlanService;
|
||||
|
||||
/**
|
||||
* 新增稳态指标方案(包含监测点关联)
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/save")
|
||||
@ApiOperation("新增稳态指标方案")
|
||||
public HttpResult<Boolean> save(@RequestBody @Validated CsHarmonicPlanParam param) {
|
||||
String methodDescribe = getMethodDescribe("save");
|
||||
csHarmonicPlanService.save(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改稳态指标方案(包含监测点关联)
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改稳态指标方案")
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated CsHarmonicPlanParam.UpdateCsHarmonicPlanParam param) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
csHarmonicPlanService.update(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除稳态指标方案(同时删除监测点关联)
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除稳态指标方案")
|
||||
@ApiImplicitParam(name = "ids", value = "ID集合")
|
||||
public HttpResult<Boolean> delete(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
csHarmonicPlanService.deleteWithLines(ids);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询稳态指标方案(包含监测点列表)
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getById")
|
||||
@ApiOperation("根据ID查询稳态指标方案")
|
||||
@ApiImplicitParam(name = "id", value = "ID", required = true)
|
||||
public HttpResult<CsHarmonicPlan> getById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getById");
|
||||
CsHarmonicPlan plan = csHarmonicPlanService.getByIdWithLines(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, plan, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询稳态指标方案
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getPage")
|
||||
@ApiOperation("分页查询稳态指标方案")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<CsHarmonicPlan>> getPage(@RequestBody CsHarmonicPlanParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("getPage");
|
||||
Page<CsHarmonicPlan> page = csHarmonicPlanService.getPage(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有稳态指标方案
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询所有稳态指标方案")
|
||||
public HttpResult<List<CsHarmonicPlan>> list() {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
List<CsHarmonicPlan> list = csHarmonicPlanService.listAllOrderBySort();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.njcn.csharmonic.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csharmonic.param.CsHarmonicPlanLineParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlanLine;
|
||||
import com.njcn.csharmonic.service.ICsHarmonicPlanLineService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/csHarmonicPlanLine")
|
||||
@Api(tags = "稳态指标方案与测点关系")
|
||||
@AllArgsConstructor
|
||||
public class CsHarmonicPlanLineController extends BaseController {
|
||||
|
||||
private final ICsHarmonicPlanLineService csHarmonicPlanLineService;
|
||||
|
||||
/**
|
||||
* 根据方案ID查询关联的监测点
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getByPlanId")
|
||||
@ApiOperation("根据方案ID查询关联的监测点")
|
||||
@ApiImplicitParam(name = "id", value = "方案ID", required = true)
|
||||
public HttpResult<List<CsHarmonicPlanLine>> getByPlanId(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getByPlanId");
|
||||
List<CsHarmonicPlanLine> list = csHarmonicPlanLineService.getByPlanId(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增方案与监测点关联
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/savePlanLines")
|
||||
@ApiOperation("新增方案与监测点关联")
|
||||
public HttpResult<Boolean> savePlanLines(@RequestBody @Validated CsHarmonicPlanLineParam param) {
|
||||
String methodDescribe = getMethodDescribe("savePlanLines");
|
||||
csHarmonicPlanLineService.savePlanLines(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据监测点ID集合删除关联
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/deleteByLineIds")
|
||||
@ApiOperation("根据监测点ID集合删除关联")
|
||||
@ApiImplicitParam(name = "lineIds", value = "监测点ID集合")
|
||||
public HttpResult<Boolean> deleteByLineIds(@RequestBody List<String> lineIds) {
|
||||
String methodDescribe = getMethodDescribe("deleteByLineIds");
|
||||
csHarmonicPlanLineService.deleteByLineIds(lineIds);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据监测点ID查询方案ID
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getPlanIdByLineId")
|
||||
@ApiOperation("根据监测点ID查询方案ID")
|
||||
@ApiImplicitParam(name = "lineId", value = "监测点ID", required = true)
|
||||
public HttpResult<String> getPlanIdByLineId(@RequestParam("lineId") String lineId) {
|
||||
String methodDescribe = getMethodDescribe("getPlanIdByLineId");
|
||||
String planId = csHarmonicPlanLineService.getPlanIdByLineId(lineId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, planId, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,16 @@ public class EventUserController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryTempEventDetail")
|
||||
@ApiOperation("查询暂态事件详细信息(未读)")
|
||||
@ApiImplicitParam(name = "param", value = "暂降事件查询参数", required = true)
|
||||
public HttpResult<List<CsEventPO>> queryTempEventDetail(@RequestBody CsEventUserQueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("queryTempEventDetail");
|
||||
List<CsEventPO> result = csEventUserPOMapper.queryTempEventDetail(param.getUserId(), param.getStartTime(), param.getEndTime(), param.getEventIds());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryTempHarmonic")
|
||||
@ApiOperation("查询稳态事件(未读)")
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryPage;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
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.event.EventStatisticVO;
|
||||
@@ -40,6 +41,9 @@ public interface CsEventUserPOMapper extends BaseMapper<CsEventUserPO> {
|
||||
//查询暂态事件(未读)
|
||||
List<String> queryTempEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询暂态事件详细信息(未读)
|
||||
List<CsEventPO> queryTempEventDetail(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询稳态事件(未读)
|
||||
List<String> queryTempHarmonic(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csharmonic.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlanLine;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
public interface CsHarmonicPlanLineMapper extends BaseMapper<CsHarmonicPlanLine> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csharmonic.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
public interface CsHarmonicPlanMapper extends BaseMapper<CsHarmonicPlan> {
|
||||
|
||||
}
|
||||
@@ -150,10 +150,35 @@
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="queryEventpage" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">
|
||||
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
|
||||
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,
|
||||
c.dev_type devType
|
||||
<if test="csEventUserQueryPage != null and csEventUserQueryPage.type != null and csEventUserQueryPage.type != '' and csEventUserQueryPage.type ==0">
|
||||
,d.NAME lineName
|
||||
</if>
|
||||
from
|
||||
cs_event b
|
||||
inner join cs_equipment_delivery c on b.device_id=c.id
|
||||
<if test="csEventUserQueryPage != null and csEventUserQueryPage.type != null and csEventUserQueryPage.type != '' and csEventUserQueryPage.type ==0">
|
||||
inner join cs_line d on d.device_id=b.device_id
|
||||
</if>
|
||||
where 1=1
|
||||
and b.process=c.process
|
||||
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.endTime != null and csEventUserQueryPage.endTime !=''">
|
||||
AND DATE(b.start_time) <= DATE(#{csEventUserQueryPage.endTime})
|
||||
@@ -174,8 +199,11 @@
|
||||
<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 test="csEventUserQueryPage != null and csEventUserQueryPage.type != null and csEventUserQueryPage.type != ''">
|
||||
AND b.type = #{csEventUserQueryPage.type}
|
||||
<if test="csEventUserQueryPage.type == '0'">
|
||||
AND d.clDid = b.cl_did
|
||||
</if>
|
||||
</if>
|
||||
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''">
|
||||
AND b.level IN
|
||||
@@ -183,22 +211,27 @@
|
||||
#{level}
|
||||
</foreach>
|
||||
</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>
|
||||
<choose>
|
||||
<when 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>
|
||||
</when>
|
||||
<otherwise>
|
||||
order by b.start_time desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
</select>
|
||||
|
||||
@@ -268,6 +301,24 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryTempEventDetail" resultType="com.njcn.csharmonic.pojo.po.CsEventPO">
|
||||
SELECT
|
||||
t2.*
|
||||
FROM
|
||||
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
t1.user_id = #{userId}
|
||||
and t1.`status`= 0
|
||||
and t2.type = 0
|
||||
<if test="ids != null and ids.size > 0">
|
||||
and t2.line_id in
|
||||
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
and t2.start_time between #{startTime} and #{endTime}
|
||||
</select>
|
||||
|
||||
<select id="queryAlarmEvent" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.event_id
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.csharmonic.mapper.CsHarmonicPlanLineMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.csharmonic.mapper.CsHarmonicPlanMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.njcn.csharmonic.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csharmonic.param.CsHarmonicPlanLineParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlanLine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
public interface ICsHarmonicPlanLineService extends IService<CsHarmonicPlanLine> {
|
||||
|
||||
/**
|
||||
* 根据方案ID查询关联的监测点
|
||||
*
|
||||
* @param id 方案ID
|
||||
* @return 关联列表
|
||||
*/
|
||||
List<CsHarmonicPlanLine> getByPlanId(String id);
|
||||
|
||||
/**
|
||||
* 新增方案与监测点关联
|
||||
*
|
||||
* @param param 参数
|
||||
*/
|
||||
void savePlanLines(CsHarmonicPlanLineParam param);
|
||||
|
||||
/**
|
||||
* 根据监测点ID集合删除关联
|
||||
*
|
||||
* @param lineIds 监测点ID集合
|
||||
*/
|
||||
void deleteByLineIds(List<String> lineIds);
|
||||
|
||||
/**
|
||||
* 根据监测点ID查询方案ID
|
||||
*
|
||||
* @param lineId 监测点ID
|
||||
* @return 方案ID
|
||||
*/
|
||||
String getPlanIdByLineId(String lineId);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.njcn.csharmonic.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csharmonic.param.CsHarmonicPlanParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
public interface ICsHarmonicPlanService extends IService<CsHarmonicPlan> {
|
||||
|
||||
/**
|
||||
* 新增稳态指标方案(包含监测点关联)
|
||||
*
|
||||
* @param param 稳态指标方案参数
|
||||
*/
|
||||
void save(CsHarmonicPlanParam param);
|
||||
|
||||
/**
|
||||
* 修改稳态指标方案(包含监测点关联)
|
||||
*
|
||||
* @param param 稳态指标方案参数
|
||||
*/
|
||||
void update(CsHarmonicPlanParam.UpdateCsHarmonicPlanParam param);
|
||||
|
||||
/**
|
||||
* 删除稳态指标方案(同时删除监测点关联)
|
||||
*
|
||||
* @param ids 方案ID集合
|
||||
*/
|
||||
void deleteWithLines(List<String> ids);
|
||||
|
||||
/**
|
||||
* 分页查询稳态指标方案
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
Page<CsHarmonicPlan> getPage(CsHarmonicPlanParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 查询所有稳态指标方案(按sort降序)
|
||||
*
|
||||
* @return 稳态指标方案列表
|
||||
*/
|
||||
List<CsHarmonicPlan> listAllOrderBySort();
|
||||
|
||||
/**
|
||||
* 根据方案ID查询详情(包含监测点列表)
|
||||
*
|
||||
* @param id 方案ID
|
||||
* @return 方案详情
|
||||
*/
|
||||
CsHarmonicPlan getByIdWithLines(String id);
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.csdevice.api.CsLedgerFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
@@ -23,8 +25,10 @@ import com.njcn.csharmonic.pojo.vo.AlarmVO;
|
||||
import com.njcn.csharmonic.service.CsEventPOService;
|
||||
import com.njcn.csharmonic.service.CsEventUserPOService;
|
||||
import com.njcn.csharmonic.service.ICsAlarmService;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -53,6 +57,8 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
|
||||
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
|
||||
private final CsEventPOService csEventPOService;
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
@Override
|
||||
public Page<AlarmVO> queryAlarmList(LineParamDTO param) {
|
||||
@@ -93,7 +99,6 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
|
||||
List<CsAlarm> list = csAlarmPage.getRecords();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
//获取用户推送事件
|
||||
List<CsEventUserPO> userEvents = csEventUserPOService.queryEventListByUserId(RequestUtil.getUserIndex(), list.stream().map(CsAlarm::getId).collect(Collectors.toList()));
|
||||
|
||||
List<String> finalDevList = devList;
|
||||
@@ -112,6 +117,29 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
|
||||
alarmVO.setWarnNums(matchedDevIds.size());
|
||||
alarmVO.setDevIds(matchedDevIds);
|
||||
alarmVO.setIsRead(userEvents.stream().filter(item1->item1.getEventId().equals(alarm.getId())).findFirst().map(CsEventUserPO::getStatus).orElse(1));
|
||||
|
||||
int interruptCounts = 0;
|
||||
int warnCounts = 0;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
List<List<String>> resultList;
|
||||
List<List<String>> resultList2;
|
||||
try {
|
||||
resultList = objectMapper.readValue(alarm.getInterruptEvent(), new TypeReference<List<List<String>>>() {});
|
||||
resultList2 = objectMapper.readValue(alarm.getAlarmEvent(), new TypeReference<List<List<String>>>() {});
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
for (String matchedDevId : matchedDevIds) {
|
||||
for (int j = 0; j < devIds.length; j++) {
|
||||
if (Objects.equals(matchedDevId, devIds[j])) {
|
||||
interruptCounts = interruptCounts + (Objects.isNull(resultList.get(j)) ? 0 : resultList.get(j).get(0).split(",").length);
|
||||
warnCounts = warnCounts + (Objects.isNull(resultList2.get(j)) ? 0 : resultList2.get(j).size());
|
||||
}
|
||||
}
|
||||
}
|
||||
alarmVO.setInterruptCounts(interruptCounts);
|
||||
alarmVO.setWarnCounts(warnCounts);
|
||||
return alarmVO;
|
||||
})
|
||||
.filter(alarmVO -> alarmVO.getWarnNums() > 0)
|
||||
@@ -119,6 +147,35 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
|
||||
.collect(Collectors.toList());
|
||||
page1.setRecords(result);
|
||||
}
|
||||
|
||||
|
||||
// if (CollectionUtil.isNotEmpty(list)) {
|
||||
// //获取用户推送事件
|
||||
// List<CsEventUserPO> userEvents = csEventUserPOService.queryEventListByUserId(RequestUtil.getUserIndex(), list.stream().map(CsAlarm::getId).collect(Collectors.toList()));
|
||||
//
|
||||
// List<String> finalDevList = devList;
|
||||
// List<AlarmVO> result = list.stream()
|
||||
// .map(alarm -> {
|
||||
// AlarmVO alarmVO = new AlarmVO();
|
||||
// alarmVO.setEventId(alarm.getId());
|
||||
// alarmVO.setDate(alarm.getTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
//
|
||||
// String devListStr = alarm.getDevList();
|
||||
// String[] devIds = devListStr.split(",");
|
||||
// List<String> matchedDevIds = Arrays.stream(devIds)
|
||||
// .filter(devId -> StrUtil.isNotBlank(devId.trim()))
|
||||
// .filter(finalDevList::contains)
|
||||
// .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(1));
|
||||
// return alarmVO;
|
||||
// })
|
||||
// .filter(alarmVO -> alarmVO.getWarnNums() > 0)
|
||||
// .sorted((a1, a2) -> a2.getDate().compareTo(a1.getDate()))
|
||||
// .collect(Collectors.toList());
|
||||
// page1.setRecords(result);
|
||||
// }
|
||||
}
|
||||
}
|
||||
return page1;
|
||||
@@ -148,6 +205,10 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
|
||||
alarmDetail.setEngineeringName(ledgerMap.get(csLedgerVO.getPids().split(",")[1]).getName());
|
||||
alarmDetail.setProjectName(ledgerMap.get(csLedgerVO.getPids().split(",")[2]).getName());
|
||||
alarmDetail.setDevName(csLedgerVO.getName());
|
||||
//添加设备类型
|
||||
CsEquipmentDeliveryDTO dto = equipmentFeignClient.queryDeviceById(Collections.singletonList(csLedgerVO.getId())).getData().get(0);
|
||||
SysDicTreePO po = dictTreeFeignClient.queryById(dto.getDevType()).getData();
|
||||
alarmDetail.setDevType(Objects.isNull(po)?null:po.getCode());
|
||||
|
||||
if (ObjectUtil.isNotNull(alarm.getInterruptEvent())) {
|
||||
String interruptEvent = alarm.getInterruptEvent();
|
||||
|
||||
@@ -32,10 +32,12 @@ import com.njcn.csharmonic.service.CsEventUserPOService;
|
||||
import com.njcn.influx.pojo.dto.EventDataSetDTO;
|
||||
import com.njcn.influx.service.EvtDataService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.api.EleEvtFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.po.EleEvtParm;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -61,6 +63,7 @@ import java.util.stream.Collectors;
|
||||
public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, CsEventUserPO> implements CsEventUserPOService{
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
private final EvtDataService evtDataService;
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
@@ -354,6 +357,9 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
temp.setProjectName(devDetail.getProjectName());
|
||||
temp.setEngineeringid(devDetail.getEngineeringid());
|
||||
temp.setEngineeringName(devDetail.getEngineeringName());
|
||||
//设备类型
|
||||
SysDicTreePO po = dictTreeFeignClient.queryById(temp.getDevType()).getData();
|
||||
temp.setDevType(Objects.isNull(po)?null:po.getCode());
|
||||
//监测位置
|
||||
temp.setEvtParamPosition(Objects.equals(temp.getLocation(), "grid") ? "电网侧" : "负载侧");
|
||||
//暂态事件类型
|
||||
@@ -367,218 +373,6 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
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 ( ));
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.njcn.csharmonic.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csharmonic.mapper.CsHarmonicPlanLineMapper;
|
||||
import com.njcn.csharmonic.param.CsHarmonicPlanLineParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlanLine;
|
||||
import com.njcn.csharmonic.service.ICsHarmonicPlanLineService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CsHarmonicPlanLineServiceImpl extends ServiceImpl<CsHarmonicPlanLineMapper, CsHarmonicPlanLine> implements ICsHarmonicPlanLineService {
|
||||
|
||||
@Override
|
||||
public List<CsHarmonicPlanLine> getByPlanId(String id) {
|
||||
LambdaQueryWrapper<CsHarmonicPlanLine> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CsHarmonicPlanLine::getId, id);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void savePlanLines(CsHarmonicPlanLineParam param) {
|
||||
List<CsHarmonicPlanLine> planLineList = new ArrayList<>();
|
||||
for (String lineId : param.getLineIds()) {
|
||||
CsHarmonicPlanLine planLine = new CsHarmonicPlanLine();
|
||||
planLine.setId(param.getId());
|
||||
planLine.setLineId(lineId);
|
||||
planLineList.add(planLine);
|
||||
}
|
||||
this.saveBatch(planLineList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByLineIds(List<String> lineIds) {
|
||||
LambdaQueryWrapper<CsHarmonicPlanLine> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(CsHarmonicPlanLine::getLineId, lineIds);
|
||||
this.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlanIdByLineId(String lineId) {
|
||||
LambdaQueryWrapper<CsHarmonicPlanLine> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CsHarmonicPlanLine::getLineId, lineId)
|
||||
.last("LIMIT 1");
|
||||
CsHarmonicPlanLine planLine = this.getOne(wrapper);
|
||||
return planLine != null ? planLine.getId() : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.njcn.csharmonic.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.csharmonic.mapper.CsHarmonicPlanMapper;
|
||||
import com.njcn.csharmonic.param.CsHarmonicPlanParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlanLine;
|
||||
import com.njcn.csharmonic.service.ICsHarmonicPlanLineService;
|
||||
import com.njcn.csharmonic.service.ICsHarmonicPlanService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CsHarmonicPlanServiceImpl extends ServiceImpl<CsHarmonicPlanMapper, CsHarmonicPlan> implements ICsHarmonicPlanService {
|
||||
|
||||
private final ICsHarmonicPlanLineService csHarmonicPlanLineService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(CsHarmonicPlanParam param) {
|
||||
CsHarmonicPlan plan = new CsHarmonicPlan();
|
||||
plan.setName(param.getName());
|
||||
plan.setHarmonicTarget(param.getHarmonicTarget());
|
||||
plan.setSort(param.getSort() != null ? param.getSort() : 0);
|
||||
this.save(plan);
|
||||
|
||||
if (CollUtil.isNotEmpty(param.getLineList())) {
|
||||
for (String lineId : param.getLineList()) {
|
||||
LambdaQueryWrapper<CsHarmonicPlanLine> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CsHarmonicPlanLine::getLineId, lineId);
|
||||
csHarmonicPlanLineService.remove(wrapper);
|
||||
|
||||
CsHarmonicPlanLine planLine = new CsHarmonicPlanLine();
|
||||
planLine.setId(plan.getId());
|
||||
planLine.setLineId(lineId);
|
||||
csHarmonicPlanLineService.save(planLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(CsHarmonicPlanParam.UpdateCsHarmonicPlanParam param) {
|
||||
CsHarmonicPlan plan = this.getById(param.getId());
|
||||
if (plan == null) {
|
||||
throw new RuntimeException("稳态指标方案不存在");
|
||||
}
|
||||
plan.setName(param.getName());
|
||||
plan.setHarmonicTarget(param.getHarmonicTarget());
|
||||
plan.setSort(param.getSort() != null ? param.getSort() : plan.getSort());
|
||||
this.updateById(plan);
|
||||
|
||||
if (CollUtil.isNotEmpty(param.getLineList())) {
|
||||
LambdaQueryWrapper<CsHarmonicPlanLine> oldWrapper = new LambdaQueryWrapper<>();
|
||||
oldWrapper.eq(CsHarmonicPlanLine::getId, param.getId());
|
||||
csHarmonicPlanLineService.remove(oldWrapper);
|
||||
|
||||
for (String lineId : param.getLineList()) {
|
||||
LambdaQueryWrapper<CsHarmonicPlanLine> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CsHarmonicPlanLine::getLineId, lineId);
|
||||
csHarmonicPlanLineService.remove(wrapper);
|
||||
|
||||
CsHarmonicPlanLine planLine = new CsHarmonicPlanLine();
|
||||
planLine.setId(param.getId());
|
||||
planLine.setLineId(lineId);
|
||||
csHarmonicPlanLineService.save(planLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteWithLines(List<String> ids) {
|
||||
this.removeByIds(ids);
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
LambdaQueryWrapper<CsHarmonicPlanLine> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(CsHarmonicPlanLine::getId, ids);
|
||||
List<CsHarmonicPlanLine> list = csHarmonicPlanLineService.list();
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
throw new BusinessException("该方案下存在监测点,重新分配后再尝试删除!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CsHarmonicPlan> getPage(CsHarmonicPlanParam.QueryParam param) {
|
||||
Page<CsHarmonicPlan> page = new Page<>(param.getPageNum(), param.getPageSize());
|
||||
LambdaQueryWrapper<CsHarmonicPlan> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(param.getName()), CsHarmonicPlan::getName, param.getName())
|
||||
.orderByAsc(CsHarmonicPlan::getSort)
|
||||
.orderByAsc(CsHarmonicPlan::getCreateTime);
|
||||
return this.page(page, wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsHarmonicPlan> listAllOrderBySort() {
|
||||
LambdaQueryWrapper<CsHarmonicPlan> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.orderByAsc(CsHarmonicPlan::getSort);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsHarmonicPlan getByIdWithLines(String id) {
|
||||
CsHarmonicPlan plan = this.getById(id);
|
||||
if (plan != null) {
|
||||
List<CsHarmonicPlanLine> planLines = csHarmonicPlanLineService.getByPlanId(id);
|
||||
if (CollUtil.isNotEmpty(planLines)) {
|
||||
List<String> lineIds = planLines.stream()
|
||||
.map(CsHarmonicPlanLine::getLineId)
|
||||
.collect(Collectors.toList());
|
||||
plan.setLineList(lineIds);
|
||||
}
|
||||
}
|
||||
return plan;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user