package com.tax.file.service.async.income;

import com.tax.file.model.FIncomeInvoice;
import com.yxcheng.token.utils.StringUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class IncomeUtil {

    public static Map<String, List<FIncomeInvoice>> splitToTaxno(List<FIncomeInvoice> invoices) {
        Map<String, List<FIncomeInvoice>> map = new HashMap<>();
        for(FIncomeInvoice entity:invoices){
            if(StringUtil.isBlank(entity.getTaxno())) continue;
            if(!map.containsKey(entity.getTaxno())){
                List<FIncomeInvoice>list = new ArrayList<>();
                list.add(entity);
                map.put(entity.getTaxno(),list);
            }else{
                List<FIncomeInvoice>list = map.get(entity.getTaxno());
                if(list.size()>=2000){
                    continue;
                }
                list.add(entity);
            }
        }
        return map;
    }

}
