Prechádzať zdrojové kódy

设备电量统计排序

missMyLove 3 rokov pred
rodič
commit
b8ea591b5a

+ 20 - 0
src/main/java/com/comtika/safe/entity/mobile/help/EleHelp.java

@@ -0,0 +1,20 @@
+package com.comtika.safe.entity.mobile.help;
+
+import lombok.Data;
+
+/**
+ * @Author: miss[494977551@qq.com]
+ * @Date: Create in 18:24 2021/1/13
+ * @DESC:
+ **/
+@Data
+public class EleHelp {
+    private String key;
+    private Integer value;
+
+    public EleHelp(){}
+    public EleHelp(String key,Integer value){
+        this.key = key;
+        this.value = value;
+    }
+}

+ 10 - 1
src/main/java/com/comtika/safe/service/mobile/impl/MobileServiceImpl.java

@@ -8,6 +8,7 @@ import com.comtika.safe.dao.message.FadMessageConfDao;
 import com.comtika.safe.entity.mobile.CommonHelp;
 import com.comtika.safe.entity.mobile.EleTotalHelp;
 import com.comtika.safe.entity.mobile.EleTotalQueryHelp;
+import com.comtika.safe.entity.mobile.help.EleHelp;
 import com.comtika.safe.entity.safe.TerminalNewestData;
 import com.comtika.safe.service.mobile.IMobileService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -165,10 +166,12 @@ public class MobileServiceImpl implements IMobileService {
         // 这里查询数据
         List<EleTotalHelp> sumTotalList = fadMessageConfDao.findTerminalEleTotalList(help.getTerminalId(),help.getStartTime(),help.getEndTime()+DateTimeUtils.ONE_DAY);
         Map<String,Integer> res = new HashMap<>();
+        Set<String> keys = new HashSet<>();
         sumTotalList.forEach(s->{
             // 处理时间
             if(s.getCreateTime() == null) return;
             String key = DateTimeUtils.formatDate(new Date(s.getCreateTime()), DateTimeUtils.FORMAT_YMD);
+            keys.add(key);
             int inc = calEle(s.getEndEle(), s.getStartEle());
             if(res.containsKey(key)){
                 res.put(key,res.get(key)+inc);
@@ -176,9 +179,15 @@ public class MobileServiceImpl implements IMobileService {
                 res.put(key,inc);
             }
         });
-        return RespWrapper.makeSuccessResp(res);
+        List<EleHelp> list = new ArrayList<>();
+        for(String key:keys){
+            Integer integer = res.get(key);
+            list.add(new EleHelp(key,integer));
+        }
+        return RespWrapper.makeSuccessResp(list);
     }
 
+
     private int calEle(Integer end,Integer start){
         if(end == null) end = 0;
         if(start == null) start = 0;