package com.flightfeather.monitor.domain.ds1.repository
|
|
import com.flightfeather.monitor.domain.ds1.entity.RiskValue
|
import com.flightfeather.monitor.domain.ds1.mapper.RiskValueMapper
|
import com.github.pagehelper.PageHelper
|
import org.springframework.stereotype.Repository
|
import tk.mybatis.mapper.entity.Example
|
import java.time.LocalDate
|
|
@Repository
|
class RiskValueRep(private val riskValueMapper: RiskValueMapper) {
|
|
/**
|
* 获取最新一条记录
|
*/
|
fun findLatestData(type: String): RiskValue? {
|
val p = PageHelper.startPage<RiskValue>(1, 1)
|
riskValueMapper.selectByExample(Example(RiskValue::class.java).apply {
|
createCriteria().andEqualTo("type", type)
|
orderBy("lst").desc()
|
})
|
return if (p.isNotEmpty()) {
|
p[0]
|
} else {
|
null
|
}
|
}
|
|
/**
|
* 插入列表
|
* @param list
|
*/
|
fun insert(list: List<RiskValue>): Int {
|
return riskValueMapper.insertList(list)
|
}
|
|
/**
|
* 查询
|
* @param mnCode
|
* @param date
|
* @param type
|
*/
|
fun select(mnCode: String, date: LocalDate, type: String): List<RiskValue?> {
|
val s = date.withDayOfMonth(1).atStartOfDay()
|
val e = s.plusMonths(1).minusSeconds(1)
|
return riskValueMapper.selectByExample(Example(RiskValue::class.java).apply {
|
createCriteria().andEqualTo("mnCode", mnCode)
|
.andBetween("lst", s, e)
|
.andEqualTo("type", type)
|
})
|
}
|
}
|