暂态严重度计算

This commit is contained in:
hzj
2025-03-12 11:39:08 +08:00
parent 21035dc71b
commit 7f6aa6f683
2 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
package com.njcn.event.utils;
import java.text.DecimalFormat;
/**
* Description:暂态事件工具类
* Date: 2025/03/12 上午 9:26【需求编号】
*
* @author clam
* @version V1.0.0
*/
public class EventUtil {
/**
* @Description: 暂态严重度计算
* @Param: persisttime持续时间毫秒eventvaule暂减深度
* @return: java.lang.String
* @Author: clam
* @Date: 2025/03/12
*/
public static String getYzd(Float persisttime, Float eventvaule) {
float yzd;
DecimalFormat df = new DecimalFormat("0.000");// 格式化小数
if (persisttime <= 20) {
yzd = 1 - eventvaule;
} else if (persisttime > 20 && persisttime <= 200) {
yzd = 2 * (1 - eventvaule);
} else if (persisttime > 200 && persisttime <= 500) {
yzd = 3.3f * (1 - eventvaule);
} else if (persisttime > 500 && persisttime <= 10000) {
yzd = 5 * (1 - eventvaule);
} else {
yzd = 10 * (1 - eventvaule);
}
return df.format(yzd);
}
}

View File

@@ -6,6 +6,7 @@ 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.event.utils.EventUtil;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.pojo.dto.EventDeatilDTO;
import com.njcn.event.pojo.po.EventDetail;
@@ -137,7 +138,8 @@ public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEv
rmpEventDetailPO.setPhase(deatilDTO.getPhase());
rmpEventDetailPO.setWavePath(deatilDTO.getWavePath());
rmpEventDetailPO.setEventDescribe(" ");
rmpEventDetailPO.setSeverity(0.00);
String severity = EventUtil.getYzd(deatilDTO.getDuration().floatValue(),(deatilDTO.getAmplitude().floatValue()/100));
rmpEventDetailPO.setSeverity(Double.valueOf(severity));
rmpEventDetailPO.setCreateTime(LocalDateTime.now());
RmpEventDetailPO one = this.lambdaQuery().eq(RmpEventDetailPO::getLineId, rmpEventDetailPO.getLineId()).eq(RmpEventDetailPO::getStartTime, rmpEventDetailPO.getStartTime()).one();