kaiyu
2020-11-18 8dc1a393928b0195bf0b5a6d6f8daec6e4a043b1
Merge remote-tracking branch 'origin/master'

# Conflicts:
# src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java
13 files modified
188 ■■■■ changed files
src/main/java/com/moral/controller/DeviceController.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java 8 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/SensorController.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/HistoryMapper.java 13 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/SensorMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/SensorService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java patch | view | raw | blame | history
src/main/java/com/moral/service/impl/HistoryServiceImpl.java 92 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/SensorServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/HistoryHourlyMapper.xml 7 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/HistoryMapper.xml 29 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/SensorMapper.xml 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/DeviceController.java
@@ -9,6 +9,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.moral.mapper.DeviceMapper;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -30,6 +31,8 @@
public class DeviceController {
    @Resource
    DeviceService deviceService;
    @Resource
    DeviceMapper deviceMapper;
    @GetMapping("count-by-example")
    public ResultBean<Integer> countByExample(PageBean pageBean){
        return  new ResultBean<Integer>(deviceService.countByExample(pageBean));
@@ -69,6 +72,12 @@
        return new ResultBean<List<Device>>(devices);
    }
    
    @GetMapping("getDeviceByMonitorId")
    public ResultBean<List<Map<String, Object>>> getDeviceByMonitorId() {
        List<Map<String, Object>> devices = deviceMapper.getDevicesByMpId(563);
        return new ResultBean<List<Map<String, Object>>>(devices);
    }
    @PostMapping("save-or-update")
    public ResultBean saveOrUpdate(@RequestBody String jsonString){
        Device device = JSONObject.parseObject(jsonString, Device.class);
src/main/java/com/moral/controller/ScreenController.java
@@ -2072,7 +2072,7 @@
        } else {
            mon = "" + month;
        }
        String table = "history_minutely_" + year + mon;
        String table = "history_five_minutely_" + year + mon;
        List list = deviceService.byMonitorIdGetDeviceAndWind(monitorPointId, table);
        return list;
    }
@@ -2093,7 +2093,7 @@
        } else {
            mon = "" + month;
        }
        String table = "history_minutely_" + year + mon;
        String table = "history_five_minutely_" + year + mon;
        List list = deviceService.byMonitorIdGetDeviceAndWindSpecial(monitorPointId, table);
        return list;
    }
@@ -2693,7 +2693,7 @@
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "monitorPointIds", value = "多个monitorid", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19)", required = true, paramType = "query", dataType = "String")})
    public  List<List<Map>> monitorAVGData(HttpServletRequest request) throws Exception {
    public ResultBean<List<List<Map>>> monitorAVGData(HttpServletRequest request) throws Exception {
        Map<String, Object> parameters = getParametersStartingWith(request, null);
        String monitorPointIds = (String) parameters.get("monitorPointIds");
        String time = (String) parameters.get("time");
@@ -2718,6 +2718,6 @@
                lists.add(dataAvbByMIdAndTime);
            }
        }
        return lists;
        return new ResultBean<List<List<Map>>>(lists);
    }
}
src/main/java/com/moral/controller/SensorController.java
@@ -56,6 +56,12 @@
        return new ResultBean<List<Sensor>>(sensors);
    }
    @GetMapping("allById")
    public ResultBean<List<Map<String, Object>>> getAllSensorsById() {
        List<Map<String, Object>> sensors = sensorService.getSensorByDId("1230");
        return new ResultBean<List<Map<String, Object>>>(sensors);
    }
    @GetMapping("getSenosrsByOrgId")
    public ResultBean<List<Sensor>> getSenosrsByOrgId(Integer organizationId, String regionCode) {
        Map<String, Object> parameters = new HashMap<>();
src/main/java/com/moral/mapper/HistoryMapper.java
@@ -7,8 +7,10 @@
import org.apache.ibatis.annotations.Param;
public interface HistoryMapper{
    String selectValueByMacAndTime(@Param("mac")String mac, @Param("time")Date time);
    String getValueByMacAndTime(@Param("mac")String mac, @Param("time")String time,@Param("time1")String time1);
    String selectValueByMacAndTime(@Param("mac") String mac, @Param("time") Date time, @Param("timeUnits") String timeUnits);
    String getValueByMacAndTime(@Param("mac") String mac, @Param("time") String time, @Param("time1") String time1, @Param("timeUnits") String timeUnits);
    List<Map<String, Object>> getAreaAllDataByAccount(Map<String, Object> parameters);
    List<Map<String, Object>> getRegionRankingData(Map<String, Object> parameters);
@@ -21,13 +23,13 @@
    Map<String, Object> getActualDataByRegion(Map<String, Object> parameters);
    
    Map<String, Object> getAVGValueByMacAndTimeslot(@Param("mac")String mac, @Param("starttime")String starttime, @Param("endtime")String endtime);
    Map<String, Object> getAVGValueByMacAndTimeslot(@Param("mac") String mac, @Param("starttime") String starttime, @Param("endtime") String endtime, @Param("timeUnits") String timeUnits);
    List<Map<String, Object>> getSensorDataToday(Map<String, Object> parameters);
    
    List<Map<String, Object>> getAVGSensorRankByMonitorPointIdList(@Param("sensor")String sensor, @Param("monitorPointIdList") List<Object> monitorPointIdList, @Param("before5Time")String before5Time, @Param("endTime")String endTime);
    List<Map<String, Object>> getAVGSensorRankByMonitorPointIdList(@Param("sensor") String sensor, @Param("monitorPointIdList") List<Object> monitorPointIdList, @Param("before5Time") String before5Time, @Param("endTime") String endTime,@Param("timeUnits") String timeUnits);
    
    Map<String, Object> getMonitorPointAVGValueByMonitorPointIdAndTimeslot(@Param("monitor_point_id")String monitor_point_id, @Param("starttime")String starttime, @Param("endtime")String endtime);
    Map<String, Object> getMonitorPointAVGValueByMonitorPointIdAndTimeslot(@Param("monitor_point_id") String monitor_point_id, @Param("starttime") String starttime, @Param("endtime") String endtime, @Param("timeUnits") String timeUnits);
    List<Map<String, Object>> getCarSensorData(Map<String, Object> parameters);
@@ -40,6 +42,7 @@
    int getNum(@Param("timef") String timef,
               @Param("timea") String timea);
    String getJsonData(@Param("mac") String mac,
                       @Param("time") String time,
                       @Param("table") String table);
src/main/java/com/moral/mapper/SensorMapper.java
@@ -34,4 +34,6 @@
    List<Sensor> selectSenosrsByOrgId(Map<String, Object> parameters);
    List<String> getSensorKeys();
    List<Map<String, Object>> getSensorByDId(String id);
}
src/main/java/com/moral/service/SensorService.java
@@ -29,6 +29,8 @@
    List<Map<String, Object>> getSensorByDeviceId(String id);
    List<Map<String, Object>> getSensorByDId(String id);
    List<Map<String, Object>> getSensorByMonitorPointId(String monitor_point_id);
    Map<String, String> getSensorsMap(Map<String, Object> parameters) throws Exception;
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -751,6 +751,8 @@
    @Override
    public List byMonitorIdGetDeviceAndWind(String id, String tab) {
        List<DeviceAndWind> deviceAndWinds = deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id), tab);
        System.out.println(deviceAndWinds);
        System.out.println(deviceAndWinds);
        List loList = new ArrayList();
        List laList = new ArrayList();
        Double U = 0.0;
@@ -827,7 +829,7 @@
            if (tvoc == null) {
                tvoc = 0.0;
            }
            Double dir = (270.0 - windDir * Math.PI / 180.0);
            Double dir = (270.0 - (windDir+180.0) * Math.PI / 180.0);
            U = windSpeed * Math.cos(dir);
            V = windSpeed * Math.sin(dir);
@@ -1029,7 +1031,7 @@
            if (tvoc == null) {
                tvoc = 0.0;
            }
            Double dir = (270.0 - windDir * Math.PI / 180.0);
            Double dir = (270.0 + (windDir+180.0) * Math.PI / 180.0);
            U = windSpeed * Math.cos(dir);
            V = windSpeed * Math.sin(dir);
src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java
src/main/java/com/moral/service/impl/HistoryServiceImpl.java
@@ -75,15 +75,19 @@
        accountService.setOrgIdsByAccount(parameters);
        LocalDateTime time = LocalDateTime.now();
        // 当前时间 -10分钟
        parameters.put("start", time.minusMinutes(10));
        LocalDateTime start = time.minusMinutes(10);
        parameters.put("start", start);
        // 当前时间 -5分钟
        parameters.put("end", time.minusMinutes(5));
        LocalDateTime end = time.minusMinutes(5);
        parameters.put("end", end);
        List<Sensor> Sensors = sensorMapper.getSensorsByCriteria(parameters);
        List<String> sensorKeys = new ArrayList<String>();
        for (Sensor sensor : Sensors) {
            sensorKeys.add(sensor.getSensorKey());
        }
        parameters.put("sensorKeys", sensorKeys);
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
        parameters.put("timeUnits", "minutely_" + df.format(start));
        List<Map<String, Object>> list = historyMapper.getAreaAllDataByAccount(parameters);
        resultMap.putAll(list.get(0));
        return resultMap;
@@ -105,6 +109,7 @@
        List<String> sensorKeys = new ArrayList<String>();
        sensorKeys.add(macKey.toString());
        parameters.put("sensorKeys", sensorKeys);
        parameters.put("timeUnits", "hourly");
        List<Map<String, Object>> list = historyMapper.getAreaAllDataByAccount(parameters);
        for (Map<String, Object> map : list) {
@@ -115,11 +120,16 @@
    @Override
    public String queryValueByMacAndTime(String mac, Date time) {
        return historyMapper.selectValueByMacAndTime(mac, time);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String timeUnits = sdf.format(time);
        return historyMapper.selectValueByMacAndTime(mac, time, timeUnits);
    }
    public String getValueByMacAndTime(String mac, String time,String time1) {
        return historyMapper.getValueByMacAndTime(mac, time,time1);
        String timeUnits = time1.substring(0, 10).replace("-", "");
        return historyMapper.getValueByMacAndTime(mac, time, time1, timeUnits);
    }
    @Override
    public List<Map<String, Object>> getRegionRankingData(Map<String, Object> parameters) {
        ValidateUtil.notNull(parameters.get("regionCode"), "param.is.null");
@@ -152,10 +162,12 @@
        parameters.put("nextLevel", nextLevel);
        LocalDate localDate = LocalDate.now();
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
        Object timeType = parameters.get("timeType");
        String table = "history";
        String column = "value";
        if ("month".equals(timeType)) {
        String column = "json";
        /*if ("month".equals(timeType)) {
            if (1 != localDate.getDayOfMonth()) {
                table = "history_daily";
                column = "json";
@@ -167,7 +179,19 @@
            parameters.put("start", LocalDateTime.now().truncatedTo(ChronoUnit.HOURS));
        } else {
            parameters.put("start", LocalDateTime.now().minusMinutes(5));
        }*/
        if ("month".equals(timeType)) {
            table = "history_daily";
            parameters.put("start", localDate.with(TemporalAdjusters.firstDayOfMonth()));
        } else if ("day".equals(timeType)) {
            table = "history_hourly";
            parameters.put("start", localDate);
        } else if ("hour".equals(timeType)) {
            table = "history_minutely_" + df.format(localDate);
            parameters.put("start", LocalDateTime.now().truncatedTo(ChronoUnit.HOURS));
        }
        parameters.put("table", table);
        parameters.put("column", column);
@@ -178,7 +202,6 @@
        }
        accountService.setOrgIdsByAccount(parameters);
        List<Map<String, Object>> result = historyMapper.getRegionRankingData(parameters);
        for (Map<String, Object> map : result) {
            if (ObjectUtils.isEmpty(map.get("avg"))) {
@@ -252,6 +275,10 @@
        ValidateUtil.notNull(parameters.get("deviceId"), "param.is.null");
        List<Map<String, Object>> sensors = sensorMapper.getSensorsByDeviceVersionId(parameters);
        parameters.put("size", 1);
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String timeUnits = sdf.format(date);
        parameters.put("timeUnits", timeUnits);
        List<Map<String, Object>> values = historyMapper.getValueByMacAndSize(parameters);
        JSONObject map = null;
        if (!ObjectUtils.isEmpty(values)) {
@@ -291,6 +318,10 @@
        ValidateUtil.notNull(parameters.get("mac"), "param.is.null");
        ValidateUtil.notNull(parameters.get("size"), "param.is.null");
        parameters.put("size", Integer.valueOf(parameters.remove("size").toString()));
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String timeUnits = sdf.format(date);
        parameters.put("timeUnits", timeUnits);
        List<Map<String, Object>> values = historyMapper.getValueByMacAndSize(parameters);
        Map<String, Object> sensorUnits = getSensorUnitByDeviceMac(parameters);
        for (Map<String, Object> value : values) {
@@ -333,6 +364,9 @@
        parameters.put("end", end);
        parameters.put("sensorKeys", Arrays.asList(((String) sensorKey).split(",")));
        accountService.setOrgIdsByAccount(parameters);
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
        //从history年月日表获取
        parameters.put("timeUnits", df.format(start));
        Map<String, Object> result = historyMapper.getActualDataByRegion(parameters);
        if (ObjectUtils.isEmpty(result)) {
            result = new HashMap<String, Object>();
@@ -372,7 +406,9 @@
            int startHour = endHour - 1;
            startTime = localDate + " " + startHour + ":00:00";
        }
        Map<String, Object> map = historyMapper.getAVGValueByMacAndTimeslot(mac, startTime, endTime);
        //从不同history日表获取数据
        String timeUnits = startTime.substring(0, 10).replace("-", "");
        Map<String, Object> map = historyMapper.getAVGValueByMacAndTimeslot(mac, startTime, endTime, timeUnits);
        Map<String, Object> returnMap = new HashMap<>();
        if (map.isEmpty()) {
            returnMap.put("AQI", "N/V");
@@ -436,10 +472,31 @@
        Date end = rightNow.getTime();
        String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(end);
        String before5Time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(beforeD);  // 前五分钟时间
        String sensor = parameters.get("sensor").toString();
        List<Map<String, Object>> result = historyMapper.getAVGSensorRankByMonitorPointIdList(sensor, monitorPointIdList, before5Time, endTime);
        return result;
        String timeUnits1 = before5Time.substring(0, 10).replace("-", "");
        List<Map<String, Object>> result1 = historyMapper.getAVGSensorRankByMonitorPointIdList(sensor, monitorPointIdList, before5Time, endTime, timeUnits1);
        String timeUnits2 = before5Time.substring(0, 10).replace("-", "");
        List<Map<String, Object>> result2 = historyMapper.getAVGSensorRankByMonitorPointIdList(sensor, monitorPointIdList, before5Time, endTime, timeUnits2);
        if (result1.isEmpty()) {
            return result2;
        } else if (result2.isEmpty()) {
            return result1;
        } else {
            for (Map<String, Object> map1 : result1) {
                Object name1 = map1.get("name");
                double value1 = Double.parseDouble(map1.get("sensor").toString());
                double avg = 0.0;
                for (Map<String, Object> map2 : result2) {
                    Object name2 = map2.get("name");
                    double value2 = Double.parseDouble(map2.get("sensor").toString());
                    if (name1.equals(name2)) {
                        avg = (value1 + value2) / 2;
                        map1.put("sensor", avg);
                    }
                }
            }
        }
        return result1;
    }
    @Override
@@ -459,7 +516,10 @@
            int startHour = endHour - 1;
            startTime = localDate + " " + startHour + ":00:00";
        }
        Map<String, Object> map = historyMapper.getMonitorPointAVGValueByMonitorPointIdAndTimeslot(monitor_point_id, startTime, endTime);
        //从不同history日表获取数据
        String timeUnits = startTime.substring(0, 10).replace("-", "");
        Map<String, Object> map = historyMapper.getMonitorPointAVGValueByMonitorPointIdAndTimeslot(monitor_point_id, startTime, endTime, timeUnits);
        Map<String, Object> returnMap = new HashMap<>();
        if (map.isEmpty()) {
            returnMap.put("AQI", "N/V");
@@ -494,10 +554,10 @@
        }
        parameters.put("sensorKeys", sensorKeys);
        List<Map<String, Object>> listMap = null;
        if (today.compareTo(startTimeDay) == 0) {
        /*if (today.compareTo(startTimeDay) == 0) {
            listMap = historyMapper.listGetSensorData(parameters);
        }
        if (CollectionUtils.isEmpty(listMap)) {
        }*/
        //if (CollectionUtils.isEmpty(listMap)) {
            listMap = historyMapper.getCarSensorData(parameters);
            if (CollectionUtils.isEmpty(listMap)) {
                if (year <= 2019) {
@@ -507,7 +567,7 @@
                    listMap = historyMinutelyMapper.getSensorData2020(parameters);
                }
            }
        }
        //}
        List<List<Map<String, Object>>> listMaps = new ArrayList<>();
        List<Map<String, Object>> listMapAvg = new ArrayList<>();
        List<Map<String, Object>> listMapMin = new ArrayList<>();
src/main/java/com/moral/service/impl/SensorServiceImpl.java
@@ -118,6 +118,11 @@
    }
    @Override
    public List<Map<String, Object>> getSensorByDId(String id) {
        List<Map<String, Object>> list = sensorMapper.getSensorByDId(id);
        return list;
    }
    @Override
    public List<Map<String, Object>> getSensorByMonitorPointId(String monitor_point_id) {
        List<Map<String, Object>> list = sensorMapper.getSensorByMonitorPointId(monitor_point_id);
        return list;
src/main/resources/mapper/HistoryHourlyMapper.xml
@@ -100,7 +100,12 @@
    </select>
    <select id="getDataByMacAndTime" resultType="java.util.Map">
        SELECT DATE_FORMAT(`time`,'%Y-%m-%d %H:%i:%s') as `time`,json->'$.${sensor}[0]' as ${sensor} FROM `history_hourly` where `mac`=#{mac} and `time`&gt;=#{startTime} and `time`&lt;#{endTime}
        SELECT DATE_FORMAT(`time`,'%Y-%m-%d %H:%i:%s') as `time`,
        json->'$.${sensor}[0]' as ${sensor}
        FROM `history_hourly`
        where `mac`=#{mac}
        and `time`&gt;=#{startTime}
        and `time`&lt;#{endTime}
    </select>
    <select id="getDataByMacAndTime1" resultType="java.util.Map">
        SELECT DATE_FORMAT(`time`,'%Y-%m-%d %H:%i:%s') as `time`,json->'$.${sensor}[0]' as ${sensor} FROM `history_hourly` where `mac`=#{mac} and `time`&gt;=#{startTime} and `time`<![CDATA[<]]>#{endTime}
src/main/resources/mapper/HistoryMapper.xml
@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.mapper.HistoryMapper">
    <select id="selectValueByMacAndTime" resultType="java.lang.String">
        select `value` from history
        select `value` from history_${timeUnits}
        where  time = #{time} and mac = #{mac}
        limit 0,1
    </select>
@@ -13,10 +13,10 @@
            d.`name`,
        </if>
        <foreach collection="sensorKeys" separator="," item="sensorKey">
            AVG(h.`value` ->'$.${sensorKey}[0]') AS '${sensorKey}'
            AVG(h.`value` ->'$.${sensorKey}') AS '${sensorKey}'
        </foreach>
        FROM
        history h,
        history_${timeUnits} h,
        device d,
        monitor_point mp
        WHERE
@@ -132,7 +132,7 @@
            value,
            time
        FROM
            history
            history_${timeUnits}
        WHERE
            mac = #{mac} 
        ORDER BY
@@ -143,10 +143,10 @@
    <select id="getActualDataByRegion" resultType="java.util.Map">
        SELECT
        <foreach collection="sensorKeys" separator="," item="sensorKey">
            MAX( `value` ->> '$.${sensorKey}' ) * 1 AS '${sensorKey}'
            MAX( `value` -> '$.${sensorKey}' ) * 1 AS '${sensorKey}'
        </foreach>
        FROM
        history h ,
        history_${timeUnits} h ,
        device d,
        monitor_point mp
        <where>
@@ -165,9 +165,10 @@
    <select id="getAVGValueByMacAndTimeslot" resultType="java.util.Map">
        SELECT AVG(JSON_EXTRACT(value,'$.e1[0]')) e1,AVG(JSON_EXTRACT(value,'$.e2[0]')) e2,AVG(JSON_EXTRACT(value,'$.e10[0]')) e10,AVG(JSON_EXTRACT(value,'$.e11[0]')) e11,AVG(JSON_EXTRACT(value,'$.e16[0]')) e16,AVG(JSON_EXTRACT(value,'$.e15[0]')) e15
        FROM history
        FROM history_${timeUnits}
        WHERE mac = #{mac}
        AND time BETWEEN #{starttime} AND #{endtime}
        AND time >= #{starttime}
        AND time <![CDATA[<]]> #{endtime}
    </select>
    <!-- 无人机sensor当天查询 -->
@@ -196,7 +197,7 @@
    <select id="getAVGSensorRankByMonitorPointIdList" resultType="java.util.Map">
        SELECT mp.name, AVG(JSON_EXTRACT(h.value,'$.${sensor}[0]')) sensor
        FROM device d, history h, monitor_point mp
        FROM device d, history_${timeUnits} h, monitor_point mp
        WHERE d.mac=h.mac
        And mp.id=d.monitor_point_id
        AND d.monitor_point_id IN
@@ -210,10 +211,11 @@
    <select id="getMonitorPointAVGValueByMonitorPointIdAndTimeslot" resultType="java.util.Map">
        SELECT AVG(JSON_EXTRACT(value,'$.e1[0]')) e1,AVG(JSON_EXTRACT(value,'$.e2[0]')) e2,AVG(JSON_EXTRACT(value,'$.e10[0]')) e10,AVG(JSON_EXTRACT(value,'$.e11[0]')) e11,AVG(JSON_EXTRACT(value,'$.e16[0]')) e16,AVG(JSON_EXTRACT(value,'$.e15[0]')) e15
        FROM device d,history h
        FROM device d,history_${timeUnits} h
        WHERE d.monitor_point_id = #{monitor_point_id}
        AND d.mac = h.mac
        AND h.time BETWEEN #{starttime} AND #{endtime}
        AND h.time >= #{starttime}
        AND h.time <![CDATA[<]]> #{endtime}
    </select>
    <!-- 走航车sensor查询 -->
@@ -292,14 +294,15 @@
        select `json` from ${table}
        where  time = #{time} and mac = #{mac}
    </select>
    <select id="getValueByMacAndTime" resultType="java.lang.String">
        select `value` from history
        select `value` from history_${timeUnits}
        where  mac = #{mac} and time &gt;= #{time1} and time &lt;=#{time}
        limit 0,1
    </select>
    <select id="getDailyAvgData" resultType="java.util.Map">
        SELECT  AVG(hd.json->"$.e1[0]") as `PM2_5`,AVG(hd.json->"$.e2[0]") as 'PM10',AVG(hd.json->"$.e10[0]") as 'CO',
            AVG(hd.json->"$.e11[0]") as 'SO2',AVG(hd.json->"$.e16[0]") as 'NO2',AVG(hd.json->"$.e15[0]") as 'O3-day'
            AVG(hd.json->"$.e11[0]") as 'SO2',AVG(hd.json->"$.e16[0]") as 'NO2',AVG(hd.json->"$.e15[0]") as 'O3_day'
FROM `history_daily` hd,monitor_point mt,device d where mt.id=d.monitor_point_id
and d.mac=hd.mac and mt.id=#{mId} and time=#{time}
    </select>
src/main/resources/mapper/SensorMapper.xml
@@ -137,6 +137,15 @@
        AND d.id = #{id}
    </select>
    <select id="getSensorByDId" resultType="java.util.Map">
        SELECT DISTINCT d.monitor_point_id,s.*
        FROM device d,device_version dv,device_version_sensor dvs,sensor s
        WHERE d.device_version_id = dvs.device_version_id
        AND dvs.sensor_id = s.id
        AND d.id = #{id}
    </select>
    <select id="getSensorByMonitorPointId" resultType="java.util.Map">
        SELECT DISTINCT s.sensor_key sensorKey,s.unit,s.name,s.description,s.id
        FROM device d,device_version dv,device_version_sensor dvs,sensor s