diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4cb2c92..1910af6 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,12 +7,9 @@ - - - - - - + + + @@ -27,7 +24,7 @@ - + @@ -35,21 +32,21 @@ - + - + - + @@ -86,21 +83,28 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -177,6 +181,8 @@ @@ -242,6 +248,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -385,7 +415,7 @@ - + 1564361618083 @@ -436,11 +466,18 @@ - - @@ -453,8 +490,9 @@ + - + @@ -681,13 +719,6 @@ - - - - - - - @@ -877,13 +908,6 @@ - - - - - - - @@ -891,24 +915,10 @@ - - - - - - - - - - - - - - - - + + @@ -923,6 +933,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index c132c98..1506dd4 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,6 +1,7 @@ package com.casic.PgInterface.patroler.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.StringUtils; import com.casic.PgInterface.patroler.domain.PgAlarmRule; import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; import org.hibernate.Criteria; @@ -18,29 +19,19 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public List getAlarmRuleDto() { + public List getAlarmRuleDto(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); + + if(StringUtils.isNotBlank(devType)) + criteria.add(Restrictions.eq("devType", devType)); criteria.addOrder(Order.desc("id")); List pgAlarmRuleList=criteria.list(); - List pgAlarmRuleDtoList = new ArrayList(); + List pgAlarmRuleDtoList = new ArrayList<>(); for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); } return pgAlarmRuleDtoList; - } - public PgAlarmRule getAlarmRuleBydevType(String devType) { - Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("devType", devType)); - - List pgAlarmRuleList=criteria.list(); - - if(pgAlarmRuleList==null||pgAlarmRuleList.size()==0) - return null; - else - return pgAlarmRuleList.get(0); - } - -} +} \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4cb2c92..1910af6 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,12 +7,9 @@ - - - - - - + + + @@ -27,7 +24,7 @@ - + @@ -35,21 +32,21 @@ - + - + - + @@ -86,21 +83,28 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -177,6 +181,8 @@ @@ -242,6 +248,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -385,7 +415,7 @@ - + 1564361618083 @@ -436,11 +466,18 @@ - - @@ -453,8 +490,9 @@ + - + @@ -681,13 +719,6 @@ - - - - - - - @@ -877,13 +908,6 @@ - - - - - - - @@ -891,24 +915,10 @@ - - - - - - - - - - - - - - - - + + @@ -923,6 +933,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index c132c98..1506dd4 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,6 +1,7 @@ package com.casic.PgInterface.patroler.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.StringUtils; import com.casic.PgInterface.patroler.domain.PgAlarmRule; import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; import org.hibernate.Criteria; @@ -18,29 +19,19 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public List getAlarmRuleDto() { + public List getAlarmRuleDto(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); + + if(StringUtils.isNotBlank(devType)) + criteria.add(Restrictions.eq("devType", devType)); criteria.addOrder(Order.desc("id")); List pgAlarmRuleList=criteria.list(); - List pgAlarmRuleDtoList = new ArrayList(); + List pgAlarmRuleDtoList = new ArrayList<>(); for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); } return pgAlarmRuleDtoList; - } - public PgAlarmRule getAlarmRuleBydevType(String devType) { - Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("devType", devType)); - - List pgAlarmRuleList=criteria.list(); - - if(pgAlarmRuleList==null||pgAlarmRuleList.size()==0) - return null; - else - return pgAlarmRuleList.get(0); - } - -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 87afd54..5561e0f 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -30,118 +30,21 @@ private static Logger logger = LoggerFactory.getLogger(PgAlarmRule.class); @Resource - private PgDeviceManager pgDeviceManager; - @Resource - private PgAlarmTypeManager pgAlarmTypeManager; - @Resource private PgAlarmRuleManager pgAlarmRuleManager; - - - /** - * 新增报警阈值 - */ - @POST - @Path("addAlarmRule") - @Produces(MediaType.APPLICATION_JSON) - public Map addAlarmRule(@FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue, - @FormParam("unit") String unit, - @FormParam("devType") String devType, - @FormParam("alarmType") String alarmType) throws Exception { - Map resultMap = new HashMap(); - String msg = ""; - String result = ""; - - PgAlarmRule pgAlarmRule = null; - - try { - pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); - if (pgAlarmRule != null) { - result = "false"; - msg = "设备阈值已经存在"; - } else { - pgAlarmRule = new PgAlarmRule(); - pgAlarmRule.setHighValue(highValue); - pgAlarmRule.setLowValue(lowValue); - pgAlarmRule.setDevType(devType); - pgAlarmRule.setUnit(unit); - pgAlarmRule.setAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - - pgAlarmRuleManager.save(pgAlarmRule); - result = "true"; - msg = "报警阈值新增成功"; - } - } catch (Exception e) { - e.printStackTrace(); - result = "false"; - msg = "报警阈值新增失败"; - } - - resultMap.put("msg", msg); - resultMap.put("result", result); - return resultMap; - } - - /** - * 编辑报警阈值 - */ - @POST - @Path("editAlarmRule") - @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("devType") String devType, - @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue, - @FormParam("unit") String unit, - @FormParam("alarmType") String alarmType) throws Exception { - Map resultMap = new HashMap(); - String msg = ""; - String result = ""; - - PgAlarmRule pgAlarmRule = null; - - try { - pgAlarmRule = pgAlarmRuleManager.get(Long.valueOf(id)); - if (pgAlarmRule == null) { - msg = "不存在报警阈值记录"; - result = "false"; - } else { - pgAlarmRule.setDevType(devType); - pgAlarmRule.setHighValue(highValue); - pgAlarmRule.setLowValue(lowValue); - pgAlarmRule.setUnit(unit); - pgAlarmRule.setAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - - pgAlarmRuleManager.save(pgAlarmRule); - msg = "编辑成功"; - result = "true"; - } - } catch (Exception ex) { - ex.printStackTrace(); - result = "false"; - msg = "报警阈值编辑失败"; - } - - resultMap.put("msg", msg); - resultMap.put("result", result); - - return resultMap; - } - /** * 获取报警阈值信息 */ @POST @Path("getAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map getAlarmRule() throws Exception { - Map resultMap = new HashMap(); + public Map getAlarmRule(@FormParam("devType") String devType) throws Exception { + Map resultMap = new HashMap<>(); String msg = ""; - List pgAlarmRuleDtoList = new ArrayList(); + List pgAlarmRuleDtoList = new ArrayList<>(); try { - pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(devType); if (pgAlarmRuleDtoList == null) msg = "不存在报警阈值信息"; else @@ -155,69 +58,4 @@ return resultMap; } - /** - * 删除报警阈值 - */ - @POST - @Path("deleteAlarmRule") - @Produces(MediaType.APPLICATION_JSON) - public Map deleteAlarmRule(@FormParam("id") String id) throws Exception { - Map resultMap = new HashMap(); - String msg = ""; - String result = ""; - PgAlarmRule pgAlarmRule = null; - - try { - pgAlarmRule = pgAlarmRuleManager.get(Long.valueOf(id)); - if (pgAlarmRule == null) { - msg = "不存在报警阈值记录"; - result = "false"; - } else { - pgAlarmRuleManager.remove(pgAlarmRule); - msg = "删除成功"; - result = "true"; - } - } catch (Exception ex) { - ex.printStackTrace(); - result = "false"; - msg = "报警阈值删除失败"; - } - - resultMap.put("msg", msg); - resultMap.put("result", result); - - return resultMap; - } - - /** - * 根据设备类型报警阈值 - */ - @POST - @Path("getAlarmRuleByDevType") - @Produces(MediaType.APPLICATION_JSON) - public Map getAlarmRuleByDevType(@FormParam("devType") String devType) throws Exception { - Map resultMap = new HashMap(); - String msg = ""; - PgAlarmRule pgAlarmRule = null; - List pgAlarmRuleDtos = new ArrayList<>(); - try { - pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); - if (pgAlarmRule == null) - msg = "不存在报警阈值记录"; - else { - PgAlarmRuleDto pgAlarmRuleDto= new PgAlarmRuleDto(pgAlarmRule); - pgAlarmRuleDtos.add(pgAlarmRuleDto); - msg = "报警阈值获取成功"; - } - } catch (Exception ex) { - ex.printStackTrace(); - msg = "报警阈值获取失败"; - } - - resultMap.put("msg", msg); - resultMap.put("result", pgAlarmRuleDtos); - - return resultMap; - } - } \ No newline at end of file diff --git "a/\346\216\245\345\217\243\350\257\264\346\230\21620190828.docx" "b/\346\216\245\345\217\243\350\257\264\346\230\21620190828.docx" index 89d580e..0682d99 100644 --- "a/\346\216\245\345\217\243\350\257\264\346\230\21620190828.docx" +++ "b/\346\216\245\345\217\243\350\257\264\346\230\21620190828.docx" Binary files differ