| | |
| | | import com.moral.service.SensorService; |
| | | import com.moral.service.SensorUnitService; |
| | | import com.moral.service.WeatherService; |
| | | import com.moral.util.AQICalculation; |
| | | import com.moral.util.MyLatLng; |
| | | import com.moral.util.TempAllocationUtils; |
| | | |
| | | import com.moral.util.mapUtils; |
| | | import com.moral.util.*; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | List<Map<String, Object>> list = new ArrayList(); |
| | | Map device = deviceService.getAllFieldByMac(parameters); |
| | | Map monitorPointMap = monitorPointService.selectAllById(device.get("monitor_point_id").toString()); |
| | | Map<String, String> sensotMap = sensorService.getSensorsMap(parameters); |
| | | List<Map<String, Object>> device_sensorList = sensorService.getSensorByDeviceId(device.get("id").toString()); |
| | | Map<String, Object> device_sensorUnit_map = new HashMap<>(); |
| | | for (Map<String, Object> device_sensorMap : device_sensorList) { |
| | | device_sensorUnit_map.put(device_sensorMap.get("sensor_key").toString(),device_sensorMap.get("unit")); |
| | | } |
| | | Map<String, String> sensorMap = sensorService.getSensorsMap(parameters); |
| | | if (startTime.length()==10&&endTime.length()==10){ |
| | | //获取当日时间 |
| | | Date dd = new Date(); |
| | |
| | | //获取系统当前时间 |
| | | String nowTime = sim.format(dd); |
| | | int days = endTime.compareTo(nowTime); |
| | | System.out.println(days); |
| | | //System.out.println(days); |
| | | List<String> dayList = DatesUtil.findDaysStr(startTime,endTime); |
| | | //System.out.println("dayList:"+dayList); |
| | | /*if (days<0){ |
| | | Date date=null; |
| | | try { |
| | |
| | | sameDayHourlyList = historyHourlyService.getDataByTimeSlot(mac,nowTime,currentTime); |
| | | } |
| | | List<Map<String, Object>> dataList = historyDailyService.getDataByTimeSlot(mac,startTime,endTime); |
| | | Set<String> keys = sensotMap.keySet(); |
| | | if (dataList.isEmpty()){ |
| | | return null; |
| | | } |
| | | Set<String> keys = sensorMap.keySet(); |
| | | for (String key:keys) { |
| | | Map<String,Object> oneSensorMap = new LinkedHashMap<>(); |
| | | oneSensorMap.put("monitorPointName",monitorPointMap.get("name")); |
| | | oneSensorMap.put("deviceName",device.get("name")); |
| | | oneSensorMap.put("sersorKey",sensotMap.get(key)); |
| | | for (Map<String, Object> dataMap: dataList) { |
| | | JSONObject dataJson = JSONObject.parseObject(dataMap.get("json").toString()); |
| | | oneSensorMap.put(dataMap.get("time").toString().substring(0,10),dataJson.getJSONArray(key).get(2)); |
| | | oneSensorMap.put("sersorKey",sensorMap.get(key)+"("+device_sensorUnit_map.get(key)+")"); |
| | | for (String day:dayList) { |
| | | for (Map<String, Object> dataMap: dataList) { |
| | | JSONObject dataJson = JSONObject.parseObject(dataMap.get("json").toString()); |
| | | if (dataMap.get("time").toString().equals(day+" 00:00:00.0")){ |
| | | oneSensorMap.put(dataMap.get("time").toString().substring(0,10),dataJson.getJSONArray(key).get(2)); |
| | | break; |
| | | }else { |
| | | continue; |
| | | } |
| | | } |
| | | if(!oneSensorMap.containsKey(day)){ |
| | | oneSensorMap.put(day,""); |
| | | } |
| | | } |
| | | |
| | | Double avg = 0.0; |
| | | if (sameDayHourlyList != null){ |
| | | for (Map sameDayHourlyMap:sameDayHourlyList){ |
| | |
| | | endTime_sb.replace(10,11," "); |
| | | endTime = endTime_sb.toString()+":00:00"; |
| | | |
| | | List<String> hoursList = DatesUtil.findHoursStr(startTime,endTime); |
| | | //System.out.println("hoursList:"+hoursList); |
| | | |
| | | List<Map<String, Object>> hourlyList = historyHourlyService.getDataByTimeSlot(mac,startTime,endTime); |
| | | Set<String> keys = sensotMap.keySet(); |
| | | if (hourlyList.isEmpty()){ |
| | | return null; |
| | | } |
| | | Set<String> keys = sensorMap.keySet(); |
| | | for (String key:keys) { |
| | | Map<String,Object> oneSensorMap = new LinkedHashMap<>(); |
| | | oneSensorMap.put("monitorPointName",monitorPointMap.get("name")); |
| | | oneSensorMap.put("deviceName",device.get("name")); |
| | | oneSensorMap.put("sersorKey",sensotMap.get(key)); |
| | | for (Map<String, Object> hourlyMap: hourlyList) { |
| | | oneSensorMap.put("sersorKey",sensorMap.get(key)+"("+device_sensorUnit_map.get(key)+")"); |
| | | for (String hour:hoursList) { |
| | | for (Map<String, Object> hourlyMap: hourlyList) { |
| | | JSONObject dataJson = JSONObject.parseObject(hourlyMap.get("json").toString()); |
| | | if (hourlyMap.get("time").toString().equals(hour+".0")){ |
| | | oneSensorMap.put(hourlyMap.get("time").toString().substring(0,19),dataJson.getJSONArray(key).get(2)); |
| | | break; |
| | | }else { |
| | | continue; |
| | | } |
| | | } |
| | | if(!oneSensorMap.containsKey(hour)){ |
| | | oneSensorMap.put(hour,""); |
| | | } |
| | | } |
| | | /*for (Map<String, Object> hourlyMap: hourlyList) { |
| | | JSONObject hourlyJson = JSONObject.parseObject(hourlyMap.get("json").toString()); |
| | | oneSensorMap.put(hourlyMap.get("time").toString().substring(0,19),hourlyJson.getJSONArray(key).get(2)); |
| | | |
| | | } |
| | | }*/ |
| | | list.add(oneSensorMap); |
| | | } |
| | | }else { |