Ejemplo n.º 1
0
        /// <summary> 
        /// </summary>        
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IMB currentMB = (IMB)CurrentSession.GetValue(Session.SessionKeys.MB);
            IMBRepository currentMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();

            PcblotInfo conPcblot = new PcblotInfo();
            conPcblot.pcbno = currentMB.Sn;
            conPcblot.status = "1";

            IList<PcblotInfo> pcblotLst = new List<PcblotInfo>();
            pcblotLst = currentMBRepository.GetPcblotInfoList(conPcblot);
            foreach (PcblotInfo ipcblot in pcblotLst)
            {
                LotInfo conLotInfo = new LotInfo();
                conLotInfo.lotNo = ipcblot.lotNo;

                LotInfo setLotInfo = new LotInfo();
                setLotInfo.qty = 1;
                setLotInfo.editor = Editor;
                setLotInfo.udt = DateTime.Now;
                currentMBRepository.UpdateLotInfoForDecQtyDefered(CurrentSession.UnitOfWork, setLotInfo, conLotInfo);
            }

            if (pcblotLst == null || pcblotLst.Count <= 0)
            {
                //若@LotNo为空或者NULL,则不需要进行下面的操作,和贯伟确认,pcblotLst为空,不做操作
            }
            else
            {
                //Update PCBLot.Status=0 where Status=1 and PCBNo=@MBSN
                // 条件
                PcblotInfo consetPcblot = new PcblotInfo();
                consetPcblot.pcbno = currentMB.Sn;
                consetPcblot.status = "1";
                // 赋值
                PcblotInfo setPcblot = new PcblotInfo();
                setPcblot.status = "0";
                setPcblot.editor = Editor;
                setPcblot.udt = DateTime.Now;
                currentMBRepository.UpdatePCBLotInfoDefered(CurrentSession.UnitOfWork, setPcblot, consetPcblot);
            }
            return base.DoExecute(executionContext);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 刷mbsno,调用该方法启动工作流,根据输入mbsno获取Lot
        /// 返回MNSB LIST 
        /// </summary>
        /// <param name="mbsno">mbsno</param>
        /// <param name="editor">editor</param>
        /// <param name="station">station</param>
        /// <param name="customer">customer</param>
        /// <param name="curMBInfo">curMBInfo</param>
        /// <returns>model</returns>
        public ArrayList inputMBSnoORLotNo(string InputStr, string InputType, string editor, string station, string customer)
        {
            logger.Debug("(PCAOQCInputImpl)Input MBSN or LotNo start:" + InputStr + "editor:" + editor + "station:" + station + "customer:" + customer);

            FisException ex;
            List<string> erpara = new List<string>();
            ArrayList retLst = new ArrayList();
            IMBRepository iMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            string LotNO = "";
            ArrayList lstRet = new ArrayList();
           try
            {
                //若刷入数据为MBSN,获取MBSN的所在LotNo(PCBLot.LotNo where PCBNo=@MBSN and Status=1),
                // 则不存在记录,则报错:“该MBSN未组Lot”
                if (InputType == "MBSN")
                {
                    PcblotInfo conPcblot = new PcblotInfo();
                    conPcblot.pcbno = InputStr;
                    conPcblot.status = "1";
                    IList<PcblotInfo> pcblotLstA = new List<PcblotInfo>();
                    pcblotLstA = iMBRepository.GetPcblotInfoList(conPcblot);
                    if ((pcblotLstA == null) || (pcblotLstA.Count == 0))
                    {
                        erpara.Add(InputStr);
                        ex = new FisException("CHK312", erpara); //该MBSN未组Lot
                        throw ex;
                    }
                    if (pcblotLstA.Count==1)
                    {
                        LotNO = pcblotLstA[0].lotNo;
                    }
                    else
                    {
                        var pcblotLst =
                            from item in pcblotLstA
                            orderby item.cdt descending
                            select item;
                        foreach (PcblotInfo tmpNode in pcblotLst)
                        {
                            LotNO = tmpNode.lotNo;
                            break;
                        }
                    }
                  
                }
                else
                {
                    LotNO = InputStr;
                }
                
                string sessionKey = LotNO;

                //2、	获取LotNo的详细信息(Lot.* where Lot.LotNo=@LotNo);若Lot信息不存在,则报错:“该Lot不存在”
                LotInfo conLotInfo = new LotInfo();
                conLotInfo.lotNo = LotNO;
                IList<LotInfo> getLotInfo = iMBRepository.GetlotInfoList(conLotInfo);
                if ((getLotInfo == null) || (getLotInfo.Count == 0))
                {
                    erpara.Add(LotNO);
                    ex = new FisException("CHK313", erpara); //该Lot不存在
                    throw ex;
                }
                //若Lot.Status=’0’,则报错:“Lot没有组合完成”;
                if (getLotInfo[0].status == "0")
                {
                    erpara.Add(LotNO);
                    ex = new FisException("CHK314", erpara); //Lot没有组合完成
                    throw ex;
                }
                //若Lot.Status=’4’,则报错:“该Lot已解散”;
                if (getLotInfo[0].status == "4")
                {
                    erpara.Add(LotNO);
                    ex = new FisException("CHK315", erpara); //该Lot已解散
                    throw ex;
                }
                //若Lot.Status=’9’,则报错:“该Lot已经通过OQC”
                if (getLotInfo[0].status == "9")
                {
                    erpara.Add(LotNO);
                    ex = new FisException("CHK316", erpara); //该Lot已经通过OQC
                    throw ex;
                }
                //4、	Update Lot Status
                //若Lot.Status=1,则Update Lot.Status=2;
                //Update PCBStatus(where PCBNo in PCBLot.PCBNo and Status=1 and LotNo=@LotNo);
                UnitOfWork uow = new UnitOfWork(); 
                if (getLotInfo[0].status.Trim() == "1")
                {
                    LotInfo setLotInfo = new LotInfo();
                    conLotInfo = new LotInfo();
                    conLotInfo.lotNo = getLotInfo[0].lotNo;
                    //conLotInfo.type = strType;
                    //setLotInfo.qty = retlot[0].qty + 1;//1;//setValue.Qty赋1,其他按需要赋值即可
                    setLotInfo.status = "2";
                    setLotInfo.editor = editor;
                    setLotInfo.udt = DateTime.Now;
                    //itemRepository.UpdateLotInfoDefered(CurrentSession.UnitOfWork, setLotInfo, conLotInfo);
                    iMBRepository.UpdateLotInfoDefered(uow, setLotInfo, conLotInfo);
                //}
                    //DEBUG Mantis 1009(itc-1414-0224)
                    //update PCBStatus,PCBLog  ->条件也要: Lot.Status=1
                    
                   //Update PCBStatus:Station=’31A’Status=’1’
                    //Insert PCBLog
                    //Insert PCBLog:Station=’31A’Status=’1’
                    PcblotInfo conPcblot4 = new PcblotInfo();
                    //conPcblot = new PcblotInfo();
                    conPcblot4.lotNo= LotNO;
                    conPcblot4.status = "1";
                    IList<PcblotInfo>pcblotLst4 = new List<PcblotInfo>();
                    pcblotLst4 = iMBRepository.GetPcblotInfoList(conPcblot4);
                    if ((pcblotLst4 == null) || (pcblotLst4.Count == 0))
                    {

                    }
                    else
                    {
                        for (int i = 0; i < pcblotLst4.Count; i++)
                        {
                            IMB mb = iMBRepository.Find(pcblotLst4[i].pcbno);
                            if (mb != null)
                            {
                                mb.MBStatus.Station = "31A";
                                mb.MBStatus.Status = MBStatusEnum.Pass;
                                mb.MBStatus.Editor = editor;
                                mb.MBStatus.Udt = DateTime.Now;
                                //记录MB Log
                                MBLog mb_log = new MBLog(0, mb.Sn, mb.Model, "31A", (int) MBStatusEnum.Pass,
                                                         getLotInfo[0].line, editor, new DateTime());
                                mb.AddLog(mb_log);
                                iMBRepository.Update(mb, uow);
                            }
                        }
                    }
                }
                uow.Commit();

                //5、重新获取Lot信息,并显示LotNo Line[Line.Descr] Type PCS = Qty Status[2:OQC In;3:Locked]
                conLotInfo = new LotInfo();
                conLotInfo.lotNo = LotNO;
                IList<LotInfo> ReturnLotInfo = iMBRepository.GetlotInfoList(conLotInfo);
                ILineRepository lineRepository = RepositoryFactory.GetInstance().GetRepository<ILineRepository, Line>();
                Line lineInfo = lineRepository.Find(ReturnLotInfo[0].line);
                if (lineInfo == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK317", erpara); //该PCB %1 没有PdLine,请确认!
                    throw ex;
                }
                string lotLineinfo = ReturnLotInfo[0].line.Trim() + "[" +lineInfo.Descr.Trim() + "]";
                string strStatus="";
                if (ReturnLotInfo[0].status == "2")
                {
                    strStatus = "OQC In";
                }
                else if (ReturnLotInfo[0].status == "3")
                {
                    strStatus = "Locked";
                }
                //Old--获取PCBLot信息,并显示PCBLot.PCBNo where LotNo=@LotNo and Status=1
                //PcblotInfo RtnconPcblot = new PcblotInfo();
                //RtnconPcblot.lotNo = ReturnLotInfo[0].lotNo;
                //RtnconPcblot.status = "1";
                //IList<PcblotInfo> rtnpcblotLst = new List<PcblotInfo>();
                //rtnpcblotLst = iMBRepository.GetPcblotInfoList(RtnconPcblot);
                //IList<string> mbsnList = new List<string>();
                //foreach (PcblotInfo pcblotnode in rtnpcblotLst)
                //{
                //    mbsnList.Add(pcblotnode.pcbno.Trim());
                //}
               //UC Update 
               //	获取LotSetting.CheckQty(先用PdLine检索,若不存在,再用’ALL’检索,若不存在,则报错:“请IE维护LotSetting”),
               //若[Checked Qty]>=LotSetting.CheckQty,---则执行[4 Save Data] PASS分支:界面初始时不自动处理
                var checkQtyforLine = 0;
                LotSettingInfo conlotSetting = new LotSettingInfo();
                conlotSetting.line = ReturnLotInfo[0].line;
                //add type 
                conlotSetting.type = ReturnLotInfo[0].type;
                IList<LotSettingInfo> LotSettinglst = iMBRepository.GetLotSettingInfoList(conlotSetting);
                if ((LotSettinglst == null) || (LotSettinglst.Count == 0))
                {
                    conlotSetting = new LotSettingInfo();
                    conlotSetting.line = "ALL";
                    conlotSetting.type = ReturnLotInfo[0].type;
                    LotSettinglst = iMBRepository.GetLotSettingInfoList(conlotSetting);
                    if ((LotSettinglst == null) || (LotSettinglst.Count == 0))
                    {
                        //报错:“请与IE联系,维护 Lot 相关设置”
                        List<string> errpara = new List<string>();
                        //errpara.Add(currenMB.Sn);
                        FisException ex1 = new FisException("CHK278", errpara);
                        throw ex1;
                    }
                    else
                    {
                        checkQtyforLine = LotSettinglst[0].checkQty;
                    }
                }
                else
                {
                    checkQtyforLine = LotSettinglst[0].checkQty;
                }
               
               //======================================================================================
                //UC Update 2012/07/03 
                //6、	获取PCBLot信息,并显示在[MBSN List]和[Checked Qty]( [Checked Qty]: Sum(Checked))
                //参考方法:
                //select a.PCBNo, ISNULL(b.Status,'0') as Checked from PCBLot a
                //      left Join PCBLotCheck b
                //      on a..PCBNo where LotNo = b.=@LotNo
                //      and a.PCBNo = b.PCBNo
                //   where a.LotNo=@LotNo and a.Status=1
                //   order by a.PCBNo
                IList<string> mbsnList = new List<string>();
                IList<string> checkedList = new List<string>();
                DataTable PcbLotCheckedTable = iMBRepository.GetPcbNoAndCheckStatusList(ReturnLotInfo[0].lotNo, "1");
                if (PcbLotCheckedTable == null)
                {
                    //throw new FisException("CHM001", new string[] { model1 });
                }
                else
                {
                    var pcbLotCheckedCount = PcbLotCheckedTable.Rows.Count;
                    for (int i = 0; i < pcbLotCheckedCount; i++)
                    {
                        mbsnList.Add(PcbLotCheckedTable.Rows[i][0] as string);
                        checkedList.Add(PcbLotCheckedTable.Rows[i][1] as string);
                    }
                }
                var pcblotcheck = new PcblotcheckInfo();
                pcblotcheck.lotNo = LotNO;
                pcblotcheck.status = "1";
                var iCheckqty = iMBRepository.GetCountOfPcblotCheck(pcblotcheck);
                var havePromptstr = "";
                if (ReturnLotInfo[0].status !="2")
                {
                    try
                    {
                        throw new FisException("CHK401", new List<string>());

                    }
                    catch (FisException ex1)
                    {
                        havePromptstr = ex1.mErrmsg;
                    }
                }
             
                lstRet.Add(ReturnLotInfo[0].lotNo);      //0
                lstRet.Add(lotLineinfo);                 //1 
                lstRet.Add(ReturnLotInfo[0].type);       //2
                lstRet.Add(ReturnLotInfo[0].qty);        //3 
                lstRet.Add(strStatus);                   //4
                lstRet.Add(mbsnList);                    //5
                lstRet.Add(ReturnLotInfo[0].line);       //6
                lstRet.Add(checkedList);                 //7
                lstRet.Add(checkQtyforLine);             //8
                lstRet.Add(iCheckqty);                   //9
                lstRet.Add(havePromptstr);              //10
                return lstRet;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PCAOQCInputImpl)Input MBSN or LotNo end  Input:" + InputStr + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 扫描9999,结束工作流
        /// 如果没有Defect,即defectCodeList为null或cout为0
        /// 将Session.AddValue(Session.SessionKeys.HasDefect,false)
        /// 否则Session.AddValue(Session.SessionKeys.HasDefect,true)
        /// </summary>
        /// <param name="mbsno">mbsno</param>
        /// <param name="defectCodeList">defectCodeList</param>
        public string save(string LotNo, String strCMD, string editor, string line, string customer)
        {
            logger.Debug("(PCAOQCInputImpl)save start,"
                + " LotNo: " + LotNo
                + " KeyCode:" + strCMD);
            FisException ex;
            List<string> erpara = new List<string>();
            IMBRepository iMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            string returnstring = "OK";
            try
            {
                if (strCMD == "LOCK") //Update Lot.Status=3
                {
                    LotInfo setLotInfo = new LotInfo();
                    LotInfo conLotInfo = new LotInfo();
                    conLotInfo.lotNo = LotNo;
                    setLotInfo.status = "3";
                    setLotInfo.editor = editor;
                    setLotInfo.udt = DateTime.Now;
                    iMBRepository.UpdateLotInfo(setLotInfo, conLotInfo);
                }
                else if (strCMD == "UNLOCK") //Update Lot.Status=2
                {
                    LotInfo setLotInfo = new LotInfo();
                    LotInfo conLotInfo = new LotInfo();
                    conLotInfo.lotNo = LotNo;
                    setLotInfo.status = "2";
                    setLotInfo.editor = editor;
                    setLotInfo.udt = DateTime.Now;
                    iMBRepository.UpdateLotInfo(setLotInfo, conLotInfo);
                }
                else if (strCMD == "UNDO")
                {
                    UnitOfWork uow = new UnitOfWork();
                    //	Update Lot.Status=4
                    LotInfo setLotInfo = new LotInfo();
                    LotInfo conLotInfo = new LotInfo();
                    conLotInfo.lotNo = LotNo;
                    setLotInfo.status = "4";
                    setLotInfo.editor = editor;
                    setLotInfo.udt = DateTime.Now;
                    iMBRepository.UpdateLotInfoDefered(uow,setLotInfo, conLotInfo);
                    //Update PCBStatus where PCBNo in PCBLot.PCBNo and PCBLot.Status=1 and LotNo=#LotNo Station=10 Status=1
                    PcblotInfo conupPcblot = new PcblotInfo();
                    conupPcblot.lotNo= LotNo;
                    conupPcblot.status = "1";
                    IList<PcblotInfo> upPcblotLst = new List<PcblotInfo>();
                    upPcblotLst = iMBRepository.GetPcblotInfoList(conupPcblot);
                    if ((upPcblotLst == null) || (upPcblotLst.Count == 0))
                    {

                    }
                    else
                    {
                        for (int i = 0; i < upPcblotLst.Count; i++)
                        {
                            IMB mb = iMBRepository.Find(upPcblotLst[i].pcbno);
                            if (mb != null)
                            {
                                mb.MBStatus.Station = "10";
                                mb.MBStatus.Status = MBStatusEnum.Pass;
                                mb.MBStatus.Editor = editor;
                                mb.MBStatus.Udt = DateTime.Now;
                                //记录MB Log 	Insert PCBLog  Station=’31A’ Status=’0’ PdLine=‘UNDO
                                MBLog mb_log = new MBLog(0, mb.Sn, mb.Model, "31A", (int)MBStatusEnum.Fail, "UNDO", editor, new DateTime());
                                mb.AddLog(mb_log);
                                iMBRepository.Update(mb, uow);
                            }
                        }
                    }
                    //	Update PCBLot.Status=0
                    PcblotInfo conPcblot = new PcblotInfo();
                    PcblotInfo setPcblot = new PcblotInfo();
                    conPcblot.lotNo = LotNo;
                    setPcblot.status = "0";
                    iMBRepository.UpdatePCBLotInfoDefered(uow, setPcblot, conPcblot);
                    uow.Commit();
                }
                else if (strCMD == "PASS")
                {
                    //	若当前Lot.Status=’3’,则报错:“该Lot已锁定,请解锁后再做放行”
                    LotInfo conLotInfo = new LotInfo();
                    conLotInfo.lotNo = LotNo;
                    IList<LotInfo> getLotInfo = iMBRepository.GetlotInfoList(conLotInfo);
                    if (getLotInfo[0].status == "3")
                    {
                        erpara.Add(LotNo);
                        ex = new FisException("CHK319", erpara); //该Lot已锁定,请解锁后再做放行!
                        throw ex;
                    }
                    //	获取LotSetting.FailQty(先用PdLine检索,若不存在,再用’ALL’检索,若不存在,则报错:“请IE维护LotSetting”)
                    LotSettingInfo conlotSetting = new LotSettingInfo();
                    int failQtyforLine = 0;
                    conlotSetting.line = getLotInfo[0].line;
                    conlotSetting.type = getLotInfo[0].type;
                    IList<LotSettingInfo> LotSettinglst = iMBRepository.GetLotSettingInfoList(conlotSetting);
                    if ((LotSettinglst == null) || (LotSettinglst.Count == 0))
                    {
                        conlotSetting = new LotSettingInfo();
                        conlotSetting.line = "ALL";
                        conlotSetting.type = getLotInfo[0].type;
                        LotSettinglst = iMBRepository.GetLotSettingInfoList(conlotSetting);
                        if ((LotSettinglst == null) || (LotSettinglst.Count == 0))
                        {
                            //报错:“请与IE联系,维护 Lot 相关设置”
                            List<string> errpara = new List<string>();
                            errpara.Add(LotNo);
                            ex = new FisException("CHK278", errpara);
                            throw ex;
                        }
                        else
                        {
                            failQtyforLine = LotSettinglst[0].failQty;
                        }
                    }
                    else
                    {
                        failQtyforLine = LotSettinglst[0].failQty;
                    }
                    //	获取当前Lot的PCBLot.Status=0的数量@CNT,
                    //若@CNT大于或者等于LotSetting.FailQty,则Update Lot.Status=3,并提示:“该Lot抽检失败的数量过多,已被锁定”;
                    PcblotInfo conpassPcblot = new PcblotInfo();
                    conpassPcblot.lotNo = LotNo;
                    conpassPcblot.status = "0";
                    IList<PcblotInfo> passPcblotLst = new List<PcblotInfo>();
                    int pcbfailCount = 0;
                    passPcblotLst = iMBRepository.GetPcblotInfoList(conpassPcblot);
                    if ((passPcblotLst == null) || (passPcblotLst.Count == 0))
                    {
                        pcbfailCount = 0;
                    }
                    else
                    {
                        pcbfailCount = passPcblotLst.Count;
                    }
                    //int pcbfailCount = passPcblotLst.Count;
                    if (pcbfailCount >= failQtyforLine)
                    {
                        LotInfo setfailLotInfo = new LotInfo();
                        LotInfo confailLotInfo = new LotInfo();
                        confailLotInfo.lotNo = LotNo;
                        setfailLotInfo.status = "3";
                        setfailLotInfo.editor = editor;
                        setfailLotInfo.udt = DateTime.Now;
                        iMBRepository.UpdateLotInfo(setfailLotInfo, confailLotInfo);
                        List<string> errpara = new List<string>();
                        errpara.Add(LotNo);
                        ex = new FisException("CHK318", errpara);//该Lot抽检失败的数量过多,已被锁定
                        throw ex;
                    }
                    else
                    {
                        //Update Lot.Status=9;
                        UnitOfWork uof = new UnitOfWork(); 
                        LotInfo setfailLotInfo = new LotInfo();
                        LotInfo confailLotInfo = new LotInfo();
                        confailLotInfo.lotNo = LotNo;
                        setfailLotInfo.status = "9";
                        setfailLotInfo.editor = editor;
                        setfailLotInfo.udt = DateTime.Now;
                        iMBRepository.UpdateLotInfoDefered(uof,setfailLotInfo, confailLotInfo);
                        // Update PCBStatus where PCBNo in PCBLot.PCBNo and PCBLot.Status=1 (Station=31 and Status=1);
                        // Insert PCBLog (Station=31 and Status=1)
                        //UpdatePCBStatus(PCBStatusInfo setValue, PCBStatusInfo condition)
                        PcblotInfo conupPcblot = new PcblotInfo();
                        conupPcblot.lotNo = LotNo;
                        conupPcblot.status = "1";
                        IList<PcblotInfo> upPcblotLst = new List<PcblotInfo>();
                        upPcblotLst = iMBRepository.GetPcblotInfoList(conupPcblot);
                        if ((upPcblotLst == null) || (upPcblotLst.Count == 0))
                        {

                        }
                        else
                        {
                             for (int i = 0; i < upPcblotLst.Count; i++)
                            {
                                IMB mb = iMBRepository.Find(upPcblotLst[i].pcbno);
                                if (mb != null)
                                {
                                    //UC Update  
                                    //Update PCBStatus where PCBNo in PCBLot.PCBNo and PCBLot.Status=1 and  
                                    //Station=31A and Status=1【2012-6-20】 (Station=31 and Status=1);
                                    if ((mb.MBStatus.Station == "31A") && (mb.MBStatus.Status == MBStatusEnum.Pass))
                                    {
                                        mb.MBStatus.Station = "31";
                                        mb.MBStatus.Status = MBStatusEnum.Pass;
                                        mb.MBStatus.Editor = editor;
                                        mb.MBStatus.Udt = DateTime.Now;
                                        //记录MB Log 	Insert PCBLog (Station=31 and Status=1)
                                        MBLog mb_log = new MBLog(0, mb.Sn, mb.Model, "31", (int)MBStatusEnum.Pass, line, editor, new DateTime());
                                        mb.AddLog(mb_log);
                                        iMBRepository.Update(mb, uof);
                                    }
                                }
                            }
                        }
                        uof.Commit();
                    }

                }
                return returnstring;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(PCAOQCInputImpl)save end,"
                   + " LotNo: " + LotNo
                   + " KeyCode:" + strCMD);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            MB currenMB = CurrentSession.GetValue(Session.SessionKeys.MB) as MB;
            IMBRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository>();
            INumControlRepository numCtrlRepository = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>();
            //Modify UC Update 	前提条件:Station=15 ITC-1414-0024
            if (this.Station != "15")
            {
                return base.DoExecute(executionContext);
            }
    
            //-------------------------------------------------------------
            //2.28.	MBCode:若第6码为’M’,则取MBSN前3码为MBCode,若第5码为’M’,则取前2码
            //CheckCode:若MBSN的第5码为’M’,则取MBSN的第6码,否则取第7码
            string strMBCode ="";
            string strCheckCode = "";
            if (currenMB.Sn.Substring(5,1)=="M")
            {
                strMBCode = currenMB.Sn.Substring(0, 3);
                strCheckCode = currenMB.Sn.Substring(6, 1);
            }
            else if (currenMB.Sn.Substring(4,1)=="M")
            {
                strMBCode = currenMB.Sn.Substring(0, 2);
                strCheckCode = currenMB.Sn.Substring(5, 1);
            }
            else
            {
                strCheckCode = currenMB.Sn.Substring(6, 1);
            }
            //-------------------------------------------------------------
            //2.29.	MBSN子板/RCTO的判定:CheckCode为数字,则为子板,为’R’,则为RCTO
            if (strCheckCode == "R")
            {
                //为’R’,则为RCTO
            }
            else if (Char.IsNumber(strCheckCode, 0) == true)
            {
                //CheckCode为数字,则为子板
            }

            //Session.AddValue("IsDocking", true);
            // Docking  @Type=’PC’
            var isDocking = false;
            try
            {
                isDocking = (bool)CurrentSession.GetValue("IsDocking");
            }
            catch (Exception ex)
            {
                var strerr = ex.Message;
                isDocking = false;
            }
            //-------------------------------------------------------------
            //Type:
            //1、	若@MBSN的CheckCode为‘R’,则@Type=’RCTO’
            //2、	若IsFru Checked,则@Type=’Fru’
            //3、	其他,@Type=’PC’
            string strType = "";
            if (isDocking == false)
            {
                if (strCheckCode == "R")
                {
                    strType = "RCTO";
                }
                else if ((bool)CurrentSession.GetValue("bFruChecked")==true)
                {
                    strType = "Fru";
                }
                else
                {
                    strType = "PC";
                }
            }
            else
            {
                strType = "PC";
            }
            //-------------------------------------------------------------
            //[LotList]中是否存在@MBCode和@Type记录 +和@Line)
            //UC UPDATE 2012/06/20 LotList]中不存在(@MBCode、@Type、和@Line 和 Lot.Status=0)记录
            IMES.DataModel.LotInfo Conlot = new IMES.DataModel.LotInfo();
            Conlot.mbcode = strMBCode;
            Conlot.type = strType;
            Conlot.line = this.Line;
            Conlot.status = "0";//Add by kaisheng 2012/06/20
            IList<LotInfo> retlot = itemRepository.GetlotInfoList(Conlot);
            
                        
            if ((retlot == null) || (retlot.Count == 0))
            {
                //不存在@MBCode和@Type记录, 则执行‘15.1 LotNo生成规则’,产生该MBCode和Type的LotNo,并Insert Lot/PCBLot
                //LotNo规则:YYYYMMDDXXXX,XXXX代表流水码,10进制,自增,幅度为1
                // --------------------------------------------------------
                //1. LotNo生成
                string sublotNo = "";
                //string Watercode = "";
                sublotNo = DateTime.Today.Year.ToString("0000") + DateTime.Today.Month.ToString("00") + DateTime.Today.Day.ToString("00");
                try
                {

                    SqlTransactionManager.Begin();
                    lock (_syncRoot_GetSeq)
                    {
                        NumControl currentMaxNum = numCtrlRepository.GetMaxValue("LotNo", "LotNo");
                        if (currentMaxNum == null)
                        {
                            currentMaxNum = new NumControl();
                            currentMaxNum.NOType = "LotNo";
                            currentMaxNum.NOName = "LotNo";
                            currentMaxNum.Value = sublotNo + beginNO;
                            currentMaxNum.Customer = "";
                            numCtrlRepository.InsertNumControl(currentMaxNum);
                            SqlTransactionManager.Commit();
                            CurrentSession.AddValue(Session.SessionKeys.LotNo, sublotNo + beginNO);
                        }
                        else if (currentMaxNum.Value.Substring(0, 8) != sublotNo)
                        {
                            currentMaxNum.Value = sublotNo + beginNO;
                            IUnitOfWork uof = new UnitOfWork();
                            numCtrlRepository.Update(currentMaxNum, uof);
                            uof.Commit();
                            SqlTransactionManager.Commit();
                            CurrentSession.AddValue(Session.SessionKeys.LotNo, sublotNo + beginNO);
                        }
                        else
                        {
                            if (currentMaxNum.Value.EndsWith("9999"))
                            {
                                //SqlTransactionManager.Commit();
                                throw new FisException("CHK867", new string[] { }); //CHK, The Quantity of LotNo is full today, please contact IE!
                            }
                            else
                            {
                                ISequenceConverter seqCvt = new SequenceConverterNormal("0123456789", 4, "9999", beginNO, '0');
                                string sequenceNumber = currentMaxNum.Value.Substring(8, 4);
                                sequenceNumber = seqCvt.NumberRule.IncreaseToNumber(sequenceNumber, 1);
                                currentMaxNum.Value = sublotNo + sequenceNumber;//currentMaxNum.Value.Substring(0, 8) + sequenceNumber;
                                IUnitOfWork uof = new UnitOfWork();
                                numCtrlRepository.Update(currentMaxNum, uof);
                                uof.Commit();
                                SqlTransactionManager.Commit();
                                CurrentSession.AddValue(Session.SessionKeys.LotNo, sublotNo + sequenceNumber);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    SqlTransactionManager.Rollback();
                    throw e;
                }
                finally
                {
                    SqlTransactionManager.Dispose();
                    SqlTransactionManager.End();
                }
                
                //Insert Lot/PCBLot 
                //Insert Lot:LotNo=新产生No, Line=当前Line,Type=@Type, Qty=1, Status=0
                //Insert PCBLot:LotNo=@LotNo, PCBNo=@MBSN, Status=1
                LotInfo conLotInfo = new LotInfo();
                conLotInfo.lotNo = (string)CurrentSession.GetValue(Session.SessionKeys.LotNo);
                conLotInfo.line = this.Line;
                conLotInfo.mbcode = strMBCode;
                conLotInfo.type = strType;
                conLotInfo.qty = 1;
                conLotInfo.status = "0";
                conLotInfo.editor = this.Editor;
                itemRepository.InsertLotInfoDefered(CurrentSession.UnitOfWork, conLotInfo);
                PcblotInfo conPcblotInfo = new PcblotInfo();
                conPcblotInfo.lotNo = (string)CurrentSession.GetValue(Session.SessionKeys.LotNo);
                conPcblotInfo.pcbno = currenMB.Sn;
                conPcblotInfo.status = "1";
                conPcblotInfo.editor = this.Editor;
                itemRepository.InsertPCBLotInfoDefered(CurrentSession.UnitOfWork, conPcblotInfo);
                CurrentSession.AddValue("LotNoQty", 1);

            }
            else
            {
                LotInfo conLotInfo = new LotInfo();
                //Get Qty

                //conLotInfo.lotNo = retlot[0].lotNo;
                ////conLotInfo.type = strType;
                //IList<LotInfo> getLotInfo = itemRepository.GetlotInfoList(conLotInfo);
                //CurrentSession.AddValue("LotNoQty", getLotInfo[0].qty + 1);
                
                CurrentSession.AddValue("LotNoQty",retlot[0].qty + 1);
                
                    //存在@MBCode和@Type记录,则Update Lot,Insert PCBLot
                //Update Lot:Qty=Qty+1, Editor, Udt where LotNo=@LotNo
                //Insert PCBLot:LotNo=@LotNo, PCBNo=@MBSN, Status=1
                LotInfo setLotInfo = new LotInfo();
                conLotInfo = new LotInfo();
                conLotInfo.lotNo = retlot[0].lotNo;
                //conLotInfo.type = strType;
                //setLotInfo.qty = retlot[0].qty + 1;//1;//setValue.Qty赋1,其他按需要赋值即可
                setLotInfo.qty = 1;
                setLotInfo.editor = this.Editor;
                setLotInfo.udt = DateTime.Now;
                //itemRepository.UpdateLotInfoDefered(CurrentSession.UnitOfWork, setLotInfo, conLotInfo);
                itemRepository.UpdateLotInfoForIncQtyDefered(CurrentSession.UnitOfWork, setLotInfo, conLotInfo);
                PcblotInfo conPcblotInfo = new PcblotInfo();
                conPcblotInfo.lotNo = retlot[0].lotNo;
                conPcblotInfo.pcbno = currenMB.Sn;
                conPcblotInfo.status = "1";
                conPcblotInfo.editor = this.Editor;
                itemRepository.InsertPCBLotInfoDefered(CurrentSession.UnitOfWork, conPcblotInfo);

                
            }
            //GetPassQtyfromlotSetting -Activity
            // Defered方法, +1 可能没立即保存--如何确保Qty值 ?? --
            int passQtyforLine = (int)CurrentSession.GetValue("PassQtyinlotSetting");



            //2、	Check @MBCode和@Type对应的Qty,若Qty>=PassQty,则Update Lot
            //Update Lot:Status=1 where LotNo=@LotNo
            int currentQty = (int)CurrentSession.GetValue("LotNoQty");
            if (currentQty >= passQtyforLine)
            {

                LotInfo setLotInfo = new LotInfo();
                LotInfo conLotInfo = new LotInfo();
                //DEBUG Mantis 1005
                if ((retlot == null) || (retlot.Count == 0))
                    conLotInfo.lotNo = (string)CurrentSession.GetValue(Session.SessionKeys.LotNo);
                else
                    conLotInfo.lotNo = retlot[0].lotNo;
                setLotInfo.status = "1";
                setLotInfo.udt = DateTime.Now;
                itemRepository.UpdateLotInfoDefered(CurrentSession.UnitOfWork, setLotInfo, conLotInfo);
            }
            return base.DoExecute(executionContext);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 扫描9999,结束工作流
        /// </summary>
        /// <param name="mbsno">mbsno</param>
        public ArrayList save(string mbsno, string LotNo)
        {
            logger.Debug("(CombinePcbInLot)save start,"
                + " mbsno: " + mbsno
                + " LotNo:" + LotNo);
            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = mbsno;
            ArrayList retLst = new ArrayList();

            IMBRepository iMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            try
            {
                
                Session session = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.MB);
                MB currentMB = session.GetValue(Session.SessionKeys.MB) as MB;
                IMBRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository>();
                if (session == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    throw ex;
                }
                else
                {
                    session.AddValue(Session.SessionKeys.LotNo, LotNo);

                    //	Check Lot Qty
                    //重新获取被选择Lot的Lot.Qty,若Lot.Qty大于UI的[Lot Qty],
                    //则提示用户:“LotNo:XXX已满,请重新选择Lot”,并重新执行‘3.4 Get [Lot List]’
                    var lotQty = (int)session.GetValue("PassQtyinlotSetting");
                    LotInfo conLotInfock = new LotInfo();
                    conLotInfock.lotNo = LotNo;
                    IList<LotInfo> getLotInfo = iMBRepository.GetlotInfoList(conLotInfock);
                    if ((getLotInfo == null) || (getLotInfo.Count == 0))
                    {
                        erpara.Add(LotNo);
                        Cancel(mbsno);
                        ex = new FisException("CHK313", erpara); //该Lot不存在
                        throw ex;
                    }
                    try
                    {
                        //UC Update 2012/07/16  Save时增加对Lot.Status的判断
                        var strStatus = getLotInfo[0].status;
                        session.AddValue("CurrentLotStatus", strStatus);
                        if (getLotInfo[0].qty >= lotQty)
                        {
                            erpara.Add(LotNo);
                            ex = new FisException("CHK279", erpara);
                            throw ex;
                        }
                    }
                    catch (FisException ex1)
                    {
                        
                       //get list again!
                        String mbType = (string)session.GetValue("GetMBType");
                        int intDay = (int)session.GetValue("OQCTimeSpan");
                        int intLotqty = (int)session.GetValue("PassQtyinlotSetting");
                        string[] statusparam = { "1", "2" };
                        IList<LotInfo> currentLotlst = itemRepository.GetLotList(statusparam, intDay, currentMB.MBStatus.Line, currentMB.MBCode, intLotqty);
                        IList<LotInfo> retorderbylot = new List<LotInfo>();
                        if (mbType.ToUpper() == "PC")
                        {
                            retorderbylot = (from item in currentLotlst where item.type == "PC" || item.type == "FRU" select item).ToList();//orderby item.cdt
                        }
                        else
                        {
                            retorderbylot = (from item in currentLotlst where item.type == mbType select item).ToList();//orderby item.cdt
                        }
                        for (int i = 0; i <= retorderbylot.Count - 1; i++)
                        {
                            retorderbylot[i].editor = retorderbylot[i].cdt.ToString();
                        }
                        List<string> strstatus = new List<string>();
                        for (int i = 0; i <= retorderbylot.Count - 1; i++)
                        {
                            switch (retorderbylot[i].status)
                            {
                                case ("0"):
                                    strstatus.Add("Not full");
                                    break;
                                case ("1"):
                                    strstatus.Add("Combine finished");
                                    break;
                                case ("2"):
                                    strstatus.Add("OQC In");
                                    break;
                                case ("3"):
                                    strstatus.Add("Lock");
                                    break;
                                case ("4"):
                                    strstatus.Add("Undo");
                                    break;
                                case ("9"):
                                    strstatus.Add("PASS");
                                    break;
                                default:
                                    strstatus.Add("Unkown");
                                    break;
                            }
                        }
                        session.AddValue("LotListforCombinePcb", retorderbylot);
                        retLst.Add("ReloadLotList");
                        retLst.Add(ex1.mErrmsg);
                        retLst.Add(retorderbylot);
                        retLst.Add(strstatus);
                        return retLst;
                    }
                   

                    session.Exception = null;
                    session.SwitchToWorkFlow();

                    if (session.Exception != null)
                    {
                        if (session.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            session.ResumeWorkFlow();
                        }

                        throw session.Exception;
                    }

                }
                retLst.Add("OK");
                return retLst;
            }
            catch (FisException ex1)
            {
                logger.Error(ex1.mErrmsg);
                throw ex1;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(CombinePcbInLot)save end,"
                   + " mbsno: " + mbsno
                  + " LotNo:" + LotNo);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// UpdateSelectLotStatus
        /// </summary>
        /// <param name="SelLotNoList"></param>
        /// <param name="pdline"></param>
        /// <returns></returns>
        public IList<LotInfo> UpdateSelectLotStatus(IList<string> SelLotNoList, string pdline)
        {
            IMES.DataModel.LotInfo Conlot = new IMES.DataModel.LotInfo();
            IMES.DataModel.LotInfo Setlot = new IMES.DataModel.LotInfo();
            
            Setlot.status ="1";
            IMBRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository>();
            for (var i = 0; i <SelLotNoList.Count; i++ )
            {
                Conlot.lotNo = SelLotNoList[i];
                itemRepository.UpdateLotInfo(Setlot,Conlot);
            }
            Conlot = new IMES.DataModel.LotInfo();
            Conlot.status = "0";
            Conlot.line = pdline;
            IList<LotInfo> retlot = itemRepository.GetlotInfoList(Conlot);
            //DEBUG ITC-14-14-0013 2012/05/31 add orderby cdt
            IList<LotInfo> retorderbylot = (from item in retlot orderby item.cdt select item).ToList();
            return retorderbylot;

        }
Ejemplo n.º 7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pdLine"></param>
        /// <returns></returns>
        public IList<LotInfo>GetLotInfoLst(string pdLine)
        {
             IMES.DataModel.LotInfo infolot = new IMES.DataModel.LotInfo();
             infolot.status = "0";
             infolot.line = pdLine; 
             IMBRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository>();
             IList<LotInfo> lstLot = itemRepository.GetlotInfoList(infolot);
             //DEBUG ITC-14-14-0013 2012/05/31 add orderby cdt
             IList<LotInfo> retorderbylot = (from item in lstLot orderby item.cdt select item).ToList();
             return retorderbylot; 

        }
Ejemplo n.º 8
0
        /// <summary>
        /// Update Lot
        /// Update Lot.Qty=Qty+1 where LotNo = (Select LotNo from PCBLot where PCBNo=@MBSN and Status=1)
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            //string mbsno = (string)CurrentSession.GetValue(Session.SessionKeys.MBSN);
            var mb = (IMB)CurrentSession.GetValue(Session.SessionKeys.MB);
            //FisException ex;
            List<string> erpara = new List<string>();

            string mbsno = mb.Sn;
            string SelectLotNo =(string)CurrentSession.GetValue(Session.SessionKeys.LotNo);

            IMBRepository iMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
           
            

            LotInfo conLotInfo = new LotInfo();
            conLotInfo.lotNo = SelectLotNo;

            LotInfo setLotInfo = new LotInfo();
            setLotInfo.qty = 1; // Qty赋要加的值
            setLotInfo.editor = Editor;
            setLotInfo.udt = DateTime.Now;

            iMBRepository.UpdateLotInfoForIncQtyDefered(CurrentSession.UnitOfWork, setLotInfo, conLotInfo);

            PcblotInfo checkInfo = new PcblotInfo();
            checkInfo.lotNo = SelectLotNo;
            checkInfo.pcbno = mbsno;
            checkInfo.status = "1";
            checkInfo.editor = Editor;
            //iMBRepository.InsertPcblotcheckInfoDefered(CurrentSession.UnitOfWork, checkInfo);
            iMBRepository.InsertPCBLotInfoDefered(CurrentSession.UnitOfWork, checkInfo);
            TestLog tItem;
            tItem = new TestLog(0, mbsno, this.Line, null, "15", new List<TestLogDefect>(), TestLog.TestLogStatus.Pass,"" , null,null,"Combine PCB In Lot",this.Editor, "MB", DateTime.Now);
            mb.AddTestLog(tItem);
            iMBRepository.Update(mb, CurrentSession.UnitOfWork);
            return base.DoExecute(executionContext);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Update Lot
        /// Update Lot.Qty=Qty-1 where LotNo = (Select LotNo from PCBLot where PCBNo=@MBSN and Status=1)
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            string mbsno = (string)CurrentSession.GetValue(Session.SessionKeys.MBSN);

            IList<string> pcblotnoList = new List<string>();

            pcblotnoList =(IList<string>) CurrentSession.GetValue(Session.SessionKeys.LotNoList);

            IMBRepository iMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();

            foreach (string ilotno in pcblotnoList)
            {
                LotInfo conLotInfo = new LotInfo();
                conLotInfo.lotNo = ilotno;

                LotInfo setLotInfo = new LotInfo();
                setLotInfo.qty = 1; // Qty赋要减的值
                setLotInfo.editor = Editor;
                setLotInfo.udt = DateTime.Now;

                iMBRepository.UpdateLotInfoForDecQtyDefered(CurrentSession.UnitOfWork, setLotInfo, conLotInfo);

                PcblotcheckInfo checkInfo = new PcblotcheckInfo();
                checkInfo.lotNo = ilotno;
                checkInfo.pcbno = mbsno;
                checkInfo.status = "0";
                checkInfo.editor = Editor;
                iMBRepository.InsertPcblotcheckInfoDefered(CurrentSession.UnitOfWork, checkInfo);
            }
            
            return base.DoExecute(executionContext);
        }