Merge remote-tracking branch 'origin/master'
# Conflicts:
# src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java
| | |
| | | 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; |
| | |
| | | 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)); |
| | |
| | | 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); |
| | |
| | | } else { |
| | | mon = "" + month; |
| | | } |
| | | String table = "history_minutely_" + year + mon; |
| | | String table = "history_five_minutely_" + year + mon; |
| | | List list = deviceService.byMonitorIdGetDeviceAndWind(monitorPointId, table); |
| | | return list; |
| | | } |
| | |
| | | } else { |
| | | mon = "" + month; |
| | | } |
| | | String table = "history_minutely_" + year + mon; |
| | | String table = "history_five_minutely_" + year + mon; |
| | | List list = deviceService.byMonitorIdGetDeviceAndWindSpecial(monitorPointId, table); |
| | | return list; |
| | | } |
| | |
| | | @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"); |
| | |
| | | lists.add(dataAvbByMIdAndTime); |
| | | } |
| | | } |
| | | return lists; |
| | | return new ResultBean<List<List<Map>>>(lists); |
| | | } |
| | | } |
| | |
| | | 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<>(); |
| | |
| | | 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);
|
| | |
| | |
|
| | | 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);
|
| | |
|
| | |
| | |
|
| | | int getNum(@Param("timef") String timef,
|
| | | @Param("timea") String timea);
|
| | |
|
| | | String getJsonData(@Param("mac") String mac,
|
| | | @Param("time") String time,
|
| | | @Param("table") String table);
|
| | |
| | | List<Sensor> selectSenosrsByOrgId(Map<String, Object> parameters); |
| | | |
| | | List<String> getSensorKeys(); |
| | | |
| | | List<Map<String, Object>> getSensorByDId(String id); |
| | | } |
| | |
| | | |
| | | 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; |
| | |
| | | @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;
|
| | |
| | | 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);
|
| | |
| | | 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);
|
| | |
| | | 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;
|
| | |
| | | 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) {
|
| | |
| | |
|
| | | @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");
|
| | |
| | | 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";
|
| | |
| | | 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);
|
| | |
|
| | |
| | | }
|
| | |
|
| | | accountService.setOrgIdsByAccount(parameters);
|
| | |
|
| | | List<Map<String, Object>> result = historyMapper.getRegionRankingData(parameters);
|
| | | for (Map<String, Object> map : result) {
|
| | | if (ObjectUtils.isEmpty(map.get("avg"))) {
|
| | |
| | | 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)) {
|
| | |
| | | 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) {
|
| | |
| | | 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>();
|
| | |
| | | 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");
|
| | |
| | | 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
|
| | |
| | | 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");
|
| | |
| | | }
|
| | | 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) {
|
| | |
| | | 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<>();
|
| | |
| | | } |
| | | |
| | | @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; |
| | |
| | | </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`>=#{startTime} and `time`<#{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`>=#{startTime} |
| | | and `time`<#{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`>=#{startTime} and `time`<![CDATA[<]]>#{endTime} |
| | |
| | | <!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>
|
| | |
| | | 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
|
| | |
| | | value,
|
| | | time
|
| | | FROM
|
| | | history |
| | | history_${timeUnits}
|
| | | WHERE
|
| | | mac = #{mac}
|
| | | ORDER BY
|
| | |
| | | <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>
|
| | |
| | |
|
| | | <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当天查询 -->
|
| | |
| | |
|
| | | <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
|
| | |
| | |
|
| | | <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查询 -->
|
| | |
| | | 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 >= #{time1} and time <=#{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>
|
| | |
| | | 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 |