package com.njcn.product.terminal.mysqlTerminal.service.impl;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.product.terminal.mysqlTerminal.mapper.UserReportPOMapper;
import com.njcn.product.terminal.mysqlTerminal.pojo.param.UserReportParam;
import com.njcn.product.terminal.mysqlTerminal.pojo.po.UserReportPO;
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.UserLedgerVO;
import com.njcn.product.terminal.mysqlTerminal.service.UserReportPOService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Description:
 * Date: 2024/4/25  10:07【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Service
@RequiredArgsConstructor
public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, UserReportPO> implements UserReportPOService {





    @Override
    public List<UserLedgerVO> selectUserList(UserReportParam userReportParam) {
        LambdaQueryWrapper<UserReportPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();

        if(StrUtil.isNotBlank(userReportParam.getCity())){
            lambdaQueryWrapper.in(UserReportPO::getCity,Stream.of(userReportParam.getCity()).collect(Collectors.toList()));
        }
        if(StrUtil.isNotBlank(userReportParam.getStationId())){
            lambdaQueryWrapper.eq(UserReportPO::getStationId,userReportParam.getStationId());
        }

        lambdaQueryWrapper.eq(UserReportPO::getState,DataStateEnum.ENABLE.getCode());

        List<UserReportPO> list = this.list(lambdaQueryWrapper);
        return BeanUtil.copyToList(list,UserLedgerVO.class);
    }



}
