| | |
| | | package com.flightfeather.monitor.domain.ds1.repository |
| | | |
| | | import com.flightfeather.monitor.domain.ds1.entity.DustExceptionData |
| | | import com.flightfeather.monitor.domain.ds1.entity.DustSiteData |
| | | import com.flightfeather.monitor.domain.ds1.entity.DustStatisticsValue |
| | | import com.flightfeather.monitor.domain.ds1.mapper.DustStatisticsValueMapper |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.stereotype.Repository |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.time.Duration |
| | |
| | | class DustStatisticsValueRep(private val dustStatisticsValueMapper: DustStatisticsValueMapper) { |
| | | |
| | | fun findLatestData(type: String): DustStatisticsValue? { |
| | | return dustStatisticsValueMapper.selectOneByExample(Example(DustStatisticsValue::class.java).apply { |
| | | val p = PageHelper.startPage<DustStatisticsValue>(1, 1) |
| | | dustStatisticsValueMapper.selectByExample(Example(DustStatisticsValue::class.java).apply { |
| | | createCriteria().andEqualTo("type", type) |
| | | orderBy("lst").desc() |
| | | }) |
| | | return if (p.isNotEmpty()) { |
| | | p[0] |
| | | } else { |
| | | null |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | fun monthlyStatics(date: LocalDate) { |
| | | val s = date.atStartOfDay() |
| | | val s = date.withDayOfMonth(1).atStartOfDay() |
| | | val e = s.plusMonths(1).minusSeconds(1) |
| | | val d = Duration.between(s, e).toDays() + 1 |
| | | val dataCount = d * 96 |
| | | dustStatisticsValueMapper.monthlyStatics(s, e, dataCount.toInt()) |
| | | } |
| | | |
| | | fun select(mnCode: String, date: LocalDate): List<DustStatisticsValue?> { |
| | | return dustStatisticsValueMapper.selectByExample(Example(DustStatisticsValue::class.java).apply { |
| | | createCriteria().andEqualTo("lst", date) |
| | | .andEqualTo("mnCode", mnCode) |
| | | }) |
| | | } |
| | | } |