|
@@ -5,14 +5,12 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.persagy.apm.diagnose.feign.AlarmResult;
|
|
import com.persagy.apm.diagnose.feign.AlarmResult;
|
|
import com.persagy.apm.diagnose.feign.client.AlarmServiceClient;
|
|
import com.persagy.apm.diagnose.feign.client.AlarmServiceClient;
|
|
import com.persagy.apm.diagnose.indicatorrecord.service.impl.MonitorIndicatorRecordServiceImpl;
|
|
import com.persagy.apm.diagnose.indicatorrecord.service.impl.MonitorIndicatorRecordServiceImpl;
|
|
|
|
+import com.persagy.apm.diagnose.maintenance.model.dto.AlarmCondition;
|
|
import com.persagy.apm.diagnose.service.dto.*;
|
|
import com.persagy.apm.diagnose.service.dto.*;
|
|
import com.persagy.apm.diagnose.utils.AlarmResultUtil;
|
|
import com.persagy.apm.diagnose.utils.AlarmResultUtil;
|
|
-import com.persagy.apm.diagnose.utils.DmpResultUtil;
|
|
|
|
import com.persagy.apm.diagnose.utils.RedisUtil;
|
|
import com.persagy.apm.diagnose.utils.RedisUtil;
|
|
-import com.persagy.apm.energyalarmstarter.alarmdata.feign.DmpResult;
|
|
|
|
-import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmconfig.QueryAlarmConfigDTO;
|
|
|
|
-import com.persagy.apm.energyalarmstarter.alarmdata.model.vo.AlarmConfigItem;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@@ -30,6 +28,8 @@ import java.util.stream.Collectors;
|
|
@Service
|
|
@Service
|
|
public class EnergyAlarmServiceImpl {
|
|
public class EnergyAlarmServiceImpl {
|
|
|
|
|
|
|
|
+ @Value(value = "${energy.eq.run.system.code}")
|
|
|
|
+ private String systemCode;
|
|
@Autowired
|
|
@Autowired
|
|
AlarmServiceClient alarmServiceClient;
|
|
AlarmServiceClient alarmServiceClient;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -47,7 +47,7 @@ public class EnergyAlarmServiceImpl {
|
|
public List<MonitorIndicatorConfigDTO> queryMonitorIndicatorConfigDTOList(String projectId) throws Exception {
|
|
public List<MonitorIndicatorConfigDTO> queryMonitorIndicatorConfigDTOList(String projectId) throws Exception {
|
|
MonitorIndicatorConfigDTO monitorIndicatorConfigDTO = MonitorIndicatorConfigDTO.builder().build();
|
|
MonitorIndicatorConfigDTO monitorIndicatorConfigDTO = MonitorIndicatorConfigDTO.builder().build();
|
|
monitorIndicatorConfigDTO.setProjectId(projectId);
|
|
monitorIndicatorConfigDTO.setProjectId(projectId);
|
|
- monitorIndicatorConfigDTO.setGroupCode("WD");
|
|
|
|
|
|
+ monitorIndicatorConfigDTO.setGroupCode(systemCode);
|
|
monitorIndicatorConfigDTO.setPd("asdasdasda");
|
|
monitorIndicatorConfigDTO.setPd("asdasdasda");
|
|
monitorIndicatorConfigDTO.setUserId("test");
|
|
monitorIndicatorConfigDTO.setUserId("test");
|
|
AlarmResult<JSONObject> result = alarmServiceClient.query(monitorIndicatorConfigDTO);
|
|
AlarmResult<JSONObject> result = alarmServiceClient.query(monitorIndicatorConfigDTO);
|
|
@@ -64,7 +64,7 @@ public class EnergyAlarmServiceImpl {
|
|
* @return: java.util.Map<java.lang.String, com.persagy.apm.diagnose.service.dto.CalculateMethodDTO>
|
|
* @return: java.util.Map<java.lang.String, com.persagy.apm.diagnose.service.dto.CalculateMethodDTO>
|
|
*/
|
|
*/
|
|
public Map<String, CalculateMethodDTO> queryCalculateMethods() throws Exception {
|
|
public Map<String, CalculateMethodDTO> queryCalculateMethods() throws Exception {
|
|
- AlarmResult<JSONObject> result = alarmServiceClient.queryCalculateMethods(CalculateMethodDTO.builder().groupCode("WD").userId("test").pd("asdasdasdasdadsdasdasdasdasdasd").build());
|
|
|
|
|
|
+ AlarmResult<JSONObject> result = alarmServiceClient.queryCalculateMethods(CalculateMethodDTO.builder().groupCode(systemCode).userId("test").pd("asdasdasdasdadsdasdasdasdasdasd").build());
|
|
List<CalculateMethodDTO> records = AlarmResultUtil.getRecords(result, CalculateMethodDTO.class);
|
|
List<CalculateMethodDTO> records = AlarmResultUtil.getRecords(result, CalculateMethodDTO.class);
|
|
return records.stream().collect(Collectors.toMap(CalculateMethodDTO::getId, Function.identity(), (key1, key2) -> key2));
|
|
return records.stream().collect(Collectors.toMap(CalculateMethodDTO::getId, Function.identity(), (key1, key2) -> key2));
|
|
}
|
|
}
|
|
@@ -79,7 +79,7 @@ public class EnergyAlarmServiceImpl {
|
|
* @updateTime 2021/9/27 11:54
|
|
* @updateTime 2021/9/27 11:54
|
|
*/
|
|
*/
|
|
public Map<String, String> queryObjId_indicatorAndMethodId(String projectId,String objId, List<String> indicatorIdList) throws Exception {
|
|
public Map<String, String> queryObjId_indicatorAndMethodId(String projectId,String objId, List<String> indicatorIdList) throws Exception {
|
|
- MonitorIndicatorConfigByEquipDTO build = MonitorIndicatorConfigByEquipDTO.builder().projectId(projectId).objId(objId).monitorIndicatorId(indicatorIdList).groupCode("WD").userId("test").pd("wwwwwwwwww").build();
|
|
|
|
|
|
+ MonitorIndicatorConfigByEquipDTO build = MonitorIndicatorConfigByEquipDTO.builder().projectId(projectId).objId(objId).monitorIndicatorId(indicatorIdList).groupCode(systemCode).userId("test").pd("wwwwwwwwww").build();
|
|
AlarmResult<JSONObject> result = alarmServiceClient.query_by_equip(build);
|
|
AlarmResult<JSONObject> result = alarmServiceClient.query_by_equip(build);
|
|
JSONObject content = result.getContent();
|
|
JSONObject content = result.getContent();
|
|
if (content == null) {
|
|
if (content == null) {
|
|
@@ -125,7 +125,7 @@ public class EnergyAlarmServiceImpl {
|
|
* @updateTime 2021/9/27 11:54
|
|
* @updateTime 2021/9/27 11:54
|
|
*/
|
|
*/
|
|
public String queryObjIndicatorMethodId(String projectId,String objId, String indicatorId) throws Exception {
|
|
public String queryObjIndicatorMethodId(String projectId,String objId, String indicatorId) throws Exception {
|
|
- MonitorIndicatorConfigByEquipDTO build = MonitorIndicatorConfigByEquipDTO.builder().projectId(projectId).objId(objId).monitorIndicatorId(Arrays.asList(indicatorId)).groupCode("WD").userId("test").pd("wwwwwwwwww").build();
|
|
|
|
|
|
+ MonitorIndicatorConfigByEquipDTO build = MonitorIndicatorConfigByEquipDTO.builder().projectId(projectId).objId(objId).monitorIndicatorId(Arrays.asList(indicatorId)).groupCode(systemCode).userId("test").pd("wwwwwwwwww").build();
|
|
AlarmResult<JSONObject> result = alarmServiceClient.query_by_equip(build);
|
|
AlarmResult<JSONObject> result = alarmServiceClient.query_by_equip(build);
|
|
JSONObject content = result.getContent();
|
|
JSONObject content = result.getContent();
|
|
if (content == null) {
|
|
if (content == null) {
|
|
@@ -160,10 +160,45 @@ public class EnergyAlarmServiceImpl {
|
|
public List<AlarmRuleDTO> getProjectAlarmRules(String projectId) throws Exception {
|
|
public List<AlarmRuleDTO> getProjectAlarmRules(String projectId) throws Exception {
|
|
AlarmRuleDTO alarmRuleDTO = AlarmRuleDTO.builder().build();
|
|
AlarmRuleDTO alarmRuleDTO = AlarmRuleDTO.builder().build();
|
|
alarmRuleDTO.setProjectId(projectId);
|
|
alarmRuleDTO.setProjectId(projectId);
|
|
- alarmRuleDTO.setGroupCode("WD");
|
|
|
|
|
|
+ alarmRuleDTO.setGroupCode(systemCode);
|
|
alarmRuleDTO.setPd("asdasdasda");
|
|
alarmRuleDTO.setPd("asdasdasda");
|
|
alarmRuleDTO.setUserId("test");
|
|
alarmRuleDTO.setUserId("test");
|
|
AlarmResult<JSONObject> result = alarmServiceClient.queryProjectAlarmRules(alarmRuleDTO);
|
|
AlarmResult<JSONObject> result = alarmServiceClient.queryProjectAlarmRules(alarmRuleDTO);
|
|
return AlarmResultUtil.getRecords(result, AlarmRuleDTO.class);
|
|
return AlarmResultUtil.getRecords(result, AlarmRuleDTO.class);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @throws
|
|
|
|
+ * @title queryMonitorIndicatorConfigDTOList
|
|
|
|
+ * @description 查询监控指标配置
|
|
|
|
+ * @author leifeng
|
|
|
|
+ * @param: projectId
|
|
|
|
+ * @updateTime 2021/9/23 20:29
|
|
|
|
+ * @return: java.util.List<com.persagy.apm.diagnose.service.dto.MonitorIndicatorConfigDTO>
|
|
|
|
+ */
|
|
|
|
+ public List<AlarmRuleDTO> getProjectAlarmRules(String projectId,List<String> alarmItemCodeList) throws Exception {
|
|
|
|
+ List<AlarmRuleDTO> allAlarmRuleDTOList = new ArrayList<>();
|
|
|
|
+ if (!CollectionUtils.isEmpty(alarmItemCodeList)){
|
|
|
|
+ for (String code:alarmItemCodeList) {
|
|
|
|
+ AlarmRuleDTO alarmRuleDTO = AlarmRuleDTO.builder().build();
|
|
|
|
+ alarmRuleDTO.setProjectId(projectId);
|
|
|
|
+ alarmRuleDTO.setGroupCode(systemCode);
|
|
|
|
+ alarmRuleDTO.setPd("asdasdasda");
|
|
|
|
+ alarmRuleDTO.setUserId("test");
|
|
|
|
+ alarmRuleDTO.setAlarmItemCode(code);
|
|
|
|
+ AlarmResult<JSONObject> result = alarmServiceClient.queryProjectAlarmRules(alarmRuleDTO);
|
|
|
|
+ List<AlarmRuleDTO> alarmRuleDTOList = AlarmResultUtil.getRecords(result, AlarmRuleDTO.class);
|
|
|
|
+ allAlarmRuleDTOList.addAll(alarmRuleDTOList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return allAlarmRuleDTOList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<AlarmCondition> getProjectAlarmCondition(String projectId,String objId,String itemCode)throws Exception{
|
|
|
|
+ QueryAlarmConditionByObjDTO selDTO = new QueryAlarmConditionByObjDTO();
|
|
|
|
+ selDTO.setObjId(objId);
|
|
|
|
+ selDTO.setItemCode(itemCode);
|
|
|
|
+ AlarmResult<JSONObject> result = alarmServiceClient.queryByObjAndItemCode(selDTO);
|
|
|
|
+ return AlarmResultUtil.getRecords(result, AlarmCondition.class);
|
|
|
|
+ }
|
|
}
|
|
}
|