public string AddDetailToRSnStationDetail(string SNDetailID, R_SN SN, string Line, string StationName, string DeviceName, OleExec DB) { string result = string.Empty; string sql = string.Empty; T_R_SN_STATION_DETAIL Table_R_Sn_Station_Detail = new T_R_SN_STATION_DETAIL(DB, DBType); Row_R_SN_STATION_DETAIL row = null; if (SN != null && !string.IsNullOrEmpty(SN.ID)) { row = (Row_R_SN_STATION_DETAIL)ConstructRow(SN); row.ID = SNDetailID; row.R_SN_ID = SN.ID; row.CLASS_NAME = GetWorkClass(DB); row.LINE = Line; row.STATION_NAME = StationName; row.DEVICE_NAME = DeviceName; row.EDIT_TIME = GetDBDateTime(DB); if (this.DBType == DB_TYPE_ENUM.Oracle) { sql = row.GetInsertString(this.DBType); result = DB.ExecSQL(sql); return(result); } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } } return(result); }
/// <summary> // /check if the last station of the SN in the route is PASS /// </summary> /// <param name="sn"></param> /// <param name="station"></param> /// <param name="sfcdb"></param> /// <returns></returns> public bool TheLastStationIsPass(string sn, string station, OleExec sfcdb) { bool bPass = true; C_ROUTE_DETAIL lastSation = null; R_SN_STATION_DETAIL r_sn_station_detail = null; T_R_SN t_r_sn = new T_R_SN(sfcdb, this.DBType); T_C_ROUTE_DETAIL t_c_route_detail = new T_C_ROUTE_DETAIL(sfcdb, this.DBType); R_SN snObject = t_r_sn.LoadSN(sn, sfcdb); if (snObject != null) { if (!t_c_route_detail.StationInRoute(snObject.ROUTE_ID, station, sfcdb)) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000156", new string[] { sn, station })); } C_ROUTE_DETAIL currentStation = t_c_route_detail.GetByRouteIdOrderBySEQASC(snObject.ROUTE_ID, sfcdb).Find(s => s.STATION_NAME == station); List <C_ROUTE_DETAIL> routeList = t_c_route_detail.GetByRouteIdOrderBySEQASC(snObject.ROUTE_ID, sfcdb).FindAll(s => s.SEQ_NO < currentStation.SEQ_NO); if (routeList.Count > 0) { lastSation = routeList.OrderBy(t => t.SEQ_NO).LastOrDefault(); if (lastSation != null) { r_sn_station_detail = sfcdb.ORM.Queryable <R_SN_STATION_DETAIL>().Where(p => p.STATION_NAME == lastSation.STATION_NAME && p.ROUTE_ID == lastSation.ROUTE_ID && p.SN == snObject.SN && p.R_SN_ID == snObject.ID).ToList().FirstOrDefault(); if (r_sn_station_detail == null) { bPass = false; } } } } return(bPass); }
//Add by LLF 2018-02-01 end //public bool CheckSNExist(string StrSN,OleExec sfcdb, MESDataObject.DB_TYPE_ENUM _DBType) //{ // bool CheckFlag = false; // T_R_SN R_SN = new T_R_SN(sfcdb, DBType); // CheckFlag = R_SN.CheckSNExists(StrSN,sfcdb); // return CheckFlag; //} public R_SN LoadSN(string SerialNo, OleExec DB) { R_SN RSN = null; T_R_SN R_Sn = new T_R_SN(DB, DBType); RSN = R_Sn.LoadSN(SerialNo, DB); return(RSN); }
//Add by LLF 2018-02-22 begin public void PanelAndSNLoad(string Sn, OleExec sfcdb, MESDataObject.DB_TYPE_ENUM _DBType) { this.sfcdb = sfcdb; this.DBType = _DBType; T_R_SN trsn = new T_R_SN(sfcdb, DBType); if (!string.IsNullOrEmpty(Sn)) { baseSN = trsn.GetDetailByPanelAndSN(Sn, sfcdb); } }
private void getBySN(string sn, OleExec sfcdb, MESDataObject.DB_TYPE_ENUM dbtype) { //get sn route_id T_R_SN TR_SN = new T_R_SN(sfcdb, dbtype); R_SN getSN = TR_SN.GetDetailBySN(sn, sfcdb); string routeid = ""; if (getSN != null && getSN.ROUTE_ID != null) { routeid = getSN.ROUTE_ID.Trim(); } getByIdOrRouteName("ID", routeid, sfcdb, dbtype); }
//Add by LLF 2018-02-22 end public void Load(string Sn, OleExec sfcdb, MESDataObject.DB_TYPE_ENUM _DBType) { this.sfcdb = sfcdb; this.DBType = _DBType; T_R_SN trsn = new T_R_SN(sfcdb, DBType); if (!string.IsNullOrEmpty(Sn)) { baseSN = trsn.GetDetailBySN(Sn, sfcdb); } T_C_KEYPART tKeyPart = new T_C_KEYPART(sfcdb, DBType); if (!string.IsNullOrEmpty(baseSN.KP_LIST_ID)) { _keyPartList = tKeyPart.GetKeyPartList(sfcdb, baseSN.KP_LIST_ID); } }
/// <summary> // /check if the sn is write into r_sn_station_detail /// </summary> /// <param name="sn"></param> /// <param name="station"></param> /// <param name="sfcdb"></param> /// <returns></returns> public bool HadWriteIntoDetail(string sn, string station, OleExec sfcdb) { bool bPass = true; R_SN_STATION_DETAIL r_sn_station_detail = null; T_R_SN t_r_sn = new T_R_SN(sfcdb, this.DBType); T_C_ROUTE_DETAIL t_c_route_detail = new T_C_ROUTE_DETAIL(sfcdb, this.DBType); R_SN snObject = t_r_sn.LoadSN(sn, sfcdb); if (snObject != null) { if (!t_c_route_detail.StationInRoute(snObject.ROUTE_ID, station, sfcdb)) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000156", new string[] { sn, station })); } r_sn_station_detail = sfcdb.ORM.Queryable <R_SN_STATION_DETAIL>().Where(p => p.STATION_NAME == station && p.ROUTE_ID == snObject.ROUTE_ID && p.SN == snObject.SN && p.R_SN_ID == snObject.ID).ToList().FirstOrDefault(); if (r_sn_station_detail == null) { bPass = false; } } return(bPass); }
public void ScanKPItem(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow(); SFCDB.BeginTrain(); try { /* * new APIInputInfo() {InputName = "SN", InputType = "STRING", DefaultValue = ""}, * new APIInputInfo() {InputName = "STATION", InputType = "STRING", DefaultValue = ""}, * new APIInputInfo() {InputName = "KPITEM", InputType = "STRING", DefaultValue = ""} */ string strSN = Data["SN"].ToString(); string station = Data["STATION"].ToString(); JToken _ItemData = Data["KPITEM"]; T_R_SN_KP TRKP = new T_R_SN_KP(SFCDB, DB_TYPE_ENUM.Oracle); T_R_SN t_r_sn = new T_R_SN(SFCDB, DB_TYPE_ENUM.Oracle); List <R_SN_KP> ItemData = new List <R_SN_KP>(); for (int i = 0; i < _ItemData.Count(); i++) { //已被綁定的就不能重複綁定 if (TRKP.CheckLinkByValue(_ItemData[i]["VALUE"].ToString(), SFCDB)) { throw new Exception(_ItemData[i]["VALUE"].ToString() + " has been link on other sn!"); } R_SN r_sn = new R_SN(); r_sn = t_r_sn.LoadSN(_ItemData[i]["VALUE"].ToString(), SFCDB); //如果KEYPART是本廠做的條碼則必須是完工狀態 if (r_sn != null && r_sn.COMPLETED_FLAG != "1") { throw new Exception(_ItemData[i]["VALUE"].ToString() + " is on " + r_sn.NEXT_STATION + ",can't completed!"); } R_SN_KP I = new R_SN_KP(); I.ID = _ItemData[i]["ID"].ToString(); I.VALUE = _ItemData[i]["VALUE"].ToString(); I.MPN = _ItemData[i]["MPN"].ToString(); I.PARTNO = _ItemData[i]["PARTNO"].ToString(); I.SCANTYPE = _ItemData[i]["SCANTYPE"].ToString(); I.ITEMSEQ = double.Parse(_ItemData[i]["ITEMSEQ"].ToString()); I.SCANSEQ = double.Parse(_ItemData[i]["SCANSEQ"].ToString()); I.DETAILSEQ = double.Parse(_ItemData[i]["DETAILSEQ"].ToString()); ItemData.Add(I); } if (ItemData.Count == 0) { StationReturn.Status = StationReturnStatusValue.Pass; } LogicObject.SN SN = new LogicObject.SN(); SN.Load(strSN, SFCDB, DB_TYPE_ENUM.Oracle); MESDataObject.Module.T_R_WO_BASE TWO = new T_R_WO_BASE(SFCDB, DB_TYPE_ENUM.Oracle); Row_R_WO_BASE RWO = TWO.GetWo(SN.WorkorderNo, SFCDB); List <R_SN_KP> snkp = TRKP.GetKPRecordBySnIDStation(SN.ID, station, SFCDB); SN_KP KPCONFIG = new SN_KP(snkp, SN.WorkorderNo, SN.SkuNo, SFCDB); R_SN_KP kpItem = KPCONFIG.KPS.Find(T => T.ID == ItemData[0].ID); if (kpItem == null) { throw new Exception("Data Error!"); } List <R_SN_KP> ConfigItem = KPCONFIG.KPS.FindAll(T => T.PARTNO == kpItem.PARTNO && T.ITEMSEQ == kpItem.ITEMSEQ && T.SCANSEQ == kpItem.SCANSEQ ); if (ConfigItem.Count != ItemData.Count) { throw new Exception("Data Error! ConfigItem.Count != ItemData.Count"); } List <Row_R_SN_KP> items = new List <Row_R_SN_KP>(); for (int i = 0; i < ItemData.Count; i++) { Row_R_SN_KP item = (Row_R_SN_KP)TRKP.GetObjByID(ItemData[i].ID, SFCDB); if (item.ITEMSEQ == ItemData[i].ITEMSEQ && item.SCANSEQ == ItemData[i].SCANSEQ && item.DETAILSEQ == ItemData[i].DETAILSEQ) { item.VALUE = ItemData[i].VALUE; item.MPN = ItemData[i].MPN; item.PARTNO = ItemData[i].PARTNO; item.EDIT_TIME = DateTime.Now; item.EDIT_EMP = LoginUser.EMP_NO; SFCDB.ExecSQL(item.GetUpdateString(DB_TYPE_ENUM.Oracle)); item.AcceptChange(); items.Add(item); } else { throw new Exception("Data Error! 1"); } } for (int i = 0; i < items.Count; i++) { var ScanTypes = SFCDB.ORM.Queryable <C_KP_Check>().Where(t => t.TYPENAME == items[i].SCANTYPE).ToList(); if (ScanTypes.Count > 0) { Assembly assembly = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + ScanTypes[0].DLL); Type APIType = assembly.GetType(ScanTypes[0].CLASS); object API_CLASS = assembly.CreateInstance(ScanTypes[0].CLASS); var Methods = APIType.GetMethods(); var Funs = Methods.Where <MethodInfo>(t => t.Name == ScanTypes[0].FUNCTION); if (Funs.Count() > 0) { Funs.ElementAt(0).Invoke(API_CLASS, new object[] { KPCONFIG, SN, items[i], items, this, SFCDB }); } } } StationReturn.Status = StationReturnStatusValue.Pass; SFCDB.CommitTrain(); } catch (Exception ee) { SFCDB.RollbackTrain(); //this.DBPools["SFCDB"].Return(SFCDB); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000037"; if (ee.InnerException != null) { StationReturn.MessagePara.Add(ee.InnerException.Message); } else { StationReturn.MessagePara.Add(ee.Message); } } this.DBPools["SFCDB"].Return(SFCDB); }
//void GetKeyPart(string PN, string seq) //{ //} /// <summary> /// 寫入 r_sn_kp /// </summary> /// <param name="rowWo"></param> /// <param name="r_sn"></param> /// <param name="sfcdb"></param> /// <param name="Station"></param> /// <param name="sfcdbType"></param> /// <param name=""></param> public void InsertR_SN_KP(WorkOrder woObject, R_SN r_sn, OleExec sfcdb, BaseClass.MESStationBase Station, MESDataObject.DB_TYPE_ENUM sfcdbType) { T_C_KP_LIST t_c_kp_list = new T_C_KP_LIST(sfcdb, sfcdbType); T_C_KP_List_Item t_c_kp_list_item = new T_C_KP_List_Item(sfcdb, sfcdbType); T_C_KP_List_Item_Detail t_c_kp_list_item_detail = new T_C_KP_List_Item_Detail(sfcdb, sfcdbType); T_R_SN_KP t_r_sn_kp = new T_R_SN_KP(sfcdb, sfcdbType); T_C_SKU_MPN t_c_sku_mpn = new T_C_SKU_MPN(sfcdb, sfcdbType); T_C_KP_Rule c_kp_rule = new T_C_KP_Rule(sfcdb, sfcdbType); Row_R_SN_KP rowSNKP; List <C_KP_List_Item> kpItemList = new List <C_KP_List_Item>(); List <C_SKU_MPN> skuMpnList = new List <C_SKU_MPN>(); List <C_KP_List_Item_Detail> itemDetailList = new List <C_KP_List_Item_Detail>(); C_KP_Rule kpRule = new C_KP_Rule(); int scanseq = 0; int result; string skuMpn = ""; try { kpItemList = t_c_kp_list_item.GetItemObjectByListId(woObject.KP_LIST_ID, sfcdb); if (kpItemList == null || kpItemList.Count == 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000255", new string[] { woObject.SkuNO })); } foreach (C_KP_List_Item kpItem in kpItemList) { itemDetailList = t_c_kp_list_item_detail.GetItemDetailObjectByItemId(kpItem.ID, sfcdb); if (itemDetailList == null || itemDetailList.Count == 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000255", new string[] { woObject.SkuNO })); } skuMpnList = t_c_sku_mpn.GetMpnBySkuAndPartno(sfcdb, woObject.SkuNO, kpItem.KP_PARTNO); if (skuMpnList.Count != 0) { skuMpn = skuMpnList[0].MPN; } foreach (C_KP_List_Item_Detail itemDetail in itemDetailList) { scanseq = scanseq + 1; kpRule = c_kp_rule.GetKPRule(sfcdb, kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE); if (kpRule == null) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000256", new string[] { kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE })); } if (kpRule.REGEX == "") { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000256", new string[] { kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE })); } rowSNKP = (Row_R_SN_KP)t_r_sn_kp.NewRow(); rowSNKP.ID = t_r_sn_kp.GetNewID(Station.BU, sfcdb); rowSNKP.R_SN_ID = r_sn.ID; rowSNKP.SN = r_sn.SN; rowSNKP.VALUE = ""; rowSNKP.PARTNO = kpItem.KP_PARTNO; rowSNKP.KP_NAME = kpItem.KP_NAME; rowSNKP.MPN = skuMpn; rowSNKP.SCANTYPE = itemDetail.SCANTYPE; rowSNKP.ITEMSEQ = kpItem.SEQ; rowSNKP.SCANSEQ = scanseq; rowSNKP.DETAILSEQ = itemDetail.SEQ; rowSNKP.STATION = kpItem.STATION; rowSNKP.REGEX = kpRule.REGEX; rowSNKP.VALID_FLAG = 1; rowSNKP.EXKEY1 = ""; rowSNKP.EXVALUE1 = ""; rowSNKP.EXKEY2 = ""; rowSNKP.EXVALUE2 = ""; rowSNKP.EDIT_EMP = Station.LoginUser.EMP_NO; rowSNKP.EDIT_TIME = Station.GetDBDateTime(); result = Convert.ToInt32(sfcdb.ExecSQL(rowSNKP.GetInsertString(sfcdbType))); if (result <= 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000083", new string[] { "R_SN_KP:" + r_sn.SN, "ADD" })); } } } } catch (Exception ex) { throw ex; } }
public static void HWDBIPSNFailAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <R_Station_Action_Para> Paras) { string ErrMessage = ""; string StrSn = ""; string APVirtualSn = ""; string VirtualSn = ""; AP_DLL APObj = new AP_DLL(); OleExec APDB = null; R_PANEL_SN PANELObj = null; Int16 FailCount = 0; List <Dictionary <string, string> > FailList = null; string R_SN_STATION_DETAIL_ID = ""; StringBuilder ReturnMessage = new StringBuilder(); string RepairmainID = "";//add by LLF 2018-04-12 if (Paras.Count < 5) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050")); } MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY); if (SNSession == null) { ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }); throw new MESReturnMessage(ErrMessage); } MESStationSession FailCountSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY); if (FailCountSession == null) { ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }); throw new MESReturnMessage(ErrMessage); } MESStationSession FailListSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY); if (FailListSession == null) { ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY }); throw new MESReturnMessage(ErrMessage); } MESStationSession PanelVitualSNSession = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY); if (PanelVitualSNSession == null) { ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[3].SESSION_TYPE + Paras[3].SESSION_KEY }); throw new MESReturnMessage(ErrMessage); } MESStationSession StatusSession = Station.StationSession.Find(t => t.MESDataType == Paras[4].SESSION_TYPE && t.SessionKey == Paras[4].SESSION_KEY); if (StatusSession == null) { StatusSession = new MESStationSession() { MESDataType = Paras[4].SESSION_TYPE, InputValue = Input.Value.ToString(), Value = Paras[4].VALUE, SessionKey = Paras[4].SESSION_KEY, ResetInput = Input }; Station.StationSession.Add(StatusSession); if (StatusSession.Value.ToString() == "") { StatusSession.Value = "FAIL"; } } MESStationSession ClearInputSession = null; if (Paras.Count >= 6) { ClearInputSession = Station.StationSession.Find(t => t.MESDataType.Equals(Paras[5].SESSION_TYPE) && t.SessionKey.Equals(Paras[5].SESSION_KEY)); if (ClearInputSession == null) { ClearInputSession = new MESStationSession() { MESDataType = Paras[5].SESSION_TYPE, SessionKey = Paras[5].SESSION_KEY }; Station.StationSession.Add(ClearInputSession); } } FailCount = Convert.ToInt16(FailCountSession.Value.ToString()); FailList = (List <Dictionary <string, string> >)FailListSession.Value; T_R_SN rSn = new T_R_SN(Station.SFCDB, DB_TYPE_ENUM.Oracle); DateTime FailTime = rSn.GetDBDateTime(Station.SFCDB); StrSn = SNSession.Value.ToString(); if (FailList.Count >= FailCount && FailCount != 0) //允許掃描多個Fail { #region 業務邏輯 OleExec oleDB = null; oleDB = Station.SFCDB; //oleDB = this.DBPools["SFCDB"].Borrow(); //oleDB.BeginTrain(); //OleExecPool APDBPool = Station.DBS["APDB"]; //APDB = APDBPool.Borrow(); //APDB.BeginTrain(); APDB = Station.APDB; try { Row_R_SN rrSn = (Row_R_SN)rSn.NewRow(); for (int i = 0; i < FailList.Count; i++) { //獲取頁面傳過來的數據 string failCode = FailList[i]["FailCode"].ToString(); string failLocation = FailList[i]["FailLocation"].ToString(); string failProcess = FailList[i]["FailProcess"].ToString(); string failDescription = FailList[i]["FailDesc"].ToString(); //黃楊盛 2018年4月24日14:14:28 模擬自動做維修的動作,修正時間 //更新R_SN REPAIR_FAILED_FLAG=’1’ //modify by ZGJ 2018-03-22 BIP Fail 的產品自動清除待維修狀態,但是記錄不良 PANELObj = (R_PANEL_SN)PanelVitualSNSession.Value; if (i == 0) { VirtualSn = PANELObj.SN.ToString(); R_SN r = rSn.GetDetailBySN(VirtualSn, Station.SFCDB); rrSn = (Row_R_SN)rSn.GetObjByID(r.ID, Station.SFCDB); //rrSn.REPAIR_FAILED_FLAG = "0"; rrSn.REPAIR_FAILED_FLAG = "1"; rrSn.SN = StrSn; rrSn.EDIT_EMP = Station.LoginUser.EMP_NO; //add by LLF 2018-03-17 rrSn.EDIT_TIME = FailTime; //add by LLF 2018-03-17 string strRet = (Station.SFCDB).ExecSQL(rrSn.GetUpdateString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(strRet) > 0)) { throw new MESReturnMessage("update repair failed flag error!"); } // Update R_PANEL_SN T_R_PANEL_SN RPanelSN = new T_R_PANEL_SN(Station.SFCDB, DB_TYPE_ENUM.Oracle); Row_R_PANEL_SN Row_Panel = (Row_R_PANEL_SN)RPanelSN.NewRow(); Row_Panel = (Row_R_PANEL_SN)RPanelSN.GetObjByID(PANELObj.ID, Station.SFCDB); Row_Panel.SN = StrSn; strRet = (Station.SFCDB).ExecSQL(Row_Panel.GetUpdateString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(strRet) > 0)) { throw new MESReturnMessage("update r_panel_sn error!"); } //Update AP //黄杨盛 2018年4月14日09:10:50 修正不能超过9连板的情况.同时加上不支持3位数连板的约束 //APVirtualSn = PANELObj.PANEL + "0" + PANELObj.SEQ_NO.ToString(); if (PANELObj.SEQ_NO > 99) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000226", new string[] { DB_TYPE_ENUM.Oracle.ToString() })); } APVirtualSn = PANELObj.PANEL + Convert.ToInt16(PANELObj.SEQ_NO).ToString("00"); string result = APObj.APUpdatePanlSN(APVirtualSn, StrSn, APDB); //APDBPool.Return(APDB); if (!result.Equals("OK")) { //2018年4月24日13:56:14 黃楊盛 //throw new MESReturnMessage("already be binded to other serial number"); throw new MESReturnMessage(result); } //新增一筆FAIL記錄到R_SN_STATION_DETAIL T_R_SN_STATION_DETAIL rSnStationDetail = new T_R_SN_STATION_DETAIL(Station.SFCDB, DB_TYPE_ENUM.Oracle); //Add by LLF 2018-03-19 R_SN_STATION_DETAIL_ID = rSnStationDetail.GetNewID(Station.BU, Station.SFCDB); //string detailResult = rSnStationDetail.AddDetailToRSnStationDetail(R_SN_STATION_DETAIL_ID,rrSn.GetDataObject(), Station.Line, Station.StationName, Station.StationName, Station.SFCDB); string detailResult = rSnStationDetail.AddDetailToBipStationFailDetail( R_SN_STATION_DETAIL_ID, rrSn.GetDataObject(), Station.Line, Station.StationName, Station.StationName, Station.SFCDB, "1"); if (!(Convert.ToInt32(detailResult) > 0)) { throw new MESReturnMessage("Insert sn station detail error!"); } //update R_SN_STATION_DETAIL rSnStationDetail.UpdateRSnStationDetailBySNID(StrSn, PANELObj.SN, Station.SFCDB); //新增一筆到R_REPAIR_MAIN T_R_REPAIR_MAIN tRepairMain = new T_R_REPAIR_MAIN(Station.SFCDB, DB_TYPE_ENUM.Oracle); Row_R_REPAIR_MAIN rRepairMain = (Row_R_REPAIR_MAIN)tRepairMain.NewRow(); RepairmainID = tRepairMain.GetNewID(Station.BU, Station.SFCDB); //rRepairMain.ID = tRepairMain.GetNewID(Station.BU, Station.SFCDB); rRepairMain.ID = RepairmainID; rRepairMain.SN = StrSn; rRepairMain.WORKORDERNO = rrSn.WORKORDERNO; rRepairMain.SKUNO = rrSn.SKUNO; rRepairMain.FAIL_LINE = Station.Line; rRepairMain.FAIL_STATION = Station.StationName; rRepairMain.FAIL_EMP = Station.LoginUser.EMP_NO; //rRepairMain.FAIL_TIME = Station.GetDBDateTime();//Modify by LLF 2018-03-17 rRepairMain.FAIL_TIME = FailTime; //Modify by LLF 2018-03-17 rRepairMain.EDIT_EMP = Station.LoginUser.EMP_NO; rRepairMain.EDIT_TIME = Station.GetDBDateTime(); rRepairMain.CLOSED_FLAG = "1"; string insertResult = (Station.SFCDB).ExecSQL(rRepairMain.GetInsertString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(insertResult) > 0)) { throw new Exception("Insert repair main error!"); } } //新增一筆到R_REPAIR_FAILCODE T_R_REPAIR_FAILCODE tRepairFailCode = new T_R_REPAIR_FAILCODE(Station.SFCDB, DB_TYPE_ENUM.Oracle); Row_R_REPAIR_FAILCODE rRepairFailCode = (Row_R_REPAIR_FAILCODE)tRepairFailCode.NewRow(); rRepairFailCode.ID = tRepairFailCode.GetNewID(Station.BU, Station.SFCDB); //rRepairFailCode.REPAIR_MAIN_ID = rRepairMain.ID; //Modify by LLF 2018-04-11 多筆FAIL 取1一個RepairMainID rRepairFailCode.REPAIR_MAIN_ID = RepairmainID; rRepairFailCode.SN = StrSn; rRepairFailCode.FAIL_CODE = failCode; rRepairFailCode.FAIL_EMP = Station.LoginUser.EMP_NO; rRepairFailCode.FAIL_TIME = FailTime; rRepairFailCode.FAIL_CATEGORY = "SYMPTOM"; rRepairFailCode.FAIL_LOCATION = failLocation; rRepairFailCode.FAIL_PROCESS = failProcess; rRepairFailCode.DESCRIPTION = failDescription; rRepairFailCode.REPAIR_FLAG = "1"; rRepairFailCode.EDIT_EMP = Station.LoginUser.EMP_NO; rRepairFailCode.EDIT_TIME = Station.GetDBDateTime(); string strResult = (Station.SFCDB).ExecSQL(rRepairFailCode.GetInsertString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(strResult) > 0)) { throw new MESReturnMessage("Insert repair failcode error!"); } //oleDB.CommitTrain(); ReturnMessage.Append(failDescription).Append("|"); } //黃楊盛 2018年4月24日14:11:42 做一筆出來的記錄 R_SN snOut = rSn.GetDetailBySN(StrSn, Station.SFCDB); rrSn = (Row_R_SN)rSn.GetObjByID(snOut.ID, Station.SFCDB); rrSn.CURRENT_STATION = rrSn.NEXT_STATION; rrSn.NEXT_STATION = rSn.GetNextStation(snOut.ROUTE_ID, snOut.NEXT_STATION, oleDB); rrSn.REPAIR_FAILED_FLAG = "0"; rrSn.SN = StrSn; rrSn.EDIT_EMP = Station.LoginUser.EMP_NO; rrSn.EDIT_TIME = FailTime; var count = (Station.SFCDB).ExecSQL(rrSn.GetUpdateString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(count) > 0)) { throw new MESReturnMessage("update rsn failed flag error!"); } // 方國剛 2018.05.02 11:45:30 // 因拋賬計算過站數量時,不計算REPAIR_FAILED_FLAG=1的數量,故BIP Fail 的產品自動清除待維修狀態后再在過站記錄表記錄一筆REPAIR_FAILED_FLAG=0的記錄 T_R_SN_STATION_DETAIL rSnStationDetailRepaired = new T_R_SN_STATION_DETAIL(Station.SFCDB, DB_TYPE_ENUM.Oracle); R_SN_STATION_DETAIL_ID = rSnStationDetailRepaired.GetNewID(Station.BU, Station.SFCDB); string detailResultRepaired = rSnStationDetailRepaired.AddDetailToBipStationFailDetail( R_SN_STATION_DETAIL_ID, rrSn.GetDataObject(), Station.Line, Station.StationName, Station.StationName, Station.SFCDB, "0"); if (!(Convert.ToInt32(detailResultRepaired) > 0)) { throw new MESReturnMessage("Insert sn station detail error!"); } } catch (Exception e) { try { //APDB.RollbackTrain(); //oleDB.RollbackTrain(); } catch (Exception x) { ; } throw new MESReturnMessage(e.Message + e.StackTrace); } finally { //APDBPool.Return(APDB); } #endregion //add by zgj 2018-03-14 //當記錄完當前 SN 不良後,清除保存在 session 中的不良信息 //((List<Dictionary<string, string>>)FailListSession.Value).Clear(); if (ClearInputSession != null) { ClearInputSession.Value = "true"; } ReturnMessage.Remove(ReturnMessage.Length - 1, 1); Station.NextInput = Station.FindInputByName("PanelSn"); Station.AddMessage("MES00000158", new string[] { StrSn, ReturnMessage.ToString() }, MESReturnView.Station.StationMessageState.Pass); } else { Station.NextInput = Station.FindInputByName("Location"); Station.AddMessage("MES00000162", new string[] { StrSn, FailCount.ToString(), FailList.Count.ToString() }, MESReturnView.Station.StationMessageState.Message); } }
public MESServiceRes TestDataUploadMES(string SN, string MODEL, string TESTTIME, string STATE, string STATION, string CELL, string OPERATOR, string ERROR_CODE) { //Sql注入; TestRecordData testRecord = new TestRecordData(); #region DataCheck; try { testRecord = TestDataUploadMES_CheckInputData(SN, MODEL, TESTTIME, STATE, STATION, CELL, OPERATOR, ERROR_CODE); } catch (Exception e) { resObj.Statusvalue = (int)StatusValue.fail; resObj.MessageCode = "MES00001"; resObj.Message = "输入参数错误:" + e.ToString(); return(resObj); } #endregion OleExec DB = new OleExec("VERTIVTESTDB", true); T_C_TEMES_STATION_MAPPING cTeMesStationMappingControl = new T_C_TEMES_STATION_MAPPING(DB, DB_TYPE_ENUM.Oracle); T_R_TEST_RECORD rTestRecordControl = new T_R_TEST_RECORD(DB, DB_TYPE_ENUM.Oracle); T_R_TEST_DETAIL_VERTIV rTestDetailVertivControl = new T_R_TEST_DETAIL_VERTIV(DB, DB_TYPE_ENUM.Oracle); T_R_SN rSnControl = new T_R_SN(DB, DB_TYPE_ENUM.Oracle); Row_R_TEST_RECORD rowRTestRecord = (Row_R_TEST_RECORD)rTestRecordControl.NewRow(); Row_R_TEST_DETAIL_VERTIV rowRTestDetailVertiv = (Row_R_TEST_DETAIL_VERTIV)rTestDetailVertivControl.NewRow(); try { C_TEMES_STATION_MAPPING cTeMesStationMapping = cTeMesStationMappingControl.GetTeMesStationMapping(DB, STATION, "A"); if (cTeMesStationMapping == null) { resObj.Statusvalue = (int)StatusValue.fail; resObj.MessageCode = "MES000017"; resObj.Message = $@"上傳失敗:未在MES系統找到Te-Station:{STATION}對應的工站,請聯繫IT配置!"; return(resObj); } R_SN rSn = rSnControl.LoadSN(SN, DB); //RTestRecord rowRTestRecord.ID = cTeMesStationMappingControl.GetNewID("VERTIV", DB); rowRTestRecord.R_SN_ID = rSn?.ID; rowRTestRecord.SN = testRecord.SN; rowRTestRecord.ENDTIME = DateTime.Parse(testRecord.TESTTIME); rowRTestRecord.STARTTIME = DateTime.Parse(testRecord.TESTTIME); rowRTestRecord.STATE = testRecord.STATE; rowRTestRecord.TEGROUP = "A"; rowRTestRecord.TESTATION = testRecord.STATION; rowRTestRecord.MESSTATION = cTeMesStationMapping?.MES_STATION; rowRTestRecord.DETAILTABLE = "R_TEST_DETAIL_VERTIV"; //RTestDetailVertiv rowRTestDetailVertiv.ID = rTestDetailVertivControl.GetNewID("VERTIV", DB); rowRTestDetailVertiv.R_TEST_RECORD_ID = rowRTestRecord.ID; rowRTestDetailVertiv.SN = testRecord.SN; rowRTestDetailVertiv.SKUNO = testRecord.MODEL; rowRTestDetailVertiv.CREATETIME = DateTime.Parse(testRecord.TESTTIME); rowRTestDetailVertiv.STATE = testRecord.STATE; rowRTestDetailVertiv.STATION = testRecord.STATION; rowRTestDetailVertiv.CELL = testRecord.CELL; rowRTestDetailVertiv.OPERATOR = testRecord.OPERATOR; rowRTestDetailVertiv.ERROR_CODE = testRecord.ERROR_CODE; } catch (Exception e) { resObj.Statusvalue = (int)StatusValue.fail; resObj.MessageCode = "MES00003"; resObj.Message = "MESDB异常:" + e.ToString(); return(resObj); } try { DB.BeginTrain(); DB.ExecSQL(rowRTestDetailVertiv.GetInsertString(DB_TYPE_ENUM.Oracle)); DB.ExecSQL(rowRTestRecord.GetInsertString(DB_TYPE_ENUM.Oracle)); DB.CommitTrain(); resObj.Statusvalue = (int)StatusValue.success; resObj.MessageCode = ""; resObj.Message = "Upload Success!"; } catch (Exception e) { DB.RollbackTrain(); resObj.Statusvalue = (int)StatusValue.fail; resObj.MessageCode = "MES00002"; resObj.Message = "写入MESERR:" + e.ToString(); } finally { DB.FreeMe(); } return(resObj); }
public static void SNFailAction_Old(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <R_Station_Action_Para> Paras) { string R_SN_STATION_DETAIL_ID = ""; if (Paras.Count == 0) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050")); } MESStationSession SNLoadPoint = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY); if (SNLoadPoint == null) { SNLoadPoint = new MESStationSession() { MESDataType = "SN", InputValue = Input.Value.ToString(), SessionKey = "1", ResetInput = Input }; Station.StationSession.Add(SNLoadPoint); } //獲取頁面傳過來的數據 string failCode = Station.Inputs.Find(s => s.DisplayName == "Fail_Code").Value.ToString(); string failLocation = Station.Inputs.Find(s => s.DisplayName == "Fail_Location").Value.ToString(); string failProcess = Station.Inputs.Find(s => s.DisplayName == "Fail_Process").Value.ToString(); string failDescription = Station.Inputs.Find(s => s.DisplayName == "Description").Value.ToString(); string strSn = Input.Value.ToString(); OleExec oleDB = null; oleDB = Station.SFCDB; //oleDB = this.DBPools["SFCDB"].Borrow(); oleDB.BeginTrain(); //以下執行 要么全成功,要么全失敗 //更新R_SN REPAIR_FAILED_FLAG=’1’ T_R_SN rSn = new T_R_SN(Station.SFCDB, DB_TYPE_ENUM.Oracle); Row_R_SN rrSn = (Row_R_SN)rSn.NewRow(); R_SN r = rSn.GetDetailBySN(strSn, Station.SFCDB); rrSn = (Row_R_SN)rSn.GetObjByID(r.ID, Station.SFCDB); rrSn.REPAIR_FAILED_FLAG = "1"; string strRet = (Station.SFCDB).ExecSQL(rrSn.GetUpdateString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(strRet) > 0)) { throw new Exception("update repair failed flag error!"); } //新增一筆FAIL記錄到R_SN_STATION_DETAIL T_R_SN_STATION_DETAIL rSnStationDetail = new T_R_SN_STATION_DETAIL(Station.SFCDB, DB_TYPE_ENUM.Oracle); R_SN_STATION_DETAIL_ID = rSnStationDetail.GetNewID(Station.BU, Station.SFCDB); string detailResult = rSnStationDetail.AddDetailToRSnStationDetail(R_SN_STATION_DETAIL_ID, rrSn.GetDataObject(), Station.Line, Station.StationName, Station.StationName, Station.SFCDB); if (!(Convert.ToInt32(detailResult) > 0)) { throw new Exception("Insert sn station detail error!"); } //新增一筆到R_REPAIR_MAIN T_R_REPAIR_MAIN tRepairMain = new T_R_REPAIR_MAIN(Station.SFCDB, DB_TYPE_ENUM.Oracle); Row_R_REPAIR_MAIN rRepairMain = (Row_R_REPAIR_MAIN)tRepairMain.NewRow(); rRepairMain.ID = tRepairMain.GetNewID(Station.BU, Station.SFCDB); rRepairMain.SN = strSn; rRepairMain.WORKORDERNO = rrSn.WORKORDERNO; rRepairMain.SKUNO = rrSn.SKUNO; rRepairMain.FAIL_LINE = Station.Line; rRepairMain.FAIL_STATION = Station.StationName; rRepairMain.FAIL_EMP = Station.User.EMP_NO; rRepairMain.FAIL_TIME = Station.GetDBDateTime(); rRepairMain.CLOSED_FLAG = "0"; string insertResult = (Station.SFCDB).ExecSQL(rRepairMain.GetInsertString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(insertResult) > 0)) { throw new Exception("Insert repair main error!"); } //新增一筆到R_REPAIR_FAILCODE T_R_REPAIR_FAILCODE tRepairFailCode = new T_R_REPAIR_FAILCODE(Station.SFCDB, DB_TYPE_ENUM.Oracle); Row_R_REPAIR_FAILCODE rRepairFailCode = (Row_R_REPAIR_FAILCODE)tRepairFailCode.NewRow(); rRepairFailCode.ID = tRepairFailCode.GetNewID(Station.BU, Station.SFCDB); rRepairFailCode.REPAIR_MAIN_ID = rRepairMain.ID; rRepairFailCode.SN = strSn; rRepairFailCode.FAIL_CODE = failCode; rRepairFailCode.FAIL_EMP = Station.User.EMP_NO; rRepairFailCode.FAIL_TIME = DateTime.Now; rRepairFailCode.FAIL_CATEGORY = "SYMPTON"; rRepairFailCode.FAIL_LOCATION = failLocation; rRepairFailCode.FAIL_PROCESS = failProcess; rRepairFailCode.DESCRIPTION = failDescription; rRepairFailCode.REPAIR_FLAG = "0"; string strResult = (Station.SFCDB).ExecSQL(rRepairFailCode.GetInsertString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(strResult) > 0)) { throw new Exception("Insert repair failcode error!"); } oleDB.CommitTrain(); Station.AddMessage("MES00000001", new string[] { }, MESReturnView.Station.StationMessageState.Pass); }
private void Get2000E3CartonValue(R_SN r_sn, OleExec DB) { t_r_sn_kp = new T_R_SN_KP(DB, MESDataObject.DB_TYPE_ENUM.Oracle); t_c_sku_ver_mapping = new T_C_SKU_VER_MAPPING(DB, DB_TYPE_ENUM.Oracle); R_SN kpSN; R_SN_STATION_DETAIL snStationDetail = null; C_SKU_VER_MAPPING verMapping = null; R_WO_BASE r_wo_base = null; List <R_SN_KP> KPList = new List <R_SN_KP>(); List <R_SN_KP> printKPList = new List <R_SN_KP>(); R_SN_KP printKP = null; R_SN_KP GPNKP; R_SN_KP GSNKP; C_SKU_DETAIL skuDetail; if (r_sn != null) { r_wo_base = DB.ORM.Queryable <R_WO_BASE>().Where(wo => wo.WORKORDERNO == r_sn.WORKORDERNO).ToList().FirstOrDefault(); KPList = t_r_sn_kp.GetKPRecordBySnID(r_sn.ID, DB); skuDetail = DB.ORM.Queryable <C_SKU_DETAIL>().Where(d => d.SKUNO == r_wo_base.SKUNO && d.STATION_NAME == I_STATION.Value.ToString() && d.CATEGORY == "PRINT" && d.CATEGORY_NAME == "KEYPART").ToList().FirstOrDefault(); if (skuDetail != null) { //打印keypart SN 對應的keypart 信息 printKP = KPList.Find(k => k.PARTNO == skuDetail.VALUE); } if (printKP != null) { kpSN = t_r_sn.LoadSN(printKP.VALUE, DB); printKPList = t_r_sn_kp.GetKPRecordBySnID(kpSN.ID, DB); GPNKP = printKPList.Find(k => k.SCANTYPE == "GPN"); GSNKP = printKPList.Find(k => k.SCANTYPE == "GSN"); if (GPNKP != null) { O_GPN.Value = GPNKP.VALUE; } if (GSNKP != null) { O_GSN.Value = GSNKP.VALUE; } } snStationDetail = DB.ORM.Queryable <R_SN_STATION_DETAIL>().Where(s => s.R_SN_ID == r_sn.ID && s.STATION_NAME == I_STATION.Value.ToString()).ToList().FirstOrDefault(); DateTime dateTime = (DateTime)snStationDetail.EDIT_TIME; O_PRINTDATE.Value = dateTime.ToString("MM/dd/yyyy"); verMapping = t_c_sku_ver_mapping.GetMappingBySkuAndVersion(r_wo_base.SKUNO, r_wo_base.SKU_VER, DB); if (verMapping != null) { O_VER.Value = verMapping.CUSTOMER_VERSION; } else { O_VER.Value = r_wo_base.SKU_VER; } } }
/// <summary> /// 移棧板或卡通內的數據 /// add by fgg 2018.06.08 /// </summary> /// <param name="Station"></param> /// <param name="Input"></param> /// <param name="Paras"></param> public static void MovePackingSessionValue(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras) { if (Paras.Count != 8) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000057", new string[] { })); } MESStationSession sessionOne = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY); if (sessionOne == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY })); } if (sessionOne.Value == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY })); } MESStationSession sessionTwo = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY); if (sessionTwo == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY })); } if (sessionTwo.Value == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY })); } MESStationSession sessionValue = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY); if (sessionValue == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY })); } if (sessionValue.Value.ToString() == "") { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY })); } MESStationSession sessionItemListOne = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY); if (sessionItemListOne == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[3].SESSION_TYPE + Paras[3].SESSION_KEY })); } MESStationSession sessionItemListTwo = Station.StationSession.Find(t => t.MESDataType == Paras[4].SESSION_TYPE && t.SessionKey == Paras[4].SESSION_KEY); if (sessionItemListTwo == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[4].SESSION_TYPE + Paras[4].SESSION_KEY })); } MESStationSession sessionCountOne = Station.StationSession.Find(t => t.MESDataType == Paras[5].SESSION_TYPE && t.SessionKey == Paras[5].SESSION_KEY); if (sessionCountOne == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[5].SESSION_TYPE + Paras[5].SESSION_KEY })); } MESStationSession sessionCountTwo = Station.StationSession.Find(t => t.MESDataType == Paras[6].SESSION_TYPE && t.SessionKey == Paras[6].SESSION_KEY); if (sessionCountTwo == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[6].SESSION_TYPE + Paras[6].SESSION_KEY })); } R_Station_Action_Para moveFlag = Paras[7]; bool moveToRight; if (moveFlag.VALUE.ToString().Equals("0")) { moveToRight = true; } else if (moveFlag.VALUE.ToString().Equals("1")) { moveToRight = false; } else { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[7].SESSION_TYPE + Paras[7].SESSION_KEY })); } try { LogicObject.Packing packOne = (LogicObject.Packing)sessionOne.Value;; LogicObject.Packing packTwo = (LogicObject.Packing)sessionTwo.Value;; string result = ""; T_R_PACKING t_r_packing = new T_R_PACKING(Station.SFCDB, Station.DBType); T_R_SN_PACKING t_r_sn_packing = new T_R_SN_PACKING(Station.SFCDB, Station.DBType); T_R_SN t_r_sn = new T_R_SN(Station.SFCDB, Station.DBType); T_R_MOVE_LIST t_r_move_list = new T_R_MOVE_LIST(Station.SFCDB, Station.DBType); T_C_PACKING t_c_packing = new T_C_PACKING(Station.SFCDB, Station.DBType); LogicObject.Packing packOneObject = new LogicObject.Packing(); LogicObject.Packing packTwoObject = new LogicObject.Packing(); R_SN r_sn; Row_R_MOVE_LIST rowMoveList; Row_R_PACKING rowPacking; C_PACKING c_packing = new C_PACKING(); if (packOne.ClosedFlag == "0") { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180613090152", new string[] { packOne.PackNo })); } if (packTwo.ClosedFlag == "0") { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180613090152", new string[] { packTwo.PackNo })); } if (!packOne.PackType.Equals(packTwo.PackType)) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612114250", new string[] { packOne.PackNo, packTwo.PackNo })); } if (!packOne.Skuno.Equals(packTwo.Skuno)) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141141", new string[] { packOne.PackNo, packTwo.PackNo })); } if (!packOne.SkunoVer.Equals(packTwo.SkunoVer)) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141356", new string[] { packOne.PackNo, packTwo.PackNo })); } Newtonsoft.Json.Linq.JArray moveValueArray = (Newtonsoft.Json.Linq.JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(sessionValue.Value.ToString()); if (packOne.PackType == LogicObject.PackType.PALLET.ToString().ToUpper()) { for (int i = 0; i < moveValueArray.Count; i++) { c_packing = t_c_packing.GetPackingBySkuAndType(packTwo.Skuno, LogicObject.PackType.CARTON.ToString().ToUpper(), Station.SFCDB); if (c_packing.MAX_QTY == 1 && Station.BU.ToUpper().Equals("VERTIV")) { //更新棧板號 //VERTIV 當卡通包規為1時,調棧板顯示卡通內的SN,故更新信息另外處理 R_PACKING packingObjectTemp = t_r_packing.GetPackingObjectBySN(moveValueArray[i].ToString(), Station.SFCDB); if (packingObjectTemp == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180620114012", new string[] { moveValueArray[i].ToString() })); } if (!t_r_packing.CheckPackNoExistByParentPackID(packingObjectTemp.PACK_NO, packOne.PackID, Station.SFCDB)) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141600", new string[] { moveValueArray[i].ToString(), packOne.PackNo })); } if (t_r_packing.CheckPackNoExistByParentPackID(packingObjectTemp.PACK_NO, packTwo.PackID, Station.SFCDB)) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141824", new string[] { moveValueArray[i].ToString(), packTwo.PackNo })); } result = t_r_packing.UpdateParentPackIDByPackNo(packingObjectTemp.PACK_NO, packTwo.PackID, Station.LoginUser.EMP_NO, Station.SFCDB); rowPacking = t_r_packing.GetRPackingByPackNo(Station.SFCDB, packingObjectTemp.PACK_NO); } else { if (!t_r_packing.CheckPackNoExistByParentPackID(moveValueArray[i].ToString(), packOne.PackID, Station.SFCDB)) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141600", new string[] { moveValueArray[i].ToString(), packOne.PackNo })); } if (t_r_packing.CheckPackNoExistByParentPackID(moveValueArray[i].ToString(), packTwo.PackID, Station.SFCDB)) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141824", new string[] { moveValueArray[i].ToString(), packTwo.PackNo })); } //更新棧板號 result = t_r_packing.UpdateParentPackIDByPackNo(moveValueArray[i].ToString(), packTwo.PackID, Station.LoginUser.EMP_NO, Station.SFCDB); rowPacking = t_r_packing.GetRPackingByPackNo(Station.SFCDB, moveValueArray[i].ToString()); } if (Convert.ToInt32(result) == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" })); } result = t_r_packing.UpdateQtyByID(packTwo.PackID, true, 1, Station.LoginUser.EMP_NO, Station.SFCDB); if (Convert.ToInt32(result) == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" })); } result = t_r_packing.UpdateQtyByID(packOne.PackID, false, 1, Station.LoginUser.EMP_NO, Station.SFCDB); if (Convert.ToInt32(result) == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" })); } //寫入記錄 rowMoveList = (Row_R_MOVE_LIST)t_r_move_list.NewRow(); rowMoveList.ID = t_r_move_list.GetNewID(Station.BU, Station.SFCDB); rowMoveList.MOVE_ID = rowPacking.ID; rowMoveList.FROM_LOCATION = packOne.PackID; rowMoveList.TO_LOCATION = packTwo.PackID; rowMoveList.PACK_TYPE = packOne.PackType; rowMoveList.MOVE_EMP = Station.LoginUser.EMP_NO; rowMoveList.MOVE_DATE = Station.GetDBDateTime(); result = Station.SFCDB.ExecSQL(rowMoveList.GetInsertString(Station.DBType)); if (Convert.ToInt32(result) == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { "R_MOVE_LIST" })); } } } else if (packOne.PackType == LogicObject.PackType.CARTON.ToString().ToUpper()) { for (int i = 0; i < moveValueArray.Count; i++) { r_sn = new R_SN(); r_sn = t_r_sn.GetDetailBySN(moveValueArray[i].ToString(), Station.SFCDB); if (!t_r_sn_packing.CheckSNExistByPackID(r_sn.ID, packOne.PackID, Station.SFCDB)) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141600", new string[] { moveValueArray[i].ToString(), packOne.PackNo })); } if (t_r_sn_packing.CheckSNExistByPackID(r_sn.ID, packTwo.PackID, Station.SFCDB)) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141824", new string[] { moveValueArray[i].ToString(), packTwo.PackNo })); } //更新卡通號 result = t_r_sn_packing.UpdatePackIDBySnID(r_sn.ID, packTwo.PackID, Station.LoginUser.EMP_NO, Station.SFCDB); if (Convert.ToInt32(result) == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_SN_PACKING" })); } result = t_r_packing.UpdateQtyByID(packTwo.PackID, true, 1, Station.LoginUser.EMP_NO, Station.SFCDB); if (Convert.ToInt32(result) == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" })); } result = t_r_packing.UpdateQtyByID(packOne.PackID, false, 1, Station.LoginUser.EMP_NO, Station.SFCDB); if (Convert.ToInt32(result) == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" })); } //寫入記錄 rowMoveList = (Row_R_MOVE_LIST)t_r_move_list.NewRow(); rowMoveList.ID = t_r_move_list.GetNewID(Station.BU, Station.SFCDB); rowMoveList.MOVE_ID = r_sn.ID; rowMoveList.FROM_LOCATION = packOne.PackID; rowMoveList.TO_LOCATION = packTwo.PackID; rowMoveList.PACK_TYPE = packOne.PackType; rowMoveList.MOVE_EMP = Station.LoginUser.EMP_NO; rowMoveList.MOVE_DATE = Station.GetDBDateTime(); result = Station.SFCDB.ExecSQL(rowMoveList.GetInsertString(Station.DBType)); if (Convert.ToInt32(result) == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { "R_MOVE_LIST" })); } } } else { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180607163531", new string[] { "Pack:" + packOne.PackType })); } //關閉卡通或棧板 result = t_r_packing.UpdateCloseFlagByPackID(packOne.PackID, "1", Station.SFCDB); if (Convert.ToInt32(result) == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612154506", new string[] { packOne.PackNo })); } //關閉卡通或棧板 result = t_r_packing.UpdateCloseFlagByPackID(packTwo.PackID, "1", Station.SFCDB); if (Convert.ToInt32(result) == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612154506", new string[] { packTwo.PackNo })); } packOneObject.DataLoad(packOne.PackNo, Station.BU, Station.SFCDB, Station.DBType); packTwoObject.DataLoad(packTwo.PackNo, Station.BU, Station.SFCDB, Station.DBType); sessionOne.Value = packOneObject; sessionTwo.Value = packTwoObject; if (moveToRight) { sessionItemListOne.Value = packOneObject.PackList; sessionItemListTwo.Value = packTwoObject.PackList; sessionCountOne.Value = packOneObject.PackList.Count; sessionCountTwo.Value = packTwoObject.PackList.Count; } else { sessionItemListOne.Value = packTwoObject.PackList; sessionItemListTwo.Value = packOneObject.PackList; sessionCountOne.Value = packTwoObject.PackList.Count; sessionCountTwo.Value = packOneObject.PackList.Count; } Station.StationMessages.Add(new StationMessage() { Message = MESReturnMessage.GetMESReturnMessage("MSGCODE20180612142034", new string[] { packOne.PackNo.ToString(), moveValueArray.Count.ToString(), packTwo.PackNo.ToString() }), State = StationMessageState.Pass }); } catch (Exception ex) { throw ex; } }
public void InLotPassStation(string NewLotFlag, R_SN SNObj, string LotNo, string LotSatusID, string Station, string EmpNo, string AQL_TYPE, string Line, string BU, OleExec DB) { T_R_LOT_STATUS Table_R_Lot_Status = new T_R_LOT_STATUS(DB, DBType); Row_R_LOT_STATUS Row_R_Lot_Status = (Row_R_LOT_STATUS)NewRow(); T_R_LOT_DETAIL Table_R_Lot_Detail = new T_R_LOT_DETAIL(DB, DBType); Row_R_LOT_DETAIL Row_R_Lot_Detail = (Row_R_LOT_DETAIL)Table_R_Lot_Detail.NewRow(); T_C_AQLTYPE Table_C_AQLTYPE = new T_C_AQLTYPE(DB, DBType); try { string LotID = ""; if (NewLotFlag == "1") { //Modify by LLF 2018-03-19,生成ID,需根據Table生成 //LotID= GetNewID(BU, DB); LotID = Table_R_Lot_Status.GetNewID(BU, DB); Row_R_Lot_Status.ID = LotID; Row_R_Lot_Status.LOT_NO = LotNo; Row_R_Lot_Status.SKUNO = SNObj.SKUNO; Row_R_Lot_Status.AQL_TYPE = AQL_TYPE; Row_R_Lot_Status.LOT_QTY = 1; Row_R_Lot_Status.REJECT_QTY = 0; Row_R_Lot_Status.SAMPLE_QTY = 1; Row_R_Lot_Status.PASS_QTY = 0; Row_R_Lot_Status.FAIL_QTY = 0; Row_R_Lot_Status.CLOSED_FLAG = "0"; Row_R_Lot_Status.LOT_STATUS_FLAG = "0"; Row_R_Lot_Status.LINE = Line; Row_R_Lot_Status.SAMPLE_STATION = Station; Row_R_Lot_Status.EDIT_EMP = EmpNo; Row_R_Lot_Status.EDIT_TIME = GetDBDateTime(DB); DB.ExecSQL(Row_R_Lot_Status.GetInsertString(DBType)); } else { LotID = LotSatusID; Row_R_Lot_Status = (Row_R_LOT_STATUS)Table_R_Lot_Status.GetObjByID(LotSatusID, DB); int LotQty = (int)Row_R_Lot_Status.LOT_QTY + 1; int SampleQty = Table_C_AQLTYPE.GetSampleQty(AQL_TYPE, LotQty, DB); Row_R_Lot_Status.SAMPLE_QTY = SampleQty; Row_R_Lot_Status.LOT_QTY += 1; DB.ExecSQL(Row_R_Lot_Status.GetUpdateString(DBType)); } //Modify by LLF 2018-03-19,生成ID,需根據Table生成 //Row_R_Lot_Detail.ID = GetNewID(BU, DB); Row_R_Lot_Detail.ID = Table_R_Lot_Detail.GetNewID(BU, DB); Row_R_Lot_Detail.LOT_ID = LotID; //Row_R_Lot_Detail.LOT_ID = LotID; Row_R_Lot_Detail.SN = SNObj.SN; Row_R_Lot_Detail.WORKORDERNO = SNObj.WORKORDERNO; Row_R_Lot_Detail.CREATE_DATE = GetDBDateTime(DB); Row_R_Lot_Detail.SAMPLING = "0"; Row_R_Lot_Detail.STATUS = "0"; Row_R_Lot_Detail.FAIL_CODE = ""; Row_R_Lot_Detail.FAIL_LOCATION = ""; Row_R_Lot_Detail.DESCRIPTION = ""; Row_R_Lot_Detail.CARTON_NO = ""; Row_R_Lot_Detail.PALLET_NO = ""; Row_R_Lot_Detail.EDIT_EMP = EmpNo; Row_R_Lot_Detail.EDIT_TIME = GetDBDateTime(DB); DB.ExecSQL(Row_R_Lot_Detail.GetInsertString(DBType)); } catch (Exception ex) { throw ex; } }
public static void SNLinkPassAction(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras) { string SubSn = ""; SN SubSNObj = new SN(); SN SnObj = new SN(); WorkOrder WO = new WorkOrder(); T_R_SN Table_R_SN = new T_R_SN(Station.SFCDB, Station.DBType); T_R_SN_STATION_DETAIL Table_SnDetail = new T_R_SN_STATION_DETAIL(Station.SFCDB, Station.DBType); T_R_SN_KEYPART_DETAIL Table_R_Keypart = new T_R_SN_KEYPART_DETAIL(Station.SFCDB, Station.DBType); string ErrMessage = string.Empty; List <C_KEYPART> SubKPList = new List <C_KEYPART>(); List <C_KEYPART> MainKPList = new List <C_KEYPART>(); string StrNextStation = ""; string Status = ""; R_SN R_Sn = null; T_R_WO_BASE WoTable = null; //add by LLF List <Dictionary <string, string> > KPList = new List <Dictionary <string, string> >(); string result = ""; if (Paras.Count == 0) { throw new Exception("參數數量不正確!"); } MESStationSession SubSNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY); if (SubSNSession == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY })); } MESStationSession SubKPSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY); if (SubKPSession == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY })); } MESStationSession MainKPSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY); if (MainKPSession == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY })); } MESStationSession KPListSession = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY); if (KPListSession == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[3].SESSION_TYPE + Paras[3].SESSION_KEY })); } MESStationSession WOSession = Station.StationSession.Find(t => t.MESDataType == Paras[4].SESSION_TYPE && t.SessionKey == Paras[4].SESSION_KEY); if (WOSession == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[4].SESSION_TYPE + Paras[4].SESSION_KEY })); } MESStationSession NextStationSession = Station.StationSession.Find(t => t.MESDataType == Paras[5].SESSION_TYPE && t.SessionKey == Paras[5].SESSION_KEY); if (NextStationSession == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[5].SESSION_TYPE + Paras[5].SESSION_KEY })); } MESStationSession StatusSession = Station.StationSession.Find(t => t.MESDataType == Paras[6].SESSION_TYPE && t.SessionKey == Paras[6].SESSION_KEY); if (StatusSession == null) { StatusSession = new MESStationSession() { MESDataType = Paras[6].SESSION_TYPE, SessionKey = Paras[6].SESSION_KEY, ResetInput = Input }; Station.StationSession.Add(StatusSession); if (string.IsNullOrEmpty(Paras[0].VALUE)) { StatusSession.Value = "PASS"; } } Status = StatusSession.Value.ToString(); MESStationSession ClearFlagGSession = Station.StationSession.Find(t => t.MESDataType == Paras[7].SESSION_TYPE && t.SessionKey == Paras[7].SESSION_KEY); if (ClearFlagGSession == null) { ClearFlagGSession = new MESStationSession() { MESDataType = Paras[7].SESSION_TYPE, SessionKey = Paras[7].SESSION_KEY, ResetInput = Input }; Station.StationSession.Add(ClearFlagGSession); } ClearFlagGSession.Value = "false"; StrNextStation = SnObj.StringListToString((List <string>)NextStationSession.Value); //StrNextStation = NextStationSession.Value.ToString(); SubKPList = (List <C_KEYPART>)SubKPSession.Value; MainKPList = (List <C_KEYPART>)MainKPSession.Value; KPList = (List <Dictionary <string, string> >)KPListSession.Value; SubSNObj = (SN)SubSNSession.Value; WO = (WorkOrder)WOSession.Value; SubSn = SubSNObj.SerialNo; R_Sn = Table_R_SN.GetById(SubSNObj.ID, Station.SFCDB); if (SubKPList.Count + MainKPList.Count == KPList.Count) { Table_R_SN.UpdateSNKeyparStatus(SubSNObj.ID, Station.LoginUser.EMP_NO, "0", Station.SFCDB); Table_R_SN.InsertLinkSN(SubSn, WO.WorkorderNo, WO.SkuNO, WO.RouteID, WO.KP_LIST_ID, Station.StationName, StrNextStation, Station.LoginUser.EMP_NO, Station.BU, Station.SFCDB, SubSNObj.Plant); //更新Main KP SN foreach (Dictionary <string, string> DicMainKP in KPList) { int SeqNo = Convert.ToInt16(DicMainKP["SEQ_NO"]); if (DicMainKP["KP_TYPE"] == "MAIN_SN") { Table_R_SN.UpdateSNKeyparStatus(DicMainKP["KP_SN_ID"], Station.LoginUser.EMP_NO, "1", Station.SFCDB); } //写KP Table_R_Keypart.INSN_KEYPART_DETAIL(Station.SFCDB, Station.BU, SubSNObj.ID, DicMainKP["SN"], DicMainKP["KEYPART_SN"], Station.StationName, DicMainKP["PART_NO"], SeqNo, DicMainKP["CATEGORY_NAME"], DicMainKP["CATEGORY"], Station.LoginUser.EMP_NO); } //寫過站記錄 result = Table_R_SN.LinkPassStationDetail(R_Sn, WO.WorkorderNo, WO.SkuNO, WO.RouteID, Station.Line, Station.StationName, Station.StationName, Station.LoginUser.EMP_NO, Station.BU, Station.SFCDB); if (Convert.ToInt32(result) <= 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { "STATION DETAIL" })); } //add by LLF WoTable = new T_R_WO_BASE(Station.SFCDB, Station.DBType); result = WoTable.AddCountToWo(WO.WorkorderNo, 1, Station.SFCDB); // 更新 R_WO_BASE 中的數據 if (Convert.ToInt32(result) <= 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "WO QTY" })); } //寫良率,UPH result = Table_R_SN.RecordUPH(WO.WorkorderNo, 1, SubSn, Status, Station.Line, Station.StationName, Station.LoginUser.EMP_NO, Station.BU, Station.SFCDB); if (Convert.ToInt32(result) <= 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { "UPH" })); } result = Table_R_SN.RecordYieldRate(WO.WorkorderNo, 1, SubSn, Status, Station.Line, Station.StationName, Station.LoginUser.EMP_NO, Station.BU, Station.SFCDB); if (Convert.ToInt32(result) <= 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { "YIELD" })); } KPListSession.Value = null; ClearFlagGSession.Value = "true"; Station.AddMessage("MES00000195", new string[] { SubSn, StrNextStation }, StationMessageState.Pass); } }
public static void SNFailAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <R_Station_Action_Para> Paras) { string ErrMessage = ""; Int16 FailCount = 0; string StrSn = ""; string R_SN_STATION_DETAIL_ID = ""; List <Dictionary <string, string> > FailList = null; if (Paras.Count == 0) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050")); } MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY); if (SNSession == null) { ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }); throw new MESReturnMessage(ErrMessage); } MESStationSession FailCountSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY); if (FailCountSession == null) { ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }); throw new MESReturnMessage(ErrMessage); } MESStationSession FailListSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY); if (FailListSession == null) { ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY }); throw new MESReturnMessage(ErrMessage); } MESStationSession StatusSession = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY); if (StatusSession == null) { StatusSession = new MESStationSession() { MESDataType = Paras[3].SESSION_TYPE, InputValue = Input.Value.ToString(), Value = Paras[3].VALUE, SessionKey = Paras[3].SESSION_KEY, ResetInput = Input }; // Station.StationSession.Add(StatusSession); if (StatusSession.Value == null) { StatusSession.Value = "FAIL"; } Station.StationSession.Add(StatusSession); } FailCount = Convert.ToInt16(FailCountSession.Value.ToString()); FailList = (List <Dictionary <string, string> >)FailListSession.Value; T_R_SN rSn = new T_R_SN(Station.SFCDB, DB_TYPE_ENUM.Oracle); DateTime FailTime = rSn.GetDBDateTime(Station.SFCDB); if (FailList.Count >= FailCount && FailCount != 0) //允許掃描多個Fail { StrSn = SNSession.InputValue.ToString(); string repairMainId = ""; for (int i = 0; i < FailList.Count; i++) { //獲取頁面傳過來的數據 string failCode = FailList[i]["FailCode"].ToString(); string failLocation = FailList[i]["FailLocation"].ToString(); string failProcess = FailList[i]["FailProcess"].ToString(); string failDescription = FailList[i]["FailDesc"].ToString(); OleExec oleDB = null; oleDB = Station.SFCDB; //oleDB.BeginTrain(); //以下執行 要么全成功,要么全失敗 T_R_REPAIR_MAIN tRepairMain = new T_R_REPAIR_MAIN(Station.SFCDB, DB_TYPE_ENUM.Oracle); Row_R_REPAIR_MAIN rRepairMain = (Row_R_REPAIR_MAIN)tRepairMain.NewRow(); Row_R_SN rrSn = (Row_R_SN)rSn.NewRow(); if (i == 0) { //更新R_SN REPAIR_FAILED_FLAG=’1’ R_SN r = rSn.GetDetailBySN(StrSn, Station.SFCDB); rrSn = (Row_R_SN)rSn.GetObjByID(r.ID, Station.SFCDB); rrSn.REPAIR_FAILED_FLAG = "1"; rrSn.EDIT_EMP = Station.LoginUser.EMP_NO; rrSn.EDIT_TIME = FailTime; string strRet = (Station.SFCDB).ExecSQL(rrSn.GetUpdateString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(strRet) > 0)) { throw new Exception("update repair failed flag error!"); } //新增一筆FAIL記錄到R_SN_STATION_DETAIL T_R_SN_STATION_DETAIL rSnStationDetail = new T_R_SN_STATION_DETAIL(Station.SFCDB, DB_TYPE_ENUM.Oracle); R_SN_STATION_DETAIL_ID = rSnStationDetail.GetNewID(Station.BU, Station.SFCDB); string detailResult = rSnStationDetail.AddDetailToRSnStationDetail(R_SN_STATION_DETAIL_ID, rrSn.GetDataObject(), Station.Line, Station.StationName, Station.StationName, Station.SFCDB); if (!(Convert.ToInt32(detailResult) > 0)) { throw new Exception("Insert sn station detail error!"); } //新增一筆到R_REPAIR_MAIN repairMainId = tRepairMain.GetNewID(Station.BU, Station.SFCDB); rRepairMain.ID = repairMainId; rRepairMain.SN = StrSn; rRepairMain.WORKORDERNO = rrSn.WORKORDERNO; rRepairMain.SKUNO = rrSn.SKUNO; rRepairMain.FAIL_LINE = Station.Line; rRepairMain.FAIL_STATION = Station.StationName; rRepairMain.FAIL_EMP = Station.LoginUser.EMP_NO; //rRepairMain.FAIL_TIME = Station.GetDBDateTime();//Mpdofy by LLF 2018-03-17 rRepairMain.FAIL_TIME = FailTime; rRepairMain.CREATE_TIME = Station.GetDBDateTime(); rRepairMain.EDIT_EMP = Station.LoginUser.EMP_NO; rRepairMain.EDIT_TIME = Station.GetDBDateTime(); rRepairMain.CLOSED_FLAG = "0"; string insertResult = (Station.SFCDB).ExecSQL(rRepairMain.GetInsertString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(insertResult) > 0)) { throw new Exception("Insert repair main error!"); } } ////新增一筆到R_REPAIR_MAIN //T_R_REPAIR_MAIN tRepairMain = new T_R_REPAIR_MAIN(Station.SFCDB, DB_TYPE_ENUM.Oracle); //Row_R_REPAIR_MAIN rRepairMain = (Row_R_REPAIR_MAIN)tRepairMain.NewRow(); //rRepairMain.ID = tRepairMain.GetNewID(Station.BU, Station.SFCDB); //rRepairMain.SN = StrSn; //rRepairMain.WORKORDERNO = rrSn.WORKORDERNO; //rRepairMain.SKUNO = rrSn.SKUNO; //rRepairMain.FAIL_LINE = Station.Line; //rRepairMain.FAIL_STATION = Station.StationName; //rRepairMain.FAIL_EMP = Station.LoginUser.EMP_NO; //rRepairMain.FAIL_TIME = FailTime.ToString(); //rRepairMain.CLOSED_FLAG = "0"; //string insertResult = (Station.SFCDB).ExecSQL(rRepairMain.GetInsertString(DB_TYPE_ENUM.Oracle)); //if (!(Convert.ToInt32(insertResult) > 0)) //{ // throw new Exception("Insert repair main error!"); //} //新增一筆到R_REPAIR_FAILCODE T_R_REPAIR_FAILCODE tRepairFailCode = new T_R_REPAIR_FAILCODE(Station.SFCDB, DB_TYPE_ENUM.Oracle); Row_R_REPAIR_FAILCODE rRepairFailCode = (Row_R_REPAIR_FAILCODE)tRepairFailCode.NewRow(); rRepairFailCode.ID = tRepairFailCode.GetNewID(Station.BU, Station.SFCDB); rRepairFailCode.REPAIR_MAIN_ID = repairMainId; rRepairFailCode.SN = StrSn; rRepairFailCode.FAIL_CODE = failCode; rRepairFailCode.FAIL_EMP = Station.LoginUser.EMP_NO; rRepairFailCode.FAIL_TIME = FailTime; rRepairFailCode.FAIL_CATEGORY = "SYMPTOM"; rRepairFailCode.FAIL_LOCATION = failLocation; rRepairFailCode.FAIL_PROCESS = failProcess; rRepairFailCode.DESCRIPTION = failDescription; rRepairFailCode.REPAIR_FLAG = "0"; rRepairFailCode.CREATE_TIME = Station.GetDBDateTime(); rRepairFailCode.EDIT_EMP = Station.LoginUser.EMP_NO; rRepairFailCode.EDIT_TIME = Station.GetDBDateTime(); string strResult = (Station.SFCDB).ExecSQL(rRepairFailCode.GetInsertString(DB_TYPE_ENUM.Oracle)); if (!(Convert.ToInt32(strResult) > 0)) { throw new Exception("Insert repair failcode error!"); } //oleDB.CommitTrain(); } ((List <Dictionary <string, string> >)FailListSession.Value).Clear(); Station.AddMessage("MES00000001", new string[] { }, MESReturnView.Station.StationMessageState.Pass); } }