From eba6f1988c6a7e37e619a27e493b17c244979070 Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Thu, 30 Sep 2021 16:11:29 +0800
Subject: [PATCH] screen-aqi            完成获取监测站数据接口

---
 screen-api/src/main/java/com/moral/api/service/impl/HistoryMonthlyServiceImpl.java |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/screen-api/src/main/java/com/moral/api/service/impl/HistoryMonthlyServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/HistoryMonthlyServiceImpl.java
index 586b30e..c6c3f77 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/HistoryMonthlyServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/HistoryMonthlyServiceImpl.java
@@ -1,10 +1,18 @@
 package com.moral.api.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.moral.api.entity.HistoryMonthly;
 import com.moral.api.mapper.HistoryMonthlyMapper;
 import com.moral.api.service.HistoryMonthlyService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -17,4 +25,30 @@
 @Service
 public class HistoryMonthlyServiceImpl extends ServiceImpl<HistoryMonthlyMapper, HistoryMonthly> implements HistoryMonthlyService {
 
+    @Autowired
+    HistoryMonthlyMapper historyMonthlyMapper;
+
+    @Override
+    public HistoryMonthly getHistoryMonthlyByMacAndDate(String mac, Date date) {
+        QueryWrapper<HistoryMonthly> wrapper = new QueryWrapper<>();
+        wrapper.eq("mac",mac);
+        wrapper.eq("time",date);
+        List<HistoryMonthly> historyMonthlies = historyMonthlyMapper.selectList(wrapper);
+        if(ObjectUtils.isEmpty(historyMonthlies))
+            return null;
+        return historyMonthlies.get(0);
+    }
+
+    @Override
+    public Map<String, HistoryMonthly> getHistoryMonthlyByMacsAndDate(List<String> mac, Date date) {
+        QueryWrapper<HistoryMonthly> wrapper = new QueryWrapper<>();
+        wrapper.in("mac",mac);
+        wrapper.eq("time",date);
+        List<HistoryMonthly> historyMonthlies = historyMonthlyMapper.selectList(wrapper);
+        Map<String,HistoryMonthly> map = new HashMap<>();
+        for (HistoryMonthly historyMonthly : historyMonthlies) {
+            map.put(historyMonthly.getMac(),historyMonthly);
+        }
+        return map;
+    }
 }

--
Gitblit v1.8.0