LotQueryServiceImpl.java

package com.mycim.server.wip.service;

import com.alipay.sofa.runtime.api.annotation.SofaService;
import com.alipay.sofa.runtime.api.annotation.SofaServiceBinding;
import com.fa.sesa.monitor.datapermission.DataPermission;
import com.fa.sesa.threadlocal.LocalContext;
import com.mycim.framework.jdbc.Page;
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.server.base.manager.NamedObjectManager;
import com.mycim.server.ctx.exec.manager.WflLinkContextValueManager;
import com.mycim.server.ctx.manager.ContextValueManager;
import com.mycim.server.prp.manager.WorkflowManager;
import com.mycim.server.spc.manager.SpcManager;
import com.mycim.server.spec.manager.AttributeConvertManager;
import com.mycim.server.system.manager.ReferenceFileManager;
import com.mycim.server.wip.manager.LotAttributeQueryManager;
import com.mycim.server.wip.manager.LotQueryManager;
import com.mycim.server.wip.manager.UnitQueryManager;
import com.mycim.utils.WflLinkContextSetupAttributeUtil;
import com.mycim.utils.WipUtils;
import com.mycim.valueobject.ObjectList;
import com.mycim.valueobject.consts.ReferenceDetailNames;
import com.mycim.valueobject.consts.ReferenceFileConst;
import com.mycim.valueobject.consts.ReworkConst;
import com.mycim.valueobject.prp.*;
import com.mycim.valueobject.spc.SpcResult;
import com.mycim.valueobject.wip.*;
import com.mycim.valueobject.wip.dto.LotQueryParameterDto;
import com.mycim.valueobject.wip.dto.ShipQueryConditionDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.Override;
import java.sql.Timestamp;
import java.util.*;

/**
 * lot 查询相关
 *
 * @author Administrator
 * @version 6.0.0
 * @date 2019/10/10
 **/
@Service
@SofaService(interfaceType = LotQueryService.class, bindings = {@SofaServiceBinding(bindingType = "bolt")})
public class LotQueryServiceImpl implements LotQueryService {

    @Autowired
    LotAttributeQueryManager lotAttributeQueryManager;

    @Autowired
    private LotQueryManager lotQueryManager;

    @Autowired
    private WorkflowManager workflowManager;

    @Autowired
    private NamedObjectManager namedObjectManager;

    @Autowired
    private WflLinkContextValueManager wflLinkContextValueManager;

    @Autowired
    private ReferenceFileManager referenceFileManager;

    @Autowired
    private ContextValueManager contextValueManager;

    @Autowired
    private UnitQueryManager unitQueryManager;

    @Autowired
    private SpcManager spcManager;

    @Autowired
    private AttributeConvertManager attributeConvertManager;


    @Override
    public long getLotRrn(String lotId) {
        return lotQueryManager.getLotRrn(lotId);
    }

    @Override
    public Lot getLot(long lotRrn) {
        return lotQueryManager.getLot(lotRrn);
    }

    @Override
    public Lot getLot(String lotId) {
        return getLot(getLotRrn(lotId));
    }

    @Override
    public LotExt getLotExt(LotExt lotExt) {
        return lotQueryManager.getLotExt(lotExt);
    }

    @Override
    public List<Map> getLotList4ExtAtEqpt(Map criterion) {
        return lotQueryManager.getLotList4ExtAtEqpt(criterion);
    }

    @Override
    public int getLotCountByStatus(String lotType, String... status) {
        return lotQueryManager.getLotCountByStatus(lotType, status);
    }

    @Override
    public Map<String, Object> getLotInfoByStatus(String lotType, int pageSize, int pageNum, String... status) {
        return lotQueryManager.getLotInfoByStatus(lotType, pageSize, pageNum, status);
    }

    @Override
    public Lot getLotByCarrierId(String carrierId, Long facilityRrn) {
        return lotQueryManager.getLotByCarrierId(carrierId, facilityRrn);
    }

    @Override
    public Lot getLot(String lotId, long facilityRrn) {
        return lotQueryManager.getLot(lotId, facilityRrn);
    }

    @Override
    public List getChildLotsForMerge(Lot lot) {
        return lotQueryManager.getChildLotsForMerge(lot);
    }

    @Override
    public long getLotRrnByExecutionRrn(long executionRrn) {
        return lotQueryManager.getLotRrnByExecutionRrn(executionRrn);
    }

    @Override
    public Page queryLotStepHistory(Page page, String lotId) {
        return lotQueryManager.queryLotStepHistory(page, lotId);
    }

    @Override
    public Map getLotInfoasMap(long facilityRrn, String lotId, Long carrierRrn) {
        return lotQueryManager.getLotInfoasMap(facilityRrn, lotId, carrierRrn);
    }

    @Override
    public Map getLotInfoasMap(long facilityRrn, String lotId) {
        return lotQueryManager.getLotInfoasMap(facilityRrn, lotId);
    }

    @Override
    public Long getCount(String tblName, Map condition) {
        return lotQueryManager.getCount(tblName, condition);
    }

    @Override
    public List qryLotTransHistory(Map map, int current, int pageSize) {
        return lotQueryManager.qryLotTransHistory(map, current, pageSize);
    }

    @Override
    public List<Map> qryAllLotAdjustDetail(Long lotRrn) {
        return lotQueryManager.qryAllLotAdjustDetail(lotRrn);
    }

    @Override
    public Map qryAdjustTransHistory(Long transRrn, Long lotRrn) {
        return lotQueryManager.qryAdjustTransHistory(transRrn, lotRrn);
    }

    @Override
    public Map getLotStepHisotryInfoByOperationRrn(Map info) {
        return lotQueryManager.getLotStepHisotryInfoByOperationRrn(info);
    }

    @Override
    public Map qryTransHistoryDetail(Long transRrn, Long lotRrn) {
        return lotQueryManager.qryTransHistoryDetail(transRrn, lotRrn);
    }

    @Override
    public List<Map> queryAllLotTrans(Long lotRrn) {
        return lotQueryManager.queryAllLotTrans(lotRrn);
    }

    @Override
    public String queryLotPurposeByLotRrn(Long lotRrn) {
        return lotQueryManager.queryLotPurposeByLotRrn(lotRrn);
    }

    @Override
    public Map qryLotAfterTransDetail(Long transRrn, Long lotRrn) {
        return lotQueryManager.qryLotAfterTransDetail(transRrn, lotRrn);
    }

    @Override
    public List qryLotCreateHistory(long lotRrn, int current, int pageSize) {
        return lotQueryManager.qryLotCreateHistory(lotRrn, current, pageSize);
    }

    @Override
    public Page qryLotHoldReleaseHistory(Page page, long lotRrn, String lotTransId, String type) {
        return lotQueryManager.qryLotHoldReleaseHistory(page, lotRrn, lotTransId, type);
    }

    @Override
    public Page qryLotHoldInfoForRelease(Page page, long lotRrn, long transRrn) {
        return lotQueryManager.qryLotHoldInfoForRelease(page, lotRrn, transRrn);
    }

    @Override
    public List qryLotSplitMergeHistory(long lotRrn, String startDate, String endDate, Integer thisPage,
                                        Integer pageSize, String type, String sourceLotId) {
        return lotQueryManager
                .qryLotSplitMergeHistory(lotRrn, startDate, endDate, thisPage, pageSize, type, sourceLotId);
    }

    @Override
    public Page qryLotSplitMergeHistory(Page page, long lotRrn, String startDate, String endDate, String sourceLotId) {
        return lotQueryManager.qryLotSplitMergeHistory(page, lotRrn, startDate, endDate, sourceLotId);
    }

    @Override
    public Long qryLotSplitMergeHistoryCount(long lotRrn, String startDate, String endDate) {
        return lotQueryManager.qryLotSplitMergeHistoryCount(lotRrn, startDate, endDate);
    }

    @Override
    public List<Map> getScrapReasons(long lotRrn) {
        return lotQueryManager.getScrapReasons(lotRrn);
    }

    @Override
    public List<Lot> getLotsByJobRrn(Long jobRrn) {
        return lotQueryManager.getLotsByJobRrn(jobRrn);
    }

    @Override
    public String getMaxLotId(String lotId) {
        return lotQueryManager.getMaxLotId(lotId);
    }

    @Override
    public String getLotStatus(long lotRrn) {
        return lotQueryManager.getLotStatus(lotRrn);
    }

    @Override
    public Page qryLotStatus(Page page, Map condition) {
        return lotQueryManager.qryLotStatus(page, condition);
    }

    @Override
    public Map getQtyForUnscrap(long lotRrn) {
        return lotQueryManager.getQtyForUnscrap(lotRrn);
    }

    @Override
    public List<Map<String,Object>>qryLotHistoryExp(Long lotRrn) {
        return lotQueryManager.qryLotHistoryExp(lotRrn);
    }

    @Override
    public List<Map<String,Object>> qryLotHistoryExp(Long lotRrn, Integer startRow, Integer pageSize) {
        return lotQueryManager.qryLotHistoryExp(lotRrn, startRow, pageSize);
    }

    @Override
    public List qryLotStepHistoryComment(long lotRrn, long stepSequence, int thisPage, int pageSize) {
        return lotQueryManager.qryLotStepHistoryComment(lotRrn, stepSequence, thisPage, pageSize);
    }

    @Override
    public Map<Long, List<Map<String, Object>>> queryLotStepHistoryComments(Long lotRrn, Set<Long> stepSeq) {
        return lotQueryManager.queryLotStepHistoryComments(lotRrn,stepSeq);
    }

    @Override
    public List<Map> qryConditionCombo(String type, String cascadeSource) {
        return lotQueryManager.qryConditionCombo(type, cascadeSource);
    }

    @Override
    public List<Map> initLotStatusComboDoOrder() {
        return lotQueryManager.initLotStatusComboDoOrder();
    }

    @Override
    public List<Map> initLotPortalComboData(String type) {
        return lotQueryManager.initLotPortalComboData(type);
    }

    @Override
    @DataPermission
    public List<Map> initLotPortalComboDataWithPermission(String type) {
        return lotQueryManager.initLotPortalComboData(type);
    }

    @Override
    public List<Map> getWorkAreaAndEqptGroupAndStationComboData(String type, String operationRrns,
                                                                String cascadeSource) {
        return lotQueryManager.getWorkAreaAndEqptGroupAndStationComboData(type, operationRrns, cascadeSource);
    }

    @Override
    public List<Map<String, Object>> qryLotInfo(Map lotPortalFormMap, long facilityRrn, String rowStart,
                                                String pageSize) {
        return lotQueryManager.qryLotInfo(lotPortalFormMap, facilityRrn, rowStart, pageSize);
    }

    @Override
    public List<Map<String, Object>> ryAllLotInfoForLotPortal(LotQueryParameterDto lotQueryParameterDto) {
        return lotQueryManager.ryAllLotInfoForLotPortal(lotQueryParameterDto);
    }

    @Override
    public Page qryBondedMappingInfos(String tLotId, String tUnitId, String productId, String startDateStr,
                                      String endDateStr, Page page) {
        return lotQueryManager.qryBondedMappingInfos(tLotId, tUnitId, productId, startDateStr, endDateStr, page);
    }

    @Override
    public long getMaxOfLotByProduct(Long productRrn) {
        return lotQueryManager.getMaxOfLotByProduct(productRrn);
    }

    @Override
    public boolean isLotHaveMovein(long lotRrn) {
        return lotQueryManager.isLotHaveMovein(lotRrn);
    }

    @Override
    public int getTotalQtyForUnscrap(long lotRrn) {
        return lotQueryManager.getTotalQtyForUnscrap(lotRrn);
    }

    @Override
    public Lot getCompletedssLotInfo(String lotId) {
        return lotQueryManager.getCompletedssLotInfo(lotId);
    }

    @Override
    public String getPriorityText(Integer priority) {
        return lotQueryManager.getPriorityText(priority, LocalContext.getFacilityRrn());
    }

    @Override
    public String getUserName(String instanceId) {
        return lotQueryManager.getUserName(instanceId);
    }

    @Override
    public String getPriorityText(Integer priority, Long facilityRrn) {
        return lotQueryManager.getPriorityText(priority, facilityRrn);
    }

    @Override
    public List<Map<String, Object>> qryOperationParameters(Long lotRrn, Long stepSequence) {
        return lotQueryManager.qryOperationParameters(lotRrn, stepSequence);
    }

    @Override
    public Map getLotReworkInfo(Lot lot) {
        return lotQueryManager.getLotReworkInfo(lot);
    }

    @Override
    public List getSplitLotInfo(long lotRrn, long facilityRrn) {
        return lotQueryManager.getSplitLotInfo(lotRrn, facilityRrn);
    }

    @Override
    public boolean isMaterialMapping(Lot lot) {
        return lotQueryManager.isMaterialMapping(lot);
    }

    @Override
    public List<Map<String, Object>> getProcessAllReworkStepInfoByLot(long lotRrn, Long productRrn, String flowSeq,
                                                                      long pageSize, int processVersion,
                                                                      Integer productVersion) {

        Map<String, String> workAreaKeyMap = attributeConvertManager.getWorkAreaKeyMap();
        List<Map<String, Object>> reworkFetureStepProcessAllStepInfo = lotQueryManager.getProcessAllReworkStepInfoByLot
                (lotRrn, productRrn, flowSeq, pageSize, processVersion, productVersion);
        for (Map<String, Object> map : reworkFetureStepProcessAllStepInfo) {
            String workArea = MapUtils.getString(map, "workArea");
            if (StringUtils.isNotBlank(workArea) && StringUtils.isNotBlank(workAreaKeyMap.get(workArea))){
                map.put("workArea", workAreaKeyMap.get(workArea));
            }
        }
        return reworkFetureStepProcessAllStepInfo;
    }

    @Override
    public Map getReworkInfo(Long transRrn, Long lotRrn) {
        return lotQueryManager.getReworkInfo(transRrn, lotRrn);
    }

    @Override
    public List<Map> getHoldReasons(long lotRrn) {
        return lotQueryManager.getHoldReasons(lotRrn);
    }

    @Override
    public long getReworkSeq(long lotRrn, String reworkRouteRrn) {
        return lotQueryManager.getReworkSeq(lotRrn, reworkRouteRrn);
    }

    @Override
    public List<TimelimitStatus> getLotTimeLimitStatusForNormal() {
        return lotQueryManager.getLotTimeLimitStatusForNormal();
    }

    @Override
    public List<LotRecycledInfo> queryLotRecycledInfoByLotNoVersion(LotRecycledInfo lotRecycledInfo) {
        return lotQueryManager.queryLotRecycledInfoByLotNoVersion(lotRecycledInfo);
    }

    @Override
    public LotStepHistory getLotStepHistory(long lotRrn, long stepSequence) {
        return lotQueryManager.getLotStepHistory(lotRrn, stepSequence);
    }

    @Override
    public List<Map> getComboItems(long facilityRrn, String type, String likeValue) {
        return lotQueryManager.getComboItems(facilityRrn, type, likeValue);
    }

    @Override
    public Page getLotPlanPage(long facilityRrn, int pageSize, int pageNo, Map<String, Object> params) {
        return lotQueryManager.getLotPlanPage(facilityRrn, pageSize, pageNo, params);
    }

    @Override
    public long getParentLotRrn(long lotRrn) {
        return lotQueryManager.getParentLotRrn(lotRrn);
    }

    @Override
    public String getToCarrierTypeForChange(Lot lot) {
        return lotQueryManager.getToCarrierTypeForChange(lot);
    }

    @Override
    public List<LotProcessInfo> getLotProcessInfo(long lotRrn, String stepType) {
        return lotQueryManager.getLotProcessInfo(lotRrn, stepType);
    }

    @Override
    public String getMaxLotIdByProductType(String productType) {
        return lotQueryManager.getMaxLotIdByProductType(productType);
    }

    @Override
    public List<Map> getLotsList(Map actionMap) {
        return lotQueryManager.getLotsList(actionMap);
    }

    @Override
    public long getBatchRrn() {
        return lotQueryManager.getBatchRrn();
    }

    @Override
    public List<Map> getLotPriorityList(long productRrn) {
        return lotQueryManager.getLotPriorityList(productRrn);
    }

    @Override
    public List<Map> getHoldLotsList(Map actionMap) {
        return lotQueryManager.getHoldLotsList(actionMap);
    }

    @Override
    public String getBatchId(String lotId) {
        return lotQueryManager.getBatchId(lotId);
    }

    @Override
    public List<NpwBank> getNPWBankLot(Map<String, String> queryInfo) {
        return lotQueryManager.getNPWBankLot(queryInfo);
    }

    @Override
    public List<Map> getLotListAtEqpt(Long eqptRrn) {
        return lotQueryManager.getLotListAtEqpt(eqptRrn);
    }

    @Override
    public Map<String, Object> getComsumeLotsByEqpt(Lot lot, Integer lotSize) {
        return lotQueryManager.getComsumeLotsByEqpt(lot, lotSize);
    }

    @Override
    public String getSourceLotBondingTag(Long trLotProductRrn, Long soLotProductRrn, Long trOperationRrn) {
        return lotQueryManager.getSourceLotBondingTag(trLotProductRrn, soLotProductRrn, trOperationRrn);
    }

    @Override
    public LotSapphreInfo getLotSapphreInfo(Long lotRrn) {
        return lotQueryManager.getLotSapphreInfo(lotRrn);
    }

    @Override
    public List<Map> qryBondedLotInfos(Unit unit) {
        return lotQueryManager.qryBondedLotInfos(unit);
    }

    @Override
    public List<Map> qryBondedLotInfos(Lot lot) {
        return lotQueryManager.qryBondedLotInfos(lot);
    }

    @Override
    public List<Map> qryByBondedLotInfos(Unit unit) {
        return lotQueryManager.qryByBondedLotInfos(unit);
    }

    @Override
    public long queryLotStepEquipmentHistoryByLot(long lotRrn) {
        return lotQueryManager.queryLotStepEquipmentHistoryByLot(lotRrn);
    }

    @Override
    public int qryLotTransHistoryCount(long lotRrn) {
        return lotQueryManager.qryLotTransHistoryCount(lotRrn);
    }

    @Override
    public List<Map<String, Object>> queryLotListCache(LotQueryParameterDto queryParameterDto) {
        return lotQueryManager.queryLotListCache(queryParameterDto);
    }

    @Override
    @DataPermission
    public List<Map<String, Object>> queryLotListCacheWithDataPermission(LotQueryParameterDto queryParameterDto) {
        return lotQueryManager.queryLotListCache(queryParameterDto);
    }

    @Override
    public List getChildLotsForMergeWithActiveHold(Lot lot) {
        return lotQueryManager.getChildLotsForMergeWithActiveHold(lot);
    }

    @Override
    public List qryLotHistoryCommentByTime(long lotRrn) {
        return lotQueryManager.qryLotHistoryCommentByTime(lotRrn);
    }

    @Override
    public Map<String, Object> queryPriorityBeforeLastAdjust(long lotRrn, long transRrn) {
        return lotQueryManager.queryPriorityBeforeLastAdjust(lotRrn, transRrn);
    }

    @Override
    public int qryLotTransHisCountByStepseq(long lotRrn) {
        return lotQueryManager.qryLotTransHisCountByStepseq(lotRrn);
    }

    @Override
    public boolean checkMultipath(Lot lot, Long facilityRrn) {
        Collection operationPath = workflowManager
                .getWflPath(lot.getRouteRrn(), lot.getRouteVersion(), lot.getOperationId());
        Collection routePath = workflowManager
                .getWflPath(lot.getProcessRrn(), lot.getProcessVersion(), lot.getRouteId());
        if (CollectionUtils.isEmpty(operationPath) && CollectionUtils.isEmpty(routePath)) {
            return false;
        }

        boolean isByProdMultipath = false;
        if (CollectionUtils.isNotEmpty(routePath)) {

            WflLinkContextValue contextValue = new WflLinkContextValue();
            contextValue.setProcessRrn(lot.getProcessRrn());
            contextValue.setProcessVersion(lot.getProcessVersion());
            contextValue.setRouteRrn(lot.getRouteRrn());

            List<WflLinkContextValue> wflLinkContextValueList = wflLinkContextValueManager
                    .getContextValues(contextValue);
            if (CollectionUtils.isNotEmpty(wflLinkContextValueList)) {
                for (WflLinkContextValue ctx : wflLinkContextValueList) {
                    boolean tmpFlag = WflLinkContextSetupAttributeUtil.isByProdRouteMultipath(ctx);
                    isByProdMultipath = isByProdMultipath || tmpFlag;
                    if (tmpFlag && NumberUtils.toLong(ctx.getContextKey1()) == lot.getProductRrn().longValue()) {
                        return false;
                    }
                }
            }
        }

        if (CollectionUtils.isNotEmpty(operationPath)) {
            WflLinkContextValue contextValue = new WflLinkContextValue();
            contextValue.setProcessRrn(lot.getProcessRrn());
            contextValue.setProcessVersion(lot.getProcessVersion());
            contextValue.setRouteRrn(lot.getRouteRrn());
            contextValue.setOperationRrn(lot.getOperationRrn());

            List<WflLinkContextValue> wflLinkContextValueList = wflLinkContextValueManager
                    .getContextValues(contextValue);

            if (CollectionUtils.isNotEmpty(wflLinkContextValueList)) {
                for (ContextValue ctx : wflLinkContextValueList) {
                    boolean tmpFlag = WflLinkContextSetupAttributeUtil.isByProdOperationMultipath(ctx);
                    isByProdMultipath = isByProdMultipath || tmpFlag;
                    if (tmpFlag && NumberUtils.toLong(ctx.getContextKey1()) == lot.getProductRrn().longValue()) {
                        return false;
                    }
                }
            }
        }

        return isByProdMultipath;
    }

    @Override
    public List<Map<String, String>> getLotAdjustDataWithSimilarTime(Long lotRrn, Timestamp transStartTimestamp) {
        List<Map<String, String>> result = lotQueryManager
                .getLotPlanAdjustDataWithSimilarTime(lotRrn, transStartTimestamp);
        for (Map<String, String> map : result) {
            map.put("createCategory",
                    getReferValus(ReferenceDetailNames.LOT_CREATE_CATEGORY, MapUtils.getString(map, "createCategory")));
            map.put("hotFlag", getReferValus(ReferenceDetailNames.LOT_HOTFLAG, MapUtils.getString(map, "hotFlag")));
            map.put("priority", getReferValus(ReferenceDetailNames.LOT_PRIORITY, MapUtils.getString(map, "priority")));

            map.put("productId", namedObjectManager.getInstanceId(MapUtils.getLongValue(map, "productRrn")));
            map.put("processId", namedObjectManager.getInstanceId(MapUtils.getLongValue(map, "processRrn")));
            map.put("routeRrn", StringUtils
                    .toString(WipUtils.getRouteRrnByProcessStep(MapUtils.getString(map, "processStepVersion"))));
            map.put("routeId", namedObjectManager.getInstanceId(MapUtils.getLongValue(map, "routeRrn")));
            map.put("operationId", namedObjectManager.getInstanceId(MapUtils.getLongValue(map, "operationRrn")));
            map.put("operationDesc", namedObjectManager.getNamedObjectDesc(MapUtils.getLongValue(map, "operationRrn")));
        }

        return result;
    }

    @Override
    public String getDataCollectionUrlForDataCollectionTrans(long transRrn, Integer transSequence) {
        return lotQueryManager.getDataCollectionUrlForDataCollectionTrans(transRrn, transSequence);
    }

    @Override
    public Map<String, Object> getLotCurrentReworkInfo(Map condition) {
        Page page = new Page(1L);
        page.setPageNo(1L);
        Collection reworkHistoryInfo = this.getLotReworkHistoryInfoList(page, condition).getResults();
        if (!reworkHistoryInfo.isEmpty()) {
            return (Map<String, Object>) reworkHistoryInfo.iterator().next();
        }
        return null;
    }

    @Override
    public Page getLotReworkHistoryInfoList(Page page, Map condition) {
        Long facilityRrn = LocalContext.getFacilityRrn();
        page = lotQueryManager.getLotReworkHistoryInfoList(page, condition);
        long startRow = page.getStartRow();
        Collection reworkHistoryList = page.getResults();
        Iterator it = reworkHistoryList.iterator();
        while (it.hasNext()) {
            Map<String, Object> info = (Map<String, Object>) it.next();
            info.put("seq", startRow++);
            // info.put("reworkRouteId", getInstanceId(MapUtils.getLongValue(info, "reworkRouteRrn")));

            String reworkProcessStepVersion = MapUtils.getString(info, "reworkProcessStepVersion");
            String returnProcessStepVersion = MapUtils.getString(info, "returnProcessStepVersion");

            String[] returnProcessStepVersions = StringUtils.split(returnProcessStepVersion, "|");
            String returnOperationStr = returnProcessStepVersions[returnProcessStepVersions.length-1];

            Long returnOperationRrn = NumberUtils
                    .toLong(StringUtils.substring(returnOperationStr, 0, StringUtils.indexOf(returnOperationStr, ",")));

            String[] reworkVersions=   StringUtils.split(reworkProcessStepVersion, "|");
            String reworkOperationStr = reworkVersions[reworkVersions.length-1];
            Long reworkOperationRrn = NumberUtils
                    .toLong(StringUtils.substring(reworkOperationStr, 0, StringUtils.indexOf(reworkOperationStr, ",")));

            Long reworkRouteRrn = WipUtils.parseRouteRrn(reworkProcessStepVersion);
            Long returnRouteRrn = WipUtils.parseRouteRrn(returnProcessStepVersion);

            info.put("routeId", namedObjectManager.getInstanceId(reworkRouteRrn));
            info.put("returnRouteId", namedObjectManager.getInstanceId(returnRouteRrn));
            info.put("operationId", namedObjectManager.getInstanceId(reworkOperationRrn));
            info.put("returnOperationId", namedObjectManager.getInstanceId(returnOperationRrn));
            String tempReworkProcessStepVersion = new String(reworkProcessStepVersion);
            if (StringUtils.isNotBlank(reworkProcessStepVersion) &&
                    reworkProcessStepVersion.indexOf("|", reworkProcessStepVersion.indexOf("|") + 1) > 0) {
                int _sep = reworkProcessStepVersion.indexOf("|", reworkProcessStepVersion.indexOf("|") + 1);
                String routeVersion = reworkProcessStepVersion.substring(_sep - 1, _sep);

                ReworkRouteContextValue reworkRouteContextValue = new ReworkRouteContextValue();
                reworkRouteContextValue.setContextRrn(namedObjectManager
                                                              .getNamedObjectRrn(reworkRouteContextValue.getContextId(),
                                                                                 facilityRrn, ObjectList.CONTEXT_KEY));
                reworkRouteContextValue.setProcessRrn(MapUtils.getLong(info, "processRrn"));
                reworkRouteContextValue.setRouteRrn(reworkRouteRrn);
                reworkRouteContextValue.setContextKey4(routeVersion);
                reworkRouteContextValue.setOperationRrn(reworkOperationRrn);
                reworkRouteContextValue.setProcessVersion(MapUtils.getInteger(info, "processVersion"));
                ContextValue simulateContextValue = contextValueManager.simulateContextValue(reworkRouteContextValue);
                if (simulateContextValue != null) {
                    info.put("countWay", simulateContextValue.getResultValue6());
                    info.put("reworkRouteId", namedObjectManager
                            .getInstanceId(NumberUtils.toLong(simulateContextValue.getResultValue1())));
                    if (ReworkConst.CountWay.BY_ROUTE.getWay()
                                                     .equalsIgnoreCase(simulateContextValue.getResultValue6())) {
                        tempReworkProcessStepVersion = tempReworkProcessStepVersion
                                .substring(0, tempReworkProcessStepVersion.lastIndexOf("|"));
                    }
                }
            }
            Long reworkCountOfUnit = unitQueryManager.getMaxReworkCountByUnit(MapUtils.getLong(info, "transRrn"));

            info.put("reworkCountOfUnit", reworkCountOfUnit);
            info.put("reworkProcessStepVersion", tempReworkProcessStepVersion);

            String returnFlowSeq = StringUtils.EMPTY;
            ResequenceContextValue resequenceContextValue = new ResequenceContextValue();
            Long resequenceContextRrn = namedObjectManager
                    .getNamedObjectRrn(resequenceContextValue.getContextId(), facilityRrn, ObjectList.CONTEXT_KEY);
            resequenceContextValue.setContextRrn(resequenceContextRrn);
            resequenceContextValue.setProcessRrn(MapUtils.getLong(info, "processRrn"));
            resequenceContextValue.setRouteRrn(returnRouteRrn);
            resequenceContextValue.setOperationRrn(returnOperationRrn);
            resequenceContextValue.setProcessVersion(MapUtils.getInteger(info, "processVersion"));

            ContextValue simulateContextValue = contextValueManager.simulateContextValue(resequenceContextValue);
            if (simulateContextValue != null && StringUtils.isNotBlank(simulateContextValue.getResultValue1())) {
                returnFlowSeq = simulateContextValue.getResultValue1();
            }

            info.put("returnFlowSeq", returnFlowSeq);

            String reworkFlowSeq = StringUtils.EMPTY;
            resequenceContextValue = new ResequenceContextValue();
            resequenceContextValue.setContextRrn(resequenceContextRrn);
            resequenceContextValue.setProcessRrn(MapUtils.getLong(info, "processRrn"));
            resequenceContextValue.setRouteRrn(reworkRouteRrn);
            resequenceContextValue.setOperationRrn(reworkOperationRrn);
            resequenceContextValue.setProcessVersion(MapUtils.getInteger(info, "processVersion"));

            simulateContextValue = contextValueManager.simulateContextValue(resequenceContextValue);
            if (simulateContextValue != null && StringUtils.isNotBlank(simulateContextValue.getResultValue1())) {
                reworkFlowSeq = simulateContextValue.getResultValue1();
            }

            info.put("flowSeq", reworkFlowSeq);
        }
        return page;
    }

    @Override
    public long getReworkCount(Long lotRrn, String processStepVersion) {
        return lotQueryManager.getReworkCount(lotRrn, processStepVersion);
    }

    @Override
    public long getMaxReworkCountByUnit(Long lotRrn, String processStepVersion) {
        return unitQueryManager.getMaxReworkCountByUnit(lotRrn, processStepVersion);
    }

    @Override
    public String getOperationType(Lot lot) {
        String operationTypeCode = lotAttributeQueryManager.getOperationType(lot);

        String operationTypeDesc = referenceFileManager
                .getRefFileValue(ReferenceDetailNames.OPERATION_TYPE, operationTypeCode,
                                 ReferenceFileConst.DATA_1_VALUE);

        return StringUtils.isEmpty(operationTypeDesc) ? operationTypeCode : operationTypeDesc;
    }

    @Override
    public String getWorkArea(Lot lot) {
        String workAreaCode = lotAttributeQueryManager.getWorkArea(lot);

        String workAreaDesc = referenceFileManager
                .getRefFileValue(ReferenceDetailNames.WORK_AREA, workAreaCode, ReferenceFileConst.DATA_1_VALUE);

        return StringUtils.isEmpty(workAreaDesc) ? workAreaCode : workAreaDesc;
    }

    @Override
    public String getStageId(Lot lot) {
        String stageIdCode = lotAttributeQueryManager.getStageId(lot);

        String stageIdDesc = referenceFileManager
                .getRefFileValue(ReferenceDetailNames.STAGE_ID, stageIdCode, ReferenceFileConst.DATA_1_VALUE);

        return StringUtils.isEmpty(stageIdDesc) ? stageIdCode : stageIdDesc;
    }

    @Override
    public void checkLotUnitReworkSeq(Lot lot, String countWay, Integer maxReworkTime) {
        lotQueryManager.checkLotUnitReworkSeq(lot,countWay,maxReworkTime);
    }

    @Override
    public String getProcessLocation(Lot lot) {
        return lotAttributeQueryManager.getProcessLocation(lot);
    }

    @Override
    public LotProcessStepInfo getLotProcessStepInfo(long lotRrn, String stepType) {
        return lotQueryManager.getLotProcessStepInfo(lotRrn, stepType);
    }

    private String getReferValus(String ref, String key_value) {
        return referenceFileManager.getReferenceDetailExchange(ref, key_value, "DATA_1_VALUE");
    }

    @Override
    public Double getParameterValueForLot(Lot lot) {
        return lotQueryManager.getParameterValueForLot(lot);
    }

    @Override
    public boolean checkSetMultiPath(Lot lot, String roleType) {
        return lotQueryManager.checkSetMultiPath(lot, roleType);
    }

    @Override
    public boolean isMultipathRunningHoldStep(Lot lot) {
        return lotQueryManager.isMultipathRunningHoldStep(lot);
    }

    @Override
    public List<WflLinkContextValue> getMultiPathByLot(Lot lot) {
        return lotQueryManager.getMultiPathByLot(lot);
    }

    @Override
    public List<TimelimitStatus> getLotTimeLimitStatusByLotRrn(Long lotRrn, String targetStatus) {
        return lotQueryManager.getLotTimeLimitStatusByLotRrn(lotRrn, targetStatus);
    }

    @Override
    public List<Map> queryLotLoopInfo(long lotRrn, long processRrn, int processVersion) {
        return lotQueryManager.queryLotLoopInfo(lotRrn, processRrn, processVersion);
    }


    @Override
    public Page queryLotLoopHistoryInfo(Page page, long lotRrn, long processRrn) {
        return lotQueryManager.queryLotLoopHistoryInfo(page, lotRrn, processRrn);
    }

    @Override
    public List<Map> queryUnitLoopInfo(LotRecycledInfo LotRecycledInfo) {
        return lotQueryManager.queryUnitLoopInfo(LotRecycledInfo);
    }

    @Override
    public List<Map> queryUnitReworkInfo(long lotRrn, String processStepVersion) {
        return lotQueryManager.queryUnitReworkInfo(lotRrn, processStepVersion);
    }

    public Long getLotCountFormHistoryByCondition(Map conditionMap) {
        return lotQueryManager.getLotCountFormHistoryByCondition(conditionMap);
    }

    @Override
    public List<Map> getBatchBankInLots(Map map) {
        return lotQueryManager.getBatchBankInLots(map);
    }

    @Override
    public List<Bonding> getBondingsByLotRrn(long targetLotRrn, String sourceLotPlanType) {
        return lotQueryManager.getBondingsByLotRrn(targetLotRrn,sourceLotPlanType);

    }

    @Override
    public void checkLotStatus(List<String> lotRrns,List<String> status) {
        lotQueryManager.checkLotStatus(lotRrns,status);
    }

    @Override
    public MultiLot getMultiLotByCarrierId(String carrierId, Long facilityRrn) {
        return lotQueryManager.getMultiLotByCarrierId(carrierId, facilityRrn);
    }

    @Override
    public MultiLot getMultiLotByCarrierRrn(long carrierRrn) {
        return lotQueryManager.getMultiLotByCarrierRrn(carrierRrn);
    }

    @Override
    public SpcResult getSpcJobResultInfo(long lotRrn, long stepSequence, long dcolRrn) {
        return spcManager.getSpcResult(lotRrn, stepSequence, dcolRrn);
    }

    @Override
    public List<Map> getBatchAdjustLots(Map map) {
        return lotQueryManager.getBatchAdjustLots(map);
    }

    @Override
    public List<Map> getBatchCancelFutureHoldLots(Map map , long refRrn) {
        return lotQueryManager.getBatchCancelFutureHoldLots(map,refRrn);
    }

    @Override
    public List<Map> getLotList4Ship(ShipQueryConditionDto shipQueryConditionDto) {
        return lotQueryManager.getLotList4Ship(shipQueryConditionDto);
    }

    @Override
    public List<WflLinkContextValue> getMultiPathForLot(Lot lot) {
        WflLinkContextValue wflLinkContextValue = new WflLinkContextValue();
        wflLinkContextValue.setProcessRrn(lot.getProcessRrn());
        wflLinkContextValue.setProcessVersion(lot.getProcessVersion());
        wflLinkContextValue.setProductRrn(lot.getProductRrn());
        wflLinkContextValue.setRouteRrn(lot.getRouteRrn());
        List<WflLinkContextValue> contextValues = wflLinkContextValueManager
                .getContextValues(wflLinkContextValue);
        if (CollectionUtils.isEmpty(contextValues)) {
            contextValues = Collections.emptyList();
        }

        return contextValues;
    }

    @Override
    public int getLotWaferCount(Long lotRrn) {
        return lotQueryManager.getLotWaferCount(lotRrn);
    }

    @Override
    public List<Map<String,Object>> queryLotByOperatorPanel(LotQueryParameterDto lotQueryParameterDto) {
        return lotQueryManager.queryLotByOperatorPanel(lotQueryParameterDto);
    }

    @Override
    public Boolean getUnitBondingInfo(List<Map> unitList) {
        Boolean unitBondingFlag = true;
        for(Map unit : unitList) {
            Boolean flag = CollectionUtils.isNotEmpty(lotQueryManager.getUnitBondingInfo(MapUtils.getLong(unit, "unitRrn")));
            unitBondingFlag = unitBondingFlag && flag;
        }
        return unitBondingFlag;
    }
}