Parcourir la source

设备监测数据报表

jichaobo il y a 4 ans
Parent
commit
ad2c722edc

+ 9 - 0
fiveep-controller/src/main/java/com/bizmatics/controller/web/RtAnalogDataController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -57,6 +58,14 @@ public class RtAnalogDataController {
         return ApiResult.success(rtAnalogDataService.getEpLoad(siteId));
     }
 
+    @RequestMapping("DataReport")
+    public ApiResult<List<Map<String,Object>>> getDataReport(@RequestParam Integer siteId,
+                                                             @RequestParam(required = false) Date startTime,
+                                                             @RequestParam(required = false) Date endTime,
+                                                             @RequestParam(required = true) String queryType){
+        return ApiResult.success(rtAnalogDataService.getDataReport(siteId,startTime,endTime,queryType));
+    }
+
 
 }
 

+ 2 - 1
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/RtAnalogDataMapper.java

@@ -5,6 +5,7 @@ import com.bizmatics.common.mvc.base.CrudMapper;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.Date;
 import java.util.Map;
 
 /**
@@ -31,6 +32,6 @@ public interface RtAnalogDataMapper extends CrudMapper<RtAnalogData> {
 
     Map<String,Object> getOneMap(@Param("siteId")Integer siteId);
 
-    Map<String,Object> getDataReportMap(@Param("siteId")Integer siteId,@Param("startTime")Integer startTime,@Param("endTime")Integer endTime);
+    Map<String,Object> getDataReportMap(@Param("siteId")Integer siteId, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
 
 }

+ 6 - 2
fiveep-persistence/src/main/resources/mapper/mysql/RtAnalogDataMapper.xml

@@ -106,11 +106,15 @@
         inner join rt_analog_data as rad
         on d.device_code = rad.deviceName
         <where>
+               and d.enable=1
             <if test="siteId != null and siteId != 0">
                 and us.site_id = #{siteId}
             </if>
-            <if test="dataTime != null and dataTime != 0">
-                and us.dataTime > #{startTime}
+            <if test="startTime != null">
+                and rad.dataTime &gt;= #{startTime}
+            </if>
+            <if test="endTime != null">
+                and rad.dataTime &lt; #{endTime}
             </if>
         </where>
     </select>

+ 4 - 0
fiveep-service/src/main/java/com/bizmatics/service/RtAnalogDataService.java

@@ -4,6 +4,7 @@ import com.bizmatics.model.RtAnalogData;
 import com.bizmatics.common.mvc.base.CrudService;
 import com.bizmatics.service.vo.RadCountVO;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -37,4 +38,7 @@ public interface RtAnalogDataService extends CrudService<RtAnalogData> {
      * @return
      */
     Double getEpLoad(Integer siteId);
+
+
+    List<Map<String,Object>> getDataReport(Integer siteId,Date startTime, Date endTime,String queryType);
 }

+ 39 - 0
fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java

@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -115,4 +116,42 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
         }
         return value;
     }
+
+    @Override
+    public List<Map<String, Object>> getDataReport(Integer siteId,Date startTime, Date endTime,String queryType) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        List<Map<String, Object>> list = new ArrayList<>();
+        Map<String, Object> radMap = baseMapper.getDataReportMap(siteId,startTime,endTime);
+        Object value = radMap.get("LoadLive");
+
+//        String[] result = queryType.split(",");
+//        for (int i = 0; i < result.length; i++) {
+//            System.out.println(result[i]);
+//        }
+
+        for (String name : radMap.keySet()) {
+            Map<String,Object> map = new HashMap<>();
+            if (queryType.startsWith("bgbhg_183__Ia")){
+                map.put("name",name);
+            }
+
+
+            map.put("value",addUnit(name,radMap.get(name).toString()));
+            list.add(map);
+
+        }
+
+//        Map<String,Object> map = new HashMap<>();
+//        map.put("LoadLive",value);
+//        list.add(map);
+
+
+//        Map<String, Object> LoopStatusList = baseMapper.getLoopStatusListMap(siteId);
+////        Iterator<String> it = radMap.keySet().iterator();
+
+//        int duration=0;
+
+
+        return list;
+    }
 }