protected override void StateChanged(StateItem stateItem, IProcessDispatcher dispatcher) { /* 处理事项: * * stateItem.ItemName : * 空托盘组,从小车站台到达入库站台。 * stateItem.State :参数 - 任务号。 */ object obj = ObjectUtil.GetObject(stateItem.State); if (obj == null || obj.ToString() == "0") return; string TaskNo = obj.ToString().PadLeft(4, '0'); try { switch (stateItem.ItemName) { case "02_1_302": break; case "02_1_306": break; case "02_1_310": break; case "02_1_314": break; case "02_1_318": break; case "02_1_324": break; default: break; } TaskDal dal = new TaskDal(); string[] strValue = dal.GetTaskInfo(TaskNo); if (!string.IsNullOrEmpty(strValue[1])) { DataTable dtTask = dal.TaskInfo(string.Format("TASK_ID='{0}'", strValue[0])); string CellCode = dtTask.Rows[0]["CELL_CODE"].ToString(); //更新小车站台到达入库站台任务完成。 dal.UpdateTaskDetailState(string.Format("TASK_ID='{0}' AND ITEM_NO='3'", strValue[0]), "2"); SysStationDal sysdal = new SysStationDal(); DataTable dtstation = sysdal.GetSationInfo(CellCode, "21","4"); //更新调度堆垛机的起始位置及目标地址。 dal.UpdateTaskDetailCrane(dtstation.Rows[0]["STATION_NO"].ToString(), CellCode, "0", dtstation.Rows[0]["CRANE_NO"].ToString(), string.Format("TASK_ID='{0}' AND ITEM_NO=4", strValue[0])); DataTable dt = dal.CraneTaskIn(string.Format("TASK.TASK_ID='{0}' and ITEM_NO='4'", strValue[0])); if (dt.Rows.Count > 0) { WriteToProcess("CraneProcess", "CraneInRequest", dt); } } } catch (Exception e) { Logger.Error("THOK.XC.Process.Process_02.PalletToStationProcess, 原因:" + e.Message); } }
/// <summary> ///接收删除指令返回值 /// </summary> /// <param name="state"></param> private void DEC(object state) { Dictionary<string, string> msg = (Dictionary<string, string>)state; if (msg["ReturnCode"] == "000") //序列号出错,重新发送报文 { TaskDal dal = new TaskDal(); DataTable dt = dal.CraneTaskIn(string.Format("DETAIL.CRANE_NO='{0}' AND ASSIGNMENT_ID='{1}'", msg["CraneNo"], msg["AssignmenID"])); DataRow dr = null; if (dt.Rows.Count > 0) dr = dt.Rows[0]; if (dr != null) { #region 错误处理 if (dr["ERR_CODE"].ToString() == "111") //入库,货位有货,重新分配货位 { CellDal cdal = new CellDal(); cdal.UpdateCellErrFlag(dr["CELL_CODE"].ToString(), "货位有货,系统无记录"); string[] strValue = dal.AssignNewCell(string.Format("TASK_ID='{0}'",dr["TASK_ID"].ToString()), dr["CRANE_NO"].ToString());//货位申请 ProductStateDal StateDal = new ProductStateDal(); StateDal.UpdateProductCellCode(strValue[0], strValue[1]); //更新Product_State 货位 SysStationDal sysdal = new SysStationDal(); DataTable dtstation = sysdal.GetSationInfo(strValue[1], dr["TASK_TYPE"].ToString(), dr["ITEM_NO"].ToString()); dal.UpdateTaskDetailCrane(dtstation.Rows[0]["STATION_NO"].ToString(), strValue[1], "1", dtstation.Rows[0]["CRANE_NO"].ToString(), string.Format("TASK_ID='{0}' AND ITEM_NO={1}", strValue[0], dr["ITEM_NO"].ToString()));//更新调度堆垛机的其实位置及目标地址。 dr.BeginEdit(); dr["CELLSTATION"] = "30" + strValue[1] + "01"; dr.EndEdit(); SendTelegramARQ(dr, false); //if (dtCrane != null) //{ // DataRow[] drs = dtCrane.Select(string.Format("ASSIGNMENT_ID='{0}'", msg["AssignmenID"])); // if (drs.Length > 0) // dtCrane.Rows.Remove(drs[0]); //} } else if (dr["ERR_CODE"].ToString() == "113")//出库,货位无货, { string ErrMsg = ""; DataRow[] drMsgs = dtErrMesage.Select(string.Format("CODE='{0}'", dr["ERR_CODE"].ToString())); if (drMsgs.Length > 0) ErrMsg = drMsgs[0]["DESCRIPTION"].ToString(); string strBillNo = ""; string[] strMessage = new string[3]; strMessage[0] = "8"; strMessage[1] =dr["TASK_ID"].ToString(); strMessage[2] = "错误代码:" + dr["ERR_CODE"] + ",错误内容:" + ErrMsg; DataTable dtProductInfo = dal.GetProductInfoByTaskID(dr["TASK_ID"].ToString()); while ((strBillNo = FormDialog.ShowDialog(strMessage, dtProductInfo)) != "") { BillDal bdal = new BillDal(); string strNewBillNo = strBillNo; string strOutTaskID = bdal.CreateCancelBillOutTask(dr["TASK_ID"].ToString(), dr["BILL_NO"].ToString(), strNewBillNo); DataTable dtOutTask = dal.CraneTaskOut(string.Format("TASK_ID='{0}'", strOutTaskID)); WriteToProcess("CraneProcess", "CraneInRequest", dtOutTask); CellDal cdal = new CellDal(); cdal.UpdateCellErrFlag(dr["CELL_CODE"].ToString(), "货位无货,系统有记录"); break; } } } #endregion } }
/// <summary> /// 发送报文后,堆垛机发送接收确认。 /// </summary> /// <param name="state"></param> private void ACK(object state) { Dictionary<string, string> msg = (Dictionary<string, string>)state; DataRow dr = null; TaskDal dal = new TaskDal(); if (dtCrane != null) { DataRow[] drs = dtCrane.Select(string.Format("SQUENCE_NO='{0}'", msg["SequenceNo"])); if (drs.Length > 0) { dr = drs[0]; } } if (dr == null) { //根据流水号,获取资料 DataTable dt = dal.CraneTaskIn(string.Format("DETAIL.SQUENCE_NO='{0}' AND DETAIL.CRANE_NO IS NOT NULL", msg["SequenceNo"])); if (dt.Rows.Count > 0) dr = dt.Rows[0]; } #region 缓存数据存在 if (dr != null) { string TaskType = dr["TASK_TYPE"].ToString(); string ItemNo = dr["ITEM_NO"].ToString(); BillDal bdal = new BillDal(); if (TaskType.Substring(1, 1) == "2" || (TaskType == "13" && ItemNo == "1") || (TaskType == "14" && ItemNo == "1" && dr["CRANE_NO"].ToString() != dr["NEW_CRANE_NO"].ToString())) { dal.UpdateTaskState(dr["TASK_ID"].ToString(), "1"); dal.UpdateTaskDetailCrane(dr["CELL_CODE"].ToString(), dr["STATION_NO"].ToString(), "1", dr["CRANE_NO"].ToString(), string.Format("TASK_ID='{0}' AND ITEM_NO={1}", dr["TASK_ID"], dr["ITEM_NO"])); //更新BILL_MASTER 单据状态作业中 bdal.UpdateBillMasterStart(dr["BILL_NO"].ToString(), dr["PRODUCT_CODE"].ToString() == "0000" ? false : true); } else if (TaskType == "14" && ItemNo == "1" && dr["CRANE_NO"].ToString() == dr["NEW_CRANE_NO"].ToString()) { //出库任务 更新任务状态:任务执行中 dal.UpdateTaskState(dr["TASK_ID"].ToString(), "1"); dal.UpdateTaskDetailCrane(dr["CELL_CODE"].ToString(), dr["NEWCELL_CODE"].ToString(), "1", dr["CRANE_NO"].ToString(), string.Format("TASK_ID='{0}' AND ITEM_NO={1}", dr["TASK_ID"], dr["ITEM_NO"])); bdal.UpdateBillMasterStart(dr["BILL_NO"].ToString(), true); } else dal.UpdateTaskDetailState(string.Format("TASK_ID='{0}' and ITEM_NO={1}", dr["TASK_ID"], dr["ITEM_NO"]), "1"); if (dtCrane != null) { DataRow []drs=dtCrane.Select(string.Format("TASK_ID='{0}'",dr["TASK_ID"])); if(drs.Length>0) { drs[0].BeginEdit(); drs[0]["state"]="1"; drs[0].EndEdit(); dtCrane.AcceptChanges(); } } } #endregion }
protected override void StateChanged(StateItem stateItem, IProcessDispatcher dispatcher) { /* * 一楼入库到达入库站台。 */ try { object obj = ObjectUtil.GetObject(stateItem.State); if (obj == null || obj.ToString() == "0") return; switch (stateItem.ItemName) { case "01_1_136": break; case "01_1_148": break; case "01_1_152": break; case "01_1_170": break; case "01_1_178": break; case "01_1_186": break; } //电控系统返回任务号9999 string TaskNo = obj.ToString().PadLeft(4, '0'); TaskDal taskDal = new TaskDal(); string[] TaskInfo = taskDal.GetTaskInfo(TaskNo); DataTable dt = taskDal.TaskInfo(string.Format("TASK_ID='{0}'", TaskInfo[0])); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; string taskType = dt.Rows[0]["TASK_TYPE"].ToString(); string ItemNo = "0"; string NextItemNo="1"; string CellCode = ""; switch(taskType) { //入库 case "11": ItemNo = "2"; NextItemNo = "3"; CellCode = dr["CELL_CODE"].ToString(); break; //盘点 case "13": ItemNo = "3"; NextItemNo = "4"; CellCode = dr["CELL_CODE"].ToString(); break; //移库 case "14": ItemNo = "2"; NextItemNo = "3"; CellCode = dr["NEWCELL_CODE"].ToString(); break; } //更新路线完成状态 taskDal.UpdateTaskDetailState(string.Format("TASK_NO='{0}' AND ITEM_NO='{1}'", TaskNo, ItemNo), "2"); SysStationDal sysdal = new SysStationDal(); DataTable dtstation = sysdal.GetSationInfo(CellCode, "11","3"); //更新调度堆垛机的起始位置及目标地址。 taskDal.UpdateTaskDetailCrane(dtstation.Rows[0]["STATION_NO"].ToString(), CellCode, "0", dtstation.Rows[0]["CRANE_NO"].ToString(), string.Format("TASK_ID='{0}' AND ITEM_NO={1}", TaskInfo[0],NextItemNo)); string strWhere = string.Format("TASK_NO='{0}'AND DETAIL.STATE='0' and ITEM_NO='{1}'", TaskNo, NextItemNo); DataTable dtInCrane = taskDal.CraneTaskIn(strWhere); if (dtInCrane.Rows.Count > 0) WriteToProcess("CraneProcess", "CraneInRequest", dtInCrane); } } catch (Exception e) { Logger.Error("THOK.XC.Process.Process_01.StockInStationProcess:" + e.Message); } }
/// <summary> /// �̵� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCheckScan_Click(object sender, EventArgs e) { object obj= ObjectUtil.GetObject(Context.ProcessDispatcher.WriteToService("StockPLC_01", "01_1_195")); if (obj == null || obj.ToString() == "0") return; string strTaskNo = obj.ToString().PadLeft(4, '0'); if ( int.Parse(obj.ToString()) >= 9800 && int.Parse(obj.ToString()) < 9999) //�̵� { string[] str = new string[3]; str[0] = "6"; str[1] = ""; str[2] = ""; TaskDal dal = new TaskDal(); //��������ţ���ȡTaskID��BILL_NO string[] strInfo = dal.GetTaskInfo(strTaskNo); DataTable dt = dal.TaskInfo(string.Format("TASK_ID='{0}'", strInfo[0])); DataTable dtProductInfo = dal.GetProductInfoByTaskID(strInfo[0]); //�߳�ֹͣ string strValue = ""; while ((strValue = FormDialog.ShowDialog(str, dtProductInfo)) != "") { dal.UpdateTaskDetailState(string.Format("TASK_ID='{0}' AND ITEM_NO=2", strInfo[0]), "2"); string writeItem = "01_2_195_"; DataTable dtTask = dal.TaskInfo(string.Format("TASK_ID='{0}'", strInfo[0])); DataRow dr = dtTask.Rows[0]; SysStationDal sysdal = new SysStationDal(); DataTable dtstation = sysdal.GetSationInfo(dr["CELL_CODE"].ToString(), "11","3"); if (strValue != "1") { CellDal celldal = new CellDal(); celldal.UpdateCellErrFlag(dr["CELL_CODE"].ToString(), "����ɨ�費һ��"); } int[] ServiceW = new int[3]; ServiceW[0] = int.Parse(strInfo[1]); //����� ServiceW[1] = int.Parse(dtstation.Rows[0]["STATION_NO"].ToString());//Ŀ�ĵ�ַ ServiceW[2] = 1; Context.ProcessDispatcher.WriteToService("StockPLC_01", writeItem + "1", ServiceW); //PLCд������ Context.ProcessDispatcher.WriteToService("StockPLC_01", writeItem + "3", 1); //PLCд������ dal.UpdateTaskDetailStation("195", dtstation.Rows[0]["STATION_NO"].ToString(), "1", string.Format("TASK_ID='{0}' AND ITEM_NO=3", strInfo[0]));//���»�λ�������վ̨�� dal.UpdateTaskDetailCrane(dtstation.Rows[0]["STATION_NO"].ToString(), dr["CELL_CODE"].ToString(), "0", dtstation.Rows[0]["CRANE_NO"].ToString(), string.Format("TASK_ID='{0}' AND ITEM_NO=4", strInfo[0]));//���µ��ȶѶ������ʵλ�ü�Ŀ���ַ�� break; } } }