From dc7924a24a630ef9b0ca7cfeaf1249e52736cc4f Mon Sep 17 00:00:00 2001 From: jpy <812110275@qq.com> Date: Sat, 27 May 2023 16:45:58 +0800 Subject: [PATCH] test --- screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java | 109 ++++++++++++++++++++++++++---------------------------- 1 files changed, 53 insertions(+), 56 deletions(-) diff --git a/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java index 7c66607..8c42804 100644 --- a/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java +++ b/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java @@ -2,10 +2,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.ISqlSegment; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments; -import com.baomidou.mybatisplus.core.conditions.segments.NormalSegmentList; import com.moral.api.config.mybatis.MybatisPlusConfig; import com.moral.api.entity.*; import com.moral.api.mapper.HistoryFiveMinutelyMapper; @@ -25,6 +22,7 @@ import com.moral.util.DateUtils; import com.moral.util.MybatisPLUSUtils; import io.lettuce.core.GeoCoordinates; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -41,6 +39,7 @@ * @since 2021-07-15 */ @Service +@Slf4j public class HistoryFiveMinutelyServiceImpl extends ServiceImpl<HistoryFiveMinutelyMapper, HistoryFiveMinutely> implements HistoryFiveMinutelyService { @Autowired @@ -77,7 +76,7 @@ } //��������������������������������� List<DeviceAndFiveMinuteDataDTO> dtos = new ArrayList<>(); - if (form.getChooseTime().equals("true")){ + if (form.getChooseTime().equals("true")) { String time = form.getTime(); String timeUnits = DateUtils.stringToDateString(time, "yyyy-MM-dd HH:mm", DateUtils.yyyyMM_EN); for (Device device : devices) { @@ -147,19 +146,18 @@ // List<WindData> windData = historyFiveMinutelyMapper.getAreaWindData(params); // return getWindData(windData); String chooseTime = params.get("chooseTime").toString(); - List<WindData> windData=null; - if (chooseTime.equals("true")){ + List<WindData> windData = null; + if (chooseTime.equals("true")) { String time = params.get("time").toString(); String timeUnits = DateUtils.stringToDateString(time, "yyyy-MM-dd HH:mm", DateUtils.yyyyMM_EN); params.put("timeUnits", timeUnits); windData = historyHourlyMapper.getArea(params); - }else { + } else { String timeUnits = DateUtils.dateToDateString(new Date(), DateUtils.yyyyMM_EN); params.put("timeUnits", timeUnits); //������������ windData = historyFiveMinutelyMapper.getAreaWindData(params); } - return getWindData(windData); } @@ -170,24 +168,24 @@ // Map<String, Object> datas = queryLastDataByMac(mac); String chooseTime = params.get("chooseTime").toString(); String mac = params.get("mac").toString(); - Map<String, Object> datas=null; - if (chooseTime.equals("true")){ + Map<String, Object> datas = null; + if (chooseTime.equals("true")) { String time = params.get("time").toString(); String timeUnits = DateUtils.stringToDateString(time, "yyyy-MM-dd HH:mm", DateUtils.yyyyMM_EN); String dbDataStr = historyHourlyMapper.queryLastHourlyMac(mac, time, timeUnits); - if (dbDataStr==null){ + if (dbDataStr == null) { return null; } // String dbDataStr = historyFiveMinutelyMapper.queryLastFiveMinutely(mac, time, timeUnits); datas = JSON.parseObject(dbDataStr, HashMap.class); - datas.put("dataTime",time); - }else { + datas.put("dataTime", time); + } else { datas = queryLastDataByMac(mac); } //������������������ Map<String, Object> result = new HashMap<>(); //������������������code������ - List<String> sensorCodes = Arrays.asList("a34004", "a34002", "a21005", "a21004", "a21026", "a05024", "a99054","a01008","a01007"); + List<String> sensorCodes = Arrays.asList("a34004", "a34002", "a21005", "a21004", "a21026", "a05024", "a99054", "a01008", "a01007"); //������������������ Device device = deviceService.getDeviceUnitAlramInforByMac(mac); //��������������������������� @@ -198,25 +196,25 @@ if (dataO != null) { String data = String.valueOf(dataO); //������������ - if (!sensor.getShowUnitKey().equals(sensor.getUnitKey()) ) + if (!sensor.getShowUnitKey().equals(sensor.getUnitKey())) data = UnitConvertUtils.calculate(data, sensor.getFormula()); //������������ - data = data +" "+ sensor.getShowUnit(); + data = data + " " + sensor.getShowUnit(); result.put(sensor.getCode(), data); - }else{ - result.put(sensor.getCode(),"-"); + } else { + result.put(sensor.getCode(), "-"); } } //������������������ - result.put("name",device.getName()); + result.put("name", device.getName()); //������������ - result.put("dataTime",datas.get("dataTime")); + result.put("dataTime", datas.get("dataTime")); //������ return orderSixParam(result); } //��������������������������������� - private Map<String,Object> orderSixParam(Map<String,Object> data){ + private Map<String, Object> orderSixParam(Map<String, Object> data) { LinkedHashMap result = new LinkedHashMap(); Object PM2_5 = data.get("a34004"); Object PM10 = data.get("a34002"); @@ -228,26 +226,26 @@ Object a01007 = data.get("a01007"); Object name = data.get("name"); Object time = data.get("dataTime"); - if(name!=null) - result.put("������",name); - if(PM2_5!=null) - result.put("PM2.5",PM2_5); - if(PM10!=null) - result.put("PM10",PM10); - if(SO2!=null) - result.put("���������������SO������",SO2); - if(NO2!=null) - result.put("���������������NO������",NO2); - if(CO!=null) - result.put("���������������CO���",CO); - if(O3!=null) - result.put("���������O������",O3); - if(time!=null) - result.put("������",time); - if (a01008!=null) - result.put("������",a01008); - if (a01007!=null) - result.put("������",a01007); + if (name != null) + result.put("������", name); + if (PM2_5 != null) + result.put("PM2.5", PM2_5); + if (PM10 != null) + result.put("PM10", PM10); + if (SO2 != null) + result.put("���������������SO������", SO2); + if (NO2 != null) + result.put("���������������NO������", NO2); + if (CO != null) + result.put("���������������CO���", CO); + if (O3 != null) + result.put("���������O������", O3); + if (time != null) + result.put("������", time); + if (a01008 != null) + result.put("������", a01008); + if (a01007 != null) + result.put("������", a01007); return result; } @@ -349,24 +347,23 @@ laLaMap.put("maxLa", lama); laLaMap.put("minLa", lami); - Double lo1 = lomi - length * 0.00001141; -// Double lo1 = lomi - length * 0.000001141 * 2; - Double lo2 = loma + length * 0.00001141; -// Double lo2 = loma + length * 0.000001141 * 2; -// Double la2 = lami - length * 0.000000899 * 2; - Double la2 = lami - length * 0.00000899; -// Double la1 = lama + length * 0.000000899 * 2; - Double la1 = lama + length * 0.00000899; + //Double lo1 = lomi - length * 0.00001141; + Double lo1 = lomi - length * 0.000001141 * 2; + //Double lo2 = loma + length * 0.00001141; + Double lo2 = loma + length * 0.000001141 * 2; + Double la2 = lami - length * 0.000000899 * 2; + //Double la2 = lami - length * 0.00000899; + Double la1 = lama + length * 0.000000899 * 2; + //Double la1 = lama + length * 0.00000899; - double dx = 0.00001141 * perdlen; - double dy = 0.00000899 * perdlen; + //double dx = 0.00001141 * perdlen; + //double dy = 0.00000899 * perdlen; -// double dx = 0.000001141 * perdlen * 2; -// double dy = 0.000000899 * perdlen * 2; + double dx = 0.000001141 * perdlen * 2; + double dy = 0.000000899 * perdlen * 2; int nx = (int) Math.floor((lo2 - lo1) / dx); int ny = (int) Math.floor((la1 - la2) / dy); - List<Double> uList = new ArrayList<>(); List<Double> vList = new ArrayList<>(); @@ -374,6 +371,7 @@ int y; for (int i = 0; i < mapList.size(); i++) { + Double lo = (Double) mapList.get(i).get("lo"); Double la = (Double) mapList.get(i).get("la"); x = (int) Math.floor((lo - lo1) / dx); @@ -423,6 +421,7 @@ } } } + String uData = "\"" + "data" + "\"" + ": " + uList; String vData = "\"" + "data" + "\"" + ": " + vList; @@ -483,6 +482,4 @@ MybatisPlusConfig.tableName.remove(); return result; } - - } -- Gitblit v1.8.0