Przeglądaj źródła

Merge branch 'master' into feature-fiveep-2021-7-12

jichaobo 4 lat temu
rodzic
commit
ee2e082899

+ 13 - 1
fiveep-controller/src/main/java/com/bizmatics/controller/web/DeviceController.java

@@ -2,10 +2,15 @@ package com.bizmatics.controller.web;
 
 
 import com.bizmatics.common.core.bean.ApiResult;
+import com.bizmatics.common.core.util.DateUtils;
 import com.bizmatics.model.Device;
+import com.bizmatics.model.HtAnalogData;
 import com.bizmatics.persistence.mapper.DeviceMapper;
+import com.bizmatics.persistence.mapper.HtAnalogDataMapper;
 import com.bizmatics.service.DeviceService;
 import com.bizmatics.service.vo.DeviceCountVO;
+import lombok.Synchronized;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -23,6 +28,7 @@ import java.util.List;
  * @author ya
  * @since 2021-07-07
  */
+@Slf4j
 @RestController
 @RequestMapping("/device")
 public class DeviceController {
@@ -32,6 +38,9 @@ public class DeviceController {
     @Autowired
     private DeviceMapper deviceMapper;
 
+    @Autowired
+    private HtAnalogDataMapper htAnalogDataMapper;
+
 
     /**
      * 查询设备总数
@@ -60,7 +69,10 @@ public class DeviceController {
         List<Device> list = deviceMapper.list(1, null, null, null, null, null);
         List<String> list1 = new ArrayList<>();
         for (Device device:list) {
-            list1.add(device.getDeviceCode());
+            long l = System.currentTimeMillis();
+            List<HtAnalogData> list2 = htAnalogDataMapper.list(DateUtils.addYears(new Date(), -10), new Date(), device.getDeviceCode());
+            long e = System.currentTimeMillis();
+            log.info("一个站点的数据获取时间"+(e-l));
         }
         return list1;
     }

+ 6 - 0
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/HtAnalogDataMapper.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -35,4 +36,9 @@ public interface HtAnalogDataMapper extends CrudMapper<HtAnalogData> {
     Map<String,Double> selectMaxAndMinAndAvg(@Param("siteId") Integer siteId,
                                              @Param("startTime") Date startTime,
                                              @Param("endTime") Date endTime);
+
+
+    List<HtAnalogData> list(@Param("startTime") Date startTime,
+                            @Param("endTime") Date endTime,
+                            @Param("deviceCode") String deviceCode);
 }

+ 13 - 0
fiveep-persistence/src/main/resources/mapper/mysql/HtAnalogDataMapper.xml

@@ -60,5 +60,18 @@
             </if>
         </where>
     </select>
+    <select id="list" resultType="com.bizmatics.model.HtAnalogData">
+        select max(Epp),min(Epp)
+        from
+        ht_analog_data
+        <where>
+            <if test="deviceCode != null and deviceCode != ''">
+                and deviceName = #{deviceCode}
+            </if>
+            <if test="endTime != null and startTime != null">
+                and dataTime BETWEEN #{startTime} and #{endTime}
+            </if>
+        </where>
+    </select>
 
 </mapper>