package com.njcn.product.event.devcie.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.njcn.product.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.product.event.devcie.mapper.PqLineMapper;
import com.njcn.product.event.devcie.pojo.po.PqLine;
import com.njcn.product.event.devcie.service.PqLineService;
import org.springframework.util.CollectionUtils;

/**
 *
 * Description:
 * Date: 2025/06/19  下午 1:43【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Service
public class PqLineServiceImpl extends ServiceImpl<PqLineMapper, PqLine> implements PqLineService{


    @Override
    public List<LedgerBaseInfoDTO> getBaseLineInfo(List<Integer> ids){
        List<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = new ArrayList<>();

        if(CollectionUtils.isEmpty(ids)){
            return ledgerBaseInfoDTOS;
        }
        if(ids.size()>1000){
            List<List<Integer>> listIds = CollUtil.split(ids,1000);
            for(List<Integer> itemIds : listIds){
                List<LedgerBaseInfoDTO> temp =this.baseMapper.getBaseLineInfo(itemIds);
                ledgerBaseInfoDTOS.addAll(temp);
            }
        }else {
            List<LedgerBaseInfoDTO> temp =this.baseMapper.getBaseLineInfo(ids);
            ledgerBaseInfoDTOS.addAll(temp);
        }
        return ledgerBaseInfoDTOS;
    }

    @Override
    public List<LedgerBaseInfoDTO> getBaseLedger(List<Integer> ids,String searchValue) {
        List<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = new ArrayList<>();

        if(CollectionUtils.isEmpty(ids)){
            return ledgerBaseInfoDTOS;
        }
        if(ids.size()>1000){
            List<List<Integer>> listIds = CollUtil.split(ids,1000);
            for(List<Integer> itemIds : listIds){
                List<LedgerBaseInfoDTO> temp =this.baseMapper.getBaseLedger(itemIds,searchValue);
                ledgerBaseInfoDTOS.addAll(temp);
            }
        }else {
            List<LedgerBaseInfoDTO> temp =this.baseMapper.getBaseLedger(ids,searchValue);
            ledgerBaseInfoDTOS.addAll(temp);
        }
        return ledgerBaseInfoDTOS;
    };



}
