| | |
| | |
|
| | | List<Map<String, Object>> getSensorData(Map<String, Object> parameters);
|
| | |
|
| | | List<Map<String, Object>> getSensorData2020(Map<String, Object> parameters);
|
| | |
|
| | | } |
| | |
| | | import com.moral.mapper.HistoryMinutelyMapper;
|
| | | import com.moral.mapper.SensorMapper;
|
| | | import com.moral.service.HistoryMinutelyService;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import static com.moral.common.bean.Constants.NULL_VALUE;
|
| | |
| | | @Override
|
| | | public Map<String, Object> getDayAQIByDevice(Map<String, Object> parameters) {
|
| | | //ValidateUtil.notNull(parameters.get("mac"), "param.is.null");
|
| | | LocalDate localDate = LocalDate.now();
|
| | | LocalDate time = LocalDate.now();
|
| | | int year = time.getYear();
|
| | | int month = time.getMonthValue();
|
| | | int day = time.getDayOfMonth();
|
| | | if (day == 1) {
|
| | | if (month == 1) {
|
| | | month = 12;
|
| | | year = year - 1;
|
| | | } else {
|
| | | month = month - 1;
|
| | | }
|
| | | }
|
| | | String monthStr = month < 10 ? ("0" + month) : month + "";
|
| | | String yearAndMonth = year + monthStr;
|
| | | // 昨日00:00:00
|
| | | parameters.put("start", localDate.minusDays(1));
|
| | | parameters.put("start", time.minusDays(1));
|
| | |
|
| | | // 今日00:00:00
|
| | | parameters.put("end", localDate);
|
| | | parameters.put("end", time);
|
| | | parameters.put("yearAndMonth", yearAndMonth);
|
| | | parameters.put("sensorKeys", Arrays.asList("e1", "e2", "e10", "e11", "e15", "e16"));
|
| | | Map<String, Double> average = historyMinutelyMapper.getSersionAvgByDevice(parameters);
|
| | | return getAQIByDataMap(average);
|
| | |
| | | String startTime = parameters.get("startTime").toString();
|
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
| | | LocalDateTime startTimeLocalDateTime = LocalDateTime.parse(startTime, dateTimeFormatter);
|
| | | LocalDate today = LocalDate.now();
|
| | | LocalDate startTimeLocalDate=startTimeLocalDateTime.toLocalDate();
|
| | | Boolean flag=today.isEqual(startTimeLocalDate);
|
| | | LocalDate time = LocalDate.now();
|
| | | int year = startTimeLocalDateTime.getYear();
|
| | | int month = startTimeLocalDateTime.getMonthValue();
|
| | | String monthStr = month < 10 ? ("0" + month) : month + "";
|
| | | String yearAndMonth = year + monthStr;
|
| | | List<Sensor> sensors = sensorMapper.getSensorsByMac(parameters);
|
| | | List<String> sensorKeys = new ArrayList<>();
|
| | | for (Sensor sensor : sensors) {
|
| | |
| | | }
|
| | | parameters.put("sensorKeys", sensorKeys);
|
| | | List<Map<String, Object>> listMap = null;
|
| | | if (flag) {
|
| | | listMap = historyMapper.getSensorDataToday(parameters);
|
| | | } else {
|
| | | if (year <= 2019) {
|
| | | listMap = historyMinutelyMapper.getSensorData(parameters);
|
| | | } else {
|
| | | parameters.put("yearAndMonth", yearAndMonth);
|
| | | listMap = historyMinutelyMapper.getSensorData2020(parameters);
|
| | | }
|
| | | List<List<Map<String, Object>>> listMaps = new ArrayList<>();
|
| | | List<Map<String, Object>> listMapAvg = new ArrayList<>();
|
| | |
| | | AVG(json->'$.${sensorKey}[0]') AS '${sensorKey}'
|
| | | </foreach>
|
| | | FROM
|
| | | history_minutely
|
| | | history_minutely_${yearAndMonth}
|
| | | WHERE
|
| | | mac IN
|
| | | (SELECT
|
| | |
| | | hm.time
|
| | | </select>
|
| | |
|
| | | <select id="getSensorData2020" resultType="java.util.LinkedHashMap">
|
| | | SELECT
|
| | | DATE_FORMAT(hm.time,'%Y-%m-%d %H:%i:%s') time,
|
| | | <foreach collection="sensorKeys" item="sensorKey" separator=",">
|
| | | hm.json->'$.${sensorKey}[0]' as '${sensorKey}',
|
| | | hm.json->'$.${sensorKey}[1]' as 'min${sensorKey}',
|
| | | hm.json->'$.${sensorKey}[2]' as 'max${sensorKey}'
|
| | | </foreach>
|
| | | FROM
|
| | | history_minutely_${yearAndMonth} as hm
|
| | | <where>
|
| | | <if test="mac!=null">
|
| | | and hm.mac=#{mac}
|
| | | </if>
|
| | | and hm.time >= #{startTime}
|
| | | and hm.time <![CDATA[<=]]> #{endTime}
|
| | | </where>
|
| | | ORDER BY
|
| | | hm.time
|
| | | </select>
|
| | |
|
| | | </mapper> |
| | |
| | | var trackPoints = []; //用来存放从后台获取到的所有历史轨迹点的数据 |
| | | var coincidentPoints = new Array(); |
| | | var flyingParameters = ['e76', 'e77', 'e78', 'e79', 'e80', 'e81']; |
| | | var monitorParameters = ['e1', 'e2', 'e10', 'e11', 'e16', 'e15', 'e17', 'e28', 'e7', 'e6', 'e82']; |
| | | var monitorParameters = ['e1', 'e2', 'e10', 'e11', 'e16', 'e15', 'e17', 'e28', 'e7', 'e6', 'e82', 'e40']; |
| | | if (sensorInfo.length > 0) { |
| | | $.each(sensorInfo, function (item, value) { |
| | | if (typeof (value.e76) == "undefined") { |
| | |
| | | var lat1 = GPS.gcj_encrypt(lat, lon).lat; |
| | | var lon2 = GPS.bd_encrypt(lat1, lon1).lon; |
| | | var lat2 = GPS.bd_encrypt(lat1, lon1).lat; |
| | | if (lon2 > 0.1 && lat2 > 0.1) { |
| | | trackPoints.push(new BMap.Point(lon2, lat2)); |
| | | } |
| | | } |
| | | }) |
| | | for (var i = 0; i < trackPoints.length; i++) { |
| | | var flyingData = []; |