jinpengyong
2023-10-10 4319627cf67d19093a18ff724c21782e34fc7a26
screen-api/src/main/java/com/moral/api/service/impl/ServicesScopeServiceImpl.java
@@ -53,6 +53,9 @@
    @Autowired
    private HistoryHourlyMapper historyHourlyMapper;
    @Autowired
    private HistoryHourlyService historyHourlyService;
    @Override
    public List<Map<String, Object>> getDateByOrgIdAndCondition(Map map) {
        int orgId = Integer.parseInt(map.get("organization_id").toString());
@@ -157,11 +160,11 @@
            }
        }
        if (type.equals("hourly")){
            Date houtly_time = DateUtils.getDate(time+":00:00",DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
            Date hourly_time = DateUtils.getDate(time+":00:00",DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
            QueryWrapper<HistoryHourly> wrapper = new QueryWrapper<>();
            wrapper.in("mac", deviceMacs);
            wrapper.eq("time", houtly_time);
            List<HistoryHourly> historyHourlies = historyHourlyMapper.selectList(wrapper);
            wrapper.eq("time", hourly_time);
            List<HistoryHourly> historyHourlies = historyHourlyService.getHourlyDataByMacs(deviceMacs,time);
            for (HistoryHourly historyHourly : historyHourlies) {
                historyDataMap.put(historyHourly.getMac(), JSON.parseObject(JSON.toJSONString(historyHourly), Map.class));
            }
@@ -206,17 +209,20 @@
                        Device device = devicesMap.get(key);
                        double getmeter1 = LongitudeAndLatitudeUtils.getmeter(point_lon, point_lat, device.getLongitude(), device.getLatitude());
                        if (getmeter1<getmeter){
                            getmeter=getmeter1;
                            near_mac = device.getMac();
                        }
                    }
                    Map<String, Object> map = historyDataMap.get(near_mac);
                    String value = map.get("value").toString();
                    JSONObject jsonObject = JSONObject.parseObject(value);
                    Double sensorValue = Double.parseDouble(jsonObject.get(sensorCode).toString());
                    resultMap.put("lon",point_lon);
                    resultMap.put("lat",point_lat);
                    resultMap.put("value",sensorValue);
                    resultList.add(resultMap);
                    if (map != null){
                        String value = map.get("value").toString();
                        JSONObject jsonObject = JSONObject.parseObject(value);
                        Double sensorValue = Double.parseDouble(jsonObject.get(sensorCode).toString());
                        resultMap.put("lon",point_lon);
                        resultMap.put("lat",point_lat);
                        resultMap.put("value",sensorValue);
                        resultList.add(resultMap);
                    }
                }
                point_lat = DoubleUtils.add(point_lat,lat_ontShare);
            }