Browse Source

版本更新

lihui001 3 years ago
parent
commit
19c77c6824
35 changed files with 1975 additions and 34 deletions
  1. 6 0
      zoniot-common/zoniot-core-common/src/main/java/com/zcxk/core/common/pojo/ProgramItem.java
  2. 4 0
      zoniot-common/zoniot-core-mongo/pom.xml
  3. 21 0
      zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/annotation/QueryField.java
  4. 99 0
      zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/annotation/QueryType.java
  5. 134 3
      zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/base/BaseDao.java
  6. 2 0
      zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/pageing/PageableImpl.java
  7. 71 0
      zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/utils/MongoPrivilegeTools.java
  8. 374 0
      zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/utils/ReflectionUtils.java
  9. 279 0
      zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/utils/StringUtil.java
  10. 17 3
      zoniot-common/zoniot-core-utils/src/main/java/com/zcxk/core/utils/BigDecimalUtils.java
  11. 26 0
      zoniot-common/zoniot-core-utils/src/main/java/com/zcxk/core/utils/CommonUtils.java
  12. 19 16
      zoniot-common/zoniot-core-utils/src/main/java/com/zcxk/core/utils/export/EasyExcelUtil.java
  13. 30 0
      zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/dto/device/DeviceDataDto.java
  14. 2 0
      zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/dto/meterReadRecord/MeterReadRecordUpdateDto.java
  15. 26 0
      zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/vo/DeviceDataVo.java
  16. 67 0
      zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/vo/MeasuringPointVo.java
  17. 50 0
      zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/vo/ProductMeasuringDictVo.java
  18. 10 0
      zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/vo/StatisticsReadRateVo.java
  19. 39 0
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/ProductMeasuringDictMapper.java
  20. 40 0
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/ProductMeasuringPointMapper.java
  21. 45 0
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/mongo/DeviceDataDao.java
  22. 28 0
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/entity/ProductMeasuringDict.java
  23. 30 0
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/entity/ProductMeasuringPoint.java
  24. 119 0
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mapper/ProductMeasuringDictMapper.xml
  25. 144 0
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mapper/ProductMeasuringPointMapper.xml
  26. 73 0
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mongo/DeviceData.java
  27. 31 0
      zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mongo/DeviceMeasuringData.java
  28. 12 8
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/controller/DeviceController.java
  29. 38 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/controller/MeasuringPointController.java
  30. 5 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/controller/ProductCategoryController.java
  31. 23 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/DeviceDataService.java
  32. 3 4
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/DeviceService.java
  33. 24 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/ProductMeasuringPointService.java
  34. 55 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/impl/DeviceDataServiceImpl.java
  35. 29 0
      zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/impl/ProductMeasuringPointServiceImpl.java

+ 6 - 0
zoniot-common/zoniot-core-common/src/main/java/com/zcxk/core/common/pojo/ProgramItem.java

@@ -27,4 +27,10 @@ public class ProgramItem implements Serializable {
 
     private String newType;
 
+    @ApiModelProperty(value="维度编码")
+    private String dimensionCode;
+
+    @ApiModelProperty(value="维度值")
+    private String dimensionValue;
+
 }

+ 4 - 0
zoniot-common/zoniot-core-mongo/pom.xml

@@ -26,6 +26,10 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.zcxk</groupId>
+            <artifactId>zoniot-core-utils</artifactId>
+        </dependency>
     </dependencies>
 
     <properties>

+ 21 - 0
zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/annotation/QueryField.java

@@ -0,0 +1,21 @@
+package com.zcxk.core.mongo.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 
+ * @Description  
+ * type表示查询类似,默认为equals
+ * attribute表示要查询的属性,默认为空串,如果为空则为字段名称
+ * @author wilian.peng
+ * @date 2019年10月28日 下午12:17:40
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface QueryField {
+    QueryType type() default QueryType.EQUALS;
+    String attribute() default "";
+}

+ 99 - 0
zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/annotation/QueryType.java

@@ -0,0 +1,99 @@
+package com.zcxk.core.mongo.annotation;
+
+import com.zcxk.core.utils.CommonUtils;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.util.StringUtils;
+
+import java.lang.reflect.Field;
+import java.util.List;
+
+/**
+ * 
+ * @Description
+  *   查询媒介
+ * 1. equals:相等
+ * 2. like:mongodb的like查询
+ * 3. in:用于列表的in类型查询  
+ * @author wilian.peng
+ * @date 2019年10月28日 下午6:23:38
+ */
+public enum QueryType {
+
+    EQUALS {
+        @Override
+        public Criteria buildCriteria(QueryField queryFieldAnnotation, Field field, Object value) {
+            if (check(queryFieldAnnotation, field, value)) {
+                String queryField = getQueryFieldName(queryFieldAnnotation, field);
+                return Criteria.where(queryField).is(value);
+            }
+            return new Criteria();
+        }
+    },
+    LIKE {
+        @Override
+        public Criteria buildCriteria(QueryField queryFieldAnnotation, Field field, Object value) {
+            if (check(queryFieldAnnotation, field, value)) {
+                String queryField = getQueryFieldName(queryFieldAnnotation, field);
+                return Criteria.where(queryField).regex(CommonUtils.makeQueryStringAllRegExp(value.toString()));
+            }
+            return new Criteria();
+        }
+    },
+    IN {
+        @Override
+        public Criteria buildCriteria(QueryField queryFieldAnnotation, Field field, Object value) {
+            if (check(queryFieldAnnotation, field, value)) {
+                if (value instanceof List) {
+                    String queryField = getQueryFieldName(queryFieldAnnotation, field);
+                    // 此处必须转型为List,否则会在in外面多一层[]
+                    return Criteria.where(queryField).in((List<?>)value);
+                }
+            }
+            return new Criteria();
+        }
+    },
+    GTE{
+		@Override
+		public Criteria buildCriteria(QueryField queryFieldAnnotation, Field field, Object value) {
+			if (check(queryFieldAnnotation, field, value)) {
+                String queryField = getQueryFieldName(queryFieldAnnotation, field);
+                return Criteria.where(queryField).gte(value);
+			}
+			return new Criteria();
+		}
+    	
+    },
+    LTE{
+    	@Override
+		public Criteria buildCriteria(QueryField queryFieldAnnotation, Field field, Object value) {
+    		if (check(queryFieldAnnotation, field, value)) {
+                String queryField = getQueryFieldName(queryFieldAnnotation, field);
+                return Criteria.where(queryField).lte(value);
+			}
+			return new Criteria();
+		}
+    	
+    };
+
+    private static boolean check(QueryField queryField, Field field, Object value) {
+        return !(queryField == null || field == null || value == null);
+    }
+
+    public abstract Criteria buildCriteria(QueryField queryFieldAnnotation, Field field, Object value);
+
+
+    /**
+     * 如果实体bean的字段上QueryField注解没有设置attribute属性时,默认为该字段的名称
+     *
+     * @param field
+     * @return
+     */
+    private static String getQueryFieldName(QueryField queryField, Field field) {
+        String queryFieldValue = queryField.attribute();
+        if (!StringUtils.hasText(queryFieldValue)) {
+            queryFieldValue = field.getName();
+        }
+        return queryFieldValue;
+    }
+}
+

+ 134 - 3
zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/base/BaseDao.java

@@ -3,7 +3,9 @@ package com.zcxk.core.mongo.base;
 import com.mongodb.client.result.DeleteResult;
 import com.mongodb.client.result.UpdateResult;
 import com.zcxk.core.common.pojo.PageResult;
+import com.zcxk.core.mongo.annotation.QueryField;
 import com.zcxk.core.mongo.pageing.Page;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.domain.Sort;
@@ -16,11 +18,10 @@ import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.data.mongodb.core.query.Update;
 
 import java.io.Serializable;
+import java.lang.reflect.Field;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+import java.util.*;
 
 public class BaseDao<T, PK extends Serializable> {
 
@@ -235,4 +236,134 @@ public class BaseDao<T, PK extends Serializable> {
         return commonOperations;
     }
 
+    /**
+     * 根据vo构建查询条件Query
+     * @param t
+     * @return
+     */
+    public Query buildBaseQuery(T t) {
+        Query query = new Query();
+
+        List<Field> fields = getAllFields(t);
+        for (Field field : fields) {
+            field.setAccessible(true);
+            try {
+                Object value = field.get(t);
+                if (value != null) {
+                    QueryField queryField = field.getAnnotation(QueryField.class);
+                    if (queryField != null) {
+                        query.addCriteria(queryField.type().buildCriteria(queryField, field, value));
+                    }
+                }
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+        return query;
+    }
+
+    /**
+     * 根据vo构建查询条件Query
+     * @param list
+     * @return
+     */
+    public Query buildQuery(List<Criteria> list){
+        Query query = new Query();
+        for(Criteria c : list){
+            query.addCriteria(c);
+        }
+        return query ;
+    }
+    public List<Criteria> buildCriteriaList(T t){
+        List<Criteria> criteriaList = new ArrayList<>();
+        List<Field> fields = getAllFields(t);
+        for (Field field : fields) {
+            field.setAccessible(true);
+            try {
+                Object value = field.get(t);
+                if (value != null) {
+                    QueryField queryField = field.getAnnotation(QueryField.class);
+                    if (queryField != null) {
+                        criteriaList.add(queryField.type().buildCriteria(queryField, field, value));
+                    }
+                }
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+        return criteriaList ;
+    }
+
+    public List<Criteria> combineCriteria(List<Criteria>... criteriaAvgs ){
+        List<Criteria> result = new ArrayList<>();
+        Map<String,List<Criteria>> map = new HashMap<>() ;
+        for(List<Criteria> cList : criteriaAvgs){
+            for(Criteria c : cList){
+                String key = c.getKey();
+                List<Criteria> existList = map.get(key);
+                if(existList == null){
+                    existList = new ArrayList<>();
+                    existList.add(c);
+                    map.put(key,existList) ;
+                }
+                else{
+                    existList.add(c);
+                }
+            }
+        }
+        for(Map.Entry<String,List<Criteria>> entry : map.entrySet() ){
+            List<Criteria> value = entry.getValue();
+            if(value.size() == 1){
+                result.addAll(value) ;
+            }
+            else{
+                Criteria tmp = new Criteria();
+                tmp.andOperator(value.toArray(new Criteria[value.size()]));
+                result.add(tmp);
+            }
+        }
+        return result ;
+    }
+
+    /**
+     * 根据vo构建更新条件Query
+     * @param t
+     * @return
+     */
+    public Update buildBaseUpdate(T t) {
+        Update update = new Update();
+
+        Field[] fields = t.getClass().getDeclaredFields();
+        for (Field field : fields) {
+            field.setAccessible(true);
+            try {
+                Object value = field.get(t);
+                if (value != null) {
+                    if(StringUtils.equals("serialVersionUID",field.getName())){
+                        continue;
+                    }
+                    update.set(field.getName(), value);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return update;
+    }
+
+    private List<Field> getAllFields(T t) {
+        List<Field> fieldList = new ArrayList<>() ;
+        Class tempClass = t.getClass();
+        // 当父类为null的时候说明到达了最上层的父类(Object类).
+        while (tempClass != null) {
+            fieldList.addAll(Arrays.asList(tempClass .getDeclaredFields()));
+            tempClass = tempClass.getSuperclass(); //得到父类,然后赋给自己
+        }
+        return fieldList;
+    }
+
 }

+ 2 - 0
zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/pageing/PageableImpl.java

@@ -17,7 +17,9 @@ public class PageableImpl implements Pageable, Serializable {
     private static final long serialVersionUID = -2348915232521382937L;
 
     private int page = 1;
+
     private int size = 10;
+
     private Sort sort;
 
     public PageableImpl() {

+ 71 - 0
zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/utils/MongoPrivilegeTools.java

@@ -0,0 +1,71 @@
+package com.zcxk.core.mongo.utils;
+
+import com.zcxk.core.common.pojo.ProgramItem;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.mongodb.core.query.Criteria;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class MongoPrivilegeTools {
+
+    public static Criteria[] buildDataPrivilegeCriteria(List<ProgramItem> dataProgramList){
+        List<Criteria> result = new ArrayList<>();
+        // 1,安装维度构建Map
+        Map<String,List<Integer>> dataProgramMap = new HashMap<>() ;
+        for (ProgramItem item : dataProgramList){
+            String code = item.getDimensionCode();
+            String value = item.getDimensionValue() ;
+            List<Integer> dataList = dataProgramMap.get(code);
+            if(dataList == null) {
+                dataList = new ArrayList<>();
+                dataList.add(Integer.parseInt(value));
+                dataProgramMap.put(code,dataList) ;
+            }
+            else{
+                dataList.add(Integer.parseInt(value));
+            }
+
+        }
+        // 2,构建查询条件
+        for(Map.Entry<String, List<Integer>> entry : dataProgramMap.entrySet()){
+            String key = entry.getKey();
+            List<Integer> value = entry.getValue();
+            if(StringUtils.equals(key,"PROVINCE")){ // 省维度
+                Criteria pCriteria = Criteria.where("provinceId").in(value);
+                result.add(pCriteria);
+            }
+            else if(StringUtils.equals(key,"CITY")){ // 市维度
+                Criteria cityCriteria = Criteria.where("cityId").in(value);
+                result.add(cityCriteria);
+            }
+            else if(StringUtils.equals(key,"REGION")){ // 区维度
+                Criteria cityCriteria = Criteria.where("regionId").in(value);
+                result.add(cityCriteria);
+            }
+            else if(StringUtils.equals(key,"COMMUNITY")){ // 小区维度
+                Criteria communityCriteria = Criteria.where("communityId").in(value);
+                result.add(communityCriteria);
+            }
+            else if(StringUtils.equals(key,"BUILDING")){ // 建筑维度
+                Criteria buildingCriteria = Criteria.where("buildingId").in(value);
+                result.add(buildingCriteria);
+            }
+            else if (StringUtils.equals(key,"CUSTOMER")){ // 客户维度
+                Criteria cCriteria = Criteria.where("customerId").in(value) ;
+                result.add(cCriteria);
+            }
+            else if (StringUtils.equals(key,"PROJECT")){ // 项目维度
+                Criteria proCriteria = Criteria.where("projectId").in(value) ;
+                result.add(proCriteria);
+            }
+        }
+
+        //转换数组
+        Criteria[] criteriaArray = result.toArray(new Criteria[result.size()]);
+        return criteriaArray ;
+    }
+
+}

+ 374 - 0
zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/utils/ReflectionUtils.java

@@ -0,0 +1,374 @@
+package com.zcxk.core.mongo.utils;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+import java.lang.reflect.*;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 
+ * @Description 
+ *  反射工具类.
+ * <p>
+  * 提供访问私有变量,获取泛型类型Class, 提取集合中元素的属性, 转换字符串到对象等Util函数. 
+ * @author wilian.peng
+ * @date 2019年10月28日 下午6:26:19
+ */
+@Slf4j
+public class ReflectionUtils {
+
+    /**
+     * 调用Getter方法.
+     */
+    public static Object invokeGetterMethod(Object obj, String propertyName) {
+        String getterMethodName = "get" + StringUtils.capitalize(propertyName);
+        return invokeMethod(obj, getterMethodName, new Class[]{}, new Object[]{});
+    }
+
+    /**
+     * 调用Setter方法.使用value的Class来查找Setter方法.
+     */
+    public static void invokeSetterMethod(Object obj, String propertyName, Object value) {
+        invokeSetterMethod(obj, propertyName, value, null);
+    }
+
+    /**
+     * 调用Setter方法.
+     *
+     * @param propertyType 用于查找Setter方法,为空时使用value的Class替代.
+     */
+    public static void invokeSetterMethod(Object obj, String propertyName, Object value, Class<?> propertyType) {
+        Class<?> type = propertyType != null ? propertyType : value.getClass();
+        String setterMethodName = "set" + StringUtils.capitalize(propertyName);
+        invokeMethod(obj, setterMethodName, new Class[]{type}, new Object[]{value});
+    }
+
+    /**
+     * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数.
+     */
+    public static Object getFieldValue(final Object obj, final String fieldName) {
+        Field field = getAccessibleField(obj, fieldName);
+
+        if (field == null) {
+            throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
+        }
+
+        Object result = null;
+        try {
+            result = field.get(obj);
+        } catch (IllegalAccessException e) {
+            log.error("不可能抛出的异常{}", e.getMessage());
+        }
+        return result;
+    }
+
+    /**
+     * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数.
+     */
+    public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
+        Field field = getAccessibleField(obj, fieldName);
+
+        if (field == null) {
+            throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
+        }
+
+        try {
+            field.set(obj, value);
+        } catch (IllegalAccessException e) {
+            log.error("不可能抛出的异常:{}", e.getMessage());
+        }
+    }
+
+    /**
+     * 循环向上转型, 获取对象的DeclaredField,	 并强制设置为可访问.
+     * <p>
+     * 如向上转型到Object仍无法找到, 返回null.
+     */
+    public static Field getAccessibleField(final Object obj, final String fieldName) {
+        Assert.notNull(obj, "object不能为空");
+        Assert.hasText(fieldName, "fieldName");
+        for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
+            try {
+                Field field = superClass.getDeclaredField(fieldName);
+                field.setAccessible(true);
+                return field;
+            } catch (NoSuchFieldException e) {//NOSONAR
+                // Field不在当前类定义,继续向上转型
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 直接调用对象方法, 无视private/protected修饰符.
+     * 用于一次性调用的情况.
+     */
+    public static Object invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
+                                      final Object[] args) {
+        Method method = getAccessibleMethod(obj, methodName, parameterTypes);
+        if (method == null) {
+            throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
+        }
+
+        try {
+            return method.invoke(obj, args);
+        } catch (Exception e) {
+            throw convertReflectionExceptionToUnchecked(e);
+        }
+    }
+
+    /**
+     * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问.
+     * 如向上转型到Object仍无法找到, 返回null.
+     * <p>
+     * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
+     */
+    public static Method getAccessibleMethod(final Object obj, final String methodName,
+                                             final Class<?>... parameterTypes) {
+        Assert.notNull(obj, "object不能为空");
+
+        for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
+            try {
+                Method method = superClass.getDeclaredMethod(methodName, parameterTypes);
+
+                method.setAccessible(true);
+
+                return method;
+
+            } catch (NoSuchMethodException e) {//NOSONAR
+                // Method不在当前类定义,继续向上转型
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 通过反射, 获得Class定义中声明的父类的泛型参数的类型.
+     * 如无法找到, 返回Object.class.
+     * eg.
+     * public UserDao extends HibernateDao<User>
+     *
+     * @param clazz The class to introspect
+     * @return the first generic declaration, or Object.class if cannot be determined
+     */
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public static <T> Class<T> getSuperClassGenricType(final Class clazz) {
+        return getSuperClassGenricType(clazz, 0);
+    }
+
+    /**
+     * 通过反射, 获得Class定义中声明的父类的泛型参数的类型.
+     * 如无法找到, 返回Object.class.
+     * <p>
+     * 如public UserDao extends HibernateDao<User,Long>
+     *
+     * @param clazz clazz The class to introspect
+     * @param index the Index of the generic ddeclaration,start from 0.
+     * @return the index generic declaration, or Object.class if cannot be determined
+     */
+    @SuppressWarnings("rawtypes")
+    public static Class getSuperClassGenricType(final Class clazz, final int index) {
+
+        Type genType = clazz.getGenericSuperclass();
+
+        if (!(genType instanceof ParameterizedType)) {
+            log.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType");
+            return Object.class;
+        }
+
+        Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
+
+        if (index >= params.length || index < 0) {
+            log.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
+                    + params.length);
+            return Object.class;
+        }
+        if (!(params[index] instanceof Class)) {
+            log.warn(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
+            return Object.class;
+        }
+
+        return (Class) params[index];
+    }
+
+    /**
+     * 将反射时的checked exception转换为unchecked exception.
+     */
+    public static RuntimeException convertReflectionExceptionToUnchecked(Exception e) {
+        if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException
+                || e instanceof NoSuchMethodException) {
+            return new IllegalArgumentException("Reflection Exception.", e);
+        } else if (e instanceof InvocationTargetException) {
+            return new RuntimeException("Reflection Exception.", ((InvocationTargetException) e).getTargetException());
+        } else if (e instanceof RuntimeException) {
+            return (RuntimeException) e;
+        }
+        return new RuntimeException("Unexpected Checked Exception.", e);
+    }
+
+    /**
+     * 根据对象获得mongodb Update语句
+     * 除id字段以外,所有被赋值的字段都会成为修改项
+     */
+    public static Update getUpdateObj(final Object obj) {
+        if (obj == null)
+            return null;
+        Field[] fields = obj.getClass().getDeclaredFields();
+        Update update = null;
+        boolean isFirst = true;
+        for (Field field : fields) {
+            field.setAccessible(true);
+            try {
+                Object value = field.get(obj);
+                if (value != null) {
+                    if ("id".equals(field.getName().toLowerCase()) || "serialversionuid".equals(field.getName().toLowerCase()))
+                        continue;
+                    if (isFirst) {
+                        update = Update.update(field.getName(), value);
+                        isFirst = false;
+                    } else {
+                        update = update.set(field.getName(), value);
+                    }
+                }
+
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+        return update;
+    }
+
+    /**
+     * 根据对象获得mongodb Query语句
+     * <p>
+     * 1.时间范围查询:在时间字段前增加begin或end,为这两个字段分别赋值
+     * 例:private Date createDate;
+     * 开始时间
+     * private Date beginCreateDate;
+     * 结束时间
+     * private Date endCreateDate;
+     * 分析后结果:where createDate >= beginCreateDate and createDate < beginCreateDate
+     * <p>
+     * 2.排序
+     * 定义并赋值VO中 orderBy 字段,以英文“,”分割多个排序,以空格分隔排序方向 asc可不写
+     * 例:private String orderBy;
+     * orderBy="createDate desc,sendDate asc,id"
+     * 分析结构:order by createDate desc,sendDate asc,id asc
+     * <p>
+     * 3.固定值搜索
+     * 定义并赋值VO中的任意字段,搜索时会把以赋值的字段当作为搜索条件
+     */
+    public static Query getQueryObj(final Object obj) {
+        if (obj == null)
+            return null;
+        Field[] fields = obj.getClass().getDeclaredFields();
+        // Sort sort=new Sort(new Order(Direction.DESC,"createDate"));
+        Query query = new Query();
+        //存放日期范围或者确定日期
+        Map<String, Criteria> dateMap = new HashMap<String, Criteria>();
+        String sortStr = null;
+        for (Field field : fields) {
+            field.setAccessible(true);
+            try {
+                Object value = field.get(obj);
+                if (value != null) {
+                    if ("serialversionuid".equals(field.getName().toLowerCase())) {
+                        continue;
+                    }
+                    if ("orderby".equals(field.getName().toLowerCase())) {
+                        sortStr = String.valueOf(value);
+                        continue;
+                    }
+                    //如果是日期类型
+                    if (field.getType().getSimpleName().equals("Date")) {
+                        if (field.getName().toLowerCase().startsWith("begin")) {
+                            String beginName = field.getName().substring(5);
+                            if (beginName.isEmpty()) {
+                                dateMap.put("begin", Criteria.where("begin").is(value));
+                            } else {
+                                beginName = StringUtil.toLowerCaseFirstOne(beginName);
+                                Criteria criteria = dateMap.get(beginName) == null ? Criteria.where(beginName).gte(value) : dateMap.get(beginName).gte(value);
+                                dateMap.put(beginName, criteria);
+                            }
+                            continue;
+                        }
+                        if (field.getName().toLowerCase().startsWith("end")) {
+                            String endName = field.getName().substring(3);
+                            if (endName.isEmpty()) {
+                                dateMap.put("end", Criteria.where("end").is(value));
+                            } else {
+                                endName = StringUtil.toLowerCaseFirstOne(endName);
+                                Criteria criteria = dateMap.get(endName) == null ? Criteria.where(endName).lt(value) : dateMap.get(endName).lt(value);
+                                dateMap.put(endName, criteria);
+                            }
+                            continue;
+                        }
+                        dateMap.put(field.getName(), Criteria.where(field.getName()).is(value));
+                        continue;
+                    }
+                    query.addCriteria(Criteria.where(field.getName()).is(value));
+                }
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }        //日期类型查询条件
+        for (String key : dateMap.keySet()) {
+            if (dateMap.get(key) != null) {
+                query.addCriteria(dateMap.get(key));
+            }
+        }
+        //排序
+        if (sortStr != null && !sortStr.trim().isEmpty()) {
+            Sort sort = null;
+            String[] strs = sortStr.split(",");
+            for (String str : strs) {
+                str = str.trim();
+                if (str.isEmpty()) {
+                    continue;
+                }
+                int i = str.indexOf(" ");
+                if (i < 0) {
+                    if (sort == null) {
+                        sort = Sort.by(Direction.ASC, str);
+                    } else {
+                        sort = sort.and(Sort.by(Direction.ASC, str));
+                    }
+                } else {
+                    String name = str.substring(0, i);
+                    String dire = str.substring(i + 1).trim();
+                    Sort sn = null;
+                    if ("desc".equals(dire.toLowerCase())) {
+                        sn = Sort.by(Direction.DESC, name);
+                    } else {
+                        sn = Sort.by(Direction.ASC, name);
+                    }
+                    if (sort == null) {
+                        sort = sn;
+                    } else {
+                        sort = sort.and(sn);
+                    }
+                }
+            }
+            if (sort != null) {
+                query.with(sort);
+            }
+        }
+        return query;
+    }
+
+    public static void main(String[] a) {
+
+    }
+}
+

+ 279 - 0
zoniot-common/zoniot-core-mongo/src/main/java/com/zcxk/core/mongo/utils/StringUtil.java

@@ -0,0 +1,279 @@
+package com.zcxk.core.mongo.utils;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+ 
+public class StringUtil {
+
+    private StringUtil() {
+        super();
+    }
+
+ 
+    public static String formatNull(String src) {
+        return (src == null || "null".equals(src)) ? "" : src;
+    }
+
+ 
+    private static final String EMPTY_REGEX = "[\\s\\u00a0\\u2007\\u202f\\u0009-\\u000d\\u001c-\\u001f]+";
+
+ 
+    public static boolean isEmpty(String input) {
+        return input == null || input.equals("") || input.matches(EMPTY_REGEX);
+    }
+
+    public static boolean isNotEmpty(String input) {
+        return !isEmpty(input);
+    }
+
+    private static final String NUM_REG = "(\\+|\\-)?\\s*\\d+(\\.\\d+)?";
+
+
+ 
+    public static String toLowerCaseFirstOne(String s) {
+        if (Character.isLowerCase(s.charAt(0)))
+            return s;
+        else
+            return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
+    }
+
+ 
+    public static String toUpperCaseFirstOne(String s) {
+        if (Character.isUpperCase(s.charAt(0)))
+            return s;
+        else
+            return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
+    }
+
+
+ 
+        public static boolean isNumber (String str){
+            if (isEmpty(str)) {
+                return false;
+            }
+
+            if (str.trim().matches(NUM_REG)) {
+                return true;
+            }
+
+            return false;
+        }
+
+ 
+        public static boolean containUnreadableCode (String str){
+            return contain(str, "\\ufffd");
+        }
+
+ 
+        public static boolean containNumber (String str){
+            return contain(str, "\\d");
+        }
+
+   
+        public static boolean containWord (String str){
+            return contain(str, "\\w");
+        }
+
+ 
+        public static boolean containPunct (String str){
+            return contain(str, PUNCT_REG);
+        }
+
+        public static boolean contain (String str, String regex){
+            if (isEmpty(str) || isEmpty(regex)) {
+                return false;
+            }
+
+            if (str.trim().matches(regex)) {
+                return true;
+            }
+
+            Pattern pattern = Pattern.compile(regex);
+            Matcher matcher = pattern.matcher(str);
+            if (matcher.find()) {
+                return true;
+            }
+
+            return false;
+        }
+
+   
+        public static String replaceAll (String input, String regex,
+                String replacement){
+            return Pattern.compile(regex, Pattern.CASE_INSENSITIVE).matcher(input)
+                    .replaceAll(replacement);
+        }
+
+  
+        public static String removeAllSpace (String text){
+            if (isEmpty(text)) {
+                return text;
+            }
+
+            return text.replaceAll("[ ]+", "");
+        }
+
+        private static final String PUNCT_REG = "[^a-zA-Z0-9\\u4e00-\\u9fa5]";
+
+  
+        public static String removeAllPunct (String str){
+            if (isEmpty(str)) {
+                return str;
+            }
+
+            return str.replaceAll(PUNCT_REG, "");
+        }
+
+  
+        public static int countMatches (String str, String sub){
+            if (isEmpty(str) || isEmpty(sub)) {
+                return 0;
+            }
+
+            int count = 0;
+            int idx = 0;
+            while ((idx = str.indexOf(sub, idx)) != -1) {
+                count++;
+                idx += sub.length();
+            }
+
+            return count;
+        }
+
+  
+        public static String substring (String str,int beginIndex, int endIndex){
+            if (isEmpty(str)) {
+                return str;
+            }
+
+            int length = str.length();
+
+            if (beginIndex >= length || endIndex <= 0 || beginIndex >= endIndex) {
+                return null;
+            }
+
+            if (beginIndex < 0) {
+                beginIndex = 0;
+            }
+            if (endIndex > length) {
+                endIndex = length;
+            }
+
+            return str.substring(beginIndex, endIndex);
+        }
+
+   
+        public static Set<String> substring (String str, String sub){
+            if (isEmpty(str) || isEmpty(sub)) {
+                return null;
+            }
+
+            Set<String> result = new HashSet<String>();
+            int idx = 0;
+            while ((idx = str.indexOf(sub, idx)) != -1) {
+                String temp = substring(str, idx - 1, idx + sub.length());
+                if (!isEmpty(temp)) {
+                    temp = removeAllPunct(temp);
+                    if (!sub.equalsIgnoreCase(temp) && !containWord(temp)) {
+                        result.add(temp);
+                    }
+
+                }
+
+                temp = substring(str, idx, idx + sub.length() + 1);
+                if (!isEmpty(temp)) {
+                    temp = removeAllPunct(temp);
+                    if (!sub.equalsIgnoreCase(temp) && !containWord(temp)) {
+                        result.add(temp);
+                    }
+                }
+
+                idx += sub.length();
+            }
+
+            return result;
+        }
+ 
+        public static String wrapXmlContent (String content){
+            if (isEmpty(content)) {
+                return "";
+            }
+
+            StringBuilder result = new StringBuilder();
+
+            for (int i = 0; i < content.length(); i++) {
+                char ch = content.charAt(i);
+                if ((ch == '\t') || (ch == '\n') || (ch == '\r')
+                        || ((ch >= ' ') && (ch <= 55295))
+                        || ((ch >= 57344) && (ch <= 65533))
+                        || ((ch >= 65536) && (ch <= 1114111))) {
+                    result.append(ch);
+                }
+            }
+
+            return result.toString();
+        }
+
+  
+        public static boolean overLength (String str){
+            if (isEmpty(str)) {
+                return false;
+            }
+
+            return str.length() > 1 ? true : false;
+        }
+
+   
+        public static String specialStr (String str){
+            str = str.replaceAll("[^\\u4e00-\\u9fa5 | 0-9| a-zA-Z | \\.]+", " ")
+                    .replaceAll("[\\.]{2,}", " ").trim();
+            return str;
+        }
+
+  
+        public static String replaceInValidateChar (String str){
+            return str.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5\\s+]", " ");
+        }
+
+  
+        public static String[] toHexString (String str){
+            char[] chars = str.toCharArray();
+
+            String[] result = new String[chars.length];
+
+            for (int i = 0; i < chars.length; i++) {
+                result[i] = Integer.toHexString((int) chars[i]);
+            }
+
+            return result;
+        }
+
+        public static String getUuid () {
+            return UUID.randomUUID().toString();
+        }
+
+        public static boolean isUrl (String src){
+            String regex = "http[s]?:\\/\\/([\\w-]+\\.[\\w-]+)(\\.[\\w-])+(:\\d{2,10})?.*";
+            Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
+            Matcher matcher = pattern.matcher(src);
+            return matcher.matches();
+        }
+
+ 
+        public static String escapeSql (String str){
+            if (StringUtil.isNotEmpty(str)) {
+                StringBuffer strbuff = new StringBuffer();
+                for (String s : str.split("")) {
+                    if (s.equals("%") || s.equals("_") || s.equals("\\")) {
+                        strbuff.append("\\");
+                    }
+                    strbuff.append(s);
+                }
+                return strbuff.toString();
+            }
+            return str;
+        }
+    }

+ 17 - 3
zoniot-common/zoniot-core-utils/src/main/java/com/zcxk/core/utils/BigDecimalUtils.java

@@ -42,12 +42,26 @@ public class BigDecimalUtils {
         return new BigDecimal(value.toString()).divide(new BigDecimal(value2.toString()), scale, RoundingMode.HALF_UP);
     }
 
+    /**
+    * @author Andy
+    * @description 乘法
+    * @date 9:38 2021/8/2
+    * @param value, value2
+    * @return java.math.BigDecimal
+    **/
+    public static BigDecimal subtract(Object value, Object value2){
+        return subtract(new BigDecimal(value.toString()), new BigDecimal(value2.toString()));
+    }
+
+    /**
+     * 乘法
+     * @param value
+     * @param value2
+     * @return
+     */
     public static BigDecimal subtract(BigDecimal value, BigDecimal value2){
         return value.subtract(value2);
     }
 
-    public static void main(String[] args) {
-        System.out.println(BigDecimalUtils.divideDown(1888,2068,4));
-    }
 
 }

+ 26 - 0
zoniot-common/zoniot-core-utils/src/main/java/com/zcxk/core/utils/CommonUtils.java

@@ -0,0 +1,26 @@
+package com.zcxk.core.utils;
+
+import org.apache.commons.lang3.StringUtils;
+
+
+public class CommonUtils {
+
+	/**
+	 * 转义正则特殊字符 ($()*+.[]?\^{}
+	 * \\需要第一个替换,否则replace方法替换时会有逻辑bug
+	 */
+	public static String makeQueryStringAllRegExp(String str) {
+		if(StringUtils.isBlank(str)){
+			return str;
+		}
+		return str.replace("\\", "\\\\").replace("*", "\\*")
+				.replace("+", "\\+").replace("|", "\\|")
+				.replace("{", "\\{").replace("}", "\\}")
+				.replace("(", "\\(").replace(")", "\\)")
+				.replace("^", "\\^").replace("$", "\\$")
+				.replace("[", "\\[").replace("]", "\\]")
+				.replace("?", "\\?").replace(",", "\\,")
+				.replace(".", "\\.").replace("&", "\\&");
+	}
+
+}

+ 19 - 16
zoniot-common/zoniot-core-utils/src/main/java/com/zcxk/core/utils/export/EasyExcelUtil.java

@@ -48,7 +48,7 @@ public  class EasyExcelUtil {
             EasyExcel.write(path + fileName, t)
                     .excelType(ExcelTypeEnum.XLSX)
                     .registerWriteHandler(new CustemhandlerUtils())
-                    .registerWriteHandler(EasyExcelUtil.getStyleStrategy())
+                    .registerWriteHandler(getStyleStrategy())
                     .sheet("Export")
                     .doWrite(data);
             filePath = getPathFileName(path, fileName);
@@ -59,6 +59,22 @@ public  class EasyExcelUtil {
         }
         return filePath;
     }
+
+    public static void excelWrite(HttpServletResponse response,Class t, String excelName, List data) throws Exception {
+        String fileName =  excelName +"-"+ DateUtil.format(new Date(), "yyyyMMddHHmmss")  + ".xlsx";
+        response.setContentType("APPLICATION/OCTET-STREAM");
+        response.setCharacterEncoding("utf-8");
+        String headStr = "attachment;filename*=UTF-8''" + URLEncoder.encode(fileName, "UTF-8");
+        response.setHeader("Content-Disposition", headStr);
+        EasyExcel.write(response.getOutputStream(), t)
+                .excelType(ExcelTypeEnum.XLSX)
+                .registerWriteHandler(new CustemhandlerUtils())
+                .registerWriteHandler(EasyExcelUtil.getStyleStrategy())
+                .sheet("Export")
+                .doWrite(data);
+    }
+
+
     private static final String getPathFileName(String uploadDir, String fileName) throws IOException {
         String pathFileName = uploadDir  + "/" + fileName;
         return ToolUtil.path(pathFileName);
@@ -72,7 +88,8 @@ public  class EasyExcelUtil {
 
         return desc;
     }
-    public static HorizontalCellStyleStrategy getStyleStrategy(){
+
+    private static HorizontalCellStyleStrategy getStyleStrategy(){
         // 头的策略
         WriteCellStyle headWriteCellStyle = new WriteCellStyle();
         // 背景设置为灰色
@@ -104,18 +121,4 @@ public  class EasyExcelUtil {
         // 这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现
         return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
     }
-
-    public static void excelWrite(HttpServletResponse response,Class t, String excelName, List data) throws Exception {
-        String fileName =  excelName +"-"+ DateUtil.format(new Date(), "yyyyMMddHHmmss")  + ".xlsx";
-        response.setContentType("APPLICATION/OCTET-STREAM");
-        response.setCharacterEncoding("utf-8");
-        String headStr = "attachment;filename*=UTF-8''" + URLEncoder.encode(fileName, "UTF-8");
-        response.setHeader("Content-Disposition", headStr);
-        EasyExcel.write(response.getOutputStream(), t)
-                .excelType(ExcelTypeEnum.XLSX)
-                .registerWriteHandler(new CustemhandlerUtils())
-                .registerWriteHandler(EasyExcelUtil.getStyleStrategy())
-                .sheet("Export")
-                .doWrite(data);
-    }
 }

+ 30 - 0
zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/dto/device/DeviceDataDto.java

@@ -0,0 +1,30 @@
+package com.zcxk.rmcp.api.dto.device;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * @author Andy
+ * @version V1.0
+ * @description: 设备数据dto
+ * @date 2021/8/2
+ **/
+@ApiModel
+@Data
+public class DeviceDataDto {
+
+    @ApiModelProperty(value="设备id")
+    private Long deviceId;
+
+    @ApiModelProperty(value="测点code")
+    private String measuringCode;
+
+    @ApiModelProperty(value="查询日期,YYYYMMDD格式")
+    private Integer startDate;
+
+    @ApiModelProperty(value="查询日期,YYYYMMDD格式")
+    private Integer endDate;
+
+}

+ 2 - 0
zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/dto/meterReadRecord/MeterReadRecordUpdateDto.java

@@ -26,5 +26,7 @@ public class MeterReadRecordUpdateDto  {
     private String readDate;
 
     @ApiModelProperty(value="读数")
+    @NotNull
+    @NotEmpty
     private String readData;
 }

+ 26 - 0
zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/vo/DeviceDataVo.java

@@ -0,0 +1,26 @@
+package com.zcxk.rmcp.api.vo;
+
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+import java.util.List;
+
+@Data
+@ApiModel
+@EqualsAndHashCode(callSuper=false)
+public class DeviceDataVo {
+
+	@ApiModelProperty(value = "值",position = 1)
+	private String value;
+
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+	@ApiModelProperty(value = "时间",position = 2)
+	private Date dateTime;
+
+}

+ 67 - 0
zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/vo/MeasuringPointVo.java

@@ -0,0 +1,67 @@
+package com.zcxk.rmcp.api.vo;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author Andy
+ * @version V1.0
+ * @description: TODO
+ * @date 2021/8/2
+ **/
+@Data
+public class MeasuringPointVo {
+
+
+    @ApiModelProperty(value="主键")
+    private Integer id;
+
+    @ApiModelProperty(value="设备类型")
+    private Integer productId;
+
+    @ApiModelProperty(value="测点编码")
+    private String measuringCode;
+
+    @ApiModelProperty(value="测点名称")
+    private String measuringName;
+
+    @ApiModelProperty(value="测点描述")
+    private String measuringDesc;
+
+    @ApiModelProperty(value="测点单位")
+    private String measuringUnit;
+
+    @ApiModelProperty(value="测点数据类型 1:离散 2:连续")
+    private String measuringDataType;
+
+    @JsonIgnore
+    @ApiModelProperty(value="状态")
+    private Integer status;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建时间")
+    private Date dateCreate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新时间")
+    private Date dateUpdate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建人")
+    private String createBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新人")
+    private String updateBy;
+
+    @ApiModelProperty(value="数据值")
+    private List<ProductMeasuringDictVo> dictList;
+
+    @ApiModelProperty(value="测点取值")
+    private String measuringData;
+
+}

+ 50 - 0
zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/vo/ProductMeasuringDictVo.java

@@ -0,0 +1,50 @@
+package com.zcxk.rmcp.api.vo;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author Andy
+ * @version V1.0
+ * @description: TODO
+ * @date 2021/8/2
+ **/
+@Data
+public class ProductMeasuringDictVo {
+
+    @ApiModelProperty(value="测点id")
+    private Integer pointId;
+
+    @ApiModelProperty(value="数据值")
+    private String dataValue;
+
+    @ApiModelProperty(value="数据名称")
+    private String dataName;
+
+    @JsonIgnore
+    @ApiModelProperty(value="数据描述")
+    private String dataDesc;
+
+    @JsonIgnore
+    @ApiModelProperty(value="状态")
+    private Integer status;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建人")
+    private String createBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新人")
+    private String updateBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建时间")
+    private LocalDateTime dateCreate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新时间")
+    private LocalDateTime dateUpdate;
+}

+ 10 - 0
zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/vo/StatisticsReadRateVo.java

@@ -1,7 +1,9 @@
 package com.zcxk.rmcp.api.vo;
 
+import com.zcxk.core.utils.BigDecimalUtils;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
 
 /**
  * @author Andy
@@ -26,4 +28,12 @@ public class StatisticsReadRateVo {
 
     @ApiModelProperty(value="抄表率")
     private String readRate;
+
+    /**
+     * 转换
+     * @return
+     */
+    public String getReadRate(){
+        return StringUtils.isEmpty(readRate) ? "0%" : BigDecimalUtils.subtract(readRate, "100").toEngineeringString() + "%";
+    }
 }

+ 39 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/ProductMeasuringDictMapper.java

@@ -0,0 +1,39 @@
+package com.zcxk.rmcp.core.dao;
+
+import com.zcxk.rmcp.api.vo.ProductMeasuringDictVo;
+import com.zcxk.rmcp.core.entity.ProductMeasuringDict;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface ProductMeasuringDictMapper {
+
+    /**
+    * @author Andy
+    * @description 添加数据
+    * @date 14:22 2021/8/2
+    * @param record
+    * @return int
+    **/
+    int insertSelective(ProductMeasuringDict record);
+
+    /**
+    * @author Andy
+    * @description 更新数据
+    * @date 14:23 2021/8/2
+    * @param record
+    * @return int
+    **/
+    int updateByPrimaryKeySelective(ProductMeasuringDict record);
+
+    /**
+    * @author Andy
+    * @description 查询数据
+    * @date 14:23 2021/8/2
+    * @param pointId
+    * @return java.util.List<com.zcxk.rmcp.api.vo.ProductMeasuringDictVo>
+    **/
+    List<ProductMeasuringDictVo> getList(@Param("pointId") Integer pointId);
+}

+ 40 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/ProductMeasuringPointMapper.java

@@ -0,0 +1,40 @@
+package com.zcxk.rmcp.core.dao;
+
+import com.zcxk.rmcp.api.vo.MeasuringPointVo;
+import com.zcxk.rmcp.core.entity.ProductMeasuringPoint;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface ProductMeasuringPointMapper {
+
+    /**
+    * @author Andy
+    * @description 添加数据
+    * @date 14:22 2021/8/2
+    * @param record
+    * @return int
+    **/
+    int insertSelective(ProductMeasuringPoint record);
+
+    /**
+    * @author Andy
+    * @description 更新数据
+    * @date 14:22 2021/8/2
+    * @param record
+    * @return int
+    **/
+    int updateByPrimaryKeySelective(ProductMeasuringPoint record);
+
+    /**
+    * @author Andy
+    * @description 查询数据
+    * @date 14:22 2021/8/2
+    * @param productId
+    * @return java.util.List<com.zcxk.rmcp.api.vo.MeasuringPointVo>
+    **/
+    List<MeasuringPointVo> getList(@Param("productId") Integer productId);
+
+}

+ 45 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/mongo/DeviceDataDao.java

@@ -0,0 +1,45 @@
+package com.zcxk.rmcp.core.dao.mongo;
+
+import com.zcxk.core.mongo.base.BaseDao;
+import com.zcxk.rmcp.core.mongo.DeviceData;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * @author Andy
+ * @version V1.0
+ * @description: 设备数据
+ * @date 2021/8/2
+ **/
+@Repository
+public class DeviceDataDao  extends BaseDao<DeviceData, String> implements BaseMongoDao {
+
+    /**
+    * @author Andy
+    * @description 查询设备数据
+    * @date 11:39 2021/8/2
+    * @param deviceId, beginDate, endDate
+    * @return java.util.List<com.zcxk.rmcp.core.mongo.DeviceData>
+    **/
+    public List<DeviceData> queryDeviceData(Long deviceId, Integer beginDate, Integer endDate){
+        DeviceData param = new DeviceData();
+        param.setDeviceId(deviceId);
+        Query query = buildBaseQuery(param);
+        if(beginDate != null || endDate != null){
+            Criteria criteria = Criteria.where("receiveDate");
+            if(beginDate != null){
+                criteria.gte(beginDate);
+            }
+            if(endDate != null){
+                criteria.lte(endDate);
+            }
+            query.addCriteria(criteria);
+        }
+        query.with(Sort.by(Sort.Order.asc("receiveTime")));
+        return findList(query);
+    }
+}

+ 28 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/entity/ProductMeasuringDict.java

@@ -0,0 +1,28 @@
+package com.zcxk.rmcp.core.entity;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.zcxk.core.mysql.base.BaseDO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@ApiModel(value="com-zcxk-common-entity-ProductMeasuringDict")
+@Data
+public class ProductMeasuringDict extends BaseDO {
+
+    @ApiModelProperty(value="测点id")
+    private Integer pointId;
+
+    @ApiModelProperty(value="数据值")
+    private String dataValue;
+
+    @ApiModelProperty(value="数据名称")
+    private String dataName;
+
+    @JsonIgnore
+    @ApiModelProperty(value="数据描述")
+    private String dataDesc;
+
+}

+ 30 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/entity/ProductMeasuringPoint.java

@@ -0,0 +1,30 @@
+package com.zcxk.rmcp.core.entity;
+
+import com.zcxk.core.mysql.base.BaseDO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel(value="com-zcxk-common-entity-ProductMeasuringPoint")
+@Data
+public class ProductMeasuringPoint extends BaseDO {
+
+    @ApiModelProperty(value="设备类型")
+    private Integer productId;
+
+    @ApiModelProperty(value="测点编码")
+    private String measuringCode;
+
+    @ApiModelProperty(value="测点名称")
+    private String measuringName;
+
+    @ApiModelProperty(value="测点描述")
+    private String measuringDesc;
+
+    @ApiModelProperty(value="测点单位")
+    private String measuringUnit;
+
+    @ApiModelProperty(value="测点数据类型 1:离散 2:连续")
+    private String measuringDataType;
+
+}

+ 119 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mapper/ProductMeasuringDictMapper.xml

@@ -0,0 +1,119 @@
+<?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.zcxk.rmcp.core.dao.ProductMeasuringDictMapper">
+
+  <resultMap id="BaseResultMap" type="com.zcxk.rmcp.core.entity.ProductMeasuringDict">
+    <!--@mbg.generated-->
+    <!--@Table sc_product_measuring_dict-->
+    <id column="point_id" property="pointId" />
+    <id column="data_value" property="dataValue" />
+    <result column="data_name" property="dataName" />
+    <result column="data_desc" property="dataDesc" />
+    <result column="status" property="status" />
+    <result column="create_by" property="createBy" />
+    <result column="update_by" property="updateBy" />
+    <result column="create_date" property="createDate" />
+    <result column="update_date" property="updateDate" />
+  </resultMap>
+
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    point_id, data_value, data_name, data_desc, `status`, create_by, update_by, date_create, 
+    date_update
+  </sql>
+  <insert id="insertSelective" parameterType="com.zcxk.rmcp.core.entity.ProductMeasuringDict">
+    <!--@mbg.generated-->
+    insert into rmcp_product_measuring_dict
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="pointId != null">
+        point_id,
+      </if>
+      <if test="dataValue != null">
+        data_value,
+      </if>
+      <if test="dataName != null">
+        data_name,
+      </if>
+      <if test="dataDesc != null">
+        data_desc,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+      <if test="dateCreate != null">
+        date_create,
+      </if>
+      <if test="dateUpdate != null">
+        date_update,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="pointId != null">
+        #{pointId},
+      </if>
+      <if test="dataValue != null">
+        #{dataValue},
+      </if>
+      <if test="dataName != null">
+        #{dataName},
+      </if>
+      <if test="dataDesc != null">
+        #{dataDesc},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="createBy != null">
+        #{createBy},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy},
+      </if>
+      <if test="dateCreate != null">
+        #{dateCreate},
+      </if>
+      <if test="dateUpdate != null">
+        #{dateUpdate},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.zcxk.rmcp.core.entity.ProductMeasuringDict">
+    update rmcp_product_measuring_dict
+    <set>
+      <if test="dataName != null">
+        data_name = #{dataName},
+      </if>
+      <if test="dataDesc != null">
+        data_desc = #{dataDesc},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy},
+      </if>
+      <if test="dateCreate != null">
+        date_create = #{dateCreate},
+      </if>
+      <if test="dateUpdate != null">
+        date_update = #{dateUpdate},
+      </if>
+    </set>
+    where point_id = #{pointId}
+      and data_value = #{dataValue}
+  </update>
+
+    <select id="getList" resultType="com.zcxk.rmcp.api.vo.ProductMeasuringDictVo">
+      select <include refid="Base_Column_List" /> from rmcp_product_measuring_dict where status = 1
+      and point_id = #{pointId}
+    </select>
+</mapper>

+ 144 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mapper/ProductMeasuringPointMapper.xml

@@ -0,0 +1,144 @@
+<?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.zcxk.rmcp.core.dao.ProductMeasuringPointMapper">
+  <resultMap id="BaseResultMap" type="com.zcxk.rmcp.core.entity.ProductMeasuringPoint">
+    <!--@mbg.generated-->
+    <!--@Table sc_product_measuring_point-->
+    <id column="id" property="id" />
+    <result column="product_id" property="productId" />
+    <result column="measuring_code" property="measuringCode" />
+    <result column="measuring_name" property="measuringName" />
+    <result column="measuring_desc" property="measuringDesc" />
+    <result column="measuring_unit" property="measuringUnit" />
+    <result column="measuring_data_type" property="measuringDataType" />
+    <result column="status" property="status" />
+    <result column="date_create" property="dateCreate" />
+    <result column="date_update" property="dateUpdate" />
+    <result column="create_date" property="createDate" />
+    <result column="update_date" property="updateDate" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, product_id, measuring_code, measuring_name, measuring_desc, measuring_unit, measuring_data_type, 
+    `status`, date_create, date_update, create_by, update_by
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.zcxk.rmcp.core.entity.ProductMeasuringPoint" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_product_measuring_point
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="productId != null">
+        product_id,
+      </if>
+      <if test="measuringCode != null">
+        measuring_code,
+      </if>
+      <if test="measuringName != null">
+        measuring_name,
+      </if>
+      <if test="measuringDesc != null">
+        measuring_desc,
+      </if>
+      <if test="measuringUnit != null">
+        measuring_unit,
+      </if>
+      <if test="measuringDataType != null">
+        measuring_data_type,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="dateCreate != null">
+        date_create,
+      </if>
+      <if test="dateUpdate != null">
+        date_update,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="productId != null">
+        #{productId},
+      </if>
+      <if test="measuringCode != null">
+        #{measuringCode},
+      </if>
+      <if test="measuringName != null">
+        #{measuringName},
+      </if>
+      <if test="measuringDesc != null">
+        #{measuringDesc},
+      </if>
+      <if test="measuringUnit != null">
+        #{measuringUnit},
+      </if>
+      <if test="measuringDataType != null">
+        #{measuringDataType},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="dateCreate != null">
+        #{dateCreate},
+      </if>
+      <if test="dateUpdate != null">
+        #{dateUpdate},
+      </if>
+      <if test="createBy != null">
+        #{createBy},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.zcxk.rmcp.core.entity.ProductMeasuringPoint">
+    <!--@mbg.generated-->
+    update sc_product_measuring_point
+    <set>
+      <if test="productId != null">
+        product_id = #{productId},
+      </if>
+      <if test="measuringCode != null">
+        measuring_code = #{measuringCode},
+      </if>
+      <if test="measuringName != null">
+        measuring_name = #{measuringName},
+      </if>
+      <if test="measuringDesc != null">
+        measuring_desc = #{measuringDesc},
+      </if>
+      <if test="measuringUnit != null">
+        measuring_unit = #{measuringUnit},
+      </if>
+      <if test="measuringDataType != null">
+        measuring_data_type = #{measuringDataType},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="dateCreate != null">
+        date_create = #{dateCreate},
+      </if>
+      <if test="dateUpdate != null">
+        date_update = #{dateUpdate},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy},
+      </if>
+    </set>
+    where id = #{id}
+  </update>
+
+    <select id="getList" resultType="com.zcxk.rmcp.api.vo.MeasuringPointVo">
+      select <include refid="Base_Column_List"/> from sc_product_measuring_point where status = 1
+      and product_id = #{productId}
+    </select>
+</mapper>

+ 73 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mongo/DeviceData.java

@@ -0,0 +1,73 @@
+package com.zcxk.rmcp.core.mongo;
+
+import com.zcxk.core.mongo.annotation.QueryField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 
+ * @Description  
+ * <p>设备数据表,按照设备ID进行分片</p>
+ * sh.enableSharding("smartcity") 
+ * sh.shardCollection("smartcity.sc_device_data",{"deviceId":"hashed"});
+ * @author wilian.peng
+ * @date 2019年11月12日 下午10:05:10
+ */
+@Data
+@ApiModel("设备数据表")
+@Document(collection = "rmcp_device_data")
+public class DeviceData implements Serializable{
+
+	private static final long serialVersionUID = 4357722209160768792L;
+
+	@ApiModelProperty(value = "主键", position = 1)
+	@Id
+	Long id ;
+
+	@QueryField
+	@ApiModelProperty(value = "设备Id", position = 2)
+	Long deviceId ;
+
+	@QueryField
+	@ApiModelProperty(value = "设备编号", position = 3)
+	String deviceNo ;
+
+	@ApiModelProperty(value = "站点", position = 4)
+	Integer siteId ;
+
+	@ApiModelProperty(value = "场景", position = 5)
+	Integer channelId ;
+
+	@ApiModelProperty(value = "建筑", position = 6)
+	Integer buildingId ;
+
+	@ApiModelProperty(value = "安装地址", position = 7)
+	String location ;
+
+	@ApiModelProperty(value = "接收数据日期,yyyyMMdd", position = 8)
+	Integer receiveDate ;
+
+	@ApiModelProperty(value = "接收数据时间", position = 9)
+	Date receiveTime ;
+
+	@ApiModelProperty(value = "测点数据", position = 10)
+	List<DeviceMeasuringData> datas ;
+
+	@ApiModelProperty(value = "状态", position = 11)
+	Integer status ;
+
+	@ApiModelProperty(value = "创建人", position = 12)
+	String createBy ;
+
+	@ApiModelProperty(value = "创建时间", position = 13)
+	Date dateCreate ;
+
+
+}

+ 31 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mongo/DeviceMeasuringData.java

@@ -0,0 +1,31 @@
+package com.zcxk.rmcp.core.mongo;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@ApiModel("设备")
+public class DeviceMeasuringData implements Serializable{
+
+	private static final long serialVersionUID = 3741755757477549082L;
+
+	@ApiModelProperty(value = "测点编码", position = 1)
+	String measuringCode ; 
+
+	@ApiModelProperty(value = "测点名称", position = 2)
+	String measuringName ; 
+	
+	@ApiModelProperty(value = "测点数据值", position = 3)
+	String measuringData ;
+	
+	@ApiModelProperty(value = "测点单位", position = 4)
+	String measuringUnit ;
+	
+	@ApiModelProperty(value = "测点数据描述", position = 5)
+	String measuringDataDesc ;
+	
+}

+ 12 - 8
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/controller/DeviceController.java

@@ -1,18 +1,13 @@
 package com.zcxk.rmcp.web.controller;
 
-import com.alibaba.fastjson.JSON;
 import com.zcxk.core.common.pojo.AjaxMessage;
 import com.zcxk.core.mysql.pageing.Pagination;
-import com.zcxk.core.oauth2.pojo.LoginUser;
-import com.zcxk.core.oauth2.util.UserUtil;
 import com.zcxk.rmcp.api.dto.BasePageDto;
+import com.zcxk.rmcp.api.dto.device.DeviceDataDto;
 import com.zcxk.rmcp.api.dto.device.DeviceInputDto;
 import com.zcxk.rmcp.api.dto.device.DeviceQueryDto;
-import com.zcxk.rmcp.api.query.CommonQueryCondition;
-import com.zcxk.rmcp.api.vo.DeviceDetailVo;
-import com.zcxk.rmcp.api.vo.DeviceMapDataVo;
-import com.zcxk.rmcp.api.vo.DeviceStatisticsVo;
-import com.zcxk.rmcp.api.vo.DeviceVo;
+import com.zcxk.rmcp.api.vo.*;
+import com.zcxk.rmcp.web.service.DeviceDataService;
 import com.zcxk.rmcp.web.service.DeviceService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -39,6 +34,9 @@ public class DeviceController {
     @Autowired
     DeviceService deviceService;
 
+    @Autowired
+    DeviceDataService dataServiceService;
+
 
     @ResponseBody
     @GetMapping("/getPage")
@@ -148,4 +146,10 @@ public class DeviceController {
         return AjaxMessage.success();
     }
 
+    @GetMapping("/getData")
+    @ApiOperation(value = "获取设备数据")
+    public AjaxMessage<List<DeviceDataVo>> getData(@RequestBody @Valid DeviceDataDto deviceDataDto) {
+        return AjaxMessage.success(dataServiceService.getData(deviceDataDto));
+    }
+
 }

+ 38 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/controller/MeasuringPointController.java

@@ -0,0 +1,38 @@
+package com.zcxk.rmcp.web.controller;
+
+import com.zcxk.core.common.pojo.AjaxMessage;
+import com.zcxk.rmcp.api.vo.MeasuringPointVo;
+import com.zcxk.rmcp.web.service.ProductMeasuringPointService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.List;
+
+/**
+ * @author Andy
+ * @version V1.0
+ * @description: 测点
+ * @date 2021/8/2
+ **/
+@Controller
+@ResponseBody
+@RequestMapping("/measuring/point")
+@Api(tags = "测点")
+public class MeasuringPointController {
+
+    @Autowired
+    private ProductMeasuringPointService productMeasuringPointService;
+
+    @GetMapping("/find")
+    @ApiOperation(value = "获取设备测点")
+    public AjaxMessage<List<MeasuringPointVo>> find(@ApiParam(value = "产品id", required = true) @RequestParam Integer productId) {
+        return AjaxMessage.success(productMeasuringPointService.getMeasuringPoint(productId));
+    }
+}

+ 5 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/controller/ProductCategoryController.java

@@ -12,6 +12,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
 
 import java.util.List;
 
+/**
+* @author Andy
+* @description 产品分类
+* @date 10:09 2021/8/2
+**/
 @Controller
 @ResponseBody
 @RequestMapping("/product/category")

+ 23 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/DeviceDataService.java

@@ -0,0 +1,23 @@
+package com.zcxk.rmcp.web.service;
+
+import com.zcxk.rmcp.api.dto.device.DeviceDataDto;
+import com.zcxk.rmcp.api.vo.DeviceDataVo;
+
+import java.util.List;
+
+/**
+ * 设备数据
+ * @author Andy
+ * @date 2021-07-19 9:44
+ */
+public interface DeviceDataService {
+
+    /**
+    * @author Andy
+    * @description 获取设备数据
+    * @date 11:47 2021/8/2
+    * @param deviceDataDto
+    * @return java.util.List<com.zcxk.rmcp.api.vo.DeviceDataVo>
+    **/
+    List<DeviceDataVo> getData(DeviceDataDto deviceDataDto);
+}

+ 3 - 4
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/DeviceService.java

@@ -3,13 +3,11 @@ package com.zcxk.rmcp.web.service;
 import com.zcxk.core.common.pojo.ResultMessage;
 import com.zcxk.core.mysql.pageing.Pagination;
 import com.zcxk.rmcp.api.dto.BasePageDto;
+import com.zcxk.rmcp.api.dto.device.DeviceDataDto;
 import com.zcxk.rmcp.api.dto.device.DeviceInputDto;
 import com.zcxk.rmcp.api.dto.device.DeviceQueryDto;
 import com.zcxk.rmcp.api.query.CommonQueryCondition;
-import com.zcxk.rmcp.api.vo.DeviceDetailVo;
-import com.zcxk.rmcp.api.vo.DeviceMapDataVo;
-import com.zcxk.rmcp.api.vo.DeviceStatisticsVo;
-import com.zcxk.rmcp.api.vo.DeviceVo;
+import com.zcxk.rmcp.api.vo.*;
 import com.zcxk.rmcp.core.entity.Device;
 import com.zcxk.rmcp.web.excel.model.DeviceImportData;
 import com.zcxk.rmcp.web.excel.model.ExcelData;
@@ -74,4 +72,5 @@ public interface DeviceService{
     void getDeviceListExcel(DeviceQueryDto dto, HttpServletResponse httpServletResponse);
 
     void batchValve(List<Long> ids, Integer valveStatus);
+
 }

+ 24 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/ProductMeasuringPointService.java

@@ -0,0 +1,24 @@
+package com.zcxk.rmcp.web.service;
+
+import com.zcxk.rmcp.api.vo.MeasuringPointVo;
+
+import java.util.List;
+
+/**
+ * @author Andy
+ * @version V1.0
+ * @description: 测点业务
+ * @date 2021/8/2
+ **/
+public interface ProductMeasuringPointService {
+
+
+    /**
+    * @author Andy
+    * @description 获取测试数据
+    * @date 14:10 2021/8/2
+    * @param productId
+    * @return java.util.List<com.zcxk.rmcp.api.vo.MeasuringPointVo>
+    **/
+    List<MeasuringPointVo> getMeasuringPoint(Integer productId);
+}

+ 55 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/impl/DeviceDataServiceImpl.java

@@ -0,0 +1,55 @@
+package com.zcxk.rmcp.web.service.impl;
+
+import com.zcxk.rmcp.api.dto.device.DeviceDataDto;
+import com.zcxk.rmcp.api.vo.DeviceDataVo;
+import com.zcxk.rmcp.core.dao.mongo.DeviceDataDao;
+import com.zcxk.rmcp.core.mongo.DeviceData;
+import com.zcxk.rmcp.core.mongo.DeviceMeasuringData;
+import com.zcxk.rmcp.web.service.DeviceDataService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 
+ * @author Andy
+ * @date 2021-07-19 9:44
+ */
+@Slf4j
+@Service
+public class DeviceDataServiceImpl implements DeviceDataService {
+
+    @Resource
+    private DeviceDataDao deviceDataDao;
+
+    @Override
+    public List<DeviceDataVo> getData(DeviceDataDto deviceDataDto) {
+        List<DeviceData> list = deviceDataDao.queryDeviceData(deviceDataDto.getDeviceId(),deviceDataDto.getStartDate(),
+                deviceDataDto.getEndDate());
+        if (CollectionUtils.isEmpty(list)) {
+            return null;
+        }
+        List<DeviceDataVo> deviceDataDTOList = new ArrayList();
+        for (DeviceData deviceData : list) {
+            if (deviceData.getDatas() == null) {
+                continue;
+            }
+            for (DeviceMeasuringData data : deviceData.getDatas()) {
+                if(!StringUtils.equals(deviceDataDto.getMeasuringCode(),data.getMeasuringCode())){
+                    continue;
+                }
+                DeviceDataVo deviceDataDTO = new DeviceDataVo();
+                deviceDataDTO.setValue(data.getMeasuringData());
+                deviceDataDTO.setDateTime(deviceData.getReceiveTime());
+                deviceDataDTOList.add(deviceDataDTO);
+                break;
+            }
+        }
+        return deviceDataDTOList;
+    }
+}

+ 29 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/impl/ProductMeasuringPointServiceImpl.java

@@ -0,0 +1,29 @@
+package com.zcxk.rmcp.web.service.impl;
+
+import com.zcxk.rmcp.api.vo.MeasuringPointVo;
+import com.zcxk.rmcp.core.dao.ProductMeasuringDictMapper;
+import com.zcxk.rmcp.core.dao.ProductMeasuringPointMapper;
+import com.zcxk.rmcp.web.service.ProductMeasuringPointService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class ProductMeasuringPointServiceImpl implements ProductMeasuringPointService {
+
+    @Resource
+    private ProductMeasuringPointMapper productMeasuringPointMapper;
+
+    @Resource
+    private ProductMeasuringDictMapper productMeasuringDictMapper;
+
+    @Override
+    public List<MeasuringPointVo> getMeasuringPoint(Integer productId) {
+        List<MeasuringPointVo> list = productMeasuringPointMapper.getList(productId);
+        list.forEach(measuringPointDto -> {
+            measuringPointDto.setDictList(productMeasuringDictMapper.getList(measuringPointDto.getId()));
+        });
+        return list;
+    }
+}