package com.hdkj.lt.bf.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdkj.lt.bf.mapper.FhzgPlanAwaitTransferUsersMapper;
import com.hdkj.lt.bf.service.FhzgPlanAwaitTransferUsersService;
import com.hdkj.lt.core.bizms.modle.dto.FhzgDistCustomerDTO;
import com.hdkj.lt.core.bizms.modle.po.plan.FhzgPlanAwaitTransferUsers;
import com.hdkj.lt.core.bizms.modle.vo.FhzgAwaitTransferUsersVO;
import com.hdkj.lt.utils.security.SqlInjectionUtil;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * 计划停电待转供用户信息表 服务实现类
 *
 * @author zhousc
 * @since 2025-05-07
 */
@Service
public class FhzgPlanAwaitTransferUsersServiceImpl extends ServiceImpl<FhzgPlanAwaitTransferUsersMapper, FhzgPlanAwaitTransferUsers> implements FhzgPlanAwaitTransferUsersService {

    @Override
    public Page<FhzgAwaitTransferUsersVO> getUserList(FhzgDistCustomerDTO dto) {
        Page<FhzgAwaitTransferUsersVO> page = new Page<>();
        page.setCurrent(dto.getPageNum());
        page.setSize(dto.getPageSize());
        dto.setTransformerName(SqlInjectionUtil.xxsEscape(dto.getTransformerName()));
        List<FhzgAwaitTransferUsersVO> list = baseMapper.selectUserList(page, dto);
        list.stream().filter(i -> i.getUserLoads() != null).forEach(i->i.setUserLoads(i.getUserLoads().multiply(new BigDecimal("1000"))));
        return page.setRecords(list);
    }
}
