diff options
author | guochuyicmri <guochuyi@chinamobile.com> | 2018-11-02 11:00:39 +0800 |
---|---|---|
committer | guochuyicmri <guochuyi@chinamobile.com> | 2018-11-02 11:00:47 +0800 |
commit | 3f5ff5e257eadf98837ac06a3dde80e7bf227a27 (patch) | |
tree | 99a23edaba9a3ba4057e228d6165b27d70703c3e | |
parent | c8dd8fb4f264ee655d865c233938f28152291770 (diff) |
Fix VNF Alarm Query Bugs
Change-Id: Ibaba1848f999a9c46dad3173fb4a640e681da77b
Issue-ID: USECASEUI-165
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
4 files changed, 96 insertions, 19 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/maxAndMinTimeBean.java b/server/src/main/java/org/onap/usecaseui/server/bean/maxAndMinTimeBean.java new file mode 100644 index 00000000..7713dff3 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/bean/maxAndMinTimeBean.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2018 CMCC, Inc. and others. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.usecaseui.server.bean; + +public class maxAndMinTimeBean { + + private String maxTime; + + private String minTime; + + public String getMaxTime() { + return maxTime; + } + + public void setMaxTime(String maxTime) { + this.maxTime = maxTime; + } + + public String getMinTime() { + return minTime; + } + + public void setMinTime(String minTime) { + this.minTime = minTime; + } + + public maxAndMinTimeBean(String maxTime, String minTime) { + this.maxTime = maxTime; + this.minTime = minTime; + } + + public maxAndMinTimeBean() { + } +} diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java index 091df4a9..2b0b6415 100755 --- a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java @@ -29,6 +29,7 @@ import javax.annotation.Resource; import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.AlarmsInformation;
+import org.onap.usecaseui.server.bean.maxAndMinTimeBean;
import org.onap.usecaseui.server.bo.AlarmBo;
import org.onap.usecaseui.server.constant.Constant;
import org.onap.usecaseui.server.service.AlarmsHeaderService;
@@ -181,33 +182,41 @@ public class AlarmController formatDate="yyyy-MM-dd";
timeInterval =86400000;
}
+ List<maxAndMinTimeBean> list = alarmsInformationService.queryMaxAndMinTime();
+ if(!UuiCommonUtil.isNotNullOrEmpty(startTime)&&list.size()>0){
+ startTime=list.get(0).getMinTime();
+ }
+ if(!UuiCommonUtil.isNotNullOrEmpty(endTime)&&list.size()>0){
+ endTime=list.get(0).getMaxTime();
+ }
sdf = new SimpleDateFormat(formatDate);
long startTimel = sdf.parse(startTime).getTime();
long endTimel = sdf.parse(endTime).getTime();
return getDiagram(sourceId, startTimel, endTimel+timeInterval, timeInterval, 1, 1,format);
} catch (Exception e) {
- logger.error(e.getMessage());
+ logger.error("alarmController diagram occured exception:"+e.getMessage());
e.printStackTrace();
}
return null;
}
+ @SuppressWarnings("rawtypes")
private String getDiagram(String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal,String format) throws JsonProcessingException{
- Map<String,List> result = new HashMap<String,List>();
+ Map<String,List> result = new HashMap<String,List>();
Map<String,List> allMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, keyVal, keyValIteraVal,format,"");
- Map<String,List> criticalMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"CRITICAL");
- Map<String,List> majorMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"MAJOR");
- Map<String,List> minorMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"MINOR");
- Map<String,List> warningMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"WARNING");
- Map<String,List> normalMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"NORMAL");
+ //Map<String,List> criticalMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"CRITICAL");
+ //Map<String,List> majorMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"MAJOR");
+ //Map<String,List> minorMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"MINOR");
+ Map<String,List> closedMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"closed");
+ Map<String,List> activeMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"active");
result.put("dateList", allMaps.get("dateTime"));
result.put("allList", allMaps.get("dataList"));
- result.put("criticalList",criticalMaps.get("dataList"));
- result.put("majorList",majorMaps.get("dataList"));
- result.put("minorList",minorMaps.get("dataList"));
- result.put("warningList",warningMaps.get("dataList"));
- result.put("normalList",normalMaps.get("dataList"));
+ //result.put("criticalList",criticalMaps.get("dataList"));
+ //result.put("majorList",majorMaps.get("dataList"));
+ //result.put("minorList",minorMaps.get("dataList"));
+ result.put("closedList",closedMaps.get("dataList"));
+ result.put("ActiveList",activeMaps.get("dataList"));
return omAlarm.writeValueAsString(result);
}
private Map<String,List> dateProcess(String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal,String format,String level) {
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java index cc116508..9a86f92f 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java @@ -20,6 +20,7 @@ import java.util.Map; import org.onap.usecaseui.server.bean.AlarmsHeader; import org.onap.usecaseui.server.bean.AlarmsInformation; +import org.onap.usecaseui.server.bean.maxAndMinTimeBean; import org.onap.usecaseui.server.util.Page; @@ -49,4 +50,6 @@ public interface AlarmsInformationService { * @return */ List<AlarmsInformation> getAllAlarmsInformationByHeaderId(String id); + + List<maxAndMinTimeBean> queryMaxAndMinTime(); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java index f5d590a2..7a6c04bc 100755 --- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java @@ -16,8 +16,8 @@ package org.onap.usecaseui.server.service.impl;
-import java.sql.Timestamp;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
import javax.transaction.Transactional;
@@ -26,6 +26,7 @@ import org.hibernate.Session; import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.onap.usecaseui.server.bean.AlarmsInformation;
+import org.onap.usecaseui.server.bean.maxAndMinTimeBean;
import org.onap.usecaseui.server.service.AlarmsInformationService;
import org.onap.usecaseui.server.util.Page;
import org.onap.usecaseui.server.util.UuiCommonUtil;
@@ -190,7 +191,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService { @Override
- public int queryDateBetween(String sourceId, String startTime, String endTime,String level) {
+ public int queryDateBetween(String sourceId, String startTime, String endTime,String status) {
if("1526554800000".equals(startTime)){
System.out.print(startTime);
}
@@ -199,8 +200,8 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService { if (sourceId != null && !"".equals(sourceId)){
hql += " and a.sourceId = :sourceId";
}
- if (UuiCommonUtil.isNotNullOrEmpty(level)){
- hql += " and a.eventServrity = :eventServrity";
+ if (UuiCommonUtil.isNotNullOrEmpty(status)){
+ hql += " and a.status = :status";
}
if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){
hql += " and (CASE WHEN a.startEpochMicrosec=0 THEN a.lastEpochMicroSec ELSE a.startEpochMicrosec END) between :startTime and :endTime ";
@@ -209,8 +210,8 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService { if (sourceId != null && !"".equals(sourceId)){
query.setString("sourceId",sourceId);
}
- if (UuiCommonUtil.isNotNullOrEmpty(level)){
- query.setString("eventServrity",level);
+ if (UuiCommonUtil.isNotNullOrEmpty(status)){
+ query.setString("status",status);
}
if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){
query.setString("startTime", startTime).setString("endTime", endTime);
@@ -222,6 +223,23 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService { return 0;
}
}
+
+ @Override
+ public List<maxAndMinTimeBean> queryMaxAndMinTime(){
+ List<maxAndMinTimeBean> list = new ArrayList<>();
+ try (Session session = getSession()){
+ String sql = "select MAX(startEpochMicrosec),MIN(startEpochMicrosec) FROM alarms_commoneventheader";
+ Query query = session.createSQLQuery(sql);
+ list = query.list();
+ session.flush();
+ }catch (Exception e){
+ logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDateBetween. LIST:" + e.getMessage());
+
+ list = new ArrayList<>();
+ }
+
+ return list;
+ }
@Override
public List<AlarmsInformation> getAllAlarmsInformationByHeaderId(String headerId) {
|