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.FaultAwaitTransferUsersMapper;
import com.hdkj.lt.bf.service.IFaultAwaitTransferUsersService;
import com.hdkj.lt.core.bizms.modle.dto.FhzgFaultDistCustomerDTO;
import com.hdkj.lt.core.bizms.modle.po.fault.FaultAwaitTransferUsers;
import com.hdkj.lt.core.bizms.modle.vo.FhzgFaultAwaitTransferUsersVO;
import com.hdkj.lt.utils.security.SqlInjectionUtil;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 故障停电待转供用户信息表 服务实现类
 * </p>
 *
 * @author luorui
 * @since 2025-05-29
 */
@Service
public class FaultAwaitTransferUsersServiceImpl extends ServiceImpl<FaultAwaitTransferUsersMapper, FaultAwaitTransferUsers> implements IFaultAwaitTransferUsersService {

    @Override
    public Page<FhzgFaultAwaitTransferUsersVO> getUserList(FhzgFaultDistCustomerDTO dto) {
        Page<FhzgFaultAwaitTransferUsersVO> page = new Page<>();
        page.setCurrent(dto.getPageNum());
        page.setSize(dto.getPageSize());
        dto.setTransformerName(SqlInjectionUtil.xxsEscape(dto.getTransformerName()));
        List<FhzgFaultAwaitTransferUsersVO> 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);
    }
}
