RunCardUtils.java
package com.mycim.valueobject.runcard.util;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.framework.utils.lang.math.NumberUtils;
import java.util.regex.Pattern;
/**
* RunCard 所用公用方法
*
* @author finatice.yang
* @date 2021/4/23
**/
public class RunCardUtils {
private static Pattern unitPattern = Pattern.compile("[^0-9]");
/**
* 获取普通lot对应的RunCard Lot Id
*
* @author finatice.yang
* @date 2021/4/23
* @version 6.0.0
**/
public static String buildMainRcLotId(String sourceLotId) {
return sourceLotId + RunCardConstants.MAINLOT_ID_IN_MES;
}
/**
* Main lot id 获取
*
* @author finatice.yang
* @date 2021/4/23
* @version 6.0.0
**/
public static String getMainLotId(String lotId) {
String returnLotId = lotId;
if (StringUtils.endsWith(lotId, RunCardConstants.MAINLOT_ID_IN_MES)) {
returnLotId = StringUtils.substringBefore(lotId, RunCardConstants.MAINLOT_ID_IN_MES);
} else if (StringUtils.contains(lotId, RunCardConstants.RECOVERY_RUN_CARD_LOT_IN_MES)) {
returnLotId = StringUtils.substringBefore(lotId, RunCardConstants.RECOVERY_RUN_CARD_LOT_IN_MES);
} else if (StringUtils.contains(lotId, RunCardConstants.SPLIT_RUN_CARD_LOT_IN_MES)) {
returnLotId = StringUtils.substringBefore(lotId, RunCardConstants.SPLIT_RUN_CARD_LOT_IN_MES);
}
return returnLotId;
}
/**
* 获取Run Card Unit Id
*
* @author finatice.yang
* @date 2021/4/23
* @version 6.0.0
**/
public static String buildRunCardUnitId(String unitId) {
return RunCardConstants.RUN_CARD_UNIT_ID_PREFIX + unitId;
}
/**
* 获取显示wafer id
*
* @author finatice.yang
* @date 2021/4/23
* @version 6.0.0
**/
public static String getShowUnitId(String unitId) {
return StringUtils.substringAfter(unitId, RunCardConstants.RUN_CARD_UNIT_ID_PREFIX);
}
/**
* 格式化出unitRrn
*
* @author finatice.yang
* @date 2021/4/30
* @version 6.0.0
**/
public static Long patternUnitRrn(String unitRrnStr) {
String unitRrn = unitPattern.matcher(unitRrnStr).replaceAll("");
return NumberUtils.toLong(unitRrn);
}
/**
* 新建Run Card Child Lot Id
*
* @author finatice.yang
* @date 2021/4/30
* @version 6.0.0
**/
public static String buildRunCardChildLotId(String lotId, int childCount, String runCardId) {
childCount = childCount + 1;
String countStr = childCount < 10 ? "0" + childCount : StringUtils.toString(childCount);
String childLotId = "";
if (StringUtils.startsWith(runCardId, "R")) {
childLotId = lotId + RunCardConstants.RECOVERY_RUN_CARD_LOT_IN_MES + countStr;
} else {
childLotId = lotId + RunCardConstants.SPLIT_RUN_CARD_LOT_IN_MES + countStr;
}
return childLotId;
}
/**
* 判断Run Card Lot Id 是否为RunCard Lot Id
*
* @author finatice.yang
* @date 2021/5/12
* @version 6.0.0
**/
public static boolean checkLotIdIsRunCardLot(String lotId) {
boolean isRunCardLotId = false;
if (StringUtils.endsWith(lotId, RunCardConstants.MAINLOT_ID_IN_MES)) {
isRunCardLotId = true;
} else if (StringUtils.contains(lotId, RunCardConstants.SPLIT_RUN_CARD_LOT_IN_MES) ||
StringUtils.contains(lotId, RunCardConstants.RECOVERY_RUN_CARD_LOT_IN_MES)) {
isRunCardLotId = true;
}
return isRunCardLotId;
}
/**
* 获取真实run card lot id
*
* @author finatice.yang
* @date 2021/8/16
* @version 6.0.0
**/
public static String buildRunCardLotId(String lotId) {
if (checkLotIdIsRunCardLot(lotId)) {
return lotId;
} else {
return buildMainRcLotId(lotId);
}
}
}