diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java index 191a069..cf05d3d 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java @@ -9,6 +9,8 @@ import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.source.service.DroolsAlarmService; import com.hnac.hzims.alarm.source.service.MessageService; import com.hnac.hzims.alarm.source.service.SoeAlarmService; +import com.hnac.hzims.common.constant.CommonConstant; +import com.hnac.hzims.common.utils.CommonUtil; import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; @@ -21,10 +23,7 @@ import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; import static com.hnac.hzims.alarm.config.constants.AlarmConstants.*; @@ -55,15 +54,8 @@ public class SoeAlarmServiceImpl implements SoeAlarmService { public List receiveMessage(String message) { // 对象转换 SoeAlarmVo parseObject = JSONObject.parseObject(message, SoeAlarmVo.class); - List alarms = Arrays.asList(parseObject); - if (CollectionUtil.isEmpty(alarms)) { - return new ArrayList<>(); - } - List res = alarms.stream().map(s -> { - AlarmEntity entity = getAlarmEntity(s); - return entity; - }).collect(Collectors.toList()); - return res; + List alarms = Collections.singletonList(parseObject); + return alarms.stream().map(this::getAlarmEntity).collect(Collectors.toList()); } private AlarmEntity getAlarmEntity(SoeAlarmVo item) { @@ -81,7 +73,7 @@ public class SoeAlarmServiceImpl implements SoeAlarmService { entity.setAlarmLevel(Integer.valueOf(item.getLevel())); entity.setAlarmStatus(1); entity.setDeviceCode(item.getDeviceCode()); - entity.setTenantId("200000"); + entity.setTenantId(CommonConstant.TENANT_ID); entity.setStationId(item.getProjectId()); R stationByCode = stationClient.getStationByCode(item.getProjectId()); if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){