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.
485 lines
16 KiB
485 lines
16 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Reflection;
|
|
|
|
namespace SiaSun.LMS.Implement
|
|
{
|
|
public class ManageMove:ManageBase
|
|
{
|
|
/// <summary>
|
|
/// 生成【巷道内倒库】任务
|
|
/// </summary>
|
|
/// <param name="STOCK_BARCODE"></param>
|
|
/// <param name="END_CELL_ID"></param>
|
|
/// <param name="bAutoSendControl"></param>
|
|
/// <param name="bTrans"></param>
|
|
/// <param name="Opertator"></param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public bool ManageCreate(string STOCK_BARCODE,
|
|
int END_CELL_ID,
|
|
bool bAutoSendControl,
|
|
bool bTrans,
|
|
string Opertator,
|
|
out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = null;
|
|
|
|
SiaSun.LMS.Model.MANAGE_LIST mMANAGE_LIST = null;
|
|
|
|
List<SiaSun.LMS.Model.MANAGE_LIST> lsMANAGE_LIST = new List<SiaSun.LMS.Model.MANAGE_LIST>();
|
|
SiaSun.LMS.Model.STORAGE_MAIN mmSTORAGE_MAIN = this._P_STORAGE_MAIN.GetModelStockBarcode(STOCK_BARCODE);
|
|
try
|
|
{
|
|
#region 校验
|
|
|
|
#region 校验上架容器条码
|
|
|
|
//if (string.IsNullOrEmpty(STOCK_BARCODE))
|
|
//{
|
|
// bResult = false;
|
|
|
|
// sResult = string.Format("请输入容器条码");
|
|
|
|
// return bResult;
|
|
//}
|
|
|
|
//if (STOCK_BARCODE.Trim().Length != 6)
|
|
//{
|
|
// bResult = false;
|
|
|
|
// sResult = string.Format("容器条码[{0}]不合法", STOCK_BARCODE);
|
|
|
|
// return bResult;
|
|
//}
|
|
|
|
////T:普通托盘
|
|
//SiaSun.LMS.Model.GOODS_MAIN mGOODS_MAIN_CONTAINER = this._P_GOODS_MAIN.GetModel(STOCK_BARCODE.Substring(0, 1).ToUpper());
|
|
|
|
//if (mGOODS_MAIN_CONTAINER == null)
|
|
//{
|
|
// bResult = false;
|
|
|
|
// sResult = string.Format("容器条码[{0}]不合法", STOCK_BARCODE);
|
|
|
|
// return bResult;
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 校验托盘库存
|
|
|
|
SiaSun.LMS.Model.STORAGE_MAIN mSTORAGE_MAIN = this._P_STORAGE_MAIN.GetModelStockBarcode(STOCK_BARCODE);
|
|
|
|
if (null == mSTORAGE_MAIN)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("容器[{0}]不存在库存", STOCK_BARCODE);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
SiaSun.LMS.Model.WH_CELL mWH_CELL = this._P_WH_CELL.GetModel(mSTORAGE_MAIN.CELL_ID);
|
|
|
|
SiaSun.LMS.Model.WH_AREA mWH_AREA = this._P_WH_AREA.GetModel(mWH_CELL.AREA_ID);
|
|
|
|
if (mWH_AREA.AREA_TYPE == SiaSun.LMS.Enum.AREA_TYPE.XuNiKu.ToString())
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("容器[{0}]在[{1}][{2}]", STOCK_BARCODE, mWH_AREA.AREA_NAME, mWH_CELL.CELL_NAME);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
if (this._P_STORAGE_MAIN.GetListStockBarcode(STOCK_BARCODE).Count > 1)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("容器[{0}]库存异常", STOCK_BARCODE);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
IList<Model.STORAGE_LIST> lsSTORAGE_LIST = this._P_STORAGE_LIST.GetListStorageID(mSTORAGE_MAIN.STORAGE_ID);
|
|
|
|
if (lsSTORAGE_LIST.Count == 0)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("容器[{0}]的库存明细异常", STOCK_BARCODE);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 校验起始货位
|
|
|
|
SiaSun.LMS.Model.WH_CELL mSTART_WH_CELL = this._P_WH_CELL.GetModel(mSTORAGE_MAIN.CELL_ID);
|
|
|
|
if (mSTART_WH_CELL == null)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("库存位置索引[{0}]不存在", mSTORAGE_MAIN.CELL_ID);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
if (mSTART_WH_CELL.CELL_INOUT.Equals(SiaSun.LMS.Enum.CELL_INOUT.Out.ToString()))
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("起始位置[{0}]入出类型[{1}]不合法", mSTART_WH_CELL.CELL_NAME, mSTART_WH_CELL.CELL_INOUT);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
if (!mSTART_WH_CELL.CELL_TYPE.Equals(Enum.CELL_TYPE.Cell.ToString()))
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("起始位置[{0}]类型[{1}]不合法", mSTART_WH_CELL.CELL_NAME, mSTART_WH_CELL.CELL_TYPE);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
if (mSTART_WH_CELL.CELL_STATUS == Enum.CELL_STATUS.Nohave.ToString() || mSTART_WH_CELL.CELL_STATUS == Enum.CELL_STATUS.Exception.ToString())
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("起始位置[{0}]货位状态[{1}]不合法", mSTART_WH_CELL.CELL_NAME, mSTART_WH_CELL.CELL_STATUS);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
if (mSTART_WH_CELL.RUN_STATUS != Enum.RUN_STATUS.Enable.ToString())
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("起始位置[{0}]运行状态[{1}]不合法", mSTART_WH_CELL.CELL_NAME, mSTART_WH_CELL.RUN_STATUS);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 校验终止货位
|
|
|
|
if (END_CELL_ID == 0)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("请选择终止货位");
|
|
|
|
return bResult;
|
|
}
|
|
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
|
|
|
|
if (mEND_WH_CELL == null)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("终止位置索引[{0}]不存在", END_CELL_ID);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
if (mEND_WH_CELL.CELL_INOUT.Equals(SiaSun.LMS.Enum.CELL_INOUT.Out.ToString()))
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("终止位置[{0}]入出类型[{1}]不合法", mEND_WH_CELL.CELL_NAME, mEND_WH_CELL.CELL_INOUT);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
if (!mEND_WH_CELL.CELL_TYPE.Equals(Enum.CELL_TYPE.Cell.ToString()))
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("终止位置[{0}]类型[{1}]不合法", mEND_WH_CELL.CELL_NAME, mEND_WH_CELL.CELL_TYPE);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
if (mEND_WH_CELL.CELL_STATUS!= Enum.CELL_STATUS.Nohave.ToString())
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("终止位置[{0}]货位状态[{1}]不合法", mEND_WH_CELL.CELL_NAME, mEND_WH_CELL.CELL_STATUS);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
if (mEND_WH_CELL.RUN_STATUS != Enum.RUN_STATUS.Enable.ToString())
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("终止位置[{0}]运行状态[{1}]不合法", mEND_WH_CELL.CELL_NAME, mEND_WH_CELL.RUN_STATUS);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 下达任务
|
|
|
|
#region 生成MANAGE_MAIN
|
|
|
|
mMANAGE_MAIN = new Model.MANAGE_MAIN();
|
|
|
|
mMANAGE_MAIN.PLAN_ID = 0;
|
|
|
|
mMANAGE_MAIN.PLAN_TYPE_CODE = string.Empty;
|
|
|
|
mMANAGE_MAIN.MANAGE_TYPE_CODE = SiaSun.LMS.Enum.MANAGE_TYPE.ManageMove.ToString();
|
|
|
|
mMANAGE_MAIN.MANAGE_STATUS = SiaSun.LMS.Enum.MANAGE_STATUS.Waiting.ToString();
|
|
|
|
mMANAGE_MAIN.STOCK_BARCODE = STOCK_BARCODE;
|
|
|
|
mMANAGE_MAIN.FULL_FLAG = mSTORAGE_MAIN.FULL_FLAG;
|
|
|
|
mMANAGE_MAIN.CELL_MODEL = mSTORAGE_MAIN.CELL_MODEL;
|
|
|
|
mMANAGE_MAIN.START_CELL_ID = mSTORAGE_MAIN.CELL_ID;
|
|
|
|
mMANAGE_MAIN.END_CELL_ID = END_CELL_ID;
|
|
|
|
mMANAGE_MAIN.MANAGE_OPERATOR = Opertator;
|
|
|
|
mMANAGE_MAIN.MANAGE_BEGIN_TIME = SiaSun.LMS.Common.StringUtil.GetCurDateTimeString();
|
|
|
|
#endregion
|
|
|
|
#region 生成MANAGE_LIST
|
|
|
|
foreach (SiaSun.LMS.Model.STORAGE_LIST mSTORAGE_LIST in this._P_STORAGE_LIST.GetListStorageID(mSTORAGE_MAIN.STORAGE_ID))
|
|
{
|
|
mMANAGE_LIST = new Model.MANAGE_LIST();
|
|
|
|
mMANAGE_LIST.GOODS_ID = mSTORAGE_LIST.GOODS_ID;
|
|
|
|
mMANAGE_LIST.PLAN_LIST_ID = 0;
|
|
|
|
mMANAGE_LIST.STORAGE_LIST_ID = mSTORAGE_LIST.STORAGE_LIST_ID;
|
|
|
|
mMANAGE_LIST.MANAGE_LIST_QUANTITY = mSTORAGE_LIST.STORAGE_LIST_QUANTITY;
|
|
|
|
mMANAGE_LIST.GOODS_PROPERTY6 = mSTORAGE_LIST.GOODS_PROPERTY6;
|
|
|
|
mMANAGE_LIST.MANAGE_LIST_REMARK = mSTORAGE_LIST.STORAGE_LIST_REMARK;
|
|
|
|
bResult = this._S_GoodsService.GoodsPropertySetValue(mSTORAGE_LIST.GOODS_ID, mMANAGE_LIST, mSTORAGE_LIST, out sResult);
|
|
if (!bResult)
|
|
{
|
|
return bResult;
|
|
}
|
|
|
|
lsMANAGE_LIST.Add(mMANAGE_LIST);
|
|
}
|
|
|
|
#endregion
|
|
|
|
bResult = base.ManageCreate(mMANAGE_MAIN, lsMANAGE_LIST, bAutoSendControl, false, out sResult);
|
|
|
|
|
|
//SiaSun.LMS.Model.WH_CELL wh_cell = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID);
|
|
|
|
//if (wh_cell != null)
|
|
//{
|
|
// this.updateLedText(mMANAGE_MAIN.START_CELL_ID, 3, "货位:" + wh_cell.CELL_CODE);
|
|
//}
|
|
//else
|
|
//{
|
|
// this.updateLedText(mMANAGE_MAIN.START_CELL_ID, 3, "货位:" + "未找到货位");
|
|
//}
|
|
//直接报完成
|
|
if ((!bAutoSendControl) && bResult)
|
|
{
|
|
bResult = this.ManageComplete(mMANAGE_MAIN.MANAGE_ID, bTrans, out sResult);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = ex.Message;
|
|
|
|
this._log.Fatal(string.Format("调用方法{0}发生异常。", MethodBase.GetCurrentMethod().Name), ex);
|
|
}
|
|
//// this.updateLedText(mmSTORAGE_MAIN.CELL_ID, 1, "任务类型:移库");
|
|
//// this.updateLedText(mmSTORAGE_MAIN.CELL_ID, 2, "条码:" + STOCK_BARCODE);
|
|
return bResult;
|
|
}
|
|
|
|
|
|
/// <summary>完成
|
|
/// 完成
|
|
/// </summary>
|
|
///
|
|
/// <param name="MANAGE_ID"></param>
|
|
/// <param name="bTrans">是否独立事务</param>
|
|
/// <param name="sResult"></param>
|
|
/// <returns></returns>
|
|
public new bool ManageComplete(int MANAGE_ID, bool bTrans, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
|
|
sResult = string.Empty;
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mmMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID);
|
|
try
|
|
{
|
|
this._P_Base_House.BeginTransaction(bTrans);
|
|
|
|
#region 校验
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = this._P_MANAGE_MAIN.GetModel(MANAGE_ID);
|
|
|
|
bResult = null != mMANAGE_MAIN;
|
|
|
|
if (!bResult)
|
|
{
|
|
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(999)))
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("控制任务索引[{0}]的控制任务未完成", mIO_CONTROL.CONTROL_ID);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
SiaSun.LMS.Model.WH_CELL mSTART_WH_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID);
|
|
if (null == mSTART_WH_CELL)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("起始位置索引[{0}]不存在", mMANAGE_MAIN.START_CELL_ID);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
SiaSun.LMS.Model.WH_CELL mEND_WH_CELL = this._P_WH_CELL.GetModel(mMANAGE_MAIN.END_CELL_ID);
|
|
if (null == mEND_WH_CELL)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("终止位置索引[{0}]不存在", mMANAGE_MAIN.END_CELL_ID);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 更新库存-巷道内倒库
|
|
|
|
bResult = this._S_StorageService.StorageMove(MANAGE_ID, out sResult);
|
|
if (!bResult)
|
|
{
|
|
return bResult;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 更新货位状态
|
|
|
|
if (!this._P_WH_AREA.GetModel(mSTART_WH_CELL.AREA_ID).AREA_TYPE.Equals(SiaSun.LMS.Enum.AREA_TYPE.XuNiKu.ToString()))
|
|
{
|
|
string CELL_STATUS = SiaSun.LMS.Enum.CELL_STATUS.Nohave.ToString();
|
|
|
|
bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.START_CELL_ID, CELL_STATUS, SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(), out sResult);
|
|
if (!bResult)
|
|
{
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
if (!this._P_WH_AREA.GetModel(mEND_WH_CELL.AREA_ID).AREA_TYPE.Equals(SiaSun.LMS.Enum.AREA_TYPE.XuNiKu.ToString()))
|
|
{
|
|
string CELL_STATUS = SiaSun.LMS.Enum.CELL_STATUS.Full.ToString();
|
|
|
|
bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.END_CELL_ID, CELL_STATUS, SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(), out sResult);
|
|
if (!bResult)
|
|
{
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 调用基类-更新管理任务;更新计划;生成入出库记录
|
|
|
|
bResult = this._S_ManageService.ManageComplete(MANAGE_ID, false, out sResult);
|
|
|
|
if (!bResult)
|
|
{
|
|
return bResult;
|
|
}
|
|
//this.updateLedText(mMANAGE_MAIN.END_CELL_ID, 1, "移库完成");
|
|
// this.updateLedText(mMANAGE_MAIN.END_CELL_ID, 2, "条码:" + mMANAGE_MAIN.STOCK_BARCODE);
|
|
// this.updateLedText(mMANAGE_MAIN.END_CELL_ID, 3, "货位:" + mMANAGE_MAIN.END_CELL_ID.ToString());
|
|
#endregion
|
|
|
|
#region 删除任务信息
|
|
|
|
this._P_IO_CONTROL.DeleteManageID(mMANAGE_MAIN.MANAGE_ID);
|
|
|
|
this._P_MANAGE_DETAIL.DeleteManageID(mMANAGE_MAIN.MANAGE_ID);
|
|
|
|
this._P_MANAGE_LIST.DeleteManageID(mMANAGE_MAIN.MANAGE_ID);
|
|
|
|
this._P_MANAGE_MAIN.Delete(mMANAGE_MAIN.MANAGE_ID);
|
|
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = ex.Message;
|
|
|
|
this._log.Fatal(string.Format("调用方法{0}发生异常。", MethodBase.GetCurrentMethod().Name), ex);
|
|
}
|
|
finally
|
|
{
|
|
if (bResult)
|
|
{
|
|
this._P_Base_House.CommitTransaction(bTrans);
|
|
//if (mmMANAGE_MAIN != null)
|
|
//{
|
|
// this.updateLedText(mmMANAGE_MAIN.END_CELL_ID, 1, "移库完成");
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
this._P_Base_House.RollBackTransaction(bTrans);
|
|
}
|
|
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
}
|