# AutoMonitorMoveInTaskManagerImpl.java

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

    import com.fa.sesa.exception.Assert;
    import com.fa.sesa.exception.Errors;
    import com.fa.sesa.threadlocal.LocalContext;
    import com.mycim.framework.utils.beans.BeanUtils;
    import com.mycim.framework.utils.beans.PropertyUtils;
    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.server.automonitor.manager.job.task.AutoMonitorMoveInTaskManager;
    import com.mycim.server.base.manager.NamedObjectManager;
    import com.mycim.server.rcp.manager.RecipeManager;
    import com.mycim.server.rcp.manager.RecipeVersionManager;
    import com.mycim.server.wip.manager.*;
    import com.mycim.utils.EmasUtil;
    import com.mycim.valueobject.ObjectList;
    import com.mycim.valueobject.SystemConstant;
    import com.mycim.valueobject.consts.SessionNames;
    import com.mycim.valueobject.consts.TransactionNames;
    import com.mycim.valueobject.prp.RecipeVersion;
    import com.mycim.valueobject.wip.Job;
    import com.mycim.valueobject.wip.Lot;
    import com.mycim.valueobject.wip.dto.LotBaseInfoDto;
    import com.mycim.valueobject.wip.dto.LotInfoDto;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    import java.util.*;

    @Service
    @Transactional
    public class AutoMonitorMoveInTaskManagerImpl implements AutoMonitorMoveInTaskManager {

        @Autowired
        private JobQueryManager jobQueryManager;

        @Autowired
        private JobManager jobManager;

        @Autowired
        private UnitQueryManager unitQueryManager;

        @Autowired
        private LotQueryManager lotQueryManager;

        @Autowired
        private NamedObjectManager namedObjectManager;

        @Autowired
        private RecipeManager recipeManager;

        @Autowired
        private RecipeVersionManager recipeVersionManager;

        @Autowired
        private LotManager lotManager;

        @Autowired
        private EquipmentRunHistoryReqManager equipmentRunHistoryReqManager;

        @Override
        public Map doExecute(Map parameters) {

            if (MapUtils.getBooleanValue(parameters, SystemConstant.Str.PAUSE_FLAG)) {
                return null;
            }

            long userRrn = MapUtils.getLongValue(parameters, "userRrn");
            long facilityRrn = MapUtils.getLongValue(parameters, "facilityRrn");
            long jobRrn = MapUtils.getLongValue(parameters, "jobRrn");

            Assert.state(jobRrn > 0, Errors.create().content("Parameters are not enough!").build());

            Job job = jobQueryManager.getJob(jobRrn);

            List<Lot> lotList = (List<Lot>) MapUtils.getObject(parameters, "lotList");
            Assert.state(CollectionUtils.isNotEmpty(lotList), Errors.create().content("Invalid lot size!").build());

            builMoveIn(job, lotList, parameters);

            parameters.put(SessionNames.RUNSTEP_FLAG, "0");

            return parameters;
        }

        public void builMoveIn(Job job, List lotList, Map parameters) {
            jobManager.moveInSpecial(job, lotList);
            parameters.put("jobRrn", job.getJobRrn() + "");
        }

    }