WetBatchUtils.java

package com.mycim.utils;

import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.valueobject.ems.Equipment;
import com.mycim.valueobject.wip.Lot;

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

/**
 * @Author: yibing.liu
 * @Date: 2022/1/4 15:13
 */
public class WetBatchUtils {

    public static String checkWetBatchList(List<Lot> lotList, Equipment equipment){
        String msg = StringUtils.EMPTY;
        Map<String, List<String>> wetMap = equipment.getWetMap();
        List<String> existList = new ArrayList<>();
        List<String> notExistList = new ArrayList<>();
        int count = 0, size = wetMap.size();
        for (List<String> list : wetMap.values()){
            String listTempStr = String.join(StringUtils.COMMA_SIGN, list);
            for (Lot l:lotList){
                if (StringUtils.contains(listTempStr, l.getProductId())){
                    existList.add(l.getLotId());
                } else {
                    notExistList.add(l.getLotId());
                }
            }
            if (existList.size() == lotList.size()){
                break;
            } else {
                if (++ count != size){
                    existList = new ArrayList<>();
                    notExistList = new ArrayList<>();
                }
            }
        }
        if (existList.size() != lotList.size()){
            msg = String.join(StringUtils.COMMA_SIGN, notExistList);
        }
        return msg;
    }

}