| | |
| | | //å端设å¤ä¼ è¾çæ æå¼ |
| | | const val INVALID_DATA_4_BYTE = "FFFFFFFF" |
| | | const val INVALID_DATA_2_BYTE = "FFFF" |
| | | |
| | | /** |
| | | * 2021-11-17 ç½æ ¼åçæµå åä¼åç³»æ°ï¼åºäºé¢å¤çæ°æ®ï¼ |
| | | */ |
| | | val scaleMap = mutableMapOf<Int, List<Float>>().apply { |
| | | // hour NO2 CO H2S SO2 O3 PM25 PM10 VOC |
| | | put(0 , listOf(1.260820655f, 1.216667552f, 1.125932298f, 1.156929588f, 0.856318541f, 1.0f, 1.0f, 1.019853828f)) |
| | | put(1 , listOf(1.216383597f, 1.227863417f, 1.136368119f, 1.150858195f, 0.864118430f, 1.0f, 1.0f, 1.021218796f)) |
| | | put(2 , listOf(1.210361269f, 1.227450386f, 1.150780492f, 1.168038461f, 0.865243847f, 1.0f, 1.0f, 1.020880802f)) |
| | | put(3 , listOf(1.163439204f, 1.189908110f, 1.235243547f, 1.211935503f, 0.874802600f, 1.0f, 1.0f, 1.021633591f)) |
| | | put(4 , listOf(1.170443945f, 1.177190080f, 1.233442915f, 1.216684222f, 0.873063632f, 1.0f, 1.0f, 1.022230877f)) |
| | | put(5 , listOf(1.258022303f, 1.128902342f, 1.326003848f, 1.263151458f, 0.856416663f, 1.0f, 1.0f, 1.022758145f)) |
| | | put(6 , listOf(1.403632463f, 1.018045753f, 1.348386592f, 1.424135126f, 0.833216869f, 1.0f, 1.0f, 1.018346466f)) |
| | | put(7 , listOf(1.122379332f, 0.921730659f, 1.413365730f, 1.469299523f, 0.884801243f, 1.0f, 1.0f, 1.004337859f)) |
| | | put(8 , listOf(0.713145787f, 0.891658820f, 1.254278025f, 1.275998356f, 1.031824600f, 1.0f, 1.0f, 0.988160256f)) |
| | | put(9 , listOf(0.523493283f, 0.840459016f, 1.136001943f, 0.992222358f, 1.180035037f, 1.0f, 1.0f, 0.977086373f)) |
| | | put(10, listOf(0.436882489f, 0.785553638f, 0.902852651f, 0.745412781f, 1.295137300f, 1.0f, 1.0f, 0.969271259f)) |
| | | put(11, listOf(0.385539681f, 0.788473715f, 0.810406932f, 0.585739873f, 1.390259619f, 1.0f, 1.0f, 0.965946441f)) |
| | | put(12, listOf(0.378202225f, 0.766903352f, 0.882086383f, 0.502122477f, 1.409121756f, 1.0f, 1.0f, 0.963580572f)) |
| | | put(13, listOf(0.393040546f, 0.728230590f, 0.782751681f, 0.438597765f, 1.378133348f, 1.0f, 1.0f, 0.963818142f)) |
| | | put(14, listOf(0.434686411f, 0.772791882f, 0.642479738f, 0.443393658f, 1.301282617f, 1.0f, 1.0f, 0.968305562f)) |
| | | put(15, listOf(0.522808107f, 0.831631952f, 0.557282786f, 0.554966933f, 1.182584786f, 1.0f, 1.0f, 0.977440538f)) |
| | | put(16, listOf(0.727836191f, 0.889160481f, 0.594713483f, 0.832742429f, 1.024609679f, 1.0f, 1.0f, 0.990246259f)) |
| | | put(17, listOf(1.028024212f, 0.938403996f, 0.671609876f, 1.070428218f, 0.911547286f, 1.0f, 1.0f, 0.999249061f)) |
| | | put(18, listOf(1.330053971f, 1.016668065f, 0.743443154f, 1.095625581f, 0.847713841f, 1.0f, 1.0f, 1.006336597f)) |
| | | put(19, listOf(1.630871928f, 1.071485305f, 0.933527520f, 1.040253374f, 0.806748833f, 1.0f, 1.0f, 1.011638015f)) |
| | | put(20, listOf(1.559280145f, 1.092548718f, 1.022834535f, 1.079664302f, 0.815339533f, 1.0f, 1.0f, 1.014308338f)) |
| | | put(21, listOf(1.460621712f, 1.131760740f, 1.121104299f, 1.088876154f, 0.827697109f, 1.0f, 1.0f, 1.015988031f)) |
| | | put(22, listOf(1.357157189f, 1.155444400f, 1.184586476f, 1.085940877f, 0.841801847f, 1.0f, 1.0f, 1.018320115f)) |
| | | put(23, listOf(1.312873355f, 1.191067031f, 1.189618093f, 1.106982786f, 0.848180982f, 1.0f, 1.0f, 1.019044077f)) |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.domain.entity; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import javax.persistence.*; |
| | | |
| | | @Table(name = "real_time_data_grid_opt") |
| | | public class RealTimeDataGridOpt extends BaseRealTimeData { |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.domain.mapper |
| | | |
| | | import com.flightfeather.uav.domain.MyMapper |
| | | import com.flightfeather.uav.domain.entity.RealTimeDataGridOpt |
| | | import org.apache.ibatis.annotations.Mapper |
| | | |
| | | @Mapper |
| | | interface RealTimeDataGridOptMapper : MyMapper<RealTimeDataGridOpt?> |
| | |
| | | package com.flightfeather.uav.lightshare.service.impl |
| | | |
| | | import com.flightfeather.uav.common.scaleMap |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.common.utils.ExcelUtil |
| | | import com.flightfeather.uav.common.utils.FileExchange |
| | |
| | | import com.flightfeather.uav.socket.eunm.UWDeviceType |
| | | import com.github.pagehelper.PageHelper |
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook |
| | | import org.springframework.beans.BeanUtils |
| | | import org.springframework.stereotype.Service |
| | | import org.springframework.web.multipart.MultipartFile |
| | | import tk.mybatis.mapper.entity.Example |
| | |
| | | private val realTimeDataVehicleMapper: RealTimeDataVehicleMapper, |
| | | private val realTimeDataUavMapper: RealTimeDataUavMapper, |
| | | private val realTimeDataGridMapper: RealTimeDataGridMapper, |
| | | private val realTimeDataGridOptMapper: RealTimeDataGridOptMapper, |
| | | private val realTimeDataGridMinMapper: RealTimeDataGridMinMapper |
| | | ) : RealTimeDataService { |
| | | |
| | |
| | | var page = 1 |
| | | var total = -1 |
| | | var count = 0 |
| | | val sT = "2021-06-19 00:00:00" |
| | | val eT = "2021-10-21 00:00:00" |
| | | |
| | | println("------æ°æ®ä¼åstart------") |
| | | while (total == -1 || page <= total) { |
| | | // é¢å¤çåçç½æ ¼åæ°æ® |
| | | val p = PageHelper.startPage<RealTimeDataGrid>(page, 50000) |
| | | val dataList1 = realTimeDataGridMapper.selectByExample(Example(RealTimeDataGrid::class.java).apply { |
| | | createCriteria().andBetween("dataTime", "2021-06-19 00:00:00", "2021-10-21 00:00:00") |
| | | createCriteria().andBetween("dataTime", sT, eT) |
| | | }) |
| | | val res = getOriginData("0d0000000001", "2021-06-19 00:00:00", "2021-10-21 00:00:00", page, 50000) |
| | | // åå§æ°æ®ï¼H2Sï¼ |
| | | val res = getOriginData("0d0000000001", sT, eT, page, 50000) |
| | | val dataList2 = res.data ?: emptyList() |
| | | |
| | | total = p.pages |
| | |
| | | if (i >= dataList2.size) break |
| | | val d1 = dataList1[i] |
| | | val d2 = dataList2[i] |
| | | // 夿尿¶ |
| | | // 夿尿¶ï¼è·åå¯¹åºæ¶æ®µçä¼åç³»æ° |
| | | val h = LocalDateTime.ofInstant(d1.dataTime?.toInstant(), ZoneId.systemDefault()).hour |
| | | val scale = |
| | | val scaleList = scaleMap[h] ?: continue |
| | | d1.apply { |
| | | // åé¢å¤çåçå åï¼é¤H2Sï¼ä¹ç³»æ° |
| | | // åç¬æåå§çH2Sä¹ä»¥ç³»æ° |
| | | // æ´æ°ç§çº§å¼ |
| | | } |
| | | // val result = epwDataPrep.mDataPrep2(dataList) |
| | | // count += airDataRepository.savePrepData2(result) |
| | | no2 = no2?.times(scaleList[0]) |
| | | co = co?.times(scaleList[1]) |
| | | so2 = so2?.times(scaleList[3]) |
| | | o3 = o3?.times(scaleList[4]) |
| | | voc = voc?.times(scaleList[7]) |
| | | |
| | | // åç¬æåå§çH2Sä¹ä»¥ç³»æ° |
| | | h2s = d2.values?.get(2)?.factorData?.toFloat()?.times(scaleList[2]) |
| | | } |
| | | |
| | | // æ´æ°ç§çº§å¼ |
| | | val opt = RealTimeDataGridOpt() |
| | | BeanUtils.copyProperties(d1, opt) |
| | | count += realTimeDataGridOptMapper.insert(opt) |
| | | } |
| | | page++ |
| | | } |
| | | |
| | |
| | | <!-- <table tableName="air_real_time_data" domainObjectName="RealTimeData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="mission" domainObjectName="Mission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="el_minutevalue" domainObjectName="ElectricMinuteValue" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <table tableName="el_company_device" domainObjectName="CompanyDevice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> |
| | | <!-- <table tableName="el_company_device" domainObjectName="CompanyDevice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="co_complaint" domainObjectName="Complaint" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="co_assessment" domainObjectName="Assessment" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="real_time_data_grid" domainObjectName="RealTimeDataGrid" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | |
| | | <!-- <table tableName="device_info" domainObjectName="DeviceInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="factor_calibration" domainObjectName="FactorCalibration" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="real_time_data_grid_min" domainObjectName="RealTimeDataGridMin" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <table tableName="real_time_data_grid_opt" domainObjectName="RealTimeDataGridOpt" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> |
| | | </context> |
| | | </generatorConfiguration> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.flightfeather.uav.domain.mapper.RealTimeDataGridOptMapper"> |
| | | <resultMap id="BaseResultMap" type="com.flightfeather.uav.domain.entity.RealTimeDataGridOpt"> |
| | | <!-- |
| | | WARNING - @mbg.generated |
| | | --> |
| | | <id column="id" jdbcType="INTEGER" property="id" /> |
| | | <result column="device_code" jdbcType="VARCHAR" property="deviceCode" /> |
| | | <result column="latitude" jdbcType="DECIMAL" property="latitude" /> |
| | | <result column="longitude" jdbcType="DECIMAL" property="longitude" /> |
| | | <result column="altitude" jdbcType="REAL" property="altitude" /> |
| | | <result column="data_time" jdbcType="TIMESTAMP" property="dataTime" /> |
| | | <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
| | | <result column="NO2" jdbcType="REAL" property="no2" /> |
| | | <result column="CO" jdbcType="REAL" property="co" /> |
| | | <result column="H2S" jdbcType="REAL" property="h2s" /> |
| | | <result column="SO2" jdbcType="REAL" property="so2" /> |
| | | <result column="O3" jdbcType="REAL" property="o3" /> |
| | | <result column="PM25" jdbcType="REAL" property="pm25" /> |
| | | <result column="PM10" jdbcType="REAL" property="pm10" /> |
| | | <result column="temperature" jdbcType="REAL" property="temperature" /> |
| | | <result column="humidity" jdbcType="REAL" property="humidity" /> |
| | | <result column="VOC" jdbcType="REAL" property="voc" /> |
| | | <result column="NOI" jdbcType="REAL" property="noi" /> |
| | | <result column="velocity" jdbcType="REAL" property="velocity" /> |
| | | <result column="wind_speed" jdbcType="REAL" property="windSpeed" /> |
| | | <result column="wind_direction" jdbcType="REAL" property="windDirection" /> |
| | | <result column="height" jdbcType="REAL" property="height" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!-- |
| | | WARNING - @mbg.generated |
| | | --> |
| | | id, device_code, latitude, longitude, altitude, data_time, create_time, NO2, CO, |
| | | H2S, SO2, O3, PM25, PM10, temperature, humidity, VOC, NOI, velocity, wind_speed, |
| | | wind_direction, height |
| | | </sql> |
| | | </mapper> |
| | |
| | | val r = realTimeDataService.averageData() |
| | | println(r.data) |
| | | } |
| | | |
| | | @Test |
| | | fun dataCalibration() { |
| | | val r = realTimeDataService.dataCalibration() |
| | | println(r.data) |
| | | } |
| | | } |