//計數器初始化 public static void CounterInitDataloader(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras) { if (Paras.Count == 0) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050")); } MESStationSession CounterSavePoint = Station.StationSession.Find(t => t.MESDataType == "COUNT" && t.SessionKey == "1"); if (CounterSavePoint == null) { CounterSavePoint = new MESStationSession() { MESDataType = "COUNT", InputValue = Input.Value.ToString(), SessionKey = "1", ResetInput = Input }; Station.StationSession.Add(CounterSavePoint); } //CounterSavePoint.Value = Paras.Find(p => p.SESSION_TYPE == "COUNT").VALUE; R_Station_Action_Para para = Paras.Where(p => p.SESSION_TYPE == "COUNT").FirstOrDefault(); if (para == null) { CounterSavePoint.Value = 0; } else { CounterSavePoint.Value = int.Parse(Paras.Where(p => p.SESSION_TYPE == "COUNT").FirstOrDefault().VALUE); } Station.AddMessage("MES00000029", new string[] { "COUNT", "InitCount" }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass); }
public static void SetNextInputAction(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras) { //参数1,获取一个内存变量,检查它的值是否为配置值, //如是,设置next为配置2的 // R_Station_Action_Para P1 = Paras[0]; MESStationSession s = Station.StationSession.Find(t => t.MESDataType == P1.SESSION_TYPE && t.SessionKey == P1.SESSION_KEY); if (s == null) { return; } if (s.Value.ToString() == P1.VALUE.ToString()) { R_Station_Action_Para P2 = Paras[1]; MESStationInput i = Station.Inputs.Find(t => t.DisplayName == P2.VALUE.ToString()); if (i != null) { Station.NextInput = i; } } else { R_Station_Action_Para P2 = Paras[2]; MESStationInput i = Station.Inputs.Find(t => t.DisplayName == P2.VALUE.ToString()); if (i != null) { Station.NextInput = i; } } }
/// <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; } }