You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1677 lines
70 KiB
1677 lines
70 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using SiaSun.LMS.Model;
|
|
|
|
|
|
namespace SiaSun.LMS.Implement
|
|
{
|
|
public class ManageBase:S_BaseService
|
|
{
|
|
private static readonly object lockObj = new object();
|
|
/// <summary>
|
|
/// 根据库存生成移库任务
|
|
/// </summary>
|
|
/// <param name="mSYS_USER"></param>
|
|
/// <param name="PLAN_LIST_ID"></param>
|
|
/// <param name="STOCK_BARCODE"></param>
|
|
/// <param name="START_CELL_ID"></param>
|
|
/// <param name="END_CELL_ID"></param>
|
|
/// <param name="bTrans"></param>
|
|
/// <param name="bAutoSendControl"></param>
|
|
/// <param name="bComplete"></param>
|
|
/// <param name="sResult"></param>
|
|
/// <param name="MANAGE_ID"></param>
|
|
/// <returns></returns>
|
|
public bool ManageCreate(SiaSun.LMS.Model.SYS_USER mSYS_USER,
|
|
int PLAN_LIST_ID,
|
|
string MANAGE_TYPE_CODE,
|
|
string STOCK_BARCODE,
|
|
int START_CELL_ID,
|
|
int END_CELL_ID,
|
|
bool bTrans,
|
|
bool bAutoSendControl,
|
|
bool bComplete, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
int MANAGE_ID = 0;
|
|
|
|
SiaSun.LMS.Model.WH_CELL mWH_CELL_START = this._P_WH_CELL.GetModel(START_CELL_ID);
|
|
|
|
SiaSun.LMS.Model.WH_CELL mWH_CELL_END = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
|
|
IList<SiaSun.LMS.Model.STORAGE_MAIN> lsSTORAGE_MAIN = null;
|
|
|
|
if (STOCK_BARCODE == string.Empty)
|
|
lsSTORAGE_MAIN = this._P_STORAGE_MAIN.GetListCellID(START_CELL_ID);
|
|
else
|
|
lsSTORAGE_MAIN = this._P_STORAGE_MAIN.GetListStockBarcode(STOCK_BARCODE);
|
|
|
|
SiaSun.LMS.Model.PLAN_MAIN mPLAN_MAIN = null;
|
|
|
|
SiaSun.LMS.Model.PLAN_LIST mPLAN_LIST = null;
|
|
|
|
bResult = lsSTORAGE_MAIN.Count > 0;
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("未找到库存");
|
|
|
|
return bResult;
|
|
}
|
|
|
|
|
|
if (this._P_MANAGE_MAIN.GetModelStockBarcode(lsSTORAGE_MAIN[0].STOCK_BARCODE) != null)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("托盘条码{0}已经存在任务", lsSTORAGE_MAIN[0].STOCK_BARCODE);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
try
|
|
{
|
|
this._P_Base_House.BeginTransaction(bTrans);
|
|
|
|
if (!PLAN_LIST_ID.Equals(0))
|
|
{
|
|
mPLAN_LIST = this._P_PLAN_LIST.GetModel(PLAN_LIST_ID);
|
|
|
|
mPLAN_MAIN = this._P_PLAN_MAIN.GetModel(mPLAN_LIST.PLAN_ID);
|
|
}
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = new SiaSun.LMS.Model.MANAGE_MAIN();
|
|
|
|
mMANAGE_MAIN.MANAGE_TYPE_CODE = MANAGE_TYPE_CODE;
|
|
|
|
if (null != mPLAN_LIST)
|
|
{
|
|
mMANAGE_MAIN.PLAN_ID = mPLAN_LIST.PLAN_ID;
|
|
}
|
|
else
|
|
{
|
|
mMANAGE_MAIN.PLAN_ID = 0;
|
|
}
|
|
|
|
if (mSYS_USER == null)
|
|
{
|
|
mMANAGE_MAIN.MANAGE_OPERATOR = "管理系统";
|
|
}
|
|
else
|
|
{
|
|
mMANAGE_MAIN.MANAGE_OPERATOR = mSYS_USER.USER_CODE;
|
|
}
|
|
|
|
mMANAGE_MAIN.STOCK_BARCODE = lsSTORAGE_MAIN[0].STOCK_BARCODE;
|
|
|
|
mMANAGE_MAIN.START_CELL_ID = START_CELL_ID;
|
|
|
|
mMANAGE_MAIN.END_CELL_ID = END_CELL_ID;
|
|
|
|
mMANAGE_MAIN.MANAGE_BEGIN_TIME = SiaSun.LMS.Common.StringUtil.GetDateTime();
|
|
|
|
//mMANAGE_MAIN.MANAGE_STATUS = SiaSun.LMS.Enum.MANAGE_STATUS.WaitingSend.ToString();
|
|
|
|
mMANAGE_MAIN.MANAGE_REMARK = string.Empty;
|
|
|
|
this._P_MANAGE_MAIN.Add(mMANAGE_MAIN);
|
|
|
|
SiaSun.LMS.Model.MANAGE_LIST mMANAGE_LIST = null;
|
|
|
|
foreach (SiaSun.LMS.Model.STORAGE_MAIN mSTORAGE_MAIN in lsSTORAGE_MAIN)
|
|
{
|
|
IList<SiaSun.LMS.Model.STORAGE_LIST> lsSTORAGE_LIST = this._P_STORAGE_LIST.GetListStorageID(mSTORAGE_MAIN.STORAGE_ID);
|
|
|
|
foreach (SiaSun.LMS.Model.STORAGE_LIST mSTORAGE_LIST in lsSTORAGE_LIST)
|
|
{
|
|
|
|
mMANAGE_LIST = new SiaSun.LMS.Model.MANAGE_LIST();
|
|
|
|
mMANAGE_LIST.MANAGE_ID = mMANAGE_MAIN.MANAGE_ID;
|
|
|
|
if (null != mPLAN_LIST)
|
|
{
|
|
mMANAGE_LIST.PLAN_LIST_ID = PLAN_LIST_ID;
|
|
}
|
|
else
|
|
{
|
|
mMANAGE_LIST.PLAN_LIST_ID = 0;
|
|
}
|
|
|
|
mMANAGE_LIST.STORAGE_LIST_ID = mSTORAGE_LIST.STORAGE_LIST_ID;
|
|
|
|
mMANAGE_LIST.GOODS_ID = mSTORAGE_LIST.GOODS_ID;
|
|
|
|
bResult = this._S_GoodsService.GoodsPropertySetValue(mSTORAGE_LIST.GOODS_ID, mMANAGE_LIST, mSTORAGE_LIST, out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
return bResult;
|
|
}
|
|
mMANAGE_LIST.BOX_BARCODE = mSTORAGE_LIST.BOX_BARCODE;
|
|
|
|
mMANAGE_LIST.MANAGE_LIST_QUANTITY = mSTORAGE_LIST.STORAGE_LIST_QUANTITY;
|
|
|
|
mMANAGE_LIST.MANAGE_LIST_REMARK = mSTORAGE_LIST.STORAGE_LIST_REMARK;
|
|
|
|
this._P_MANAGE_LIST.Add(mMANAGE_LIST);
|
|
|
|
if ((null != mPLAN_LIST) && (mMANAGE_LIST.GOODS_ID == mPLAN_LIST.GOODS_ID))
|
|
{
|
|
mPLAN_LIST.PLAN_LIST_ORDERED_QUANTITY += mMANAGE_LIST.MANAGE_LIST_QUANTITY;
|
|
|
|
this._P_PLAN_LIST.Update(mPLAN_LIST);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (mWH_CELL_START != null)
|
|
{
|
|
bResult = this._S_CellService.CellUpdateStatus(START_CELL_ID, string.Empty, SiaSun.LMS.Enum.RUN_STATUS.Selected.ToString(), out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("更新开始货位{0}状态错误\n{1}", mWH_CELL_START.CELL_CODE, sResult);
|
|
|
|
this._P_Base_House.RollBackTransaction(bTrans);
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
if (mWH_CELL_END != null)
|
|
{
|
|
bResult = this._S_CellService.CellUpdateStatus(END_CELL_ID, string.Empty, SiaSun.LMS.Enum.RUN_STATUS.Selected.ToString(), out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("更新结束货位{0}状态错误\n{1}", mWH_CELL_END.CELL_CODE, sResult);
|
|
|
|
this._P_Base_House.RollBackTransaction(bTrans);
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
MANAGE_ID = mMANAGE_MAIN.MANAGE_ID;
|
|
|
|
if (bAutoSendControl)
|
|
{
|
|
bResult = this.ManageDownLoad(MANAGE_ID, string.Empty, false, out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
this._P_Base_House.RollBackTransaction(bTrans);
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
if (bComplete)
|
|
{
|
|
bResult = this.ManageComplete(MANAGE_ID, false, out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
this._P_Base_House.RollBackTransaction(bTrans);
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
sResult = string.Format("托盘{0}生成任务成功", mMANAGE_MAIN.STOCK_BARCODE);
|
|
|
|
this._P_Base_House.CommitTransaction(bTrans);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this._P_Base_House.RollBackTransaction(bTrans);
|
|
|
|
bResult = false;
|
|
|
|
sResult = ex.Message;
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
/// <summary>完成
|
|
/// 完成
|
|
/// </summary>
|
|
/// <param name="MANAGE_ID"></param>
|
|
/// <param name="bTrans">是否独立事务</param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public bool ManageComplete(int MANAGE_ID, bool bTrans, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID);
|
|
|
|
bResult = null != mMANAGE_MAIN;
|
|
|
|
if (!bResult)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("未能找到任务{0}", MANAGE_ID.ToString());
|
|
|
|
return bResult;
|
|
}
|
|
|
|
bResult = this.ManageComplete(mMANAGE_MAIN, bTrans, out sResult);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
|
|
/// <summary>完成
|
|
/// 完成
|
|
/// </summary>
|
|
/// <param name="MANAGE_ID"></param>
|
|
/// <param name="bTrans">是否独立事务</param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public bool ManageComplete(SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN, bool bTrans, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
try
|
|
{
|
|
this._P_Base_House.BeginTransaction(bTrans);
|
|
|
|
mMANAGE_MAIN.MANAGE_END_TIME = SiaSun.LMS.Common.StringUtil.GetDateTime();
|
|
|
|
this._P_MANAGE_MAIN.Update(mMANAGE_MAIN);
|
|
|
|
bResult = this._S_ManageService.RecordCreate(mMANAGE_MAIN.MANAGE_ID, "Complete", out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("生成出入库记录错误-{0}", sResult);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
SiaSun.LMS.Model.PLAN_MAIN mPLAN_MAIN = this._P_PLAN_MAIN.GetModel(mMANAGE_MAIN.PLAN_ID);
|
|
|
|
if (null == mPLAN_MAIN)
|
|
{
|
|
return bResult;
|
|
}
|
|
|
|
SiaSun.LMS.Model.PLAN_TYPE mPLAN_TYPE = this._P_PLAN_TYPE.GetModelPlanTypeCode(mPLAN_MAIN.PLAN_TYPE_CODE);
|
|
|
|
object[] outParams = new object[] { };
|
|
|
|
if (this._S_PlanService.Invoke(mPLAN_TYPE.PLAN_TYPE_CLASS, "PlanCheckComplete", new object[] { mMANAGE_MAIN.PLAN_ID }, out outParams))
|
|
{
|
|
bResult = this._S_PlanService.Invoke(mPLAN_TYPE.PLAN_TYPE_CLASS, "PlanComplete", new object[] { mMANAGE_MAIN.PLAN_ID, false }, out outParams);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("计划完成错误-{0}", sResult);
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = ex.Message;
|
|
}
|
|
finally
|
|
{
|
|
if (bResult)
|
|
{
|
|
//this._S_LEDService.ledMessageCreate(mMANAGE_MAIN, "");
|
|
|
|
this._P_Base_House.CommitTransaction(bTrans);
|
|
|
|
}
|
|
else
|
|
{
|
|
this._P_Base_House.RollBackTransaction(bTrans);
|
|
}
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
|
|
/// <summary>管理-异常
|
|
/// 管理-异常
|
|
/// </summary>
|
|
/// <param name="dt"></param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public bool ManageException(int MANAGE_ID, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID);
|
|
|
|
if (null == mMANAGE_MAIN)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("未能找到管理任务索引{0}", MANAGE_ID.ToString());
|
|
|
|
return bResult;
|
|
}
|
|
|
|
try
|
|
{
|
|
SiaSun.LMS.Model.WH_CELL mWH_CELL_START = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID);
|
|
|
|
SiaSun.LMS.Model.WH_CELL mWH_CELL_END = this._P_WH_CELL.GetModel(mMANAGE_MAIN.END_CELL_ID);
|
|
|
|
|
|
this._P_Base_House.BeginTransaction();
|
|
|
|
|
|
|
|
if (mWH_CELL_START != null && mWH_CELL_START.CELL_TYPE == Enum.CELL_TYPE.Cell.ToString())
|
|
{
|
|
bResult = this._S_CellService.CellUpdateStatus(mWH_CELL_START.CELL_ID, Enum.CELL_STATUS.Exception.ToString(), Enum.RUN_STATUS.Enable.ToString(), out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("更新起始位置{0} 状态错误\n", mWH_CELL_START.CELL_CODE.ToString());
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
if (mWH_CELL_END != null && mWH_CELL_END.CELL_TYPE == Enum.CELL_TYPE.Cell.ToString())
|
|
{
|
|
bResult = this._S_CellService.CellUpdateStatus(mWH_CELL_END.CELL_ID, Enum.CELL_STATUS.Exception.ToString(), Enum.RUN_STATUS.Enable.ToString(), out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("更新目标位置{0} 状态错误\n", mWH_CELL_START.CELL_CODE.ToString());
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
|
|
SiaSun.LMS.Model.IO_CONTROL mIO_CONTROL = this._P_IO_CONTROL.GetModelManageID(mMANAGE_MAIN.MANAGE_ID);
|
|
|
|
if (null == mIO_CONTROL)
|
|
{
|
|
sResult = string.Format("未能找到管理任务索引{0}的控制任务", MANAGE_ID.ToString());
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
mMANAGE_MAIN.MANAGE_REMARK = mIO_CONTROL.ERROR_TEXT;
|
|
|
|
//mMANAGE_MAIN.MANAGE_STATUS = Enum.MANAGE_STATUS.ExceptionComplete.ToString();
|
|
|
|
this._P_MANAGE_MAIN.Update(mMANAGE_MAIN);
|
|
|
|
this._P_IO_CONTROL.DeleteManageID(mMANAGE_MAIN.MANAGE_ID);
|
|
|
|
this._P_Base_House.CommitTransaction();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = ex.Message;
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 管理-故障
|
|
/// </summary>
|
|
/// <param name="dt"></param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public bool ManageError(int MANAGE_ID, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID);
|
|
|
|
if (null == mMANAGE_MAIN)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("未能找到管理任务索引{0}", MANAGE_ID.ToString());
|
|
|
|
return bResult;
|
|
}
|
|
|
|
try
|
|
{
|
|
this._P_Base_House.BeginTransaction();
|
|
|
|
|
|
SiaSun.LMS.Model.IO_CONTROL mIO_CONTROL = this._P_IO_CONTROL.GetModelManageID(mMANAGE_MAIN.MANAGE_ID);
|
|
|
|
if (null == mIO_CONTROL)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("未能找到管理任务索引{0}的控制任务", MANAGE_ID.ToString());
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
mMANAGE_MAIN.MANAGE_REMARK = mIO_CONTROL.ERROR_TEXT;
|
|
|
|
mMANAGE_MAIN.MANAGE_STATUS = Enum.MANAGE_STATUS.Error.ToString() ;
|
|
|
|
this._P_MANAGE_MAIN.Update(mMANAGE_MAIN);
|
|
|
|
this._P_Base_House.CommitTransaction();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = ex.Message;
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
/// <summary>管理-取消
|
|
/// 管理-取消
|
|
/// </summary>
|
|
/// <param name="MANAGE_ID"></param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public bool ManageCancel(int MANAGE_ID, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID);
|
|
|
|
if (null == mMANAGE_MAIN)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("未能找到管理任务索引{0}", MANAGE_ID.ToString());
|
|
|
|
return bResult;
|
|
}
|
|
|
|
bResult = this._S_ManageService.RecordCreate(mMANAGE_MAIN.MANAGE_ID, "Cancel", out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("生成出入库记录错误-{0}", sResult);
|
|
|
|
return bResult;
|
|
}
|
|
SiaSun.LMS.Model.IO_CONTROL mIO_CONTROL = this._P_IO_CONTROL.GetModelManageID(MANAGE_ID);
|
|
|
|
if (null != mIO_CONTROL && !mIO_CONTROL.CONTROL_STATUS.Equals(900))
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("存在控制任务{0},先处理控制任务", mIO_CONTROL.CONTROL_ID);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
try
|
|
{
|
|
this._P_Base_House.BeginTransaction();
|
|
|
|
bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.START_CELL_ID, string.Empty, SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(), out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("更新起始货位{0}状态错误\n{1}", mMANAGE_MAIN.START_CELL_ID.ToString(), sResult);
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.END_CELL_ID, string.Empty, SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(), out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("更新终止货位{0}状态错误\n{1}", mMANAGE_MAIN.END_CELL_ID.ToString(), sResult);
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
foreach (SiaSun.LMS.Model.MANAGE_LIST mMANAGE_LIST in this._P_MANAGE_LIST.GetListManageID(MANAGE_ID))
|
|
{
|
|
SiaSun.LMS.Model.PLAN_LIST mPLAN_LIST = this._P_PLAN_LIST.GetModel(mMANAGE_LIST.PLAN_LIST_ID);
|
|
|
|
if (null != mPLAN_LIST)
|
|
{
|
|
mPLAN_LIST.PLAN_LIST_ORDERED_QUANTITY -= mMANAGE_LIST.MANAGE_LIST_QUANTITY;
|
|
|
|
this._P_PLAN_LIST.Update(mPLAN_LIST);
|
|
|
|
}
|
|
}
|
|
|
|
this._P_IO_CONTROL.DeleteManageID(MANAGE_ID);
|
|
|
|
this._P_MANAGE_DETAIL.DeleteManageID(MANAGE_ID);
|
|
|
|
this._P_MANAGE_LIST.DeleteManageID(MANAGE_ID);
|
|
|
|
this._P_MANAGE_MAIN.Delete(MANAGE_ID);
|
|
|
|
if (bResult)
|
|
{
|
|
//this._S_LEDService.ledMessageCreate(mMANAGE_MAIN,"");
|
|
|
|
}
|
|
|
|
this._P_Base_House.CommitTransaction();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = ex.Message;
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
/// <summary>管理-执行
|
|
/// 管理-执行
|
|
/// </summary>
|
|
/// <param name="MANAGE_ID"></param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public bool ManageExecute(int MANAGE_ID, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID);
|
|
|
|
if (null == mMANAGE_MAIN)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("未能找到管理任务索引{0}", MANAGE_ID.ToString());
|
|
|
|
return bResult;
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
this._P_Base_House.BeginTransaction();
|
|
|
|
mMANAGE_MAIN.MANAGE_REMARK = string.Empty;
|
|
|
|
mMANAGE_MAIN.MANAGE_STATUS = Enum.MANAGE_STATUS.Executing.ToString();
|
|
|
|
this._P_MANAGE_MAIN.Update(mMANAGE_MAIN);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("任务状态更新错误\n{0}", sResult);
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
this._P_Base_House.CommitTransaction();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = ex.Message;
|
|
|
|
this._P_Base_House.RollBackTransaction();
|
|
}
|
|
finally
|
|
{
|
|
if (bResult)
|
|
{
|
|
//this._S_LEDService.ledMessageCreate(mMANAGE_MAIN, "Executing");
|
|
|
|
}
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
|
|
/// <summary>管理-执行
|
|
/// 管理-执行
|
|
/// </summary>
|
|
/// <param name="MANAGE_ID"></param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public bool ManageWaitConfirm(int MANAGE_ID, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
return bResult;
|
|
}
|
|
|
|
/// <summary>管理-执行
|
|
/// 管理-执行
|
|
/// </summary>
|
|
/// <param name="MANAGE_ID"></param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public bool ManageConfirm(int MANAGE_ID, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
|
|
return bResult;
|
|
}
|
|
|
|
|
|
/// <summary>管理-下达 控制是否独立事务
|
|
/// 管理-下达 控制是否独立事务
|
|
/// </summary>
|
|
/// <param name="MANAGE_ID"></param>
|
|
/// <param name="bTrans"></param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public bool ManageDownLoad(int MANAGE_ID,string START_CELL_CODE, bool bTrans, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
int END_CELL_ID =0;
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID);
|
|
IList<MANAGE_LIST> lsMANAGE_LIST = this._P_MANAGE_LIST.GetListManageID(mMANAGE_MAIN.MANAGE_ID);
|
|
|
|
if (null == mMANAGE_MAIN)
|
|
{
|
|
bResult = false;
|
|
sResult = string.Format("未能找到任务{0}", MANAGE_ID.ToString());
|
|
return bResult;
|
|
}
|
|
|
|
SiaSun.LMS.Model.WH_CELL mSTART_CELL = null;
|
|
|
|
if (START_CELL_CODE == string.Empty)
|
|
{
|
|
mSTART_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID);
|
|
|
|
if (null == mSTART_CELL)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("未能找到起始位置{0}", mSTART_CELL.CELL_CODE);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
mSTART_CELL = this._P_WH_CELL.GetModel(START_CELL_CODE);
|
|
|
|
if (null == mSTART_CELL)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("未能找到起始位置{0}", mSTART_CELL.CELL_CODE);
|
|
|
|
return bResult;
|
|
}
|
|
else
|
|
{
|
|
mMANAGE_MAIN.START_CELL_ID = mSTART_CELL.CELL_ID;
|
|
|
|
//this._P_MANAGE_MAIN.Update(mMANAGE_MAIN);
|
|
|
|
bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.START_CELL_ID, string.Empty, SiaSun.LMS.Enum.RUN_STATUS.Selected.ToString(), out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("更新开始货位{0}状态错误\n{1}", mSTART_CELL.CELL_CODE, sResult);
|
|
|
|
this._P_Base_House.RollBackTransaction(bTrans);
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
}
|
|
|
|
lock (lockObj)
|
|
{
|
|
if (mMANAGE_MAIN.END_CELL_ID.Equals(0))
|
|
{
|
|
if (string.IsNullOrWhiteSpace(mMANAGE_MAIN.CELL_MODEL))
|
|
{
|
|
//GOODS_MAIN gm = _P_GOODS_MAIN.GetModel(lsMANAGE_LIST[0].GOODS_ID);
|
|
//if (gm != null)
|
|
//{
|
|
// if (gm.GOODS_CODE == "10100002")
|
|
// {
|
|
// mMANAGE_MAIN.CELL_MODEL = "height";
|
|
// }
|
|
// else
|
|
// {
|
|
// mMANAGE_MAIN.CELL_MODEL = "low";
|
|
// }
|
|
//}
|
|
if (mSTART_CELL.CELL_CODE == "21006" ||
|
|
mSTART_CELL.CELL_CODE == "22003")
|
|
{
|
|
mMANAGE_MAIN.CELL_MODEL = "low";
|
|
}
|
|
else
|
|
{
|
|
mMANAGE_MAIN.CELL_MODEL = "height";
|
|
}
|
|
}
|
|
//出库任务
|
|
if (mSTART_CELL.CELL_TYPE == Enum.CELL_TYPE.Cell.ToString())
|
|
{
|
|
bResult = this._S_CellService.CellOutAllocate(mSTART_CELL.CELL_CODE,
|
|
out END_CELL_ID,
|
|
out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("未找到出库站台\n {0}", sResult);
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
//入库任务
|
|
else
|
|
{
|
|
if (lsMANAGE_LIST[0].GOODS_ID == 32782 ||
|
|
lsMANAGE_LIST[0].GOODS_ID == 32789)
|
|
{
|
|
bResult = this._S_CellService.CellInAllocate(mSTART_CELL.DEVICE_CODE,
|
|
mMANAGE_MAIN.CELL_MODEL,
|
|
mMANAGE_MAIN.MANAGE_ID,
|
|
false,
|
|
out END_CELL_ID,
|
|
out sResult);
|
|
if (!bResult && !string.IsNullOrWhiteSpace(sResult) && sResult.Contains("小料库货位不足"))
|
|
{
|
|
sResult = string.Empty;
|
|
bResult = this._S_CellService.CellInAllocate(mSTART_CELL.DEVICE_CODE,
|
|
mMANAGE_MAIN.CELL_MODEL,
|
|
mMANAGE_MAIN.MANAGE_ID,
|
|
true,
|
|
out END_CELL_ID,
|
|
out sResult);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//if (lsMANAGE_LIST[0].GOODS_ID == 32779 && mMANAGE_MAIN.CELL_MODEL == "low")
|
|
//{
|
|
// bResult = this._S_CellService.CellInAllocate(mSTART_CELL.DEVICE_CODE,
|
|
// "height",
|
|
// mMANAGE_MAIN.MANAGE_ID,
|
|
// false,
|
|
// out END_CELL_ID,
|
|
// out sResult);
|
|
// if (!bResult)
|
|
// {
|
|
// bResult = this._S_CellService.CellInAllocate(mSTART_CELL.DEVICE_CODE,
|
|
// mMANAGE_MAIN.CELL_MODEL,
|
|
// mMANAGE_MAIN.MANAGE_ID,
|
|
// false,
|
|
// out END_CELL_ID,
|
|
// out sResult);
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
if (mSTART_CELL.DEVICE_CODE == "38001")
|
|
{
|
|
mMANAGE_MAIN.CELL_MODEL = "height";
|
|
}
|
|
bResult = this._S_CellService.CellInAllocate(mSTART_CELL.DEVICE_CODE,
|
|
mMANAGE_MAIN.CELL_MODEL,
|
|
mMANAGE_MAIN.MANAGE_ID,
|
|
false,
|
|
out END_CELL_ID,
|
|
out sResult);
|
|
if (!bResult && mMANAGE_MAIN.CELL_MODEL == "low")
|
|
{
|
|
mMANAGE_MAIN.CELL_MODEL = "height";
|
|
bResult = this._S_CellService.CellInAllocate(mSTART_CELL.DEVICE_CODE,
|
|
mMANAGE_MAIN.CELL_MODEL,
|
|
mMANAGE_MAIN.MANAGE_ID,
|
|
false,
|
|
out END_CELL_ID,
|
|
out sResult);
|
|
}
|
|
//}
|
|
}
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("分配货位失败\n {0}", sResult);
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
mMANAGE_MAIN.START_CELL_ID = mSTART_CELL.CELL_ID;
|
|
|
|
mMANAGE_MAIN.END_CELL_ID = END_CELL_ID;
|
|
|
|
SiaSun.LMS.Model.WH_CELL mWH_CELL_END = null;
|
|
|
|
mWH_CELL_END = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
|
|
if (mWH_CELL_END != null)
|
|
{
|
|
bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.END_CELL_ID, string.Empty, SiaSun.LMS.Enum.RUN_STATUS.Selected.ToString(), out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("更新结束货位{0}状态错误\n{1}", mWH_CELL_END.CELL_CODE, sResult);
|
|
|
|
this._P_Base_House.RollBackTransaction(bTrans);
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
SiaSun.LMS.Model.WH_CELL mEND_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.END_CELL_ID);
|
|
|
|
if (null == mEND_CELL)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("未能找到终止位置{0}", mEND_CELL.CELL_CODE);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
//路径校验
|
|
bResult = this._P_IO_CONTROL_ROUTE.GetList(mSTART_CELL.DEVICE_CODE, mEND_CELL.DEVICE_CODE).Count > 0;
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("{0}-{1}之间无可用路径,请在监控系统中查看设备状态!", mSTART_CELL.CELL_CODE, mEND_CELL.CELL_CODE);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
if (mSTART_CELL.CELL_TYPE == Enum.CELL_TYPE.Cell.ToString() &&
|
|
mSTART_CELL.CELL_FORK_TYPE == "Far")
|
|
{
|
|
WH_CELL wc = this._P_WH_CELL.GetModel(mSTART_CELL.LOCK_DEVICE_CODE);
|
|
if (wc != null && wc.CELL_CODE != mSTART_CELL.CELL_CODE &&
|
|
!((wc.CELL_STATUS == Enum.CELL_STATUS.Nohave.ToString() &&
|
|
wc.RUN_STATUS != Enum.RUN_STATUS.Selected.ToString()) ||
|
|
(wc.CELL_STATUS != Enum.CELL_STATUS.Nohave.ToString() &&
|
|
wc.RUN_STATUS == Enum.RUN_STATUS.Selected.ToString())))
|
|
{
|
|
bResult = false;
|
|
sResult = "起始位置近叉有库存";
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
if (mEND_CELL.CELL_TYPE == Enum.CELL_TYPE.Cell.ToString())
|
|
{
|
|
if (mEND_CELL.CELL_FORK_TYPE == "Near")
|
|
{
|
|
WH_CELL wc = this._P_WH_CELL.GetModel(mEND_CELL.LOCK_DEVICE_CODE);
|
|
if (wc != null && wc.CELL_CODE != mEND_CELL.CELL_CODE &&
|
|
wc.RUN_STATUS == Enum.RUN_STATUS.Selected.ToString())
|
|
{
|
|
bResult = false;
|
|
sResult = "目标位置远叉有任务";
|
|
return bResult;
|
|
}
|
|
}
|
|
else if (mEND_CELL.CELL_FORK_TYPE == "Far")
|
|
{
|
|
WH_CELL wc = this._P_WH_CELL.GetModel(mEND_CELL.LOCK_DEVICE_CODE);
|
|
if (wc != null && wc.CELL_CODE != mEND_CELL.CELL_CODE &&
|
|
(wc.RUN_STATUS == Enum.RUN_STATUS.Selected.ToString() ||
|
|
wc.CELL_STATUS != Enum.CELL_STATUS.Nohave.ToString()))
|
|
{
|
|
bResult = false;
|
|
sResult = "目标位置近叉有库存";
|
|
return bResult;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (mEND_CELL.DEVICE_CODE == "11026" ||
|
|
mEND_CELL.DEVICE_CODE == "11019" ||
|
|
mEND_CELL.DEVICE_CODE == "38001")
|
|
{
|
|
if (mEND_CELL.DEVICE_CODE == "11026" ||
|
|
mEND_CELL.DEVICE_CODE == "11019")
|
|
{
|
|
DataTable dtManageMain = this.GetList(string.Format("select * from MANAGE_MAIN where END_CELL_ID='{0}'", mEND_CELL.CELL_ID));
|
|
if (dtManageMain.Rows.Count > 1)
|
|
{
|
|
bResult = false;
|
|
sResult = string.Format("{0} 已存在出库任务", mEND_CELL.CELL_CODE);
|
|
return bResult;
|
|
}
|
|
}
|
|
if (lsMANAGE_LIST != null && lsMANAGE_LIST.Count > 0)
|
|
{
|
|
GOODS_MAIN gm = this._P_GOODS_MAIN.GetModel(lsMANAGE_LIST[0].GOODS_ID);
|
|
if (mEND_CELL.DEVICE_CODE == "11026" ||
|
|
mEND_CELL.DEVICE_CODE == "11019")
|
|
{
|
|
if (gm != null && gm.GOODS_CODE != "GTP")
|
|
{
|
|
bResult = false;
|
|
sResult = string.Format("{0} 只能出母托盘垛", mEND_CELL.CELL_CODE);
|
|
return bResult;
|
|
}
|
|
}
|
|
else if (mEND_CELL.DEVICE_CODE == "38001")
|
|
{
|
|
if (gm != null && !mEND_CELL.SHELF_TYPE.Contains(gm.GOODS_CODE + "|"))
|
|
{
|
|
bResult = false;
|
|
sResult = string.Format("{0} 只能出库指定物料(铁、糖、锂)", mEND_CELL.CELL_CODE);
|
|
return bResult;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
try
|
|
{
|
|
|
|
this._P_Base_House.BeginTransaction(bTrans);
|
|
|
|
SiaSun.LMS.Model.IO_CONTROL mIO_CONTROL = this._P_IO_CONTROL.GetModelManageID(MANAGE_ID);
|
|
|
|
bResult = null == mIO_CONTROL;
|
|
|
|
if (!bResult)
|
|
{
|
|
sResult = string.Format("{0}控制任务已经存在! ", mMANAGE_MAIN.STOCK_BARCODE.ToString());
|
|
|
|
return bResult;
|
|
}
|
|
|
|
int CONTROL_TASK_TYPE = 0;
|
|
|
|
mIO_CONTROL = new SiaSun.LMS.Model.IO_CONTROL();
|
|
|
|
string IN_OUT_TYPE = string.Format("{0}-{1}", mSTART_CELL.CELL_TYPE, mEND_CELL.CELL_TYPE).ToLower();
|
|
|
|
switch (IN_OUT_TYPE)
|
|
{
|
|
case "station-cell"://站台-货位-入
|
|
|
|
CONTROL_TASK_TYPE = Convert.ToInt32(SiaSun.LMS.Enum.CONTROL_TYPE.Up.ToString("d"));
|
|
|
|
break;
|
|
|
|
case "cell-station"://货位-站台-出
|
|
|
|
CONTROL_TASK_TYPE = Convert.ToInt32(SiaSun.LMS.Enum.CONTROL_TYPE.Down.ToString("d"));
|
|
|
|
break;
|
|
|
|
case "cell-cell"://货位-货位-移
|
|
|
|
CONTROL_TASK_TYPE = Convert.ToInt32(SiaSun.LMS.Enum.CONTROL_TYPE.Move.ToString("d"));
|
|
break;
|
|
|
|
case "station-station"://站台-站台-移
|
|
|
|
CONTROL_TASK_TYPE = Convert.ToInt32(SiaSun.LMS.Enum.CONTROL_TYPE.MoveStation.ToString("d"));
|
|
|
|
break;
|
|
}
|
|
|
|
mIO_CONTROL.RELATIVE_CONTROL_ID = -1;
|
|
mIO_CONTROL.MANAGE_ID = mMANAGE_MAIN.MANAGE_ID;
|
|
mIO_CONTROL.STOCK_BARCODE = mMANAGE_MAIN.STOCK_BARCODE;
|
|
//mIO_CONTROL.CELL_GROUP = mEND_CELL.CELL_GROUP;
|
|
mIO_CONTROL.CONTROL_TASK_LEVEL = string.IsNullOrEmpty(mMANAGE_MAIN.MANAGE_LEVEL) ? "0" : mMANAGE_MAIN.MANAGE_LEVEL;
|
|
if (mSTART_CELL.CELL_CODE == "13012" ||
|
|
mSTART_CELL.CELL_CODE == "13016" ||
|
|
mSTART_CELL.CELL_CODE.StartsWith("140"))
|
|
{
|
|
mIO_CONTROL.CONTROL_TASK_LEVEL = "9";
|
|
}
|
|
mIO_CONTROL.PRE_CONTROL_STATUS = string.Empty;
|
|
mIO_CONTROL.CONTROL_TASK_TYPE = CONTROL_TASK_TYPE;
|
|
mIO_CONTROL.START_DEVICE_CODE = mSTART_CELL.CELL_CODE;
|
|
mIO_CONTROL.END_DEVICE_CODE = mEND_CELL.CELL_CODE;
|
|
if (mEND_CELL.CELL_CODE == "11019")
|
|
{
|
|
mIO_CONTROL.CONTROL_TASK_LEVEL = "9";
|
|
}
|
|
mIO_CONTROL.CONTROL_BEGIN_TIME = SiaSun.LMS.Common.StringUtil.GetDateTime();
|
|
|
|
//单叉状态25 双叉状态0 string.IsNullOrEmpty(mMANAGE_MAIN.MANAGE_FORK) || !mMANAGE_MAIN.MANAGE_FORK.Equals("1") ? 0 : 25;
|
|
mIO_CONTROL.CONTROL_STATUS = 0;
|
|
//mIO_CONTROL.CONTROL_REMARK = mMANAGE_MAIN.MANAGE_REMARK;
|
|
foreach (Model.MANAGE_LIST mMANAGE_LIST in lsMANAGE_LIST)
|
|
{
|
|
mIO_CONTROL.CONTROL_REMARK = mMANAGE_MAIN.MANAGE_TYPE_CODE.Equals("StockOut") ? Convert.ToString(mMANAGE_LIST.MANAGE_LIST_QUANTITY) : mMANAGE_MAIN.MANAGE_REMARK;
|
|
}
|
|
mIO_CONTROL.START_WAREHOUSE_CODE = "1";
|
|
mIO_CONTROL.END_WAREHOUSE_CODE = "1";
|
|
|
|
this._P_IO_CONTROL.Add(mIO_CONTROL);
|
|
|
|
mMANAGE_MAIN.MANAGE_STATUS = SiaSun.LMS.Enum.MANAGE_STATUS.WaitingExecute.ToString();
|
|
|
|
this._P_MANAGE_MAIN.Update(mMANAGE_MAIN);
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = ex.Message;
|
|
}
|
|
finally
|
|
{
|
|
if (bResult)
|
|
{
|
|
this._P_Base_House.CommitTransaction(bTrans);
|
|
}
|
|
else
|
|
{
|
|
this._P_Base_House.RollBackTransaction(bTrans);
|
|
}
|
|
}
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
public bool RepeatCellInAllocate(string START_DEVICE_CODE, string CELL_MODEL, int MANAGE_ID, int end_cell_id, out int END_CELL_ID, out string sResult)
|
|
{
|
|
sResult = string.Empty;
|
|
bool bResult = true;
|
|
int DEVICE_CODE = 0;
|
|
int index = 0;
|
|
int index_n = 0;
|
|
string ordered = string.Empty;
|
|
string strLaneway = string.Empty;
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID);
|
|
//Model.MANAGE_LIST mMANAGE_LIST = this._P_MANAGE_LIST.GetModelByManageId(MANAGE_ID);
|
|
|
|
//设备状态可用并且有可用货位的巷道
|
|
strLaneway = string.Format(@"SELECT DEVICE_CODE
|
|
FROM (SELECT DISTINCT DEVICE_CODE AS DEVICE_CODE
|
|
FROM WH_CELL
|
|
INNER JOIN IO_CONTROL_ROUTE ON DEVICE_CODE =
|
|
IO_CONTROL_ROUTE.END_DEVICE
|
|
WHERE CELL_TYPE = 'Cell'
|
|
AND START_DEVICE = {0}
|
|
AND CONTROL_ROUTE_TYPE = 1
|
|
AND CONTROL_ROUTE_STATUS = 1
|
|
AND RUN_STATUS ='Enable'
|
|
) T ORDER BY DEVICE_CODE", START_DEVICE_CODE);
|
|
|
|
//获得所有可用巷道
|
|
DataTable dt_laneway = this.GetList(strLaneway);
|
|
|
|
if (dt_laneway.Rows.Count == 0)
|
|
{
|
|
sResult = string.Format("入库未找到可用路径,请检查设备状态");
|
|
END_CELL_ID = 0;
|
|
return false;
|
|
}
|
|
|
|
if (dt_laneway.Rows.Count == 1)
|
|
{
|
|
//可用单深巷道的空货位数
|
|
DataTable dt_cellcount = this.GetList(string.Format(@"SELECT CELL_ID
|
|
FROM WH_CELL
|
|
WHERE DEVICE_CODE = {0}
|
|
AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS = 'Enable'
|
|
AND CELL_TYPE ='Cell'", Convert.ToInt32(dt_laneway.Rows[0]["DEVICE_CODE"])));
|
|
|
|
|
|
if (dt_laneway.Rows[0]["DEVICE_CODE"].ToString() != "18002")//双深巷道
|
|
{
|
|
DataTable dt_cellnear = this.GetList(string.Format(@"SELECT CELL_ID
|
|
FROM WH_CELL
|
|
WHERE DEVICE_CODE = {0}
|
|
AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS = 'Enable'
|
|
AND CELL_FORK_TYPE = 'Near'
|
|
AND CELL_TYPE ='Cell'", Convert.ToInt32(dt_laneway.Rows[0]["DEVICE_CODE"])));
|
|
|
|
DEVICE_CODE = Convert.ToInt32(dt_laneway.Rows[0]["DEVICE_CODE"]);
|
|
|
|
if (dt_cellnear.Rows.Count == 2)
|
|
{
|
|
bResult = false;
|
|
sResult = "当前双申巷道近端空货位货位不足,请查看!";
|
|
END_CELL_ID = 0;
|
|
return bResult;
|
|
}
|
|
}
|
|
else if (dt_laneway.Rows[0]["DEVICE_CODE"].ToString() == "18002" && dt_cellcount.Rows.Count == 1)//单深巷道
|
|
{
|
|
bResult = false;
|
|
sResult = "当前2巷道只有1个空货位,请查看!";
|
|
END_CELL_ID = 0;
|
|
return bResult;
|
|
}
|
|
else
|
|
{
|
|
DEVICE_CODE = Convert.ToInt32(dt_laneway.Rows[0]["DEVICE_CODE"]);
|
|
}
|
|
}
|
|
|
|
#region 货物平均分配 可用巷道>=2时
|
|
if (dt_laneway.Rows.Count >= 2)
|
|
{
|
|
//获得库存少的巷道
|
|
IList<MANAGE_LIST> lsMANAGE_LIST = this._P_MANAGE_LIST.GetListManageID(mMANAGE_MAIN.MANAGE_ID);
|
|
DataTable dt_storage = null;
|
|
DataTable dt_manage_num = null;
|
|
DataTable lane_way = null;
|
|
int manage_num = Convert.ToInt32(SiaSun.LMS.Common.StringUtil.GetConfig("ManageCountLimit").ToString());
|
|
int[] su = new int[dt_laneway.Rows.Count];
|
|
int[] sm = new int[dt_laneway.Rows.Count];
|
|
for (int i = 0; i < dt_laneway.Rows.Count; i++)
|
|
{
|
|
dt_storage = this.GetList(string.Format(@"SELECT CELL_ID FROM WH_CELL
|
|
WHERE CELL_TYPE ='Cell'
|
|
AND CELL_STATUS in ('Full','Pallet', 'Bullet', 'Forbiden')
|
|
AND RUN_STATUS IN ('Enable','Disable') AND DEVICE_CODE = '{0}'
|
|
OR (CELL_STATUS = 'Nohave' and RUN_STATUS in ('Selected','Disable')
|
|
and DEVICE_CODE = '{0}')",
|
|
Convert.ToInt32(dt_laneway.Rows[i]["DEVICE_CODE"])));
|
|
|
|
lane_way = this.GetList(string.Format(@"SELECT TOP 1 * FROM WH_CELL
|
|
WHERE device_code = {0}
|
|
AND CELL_TYPE ='Cell'", Convert.ToInt32(dt_laneway.Rows[i]["DEVICE_CODE"])));
|
|
|
|
dt_manage_num = this.GetList(string.Format(@"SELECT * FROM V_MANAGE WHERE LANE_WAY = {0}
|
|
AND (MANAGE_STATUS = 'Executing' or MANAGE_STATUS = 'WaitingExecute') AND
|
|
MANAGE_TYPE_CLASS in ('ManageIn','StockInMin','StockIn','ManageUp')", lane_way.Rows[0]["LANE_WAY"]));
|
|
|
|
su[i] = dt_storage.Rows.Count;//记货位数
|
|
sm[i] = dt_manage_num.Rows.Count;//记任务数
|
|
}
|
|
|
|
index = SiaSun.LMS.Common.StringUtil.CheckMin(su);
|
|
index_n = SiaSun.LMS.Common.StringUtil.CheckMin(sm);
|
|
|
|
if (sm[index] > manage_num)
|
|
{
|
|
DEVICE_CODE = Convert.ToInt32(dt_laneway.Rows[index_n]["DEVICE_CODE"]);
|
|
}
|
|
else
|
|
{
|
|
DEVICE_CODE = Convert.ToInt32(dt_laneway.Rows[index]["DEVICE_CODE"]);
|
|
}
|
|
|
|
//优先入库巷道的空货位数
|
|
DataTable dt_cellcount = this.GetList(string.Format(@"SELECT CELL_ID
|
|
FROM WH_CELL
|
|
WHERE device_code = {0}
|
|
AND cell_status = 'Nohave'
|
|
AND run_status = 'Enable'
|
|
AND CELL_TYPE ='Cell'", DEVICE_CODE));
|
|
|
|
|
|
|
|
if (DEVICE_CODE == 18002 && dt_cellcount.Rows.Count == 1)
|
|
{
|
|
bResult = false;
|
|
sResult = "当前2巷道只有1个空货位,请查看!";
|
|
END_CELL_ID = 0;
|
|
return bResult;
|
|
}
|
|
if (DEVICE_CODE != 18002)
|
|
{
|
|
DataTable dt_cellnear = this.GetList(string.Format(@"SELECT CELL_ID
|
|
FROM WH_CELL
|
|
WHERE DEVICE_CODE = {0}
|
|
AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS = 'Enable'
|
|
AND CELL_FORK_TYPE = 'Near'
|
|
AND CELL_TYPE ='Cell'", Convert.ToInt32(dt_laneway.Rows[0]["DEVICE_CODE"])));
|
|
if (dt_cellnear.Rows.Count == 2)
|
|
{
|
|
bResult = false;
|
|
sResult = "当前双申巷道近端空货位货位不足,请查看!";
|
|
END_CELL_ID = 0;
|
|
return bResult;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
string strSQL = string.Empty;
|
|
DataTable dtCELL = null;
|
|
#region//母托盘入库
|
|
if (mMANAGE_MAIN.MANAGE_TYPE_CODE == "StockIn")
|
|
{
|
|
if (DEVICE_CODE != 18002)
|
|
{
|
|
///条件1:
|
|
///Double有货无任务,且Double物料与上架物料一致时,选择Normal空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS = 'Enable'
|
|
AND CELL_STATUS = 'Pallet' AND RUN_STATUS_NEAR = 'Enable' AND DEVICE_CODE = {0}
|
|
AND CELL_STATUS_NEAR ='Nohave' ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_NEAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
|
|
///条件2:
|
|
///Double无货有任务,且Double任务物料与上架物料一致时,选择Normal空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS = 'Selected' AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS_NEAR = 'Enable' AND CELL_STATUS_NEAR ='Nohave' AND DEVICE_CODE = {0}
|
|
AND CELL_ID_FAR IN (SELECT END_CELL_ID FROM MANAGE_MAIN WHERE MANAGE_TYPE_CODE
|
|
in ('StockIn')) ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_NEAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
|
|
///条件3:
|
|
///Double无任务,货位状态可为/空容器/禁用等运行状态为可用/禁用,选择Normal空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS IN ('Disable')
|
|
AND CELL_STATUS IN ('Pallet','Nohave') AND RUN_STATUS_NEAR = 'Enable' AND DEVICE_CODE = {0}
|
|
AND CELL_STATUS_NEAR ='Nohave' ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_NEAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
|
|
///条件4:
|
|
///Double和Normal全部空货位,选择Double空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS = 'Enable' AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS_NEAR = 'Enable' AND CELL_STATUS_NEAR ='Nohave' AND DEVICE_CODE = {0}
|
|
ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
bResult = false;
|
|
sResult = "当前双申巷道空货位货位不足,请查看!";
|
|
END_CELL_ID = 0;
|
|
return bResult;
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_FAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ordered = "ASC";
|
|
//获得货位
|
|
strSQL = string.Format(@"SELECT CELL_ID, CELL_CODE, CELL_GROUP
|
|
FROM WH_CELL
|
|
WHERE DEVICE_CODE = {0}
|
|
AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS = 'Enable'
|
|
AND CELL_TYPE ='Cell'
|
|
ORDER BY cell_y {1}, cell_x,cell_z", DEVICE_CODE, ordered);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region//子托盘入库
|
|
else if (mMANAGE_MAIN.MANAGE_TYPE_CODE == "StockInMin")
|
|
{
|
|
//分配的巷道为2巷道时双申巷道
|
|
if (DEVICE_CODE != 18002)
|
|
{
|
|
///条件1:
|
|
///Double有货无任务,且Double物料与上架物料一致时,选择Normal空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS = 'Enable'
|
|
AND CELL_STATUS = 'Bullet' AND RUN_STATUS_NEAR = 'Enable' AND DEVICE_CODE = {0}
|
|
AND CELL_STATUS_NEAR ='Nohave' ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_NEAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
|
|
///条件2:
|
|
///Double无货有任务,且Double任务物料与上架物料一致时,选择Normal空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS = 'Selected' AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS_NEAR = 'Enable' AND CELL_STATUS_NEAR ='Nohave' AND DEVICE_CODE = {0}
|
|
AND CELL_ID_FAR IN (SELECT END_CELL_ID FROM MANAGE_MAIN WHERE MANAGE_TYPE_CODE
|
|
in ('StockInMin')) ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_NEAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
|
|
///条件3:
|
|
///Double无任务,货位状态可为/子托盘/禁用等运行状态为可用/禁用,选择Normal空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS IN ('Disable')
|
|
AND CELL_STATUS IN ('Bullet','Nohave') AND RUN_STATUS_NEAR = 'Enable' AND DEVICE_CODE = {0}
|
|
AND CELL_STATUS_NEAR ='Nohave' ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_NEAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
|
|
///条件4:
|
|
///Double和Normal全部空货位,选择Double空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS = 'Enable' AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS_NEAR = 'Enable' AND CELL_STATUS_NEAR ='Nohave' AND DEVICE_CODE = {0}
|
|
ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_FAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ordered = "ASC";
|
|
//获得货位
|
|
strSQL = string.Format(@"SELECT CELL_ID, CELL_CODE, CELL_GROUP
|
|
FROM WH_CELL
|
|
WHERE DEVICE_CODE = {0}
|
|
AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS = 'Enable'
|
|
AND CELL_TYPE ='Cell'
|
|
ORDER BY cell_y {1}, cell_x,cell_z", DEVICE_CODE, ordered);
|
|
}
|
|
}
|
|
#endregion
|
|
#region//货物入库
|
|
else
|
|
{
|
|
//分配的巷道为2巷道时双申巷道
|
|
if (DEVICE_CODE != 18002)
|
|
{
|
|
///条件1:
|
|
///Double有货无任务,且Double物料与上架物料一致时,选择Normal空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS = 'Enable'
|
|
AND CELL_STATUS = 'Full' AND RUN_STATUS_NEAR = 'Enable' and device_code = '{0}'
|
|
AND CELL_STATUS_NEAR ='Nohave' ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_NEAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
|
|
///条件2:
|
|
///Double无货有任务,且Double任务物料与上架物料一致时,选择Normal空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS = 'Selected' AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS_NEAR = 'Enable' AND CELL_STATUS_NEAR ='Nohave' and device_code = '{0}'
|
|
AND CELL_ID_FAR IN (SELECT END_CELL_ID FROM MANAGE_MAIN WHERE MANAGE_TYPE_CODE
|
|
in ('ManageInlocal','ManageUp')) ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_NEAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
|
|
///条件3:
|
|
///Double无任务,货位状态可为/有货/禁用等运行状态为可用/禁用,选择Normal空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS IN ('Disable')
|
|
and device_code = '{0}' and CELL_STATUS IN ('Full','Nohave') AND RUN_STATUS_NEAR = 'Enable'
|
|
AND CELL_STATUS_NEAR ='Nohave' ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_NEAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
|
|
///条件4:
|
|
///Double和Normal全部空货位,选择Double空货位
|
|
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE RUN_STATUS = 'Enable' AND CELL_STATUS = 'Nohave'
|
|
and device_code = '{0}' AND RUN_STATUS_NEAR = 'Enable' AND CELL_STATUS_NEAR ='Nohave'
|
|
ORDER BY CELL_Y,CELL_X", DEVICE_CODE);
|
|
|
|
dtCELL = this.GetList(strSQL);
|
|
if (dtCELL.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dtCELL.Rows[0]["CELL_ID_FAR"].ToString());
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ordered = "ASC";
|
|
//获得货位
|
|
strSQL = string.Format(@"SELECT CELL_ID, CELL_CODE, CELL_GROUP
|
|
FROM WH_CELL
|
|
WHERE DEVICE_CODE = {0}
|
|
AND CELL_STATUS = 'Nohave'
|
|
AND RUN_STATUS = 'Enable'
|
|
AND CELL_TYPE ='Cell'
|
|
ORDER BY cell_y {1}, cell_x,cell_z", DEVICE_CODE, ordered);
|
|
}
|
|
}
|
|
#endregion
|
|
DataTable dt = this.GetList(strSQL);
|
|
|
|
bResult = dt.Rows.Count > 0;
|
|
|
|
if (bResult)
|
|
{
|
|
END_CELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID"]);
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
Model.WH_CELL nEND_WH_CELL = this._P_WH_CELL.GetModel(end_cell_id);
|
|
nEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Enable.ToString();
|
|
mEND_WH_CELL.RUN_STATUS = Enum.RUN_STATUS.Selected.ToString();
|
|
this._P_WH_CELL.Update(mEND_WH_CELL);
|
|
this._P_WH_CELL.Update(nEND_WH_CELL);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
sResult = string.Format("未找到入库货位");
|
|
END_CELL_ID = 0;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|