feiyu02
2025-09-30 6904763f0e74d9a9fa4dbc39f635d2aee39416c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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) }
    }
}