| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.awt.geom.GeneralPath; |
| | | import java.awt.geom.Point2D; |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),vo); |
| | | } |
| | | |
| | | @GetMapping("UAVTest") |
| | | public ResultMessage UAVTest(BigDecimal lat, BigDecimal lon, String batch){ |
| | | historySecondUavService.UAVTest(lat, lon, batch); |
| | | return new ResultMessage(); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.moral.api.pojo.dto.uav.UAVQueryTimeSlotDTO; |
| | | import com.moral.api.pojo.form.uav.UAVQueryTimeSlotForm; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | List<HistorySecondUav> queryDataByBatch(String batch); |
| | | |
| | | |
| | | boolean UAVTest(BigDecimal lat, BigDecimal lon, String batch); |
| | | } |
| | |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.time.Duration; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.OptionalDouble; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.DoubleStream; |
| | | |
| | |
| | | CityAqiMonthly cityAqiMonthly = cityAqiMonthlyMapper.selectOne(cityAqiMonthlyQueryWrapper); |
| | | Double compositeIndex = null; |
| | | String compositeIndexYearOnYear = null; |
| | | Integer pm25 = null; |
| | | Double pm25 = null; |
| | | String pm25YearOnYear = null; |
| | | if (cityAqiMonthly != null) { |
| | | Map<String, Object> aqiMap = JSONObject.parseObject(cityAqiMonthly.getValue(), Map.class); |
| | |
| | | |
| | | //3.PM2.5浓度 |
| | | if (aqiMap.get("PM2_5") != null) { |
| | | pm25 = Integer.parseInt(aqiMap.get("PM2_5").toString()); |
| | | pm25 = Objects.nonNull(aqiMap.get("PM2_5"))?Double.parseDouble(aqiMap.get("PM2_5").toString()):0d; |
| | | } |
| | | currentRankingResult.put("PM2_5", pm25 + "ug/m³"); |
| | | |
| | |
| | | Map<Integer, Map<String, Object>> monthlyCumulativeResult = null; |
| | | Double cityCompositeIndex = null; |
| | | String cityCompositeIndexYearOnYear = null; |
| | | Integer cityPM25 = null; |
| | | Double cityPM25 = null; |
| | | String cityPM25YearOnYear = null; |
| | | if (!"1".equals(month)) { |
| | | Map<String, Object> cumulativeRankingResult = new HashMap<>(); |
| | |
| | | cityCompositeIndexYearOnYear = cityMap.get("compositeIndex_yearOnYear").toString(); |
| | | } |
| | | //地级市PM2.5 |
| | | cityPM25 = (int) Double.parseDouble(cityMap.get("PM2_5").toString()); |
| | | cityPM25 = Double.parseDouble(cityMap.get("PM2_5").toString()); |
| | | if (cityMap.get("PM2_5_yearOnYear") != null) { |
| | | cityPM25YearOnYear = cityMap.get("PM2_5_yearOnYear").toString(); |
| | | } |
| | |
| | | * @param pm25YearOnYear 中心城区(地级市)pm2.5同比 |
| | | * @description 获取本期所有县市区与中心城区(地级市)因子对比情况 |
| | | */ |
| | | private Map<String, Object> getAreaCurrentMonthResult(Map<Integer, String> areasMap, List<CityAqiMonthly> areaData, Double compositeIndex, String compositeIndexYearOnYear, Integer pm25, String pm25YearOnYear) { |
| | | private Map<String, Object> getAreaCurrentMonthResult(Map<Integer, String> areasMap, List<CityAqiMonthly> areaData, Double compositeIndex, String compositeIndexYearOnYear, Double pm25, String pm25YearOnYear) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("compositeIndex", compositeIndex); |
| | | result.put("compositeIndexYearOnYear", compositeIndexYearOnYear); |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.HistorySecondUavMapper; |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean UAVTest(BigDecimal lat, BigDecimal lon, String batch) { |
| | | List<HistorySecondUav> list = new ArrayList<>(); |
| | | |
| | | QueryWrapper<HistorySecondUav> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("batch", batch); |
| | | wrapper.select("value,mac,time,organization_id"); |
| | | wrapper.orderByAsc("time"); |
| | | List<HistorySecondUav> datas = historySecondUavMapper.selectList(wrapper); |
| | | Date time =DateUtils.addDays(datas.get(2).getTime(),0); |
| | | //String bat = "2023-08-08 14:42:20"; |
| | | for(HistorySecondUav g : datas){ |
| | | HistorySecondUav historySecondUav = new HistorySecondUav(); |
| | | historySecondUav.setTime(DateUtils.addDays(g.getTime(),0)); |
| | | historySecondUav.setMac(g.getMac()); |
| | | historySecondUav.setBatch(time); |
| | | historySecondUav.setOrganizationId(g.getOrganizationId()); |
| | | Map<String, Object> data = JSON.parseObject(g.getValue(), Map.class); |
| | | Map<String, Object> dataResult = new HashMap<>(); |
| | | dataResult = data; |
| | | dataResult.put("flylat",Objects.isNull(data.get("flylat"))||data.get("flylat").toString().equals("0")?0d:Double.parseDouble(String.format("%.10f",Double.parseDouble(data.get("flylat").toString())+lat.doubleValue()))); |
| | | dataResult.put("flylon",Objects.isNull(data.get("flylon"))||data.get("flylon").toString().equals("0")?0d:Double.parseDouble(String.format("%.10f",Double.parseDouble(data.get("flylon").toString())+lon.doubleValue()))); |
| | | /*if(Objects.nonNull(data.get("a21026"))&& !data.get("a21026").toString().equals("0")){ |
| | | Double a21026D = Double.parseDouble(data.get("a21026").toString()); |
| | | if( a21026D>15){ |
| | | a21026D = a21026D -10; |
| | | } |
| | | dataResult.put("a21026",Double.parseDouble(String.format("%.4f",a21026D))); |
| | | } |
| | | if(Objects.nonNull(data.get("a21004"))&& !data.get("a21004").toString().equals("0")){ |
| | | Double a21024D = Double.parseDouble(data.get("a21004").toString()); |
| | | if( a21024D>100){ |
| | | a21024D = a21024D -100; |
| | | } |
| | | dataResult.put("a21004",Double.parseDouble(String.format("%.4f",a21024D))); |
| | | }*/ |
| | | historySecondUav.setValue(JSONObject.toJSONString(dataResult)); |
| | | list.add(historySecondUav); |
| | | } |
| | | this.saveBatch(list); |
| | | return true; |
| | | } |
| | | } |
| | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.text.NumberFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | List<Map<String, Object>> devices = deviceService.getDevicesByOrganizationId(organizationId); |
| | | Set<Map<String, Object>> result = new HashSet<>(); |
| | | for (Map<String, Object> device : devices) { |
| | | List<Map<String, Object>> professions = (List<Map<String, Object>>) device.get("professions"); |
| | | result.addAll(professions); |
| | | if(Objects.nonNull(device)&&Objects.nonNull(device.get("professions"))&&device.containsKey("professions")){ |
| | | List<Map<String, Object>> professions = (List<Map<String, Object>>) device.get("professions"); |
| | | result.addAll(professions); |
| | | } |
| | | } |
| | | return result; |
| | | } |