From 2ea90fc83051b92d242b87c887336890578a0a30 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Thu, 11 Jan 2018 11:11:12 +0800 Subject: [PATCH] 报警配置 --- src/main/java/com/moral/service/DeviceVersionService.java | 5 src/main/resources/mapper/DeviceVersionSensorMapper.xml | 12 src/main/java/com/moral/entity/DeviceVersionSensor.java | 17 + src/main/java/com/moral/controller/SensorController.java | 34 ++ src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java | 33 ++ src/main/java/com/moral/service/SensorService.java | 10 src/main/java/com/moral/mapper/MonitorPointMapper.java | 3 src/main/java/com/moral/mapper/ProvinceMapper.java | 3 src/main/java/com/moral/service/impl/SensorServiceImpl.java | 49 +++ src/main/java/com/moral/entity/alarm/AlarmConfig.java | 16 + src/main/resources/mapper/SensorMapper.xml | 16 + src/main/java/com/moral/common/util/ExampleUtil.java | 27 + src/main/java/com/moral/controller/DeviceVersionController.java | 18 + src/main/java/com/moral/mapper/AreaMapper.java | 3 src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java | 23 + src/main/java/com/moral/entity/alarm/AlarmMode.java | 16 + src/main/java/com/moral/entity/MonitorPoint.java | 5 src/main/java/com/moral/mapper/DeviceVersionSensorMapper.java | 7 src/main/java/com/moral/mapper/SensorMapper.java | 7 src/main/java/com/moral/common/util/MyBatisBaseMapUtil.java | 6 src/main/java/com/moral/entity/Sensor.java | 25 + src/main/java/com/moral/entity/alarm/AlarmSensorLevel.java | 24 + /dev/null | 330 ----------------------- src/main/java/com/moral/entity/alarm/AlarmConfigValue.java | 11 src/main/resources/mapper/MonitorPointMapper.xml | 122 +++++++- src/main/java/com/moral/entity/alarm/AlarmStyle.java | 6 src/main/java/com/moral/mapper/CityMapper.java | 3 src/main/java/com/moral/service/impl/OrganizationServiceImpl.java | 4 28 files changed, 457 insertions(+), 378 deletions(-) diff --git a/src/main/java/com/moral/common/util/ExampleUtil.java b/src/main/java/com/moral/common/util/ExampleUtil.java index f395cba..1852f44 100644 --- a/src/main/java/com/moral/common/util/ExampleUtil.java +++ b/src/main/java/com/moral/common/util/ExampleUtil.java @@ -19,17 +19,22 @@ private final static String CRITERIA_SPLIT = "\\|\\|\\|"; private final static String CONDITION_SPLIT = "\\|\\|"; private static Map<String, Method> criteriaMethodMap = null; - private static void setOrderByClause(Example example,String orderByClause) throws UnsupportedEncodingException { + private static void setOrderByClause(Example example,String orderByClause) throws UnsupportedEncodingException, NoSuchFieldException { orderByClause = URLDecoder.decode(orderByClause,"UTF-8"); String[] orderBys = orderByClause.split(CRITERIA_SPLIT); for(String orderBy : orderBys){ String[] items = orderBy.split(CONDITION_SPLIT); - String property = items[0]; - String sort = items[1]; - if("asc".equals(sort)){ - example.orderBy(property).asc(); - }else{ - example.orderBy(property).desc(); + if(items.length == 2){ + String property = items[0]; + String sort = items[1]; + if(isPropertyOfClass(example.getEntityClass(),property)){ + + if("asc".equals(sort)){ + example.orderBy(property).asc(); + }else{ + example.orderBy(property).desc(); + } + } } } } @@ -47,7 +52,9 @@ if (!StringUtils.isNullOrEmpty(params) && params.startsWith("or|")) { String[] criteria = params.trim().split(OR_SPLIT); for (String criterion : criteria) { - Example.Criteria criteriaOfExample = null; + // criterion���null���""������ + if(StringUtils.isNullOrEmpty(criterion)) { continue;}; + Example.Criteria criteriaOfExample = example.or(); if (!StringUtils.isNullOrEmpty(criterion)) { String[] conditions = criterion.trim().split(CRITERIA_SPLIT); for (String condition : conditions) { @@ -65,10 +72,6 @@ for (int index = 2; index < conditionItems.length; index++) { values.add(conditionItems[index]); } - } - //��������������������������������� or ��������� - if(criteriaOfExample == null){ - criteriaOfExample = example.or(); } invokeMethod(criteriaOfExample,method,propertyName,values); } diff --git a/src/main/java/com/moral/common/util/MyBatisBaseMapUtil.java b/src/main/java/com/moral/common/util/MyBatisBaseMapUtil.java index 6e38228..5b04510 100644 --- a/src/main/java/com/moral/common/util/MyBatisBaseMapUtil.java +++ b/src/main/java/com/moral/common/util/MyBatisBaseMapUtil.java @@ -28,8 +28,10 @@ return page; } public static PageBean queryPage(BaseMapper baseMapper,PageBean pageBean, Example example){ - PageHelper.startPage(pageBean.getPageIndex(),pageBean.getPageSize()); + if(pageBean.getPageSize()>0){ + PageHelper.startPage(pageBean.getPageIndex(),pageBean.getPageSize()); + } List page = baseMapper.selectByExample(example); return new PageBean(page); } -} +} \ No newline at end of file diff --git a/src/main/java/com/moral/controller/DeviceVersionController.java b/src/main/java/com/moral/controller/DeviceVersionController.java index 82bcd73..a4a3563 100644 --- a/src/main/java/com/moral/controller/DeviceVersionController.java +++ b/src/main/java/com/moral/controller/DeviceVersionController.java @@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.UnsupportedEncodingException; +import java.util.List; @RestController @RequestMapping("device-version") @@ -32,4 +33,21 @@ ResultBean resultBean = new ResultBean(ResultBean.SUCCESS); return resultBean; } + @GetMapping("get-sensor-ids") + public List<Integer> getSensorIds(Integer deviceVersionId){ + return deviceVersionService.getSensorIds(deviceVersionId); + } + @PostMapping("version-sensor-config/{id}") + public ResultBean versionSensorConfig(@PathVariable("id") Integer deviceVersionId,@RequestBody Integer [] sensorIds){ + ResultBean resultBean = new ResultBean(); + if(deviceVersionId==null){ + resultBean.setCode(ResultBean.NO_PERMISSION); + resultBean.setMessage("������������ID���������null"); + return resultBean; + }else{ + deviceVersionService.versionSensorConfig(deviceVersionId,sensorIds); + resultBean.setCode(ResultBean.SUCCESS); + } + return resultBean; + } } diff --git a/src/main/java/com/moral/controller/SensorController.java b/src/main/java/com/moral/controller/SensorController.java new file mode 100644 index 0000000..b64ee4f --- /dev/null +++ b/src/main/java/com/moral/controller/SensorController.java @@ -0,0 +1,34 @@ +package com.moral.controller; + +import com.moral.common.bean.PageBean; +import com.moral.common.bean.ResultBean; +import com.moral.entity.Sensor; +import com.moral.service.SensorService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("sensor") +@CrossOrigin(origins = "*", maxAge = 3600) +public class SensorController { + @Resource + SensorService sensorService; + @GetMapping("page-list") + public PageBean pageList(PageBean pageBean) { + return sensorService.queryByPageBean(pageBean); + } + @PostMapping("delete-by-ids") + public ResultBean deleteByIds(@RequestBody Integer [] ids){ + sensorService.deleteByIds(ids); + ResultBean resultBean = new ResultBean(ResultBean.SUCCESS); + return resultBean; + } + @PostMapping("add-or-modify") + public ResultBean addOrModify(@RequestBody Sensor sensor){ + sensorService.addOrModify(sensor); + ResultBean resultBean = new ResultBean(ResultBean.SUCCESS); + return resultBean; + } +} diff --git a/src/main/java/com/moral/entity/AreaExample.java b/src/main/java/com/moral/entity/AreaExample.java deleted file mode 100644 index 0a3c733..0000000 --- a/src/main/java/com/moral/entity/AreaExample.java +++ /dev/null @@ -1,390 +0,0 @@ -package com.moral.entity; - -import java.util.ArrayList; -import java.util.List; - -public class AreaExample { - protected String orderByClause; - - protected boolean distinct; - - protected List<Criteria> oredCriteria; - - public AreaExample() { - oredCriteria = new ArrayList<Criteria>(); - } - - public void setOrderByClause(String orderByClause) { - this.orderByClause = orderByClause; - } - - public String getOrderByClause() { - return orderByClause; - } - - public void setDistinct(boolean distinct) { - this.distinct = distinct; - } - - public boolean isDistinct() { - return distinct; - } - - public List<Criteria> getOredCriteria() { - return oredCriteria; - } - - public void or(Criteria criteria) { - oredCriteria.add(criteria); - } - - public Criteria or() { - Criteria criteria = createCriteriaInternal(); - oredCriteria.add(criteria); - return criteria; - } - - public Criteria createCriteria() { - Criteria criteria = createCriteriaInternal(); - if (oredCriteria.size() == 0) { - oredCriteria.add(criteria); - } - return criteria; - } - - protected Criteria createCriteriaInternal() { - Criteria criteria = new Criteria(); - return criteria; - } - - public void clear() { - oredCriteria.clear(); - orderByClause = null; - distinct = false; - } - - protected abstract static class GeneratedCriteria { - protected List<Criterion> criteria; - - protected GeneratedCriteria() { - super(); - criteria = new ArrayList<Criterion>(); - } - - public boolean isValid() { - return criteria.size() > 0; - } - - public List<Criterion> getAllCriteria() { - return criteria; - } - - public List<Criterion> getCriteria() { - return criteria; - } - - protected void addCriterion(String condition) { - if (condition == null) { - throw new RuntimeException("Value for condition cannot be null"); - } - criteria.add(new Criterion(condition)); - } - - protected void addCriterion(String condition, Object value, String property) { - if (value == null) { - throw new RuntimeException("Value for " + property + " cannot be null"); - } - criteria.add(new Criterion(condition, value)); - } - - protected void addCriterion(String condition, Object value1, Object value2, String property) { - if (value1 == null || value2 == null) { - throw new RuntimeException("Between values for " + property + " cannot be null"); - } - criteria.add(new Criterion(condition, value1, value2)); - } - - public Criteria andAreaCodeIsNull() { - addCriterion("area_code is null"); - return (Criteria) this; - } - - public Criteria andAreaCodeIsNotNull() { - addCriterion("area_code is not null"); - return (Criteria) this; - } - - public Criteria andAreaCodeEqualTo(Integer value) { - addCriterion("area_code =", value, "areaCode"); - return (Criteria) this; - } - - public Criteria andAreaCodeNotEqualTo(Integer value) { - addCriterion("area_code <>", value, "areaCode"); - return (Criteria) this; - } - - public Criteria andAreaCodeGreaterThan(Integer value) { - addCriterion("area_code >", value, "areaCode"); - return (Criteria) this; - } - - public Criteria andAreaCodeGreaterThanOrEqualTo(Integer value) { - addCriterion("area_code >=", value, "areaCode"); - return (Criteria) this; - } - - public Criteria andAreaCodeLessThan(Integer value) { - addCriterion("area_code <", value, "areaCode"); - return (Criteria) this; - } - - public Criteria andAreaCodeLessThanOrEqualTo(Integer value) { - addCriterion("area_code <=", value, "areaCode"); - return (Criteria) this; - } - - public Criteria andAreaCodeIn(List<Integer> values) { - addCriterion("area_code in", values, "areaCode"); - return (Criteria) this; - } - - public Criteria andAreaCodeNotIn(List<Integer> values) { - addCriterion("area_code not in", values, "areaCode"); - return (Criteria) this; - } - - public Criteria andAreaCodeBetween(Integer value1, Integer value2) { - addCriterion("area_code between", value1, value2, "areaCode"); - return (Criteria) this; - } - - public Criteria andAreaCodeNotBetween(Integer value1, Integer value2) { - addCriterion("area_code not between", value1, value2, "areaCode"); - return (Criteria) this; - } - - public Criteria andAreaNameIsNull() { - addCriterion("area_name is null"); - return (Criteria) this; - } - - public Criteria andAreaNameIsNotNull() { - addCriterion("area_name is not null"); - return (Criteria) this; - } - - public Criteria andAreaNameEqualTo(String value) { - addCriterion("area_name =", value, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameNotEqualTo(String value) { - addCriterion("area_name <>", value, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameGreaterThan(String value) { - addCriterion("area_name >", value, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameGreaterThanOrEqualTo(String value) { - addCriterion("area_name >=", value, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameLessThan(String value) { - addCriterion("area_name <", value, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameLessThanOrEqualTo(String value) { - addCriterion("area_name <=", value, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameLike(String value) { - addCriterion("area_name like", value, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameNotLike(String value) { - addCriterion("area_name not like", value, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameIn(List<String> values) { - addCriterion("area_name in", values, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameNotIn(List<String> values) { - addCriterion("area_name not in", values, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameBetween(String value1, String value2) { - addCriterion("area_name between", value1, value2, "areaName"); - return (Criteria) this; - } - - public Criteria andAreaNameNotBetween(String value1, String value2) { - addCriterion("area_name not between", value1, value2, "areaName"); - return (Criteria) this; - } - - public Criteria andCityCodeIsNull() { - addCriterion("city_code is null"); - return (Criteria) this; - } - - public Criteria andCityCodeIsNotNull() { - addCriterion("city_code is not null"); - return (Criteria) this; - } - - public Criteria andCityCodeEqualTo(Integer value) { - addCriterion("city_code =", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeNotEqualTo(Integer value) { - addCriterion("city_code <>", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeGreaterThan(Integer value) { - addCriterion("city_code >", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeGreaterThanOrEqualTo(Integer value) { - addCriterion("city_code >=", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeLessThan(Integer value) { - addCriterion("city_code <", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeLessThanOrEqualTo(Integer value) { - addCriterion("city_code <=", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeIn(List<Integer> values) { - addCriterion("city_code in", values, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeNotIn(List<Integer> values) { - addCriterion("city_code not in", values, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeBetween(Integer value1, Integer value2) { - addCriterion("city_code between", value1, value2, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeNotBetween(Integer value1, Integer value2) { - addCriterion("city_code not between", value1, value2, "cityCode"); - return (Criteria) this; - } - } - - public static class Criteria extends GeneratedCriteria { - - protected Criteria() { - super(); - } - } - - public static class Criterion { - private String condition; - - private Object value; - - private Object secondValue; - - private boolean noValue; - - private boolean singleValue; - - private boolean betweenValue; - - private boolean listValue; - - private String typeHandler; - - public String getCondition() { - return condition; - } - - public Object getValue() { - return value; - } - - public Object getSecondValue() { - return secondValue; - } - - public boolean isNoValue() { - return noValue; - } - - public boolean isSingleValue() { - return singleValue; - } - - public boolean isBetweenValue() { - return betweenValue; - } - - public boolean isListValue() { - return listValue; - } - - public String getTypeHandler() { - return typeHandler; - } - - protected Criterion(String condition) { - super(); - this.condition = condition; - this.typeHandler = null; - this.noValue = true; - } - - protected Criterion(String condition, Object value, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.typeHandler = typeHandler; - if (value instanceof List<?>) { - this.listValue = true; - } else { - this.singleValue = true; - } - } - - protected Criterion(String condition, Object value) { - this(condition, value, null); - } - - protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.secondValue = secondValue; - this.typeHandler = typeHandler; - this.betweenValue = true; - } - - protected Criterion(String condition, Object value, Object secondValue) { - this(condition, value, secondValue, null); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/moral/entity/CityExample.java b/src/main/java/com/moral/entity/CityExample.java deleted file mode 100644 index 3882be8..0000000 --- a/src/main/java/com/moral/entity/CityExample.java +++ /dev/null @@ -1,390 +0,0 @@ -package com.moral.entity; - -import java.util.ArrayList; -import java.util.List; - -public class CityExample { - protected String orderByClause; - - protected boolean distinct; - - protected List<Criteria> oredCriteria; - - public CityExample() { - oredCriteria = new ArrayList<Criteria>(); - } - - public void setOrderByClause(String orderByClause) { - this.orderByClause = orderByClause; - } - - public String getOrderByClause() { - return orderByClause; - } - - public void setDistinct(boolean distinct) { - this.distinct = distinct; - } - - public boolean isDistinct() { - return distinct; - } - - public List<Criteria> getOredCriteria() { - return oredCriteria; - } - - public void or(Criteria criteria) { - oredCriteria.add(criteria); - } - - public Criteria or() { - Criteria criteria = createCriteriaInternal(); - oredCriteria.add(criteria); - return criteria; - } - - public Criteria createCriteria() { - Criteria criteria = createCriteriaInternal(); - if (oredCriteria.size() == 0) { - oredCriteria.add(criteria); - } - return criteria; - } - - protected Criteria createCriteriaInternal() { - Criteria criteria = new Criteria(); - return criteria; - } - - public void clear() { - oredCriteria.clear(); - orderByClause = null; - distinct = false; - } - - protected abstract static class GeneratedCriteria { - protected List<Criterion> criteria; - - protected GeneratedCriteria() { - super(); - criteria = new ArrayList<Criterion>(); - } - - public boolean isValid() { - return criteria.size() > 0; - } - - public List<Criterion> getAllCriteria() { - return criteria; - } - - public List<Criterion> getCriteria() { - return criteria; - } - - protected void addCriterion(String condition) { - if (condition == null) { - throw new RuntimeException("Value for condition cannot be null"); - } - criteria.add(new Criterion(condition)); - } - - protected void addCriterion(String condition, Object value, String property) { - if (value == null) { - throw new RuntimeException("Value for " + property + " cannot be null"); - } - criteria.add(new Criterion(condition, value)); - } - - protected void addCriterion(String condition, Object value1, Object value2, String property) { - if (value1 == null || value2 == null) { - throw new RuntimeException("Between values for " + property + " cannot be null"); - } - criteria.add(new Criterion(condition, value1, value2)); - } - - public Criteria andCityCodeIsNull() { - addCriterion("city_code is null"); - return (Criteria) this; - } - - public Criteria andCityCodeIsNotNull() { - addCriterion("city_code is not null"); - return (Criteria) this; - } - - public Criteria andCityCodeEqualTo(Integer value) { - addCriterion("city_code =", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeNotEqualTo(Integer value) { - addCriterion("city_code <>", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeGreaterThan(Integer value) { - addCriterion("city_code >", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeGreaterThanOrEqualTo(Integer value) { - addCriterion("city_code >=", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeLessThan(Integer value) { - addCriterion("city_code <", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeLessThanOrEqualTo(Integer value) { - addCriterion("city_code <=", value, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeIn(List<Integer> values) { - addCriterion("city_code in", values, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeNotIn(List<Integer> values) { - addCriterion("city_code not in", values, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeBetween(Integer value1, Integer value2) { - addCriterion("city_code between", value1, value2, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityCodeNotBetween(Integer value1, Integer value2) { - addCriterion("city_code not between", value1, value2, "cityCode"); - return (Criteria) this; - } - - public Criteria andCityNameIsNull() { - addCriterion("city_name is null"); - return (Criteria) this; - } - - public Criteria andCityNameIsNotNull() { - addCriterion("city_name is not null"); - return (Criteria) this; - } - - public Criteria andCityNameEqualTo(String value) { - addCriterion("city_name =", value, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameNotEqualTo(String value) { - addCriterion("city_name <>", value, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameGreaterThan(String value) { - addCriterion("city_name >", value, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameGreaterThanOrEqualTo(String value) { - addCriterion("city_name >=", value, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameLessThan(String value) { - addCriterion("city_name <", value, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameLessThanOrEqualTo(String value) { - addCriterion("city_name <=", value, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameLike(String value) { - addCriterion("city_name like", value, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameNotLike(String value) { - addCriterion("city_name not like", value, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameIn(List<String> values) { - addCriterion("city_name in", values, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameNotIn(List<String> values) { - addCriterion("city_name not in", values, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameBetween(String value1, String value2) { - addCriterion("city_name between", value1, value2, "cityName"); - return (Criteria) this; - } - - public Criteria andCityNameNotBetween(String value1, String value2) { - addCriterion("city_name not between", value1, value2, "cityName"); - return (Criteria) this; - } - - public Criteria andProvinceCodeIsNull() { - addCriterion("province_code is null"); - return (Criteria) this; - } - - public Criteria andProvinceCodeIsNotNull() { - addCriterion("province_code is not null"); - return (Criteria) this; - } - - public Criteria andProvinceCodeEqualTo(Integer value) { - addCriterion("province_code =", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeNotEqualTo(Integer value) { - addCriterion("province_code <>", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeGreaterThan(Integer value) { - addCriterion("province_code >", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeGreaterThanOrEqualTo(Integer value) { - addCriterion("province_code >=", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeLessThan(Integer value) { - addCriterion("province_code <", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeLessThanOrEqualTo(Integer value) { - addCriterion("province_code <=", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeIn(List<Integer> values) { - addCriterion("province_code in", values, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeNotIn(List<Integer> values) { - addCriterion("province_code not in", values, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeBetween(Integer value1, Integer value2) { - addCriterion("province_code between", value1, value2, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeNotBetween(Integer value1, Integer value2) { - addCriterion("province_code not between", value1, value2, "provinceCode"); - return (Criteria) this; - } - } - - public static class Criteria extends GeneratedCriteria { - - protected Criteria() { - super(); - } - } - - public static class Criterion { - private String condition; - - private Object value; - - private Object secondValue; - - private boolean noValue; - - private boolean singleValue; - - private boolean betweenValue; - - private boolean listValue; - - private String typeHandler; - - public String getCondition() { - return condition; - } - - public Object getValue() { - return value; - } - - public Object getSecondValue() { - return secondValue; - } - - public boolean isNoValue() { - return noValue; - } - - public boolean isSingleValue() { - return singleValue; - } - - public boolean isBetweenValue() { - return betweenValue; - } - - public boolean isListValue() { - return listValue; - } - - public String getTypeHandler() { - return typeHandler; - } - - protected Criterion(String condition) { - super(); - this.condition = condition; - this.typeHandler = null; - this.noValue = true; - } - - protected Criterion(String condition, Object value, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.typeHandler = typeHandler; - if (value instanceof List<?>) { - this.listValue = true; - } else { - this.singleValue = true; - } - } - - protected Criterion(String condition, Object value) { - this(condition, value, null); - } - - protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.secondValue = secondValue; - this.typeHandler = typeHandler; - this.betweenValue = true; - } - - protected Criterion(String condition, Object value, Object secondValue) { - this(condition, value, secondValue, null); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/moral/entity/DeviceVersionSensor.java b/src/main/java/com/moral/entity/DeviceVersionSensor.java new file mode 100644 index 0000000..6fe37c1 --- /dev/null +++ b/src/main/java/com/moral/entity/DeviceVersionSensor.java @@ -0,0 +1,17 @@ +package com.moral.entity; + +import lombok.Data; + +import javax.persistence.Id; + +@Data +public class DeviceVersionSensor { + @Id + private Integer id; + + private Integer deviceVersionId; + + private Integer sensorId; + + +} \ No newline at end of file diff --git a/src/main/java/com/moral/entity/MonitorPoint.java b/src/main/java/com/moral/entity/MonitorPoint.java index 305bee2..40f9998 100644 --- a/src/main/java/com/moral/entity/MonitorPoint.java +++ b/src/main/java/com/moral/entity/MonitorPoint.java @@ -1,6 +1,7 @@ package com.moral.entity; import javax.persistence.Id; +import javax.persistence.Transient; import lombok.Data; @@ -94,4 +95,8 @@ * @mbggenerated Thu Dec 07 16:40:22 CST 2017 */ private String description; + @Transient + private AreaNames areaNames; + @Transient + private Organization organization; } \ No newline at end of file diff --git a/src/main/java/com/moral/entity/ProvinceExample.java b/src/main/java/com/moral/entity/ProvinceExample.java deleted file mode 100644 index c827a64..0000000 --- a/src/main/java/com/moral/entity/ProvinceExample.java +++ /dev/null @@ -1,330 +0,0 @@ -package com.moral.entity; - -import java.util.ArrayList; -import java.util.List; - -public class ProvinceExample { - protected String orderByClause; - - protected boolean distinct; - - protected List<Criteria> oredCriteria; - - public ProvinceExample() { - oredCriteria = new ArrayList<Criteria>(); - } - - public void setOrderByClause(String orderByClause) { - this.orderByClause = orderByClause; - } - - public String getOrderByClause() { - return orderByClause; - } - - public void setDistinct(boolean distinct) { - this.distinct = distinct; - } - - public boolean isDistinct() { - return distinct; - } - - public List<Criteria> getOredCriteria() { - return oredCriteria; - } - - public void or(Criteria criteria) { - oredCriteria.add(criteria); - } - - public Criteria or() { - Criteria criteria = createCriteriaInternal(); - oredCriteria.add(criteria); - return criteria; - } - - public Criteria createCriteria() { - Criteria criteria = createCriteriaInternal(); - if (oredCriteria.size() == 0) { - oredCriteria.add(criteria); - } - return criteria; - } - - protected Criteria createCriteriaInternal() { - Criteria criteria = new Criteria(); - return criteria; - } - - public void clear() { - oredCriteria.clear(); - orderByClause = null; - distinct = false; - } - - protected abstract static class GeneratedCriteria { - protected List<Criterion> criteria; - - protected GeneratedCriteria() { - super(); - criteria = new ArrayList<Criterion>(); - } - - public boolean isValid() { - return criteria.size() > 0; - } - - public List<Criterion> getAllCriteria() { - return criteria; - } - - public List<Criterion> getCriteria() { - return criteria; - } - - protected void addCriterion(String condition) { - if (condition == null) { - throw new RuntimeException("Value for condition cannot be null"); - } - criteria.add(new Criterion(condition)); - } - - protected void addCriterion(String condition, Object value, String property) { - if (value == null) { - throw new RuntimeException("Value for " + property + " cannot be null"); - } - criteria.add(new Criterion(condition, value)); - } - - protected void addCriterion(String condition, Object value1, Object value2, String property) { - if (value1 == null || value2 == null) { - throw new RuntimeException("Between values for " + property + " cannot be null"); - } - criteria.add(new Criterion(condition, value1, value2)); - } - - public Criteria andProvinceCodeIsNull() { - addCriterion("province_code is null"); - return (Criteria) this; - } - - public Criteria andProvinceCodeIsNotNull() { - addCriterion("province_code is not null"); - return (Criteria) this; - } - - public Criteria andProvinceCodeEqualTo(Integer value) { - addCriterion("province_code =", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeNotEqualTo(Integer value) { - addCriterion("province_code <>", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeGreaterThan(Integer value) { - addCriterion("province_code >", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeGreaterThanOrEqualTo(Integer value) { - addCriterion("province_code >=", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeLessThan(Integer value) { - addCriterion("province_code <", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeLessThanOrEqualTo(Integer value) { - addCriterion("province_code <=", value, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeIn(List<Integer> values) { - addCriterion("province_code in", values, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeNotIn(List<Integer> values) { - addCriterion("province_code not in", values, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeBetween(Integer value1, Integer value2) { - addCriterion("province_code between", value1, value2, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceCodeNotBetween(Integer value1, Integer value2) { - addCriterion("province_code not between", value1, value2, "provinceCode"); - return (Criteria) this; - } - - public Criteria andProvinceNameIsNull() { - addCriterion("province_name is null"); - return (Criteria) this; - } - - public Criteria andProvinceNameIsNotNull() { - addCriterion("province_name is not null"); - return (Criteria) this; - } - - public Criteria andProvinceNameEqualTo(String value) { - addCriterion("province_name =", value, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameNotEqualTo(String value) { - addCriterion("province_name <>", value, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameGreaterThan(String value) { - addCriterion("province_name >", value, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameGreaterThanOrEqualTo(String value) { - addCriterion("province_name >=", value, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameLessThan(String value) { - addCriterion("province_name <", value, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameLessThanOrEqualTo(String value) { - addCriterion("province_name <=", value, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameLike(String value) { - addCriterion("province_name like", value, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameNotLike(String value) { - addCriterion("province_name not like", value, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameIn(List<String> values) { - addCriterion("province_name in", values, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameNotIn(List<String> values) { - addCriterion("province_name not in", values, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameBetween(String value1, String value2) { - addCriterion("province_name between", value1, value2, "provinceName"); - return (Criteria) this; - } - - public Criteria andProvinceNameNotBetween(String value1, String value2) { - addCriterion("province_name not between", value1, value2, "provinceName"); - return (Criteria) this; - } - } - - public static class Criteria extends GeneratedCriteria { - - protected Criteria() { - super(); - } - } - - public static class Criterion { - private String condition; - - private Object value; - - private Object secondValue; - - private boolean noValue; - - private boolean singleValue; - - private boolean betweenValue; - - private boolean listValue; - - private String typeHandler; - - public String getCondition() { - return condition; - } - - public Object getValue() { - return value; - } - - public Object getSecondValue() { - return secondValue; - } - - public boolean isNoValue() { - return noValue; - } - - public boolean isSingleValue() { - return singleValue; - } - - public boolean isBetweenValue() { - return betweenValue; - } - - public boolean isListValue() { - return listValue; - } - - public String getTypeHandler() { - return typeHandler; - } - - protected Criterion(String condition) { - super(); - this.condition = condition; - this.typeHandler = null; - this.noValue = true; - } - - protected Criterion(String condition, Object value, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.typeHandler = typeHandler; - if (value instanceof List<?>) { - this.listValue = true; - } else { - this.singleValue = true; - } - } - - protected Criterion(String condition, Object value) { - this(condition, value, null); - } - - protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.secondValue = secondValue; - this.typeHandler = typeHandler; - this.betweenValue = true; - } - - protected Criterion(String condition, Object value, Object secondValue) { - this(condition, value, secondValue, null); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/moral/entity/Sensor.java b/src/main/java/com/moral/entity/Sensor.java new file mode 100644 index 0000000..32502d1 --- /dev/null +++ b/src/main/java/com/moral/entity/Sensor.java @@ -0,0 +1,25 @@ +package com.moral.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Id; + +@Data +public class Sensor { + @Id + private Integer id; + + private String name; + + @Column(name = "`key`") + private String key; + + private Double upper; + + private Double lower; + + private String unit; + + private String description; +} \ No newline at end of file diff --git a/src/main/java/com/moral/entity/alarm/AlarmConfig.java b/src/main/java/com/moral/entity/alarm/AlarmConfig.java new file mode 100644 index 0000000..7384a13 --- /dev/null +++ b/src/main/java/com/moral/entity/alarm/AlarmConfig.java @@ -0,0 +1,16 @@ +package com.moral.entity.alarm; + +import lombok.Data; + +import javax.persistence.Id; +import java.util.Date; + +@Data +public class AlarmConfig { + @Id + private Integer id; + private Integer organizationId; + private Date createTime; + private Date updateTime; + private AlarmConfigValue value; +} diff --git a/src/main/java/com/moral/entity/alarm/AlarmConfigValue.java b/src/main/java/com/moral/entity/alarm/AlarmConfigValue.java new file mode 100644 index 0000000..75da689 --- /dev/null +++ b/src/main/java/com/moral/entity/alarm/AlarmConfigValue.java @@ -0,0 +1,11 @@ +package com.moral.entity.alarm; + +import lombok.Data; + +import java.util.Map; + +@Data +public class AlarmConfigValue { + private AlarmMode alarmMode; + private Map<String,AlarmSensorLevel> alarmLevels; +} diff --git a/src/main/java/com/moral/entity/alarm/AlarmMode.java b/src/main/java/com/moral/entity/alarm/AlarmMode.java new file mode 100644 index 0000000..dae319b --- /dev/null +++ b/src/main/java/com/moral/entity/alarm/AlarmMode.java @@ -0,0 +1,16 @@ +package com.moral.entity.alarm; + +import lombok.Data; + +import java.util.List; + +/* + ��������������������� + */ +@Data +public class AlarmMode { + private int enable; + private List<AlarmStyle> level1; + private List<AlarmStyle> level2; + private List<AlarmStyle> level3; +} diff --git a/src/main/java/com/moral/entity/alarm/AlarmSensorLevel.java b/src/main/java/com/moral/entity/alarm/AlarmSensorLevel.java new file mode 100644 index 0000000..02de3af --- /dev/null +++ b/src/main/java/com/moral/entity/alarm/AlarmSensorLevel.java @@ -0,0 +1,24 @@ +package com.moral.entity.alarm; + +import lombok.Data; + +import java.util.List; + +/* + ��������������������������� + */ +@Data +public class AlarmSensorLevel { + /* + ������������������1���������0��������� + */ + private int enable; + /* + ������������������������ [100,200,300] + */ + private List<Float> increment; + /* + ������������ ������������[-100,-200,-300] + */ + private List<Float> degression; +} diff --git a/src/main/java/com/moral/entity/alarm/AlarmStyle.java b/src/main/java/com/moral/entity/alarm/AlarmStyle.java new file mode 100644 index 0000000..cf21124 --- /dev/null +++ b/src/main/java/com/moral/entity/alarm/AlarmStyle.java @@ -0,0 +1,6 @@ +package com.moral.entity.alarm; + +public enum AlarmStyle { + //��������������������������������� + weixin,email,sms,vioce +} diff --git a/src/main/java/com/moral/mapper/AreaMapper.java b/src/main/java/com/moral/mapper/AreaMapper.java index cea51c3..681ad1f 100644 --- a/src/main/java/com/moral/mapper/AreaMapper.java +++ b/src/main/java/com/moral/mapper/AreaMapper.java @@ -2,9 +2,6 @@ import com.moral.common.mapper.BaseMapper; import com.moral.entity.Area; -import com.moral.entity.AreaExample; -import java.util.List; -import org.apache.ibatis.annotations.Param; public interface AreaMapper extends BaseMapper<Area> { } \ No newline at end of file diff --git a/src/main/java/com/moral/mapper/CityMapper.java b/src/main/java/com/moral/mapper/CityMapper.java index 416b69a..751e95b 100644 --- a/src/main/java/com/moral/mapper/CityMapper.java +++ b/src/main/java/com/moral/mapper/CityMapper.java @@ -2,9 +2,6 @@ import com.moral.common.mapper.BaseMapper; import com.moral.entity.City; -import com.moral.entity.CityExample; -import java.util.List; -import org.apache.ibatis.annotations.Param; public interface CityMapper extends BaseMapper<City> { } \ No newline at end of file diff --git a/src/main/java/com/moral/mapper/DeviceVersionSensorMapper.java b/src/main/java/com/moral/mapper/DeviceVersionSensorMapper.java new file mode 100644 index 0000000..7461be6 --- /dev/null +++ b/src/main/java/com/moral/mapper/DeviceVersionSensorMapper.java @@ -0,0 +1,7 @@ +package com.moral.mapper; + +import com.moral.common.mapper.BaseMapper; +import com.moral.entity.DeviceVersionSensor; + +public interface DeviceVersionSensorMapper extends BaseMapper<DeviceVersionSensor> { +} \ No newline at end of file diff --git a/src/main/java/com/moral/mapper/MonitorPointMapper.java b/src/main/java/com/moral/mapper/MonitorPointMapper.java index 1483e61..e028c47 100644 --- a/src/main/java/com/moral/mapper/MonitorPointMapper.java +++ b/src/main/java/com/moral/mapper/MonitorPointMapper.java @@ -5,8 +5,9 @@ import com.moral.common.mapper.BaseMapper; import com.moral.entity.MonitorPoint; +import tk.mybatis.mapper.entity.Example; public interface MonitorPointMapper extends BaseMapper<MonitorPoint>{ - + List<MonitorPoint> selectWithAreaNameByExample(Example example); List<MonitorPoint> getMonitorPointsByAreaName(Map<String, Object> parameters); } \ No newline at end of file diff --git a/src/main/java/com/moral/mapper/ProvinceMapper.java b/src/main/java/com/moral/mapper/ProvinceMapper.java index 5e78c4d..b687207 100644 --- a/src/main/java/com/moral/mapper/ProvinceMapper.java +++ b/src/main/java/com/moral/mapper/ProvinceMapper.java @@ -2,9 +2,6 @@ import com.moral.common.mapper.BaseMapper; import com.moral.entity.Province; -import com.moral.entity.ProvinceExample; -import java.util.List; -import org.apache.ibatis.annotations.Param; public interface ProvinceMapper extends BaseMapper<Province> { } \ No newline at end of file diff --git a/src/main/java/com/moral/mapper/SensorMapper.java b/src/main/java/com/moral/mapper/SensorMapper.java new file mode 100644 index 0000000..94338a4 --- /dev/null +++ b/src/main/java/com/moral/mapper/SensorMapper.java @@ -0,0 +1,7 @@ +package com.moral.mapper; + +import com.moral.common.mapper.BaseMapper; +import com.moral.entity.Sensor; + +public interface SensorMapper extends BaseMapper<Sensor> { +} \ No newline at end of file diff --git a/src/main/java/com/moral/service/DeviceVersionService.java b/src/main/java/com/moral/service/DeviceVersionService.java index 5220a19..44cf766 100644 --- a/src/main/java/com/moral/service/DeviceVersionService.java +++ b/src/main/java/com/moral/service/DeviceVersionService.java @@ -4,10 +4,15 @@ import com.moral.entity.DeviceVersion; import java.io.UnsupportedEncodingException; +import java.util.List; public interface DeviceVersionService { public PageBean queryByPageBean(PageBean pageBean); public void addOrModify(DeviceVersion deviceVersion); public void deleteByIds(Integer... ids); + + void versionSensorConfig(Integer deviceVersionId, Integer[] sensorIds); + + List<Integer> getSensorIds(int deviceVersionId); } diff --git a/src/main/java/com/moral/service/SensorService.java b/src/main/java/com/moral/service/SensorService.java new file mode 100644 index 0000000..d525564 --- /dev/null +++ b/src/main/java/com/moral/service/SensorService.java @@ -0,0 +1,10 @@ +package com.moral.service; + +import com.moral.common.bean.PageBean; +import com.moral.entity.Sensor; + +public interface SensorService { + public PageBean queryByPageBean(PageBean pageBean); + public void addOrModify(Sensor sensor); + public void deleteByIds(Integer... ids); +} diff --git a/src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java b/src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java index 6c6f0de..ac912aa 100644 --- a/src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java +++ b/src/main/java/com/moral/service/impl/DeviceVersionServiceImpl.java @@ -4,8 +4,11 @@ import com.moral.common.util.ExampleUtil; import com.moral.common.util.MyBatisBaseMapUtil; import com.moral.entity.DeviceVersion; +import com.moral.entity.DeviceVersionSensor; import com.moral.mapper.DeviceVersionMapper; +import com.moral.mapper.DeviceVersionSensorMapper; import com.moral.service.DeviceVersionService; +import org.springframework.data.mongodb.core.aggregation.ArrayOperators; import org.springframework.stereotype.Service; import tk.mybatis.mapper.entity.Example; @@ -13,11 +16,14 @@ import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; @Service public class DeviceVersionServiceImpl implements DeviceVersionService { @Resource private DeviceVersionMapper deviceVersionMapper; + @Resource + private DeviceVersionSensorMapper deviceVersionSensorMapper; private static Class ENTITY_CLASS = DeviceVersion.class; public PageBean queryByPageBean(PageBean pageBean){ return MyBatisBaseMapUtil.queryPage(deviceVersionMapper,pageBean,ENTITY_CLASS); @@ -48,4 +54,31 @@ } } + @Override + public void versionSensorConfig(Integer deviceVersionId, Integer[] sensorIds){ + Example example = new Example(DeviceVersionSensor.class); + example.or().andEqualTo("deviceVersionId",deviceVersionId); + deviceVersionSensorMapper.deleteByExample(example); + if(sensorIds!=null && sensorIds.length >0){ + List<DeviceVersionSensor> deviceVersionSensorList = new ArrayList<DeviceVersionSensor>(); + for(int sensorId:sensorIds){ + DeviceVersionSensor deviceVersionSensor = new DeviceVersionSensor(); + deviceVersionSensor.setDeviceVersionId(deviceVersionId); + deviceVersionSensor.setSensorId(sensorId); + deviceVersionSensorList.add(deviceVersionSensor); + } + deviceVersionSensorMapper.insertList(deviceVersionSensorList); + } + } + @Override + public List<Integer> getSensorIds(int deviceVersionId){ + DeviceVersionSensor deviceVersionSensor = new DeviceVersionSensor(); + deviceVersionSensor.setDeviceVersionId(deviceVersionId); + List<DeviceVersionSensor> deviceVersionSensorList = deviceVersionSensorMapper.select(deviceVersionSensor); + List<Integer> sensorIds = new ArrayList<>(); + for(DeviceVersionSensor dvSensor:deviceVersionSensorList ){ + sensorIds.add(dvSensor.getSensorId()); + } + return sensorIds; + } } diff --git a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java index 6712510..a8267e6 100644 --- a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java +++ b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java @@ -6,7 +6,10 @@ import javax.annotation.Resource; +import com.github.pagehelper.PageHelper; +import com.moral.common.bean.Constants; import com.moral.common.bean.PageBean; +import com.moral.common.util.ExampleUtil; import com.moral.common.util.MyBatisBaseMapUtil; import org.springframework.stereotype.Service; @@ -29,7 +32,18 @@ @Override public PageBean queryByPageBean(PageBean pageBean) { - return MyBatisBaseMapUtil.queryPage(monitorPointMapper,pageBean,ENTITY_CLASS); + Example example = ExampleUtil.generateExample(ENTITY_CLASS,pageBean); + List<Example.Criteria> criteriaList = example.getOredCriteria(); + if(criteriaList!=null&&criteriaList.size()>0){ + for(Example.Criteria cri : criteriaList){ + cri.andNotEqualTo("isDelete", Constants.IS_DELETE_TRUE); + } + }else { + example.or().andNotEqualTo("isDelete",Constants.IS_DELETE_TRUE); + } + PageHelper.startPage(pageBean.getPageIndex(),pageBean.getPageSize()); + List<MonitorPoint> monitorPointList = monitorPointMapper.selectWithAreaNameByExample(example); + return new PageBean(monitorPointList); } @Override @@ -48,13 +62,16 @@ @Override public void deleteByIds(Integer... ids) { + MonitorPoint monitorPoint = new MonitorPoint(); + monitorPoint.setIsDelete(Constants.IS_DELETE_TRUE); if(ids!=null&&ids.length>0){ if(ids.length==1){ - monitorPointMapper.deleteByPrimaryKey(ids[0]); + monitorPoint.setId(ids[0]); + monitorPointMapper.updateByPrimaryKeySelective(monitorPoint); }else{ Example example = new Example(ENTITY_CLASS); example.or().andIn("id", Arrays.asList(ids)); - monitorPointMapper.deleteByExample(example); + monitorPointMapper.updateByExampleSelective(monitorPoint,example); } } diff --git a/src/main/java/com/moral/service/impl/OrganizationServiceImpl.java b/src/main/java/com/moral/service/impl/OrganizationServiceImpl.java index 828c235..92e9a0c 100644 --- a/src/main/java/com/moral/service/impl/OrganizationServiceImpl.java +++ b/src/main/java/com/moral/service/impl/OrganizationServiceImpl.java @@ -65,7 +65,9 @@ }else { example.or().andNotEqualTo("isDelete",Constants.IS_DELETE_TRUE); } - PageHelper.startPage(pageBean.getPageIndex(),pageBean.getPageSize()); + if(pageBean.getPageSize()>0){ + PageHelper.startPage(pageBean.getPageIndex(),pageBean.getPageSize()); + } List<Organization> organizationList = organizationMapper.selectWithAreaNameByExample(example); return new PageBean(organizationList); } diff --git a/src/main/java/com/moral/service/impl/SensorServiceImpl.java b/src/main/java/com/moral/service/impl/SensorServiceImpl.java new file mode 100644 index 0000000..92cb96f --- /dev/null +++ b/src/main/java/com/moral/service/impl/SensorServiceImpl.java @@ -0,0 +1,49 @@ +package com.moral.service.impl; + +import com.moral.common.bean.PageBean; +import com.moral.common.util.MyBatisBaseMapUtil; +import com.moral.entity.Sensor; +import com.moral.mapper.SensorMapper; +import com.moral.service.SensorService; +import org.springframework.stereotype.Service; +import tk.mybatis.mapper.entity.Example; + +import javax.annotation.Resource; +import java.util.Arrays; + +@Service +public class SensorServiceImpl implements SensorService{ + @Resource + SensorMapper sensorMapper; + + private static Class ENTITY_CLASS = Sensor.class; + public PageBean queryByPageBean(PageBean pageBean){ + return MyBatisBaseMapUtil.queryPage(sensorMapper,pageBean,ENTITY_CLASS); + } + public void addOrModify(Sensor sensor){ + try{ + if(sensor.getId()==null){ + sensorMapper.insertSelective(sensor); + }else{ + sensorMapper.updateByPrimaryKeySelective(sensor); + } + } + catch (Exception ex){ + throw ex; + } + } + + @Override + public void deleteByIds(Integer... ids) { + if(ids!=null&&ids.length>0){ + if(ids.length==1){ + sensorMapper.deleteByPrimaryKey(ids[0]); + }else{ + Example example = new Example(ENTITY_CLASS); + example.or().andIn("id", Arrays.asList(ids)); + sensorMapper.deleteByExample(example); + } + + } + } +} diff --git a/src/main/resources/mapper/DeviceVersionSensorMapper.xml b/src/main/resources/mapper/DeviceVersionSensorMapper.xml new file mode 100644 index 0000000..6f85d48 --- /dev/null +++ b/src/main/resources/mapper/DeviceVersionSensorMapper.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.moral.mapper.DeviceVersionSensorMapper" > + <resultMap id="BaseResultMap" type="com.moral.entity.DeviceVersionSensor" > + <id column="id" property="id" jdbcType="INTEGER" /> + <result column="device_version_id" property="deviceVersionId" jdbcType="INTEGER" /> + <result column="sensor_id" property="sensorId" jdbcType="INTEGER" /> + </resultMap> + <sql id="Base_Column_List" > + id, device_version_id, sensor_id + </sql> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/MonitorPointMapper.xml b/src/main/resources/mapper/MonitorPointMapper.xml index b434327..bf0a5ee 100644 --- a/src/main/resources/mapper/MonitorPointMapper.xml +++ b/src/main/resources/mapper/MonitorPointMapper.xml @@ -1,21 +1,103 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > -<mapper namespace="com.moral.mapper.MonitorPointMapper" > - <select id="getMonitorPointsByAreaName" resultType="com.moral.entity.MonitorPoint"> - SELECT - mp.* - FROM - monitor_point mp, - area a - <if test="cityName != null"> - ,city c - </if> - WHERE - mp.area_code = a.area_code - AND a.area_name = #{areaName} - <if test="cityName != null"> - AND c.city_name = #{cityName} - AND mp.city_code = c.city_code - </if> - </select> +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.moral.mapper.MonitorPointMapper"> + <resultMap id="BaseResultMap" type="com.moral.entity.MonitorPoint"> + <id column="id" jdbcType="INTEGER" property="id" /> + <result column="name" jdbcType="VARCHAR" property="name" /> + <result column="longitude" jdbcType="REAL" property="longitude" /> + <result column="latitude" jdbcType="REAL" property="latitude" /> + <result column="province_code" jdbcType="INTEGER" property="provinceCode" /> + <result column="city_code" jdbcType="INTEGER" property="cityCode" /> + <result column="area_code" jdbcType="INTEGER" property="areaCode" /> + <result column="organization_id" jdbcType="INTEGER" property="organizationId" /> + <result column="address" jdbcType="VARCHAR" property="address" /> + <result column="is_delete" jdbcType="CHAR" property="isDelete" /> + <result column="description" jdbcType="VARCHAR" property="description" /> + <!-- ������������������������������ --> + <association property="areaNames" javaType="com.moral.entity.AreaNames"> + <result column="province_name" property="provinceName" jdbcType="VARCHAR" /> + <result column="city_name" property="cityName" jdbcType="VARCHAR" /> + <result column="area_name" property="areaName" jdbcType="VARCHAR" /> + </association> + <association property="organization" javaType="com.moral.entity.Organization"> + <result column="organization_id" property="id" jdbcType="VARCHAR" /> + <result column="organization_name" property="name" jdbcType="VARCHAR" /> + </association> + </resultMap> + <sql id="Example_Where_Clause"> + <where> + <foreach collection="oredCriteria" item="criteria" separator="or"> + <if test="criteria.valid"> + <trim prefix="(" prefixOverrides="and" suffix=")"> + <foreach collection="criteria.criteria" item="criterion"> + <choose> + <when test="criterion.noValue"> + and ${criterion.condition} + </when> + <when test="criterion.singleValue"> + and ${criterion.condition} #{criterion.value} + </when> + <when test="criterion.betweenValue"> + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + </when> + <when test="criterion.listValue"> + and ${criterion.condition} + <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> + #{listItem} + </foreach> + </when> + </choose> + </foreach> + </trim> + </if> + </foreach> + </where> + </sql> + <sql id="Base_Column_List"> + id, name, longitude, latitude, province_code, city_code, area_code, organization_id, + address, is_delete, description + </sql> + <sql id="Relation_Province_City_Area_List"> + are.area_name, cti.city_name, pro.province_name + </sql> + <select id="selectWithAreaNameByExample" parameterType="tk.mybatis.mapper.entity.Example" resultMap="BaseResultMap"> + select + <if test="distinct"> + distinct + </if> + mpt.* , + org.name as organization_name , + <include refid="Relation_Province_City_Area_List" /> + from monitor_point mpt + left join area are on mpt.area_code = are.area_code + left join city cti on mpt.city_code = cti.city_code + left join province pro on mpt.province_code = pro.province_code + left join organization org on mpt.organization_id = org.id + where mpt.id in ( + select id from monitor_point + <if test="_parameter != null"> + <include refid="Example_Where_Clause" /> + </if> + <if test="orderByClause != null"> + order by ${orderByClause} + </if> + ) + </select> + <select id="getMonitorPointsByAreaName" resultType="com.moral.entity.MonitorPoint"> + SELECT + mp.* + FROM + monitor_point mp, + area a + <if test="cityName != null"> + ,city c + </if> + WHERE + mp.area_code = a.area_code + AND a.area_name = #{areaName} + <if test="cityName != null"> + AND c.city_name = #{cityName} + AND mp.city_code = c.city_code + </if> + </select> </mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/SensorMapper.xml b/src/main/resources/mapper/SensorMapper.xml new file mode 100644 index 0000000..3894d48 --- /dev/null +++ b/src/main/resources/mapper/SensorMapper.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.moral.mapper.SensorMapper" > + <resultMap id="BaseResultMap" type="com.moral.entity.Sensor" > + <id column="id" property="id" jdbcType="INTEGER" /> + <result column="name" property="name" jdbcType="VARCHAR" /> + <result column="key" property="key" jdbcType="VARCHAR" /> + <result column="upper" property="upper" jdbcType="DOUBLE" /> + <result column="lower" property="lower" jdbcType="DOUBLE" /> + <result column="unit" property="unit" jdbcType="VARCHAR" /> + <result column="description" property="description" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List" > + id, name, key, upper, lower, unit, description + </sql> +</mapper> \ No newline at end of file -- Gitblit v1.8.0