RunCardQueryManagerImpl.java
package com.mycim.server.wip.manager.impl;
import com.fa.sesa.threadlocal.LocalContext;
import com.mycim.framework.jdbc.Page;
import com.mycim.framework.utils.beans.BeanUtils;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.framework.utils.lang.collections.CollectionUtils;
import com.mycim.framework.utils.lang.collections.MapUtils;
import com.mycim.framework.utils.lang.math.NumberUtils;
import com.mycim.framework.utils.lang.time.DateUtils;
import com.mycim.server.base.manager.NamedObjectManager;
import com.mycim.server.ctx.exec.manager.ProcessOperationDescContextValueManager;
import com.mycim.server.ctx.exec.manager.ResequenceContextValueManager;
import com.mycim.server.prp.manager.OperationManager;
import com.mycim.server.spec.manager.AttributeConvertManager;
import com.mycim.server.system.manager.ReferenceFileManager;
import com.mycim.server.wip.dao.RunCardQueryDao;
import com.mycim.server.wip.manager.LotQueryManager;
import com.mycim.server.wip.manager.RunCardQueryManager;
import com.mycim.server.wip.manager.UnitQueryManager;
import com.mycim.utils.WipUtils;
import com.mycim.valueobject.ObjectList;
import com.mycim.valueobject.consts.ReferenceFileConst;
import com.mycim.valueobject.consts.SystemConstants;
import com.mycim.valueobject.prp.Operation;
import com.mycim.valueobject.runcard.dto.RunCardPortalQueryDTO;
import com.mycim.valueobject.runcard.util.RunCardConstants;
import com.mycim.valueobject.runcard.util.RunCardStoreSubStatus;
import com.mycim.valueobject.wip.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
* RunCardQueryManager实现
*
* @author pinyan.song
* @version 6.0.0
* @date 2019-10-9
**/
@Service
@Transactional
public class RunCardQueryManagerImpl implements RunCardQueryManager {
@Autowired
RunCardQueryDao runCardQueryDao;
@Autowired
UnitQueryManager unitQueryManager;
@Autowired
LotQueryManager lotQueryManager;
@Autowired
NamedObjectManager namedObjectManager;
@Autowired
OperationManager operationManager;
@Autowired
ProcessOperationDescContextValueManager operationDescContextValueManager;
@Autowired
ReferenceFileManager referenceFileManager;
@Autowired
ResequenceContextValueManager resequenceContextValueManager;
@Autowired
AttributeConvertManager attributeConvertManager;
@Override
public LotRunCard getLotRunCardByMainLot(Long lotRrn) {
List<String> status = new ArrayList<String>();
status.add("PROCESSING");
List<LotRunCard> runcardList = runCardQueryDao.getLotRunCardByLot(lotRrn, status);
return runcardList.size() == 1 ? runcardList.get(0) : null;
}
@Override
public List<LotRunCard> getLotRunCardByLot(long lotRrn, List<String> status) {
return runCardQueryDao.getLotRunCardByLot(lotRrn, status);
}
@Override
public LotRecoveryRunCard getLotRecoveryRunCard(Long runCardRrn) {
return runCardQueryDao.getLotRecoveryRunCard(runCardRrn);
}
@Override
public LotRunCard getLotRunCard(Long runCardRrn) {
return runCardQueryDao.getLotRunCard(runCardRrn);
}
@Override
public LotRunCardStore getSplitRunCardLotStore(long lotRrn) {
return runCardQueryDao.getSplitRunCardLotStore(lotRrn, 0L, null);
}
@Override
public List<LotRunCardSplit> getLotRunCardSplit(Long runCardRrn) {
List<LotRunCardSplit> splitList = runCardQueryDao.getLotRunCardSplitSet(runCardRrn);
return splitList;
}
@Override
public List<LotRunCardStep> getLotRunCardStepList(Long runCardRrn, Integer splitSeq) {
List<LotRunCardSplit> splitSetList = runCardQueryDao.getLotRunCardSplitSet(runCardRrn);
String stepSerials = "";
for (LotRunCardSplit splitSet : splitSetList) {
if (splitSet.getSplitSeq().intValue() == splitSeq.intValue()) {
stepSerials = splitSet.getStepSerials();
}
}
List<String> stepSerialList = Arrays.asList(StringUtils.split(stepSerials, ","));
List<LotRunCardStep> lotRunCardStepList = new ArrayList<>();
List<LotRunCardStep> allStepList = runCardQueryDao.getLotRunCardStepList(runCardRrn);
for (LotRunCardStep lotRunCardStep : allStepList) {
if (stepSerialList.contains(lotRunCardStep.getStepSerialNo().toString())) {
lotRunCardStepList.add(lotRunCardStep);
}
}
return lotRunCardStepList;
}
@Override
public List<LotRunCardStep> getLotRunCardStepList(Long runCardRrn) {
List<LotRunCardStep> data = runCardQueryDao.getLotRunCardStepList(runCardRrn);
return CollectionUtils.isEmpty(data) ? Collections.emptyList() : data;
}
@Override
public LotRunCardStep getLotRunCardStep(Long lotRrn) {
SRCLotSpecialStep specialStep = getLotSplitRunCardSpecialStep(lotRrn);
if (Objects.nonNull(specialStep)) {
return getLotRunCardStep(specialStep.getRuncardRrn(), NumberUtils.toInt(specialStep.getStepNo()));
}
return null;
}
@Override
public LotRunCardStep getLotRunCardStep(Long runCardRrn, int stepSerialNo) {
return runCardQueryDao.getLotRunCardStep(runCardRrn, stepSerialNo);
}
@Override
public List<LotRunCardStepParameter> getLotRunCardStepParameterList(Long runCardRrn) {
List<LotRunCardStepParameter> data = runCardQueryDao.getLotRunCardStepParameterList(runCardRrn);
return CollectionUtils.isEmpty(data) ? Collections.emptyList() : data;
}
@Override
public List<LotRunCardStepParameter> getLotRunCardStepParameterList(Long runCardRrn, Integer stepSerialNo,
Long parameterSetRrn) {
List<LotRunCardStepParameter> data = runCardQueryDao
.getLotRunCardStepParameterList(runCardRrn, stepSerialNo, parameterSetRrn);
return CollectionUtils.isEmpty(data) ? Collections.emptyList() : data;
}
@Override
public LotRunCardStore getSplitRunCardLotStore(long lotRrn, long runcardRrn) {
return runCardQueryDao.getSplitRunCardLotStore(lotRrn, runcardRrn, null);
}
@Override
public LotRunCardStore getSplitRunCardLotStore(String showLotId, Long runcardRrn) {
return runCardQueryDao.getSplitRunCardLotStore(0L, runcardRrn, showLotId);
}
@Override
public LotRunCard getOuterInfo(long lotRrn) {
LotRunCardStore lotStore = getSplitRunCardLotStore(lotRrn);
String mainLotId = lotStore.getMainLotId();
Lot lot = lotQueryManager.getLot(mainLotId, LocalContext.getFacilityRrn());
List<String> status = new ArrayList<String>();
status.add("PROCESSING");
List<LotRunCard> runcardList = runCardQueryDao.getLotRunCardByLot(lot.getLotRrn(), status);
LotRunCard lotRuncard = null;
for (LotRunCard runcard : runcardList) {
//chanclemovein 的rrc没有SplitOperationRrn,这里又要要兼容升版问题
if (StringUtils.equalsIgnoreCase(runcard.getSplitStepPath(), lotStore.getWflStep()) ||
(runcard.getSplitOperationRrn() == lotStore.getOperationRrn().longValue())) {
lotRuncard = runcard;
break;
}
}
return lotRuncard;
}
@Override
public List<Map<String, Object>> getRunCardLotsByRuncardRrn(Long runcardRrn) {
return runCardQueryDao.getRunCardLotsByRuncardRrn(runcardRrn);
}
@Override
public SRCLotSpecialStep getLotSplitRunCardSpecialStep(Long lotSpecialStepRrn, Integer stepSequence) {
return runCardQueryDao.getLotSplitRunCardSpecialStep(lotSpecialStepRrn, stepSequence);
}
@Override
public SRCLotSpecialStep getLotSplitRunCardSpecialStep(Long lotRrn) {
LotRunCardStore store = getSplitRunCardLotStore(lotRrn);
if (Objects.nonNull(store)) {
Long lotSpecialStepRrn = store.getLotSpecialStepRrn();
Integer stepSeq = store.getStepSequence();
return getLotSplitRunCardSpecialStep(lotSpecialStepRrn, stepSeq);
}
return null;
}
@Override
public List<Map<String, Object>> getSplitedRunCardLots(long runcardRrn) {
return runCardQueryDao.getSplitedRunCardLots(runcardRrn);
}
@Override
public Map<String, Object> getLotRunCardReviewQueueHistory(Long transRrn, Integer transSequence) {
return runCardQueryDao.getLotRunCardReviewQueueHistory(transRrn, transSequence);
}
@Override
public LotRunCardReviewQueue getLotRunCardReviewQueue(Long runCardRrn, Integer queueSequence) {
return runCardQueryDao.getLotRunCardReviewQueue(runCardRrn, queueSequence);
}
@Override
public LotRunCardReviewQueue getLotRunCardReviewQueueFirst(Long runCardRrn) {
return runCardQueryDao.getLotRunCardReviewQueueFirst(runCardRrn);
}
@Override
public LotRunCardReviewQueue getLotRunCardReviewQueueLast(Long runCardRrn) {
return runCardQueryDao.getLotRunCardReviewQueueLast(runCardRrn);
}
@Override
public List<LotRunCardReviewQueue> getLotRunCardReviewQueueByReviewRole(Long runCardRrn, String reviewRole) {
return runCardQueryDao.getLotRunCardReviewQueueByReviewRole(runCardRrn, reviewRole);
}
@Override
public boolean isRunCardId(String runCardId, String idType) {
return StringUtils.isNotEmpty(runCardId) && StringUtils.indexOf(runCardId, idType) == 0 &&
runCardId.length() == 15;
}
@Override
public Integer getLotRunCardReviewQueueFirstSeq(Long runCardRrn) {
LotRunCardReviewQueue lotRunCardReviewQueue = getLotRunCardReviewQueueFirst(runCardRrn);
if (lotRunCardReviewQueue == null) {
return 0;
}
return lotRunCardReviewQueue.getQueueSequence();
}
@Override
public String getLotRunCardReviewQueueFirstRole(Long runCardRrn) {
LotRunCardReviewQueue lotRunCardReviewQueue = getLotRunCardReviewQueueFirst(runCardRrn);
if (lotRunCardReviewQueue == null) {
return "MFG";
}
return lotRunCardReviewQueue.getReviewRole();
}
@Override
public List<LotRunCard> getEffectiveLotRuncardByLot(long lotRrn) {
List<String> status = new ArrayList<String>();
status.add("ACTIVE");
status.add("DRAFT");
status.add("SUBMIT");
return runCardQueryDao.getLotRunCardByLot(lotRrn, status);
}
@Override
public LotRunCard getLotSplitRunCardSetByLot(String lotId) {
LotRunCard lotRunCard = null;
if (StringUtils.contains(lotId, RunCardConstants.MAINLOT_ID_IN_MES)) {
String baseLotId = StringUtils.substringBefore(lotId, RunCardConstants.MAINLOT_ID_IN_MES);
Lot baseLot = lotQueryManager.getLot(baseLotId, LocalContext.getFacilityRrn());
Lot lot = lotQueryManager.getLot(lotId, LocalContext.getFacilityRrn());
List<String> status = new ArrayList<String>();
status.add("ACTIVE");
status.add("PROCESSING");
List<LotRunCard> runcardList = runCardQueryDao.getLotRunCardByLot(baseLot.getLotRrn(), status);
LotRunCardStore runcardStore = runCardQueryDao.getSplitRunCardLotStore(lot.getLotRrn(), 0, null);
if (CollectionUtils.isNotEmpty(runcardList) && runcardStore != null) {
for (LotRunCard runCard : runcardList) {
if (runcardStore.getRuncardRrn().longValue() == runCard.getRunCardRrn().longValue()) {
lotRunCard = runCard;
}
}
}
}
return lotRunCard;
}
@Override
public List<Map<String, Object>> qrySplitRunCardLotInfo(Map<String, Object> lotPortalFormMap, long facilityRrn,
String startRowStr, String pageSize) {
buildLotPortalConditionMap(lotPortalFormMap);
int startRow = 0;
int currentTotalRow = 10;
if (StringUtils.isNotBlank(startRowStr) && StringUtils.isNotBlank(pageSize)) {
try {
startRow = Integer.parseInt(startRowStr);
currentTotalRow = startRow + Integer.parseInt(pageSize);
} catch (Exception e) {
startRow = 0;
currentTotalRow = 10;
}
}
String refNamedSpace = namedObjectManager.getNamedSpace(LocalContext.getFacilityRrn(),
ObjectList.REFERENCE_FILE_KEY);
lotPortalFormMap.put("referenceNamedSpace", refNamedSpace);
lotPortalFormMap.put("facilityRrn", LocalContext.getFacilityRrn());
Map<String, Object> countMap = runCardQueryDao.queryRunCardLotCount(lotPortalFormMap);
List<Map<String, Object>> results = runCardQueryDao.querySplitRunCardLotInfoByPage(lotPortalFormMap, startRow,
currentTotalRow, countMap);
return results;
}
@Override
public Map<String, Object> getRCLotInfoMap(String lotId) {
long facilityRrn = LocalContext.getFacilityRrn();
Map<String, Object> lotInfoMap = new HashMap<>();
Lot mainLot = lotQueryManager.getLot(lotId, facilityRrn);
BeanUtils.copyBeanToMap(lotInfoMap, mainLot);
LotRunCardStore lotStore = getSplitRunCardLotStore(mainLot.getLotRrn());
if (lotStore == null) {
return lotInfoMap;
}
Lot lot = lotQueryManager.getLot(lotStore.getMainLotId(), facilityRrn);
// BeanUtils.copyBeanToMap(lotInfoMap, lot);
SystemConstants.copyBeanToMapIgnoreKeys(lotInfoMap, lot, "flipType", "carrierId");
if (mainLot.getLotRrn() == mainLot.getBasedLotRrn()) {
BeanUtils.copyBeanToMap(lotInfoMap, lotStore);
} else {
SystemConstants.copyBeanToMapIgnoreKeys(lotInfoMap, lotStore, "carrierId");
}
lotInfoMap.put("lotStatus", mainLot.getLotStatus());
lotInfoMap.put("duedate", DateUtils.formatDate(lot.getDueDate(), DateUtils.DATE_FORMAT4DAYD));
lotInfoMap.put("qty1", lot.getQty1().intValue());
String hotFlagString = "";
if (StringUtils.isNotBlank(lot.getHotFlag()) && StringUtils.isNotBlank(lot.getPriority().toString())) {
hotFlagString = lotQueryManager.getHotflagSplicingPriority(Integer.parseInt(lot.getHotFlag()),
lot.getPriority(), facilityRrn);
}
lotInfoMap.put("hotFlagString", hotFlagString);
LotExt lotExt = new LotExt();
lotExt.setLotRrn(lot.getLotRrn());
String customerId = lotQueryManager.getLotExt(lotExt).getCustomerId();
lotInfoMap.put("customerId", customerId);
lotInfoMap.put("lotPurpose", lot.getLotComments());
String nextStepVersion1 = MapUtils.getString(lotInfoMap, "nextStepVersion1");
if (StringUtils.isBlank(nextStepVersion1)) {
nextStepVersion1 = null;
}
Long productRrn = MapUtils.getLong(lotInfoMap, "productRrn");
Long processRrn = MapUtils.getLong(lotInfoMap, "processRrn");
Integer processVersion = MapUtils.getInteger(lotInfoMap, "processVersion");
Long routeRrn = WipUtils.getRouteRrnByProcessStep(nextStepVersion1);
Long operationRrn = MapUtils.getLong(lotInfoMap, "nextOperationRrn1");
SRCLotSpecialStep srcLotSpecialStep = getLotSplitRunCardSpecialStep(lotStore.getLotSpecialStepRrn(),
lotStore.getStepSequence() + 1);
List<LotRunCardStep> lotRunCardStepList = getLotRunCardStepList(lotStore.getRuncardRrn());
for (LotRunCardStep runcardStep : lotRunCardStepList) {
String stepPath = runcardStep.getStepPath();
if (StringUtils.isNotBlank(stepPath)) {
processRrn = new Long(stepPath.substring(0, stepPath.indexOf(".")));
stepPath = stepPath.substring(stepPath.indexOf("|"));
routeRrn = new Long(stepPath.substring(1, stepPath.indexOf(".")));
}
if (srcLotSpecialStep != null) {
if (NumberUtils.toInt(srcLotSpecialStep.getStepNo()) == runcardStep.getStepSerialNo()) {
operationRrn = runcardStep.getOperationRrn();
lotInfoMap.put("nextOperationId1", namedObjectManager.getInstanceId(operationRrn));
break;
}
} else {
//如果没有下一步,则下一步骤默认是显示空
lotInfoMap.put("nextOperationId1", "");
}
}
String nextOperationDesc1 = operationDescContextValueManager.getOperationDesc(productRrn, processRrn,
processVersion, routeRrn,
operationRrn);
if (StringUtils.isBlank(nextOperationDesc1)) {
lotInfoMap.put("nextOperationDesc1", "");
} else {
lotInfoMap.put("nextOperationDesc1", nextOperationDesc1);
}
lotInfoMap.put("splitMergeFlag", StringUtils.nullToStr(lot.getSplitMergeFlag()));
lotInfoMap.put("pollutionLevel", mainLot.getPollutionLevel());
String pollutionLevel = mainLot.getPollutionLevel();
String pollutionLevelColor = referenceFileManager.getReferenceDetailExchange("$$LOT_POLUTIONLEVEL",
pollutionLevel, "data_2_value");
if (StringUtils.isNotBlank(pollutionLevelColor)) {
String plBgColor = StringUtils.substringBefore(pollutionLevelColor, "$");
String plColor = StringUtils.substringAfter(pollutionLevelColor, "$");
lotInfoMap.put("plBgColor", plBgColor);
lotInfoMap.put("plColor", plColor);
}
lotInfoMap.put("qty1", mainLot.getQty1().intValue());
productRrn = MapUtils.getLong(lotInfoMap, "productRrn");
processRrn = MapUtils.getLong(lotInfoMap, "processRrn");
routeRrn = MapUtils.getLong(lotInfoMap, "routeRrn");
operationRrn = MapUtils.getLong(lotInfoMap, "operationRrn");
processVersion = MapUtils.getInteger(lotInfoMap, "processVersion");
lotInfoMap.put("flowSeq",
resequenceContextValueManager.getFlowSeq(processRrn, processVersion, operationRrn, routeRrn));
lotInfoMap.put("operationDesc",
operationDescContextValueManager.getOperationDesc(productRrn, processRrn, processVersion,
routeRrn, operationRrn));
lotInfoMap.put("lotComments", lotQueryManager.getLotComments(lot));
// get lot q-time
/*int qTBufferTime = this.getQTBufferTime();
Map<String, Object> qTimeMap = this.getQtimeRemainTime(lot.getLotRrn());
if (StringUtils.equalsIgnoreCase("Y", MapUtils.getString(qTimeMap, "isRemainTime"))) {
lotInfoMap.put("qTime", MapUtils.getString(qTimeMap, "remainTime"));
lotInfoMap.put("qTBufferTime", qTBufferTime);
}*/
// get lot category
String lotCategoryStr = referenceFileManager.getRefFileValue("$LOT_CREATE_CATEGORY", lot.getCreateCategory(),
ReferenceFileConst.DATA_1_VALUE);
lotInfoMap.put("lotCategoryStr", lotCategoryStr);
String consumedMaterial = lotQueryManager.getConsumedMaterial(lot.getLotRrn());
lotInfoMap.put("consumedMaterial", StringUtils.trimToEmpty(consumedMaterial));
if (StringUtils.equalsIgnoreCase(RunCardStoreSubStatus.SPLIT.toString(), lotStore.getSubStatus())) {
Long lotSpecialStepRrn = lotStore.getLotSpecialStepRrn();
Integer stepSeq = lotStore.getStepSequence();
SRCLotSpecialStep lotSpecialStep = getLotSplitRunCardSpecialStep(lotSpecialStepRrn, stepSeq);
if (lotSpecialStep != null) {
// BeanUtils.copyBeanToMap(lotInfoMap, lotSpecialStep);
// 避免被MainLot的FlipType覆盖
SystemConstants.copyBeanToMapIgnoreKeys(lotInfoMap, lotSpecialStep, "flipType");
if (mainLot.getEqptRrn() != null && mainLot.getEqptRrn() > 0) {
lotInfoMap.put("recipeId", mainLot.getRecipePhysicalId());
}
String stepNo = lotSpecialStep.getStepNo();
long runcardRrn = lotSpecialStep.getRuncardRrn();
List<LotRunCardStep> stepList = getLotRunCardStepList(runcardRrn);
for (LotRunCardStep runcardStep : stepList) {
if (NumberUtils.toInt(stepNo) == runcardStep.getStepSerialNo()) {
lotInfoMap.put("flowSeq", runcardStep.getFlowSeq());
lotInfoMap.put("operationId", namedObjectManager.getInstanceId(runcardStep.getOperationRrn()));
lotInfoMap.put("operationDesc", runcardStep.getComments());
}
}
}
} else if (StringUtils.equalsIgnoreCase(RunCardStoreSubStatus.BANKIN.toString(), lotStore.getSubStatus()) &&
StringUtils.equals(LotStatus.WAITING, MapUtils.getString(lotInfoMap, "lotStatus"))) {
lotInfoMap.put("recipeId", "");
lotInfoMap.put("lotStatus", RunCardConstants.SHOW_RUNCARD_MAIN_LOT_STATUS_WAITING_SPLIT);
} else if (StringUtils.equalsIgnoreCase(RunCardStoreSubStatus.AUTO.toString(), lotStore.getSubStatus())) {
if (StringUtils.equals(LotStatus.WAITING, MapUtils.getString(lotInfoMap, "lotStatus"))) {
lotInfoMap.put("recipeId", "");
lotInfoMap.put("lotStatus", RunCardConstants.SHOW_RUNCARD_MAIN_LOT_STATUS_WAITING_REPOS);
} else if (StringUtils.equals(LotStatus.RUNNING, MapUtils.getString(lotInfoMap, "lotStatus"))) {
LotRecoveryRunCard recoveryRunCard = getLotRecoveryRunCard(MapUtils.getLong(lotInfoMap, "runcardRrn"));
if (recoveryRunCard != null && !StringUtils.equalsIgnoreCase(RunCardStoreSubStatus.BANKOUT.toString(),
lotStore.getSubStatus())) {
String runcardAction = recoveryRunCard.getRunCardAction();
if (StringUtils.equalsIgnoreCase("CANCELTRACKIN", runcardAction)) {
lotInfoMap.put("lotStatus", RunCardConstants.SHOW_RUNCARD_MAIN_LOT_STATUS_WAITING_CANCEL);
} else if (StringUtils.equalsIgnoreCase("TRACKOUT", runcardAction)) {
lotInfoMap.put("lotStatus", RunCardConstants.SHOW_RUNCARD_MAIN_LOT_STATUS_WAITING_DISPATCH);
}
}
}
} else if (StringUtils.equals(LotStatus.RUNCARD_FINISH, MapUtils.getString(lotInfoMap, "lotStatus"))) {
lotInfoMap.put("recipeId", "");
}
String workArea = "";
if (StringUtils.isNotBlank(MapUtils.getString(lotInfoMap, "workArea"))) {
workArea = getReferValus("$$WORK_AREA", MapUtils.getString(lotInfoMap, "workArea"));
} else {
Operation operation = operationManager.getOperation(MapUtils.getLongValue(lotInfoMap, "operationRrn"));
if (operation != null && StringUtils.isNotEmpty(operation.getWorkArea())) {
workArea = this.getReferValus("$$WORK_AREA", operation.getWorkArea());
}
}
lotInfoMap.put("workArea", workArea);
if (StringUtils.contains(lot.getLotId(), ".S")) {
lotInfoMap.put("mainLotId", lot.getLotId());
}
lotInfoMap.put("qTime", mainLot.getqTime());
lotInfoMap.put("qTimeBgc", mainLot.getqTimeBgc());
return lotInfoMap;
}
@Override
public RunCardLotInfo getRunCardLotInfo(String lotId) {
Long facilityRrn = LocalContext.getFacilityRrn();
RunCardLotInfo runCardLotInfo = new RunCardLotInfo();
Lot mainLot = lotQueryManager.getLot(lotId, facilityRrn);
if (Objects.isNull(mainLot)) {
return null;
}
BeanUtils.copyProperties(mainLot, runCardLotInfo);
LotRunCardStore lotStore = getSplitRunCardLotStore(mainLot.getLotRrn());
if (Objects.isNull(lotStore)) {
return runCardLotInfo;
}
Lot lot = lotQueryManager.getLot(lotStore.getMainLotId(), facilityRrn);
BeanUtils.copyProperties(lot, runCardLotInfo);
BeanUtils.copyProperties(lotStore, runCardLotInfo);
runCardLotInfo.setLotStatus(mainLot.getLotStatus());
runCardLotInfo.setQty1(lot.getInt_qty1());
String hotFlagString = "";
if (StringUtils.isNotBlank(lot.getHotFlag()) && StringUtils.isNotBlank(lot.getPriority().toString())) {
hotFlagString = lotQueryManager.getHotflagSplicingPriority(NumberUtils.toInt(lot.getHotFlag()),
lot.getPriority(), facilityRrn);
}
runCardLotInfo.setHotFlagString(hotFlagString);
Long lotSpecialStepRrn = lotStore.getLotSpecialStepRrn();
Integer stepSequence = lotStore.getStepSequence();
SRCLotSpecialStep lotSpecialStep = getLotSplitRunCardSpecialStep(lotSpecialStepRrn, stepSequence);
if (lotSpecialStep != null) {
BeanUtils.copyProperties(lotSpecialStep, runCardLotInfo);
}
return runCardLotInfo;
}
@Override
public Map<String, Object> getRCLotStepInfo(String lotId, Long runCardRrn) {
return runCardQueryDao.getRCLotStepInfo(lotId, runCardRrn);
}
@Override
public int getRCChildLotCount(String lotId, String runCardIdPrefix) {
return runCardQueryDao.getRCChildLotCount(lotId, LocalContext.getFacilityRrn(), runCardIdPrefix);
}
@Override
public Page qryRuncardLotTransHistory(Page page, Long lotRrn) {
return runCardQueryDao.qryRuncardLotTransHistory(page, lotRrn);
}
@Override
public List<Map<String, Object>> qryRuncardLotTransHistory(Map<String, Object> condition, int thisPage,
int pageSize) {
return paddingDataRuncardLotTransHis(runCardQueryDao.qryRuncardLotTransHistory(condition, thisPage, pageSize));
}
@Override
public String getRCRunCardIdByLotId(String lotId) {
return runCardQueryDao.getRCRunCardIdByLotId(lotId);
}
@Override
public List getSumbitAndActiveRunCardCreateTime(Long lotRrn) {
return runCardQueryDao.getSumbitAndActiveRunCardCreateTime(LocalContext.getFacilityRrn(), lotRrn);
}
@Override
public List<Map<String, Object>> queryFecthStepBySrc(long lotRrn) {
Map<String, String> flipTypeMap = attributeConvertManager.getFlipTypeKeyMap();
List<Map<String, Object>> results = runCardQueryDao.queryFecthStepBySrc(lotRrn);
results.forEach(r -> {
String flipType = MapUtils.getString(r, "flipType");
r.put("flipTypeDesc", MapUtils.getString(flipTypeMap, flipType));
});
return results;
}
@Override
public Map<String, Long> getRCLotRouteRrnAndOperationRrn(String lotId) {
return runCardQueryDao.getRCLotRouteRrnAndOperationRrn(lotId);
}
@Override
public List<Map<String, Object>> getRcLotInfoOfRcQtime(long lotRrn) {
return runCardQueryDao.getRcLotInfoOfRcQtime(lotRrn);
}
@Override
public Long getLotRrnByRunCardRrn(long runCardRrn) {
return runCardQueryDao.getLotRrnByRunCardRrn(runCardRrn);
}
private List<Map<String, Object>> paddingDataRuncardLotTransHis(List<Map<String, Object>> results) {
for (Map m : results) {
Long tempRrn = MapUtils.getLongValue(m, "productRrn");
m.put("product_id", namedObjectManager.getInstanceId(tempRrn));
tempRrn = MapUtils.getLongValue(m, "eqpt_rrn");
m.put("equipment_id", namedObjectManager.getInstanceId(tempRrn));
tempRrn = MapUtils.getLongValue(m, "operationRrn");
m.put("operationDesc", namedObjectManager.getNamedObjectDesc(tempRrn));
}
return results;
}
private String getReferValus(String ref, String key_value) {
return referenceFileManager.getReferenceDetailExchange(ref, key_value, "DATA_1_VALUE");
}
private Map<String, Object> buildLotPortalConditionMap(Map lotPortalFormMap) {
if (StringUtils.isNotBlank(MapUtils.getString(lotPortalFormMap, "lotId"))) {
lotPortalFormMap.put("lotId",
StringUtils.replace(MapUtils.getString(lotPortalFormMap, "lotId"), "*", "%").toString()
.toUpperCase());
}
if (MapUtils.getObject(lotPortalFormMap, "lotStatus") != null) {
String[] lotStatusArray = (String[]) MapUtils.getObject(lotPortalFormMap, "lotStatus");
if (lotStatusArray != null && lotStatusArray.length > 0) {
if (lotStatusArray.length != 1 || StringUtils.isNotEmpty(lotStatusArray[0])) {
lotPortalFormMap.put("lotStatusArray", lotStatusArray);
}
} else {
lotPortalFormMap.put("lotStatusArray", lotStatusArray);
}
}
if (MapUtils.getObject(lotPortalFormMap, "lotCategory") != null) {
String[] lotCategoryArray = (String[]) MapUtils.getObject(lotPortalFormMap, "lotCategory");
lotPortalFormMap.put("lotCategoryArray", lotCategoryArray);
} else {
lotPortalFormMap.put("lotCategory", StringUtils.EMPTY);
}
if (StringUtils.isNotBlank(MapUtils.getString(lotPortalFormMap, "productId"))) {
lotPortalFormMap.put("productId",
MapUtils.getString(lotPortalFormMap, "productId").replace("*", "").toUpperCase()
.replaceAll(",", "|"));
}
if (StringUtils.isNotBlank(MapUtils.getString(lotPortalFormMap, "processId"))) {
lotPortalFormMap.put("processId",
MapUtils.getString(lotPortalFormMap, "processId").replace("*", "%").toUpperCase());
}
if (StringUtils.isNotBlank(MapUtils.getString(lotPortalFormMap, "routeId"))) {
lotPortalFormMap.put("routeId",
MapUtils.getString(lotPortalFormMap, "routeId").replace("*", "%").toUpperCase());
}
if (StringUtils.isNotBlank(MapUtils.getString(lotPortalFormMap, "carrierId"))) {
lotPortalFormMap.put("carrierId",
StringUtils.replace(MapUtils.getString(lotPortalFormMap, "carrierId"), "*", "%")
.toString().toUpperCase());
}
if (StringUtils.isNotBlank(MapUtils.getString(lotPortalFormMap, "stationId"))) {
lotPortalFormMap.put("stationId",
MapUtils.getString(lotPortalFormMap, "stationId").replace("*", "%").toUpperCase());
}
if (StringUtils.isNotBlank(MapUtils.getString(lotPortalFormMap, "eqptGroupId"))) {
lotPortalFormMap.put("eqptGroupId",
MapUtils.getString(lotPortalFormMap, "eqptGroupId").replace("*", "%").toUpperCase());
}
if (StringUtils.isNotBlank(MapUtils.getString(lotPortalFormMap, "stageId"))) {
lotPortalFormMap.put("stageId",
MapUtils.getString(lotPortalFormMap, "stageId").replace("*", "%").toUpperCase());
}
if (StringUtils.isNotBlank(MapUtils.getString(lotPortalFormMap, "customId"))) {
lotPortalFormMap.put("customId", MapUtils.getString(lotPortalFormMap, "customId").replace("*", "%"));
}
if (StringUtils.isNotBlank(MapUtils.getString(lotPortalFormMap, "eqptId"))) {
lotPortalFormMap.put("eqptId",
MapUtils.getString(lotPortalFormMap, "eqptId").replace("*", "%").toUpperCase());
}
return lotPortalFormMap;
}
@Override
public List<Map<String, Object>> getRunCardGridInfo(String lotId) {
return runCardQueryDao.getRunCardGridInfo(lotId);
}
}