From da0cb6ec9344641c5d1820e099131b58149b3fbc Mon Sep 17 00:00:00 2001 From: swb <jpy123456> Date: Fri, 15 Nov 2024 08:44:30 +0800 Subject: [PATCH] fix:国控站显示提交 --- screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java | 1009 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 936 insertions(+), 73 deletions(-) diff --git a/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java index 1f34fd1..5646116 100644 --- a/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java +++ b/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java @@ -1,19 +1,32 @@ package com.moral.api.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.moral.api.entity.*; +import com.moral.api.mapper.DeviceMapper; +import com.moral.api.mapper.HistoryMonthlyMapper; +import com.moral.api.mapper.OrganizationMapper; +import com.moral.api.pojo.dto.dataDisplay.HeatMapDTO; import com.moral.api.pojo.dto.dataDisplay.MonitorPointDataDisplayDTO; import com.moral.api.pojo.dto.dataDisplay.SensorComparisonDisplayDTO; import com.moral.api.pojo.form.dataDisplay.MonitorPointDataDisplayForm; import com.moral.api.pojo.form.dataDisplay.SensorComparisonDisplayForm; +import com.moral.api.pojo.vo.historyMonthly.HistoryResultVo; import com.moral.api.service.*; +import com.moral.api.utils.GetCenterPointFromListOfCoordinates; +import com.moral.api.utils.StringUtils; import com.moral.constant.Constants; +import com.moral.constant.SeparateTableType; +import com.moral.pojo.AQI; import com.moral.util.*; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; import java.util.*; +import java.util.stream.Collectors; + /** * @ClassName DataDisplayServiceImpl @@ -23,6 +36,7 @@ * @Version TODO **/ @Service +@Slf4j public class DataDisplayServiceImpl implements DataDisplayService { @Autowired @@ -32,23 +46,35 @@ @Autowired HistoryHourlyService historyHourlyService; @Autowired + HistoryMonthlyMapper historyMonthlyMapper; + @Autowired HistoryWeeklyService historyWeeklyService; @Autowired HistoryMonthlyService historyMonthlyService; + @Autowired + OrganizationMapper organizationMapper; + + @Autowired + DeviceMapper deviceMapper; @Override public List<MonitorPointDataDisplayDTO> getMonitorPointDisplayData(MonitorPointDataDisplayForm form) { //������ - Integer monitorPointId = form.getMonitorPointId(); +// Integer monitorPointId = form.getMacs(); + List<String> macs = form.getMacs(); String reportType = form.getReportType(); Date startTime = form.getStartTime(); Date endTime = form.getEndTime(); //������������id������������������������������ - List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPointId); +// List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPointId); + QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>(); + deviceQueryWrapper.eq("is_delete",Constants.NOT_DELETE); + deviceQueryWrapper.in("mac", macs); + List<Device> devices = deviceMapper.selectList(deviceQueryWrapper); Map<String, Device> deviceMap = new HashMap<>(); - List<String> macs = new ArrayList<>(); +// List<String> ListMacs = new ArrayList<>(); devices.forEach(value -> { - macs.add(value.getMac()); +// ListMacs.add(value.getMac()); deviceMap.put(value.getMac(), value); }); List<MonitorPointDataDisplayDTO> dtos = new ArrayList<>(); @@ -68,42 +94,56 @@ } //��������������������������������������������������������� else if (reportType.equals(Constants.HOURLY_REPORT)) { - Map<String, HistoryHourly> macDataMap = new HashMap<>(); + Map<String, List<HistoryHourly>> macDataMap = new HashMap<>(); //������������ macs.forEach(value -> { - List<HistoryHourly> datas = historyHourlyService.getValueByMacAndTime(value, startTime, startTime); + List<HistoryHourly> datas = historyHourlyService.getValueByMacAndTime(value, startTime, endTime); if (datas.size() != 0) - macDataMap.put(value, datas.get(0)); + macDataMap.put(value,datas); }); if (macDataMap.size() != 0) - dtos = calculateReportData(macDataMap, deviceMap, startTime); + dtos = calculateReportData(macDataMap, deviceMap, reportType, startTime); } //��������������������������������������������� else if (reportType.equals(Constants.DAILY_REPORT)) { + Map<String, List<HistoryDaily>> macDataMap = new HashMap<>(); //������������ - Map<String, HistoryDaily> macDataMap = historyDailyService.getHistoryDailyByMacsAndDate(macs, startTime); + macs.forEach(value -> { + List<HistoryDaily> datas = historyDailyService.getHistoryDailyByMacAndTimeSlot(value, startTime, endTime); + if (datas.size() != 0) + macDataMap.put(value,datas); + }); + if (macDataMap.size() != 0) - dtos = calculateReportData(macDataMap, deviceMap, startTime); + dtos = calculateReportData(macDataMap, deviceMap, reportType, startTime); } //��������������������������������������������� else if (reportType.equals(Constants.WEEKLY_REPORT)) { //������������ Map<String, HistoryWeekly> macDataMap = historyWeeklyService.getHistoryWeeklyByMacsAndDate(macs, startTime); if (macDataMap.size() != 0) - dtos = calculateReportData(macDataMap, deviceMap, startTime, endTime); + dtos = calculateReportData(macDataMap, deviceMap, reportType, startTime, endTime); } //������������������ else if (reportType.equals(Constants.MONTHLY_REPORT)) { //������������������������������������������������������������������������������������������������ Map<String, List<HistoryDaily>> macDataDailyMap = new HashMap<>(); - Map<String, HistoryMonthly> macDataMonthlyMap = historyMonthlyService.getHistoryMonthlyByMacsAndDate(macs, startTime); + Map<String, List<HistoryMonthly>> macDataMonthlyMap = new HashMap<>(); + macs.forEach(mac -> { + QueryWrapper<HistoryMonthly> wrapper = new QueryWrapper<>(); + wrapper.eq("mac",mac); + wrapper.between("time",startTime,endTime); + List<HistoryMonthly> monthlyList = historyMonthlyMapper.selectList(wrapper); + if (!ObjectUtils.isEmpty(monthlyList)) + macDataMonthlyMap.put(mac, monthlyList); + }); macs.forEach(mac -> { List<HistoryDaily> dailyDatas = historyDailyService.getHistoryDailyByMacAndTimeSlot(mac, startTime, endTime); if (!ObjectUtils.isEmpty(dailyDatas)) macDataDailyMap.put(mac, dailyDatas); }); if (macDataMonthlyMap.size() != 0) - dtos = calculateReportData(macDataMonthlyMap, deviceMap, startTime); + dtos = calculateReportData(macDataMonthlyMap, deviceMap, reportType, startTime); //������������������ injectComprehensiveIndex(dtos, macDataDailyMap); } @@ -124,9 +164,20 @@ List<HistoryHourly> hourlies = historyHourlyService.getValueByMacAndTime(mac, startDate, endDate); for (HistoryHourly historyHourly : hourlies) { Date time = historyHourly.getTime(); - int hour = DateUtils.getHour(time); + String dateStr = DateUtils.dateToDateString(time, "yyyy-MM-dd HH"); String value = historyHourly.getValue(); - timeValueMap.put(String.valueOf(hour), value); + timeValueMap.put(dateStr, value); + } + //���������������������������������������24������������������ + for (int i = 0; i < 24; i++) { + //������������ + String time = DateUtils.dateToDateString(startDate, "yyyy-MM-dd"); + if (i < 10) + time = time + " 0" + i; + else + time = time + " " + i; + if (timeValueMap.get(time) == null) + timeValueMap.put(time, null); } } //������������������ @@ -134,38 +185,777 @@ List<HistoryDaily> dailies = historyDailyService.getHistoryDailyByMacAndTimeSlot(mac, startDate, endDate); for (HistoryDaily historyDaily : dailies) { Date time = historyDaily.getTime(); - int day = DateUtils.getDay(time); + String dateStr = DateUtils.dateToDateString(time, "yyyy-MM-dd"); String value = historyDaily.getValue(); - timeValueMap.put(String.valueOf(day), value); + timeValueMap.put(String.valueOf(dateStr), value); + } + //������������������������������������������������������ + int days = DateUtils.getMonthDay(startDate); + for (int i = 1; i <= days; i++) { + //������������ + String time = DateUtils.dateToDateString(startDate, "yyyy-MM"); + if (i < 10) + time = time + "-0" + i; + else + time = time + "-" + i; + if (timeValueMap.get(time) == null) + timeValueMap.put(time, null); } } else return null; + //������������ + timeValueMap = sortMapByTime(timeValueMap, reportType); //������������������ List<SensorComparisonDisplayDTO> dtos = new ArrayList<>(); for (String sensor : sensors) { SensorComparisonDisplayDTO dto = new SensorComparisonDisplayDTO(); - Map<String,Double> dtoTimeValueMap = new LinkedHashMap<>(); + List<Map<String, Object>> dtoTimeValueList = new ArrayList<>(); dto.setSensorCode(sensor); timeValueMap.forEach((time, valueJson) -> { + Map<String, Object> listMap = new HashMap<>(); + //��������������������������������������������� + if (valueJson == null) { + listMap.put("time", time); + listMap.put("value", ""); + dtoTimeValueList.add(listMap); + return; + } Map<String, Object> valueMap = JSON.parseObject(valueJson, Map.class); Object sensorValueObject = valueMap.get(sensor); - if(sensorValueObject==null) + //��������������������������������������������� + if (sensorValueObject == null) { + listMap.put("time", time); + listMap.put("value", ""); + dtoTimeValueList.add(listMap); return; - Double sensorValue = Double.parseDouble(sensorValueObject.toString()); - //������������������������������������������ - if(reportType.equals(Constants.HOURLY_REPORT)){ - if(!Constants.NORMAL_FLAG.equals(valueMap.get(sensor+"-Flag"))) - return; } + //������������������������������������������ + if (reportType.equals(Constants.DAILY_REPORT)) { + //���������������������N��������������� + if (!Constants.NORMAL_FLAG.equals(valueMap.get(sensor + "-Flag"))) { + listMap.put("time", time); + listMap.put("value", ""); + dtoTimeValueList.add(listMap); + return; + } + } + //������������ + Double sensorValue = Double.parseDouble(sensorValueObject.toString()); //������������ - dtoTimeValueMap.put(time,sensorValue); - dto.setTimeValueMap(dtoTimeValueMap); + listMap.put("time", time); + listMap.put("value", sensorValue); + dtoTimeValueList.add(listMap); }); + dto.setTimeValueList(dtoTimeValueList); dtos.add(dto); } return dtos; } + public static void main(String[] args) { + List<String> sensors = new ArrayList<>(); + sensors.add("a34004"); + sensors.add("a34002"); + sensors.add("a21026"); + StringBuilder str = new StringBuilder(); + for(String s : sensors){ + str.append(" avg(JSON_EXTRACT( value, '$"+s+"' )) pm,"); + } + str.deleteCharAt(str.length() - 1); + System.out.println(str.toString()); + + } + + + @Override + public List<SensorComparisonDisplayDTO> getSensorComparisonDisplayDataV2(Map<String, Object> params) { + //������ + List<String> sensors = (List<String>) params.get("sensorCodes"); + /*Date startDate = form.getStartDate(); + Date endDate = form.getEndDate();*/ + //������������ + List<String> times = (List<String>) params.get("times"); + String startTime = times.get(0); + String endTime = times.get(1); + boolean type = subStr(params.get("mac").toString()); + String mac = type?params.get("mac").toString().substring(0, params.get("mac").toString().indexOf(",avg")):params.get("mac").toString(); + List<String> macList = new ArrayList<>(); + if(type){ + macList = deviceService.getMacMonitorPointId(Integer.parseInt(mac)); + }else { + macList.add(mac); + } + + String reportType = params.get("reportType").toString(); + Map<String, String> timeValueMap = new LinkedHashMap<>();//key���time���value������������json + //��������������� + if (reportType.equals(Constants.MONTHLY_REPORT)) { + //������������������ + List<SensorComparisonDisplayDTO> dtos = new ArrayList<>(); + + Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_EN); + Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_EN); + for(String s : sensors){ + SensorComparisonDisplayDTO dto = new SensorComparisonDisplayDTO(); + if(s.equals("a00e12") || s.equals("a00e03")){ + dto.setCode("1"); + }else if (s.equals("a01006")){ + dto.setCode("2"); + }else if (s.equals("a99054") || s.equals("a21005")){ + dto.setCode("3"); + }else { + dto.setCode("0"); + } + List<Map<String, Object>> dtoTimeValueList = new ArrayList<>(); + String str = " ROUND(avg(JSON_EXTRACT( value, '$."+s+"' )),2) value "; + List<HistoryResultVo> monthlies = historyMonthlyMapper.listAll(str.toString(),macList,startTime.substring(0,7)+"-01 00:00:00",endTime.substring(0,7)+"-01 00:00:00"); + Map<String, List<HistoryResultVo>> prodMap= monthlies.stream().collect(Collectors.groupingBy(HistoryResultVo::getTime)); + //��������������������� + Date middleDate = startDate; + while (DateUtils.compareDateStr(DateUtils.dateToDateString(endDate,DateUtils.yyyy_MM_EN),DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN),DateUtils.yyyy_MM_EN)<=0){ + Map<String, Object> resultMap = new LinkedHashMap<>(); + resultMap.put("time",DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN)); + if (prodMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN)) == null){ + resultMap.put("value",null); + }else { + List<HistoryResultVo> resultList = prodMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN)); + resultMap.put("value", resultList.get(0).getValue()); + } + dtoTimeValueList.add(resultMap); + middleDate = DateUtils.addMonths(middleDate,1); + } + + dto.setTimeValueList(dtoTimeValueList); + dtos.add(dto); + } + + return dtos; + + } + //������������������ + else if (reportType.equals(Constants.HOURLY_REPORT)) { + Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_EN); + Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_HH_EN); + List<HistoryHourly> hourlies = historyHourlyService.getValueByMacAndTime(mac, startDate, endDate); + for (HistoryHourly historyHourly : hourlies) { + Date time = historyHourly.getTime(); + String dateStr = DateUtils.dateToDateString(time, "yyyy-MM-dd HH"); + String value = historyHourly.getValue(); + timeValueMap.put(dateStr, value); + } + //��������������������� + Date middleDate = startDate; + while (DateUtils.compareDateStr(DateUtils.dateToDateString(endDate,DateUtils.yyyy_MM_dd_HH_EN),DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_HH_EN),DateUtils.yyyy_MM_dd_HH_EN)<=0){ + if (timeValueMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_HH_EN)) == null) + timeValueMap.put(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_HH_EN), null); + middleDate = DateUtils.addHours(middleDate,1); + } + } + //��������������� + else if (reportType.equals(Constants.DAILY_REPORT)) { + Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_EN); + Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_EN); + List<HistoryDaily> dailies = historyDailyService.getHistoryDailyByMacAndTimeSlot(mac, startDate, endDate); + for (HistoryDaily historyDaily : dailies) { + Date time = historyDaily.getTime(); + String dateStr = DateUtils.dateToDateString(time, "yyyy-MM-dd"); + String value = historyDaily.getValue(); + timeValueMap.put(String.valueOf(dateStr), value); + } + //��������������������� + Date middleDate = startDate; + while (DateUtils.compareDateStr(DateUtils.dateToDateString(endDate,DateUtils.yyyy_MM_dd_EN),DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_EN),DateUtils.yyyy_MM_dd_EN)<=0){ + if (timeValueMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_EN)) == null) + timeValueMap.put(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_EN), null); + middleDate = DateUtils.addDays(middleDate,1); + } + } else + return null; + //������������ + //timeValueMap = sortMapByTime(timeValueMap, reportType); + //������������������ + List<SensorComparisonDisplayDTO> dtos = new ArrayList<>(); + for (String sensor : sensors) { + SensorComparisonDisplayDTO dto = new SensorComparisonDisplayDTO(); + List<Map<String, Object>> dtoTimeValueList = new ArrayList<>(); + if(sensor.equals("a00e12") || sensor.equals("a00e03")){ + dto.setCode("1"); + }else if (sensor.equals("a01006")){ + dto.setCode("2"); + }else if (sensor.equals("a99054") || sensor.equals("a21005")){ + dto.setCode("3"); + }else { + dto.setCode("0"); + } + dto.setSensorCode(sensor); + timeValueMap.forEach((time, valueJson) -> { + Map<String, Object> listMap = new HashMap<>(); + //��������������������������������������������� + if (valueJson == null) { + listMap.put("time", time); + listMap.put("value", ""); + dtoTimeValueList.add(listMap); + return; + } + Map<String, Object> valueMap = JSON.parseObject(valueJson, Map.class); + Object sensorValueObject = valueMap.get(sensor); + //��������������������������������������������� + if (sensorValueObject == null) { + listMap.put("time", time); + listMap.put("value", ""); + dtoTimeValueList.add(listMap); + return; + } + //������������������������������������������ + if (reportType.equals(Constants.HOURLY_REPORT)) { + //���������������������N��������������� + if (!Constants.NORMAL_FLAG.equals(valueMap.get(sensor + "-Flag"))) { + listMap.put("time", time); + listMap.put("value", ""); + dtoTimeValueList.add(listMap); + return; + } + } + //������������ + Double sensorValue = Double.parseDouble(sensorValueObject.toString()); + //������������ + listMap.put("time", time); + listMap.put("value", sensorValue); + dtoTimeValueList.add(listMap); + }); + Collections.sort(dtoTimeValueList, new Comparator<Map<String, Object>>() { + public int compare(Map<String, Object> o1, Map<String, Object> o2) { + String id1 = (String) o1.get("time"); + String id2 = (String) o2.get("time"); + return id1.compareTo(id2); + } + + }); + dto.setTimeValueList(dtoTimeValueList); + dtos.add(dto); + } + return dtos; + } + @Override + public List<SensorComparisonDisplayDTO> getSensorComparisonDisplayDataV3(Map<String, Object> params) { + //������ + List<String> sensors = (List<String>) params.get("sensorCodes"); + //������������ + List<String> times = (List<String>) params.get("times"); + String startTime = times.get(0); + String endTime = times.get(1); + boolean type = subStr(params.get("mac").toString()); + String mac = type?params.get("mac").toString().substring(0, params.get("mac").toString().indexOf(",avg")):params.get("mac").toString(); + List<String> macList = new ArrayList<>(); + if(type){ + macList = deviceService.getMacMonitorPointId(Integer.parseInt(mac)); + }else { + macList.add(mac); + } + String reportType = params.get("reportType").toString(); + List<SensorComparisonDisplayDTO> dtos = new ArrayList<>(); + Date startDate = null; + Date endDate = null; + if (reportType.equals(Constants.MONTHLY_REPORT)) { + startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_EN); + endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_EN); + } else if (reportType.equals(Constants.HOURLY_REPORT)) { + startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_EN); + endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_HH_EN); + } else if (reportType.equals(Constants.DAILY_REPORT)) { + startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_EN); + endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_EN); + } + for(String s : sensors){ + SensorComparisonDisplayDTO dto = new SensorComparisonDisplayDTO(); + if(s.equals("a00e12") || s.equals("a00e03")){ + dto.setCode("1"); + }else if (s.equals("a01006")){ + dto.setCode("2"); + }else if (s.equals("a99054") || s.equals("a21005")){ + dto.setCode("3"); + }else { + dto.setCode("0"); + } + List<Map<String, Object>> dtoTimeValueList = new ArrayList<>(); + String str = " ROUND(avg(JSON_EXTRACT( value, '$."+s+"' )),2) value "; + List<HistoryResultVo> historyResultVos = new ArrayList<>(); + if (reportType.equals(Constants.MONTHLY_REPORT)) { + historyResultVos = historyMonthlyMapper.listAll(str,macList,startTime.substring(0,7)+"-01 00:00:00",endTime.substring(0,7)+"-01 00:00:00"); + } else if (reportType.equals(Constants.HOURLY_REPORT)) { + historyResultVos = historyHourlyService.getAvgValueByMacAndTime(macList,str, startDate, endDate); + } else if (reportType.equals(Constants.DAILY_REPORT)) { + historyResultVos = historyDailyService.listAvgResult(str,macList,DateUtils.dateToDateString(startDate,DateUtils.yyyy_MM_dd_EN) ,DateUtils.dateToDateString(endDate,DateUtils.yyyy_MM_dd_EN) ); + } + Map<String, List<HistoryResultVo>> prodMap= historyResultVos.stream().collect(Collectors.groupingBy(HistoryResultVo::getTime)); + Date middleDate = startDate; + while(DateUtils.isTimeBeforE(endDate,middleDate)){ + Map<String, Object> resultMap = new LinkedHashMap<>(); + if (reportType.equals(Constants.MONTHLY_REPORT)) { + resultMap.put("time",DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN)); + if (prodMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN)) == null){ + resultMap.put("value",null); + }else { + List<HistoryResultVo> resultList = prodMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_EN)); + resultMap.put("value", resultList.get(0).getValue()); + } + dtoTimeValueList.add(resultMap); + middleDate = DateUtils.addMonths(middleDate,1); + }else if(reportType.equals(Constants.HOURLY_REPORT)) { + resultMap.put("time",DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_HH_EN)); + if (prodMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_HH_EN)) == null){ + resultMap.put("value",null); + }else { + List<HistoryResultVo> resultList = prodMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_HH_EN)); + resultMap.put("value", resultList.get(0).getValue()); + } + dtoTimeValueList.add(resultMap); + middleDate = DateUtils.addHours(middleDate,1); + }else if(reportType.equals(Constants.DAILY_REPORT)){ + resultMap.put("time",DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_EN)); + if (prodMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_EN)) == null){ + resultMap.put("value",null); + }else { + List<HistoryResultVo> resultList = prodMap.get(DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_EN)); + resultMap.put("value", resultList.get(0).getValue()); + } + dtoTimeValueList.add(resultMap); + middleDate = DateUtils.addDays(middleDate,1); + } + } + dto.setSensorCode(s); + dto.setTimeValueList(dtoTimeValueList); + dtos.add(dto); + } + return dtos; + } + + /** + * ��������������� + * @param code + * @param startTime + * @param type + * @return + */ + @Override + public List<HeatMapDTO> getHeatMapData(String code, String startTime, String type, String form) { + HashMap<String, Object> map = new HashMap<>(); + map.put("start",startTime); + map.put("type","$."+ type); + + ArrayList<Integer> list = new ArrayList<>(); + +// ArrayList<Map<String, Object>> rsHeatMap = new ArrayList<>(); + ArrayList<HeatMapDTO> rsHeatMap = new ArrayList<>(); + if (form.equals("hour")){ //������ + Date date1 = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_EN); + List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(date1, date1, SeparateTableType.MONTH); +// for (Integer integer : list) { + map.put("organizationIds",list); + map.put("tableName",tableNames.get(0)); +// List<Map<String, Object>> heatMap = deviceMapper.getHeatMap(map); + List<HeatMapDTO> heatMap = deviceMapper.getHeatMap(map); + rsHeatMap.addAll(heatMap); +// } + + }else { //��� +// for (Integer integer : list) { + map.put("organizationIds",list); +// List<Map<String, Object>> heatMap = deviceMapper.getHeatMap(map); + List<HeatMapDTO> heatMap = deviceMapper.getHeatMap(map); + rsHeatMap.addAll(heatMap); +// } + } + + return distrinList(rsHeatMap); + } + + @Override + public List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form,Integer monitorId) { + HashMap<String, Object> map = new HashMap<>(); + map.put("start",startTime); + map.put("type","$."+ type); + map.put("monitorId",monitorId); + ArrayList<Integer> list = new ArrayList<>(); + list.add(id); + ArrayList<HeatMapDTO> rsHeatMap = new ArrayList<>(); +/* ArrayList<String> list1 = new ArrayList<>(); + list1.add("���������������"); + list1.add("���������������"); + list1.add("���������������"); + list1.add("���������������"); + list1.add("������������������");*/ + + if (form.equals("hour")){ //������ +// String[] split = startTime.split("-"); +// String s = "_" + split[0] + split[1]; + String dateString = DateUtils.stringToDateString(startTime, DateUtils.yyyy_MM_dd_HH_EN, DateUtils.yyyyMM_EN); + map.put("organizationIds",list); + map.put("tableName","_"+dateString); + + List<HeatMapDTO> heatMap = deviceMapper.getHeatMapV1(map); + //������������ + List<HeatMapDTO> collect1 = heatMap.stream().filter(d -> d.getTime() != null).collect(Collectors.toList()); + if (ObjectUtils.isEmpty(collect1)){ + return null; + } + for (HeatMapDTO heatMapDTO : heatMap) { +// if (list1.contains(heatMapDTO.getName())){ + if (type.equals("a34002") || type.equals("a21026")){ + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?49.0:heatMapDTO.getCount()); + }else if (type.equals("a34004")){ + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?20.0:heatMapDTO.getCount()); + }else if (type.equals("a21004")){ + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?20.0:heatMapDTO.getCount()); + }else if (type.equals("a21005")){ + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?1.0:heatMapDTO.getCount()); + }else if (type.equals("a05024")){ + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?138.0:heatMapDTO.getCount()); + }else { + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?0.2:heatMapDTO.getCount()); + } +// }else { +// if (ObjectUtils.isEmpty(heatMapDTO.getCount())){ +// heatMapDTO.setCount(0.0); +// } +// } + } + + getHeatMap(heatMap,type); + rsHeatMap.addAll(heatMap); + }else { //��� + map.put("organizationIds",list); + List<HeatMapDTO> heatMap = deviceMapper.getHeatMapV1(map); + List<HeatMapDTO> collect1 = heatMap.stream().filter(d -> d.getTime() != null).collect(Collectors.toList()); + if (ObjectUtils.isEmpty(collect1)){ + return null; + } + for (HeatMapDTO heatMapDTO : heatMap) { + if (type.equals("a34002") || type.equals("a21026")){ + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?49.0:heatMapDTO.getCount()); + }else if (type.equals("a34004")){ + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?34.0:heatMapDTO.getCount()); + }else if (type.equals("a21004")){ + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?39.0:heatMapDTO.getCount()); + }else if (type.equals("a21005")){ + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?1.9:heatMapDTO.getCount()); + }else if (type.equals("a05024")){ + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?100.0:heatMapDTO.getCount()); + }else { + heatMapDTO.setCount(ObjectUtils.isEmpty(heatMapDTO.getCount())?0.4:heatMapDTO.getCount()); + } + } + getHeatMap(heatMap,type); + rsHeatMap.addAll(heatMap); + } + if (id==71){ + for (int i = 0; i <6; i++) { + HeatMapDTO heatMapDTO = new HeatMapDTO(); + heatMapDTO.setCount(0.0); + if (i==0){ + heatMapDTO.setLat(40.590436); + heatMapDTO.setLng(122.861935); + heatMapDTO.setMac("1111"); + heatMapDTO.setName("1111"); + }else if (i==1){ + heatMapDTO.setLat(40.636617); + heatMapDTO.setLng(123.101544); + heatMapDTO.setMac("2222"); + heatMapDTO.setName("2222"); + }else if (i==2){ + heatMapDTO.setLat(40.890881); + heatMapDTO.setLng(122.910687); + heatMapDTO.setMac("3333"); + heatMapDTO.setName("3333"); + }else if (i==3){ + heatMapDTO.setLat(40.682129); + heatMapDTO.setLng(123.105836); + heatMapDTO.setMac("4444"); + heatMapDTO.setName("4444"); + }else if (i==4){ + heatMapDTO.setLat(40.890037); + heatMapDTO.setLng(123.021151); + heatMapDTO.setMac("5555"); + heatMapDTO.setName("5555"); + }else { + heatMapDTO.setLat(41.051333); + heatMapDTO.setLng(122.505864); + heatMapDTO.setMac("6666"); + heatMapDTO.setName("6666"); + } + rsHeatMap.add(heatMapDTO); + } + } + + if (!ObjectUtils.isEmpty(monitorId)){ + if (monitorId==117){ + double lat =33.35001; + double lng =120.142939; + for (int i = 0; i <24 ; i++) { + for (int j = 0; j < 20; j++) { + HeatMapDTO heatMapDTO = new HeatMapDTO(); + heatMapDTO.setCount(0.0); + heatMapDTO.setLat(lat); + heatMapDTO.setLng(lng); + heatMapDTO.setName("1"); + heatMapDTO.setMac(i+"10"+j); + rsHeatMap.add(heatMapDTO); + lng=lng+0.0021; + if (j==19){ + lng=120.142939; + } + } + lat =lat-0.0011; + } + } else if (monitorId==118){ + double lat =33.375618; + double lng =120.14271; + for (int i = 0; i <24 ; i++) { + for (int j = 0; j < 17; j++) { + HeatMapDTO heatMapDTO = new HeatMapDTO(); + heatMapDTO.setCount(0.0); + heatMapDTO.setLat(lat); + heatMapDTO.setLng(lng); + heatMapDTO.setName("1"); + heatMapDTO.setMac(i+"10"+j); + rsHeatMap.add(heatMapDTO); + lng=lng+0.0021; + if (j==16){ + lng=120.14271; + } + } + lat =lat-0.0011; + } + } else if (monitorId==120){ + double lat =33.410581; + double lng =120.108739; + for (int i = 0; i <21 ; i++) { + for (int j = 0; j < 15; j++) { + HeatMapDTO heatMapDTO = new HeatMapDTO(); + heatMapDTO.setCount(0.0); + heatMapDTO.setLat(lat); + heatMapDTO.setLng(lng); + heatMapDTO.setName("1"); + heatMapDTO.setMac(i+"10"+j); + rsHeatMap.add(heatMapDTO); + lng=lng+0.0021; + if (j==14){ + lng=120.108739; + } + } + lat =lat-0.001; + } + }else if (monitorId==121){ + double lat =33.398466; + double lng =120.153462; + for (int i = 0; i <13 ; i++) { + for (int j = 0; j < 16; j++) { + HeatMapDTO heatMapDTO = new HeatMapDTO(); + heatMapDTO.setCount(0.0); + heatMapDTO.setLat(lat); + heatMapDTO.setLng(lng); + heatMapDTO.setName("1"); + heatMapDTO.setMac(i+"10"+j); + rsHeatMap.add(heatMapDTO); + lng=lng+0.00085; + if (j==15){ + lng=120.153462; + } + } + lat =lat-0.001; + } + }else if (monitorId==122){ + double lat =33.210894; + double lng =120.424509; + for (int i = 0; i <15 ; i++) { + for (int j = 0; j < 9; j++) { + HeatMapDTO heatMapDTO = new HeatMapDTO(); + heatMapDTO.setCount(0.0); + heatMapDTO.setLat(lat); + heatMapDTO.setLng(lng); + heatMapDTO.setName("1"); + heatMapDTO.setMac(i+"10"+j); + rsHeatMap.add(heatMapDTO); + lng=lng+0.0021; + if (j==8){ + lng=120.424509; + } + } + lat =lat-0.001; + } + }else if (monitorId==119){ + double lat =33.384755; + double lng =120.20625; + for (int i = 0; i <14 ; i++) { + for (int j = 0; j < 12; j++) { + HeatMapDTO heatMapDTO = new HeatMapDTO(); + heatMapDTO.setCount(0.0); + heatMapDTO.setLat(lat); + heatMapDTO.setLng(lng); + heatMapDTO.setName("1"); + heatMapDTO.setMac(i+"10"+j); + rsHeatMap.add(heatMapDTO); + lng=lng+0.0021; + if (j==11){ + lng=120.20625; + } + } + lat =lat-0.001; + } + } + } + /* if (id==73){ + //��������� + double lat =33.414538; + double lng =120.066616; + for (int i = 0; i <11 ; i++) { + for (int j = 0; j < 20; j++) { + HeatMapDTO heatMapDTO = new HeatMapDTO(); + heatMapDTO.setCount(0.0); + heatMapDTO.setLat(lat); + heatMapDTO.setLng(lng); + heatMapDTO.setName("1"); + heatMapDTO.setMac(i+"1"+j); + rsHeatMap.add(heatMapDTO); + lng=lng+0.01; + if (j==19){ + lng=120.066616; + } + } + lat =lat-0.01; + } + //��������� + double lat1 =33.214555; + double lng1 =120.416805; + for (int i = 0; i < 11 ; i++) { + for (int j = 0; j < 10; j++) { + HeatMapDTO heatMapDTO = new HeatMapDTO(); + heatMapDTO.setCount(0.0); + heatMapDTO.setLat(lat1); + heatMapDTO.setLng(lng1); + heatMapDTO.setName("2"); + heatMapDTO.setMac(i+"2"+j); + rsHeatMap.add(heatMapDTO); + lng1=lng1+0.004; + if (j==9){ + lng1=120.416805; + } + } + lat1 =lat1-0.0022; + } + }*/ + return distrinList(rsHeatMap); + } + + //������������ + private void getHeatMap(List<HeatMapDTO> heatMap,String type) { + //������������ + List<HeatMapDTO> collect1 = heatMap.stream().filter(d -> d.getGroupId() != null).collect(Collectors.toList()); + if (ObjectUtils.isEmpty(collect1)){ + return; + } + //������������ + Map<Integer, List<HeatMapDTO>> collect = collect1.parallelStream().collect(Collectors.groupingBy(o ->o.getGroupId())); + Set<Integer> integers = collect.keySet(); + int i = 0 ; + for (Integer integer : integers) { + ArrayList<Double> doubleArrayList = new ArrayList<>(); + ArrayList<GeoCoordinate> geoCoordinates = new ArrayList<>(); + List<HeatMapDTO> heatMapDTOS = collect.get(integer); + if (heatMapDTOS.size()>1){ + for (HeatMapDTO heatMapDTO : heatMapDTOS) { + GeoCoordinate geoCoordinate = new GeoCoordinate(); + doubleArrayList.add(heatMapDTO.getCount()); +// heatMapDTO.setCount(heatMapDTO.getCount()); + if (type.equals("a21026")){ + heatMapDTO.setCount(1.0); + }else { + heatMapDTO.setCount(0.0); + } + + geoCoordinate.setLongitude(heatMapDTO.getLng()); + geoCoordinate.setLatitude(heatMapDTO.getLat()); + geoCoordinates.add(geoCoordinate); + } + } + if (!ObjectUtils.isEmpty(doubleArrayList) &&doubleArrayList.size()>1){ + HeatMapDTO heatMapDTO = new HeatMapDTO(); + //������������������ + double asDouble = doubleArrayList.stream().mapToDouble(Double::valueOf).max().getAsDouble(); + //��������������� + GeoCoordinate centerPoint = GetCenterPointFromListOfCoordinates.getCenterPoint(geoCoordinates); +// double rsCode = asDouble - (doubleArrayList.size()*10); + double rsCode = asDouble - doubleArrayList.size()-1; +// log.info(asDouble+"-----"+rsCode); +// heatMapDTO.setCount(rsCode); + heatMapDTO.setCount(rsCode); +// heatMapDTO.setSum(asDouble); + heatMapDTO.setLng(centerPoint.getLongitude()); + heatMapDTO.setLat(centerPoint.getLatitude()); + heatMapDTO.setMac(i+""); + heatMapDTO.setName(integer+""); + heatMap.add(heatMapDTO); + i++; + } + } + } + + /** + * ������������ + * @param responseList + * @return + */ + private List<HeatMapDTO> distrinList(List<HeatMapDTO> responseList){ + List<HeatMapDTO> rsMap = new ArrayList<>(); + Set<String> keysSet = new HashSet<String>(); + for (HeatMapDTO heatMapDTO : responseList) { + String keys = String.valueOf(heatMapDTO.getMac()); + int beforeSize = keysSet.size(); + keysSet.add(keys); + int afterSize = keysSet.size(); + if(afterSize == beforeSize + 1){ + rsMap.add(heatMapDTO); + } + } + return rsMap; + + + } + + /** + * @Description: ������������������������ + * @Param: [timeValueMap, reportType] + * @return: java.util.Map<java.lang.String , java.lang.String> + * @Author: ��������� + * @Date: 2021/11/3 + */ + private Map<String, String> sortMapByTime(Map<String, String> timeValueMap, String reportType) { + List<Map.Entry<String, String>> entries = new ArrayList(timeValueMap.entrySet()); + Collections.sort(entries, new Comparator<Map.Entry<String, String>>() { + @Override + public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) { + if (Constants.DAILY_REPORT.equals(reportType)) { + String atime = o1.getKey(); + String btime = o2.getKey(); + atime = atime.substring(11, 13); + btime = btime.substring(11, 13); + return Integer.parseInt(atime) - Integer.parseInt(btime); + } else if (Constants.MONTHLY_REPORT.equals(reportType)) { + String atime = o1.getKey(); + String btime = o2.getKey(); + atime = atime.substring(8, 10); + btime = btime.substring(8, 10); + return Integer.parseInt(atime) - Integer.parseInt(btime); + } + return 0; + } + }); + Map<String, String> sortedMap = new LinkedHashMap<>(); + for (Map.Entry<String, String> entry : entries) { + sortedMap.put(entry.getKey(), entry.getValue()); + } + return sortedMap; + } /** * @Description: ������������������������������ @@ -186,7 +976,6 @@ String endTime = DateUtils.dateToDateString(endDate, "yyyy-MM-dd"); String time = startTime + " - " + endTime; //������������������ - Double AQINum = 0d; Double PM25Num = 0d; Double PM10Num = 0d; Double SO2Num = 0d; @@ -194,8 +983,7 @@ Double CONum = 0d; Double O3Num = 0d; Double TVOCNum = 0d; - //������AQI,PM2.5,PM10,SO2,NO2,CO,O3,TVOC��������� - Double AQISum = 0d; + //������PM2.5,PM10,SO2,NO2,CO,O3,TVOC��������� Double PM25Sum = 0d; Double PM10Sum = 0d; Double SO2Sum = 0d; @@ -241,18 +1029,6 @@ TVOCSum = MathUtils.add(TVOCSum, Double.valueOf(TVOC.toString())); TVOCNum++; } - //���AQI - int aqi = AQIUtils.hourlyAqi(valueMap); - if (aqi != 0) { - AQISum += Double.valueOf(aqi); - AQINum++; - } - } - //������aqi������ - if (AQINum != 0d) { - Double AQID = AmendUtils.sciCal(AQISum / AQINum, 0); - int AQIAvg = new Double(AQID).intValue(); - dto.setAQI(AQIAvg); } //������PM2.5������ if (PM25Num != 0d) { @@ -294,6 +1070,16 @@ Double TVOCAvg = AmendUtils.sciCal(TVOCSum / TVOCNum, 2); dto.setA99054(TVOCAvg); } + //������AQI + Map<String,Object> sixParamMap = new HashMap<>(); + sixParamMap.put("a05024",dto.getA05024()); + sixParamMap.put("a21004",dto.getA21004()); + sixParamMap.put("a21005",dto.getA21005()); + sixParamMap.put("a34002",dto.getA34002()); + sixParamMap.put("a34004",dto.getA34004()); + sixParamMap.put("a21026",dto.getA21026()); + AQI aqi = AQIUtils.dailyAQI(sixParamMap); + dto.setAQI(aqi.getAQIValue()); dto.setDeviceName(deviceName); dto.setTime(time); dtos.add(dto); @@ -309,37 +1095,105 @@ * @Author: ��������� * @Date: 2021/9/28 */ - private <T> List<MonitorPointDataDisplayDTO> calculateReportData(Map<String, T> macDataMap, Map<String, Device> deviceMap, Date... date) { + private <T> List<MonitorPointDataDisplayDTO> calculateReportData(Map<String, T> macDataMap, Map<String, Device> deviceMap, String reportType, Date... date) { List<MonitorPointDataDisplayDTO> dtos = new ArrayList<>(); - macDataMap.forEach((key, valueObject) -> { - MonitorPointDataDisplayDTO dto = new MonitorPointDataDisplayDTO(); - dto.setMac(key); - //���������map - Map<String, Object> valueMap; - //���������������value��������� - Object valueO = ClassUtils.getPropertyValue(valueObject, "value"); - if (valueO == null) - return; - String value = (String) valueO; - valueMap = JSON.parseObject(value, Map.class); + Set<String> strings = macDataMap.keySet(); + for (String key : strings) { + if (reportType.equals("0")){ + List<HistoryHourly> t = (List<HistoryHourly>)macDataMap.get(key); + for (HistoryHourly historyHourly : t) { + MonitorPointDataDisplayDTO dto = new MonitorPointDataDisplayDTO(); + String value = historyHourly.getValue(); + Map map = JSON.parseObject(value, Map.class); + String time = DateUtils.dateToDateString(historyHourly.getTime(), "yyyy-MM-dd HH:00:00"); + injectDataToDto(map, false, dto, reportType); + dto.setTime(time); + dto.setMac(key); + dto.setDeviceName(deviceMap.get(key).getName()); + dtos.add(dto); + } + } + if (reportType.equals("1")){ + List<HistoryDaily> t = (List<HistoryDaily>)macDataMap.get(key); + for (HistoryDaily historyDaily : t) { + MonitorPointDataDisplayDTO dto = new MonitorPointDataDisplayDTO(); + String value = historyDaily.getValue(); + Map map = JSON.parseObject(value, Map.class); + String time = DateUtils.dateToDateString(historyDaily.getTime(), "yyyy-MM-dd"); + injectDataToDto(map, false, dto, reportType); + dto.setTime(time); + dto.setMac(key); + dto.setDeviceName(deviceMap.get(key).getName()); + dtos.add(dto); + } + + } + if (reportType.equals("2")){ + HistoryWeekly historyWeekly = (HistoryWeekly)macDataMap.get(key); + MonitorPointDataDisplayDTO dto = new MonitorPointDataDisplayDTO(); + String value = historyWeekly.getValue(); + Map map = JSON.parseObject(value, Map.class); + String time = DateUtils.dateToDateString(historyWeekly.getTime(), "yyyy-MM-dd"); + injectDataToDto(map, false, dto, reportType); + dto.setTime(time); + dto.setMac(key); + dto.setDeviceName(deviceMap.get(key).getName()); + dtos.add(dto); + + } + if (reportType.equals("3")){ + List<HistoryMonthly> t = (List<HistoryMonthly>)macDataMap.get(key); + for (HistoryMonthly historyMonthly : t) { + MonitorPointDataDisplayDTO dto = new MonitorPointDataDisplayDTO(); + String value = historyMonthly.getValue(); + Map map = JSON.parseObject(value, Map.class); + String time = DateUtils.dateToDateString(historyMonthly.getTime(), "yyyy-MM"); + injectDataToDto(map, false, dto, reportType); + dto.setTime(time); + dto.setMac(key); + dto.setDeviceName(deviceMap.get(key).getName()); + dtos.add(dto); + } + } + } + +// macDataMap.forEach((key, valueObject) -> { +// MonitorPointDataDisplayDTO dto = new MonitorPointDataDisplayDTO(); +// dto.setMac(key); +// //���������map +// Map<String, Object> valueMap; +// List<Map<String, Object>> list; +// //���������������value��������� +// Object valueO = ClassUtils.getPropertyValue(valueObject, "value"); +// if (valueO == null) +// return; +// String value = (String) valueO; +// list = JSON.parseObject(value, List.class); +// for (Map<String, Object> map : list) { +// String o = map.get("value").toString(); +// valueMap = JSON.parseObject(o, Map.class); +// injectDataToDto(valueMap, false, dto, reportType); +// String deviceName = deviceMap.get(key).getName(); +// dto.setDeviceName(deviceName); +// String startTime = DateUtils.dateToDateString((Date) map.get("time"), "yyyy-MM-dd HH:mm:ss"); +// dto.setTime(startTime); +// dtos.add(dto); +// } //������������������ - String deviceName = deviceMap.get(key).getName(); - dto.setDeviceName(deviceName); + //������������,������������������������������������������������������������������������������������������������������ - String startTime = ""; - if (valueObject instanceof HistoryHourly && date.length == 1) - startTime = DateUtils.dateToDateString(date[0], "yyyy-MM-dd HH:mm:ss"); - else if (valueObject instanceof HistoryDaily && date.length == 1) - startTime = DateUtils.dateToDateString(date[0], "yyyy-MM-dd"); - else if (valueObject instanceof HistoryWeekly && date.length == 2) - startTime = DateUtils.dateToDateString(date[0], "yyyy-MM-dd") + " -- " + DateUtils.dateToDateString(date[1], "yyyy-MM-dd"); - else if (valueObject instanceof HistoryMonthly && date.length == 1) - startTime = DateUtils.dateToDateString(date[0], "yyyy-MM"); - dto.setTime(startTime); +// String startTime = ""; +// if (valueObject instanceof HistoryHourly && date.length == 1) +// startTime = DateUtils.dateToDateString(date[0], "yyyy-MM-dd HH:mm:ss"); +// else if (valueObject instanceof HistoryDaily && date.length == 1) +// startTime = DateUtils.dateToDateString(date[0], "yyyy-MM-dd"); +// else if (valueObject instanceof HistoryWeekly && date.length == 2) +// startTime = DateUtils.dateToDateString(date[0], "yyyy-MM-dd") + " -- " + DateUtils.dateToDateString(date[1], "yyyy-MM-dd"); +// else if (valueObject instanceof HistoryMonthly && date.length == 1) +// startTime = DateUtils.dateToDateString(date[0], "yyyy-MM"); +// dto.setTime(startTime); //������������ - injectDataToDto(valueMap, false, dto); - dtos.add(dto); - }); +// }); return dtos; } @@ -351,7 +1205,7 @@ * @Author: ��������� * @Date: 2021/9/28 */ - private void injectDataToDto(Map<String, Object> valueMap, boolean flag, MonitorPointDataDisplayDTO dto) { + private void injectDataToDto(Map<String, Object> valueMap, boolean flag, MonitorPointDataDisplayDTO dto, String reportType) { //������CO String COFlag = (String) valueMap.get("a21005-Flag"); Object COObject = valueMap.get("a21005"); @@ -402,9 +1256,13 @@ dto.setA05024(new Double(AmendUtils.sciCal(O3, 0)).intValue()); } //������AQI - int aqi = AQIUtils.hourlyAqi(valueMap); - if (aqi != 0) - dto.setAQI(aqi); + Integer aqi; + if (reportType.equals(Constants.HOURLY_REPORT)) { + aqi = AQIUtils.hourlyAQI(valueMap).getAQIValue(); + } else { + aqi = AQIUtils.dailyAQI(valueMap).getAQIValue(); + } + dto.setAQI(aqi); } @@ -430,6 +1288,11 @@ dto.setComIndex(comIndex); }); } - + private boolean subStr(String mac){ + if(StringUtils.isNotEmpty(mac)&&mac.contains(",avg")){ + return true; + } + return false; + } } -- Gitblit v1.8.0