代码优化

This commit is contained in:
hzj
2026-06-16 16:25:50 +08:00
parent 9a9a8151d9
commit 148e834f9c

View File

@@ -37,6 +37,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper; import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -159,7 +160,13 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
@Override @Override
// @Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
public Boolean addEventDetail(EventDeatilDTO deatilDTO) { public Boolean addEventDetail(EventDeatilDTO deatilDTO) {
RmpEventDetailPO one = this.lambdaQuery().eq(RmpEventDetailPO::getLineId, deatilDTO.getMonitorId()).eq(RmpEventDetailPO::getStartTime, deatilDTO.getStartTime()).one();
RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO(); RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO();
if(Objects.nonNull(one)){
BeanUtils.copyProperties(one,rmpEventDetailPO);
}
// rmpEventDetailPO.setMeasurementPointId(deatilDTO.getMonitorId()); // rmpEventDetailPO.setMeasurementPointId(deatilDTO.getMonitorId());
rmpEventDetailPO.setLineId(deatilDTO.getMonitorId()); rmpEventDetailPO.setLineId(deatilDTO.getMonitorId());
DictData data = dicDataFeignClient.getDicDataByCode(eventTypeReflection(deatilDTO.getEventType())).getData(); DictData data = dicDataFeignClient.getDicDataByCode(eventTypeReflection(deatilDTO.getEventType())).getData();
@@ -184,7 +191,6 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
rmpEventDetailPO.setSeverity(Double.valueOf(severity)); rmpEventDetailPO.setSeverity(Double.valueOf(severity));
rmpEventDetailPO.setCreateTime(LocalDateTime.now()); rmpEventDetailPO.setCreateTime(LocalDateTime.now());
RmpEventDetailPO one = this.lambdaQuery().eq(RmpEventDetailPO::getLineId, rmpEventDetailPO.getLineId()).eq(RmpEventDetailPO::getStartTime, rmpEventDetailPO.getStartTime()).one();
if(Objects.nonNull(one)){ if(Objects.nonNull(one)){
rmpEventDetailPO.setEventId(one.getEventId()); rmpEventDetailPO.setEventId(one.getEventId());