|
@@ -9,6 +9,7 @@ import com.zksy.api.domain.WarningThresholdLevel;
|
|
|
import com.zksy.api.domain.dto.ThresholdEvaluationResult;
|
|
import com.zksy.api.domain.dto.ThresholdEvaluationResult;
|
|
|
import com.zksy.api.domain.dto.ThresholdLevelValue;
|
|
import com.zksy.api.domain.dto.ThresholdLevelValue;
|
|
|
import com.zksy.api.mapper.EquipmentBaseApiMapper;
|
|
import com.zksy.api.mapper.EquipmentBaseApiMapper;
|
|
|
|
|
+import com.zksy.api.mapper.EquipmentWarningTypeBindingMapper;
|
|
|
import com.zksy.api.mapper.WarningThresholdConfigMapper;
|
|
import com.zksy.api.mapper.WarningThresholdConfigMapper;
|
|
|
import com.zksy.api.mapper.WarningThresholdLevelMapper;
|
|
import com.zksy.api.mapper.WarningThresholdLevelMapper;
|
|
|
import com.zksy.api.mapper.WarningTypeApiMapper;
|
|
import com.zksy.api.mapper.WarningTypeApiMapper;
|
|
@@ -24,6 +25,7 @@ import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -39,6 +41,7 @@ public class ThresholdEvaluationServiceImpl implements ThresholdEvaluationServic
|
|
|
private final WarningThresholdConfigMapper configMapper;
|
|
private final WarningThresholdConfigMapper configMapper;
|
|
|
private final WarningThresholdLevelMapper levelMapper;
|
|
private final WarningThresholdLevelMapper levelMapper;
|
|
|
private final EquipmentBaseApiMapper equipmentBaseMapper;
|
|
private final EquipmentBaseApiMapper equipmentBaseMapper;
|
|
|
|
|
+ private final EquipmentWarningTypeBindingMapper warningTypeBindingMapper;
|
|
|
private final WarningTypeApiMapper warningTypeMapper;
|
|
private final WarningTypeApiMapper warningTypeMapper;
|
|
|
private final AlarmDataService alarmDataService;
|
|
private final AlarmDataService alarmDataService;
|
|
|
private final EarlyWarningAutoService earlyWarningAutoService;
|
|
private final EarlyWarningAutoService earlyWarningAutoService;
|
|
@@ -47,12 +50,14 @@ public class ThresholdEvaluationServiceImpl implements ThresholdEvaluationServic
|
|
|
public ThresholdEvaluationServiceImpl(WarningThresholdConfigMapper configMapper,
|
|
public ThresholdEvaluationServiceImpl(WarningThresholdConfigMapper configMapper,
|
|
|
WarningThresholdLevelMapper levelMapper,
|
|
WarningThresholdLevelMapper levelMapper,
|
|
|
EquipmentBaseApiMapper equipmentBaseMapper,
|
|
EquipmentBaseApiMapper equipmentBaseMapper,
|
|
|
|
|
+ EquipmentWarningTypeBindingMapper warningTypeBindingMapper,
|
|
|
WarningTypeApiMapper warningTypeMapper,
|
|
WarningTypeApiMapper warningTypeMapper,
|
|
|
AlarmDataService alarmDataService,
|
|
AlarmDataService alarmDataService,
|
|
|
EarlyWarningAutoService earlyWarningAutoService) {
|
|
EarlyWarningAutoService earlyWarningAutoService) {
|
|
|
this.configMapper = configMapper;
|
|
this.configMapper = configMapper;
|
|
|
this.levelMapper = levelMapper;
|
|
this.levelMapper = levelMapper;
|
|
|
this.equipmentBaseMapper = equipmentBaseMapper;
|
|
this.equipmentBaseMapper = equipmentBaseMapper;
|
|
|
|
|
+ this.warningTypeBindingMapper = warningTypeBindingMapper;
|
|
|
this.warningTypeMapper = warningTypeMapper;
|
|
this.warningTypeMapper = warningTypeMapper;
|
|
|
this.alarmDataService = alarmDataService;
|
|
this.alarmDataService = alarmDataService;
|
|
|
this.earlyWarningAutoService = earlyWarningAutoService;
|
|
this.earlyWarningAutoService = earlyWarningAutoService;
|
|
@@ -117,6 +122,23 @@ public class ThresholdEvaluationServiceImpl implements ThresholdEvaluationServic
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<String> findApplicableWarningCodes(String deviceCode) {
|
|
|
|
|
+ if (isBlank(deviceCode)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ EquipmentBase device = equipmentBaseMapper.selectOne(
|
|
|
|
|
+ Wrappers.lambdaQuery(EquipmentBase.class)
|
|
|
|
|
+ .and(wrapper -> wrapper.eq(EquipmentBase::getEquipmentId, deviceCode)
|
|
|
|
|
+ .or().eq(EquipmentBase::getEquipmentCode, deviceCode))
|
|
|
|
|
+ .last("LIMIT 1"));
|
|
|
|
|
+ if (device == null || device.getEquipmentTypeId() == null) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> codes = warningTypeBindingMapper.selectWarningCodesByEquipmentType(device.getEquipmentTypeId());
|
|
|
|
|
+ return codes == null ? Collections.emptyList() : codes;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public ThresholdLevelValue resolveAlarmThreshold(String deviceCode, String warningCode,
|
|
public ThresholdLevelValue resolveAlarmThreshold(String deviceCode, String warningCode,
|
|
|
LocalDateTime sampleTime) {
|
|
LocalDateTime sampleTime) {
|