From 85bb152fd3c94fc652082ca8b07ff62f6e861863 Mon Sep 17 00:00:00 2001 From: guochuyicmri Date: Mon, 5 Nov 2018 14:06:09 +0800 Subject: Fix VNF Alarm Query Bugs Change-Id: I7cecce26ce2b1837e682574c7c8de7ae5d584c72 Issue-ID: USECASEUI-165 Signed-off-by: guochuyicmri --- .../usecaseui/server/controller/AlarmController.java | 16 ++++++++-------- .../service/impl/AlarmsInformationServiceImpl.java | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) 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 2b0b6415..a2be2c4c 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 @@ -171,7 +171,7 @@ public class AlarmController } @RequestMapping(value = {"/alarm/diagram"},method = RequestMethod.POST,produces = "application/json") - public String diagram(@RequestParam String sourceId, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String format) { + public String diagram(@RequestParam String sourceName, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String format) { long timeInterval = 0; try { if("month".equals(format)){//alarm day month year @@ -192,7 +192,7 @@ public class AlarmController 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); + return getDiagram(sourceName, startTimel, endTimel+timeInterval, timeInterval, 1, 1,format); } catch (Exception e) { logger.error("alarmController diagram occured exception:"+e.getMessage()); e.printStackTrace(); @@ -201,15 +201,15 @@ public class AlarmController } @SuppressWarnings("rawtypes") - private String getDiagram(String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal,String format) throws JsonProcessingException{ + private String getDiagram(String sourceName, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal,String format) throws JsonProcessingException{ Map result = new HashMap(); - Map allMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, keyVal, keyValIteraVal,format,""); + Map allMaps = dateProcess(sourceName, startTimeL, endTimeL, timeIteraPlusVal, keyVal, keyValIteraVal,format,""); //Map criticalMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"CRITICAL"); //Map majorMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"MAJOR"); //Map minorMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"MINOR"); - Map closedMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"closed"); - Map activeMaps = dateProcess(sourceId, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"active"); + Map closedMaps = dateProcess(sourceName, startTimeL, endTimeL, timeIteraPlusVal, 1, 1,format,"closed"); + Map activeMaps = dateProcess(sourceName, 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")); @@ -219,13 +219,13 @@ public class AlarmController result.put("ActiveList",activeMaps.get("dataList")); return omAlarm.writeValueAsString(result); } - private Map dateProcess(String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal,String format,String level) { + private Map dateProcess(String sourceName, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal,String format,String level) { Map result = new HashMap(); List dateList = new ArrayList(); List numList = new ArrayList(); long tmpEndTimeL = startTimeL + timeIteraPlusVal; while (endTimeL >= tmpEndTimeL) { - int num = alarmsInformationService.queryDateBetween(sourceId,startTimeL+"",tmpEndTimeL+"",level); + int num = alarmsInformationService.queryDateBetween(sourceName,startTimeL+"",tmpEndTimeL+"",level); dateList.add(DateUtils.getResultDate(startTimeL, format)); int maxDay2 = DateUtils.MonthOfDay(sdf.format(new Date(tmpEndTimeL)), formatDate); int maxDay = DateUtils.MonthOfDay(sdf.format(new Date(startTimeL)), formatDate); 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 7a6c04bc..b44a5c27 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 @@ -191,14 +191,14 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService { @Override - public int queryDateBetween(String sourceId, String startTime, String endTime,String status) { + public int queryDateBetween(String sourceName, String startTime, String endTime,String status) { if("1526554800000".equals(startTime)){ System.out.print(startTime); } try(Session session = getSession()) { String hql = "select count(*) from AlarmsHeader a where 1=1 "; - if (sourceId != null && !"".equals(sourceId)){ - hql += " and a.sourceId = :sourceId"; + if (sourceName != null && !"".equals(sourceName)){ + hql += " and a.sourceName = :sourceName"; } if (UuiCommonUtil.isNotNullOrEmpty(status)){ hql += " and a.status = :status"; @@ -207,8 +207,8 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService { hql += " and (CASE WHEN a.startEpochMicrosec=0 THEN a.lastEpochMicroSec ELSE a.startEpochMicrosec END) between :startTime and :endTime "; } Query query = session.createQuery(hql); - if (sourceId != null && !"".equals(sourceId)){ - query.setString("sourceId",sourceId); + if (sourceName != null && !"".equals(sourceName)){ + query.setString("sourceName",sourceName); } if (UuiCommonUtil.isNotNullOrEmpty(status)){ query.setString("status",status); -- cgit 1.2.3-korg