# AutoMonitorItemInqManagerImpl.java

    package com.mycim.server.automonitor.manager.impl;

    import com.mycim.framework.jdbc.Page;
    import com.mycim.framework.utils.lang.StringUtils;
    import com.mycim.server.automonitor.dao.AutoMonitorItemInqDao;
    import com.mycim.server.automonitor.manager.AutoMonitorItemInqManager;
    import com.mycim.valueobject.automonitor.dto.AutoMonitorItemQueryDTO;
    import com.mycim.valueobject.automonitor.entity.AutoMonitorItem;
    import com.mycim.valueobject.automonitor.entity.AutoMonitorItemStep;
    import com.mycim.valueobject.automonitor.entity.AutoMonitorItemStepEdcInfo;
    import com.mycim.valueobject.automonitor.util.AutoMonitorOperationConstants;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;

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

    /**
     * @author finatice.yang
     * @date 2021/8/27
     **/
    @Service
    public class AutoMonitorItemInqManagerImpl implements AutoMonitorItemInqManager {

        @Autowired
        AutoMonitorItemInqDao itemInqDao;

        @Override
        public AutoMonitorItem getAutoMonitorActiveItem(Long eqptRrn, String itemType) {
            return itemInqDao.getAutoMonitorActiveItem(eqptRrn,itemType);
        }

        @Override
        public AutoMonitorItem getAutoMonitorItem(Long eqptRrn, String itemType) {
            return itemInqDao.getAutoMonitorItem(eqptRrn,itemType);
        }

        @Override
        public AutoMonitorItem getAutoMonitorItem(Long workflowRrn, Integer workflowVersion) {
            return itemInqDao.getAutoMonitorItem(workflowRrn,workflowVersion);
        }

        @Override
        public List<AutoMonitorItem> getAutoMonitorItemList(AutoMonitorItemQueryDTO conditions) {
            return itemInqDao.getAutoMonitorItemList(conditions);
        }

        @Override
        public Page getAutoMonitorItemPage(Page page, AutoMonitorItemQueryDTO conditions) {
            return itemInqDao.getAutoMonitorItemPage(page,conditions);
        }

        @Override
        public List<String> getAutoMonitorItemTypeList(Long eqptRrn) {
            return itemInqDao.getAutoMonitorItemTypeList(eqptRrn);
        }

        @Override
        public AutoMonitorItemStep getAutoMonitorItemStep(Long workflowRrn, Integer workflowVersion, Long operationRrn) {
            return itemInqDao.getAutoMonitorItemStep(workflowRrn, workflowVersion, operationRrn);
        }

        @Override
        public List<AutoMonitorItemStep> getAutoMonitorItemSteps(Long workflowRrn, Integer workflowVersion) {
            List<AutoMonitorItemStep> stepList = itemInqDao.getAutoMonitorItemSteps(workflowRrn, workflowVersion);

            List<AutoMonitorItemStepEdcInfo> edcInfoList = itemInqDao.getItemStepEdcInfo(workflowRrn, workflowVersion);

            for (AutoMonitorItemStep step : stepList) {
                String nonRTSlotType = step.getNonRTSlotType();
                if (StringUtils.isBlank(nonRTSlotType)) {
                    step.setNonRTSlotType(AutoMonitorOperationConstants.STEP_SLOT_TYPE_LOT);
                } else if (StringUtils.equals(nonRTSlotType, AutoMonitorOperationConstants.STEP_SLOT_TYPE_PROCESS)) {
                    step.setNonRTSlotType(AutoMonitorOperationConstants.STEP_SLOT_TYPE_LOT);
                }
                if (StringUtils.equals(nonRTSlotType, AutoMonitorOperationConstants.STEP_SLOT_TYPE_LOT)) {
                    for (AutoMonitorItemStepEdcInfo edcInfo : edcInfoList) {
                        if (edcInfo.getStepSequence().longValue() == step.getStepSequence().longValue()) {
                            step.setNonRTJobIds(edcInfo.getNonRTJobIds());
                            step.setNonRTJobNames(edcInfo.getNonRTJobNames());
                            break;
                        }
                    }
                } else {
                    step.setWaferNonRTJobIds(new ArrayList<String>());
                    step.setWaferNonRTJobNames(new ArrayList<String>());
                    for (AutoMonitorItemStepEdcInfo edcInfo : edcInfoList) {
                        if (edcInfo.getStepSequence().longValue() == step.getStepSequence().longValue()) {
                            step.getWaferNonRTJobIds().add(edcInfo.getNonRTJobIds());
                            step.getWaferNonRTJobNames().add(edcInfo.getNonRTJobNames());
                        }
                    }
                }
            }

            return stepList;
        }

        @Override
        public List<AutoMonitorItemStepEdcInfo> getEdcInfoList(Long workflowRrn, Integer workflowVersion,
                                                               Long stepSequence) {
            return itemInqDao.getItemStepEdcInfo(workflowRrn,workflowVersion,stepSequence);
        }

    }