1. 添加车载走航动态校准功能
2. 添加网格化数据校准功能
3. 添加网格化数据分钟均值转换功能(待完成)
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.domain.entity; |
| | | |
| | | import javax.persistence.*; |
| | | |
| | | @Table(name = "factor_calibration") |
| | | public class FactorCalibration { |
| | | @Id |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 设å¤ç±»åï¼0a:车载; 0b:æ 人æº; 0c:æ 人è¹; 0d:ç½æ ¼åï¼ |
| | | */ |
| | | @Column(name = "device_type") |
| | | private String deviceType; |
| | | |
| | | /** |
| | | * çæµå åid |
| | | */ |
| | | @Column(name = "factor_id") |
| | | private Integer factorId; |
| | | |
| | | /** |
| | | * çæµå ååç§° |
| | | */ |
| | | @Column(name = "factor_name") |
| | | private String factorName; |
| | | |
| | | /** |
| | | * çæµå åæ ¡åç³»æ° |
| | | */ |
| | | @Column(name = "factor_scale") |
| | | private Float factorScale; |
| | | |
| | | /** |
| | | * @return id |
| | | */ |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | | |
| | | /** |
| | | * @param id |
| | | */ |
| | | public void setId(Integer id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | /** |
| | | * è·å设å¤ç±»åï¼0a:车载; 0b:æ 人æº; 0c:æ 人è¹; 0d:ç½æ ¼åï¼ |
| | | * |
| | | * @return device_type - 设å¤ç±»åï¼0a:车载; 0b:æ 人æº; 0c:æ 人è¹; 0d:ç½æ ¼åï¼ |
| | | */ |
| | | public String getDeviceType() { |
| | | return deviceType; |
| | | } |
| | | |
| | | /** |
| | | * 设置设å¤ç±»åï¼0a:车载; 0b:æ 人æº; 0c:æ 人è¹; 0d:ç½æ ¼åï¼ |
| | | * |
| | | * @param deviceType 设å¤ç±»åï¼0a:车载; 0b:æ 人æº; 0c:æ 人è¹; 0d:ç½æ ¼åï¼ |
| | | */ |
| | | public void setDeviceType(String deviceType) { |
| | | this.deviceType = deviceType == null ? null : deviceType.trim(); |
| | | } |
| | | |
| | | /** |
| | | * è·åçæµå åid |
| | | * |
| | | * @return factor_id - çæµå åid |
| | | */ |
| | | public Integer getFactorId() { |
| | | return factorId; |
| | | } |
| | | |
| | | /** |
| | | * è®¾ç½®çæµå åid |
| | | * |
| | | * @param factorId çæµå åid |
| | | */ |
| | | public void setFactorId(Integer factorId) { |
| | | this.factorId = factorId; |
| | | } |
| | | |
| | | /** |
| | | * è·åçæµå ååç§° |
| | | * |
| | | * @return factor_name - çæµå ååç§° |
| | | */ |
| | | public String getFactorName() { |
| | | return factorName; |
| | | } |
| | | |
| | | /** |
| | | * è®¾ç½®çæµå ååç§° |
| | | * |
| | | * @param factorName çæµå ååç§° |
| | | */ |
| | | public void setFactorName(String factorName) { |
| | | this.factorName = factorName == null ? null : factorName.trim(); |
| | | } |
| | | |
| | | /** |
| | | * è·åçæµå åæ ¡åç³»æ° |
| | | * |
| | | * @return factor_scale - çæµå åæ ¡åç³»æ° |
| | | */ |
| | | public Float getFactorScale() { |
| | | return factorScale; |
| | | } |
| | | |
| | | /** |
| | | * è®¾ç½®çæµå åæ ¡åç³»æ° |
| | | * |
| | | * @param factorScale çæµå åæ ¡åç³»æ° |
| | | */ |
| | | public void setFactorScale(Float factorScale) { |
| | | this.factorScale = factorScale; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.domain.mapper |
| | | |
| | | import com.flightfeather.uav.domain.MyMapper |
| | | import com.flightfeather.uav.domain.entity.FactorCalibration |
| | | import org.apache.ibatis.annotations.Mapper |
| | | |
| | | @Mapper |
| | | interface FactorCalibrationMapper : MyMapper<FactorCalibration> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.lightshare.bean |
| | | |
| | | data class ElectricVo( |
| | | var time: String? = null, |
| | | //äº§çº¿é£æº |
| | | var d1eA: Double = .0, |
| | | var d1eB: Double = .0, |
| | | var d1eC: Double = .0, |
| | | var d1Status: String? = "0", |
| | | //åºæ°ååè£
ç½® |
| | | var d2eA: Double = .0, |
| | | var d2eB: Double = .0, |
| | | var d2eC: Double = .0, |
| | | var d2Status: String? = "0" |
| | | ) |
| | |
| | | import com.flightfeather.uav.domain.entity.ElectricMinuteValue |
| | | import com.flightfeather.uav.lightshare.bean.BaseResponse |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import com.flightfeather.uav.lightshare.bean.ElectricVo |
| | | |
| | | interface ElectricityService { |
| | | |
| | |
| | | fun getMinuteData2(deviceCode: String, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> |
| | | |
| | | fun getByCompany(cId:String):BaseResponse<List<ElectricMinuteValue>> |
| | | |
| | | fun getElectricityInfo(cId: String, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<List<ElectricVo>> |
| | | } |
| | |
| | | * å»é¤åå§æ°æ®ä¸çå¼å¸¸æ³¢å¨å¼ |
| | | */ |
| | | fun dataPreprocessing(): BaseResponse<String> |
| | | |
| | | /** |
| | | * åå¼è®¡ç®ï¼å°ç§çº§å¼æ¢ç®ä¸ºåéåå¼ |
| | | */ |
| | | fun averageData(): BaseResponse<String> |
| | | } |
| | |
| | | import com.flightfeather.uav.lightshare.bean.BaseResponse |
| | | import com.flightfeather.uav.lightshare.bean.DataHead |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import com.flightfeather.uav.lightshare.bean.ElectricVo |
| | | import com.flightfeather.uav.lightshare.service.ElectricityService |
| | | import com.flightfeather.uav.socket.bean.AirData |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.stereotype.Service |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.text.SimpleDateFormat |
| | | import java.time.LocalDateTime |
| | | import java.time.ZoneId |
| | | import java.time.format.DateTimeFormatter |
| | | |
| | | @Service |
| | | class ElectricityServiceImpl( |
| | |
| | | ) : ElectricityService { |
| | | |
| | | private var dateFormatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") |
| | | private var dateFormatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm") |
| | | |
| | | override fun getMinuteData( |
| | | deviceCode: String, startTime: String?, |
| | |
| | | |
| | | return BaseResponse(true, data = result) |
| | | } |
| | | |
| | | override fun getElectricityInfo(cId: String, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<List<ElectricVo>> { |
| | | val perP = perPage ?: 60 |
| | | val p = page ?: 1 |
| | | val sTime = startTime?.let { dateFormatter.parse(it) } |
| | | val eTime = endTime?.let { dateFormatter.parse(it) } |
| | | val result = mutableListOf<ElectricVo>() |
| | | val deviceCodeList = companyDeviceMapper.selectByExample(Example(CompanyDevice::class.java).apply { |
| | | createCriteria().andEqualTo("cdCompanyId", cId) |
| | | }) |
| | | //äº§çº¿é£æº |
| | | var d1: String? = null |
| | | //åºæ°ååè£
ç½® |
| | | var d2: String? = null |
| | | |
| | | deviceCodeList.forEach { |
| | | // FIXME: 2021/11/5 æ¤å¤ææ¶åæ»ï¼åç»ä¿®æ¹ |
| | | if (it?.cdDeviceCode == "31011020210602" || it?.cdDeviceCode == "31011020210603") { |
| | | d1 = it.cdDeviceCode |
| | | }else if (it?.cdDeviceCode == "31011020210601" || it?.cdDeviceCode == "31011020210604") { |
| | | d2 = it.cdDeviceCode |
| | | } |
| | | } |
| | | |
| | | var pageInfo = PageHelper.startPage<ElectricMinuteValue>(p, perP) |
| | | val dataList1 = electricMinuteValueMapper.selectByExample(Example(ElectricMinuteValue::class.java).apply { |
| | | createCriteria().andEqualTo("mvStatCode", d1) |
| | | .apply { |
| | | sTime?.let { andGreaterThanOrEqualTo("mvDataTime", it) } |
| | | eTime?.let { andLessThanOrEqualTo("mvDataTime", it) } |
| | | } |
| | | orderBy("mvDataTime").apply { |
| | | // å½è¯·æ±æ¥å£ä¸ä¼ éèµ·å§æ¶é´ï¼é»è®¤è·åææ°çæ°æ® |
| | | if (startTime == null && endTime == null) { |
| | | desc() |
| | | } |
| | | } |
| | | }) |
| | | if (startTime == null && endTime == null) { |
| | | dataList1.reverse() |
| | | } |
| | | pageInfo = PageHelper.startPage<ElectricMinuteValue>(p, perP) |
| | | val dataList2 = electricMinuteValueMapper.selectByExample(Example(ElectricMinuteValue::class.java).apply { |
| | | createCriteria().andEqualTo("mvStatCode", d2) |
| | | .apply { |
| | | sTime?.let { andGreaterThanOrEqualTo("mvDataTime", it) } |
| | | eTime?.let { andLessThanOrEqualTo("mvDataTime", it) } |
| | | } |
| | | orderBy("mvDataTime").apply { |
| | | // å½è¯·æ±æ¥å£ä¸ä¼ éèµ·å§æ¶é´ï¼é»è®¤è·åææ°çæ°æ® |
| | | if (startTime == null && endTime == null) { |
| | | desc() |
| | | } |
| | | } |
| | | }) |
| | | if (startTime == null && endTime == null) { |
| | | dataList2.reverse() |
| | | } |
| | | |
| | | // FIXME: 2021/11/5 è¿åç»æéè¦æ ¹æ®ä¸¤å°è®¾å¤çæ°æ®å§æ«æ¶é´ï¼éåæé¿çä¸¤ä¸ªå§æ«æ¶é´ |
| | | val sT = if (dataList1.isEmpty() && dataList2.isNotEmpty()) { |
| | | dataList2[0]?.mvDataTime |
| | | }else if (dataList1.isNotEmpty() && dataList2.isEmpty()) { |
| | | dataList1[0]?.mvDataTime |
| | | } else if (dataList1.isNotEmpty() && dataList2.isNotEmpty()) { |
| | | if (dataList1[0]?.mvDataTime?.after(dataList2[0]?.mvDataTime) == true) { |
| | | dataList2[0]?.mvDataTime |
| | | } else { |
| | | dataList1[0]?.mvDataTime |
| | | } |
| | | } else { |
| | | null |
| | | } |
| | | val eT = if (dataList1.isEmpty() && dataList2.isNotEmpty()) { |
| | | dataList2.last()?.mvDataTime |
| | | }else if (dataList1.isNotEmpty() && dataList2.isEmpty()) { |
| | | dataList1.last()?.mvDataTime |
| | | } else if (dataList1.isNotEmpty() && dataList2.isNotEmpty()) { |
| | | if (dataList1.last()?.mvDataTime?.after(dataList2.last()?.mvDataTime) == true) { |
| | | dataList1.last()?.mvDataTime |
| | | } else { |
| | | dataList2.last()?.mvDataTime |
| | | } |
| | | } else { |
| | | null |
| | | } |
| | | |
| | | var lsT = LocalDateTime.ofInstant(sT?.toInstant(), ZoneId.systemDefault()).withSecond(0) |
| | | val leT = LocalDateTime.ofInstant(eT?.toInstant(), ZoneId.systemDefault()).withSecond(0) |
| | | |
| | | if (sT != null && eT != null) { |
| | | while (!lsT.isAfter(leT)) { |
| | | val vo = ElectricVo(lsT.format(dateFormatter2)) |
| | | if (dataList1.isNotEmpty()) { |
| | | val d = dataList1[0] |
| | | val t = LocalDateTime.ofInstant(d?.mvDataTime?.toInstant(), ZoneId.systemDefault()).withSecond(0) |
| | | if (lsT.isEqual(t)) { |
| | | vo.apply { |
| | | d1eA = d?.mvElectricityA ?: .0 |
| | | d1eB = d?.mvElectricityB ?: .0 |
| | | d1eC = d?.mvElectricityC ?: .0 |
| | | d1Status = getStatus(d) |
| | | } |
| | | dataList1.removeAt(0) |
| | | } |
| | | } |
| | | if (dataList2.isNotEmpty()) { |
| | | val d = dataList2[0] |
| | | val t = LocalDateTime.ofInstant(d?.mvDataTime?.toInstant(), ZoneId.systemDefault()).withSecond(0) |
| | | if (lsT.isEqual(t)) { |
| | | vo.apply { |
| | | d2eA = d?.mvElectricityA ?: .0 |
| | | d2eB = d?.mvElectricityB ?: .0 |
| | | d2eC = d?.mvElectricityC ?: .0 |
| | | d2Status = getStatus(d) |
| | | } |
| | | dataList2.removeAt(0) |
| | | } |
| | | } |
| | | result.add(vo) |
| | | |
| | | lsT = lsT.plusMinutes(1) |
| | | } |
| | | } |
| | | |
| | | return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages), data = result) |
| | | } |
| | | |
| | | // FIXME: 2021/11/5 æ¤å¤ææ¶åæ»ï¼åç»ä¿®æ¹ |
| | | private fun getStatus(e: ElectricMinuteValue?): String { |
| | | var values = listOf(1, 100) |
| | | var status = listOf("0", "2", "3") |
| | | if (e == null) { |
| | | return status.first() |
| | | } |
| | | when (e.mvStatCode) { |
| | | "31011020210601" -> { |
| | | values = listOf(1, 100) |
| | | status = listOf("0", "2", "3") |
| | | } |
| | | "31011020210602" -> { |
| | | values = listOf(13, 30) |
| | | status = listOf("0", "2", "3") |
| | | } |
| | | "31011020210603" -> { |
| | | values = listOf(1, 50, 80) |
| | | status = listOf("0", "1", "2", "3") |
| | | } |
| | | "31011020210604" -> { |
| | | values = listOf(15, 90, 125) |
| | | status = listOf("0", "1", "2", "3") |
| | | } |
| | | } |
| | | val electricityList = mutableListOf<Double>() |
| | | electricityList.add(e.mvElectricityA) |
| | | electricityList.add(e.mvElectricityB) |
| | | electricityList.add(e.mvElectricityC) |
| | | |
| | | val avg = electricityList.average() |
| | | for (i in values.indices) { |
| | | if (avg < values[i]) { |
| | | return status[i] |
| | | } |
| | | } |
| | | return status.last() |
| | | } |
| | | } |
| | |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.io.ByteArrayInputStream |
| | | import java.text.SimpleDateFormat |
| | | import java.time.LocalDateTime |
| | | import java.time.format.DateTimeFormatter |
| | | import java.util.* |
| | | import javax.servlet.http.HttpServletResponse |
| | | import javax.swing.text.DateFormatter |
| | | |
| | | @Service |
| | | class RealTimeDataServiceImpl( |
| | |
| | | ) : RealTimeDataService { |
| | | |
| | | private var dateFormatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") |
| | | private var dateFormatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm") |
| | | private val fileExchange = FileExchange() |
| | | |
| | | override fun getSecondData(deviceCode: String?, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> { |
| | |
| | | val _page = page ?: 1 |
| | | val sTime = startTime?.let { dateFormatter.parse(it) } |
| | | val eTime = endTime?.let { dateFormatter.parse(it) } |
| | | val pageInfo = PageHelper.startPage<RealTimeData>(_page, _perPage) |
| | | // var pageInfo = PageHelper.startPage<BaseRealTimeData>(_page, _perPage) |
| | | var pageNum = 1 |
| | | var pages = 0 |
| | | val result = mutableListOf<DataVo>() |
| | | |
| | | when (UWDeviceType.getType(deviceCode)) { |
| | | UWDeviceType.VEHICLE -> { |
| | | val pageInfo = PageHelper.startPage<RealTimeDataVehicle>(_page, _perPage) |
| | | realTimeDataVehicleMapper.selectByExample(Example(RealTimeDataVehicle::class.java).apply { |
| | | getSecondDataExample(this, deviceCode, sTime, eTime) |
| | | }).forEach { result.add(it.toDataVo()) } |
| | | pageNum = pageInfo.pageNum |
| | | pages = pageInfo.pages |
| | | } |
| | | UWDeviceType.UAV -> { |
| | | val pageInfo = PageHelper.startPage<RealTimeDataUav>(_page, _perPage) |
| | | realTimeDataUavMapper.selectByExample(Example(RealTimeDataUav::class.java).apply { |
| | | getSecondDataExample(this, deviceCode, sTime, eTime) |
| | | }).forEach { result.add(it.toDataVo()) } |
| | | pageNum = pageInfo.pageNum |
| | | pages = pageInfo.pages |
| | | } |
| | | UWDeviceType.GRID -> { |
| | | val pageInfo = PageHelper.startPage<RealTimeDataGrid>(_page, _perPage) |
| | | realTimeDataGridMapper.selectByExample(Example(RealTimeDataGrid::class.java).apply { |
| | | getSecondDataExample(this, deviceCode, sTime, eTime) |
| | | }).forEach { result.add(it.toDataVo()) } |
| | | pageNum = pageInfo.pageNum |
| | | pages = pageInfo.pages |
| | | } |
| | | else -> { |
| | | // ä»åå§æ°æ®è¡¨ä¸è·åæ°æ® |
| | | val pageInfo = PageHelper.startPage<RealTimeData>(_page, _perPage) |
| | | realTimeDataMapper.selectByExample(Example(RealTimeData::class.java).apply { |
| | | getSecondDataExample(this, deviceCode, sTime, eTime) |
| | | }).forEach { |
| | |
| | | } |
| | | result.add(it.toDataVo()) |
| | | } |
| | | pageNum = pageInfo.pageNum |
| | | pages = pageInfo.pages |
| | | } |
| | | } |
| | | |
| | | if (startTime == null && endTime == null) { |
| | | result.reverse() |
| | | } |
| | | return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages), data = result) |
| | | return BaseResponse(true, head = DataHead(pageNum, pages), data = result) |
| | | } |
| | | |
| | | private fun getSecondDataExample(example: Example, deviceCode: String?, sTime: Date?, eTime: Date?) { |
| | |
| | | return contents |
| | | } |
| | | |
| | | private fun getOriginData(deviceCode: String?, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> { |
| | | val _perPage = perPage ?: 60 |
| | | val _page = page ?: 1 |
| | | val sTime = startTime?.let { dateFormatter.parse(it) } |
| | | val eTime = endTime?.let { dateFormatter.parse(it) } |
| | | // var pageInfo = PageHelper.startPage<BaseRealTimeData>(_page, _perPage) |
| | | var pageNum = 1 |
| | | var pages = 0 |
| | | val result = mutableListOf<DataVo>() |
| | | |
| | | // ä»åå§æ°æ®è¡¨ä¸è·åæ°æ® |
| | | val pageInfo = PageHelper.startPage<RealTimeData>(_page, _perPage) |
| | | realTimeDataMapper.selectByExample(Example(RealTimeData::class.java).apply { |
| | | getSecondDataExample(this, deviceCode, sTime, eTime) |
| | | }).forEach { |
| | | if (it.longitude == null || it.latitude == null) { |
| | | return@forEach |
| | | } |
| | | result.add(it.toDataVo()) |
| | | } |
| | | pageNum = pageInfo.pageNum |
| | | pages = pageInfo.pages |
| | | |
| | | if (startTime == null && endTime == null) { |
| | | result.reverse() |
| | | } |
| | | return BaseResponse(true, head = DataHead(pageNum, pages), data = result) |
| | | } |
| | | |
| | | override fun dataPreprocessing(): BaseResponse<String> { |
| | | val epwDataPrep = EPWDataPrep() |
| | | val res = getSecondData("0b0000000002", "2021-10-23 19:00:00", "2021-10-23 20:00:00", 1, 5000) |
| | | val dataList = res.data ?: emptyList() |
| | | var page = 1 |
| | | var total = -1 |
| | | var count = 0 |
| | | dataList.forEach { |
| | | val result = epwDataPrep.mDataPrep2(listOf(it)) |
| | | count += airDataRepository.savePrepData2(result) |
| | | println("[${it.deviceCode}]: [${it.time}]") |
| | | Thread.sleep(4000) |
| | | |
| | | while (total == -1 || page <= total) { |
| | | println("------start------") |
| | | val res = getOriginData("0d0000000001", "2021-07-05 19:47:01", "2021-11-05 00:00:00", page, 50000) |
| | | res.head?.let { |
| | | total = it.totalPage |
| | | } |
| | | if (page == 1) { |
| | | println("æ»é¡µæ°ï¼$total") |
| | | } |
| | | println("å½å页æ°ï¼$page") |
| | | val dataList = res.data ?: emptyList() |
| | | val result = epwDataPrep.mDataPrep2(dataList) |
| | | count += airDataRepository.savePrepData2(result) |
| | | page++ |
| | | } |
| | | |
| | | return BaseResponse(count > 0, data = "æå
¥æ°æ®: ${count}æ¡") |
| | | } |
| | | |
| | | override fun averageData(): BaseResponse<String> { |
| | | val epwDataPrep = EPWDataPrep() |
| | | var page = 1 |
| | | var total = -1 |
| | | var count = 0 |
| | | |
| | | while (total == -1 || page <= total) { |
| | | println("------start------") |
| | | val res = getOriginData("0d0000000001", "2021-07-05 19:47:01", "2021-11-05 00:00:00", page, 50000) |
| | | res.head?.let { |
| | | total = it.totalPage |
| | | } |
| | | if (page == 1) { |
| | | println("æ»é¡µæ°ï¼$total") |
| | | } |
| | | println("å½å页æ°ï¼$page") |
| | | res.data?.forEach { |
| | | |
| | | } |
| | | |
| | | page++ |
| | | } |
| | | |
| | | return BaseResponse(count > 0, data = "æå
¥æ°æ®: ${count}æ¡") |
| | | } |
| | | } |
| | |
| | | @RequestParam(value = "perPage", required = false) perPage: Int? |
| | | ) = electricityService.getMinuteData2(deviceCode, startTime, endTime, page, perPage) |
| | | |
| | | @ApiOperation(value = "è·åä¼ä¸ç¨çµéææ°ä¸æ¡åéåå¼") |
| | | @GetMapping("/company") |
| | | fun getByCompany( |
| | | @ApiParam("ä¼ä¸id") @RequestParam(value = "cId") cId: String, |
| | | ) = electricityService.getByCompany(cId) |
| | | |
| | | @ApiOperation(value = "è·åä¼ä¸ç¨çµéæ´åæ°æ®") |
| | | @GetMapping("/info") |
| | | fun getElectricityInfo( |
| | | @ApiParam("ä¼ä¸id") @RequestParam(value = "cId") cId: String, |
| | | @ApiParam(value = "å¼å§æ¶é´", example = "yyyy-MM-dd HH:mm:ss") @RequestParam(value = "startTime", required = false) startTime: String?, |
| | | @ApiParam(value = "ç»ææ¶é´", example = "yyyy-MM-dd HH:mm:ss") @RequestParam(value = "endTime", required = false) endTime: String?, |
| | | @RequestParam(value = "page", required = false) page: Int?, |
| | | @RequestParam(value = "perPage", required = false) perPage: Int? |
| | | ) = electricityService.getElectricityInfo(cId, startTime, endTime, page, perPage) |
| | | } |
| | |
| | | package com.flightfeather.uav.repository.impl |
| | | |
| | | import com.flightfeather.uav.common.utils.GsonUtils |
| | | import com.flightfeather.uav.domain.MyMapper |
| | | import com.flightfeather.uav.domain.entity.* |
| | | import com.flightfeather.uav.domain.mapper.RealTimeDataGridMapper |
| | | import com.flightfeather.uav.domain.mapper.RealTimeDataMapper |
| | | import com.flightfeather.uav.domain.mapper.RealTimeDataUavMapper |
| | | import com.flightfeather.uav.domain.mapper.RealTimeDataVehicleMapper |
| | | import com.flightfeather.uav.domain.mapper.* |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import com.flightfeather.uav.repository.AirDataRepository |
| | | import com.flightfeather.uav.socket.bean.AirData |
| | |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.math.BigDecimal |
| | | import java.text.SimpleDateFormat |
| | | import java.time.LocalDateTime |
| | | import java.time.ZoneId |
| | | import java.util.* |
| | | import kotlin.math.abs |
| | | import kotlin.math.sqrt |
| | | |
| | | /** |
| | | * @author riku |
| | |
| | | private val realTimeDataMapper: RealTimeDataMapper, |
| | | private val realTimeDataVehicleMapper: RealTimeDataVehicleMapper, |
| | | private val realTimeDataUavMapper: RealTimeDataUavMapper, |
| | | private val realTimeDataGridMapper: RealTimeDataGridMapper |
| | | private val realTimeDataGridMapper: RealTimeDataGridMapper, |
| | | private val factorCalibrationMapper: FactorCalibrationMapper |
| | | ): AirDataRepository { |
| | | |
| | | // FIXME: 2021/10/25 临æ¶è½¦è½½æ°æ®ï¼ç±äºæ 人æºé¨åçæµå åæ°æ®æ æï¼å æ¤ææ¶éç¨è½¦è½½æ°æ®ä½ä¸ºå¡«å
|
| | | private val tmpVehicleDataList = mutableListOf<BaseRealTimeData>() |
| | | |
| | | // èµ°èªçæµæ ¡åç³»æ° |
| | | private val calibrationMap = mutableMapOf<String, MutableMap<Int, Float>>() |
| | | // èµ°èªçæµæ ¡åç³»æ°æ´æ°æ¶é´ |
| | | private var cUpdateTime = LocalDateTime.now() |
| | | // èµ°èªçæµæ ¡åç³»æ°æ´æ°æ¶é´é´éï¼åéï¼ |
| | | private val cInterval = 5L |
| | | |
| | | override fun saveAirData(dataPackage: AirDataPackage): Int { |
| | | val data = RealTimeData().apply { |
| | |
| | | dataTransform(vo, d) |
| | | /***************************************************************************************************/ |
| | | // FIXME: 2021/10/27 è½¦è½½çæµé¨åå åéçº§è°æ´ï¼NO2*0.6ï¼H2S*0.3, SO2*0.2, O3*0.5ï¼å
¶ä»è¦ç´ ä¸å |
| | | d.no2 = d.no2?.times(0.6f) |
| | | d.h2s = d.h2s?.times(0.3f) |
| | | d.so2 = d.so2?.times(0.2f) |
| | | d.o3 = d.o3?.times(0.5f) |
| | | calibration(d, UWDeviceType.VEHICLE) |
| | | /***************************************************************************************************/ |
| | | realTimeDataVehicleMapper.insert(d) |
| | | count++ |
| | |
| | | UWDeviceType.GRID -> { |
| | | val d = RealTimeDataGrid() |
| | | dataTransform(vo, d) |
| | | /**************************************************************************/ |
| | | // FIXME: 2021/11/8 é对åå²ç½æ ¼ååå§æ°æ®ï¼è¿è¡ä¸´æ¶æ ¡åå¤ç |
| | | val dTime = LocalDateTime.ofInstant(d.dataTime?.toInstant(), ZoneId.systemDefault()) |
| | | // CO: 2021.8.28 17:27èµ· *0.25 |
| | | val coTime = LocalDateTime.of(2021, 8, 28, 17, 27, 0) |
| | | if (dTime.isAfter(coTime)) { |
| | | d.co = d.co?.times(0.25f) |
| | | } |
| | | |
| | | // NO2 |
| | | d.no2 = d.no2?.times(0.6f) |
| | | |
| | | // O3 |
| | | d.o3 = abs(d.o3?.minus(d.no2?.div(2) ?: 0f) ?: 0f) * 1.5f |
| | | |
| | | // SO2: *0.2, 2021.8.29 6:00èµ· *0.08 |
| | | val so2Time = LocalDateTime.of(2021, 8, 29, 6, 0, 0) |
| | | d.so2 = if (dTime.isAfter(so2Time)) { |
| | | d.so2?.times(0.08f) |
| | | } else { |
| | | d.so2?.times(0.2f) |
| | | } |
| | | |
| | | // H2S |
| | | d.h2s = d.h2s?.let { sqrt(it) * 2 } |
| | | /**************************************************************************/ |
| | | realTimeDataGridMapper.insert(d) |
| | | count++ |
| | | } |
| | | UWDeviceType.BOAT -> { |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | private fun calibration(data: BaseRealTimeData, type: UWDeviceType) { |
| | | //1. æ ¡åç³»æ°æç
§ä¸å®æ¶é´é´éè¿è¡å·æ° |
| | | val now = LocalDateTime.now() |
| | | if (calibrationMap.isEmpty() || now.minusMinutes(cInterval).isAfter(cUpdateTime)) { |
| | | cUpdateTime = now |
| | | calibrationMap[type.value] = mutableMapOf() |
| | | factorCalibrationMapper.selectByExample(Example(FactorCalibration::class.java).apply { |
| | | createCriteria().andEqualTo("deviceType", type.value) |
| | | }).forEach { |
| | | calibrationMap[type.value]?.put(it.factorId, it.factorScale) |
| | | } |
| | | } |
| | | //2. æ ¹æ®æ ¡åç³»æ°è®¡ç® |
| | | calibrationMap[type.value]?.let{ |
| | | data.voc = data.voc?.times(it[FactorType.VOC.value] ?: 1f) |
| | | data.co = data.co?.times(it[FactorType.CO.value] ?: 1f) |
| | | data.pm25 = data.pm25?.times(it[FactorType.PM25.value] ?: 1f) |
| | | data.pm10 = data.pm10?.times(it[FactorType.PM10.value] ?: 1f) |
| | | |
| | | data.no2 = data.no2?.times(it[FactorType.NO2.value] ?: 1f) |
| | | data.h2s = data.h2s?.times(it[FactorType.H2S.value] ?: 1f) |
| | | data.so2 = data.so2?.times(it[FactorType.SO2.value] ?: 1f) |
| | | data.o3 = data.o3?.times(it[FactorType.O3.value] ?: 1f) |
| | | } |
| | | } |
| | | } |
| | |
| | | enum class UWDeviceType(val value: String, val des: String) { |
| | | UAV("0b", "æ 人æºè®¾å¤"), |
| | | VEHICLE("0a", "车载设å¤"), |
| | | BOAT("0c", "æ 人è¹"), |
| | | GRID("0d", "ç½æ ¼å设å¤"); |
| | | |
| | | companion object { |
| | |
| | | fun getType(deviceCode: String?): UWDeviceType? = when (deviceCode?.substring(0, 2)) { |
| | | UAV.value -> UAV |
| | | VEHICLE.value -> VEHICLE |
| | | BOAT.value -> BOAT |
| | | GRID.value -> GRID |
| | | else -> null |
| | | } |
| | |
| | | # password: cn.FLIGHTFEATHER |
| | | |
| | | # çº¿ä¸æå¡å¨ |
| | | url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false |
| | | username: dronemonitor |
| | | password: dronemonitor_hackxrnomxm |
| | | # url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false |
| | | # username: dronemonitor |
| | | # password: dronemonitor_hackxrnomxm |
| | | |
| | | # å¼åæ¬å°æå¡å¨ |
| | | # url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false |
| | |
| | | # password: 123456 |
| | | |
| | | # å¼åè¿ç¨æå¡å¨ |
| | | # url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false |
| | | # username: remoteU1 |
| | | # password: eSoF8DnzfGTlhAjE |
| | | url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false |
| | | username: remoteU1 |
| | | password: eSoF8DnzfGTlhAjE |
| | | hikari: |
| | | maximum-pool-size: 500 |
| | | minimum-idle: 20 |
| | |
| | | <!-- <table tableName="real_time_data_grid" domainObjectName="RealTimeDataGrid" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="real_time_data_uav" domainObjectName="RealTimeDataUav" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="real_time_data_vehicle" domainObjectName="RealTimeDataVehicle" 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="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"/> |
| | | </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.FactorCalibrationMapper"> |
| | | <resultMap id="BaseResultMap" type="com.flightfeather.uav.domain.entity.FactorCalibration"> |
| | | <!-- |
| | | WARNING - @mbg.generated |
| | | --> |
| | | <id column="id" jdbcType="INTEGER" property="id" /> |
| | | <result column="device_type" jdbcType="VARCHAR" property="deviceType" /> |
| | | <result column="factor_id" jdbcType="INTEGER" property="factorId" /> |
| | | <result column="factor_name" jdbcType="VARCHAR" property="factorName" /> |
| | | <result column="factor_scale" jdbcType="REAL" property="factorScale" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!-- |
| | | WARNING - @mbg.generated |
| | | --> |
| | | id, device_type, factor_id, factor_name, factor_scale |
| | | </sql> |
| | | </mapper> |
| | |
| | | |
| | | @Test |
| | | fun dataPreprocessing() { |
| | | realTimeDataService.dataPreprocessing() |
| | | val r = realTimeDataService.dataPreprocessing() |
| | | println(r.data) |
| | | } |
| | | } |