public override void MakeLabel(OleExec DB) { //base.MakeLabel(DB); t_r_sn = new T_R_SN(DB, MESDataObject.DB_TYPE_ENUM.Oracle); C_SKU_Label labelName = null; LogicObject.SN snObj; R_SN r_sn; if (I_SN.Value is string) { r_sn = t_r_sn.LoadSN(I_SN.Value.ToString(), DB); } else if (typeof(LogicObject.SN) == I_SN.Value.GetType()) { snObj = (LogicObject.SN)I_SN.Value; r_sn = t_r_sn.LoadSN(snObj.SerialNo, DB); } else if (typeof(R_SN) == I_SN.Value.GetType()) { r_sn = (R_SN)I_SN.Value; } else { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180607163531", new string[] { I_SN.Value.ToString() })); } labelName = DB.ORM.Queryable <C_SKU_Label>().Where(l => l.SKUNO == r_sn.SKUNO && l.STATION == I_STATION.Value.ToString()).ToList().FirstOrDefault(); if (labelName.LABELNAME == "2000E3_CARTON") { Get2000E3CartonValue(r_sn, DB); } }
/// <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); }
/// <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); }
/// <summary> /// 從輸入加載SN對象集合 /// </summary> /// <param name="Station"></param> /// <param name="Input"></param> /// <param name="Paras"></param> public static void GetSnObjectListDataloader(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras) { if (Paras.Count != 4) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000057")); } MESStationSession sessionWO = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY); if (sessionWO == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE })); } MESStationSession sessionInputType = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY); if (sessionInputType == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE })); } if (sessionInputType.Value.ToString() == "") { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE })); } MESStationSession sessionInputString = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY); if (sessionInputString == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE })); } if (sessionInputString.Value.ToString() == "") { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE })); } MESStationSession snObjectList = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_KEY && t.SessionKey == Paras[3].SESSION_KEY); if (snObjectList == null) { snObjectList = new MESStationSession() { MESDataType = Paras[3].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[3].SESSION_KEY, ResetInput = Input }; Station.StationSession.Add(snObjectList); } try { WorkOrder objWorkorder = new WorkOrder(); objWorkorder = (WorkOrder)sessionWO.Value; string inputType = sessionInputType.Value.ToString(); string inputString = sessionInputString.Value.ToString(); List <R_SN> snList = new List <R_SN>(); T_R_SN_KP t_r_sn_kp = new T_R_SN_KP(Station.SFCDB, Station.DBType); if (inputType.Equals("SN")) { T_R_SN t_r_sn = new T_R_SN(Station.SFCDB, Station.DBType); snList.Add(t_r_sn.LoadSN(inputString, Station.SFCDB)); } else if (inputType.Equals("PANEL")) { T_R_PANEL_SN t_r_panel_sn = new T_R_PANEL_SN(Station.SFCDB, Station.DBType); snList = t_r_panel_sn.GetValidSnByPanel(inputString, Station.SFCDB); } else { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180529094259")); } snObjectList.Value = snList; Station.AddMessage("MES00000001", new string[] { sessionInputString.Value.ToString() }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass); } catch (Exception ex) { throw ex; } }
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; } } }
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); }