package com.unis.rotationPlan.info.modular.rpIssuance.util;

import com.unis.rotationPlan.info.modular.businessrpreport.entity.BusinessRpOutbound;

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

public class OutboundDataOrganizer {


    public static List<Map<String, Object>> organizeOutboundData(List<BusinessRpOutbound> outboundList) {
        Map<String, List<BusinessRpOutbound>> organizedData = new HashMap<>();

        // 处理出库数据
        for (BusinessRpOutbound outbound : outboundList) {
            String orgName = outbound.getOrgName(); // 假设BusinessRpOutbound有getOrgName方法
            organizedData.computeIfAbsent(orgName, k -> new ArrayList<>()).add(outbound);
        }

        // 构建最终结果
        List<Map<String, Object>> resultList = new ArrayList<>();
        for (Map.Entry<String, List<BusinessRpOutbound>> entry : organizedData.entrySet()) {
            Map<String, Object> orgData = new HashMap<>();
            orgData.put("orgName", entry.getKey());
            orgData.put("businessRpOutboundList", entry.getValue());
            resultList.add(orgData);
        }

        return resultList;
    }
}
