import Ignore_ExecPageFlipper as ExecPageFlipper
import com.sdtool.business.dao.SystemDao
import com.sdtool.common.api.NoSqlKeysService
import com.sdtool.common.datas.RedisKeys
import com.sdtool.common.entity.system.PersonConfigValue
import com.dySweetFishPlugin.redis.RedisService
import com.sweetfish.convert.json.JsonConvert
import com.sweetfish.source.PageFlipper
import org.rex.RMap

static def createRunnable(RedisService redisService, NoSqlKeysService keysService, SystemDao systemDao, JsonConvert jsonConvert, String dataSourceId, long supplierCode) {
    return {
        redisService.del(keysService.getRedisKey(RedisKeys.KEY_ERP_PERSONCONFIG, supplierCode))
        RMap tmpParams = new RMap()

        ExecPageFlipper.execute(500, { PageFlipper p ->
            List<PersonConfigValue> configValueList = systemDao.queryPersonConfigValue(tmpParams, p, dataSourceId, supplierCode)

            if (!configValueList.isEmpty()) {
                Map<String, String> redisMap = configValueList.collectEntries { [String.valueOf(it.getIdUser()) + "_" + it.getConfigKey(), jsonConvert.convertTo(it)] }
                redisService.hmset(keysService.getRedisKey(RedisKeys.KEY_ERP_PERSONCONFIG, supplierCode), redisMap)
            }
        })

    } as Runnable
}

//groovy最后一个表达式的值为返回
createRunnable(redisService, keysService, systemDao, jsonConvert, dataSourceId, supplierCode)




