| | |
| | | import com.flightfeather.uav.common.utils.ExcelUtil |
| | | import com.flightfeather.uav.common.utils.FileExchange |
| | | import com.flightfeather.uav.common.utils.GsonUtils |
| | | import com.flightfeather.uav.dataprocess.AverageUtil |
| | | 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.* |
| | | import com.flightfeather.uav.lightshare.service.RealTimeDataService |
| | | import com.flightfeather.uav.model.epw.EPWDataPrep |
| | |
| | | private val airDataRepository: AirDataRepository, |
| | | private val realTimeDataVehicleMapper: RealTimeDataVehicleMapper, |
| | | private val realTimeDataUavMapper: RealTimeDataUavMapper, |
| | | private val realTimeDataGridMapper: RealTimeDataGridMapper |
| | | private val realTimeDataGridMapper: RealTimeDataGridMapper, |
| | | private val realTimeDataGridMinMapper: RealTimeDataGridMinMapper |
| | | ) : 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>> { |
| | | override fun getSecondData(deviceCode: String?, startTime: String?, endTime: String?, type: Int?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> { |
| | | val _perPage = perPage ?: 60 |
| | | val _page = page ?: 1 |
| | | val sTime = startTime?.let { dateFormatter.parse(it) } |
| | |
| | | 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 |
| | | // 网格化监测秒级值 |
| | | if (type == null || type == 0) { |
| | | 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 if (type == 1) { |
| | | val pageInfo = PageHelper.startPage<RealTimeDataGridMin>(_page, _perPage) |
| | | realTimeDataGridMinMapper.selectByExample(Example(RealTimeDataGridMin::class.java).apply { |
| | | getSecondDataExample(this, deviceCode, sTime, eTime) |
| | | }).forEach { result.add(it.toDataVo()) } |
| | | pageNum = pageInfo.pageNum |
| | | pages = pageInfo.pages |
| | | } |
| | | } |
| | | else -> { |
| | | // 从原始数据表中获取数据 |
| | |
| | | var count = 0 |
| | | |
| | | while (total == -1 || page <= total) { |
| | | println("------start------") |
| | | 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 |
| | |
| | | } |
| | | |
| | | override fun averageData(): BaseResponse<String> { |
| | | val epwDataPrep = EPWDataPrep() |
| | | var page = 1 |
| | | var total = -1 |
| | | var count = 0 |
| | | |
| | | val minFormatter = SimpleDateFormat("yyyy-MM-dd HH:mm") |
| | | val averageUtil = AverageUtil<RealTimeDataGrid, RealTimeDataGridMin>({d -> |
| | | minFormatter.format(d.dataTime) |
| | | },{list -> |
| | | list.avg() |
| | | }) |
| | | |
| | | 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 |
| | | } |
| | | println("------均值计算start------") |
| | | |
| | | val p = PageHelper.startPage<RealTimeDataGrid>(page, 50000) |
| | | val res = realTimeDataGridMapper.selectByExample(Example(RealTimeDataGrid::class.java).apply { |
| | | createCriteria().andBetween("dataTime", "2021-06-01 00:00:00", "2021-11-05 00:00:00") |
| | | }) |
| | | |
| | | total = p.pages |
| | | |
| | | if (page == 1) { |
| | | println("总页数:$total") |
| | | } |
| | | println("当前页数:$page") |
| | | res.data?.forEach { |
| | | |
| | | averageUtil.avg(res).forEach { |
| | | realTimeDataGridMinMapper.insert(it) |
| | | count++ |
| | | } |
| | | |
| | | page++ |
| | |
| | | |
| | | return BaseResponse(count > 0, data = "插入数据: ${count}条") |
| | | } |
| | | |
| | | override fun dataCalibration(): BaseResponse<String> { |
| | | return BaseResponse(true) |
| | | } |
| | | } |