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.
931 lines
29 KiB
931 lines
29 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using System;
|
|
using System;
|
|
|
|
|
|
namespace SiaSun.LMS.Implement
|
|
{
|
|
public class ManageBase:S_BaseService
|
|
{
|
|
|
|
/// <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;
|
|
}
|
|
|
|
mMANAGE_MAIN.MANAGE_OPERATOR = mSYS_USER.USER_NAME;
|
|
|
|
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, 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;
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
}
|
|
|
|
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);
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
if (mMANAGE_MAIN.END_CELL_ID.Equals(0))
|
|
{
|
|
bResult = this._S_CellService.CellInAllocate(mSTART_CELL.CELL_CODE,
|
|
mMANAGE_MAIN.CELL_MODEL,
|
|
mMANAGE_MAIN.MANAGE_ID,
|
|
1,
|
|
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 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;
|
|
}
|
|
|
|
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}已经存在!", MANAGE_ID.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;
|
|
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;
|
|
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;
|
|
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;
|
|
}
|
|
|
|
}
|
|
}
|