public void DataLoad(string packNo, string bu, OleExec sfcdb, DB_TYPE_ENUM DBType) { List <string> itemList = new List <string>(); T_C_SKU t_c_sku = new T_C_SKU(sfcdb, DBType); T_R_PACKING t_r_packing = new T_R_PACKING(sfcdb, DBType); T_R_SN_PACKING t_r_sn_packing = new T_R_SN_PACKING(sfcdb, DBType); T_R_SN t_r_sn = new T_R_SN(sfcdb, DBType); T_C_PACKING t_c_packing = new T_C_PACKING(sfcdb, DBType); R_PACKING packing = new R_PACKING(); C_SKU sku = new C_SKU(); Packing packObject = new Packing(); C_PACKING c_packing = new C_PACKING(); packing = t_r_packing.GetRPackingByPackNo(sfcdb, packNo).GetDataObject(); sku = t_c_sku.GetSku(packing.SKUNO, sfcdb, DBType).GetDataObject(); if (packing.PACK_TYPE == LogicObject.PackType.PALLET.ToString().ToUpper()) { c_packing = t_c_packing.GetPackingBySkuAndType(sku.SKUNO, LogicObject.PackType.CARTON.ToString().ToUpper(), sfcdb); if (c_packing.MAX_QTY == 1 && bu.ToUpper().Equals("VERTIV")) { //VERTIV 當卡通包規為1時,調棧板顯示卡通內的SN itemList = t_r_packing.GetPakcingSNList(packing.ID, sfcdb); } else { List <R_PACKING> packingList = t_r_packing.GetListPackByParentPackId(packing.ID, sfcdb); foreach (R_PACKING pack in packingList) { itemList.Add(pack.PACK_NO); } } } else if (packing.PACK_TYPE == LogicObject.PackType.CARTON.ToString().ToUpper()) { List <Row_R_SN_PACKING> snPackingList = t_r_sn_packing.GetPackItem(packing.ID, sfcdb); foreach (Row_R_SN_PACKING sn in snPackingList) { itemList.Add(t_r_sn.GetById(sn.SN_ID, sfcdb).SN); } } this.PackID = packing.ID; this.PackNo = packing.PACK_NO; this.PackType = packing.PACK_TYPE; this.ParentPackID = packing.PARENT_PACK_ID; this.Skuno = packing.SKUNO; this.SkunoVer = sku.VERSION; this.MaxQty = packing.MAX_QTY; this.Qty = packing.QTY; this.ClosedFlag = packing.CLOSED_FLAG; this.CreatTime = packing.CREATE_TIME; this.EditTime = packing.EDIT_TIME; this.EditEmp = packing.EDIT_EMP; this.Line = packing.LINE; this.Station = packing.STATION; this.IP = packing.IP; this.PackList = itemList; }
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); } }