package cn.flightfeather.supervision.common.risk
|
|
import cn.flightfeather.supervision.domain.entity.BaseInfo
|
import cn.flightfeather.supervision.domain.entity.Userinfo
|
import cn.flightfeather.supervision.domain.enumeration.UserType
|
import cn.flightfeather.supervision.domain.mapper.*
|
import cn.flightfeather.supervision.lightshare.service.LedgerService
|
import tk.mybatis.mapper.entity.Example
|
|
class DataSource(val config: Config, val dbMapper: DbMapper) {
|
/**
|
* 用户筛选条件
|
*/
|
data class Config(
|
val district: String,
|
val sceneType: String,
|
val year: Int,
|
val month: Int,
|
val userConfigId: Int? = null,
|
) {
|
// 聚集区名称
|
var areaName: String? = null
|
}
|
|
private val sourceList = mutableListOf<Userinfo?>()
|
|
fun loop(callback: (user: Userinfo, config: Config, dbMapper: DbMapper) -> Unit) {
|
getUser()
|
sourceList.forEach {
|
it?.let { callback(it, config, dbMapper) }
|
}
|
}
|
|
private fun getUser() {
|
sourceList.clear()
|
var idList = emptyList<String>()
|
val c = dbMapper.userConfigMapper.selectByPrimaryKey(config.userConfigId)
|
c?.let {
|
config.areaName = c.ucArea
|
idList = dbMapper.baseInfoMapper.selectByExample(Example(BaseInfo::class.java).apply {
|
createCriteria().andEqualTo("biProvinceName", c.ucProvinceName)
|
.andEqualTo("biCityName", c.ucCityName)
|
.apply {
|
c.ucDistrictName?.let { andEqualTo("biDistrictName", it) }
|
c.ucTownName?.let { andEqualTo("biTownName", it) }
|
c.ucArea?.let { andEqualTo("biArea", it) }
|
}
|
}).map { it.biGuid }
|
}
|
dbMapper.userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
|
createCriteria().andEqualTo("extension1", config.district)
|
.andEqualTo("extension2", config.sceneType)
|
.andEqualTo("isenable", true)
|
.andEqualTo("usertypeid", UserType.Enterprise.value)
|
.apply {
|
if (idList.isNotEmpty()) andIn("guid", idList)
|
}
|
and(createCriteria().orNotEqualTo("workno", "test").orIsNull("workno"))
|
}).let { sourceList.addAll(it) }
|
}
|
}
|