宜昌华友原料库管理软件
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.

1879 lines
83 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Data;
using SiaSun.LMS.Model;
namespace SiaSun.LMS.Implement
{
public class ManageOut : ManageBase
{
private static readonly object lockObj = new object();
/// <summary>
/// 根据计划生成出库任务
/// 调用界面 MANAGE_PLAN_OUT.XAML
/// </summary>
/// <param name="mMANAGE_MAIN"></param>
/// <param name="lsPLAN_LIST"></param>
/// <param name="lsMANAGE_LIST"></param>
/// <param name="bTrans"></param>
/// <param name="bAutoSendControl"></param>
/// <param name="bComplete"></param>
/// <param name="sResult"></param>
/// <returns></returns>
public bool ManageCreate(SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN,
List<SiaSun.LMS.Model.PLAN_LIST> lsPLAN_LIST,
List<SiaSun.LMS.Model.MANAGE_LIST> lsMANAGE_LIST,
bool bTrans,
bool bAutoSendControl,
bool bComplete, out string sResult)
{
bool bResult = true;
sResult = string.Empty;
SiaSun.LMS.Model.WH_CELL mWH_CELL_START = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID);
SiaSun.LMS.Model.WH_AREA mWH_AREA_START = null;
if (mWH_CELL_START != null)
mWH_AREA_START = this._P_WH_AREA.GetModel(mWH_CELL_START.AREA_ID);
SiaSun.LMS.Model.WH_CELL mWH_CELL_END = this._P_WH_CELL.GetModel(mMANAGE_MAIN.END_CELL_ID);
SiaSun.LMS.Model.WH_AREA mWH_AREA_END = null;
if (mWH_CELL_END != null)
mWH_AREA_END = this._P_WH_AREA.GetModel(mWH_CELL_END.AREA_ID);
IList<SiaSun.LMS.Model.STORAGE_MAIN> lsSTORAGE_MAIN = null;
if (mMANAGE_MAIN.STOCK_BARCODE == string.Empty)
lsSTORAGE_MAIN = this._P_STORAGE_MAIN.GetListCellID(mMANAGE_MAIN.START_CELL_ID);
else
lsSTORAGE_MAIN = this._P_STORAGE_MAIN.GetListStockBarcode(mMANAGE_MAIN.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;
}
int SCELL_ID = 0;
int iManageLevel = 0;
if (mWH_CELL_END.DEVICE_CODE == "38001")
{
iManageLevel = 8;
}
if (mWH_CELL_START.SHELF_TYPE == "Double")//双申巷道
{
if (mMANAGE_MAIN.MANAGE_TYPE_CODE == "StockOut")
{
bResult = this.DoubleManageStockJudge(mWH_CELL_END.CELL_CODE, mMANAGE_MAIN.START_CELL_ID, out SCELL_ID, out sResult);
}
else
{
bResult = this.DoubleManageJudge(mWH_CELL_END.CELL_CODE, mMANAGE_MAIN.START_CELL_ID, iManageLevel, out SCELL_ID, out sResult);
}
if (bResult)
{
mMANAGE_MAIN.START_CELL_ID = SCELL_ID;
}
else
{
AddLog(sResult);
//this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
}
try
{
this._P_Base_House.BeginTransaction(bTrans);
if (lsPLAN_LIST != null && lsPLAN_LIST.Count > 0)
{
mPLAN_LIST = this._P_PLAN_LIST.GetModel(lsPLAN_LIST[0].PLAN_LIST_ID);
mPLAN_MAIN = this._P_PLAN_MAIN.GetModel(mPLAN_LIST.PLAN_ID);
}
mMANAGE_MAIN.STOCK_BARCODE = lsSTORAGE_MAIN[0].STOCK_BARCODE;
mMANAGE_MAIN.MANAGE_LEVEL = iManageLevel.ToString();
this._P_MANAGE_MAIN.Add(mMANAGE_MAIN);
foreach (SiaSun.LMS.Model.MANAGE_LIST mMANAGE_LIST in lsMANAGE_LIST)
{
if (lsPLAN_LIST != null)
{
foreach (SiaSun.LMS.Model.PLAN_LIST temp_mPLAN_LIST in lsPLAN_LIST)
{
if (mMANAGE_LIST.GOODS_ID == temp_mPLAN_LIST.GOODS_ID)
{
mMANAGE_LIST.PLAN_LIST_ID = temp_mPLAN_LIST.PLAN_LIST_ID;
temp_mPLAN_LIST.PLAN_LIST_ORDERED_QUANTITY += mMANAGE_LIST.MANAGE_LIST_QUANTITY;
this._P_PLAN_LIST.Update(temp_mPLAN_LIST);
break;
}
}
}
mMANAGE_LIST.MANAGE_ID = mMANAGE_MAIN.MANAGE_ID;
this._P_MANAGE_LIST.Add(mMANAGE_LIST);
}
if (mWH_CELL_START != null)
{
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}", mWH_CELL_START.CELL_CODE, sResult);
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
}
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;
}
}
if (bAutoSendControl && mWH_AREA_START != null && mWH_AREA_START.AREA_TYPE.ToLower() == "liku")
{
bResult = this.ManageDownLoad(mMANAGE_MAIN.MANAGE_ID, string.Empty, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
}
if (bComplete && (mWH_AREA_START == null || mWH_AREA_START.AREA_TYPE.ToLower() == "xuniku"))
{
bResult = this.ManageComplete(mMANAGE_MAIN.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>
/// 生成无计划出库任务
/// 调用界面 MANAGE_OUT.XAML
/// </summary>
/// <param name="mMANAGE_MAIN"></param>
/// <param name="lsMANAGE_LIST"></param>
/// <param name="bTrans"></param>
/// <param name="bAutoSendControl"></param>
/// <param name="bComplete"></param>
/// <param name="sResult"></param>
/// <returns></returns>
public bool ManageCreate(SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN,
List<SiaSun.LMS.Model.MANAGE_LIST> lsMANAGE_LIST,
bool bTrans,
bool bAutoSendControl,
bool bComplete, out string sResult)
{
bool bResult = true;
sResult = string.Empty;
int MANAGE_ID = 0;
try
{
SiaSun.LMS.Model.WH_CELL mWH_CELL_START = this._P_WH_CELL.GetModel(mMANAGE_MAIN.START_CELL_ID);
SiaSun.LMS.Model.WH_AREA mWH_AREA_START = null;
if (mWH_CELL_START != null)
mWH_AREA_START = this._P_WH_AREA.GetModel(mWH_CELL_START.AREA_ID);
SiaSun.LMS.Model.WH_CELL mWH_CELL_END = this._P_WH_CELL.GetModel(mMANAGE_MAIN.END_CELL_ID);
SiaSun.LMS.Model.WH_AREA mWH_AREA_END = null;
if (mWH_CELL_END != null)
mWH_AREA_END = this._P_WH_AREA.GetModel(mWH_CELL_END.AREA_ID);
if (mWH_CELL_START != null
&& (mWH_CELL_START.CELL_TYPE.TrimEnd() == Enum.CELL_TYPE.Cell.ToString() || mWH_CELL_START.CELL_STORAGE_TYPE.TrimEnd() == Enum.CELL_STORAGE_TYPE.Single.ToString())
&& (mWH_CELL_START.CELL_STATUS != Enum.CELL_STATUS.Have.ToString() || mWH_CELL_START.CELL_STATUS != Enum.CELL_STATUS.Pallet.ToString())
&& mWH_CELL_START.RUN_STATUS != Enum.RUN_STATUS.Enable.ToString())
{
bResult = false;
sResult = string.Format("起始位置{0}不可用", mWH_CELL_START.CELL_CODE);
return bResult;
}
//if (mWH_CELL_END != null
// && (mWH_CELL_END.CELL_TYPE.TrimEnd() == Enum.CELL_TYPE.Cell.ToString() || mWH_CELL_END.CELL_STORAGE_TYPE.TrimEnd() == Enum.CELL_STORAGE_TYPE.Single.ToString())
// && mWH_CELL_END.CELL_STATUS != Enum.CELL_STATUS.Nohave.ToString()
// && mWH_CELL_END.RUN_STATUS != Enum.RUN_STATUS.Enable.ToString())
//{
// bResult = false;
// sResult = string.Format("终止位置{0}不可用", mWH_CELL_END.CELL_CODE);
// return bResult;
//}
foreach (SiaSun.LMS.Model.MANAGE_LIST mMANAGE_LIST in lsMANAGE_LIST)
{
DataTable dtStorageListId = this.GetList(string.Format("select * from storage_list where storage_list_id ={0}", mMANAGE_LIST.STORAGE_LIST_ID));
if (dtStorageListId.Rows.Count == 0)
{
bResult = false;
sResult = string.Format("库存索引 {0} 不存在,请刷新界面重新下达!", mMANAGE_LIST.STORAGE_LIST_ID);
return bResult;
}
if (mMANAGE_LIST.GOODS_ID == 32778 &&
mWH_CELL_END != null &&
(mWH_CELL_END.CELL_CODE == "11001" ||
mWH_CELL_END.CELL_CODE == "11031"))
{
bResult = false;
sResult = string.Format("母托盘垛不能出库到原料库一楼入库口");
return bResult;
}
}
this._P_Base_House.BeginTransaction(bTrans);
int SCELL_ID = 0;
int iManageLevel = 0;
if (mWH_CELL_END.DEVICE_CODE == "38001")
{
iManageLevel = 8;
}
if (mWH_CELL_START.SHELF_TYPE == "Double")//双申巷道
{
if (mMANAGE_MAIN.MANAGE_TYPE_CODE == "StockOut")
{
bResult = this.DoubleManageStockJudge(mWH_CELL_END.CELL_CODE, mMANAGE_MAIN.START_CELL_ID, out SCELL_ID, out sResult);
}
else
{
bResult = this.DoubleManageJudge(mWH_CELL_END.CELL_CODE, mMANAGE_MAIN.START_CELL_ID, iManageLevel, out SCELL_ID, out sResult);
}
if (bResult)
{
mMANAGE_MAIN.START_CELL_ID = SCELL_ID;
}
else
{
AddLog(sResult);
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
}
if (mWH_CELL_START != null)
{
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}", mWH_CELL_START.CELL_CODE, sResult);
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
}
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;
}
}
IList<SiaSun.LMS.Model.STORAGE_MAIN> lsSTORAGE_MAIN = null;
if (mMANAGE_MAIN.STOCK_BARCODE == string.Empty)
lsSTORAGE_MAIN = this._P_STORAGE_MAIN.GetListCellID(mMANAGE_MAIN.START_CELL_ID);
else
lsSTORAGE_MAIN = this._P_STORAGE_MAIN.GetListStockBarcode(mMANAGE_MAIN.STOCK_BARCODE);
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;
}
mMANAGE_MAIN.STOCK_BARCODE = lsSTORAGE_MAIN[0].STOCK_BARCODE;
mMANAGE_MAIN.MANAGE_LEVEL = iManageLevel.ToString();
this._P_MANAGE_MAIN.Add(mMANAGE_MAIN);
foreach (SiaSun.LMS.Model.MANAGE_LIST mMANAGE_LIST in lsMANAGE_LIST)
{
mMANAGE_LIST.MANAGE_ID = mMANAGE_MAIN.MANAGE_ID;
mMANAGE_LIST.PLAN_LIST_ID = 0;
this._P_MANAGE_LIST.Add(mMANAGE_LIST);
}
MANAGE_ID = mMANAGE_MAIN.MANAGE_ID;
if (bAutoSendControl && mWH_AREA_START != null && mWH_AREA_START.AREA_TYPE.ToLower() == "liku")
{
bResult = this.ManageDownLoad(MANAGE_ID, string.Empty, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
}
if (bComplete && (mWH_AREA_START == null || mWH_AREA_START.AREA_TYPE.ToLower() == "xuniku" || mWH_AREA_START.AREA_TYPE.ToLower() == "pingku"))
{
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>
/// 根据物料ID及物料属性 生成批量下架任务
/// 调用界面 MANAGE_STOCK_OUT.XAML
///
/// </summary>
/// <param name="mSYS_USER"></param>
/// <param name="GOODS_ID"></param>
/// <param name="GOODS_PROPERTY"></param>
/// <param name="QUANTITY"></param>
/// <param name="WAREHOUSE_ID"></param>
/// <param name="AREA_ID"></param>
/// <param name="LOGIC_ID"></param>
/// <param name="END_CELL_ID"></param>
/// <param name="bTrans"></param>
/// <param name="sResult"></param>
/// <returns></returns>
public bool ManageCreate(SiaSun.LMS.Model.SYS_USER mSYS_USER,
string MANAGE_TYPE_CODE,
int GOODS_ID,
string GOODS_PROPERTY_CONDITION,
decimal MANAGE_LIST_QUANTITY,
int END_CELL_ID,
bool bTrans,
out string sResult)
{
bool bResult = false;
sResult = string.Empty;
SiaSun.LMS.Model.WH_CELL mWH_CELL = this._P_WH_CELL.GetModel(END_CELL_ID);
bResult = null != mWH_CELL;
if (!bResult)
{
sResult = "出库站台错误";
return bResult;
}
try
{
DataTable dtLANEWAY = null;
bResult = this._S_CellService.LaneWayGetList(END_CELL_ID, GOODS_ID, GOODS_PROPERTY_CONDITION, out dtLANEWAY, out sResult);
if (!bResult)
{
return bResult;
}
int iSumQuantity = 0;
foreach (DataRow drLANEWAY in dtLANEWAY.Rows)
{
iSumQuantity += Convert.ToInt32(drLANEWAY["STORAGE_BALANCE"]);
}
bResult = iSumQuantity >= MANAGE_LIST_QUANTITY;
if (!bResult)
{
sResult = string.Format("库存{0}小于需求{1},请重新输入数量!", iSumQuantity, MANAGE_LIST_QUANTITY);
return bResult;
}
this._P_Base_House.BeginTransaction(bTrans);
decimal MANAGE_LIST_QUANTITY_FINISHED = 0;
while (MANAGE_LIST_QUANTITY_FINISHED < MANAGE_LIST_QUANTITY)
{
int START_CELL_ID = 0;
string STOCK_BARCODE = string.Empty;
decimal MANAGE_ORDERED_QUANTITY = 0;
DataView dvLANEWAY = dtLANEWAY.DefaultView;
dvLANEWAY.RowFilter = "STORAGE_BALANCE > 0";
dvLANEWAY.Sort = "OUT_TASK_BALANCE asc,STORAGE_BALANCE desc";
bResult = dvLANEWAY.Count > 0;
if (!bResult)
{
sResult = "库存数量不足";
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
int iLANEWAY = Convert.ToInt32(dvLANEWAY[0]["LANE_WAY"]);
bResult = this._S_CellService.CellOutAllocate(iLANEWAY, END_CELL_ID, GOODS_ID, GOODS_PROPERTY_CONDITION, MANAGE_LIST_QUANTITY - MANAGE_LIST_QUANTITY_FINISHED, out START_CELL_ID, out STOCK_BARCODE, out MANAGE_ORDERED_QUANTITY, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
bResult = this.ManageCreate(mSYS_USER, 0, MANAGE_TYPE_CODE, STOCK_BARCODE, START_CELL_ID, END_CELL_ID, false, true, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
dvLANEWAY[0].Row["STORAGE_BALANCE"] = Convert.ToDecimal(dvLANEWAY[0].Row["STORAGE_BALANCE"]) - MANAGE_ORDERED_QUANTITY;
if (dvLANEWAY.Count > 0)
dvLANEWAY[0].Row["OUT_TASK_BALANCE"] = Convert.ToDecimal(dvLANEWAY[0].Row["OUT_TASK_BALANCE"]) + 1;
MANAGE_LIST_QUANTITY_FINISHED += MANAGE_ORDERED_QUANTITY;
}
this._P_Base_House.CommitTransaction(bTrans);
}
catch (Exception ex)
{
this._P_Base_House.RollBackTransaction(bTrans);
bResult = false;
sResult = ex.Message;
}
return bResult;
}
/// <summary> 暂存出库
/// 生成无计划暂存出库任务
/// 调用界面 MANAGE_OUT.XAML
/// </summary>
/// <param name="mMANAGE_MAIN"></param>
/// <param name="lsMANAGE_LIST"></param>
/// <param name="bTrans"></param>
/// <param name="bAutoSendControl"></param>
/// <param name="bComplete"></param>
/// <param name="sResult"></param>
/// <returns></returns>
public bool ManageCreateWorkingArea(SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN,
List<SiaSun.LMS.Model.MANAGE_LIST> lsMANAGE_LIST,
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(mMANAGE_MAIN.START_CELL_ID);
SiaSun.LMS.Model.WH_AREA mWH_AREA_START = null;
if (mWH_CELL_START != null)
mWH_AREA_START = this._P_WH_AREA.GetModel(mWH_CELL_START.AREA_ID);
SiaSun.LMS.Model.WH_CELL mWH_CELL_END = this._P_WH_CELL.GetModel(mMANAGE_MAIN.END_CELL_ID);
SiaSun.LMS.Model.WH_AREA mWH_AREA_END = null;
if (mWH_CELL_END != null)
mWH_AREA_END = this._P_WH_AREA.GetModel(mWH_CELL_END.AREA_ID);
if (mWH_CELL_START != null
&& (mWH_CELL_START.CELL_TYPE.TrimEnd() == Enum.CELL_TYPE.Cell.ToString())
&& (mWH_CELL_START.CELL_STATUS != Enum.CELL_STATUS.Have.ToString()
|| mWH_CELL_START.CELL_STATUS != Enum.CELL_STATUS.Pallet.ToString())
&& mWH_CELL_START.RUN_STATUS != Enum.RUN_STATUS.Enable.ToString())
{
bResult = false;
sResult = string.Format("起始位置{0}不可用", mWH_CELL_START.CELL_CODE);
return bResult;
}
IList<SiaSun.LMS.Model.STORAGE_MAIN> lsSTORAGE_MAIN = null;
if (mMANAGE_MAIN.STOCK_BARCODE == string.Empty)
lsSTORAGE_MAIN = this._P_STORAGE_MAIN.GetListCellID(mMANAGE_MAIN.START_CELL_ID);
else
lsSTORAGE_MAIN = this._P_STORAGE_MAIN.GetListStockBarcode(mMANAGE_MAIN.STOCK_BARCODE);
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;
}
STORAGE_MAIN sm = this._P_STORAGE_MAIN.GetModelStockBarcode(lsSTORAGE_MAIN[0].STOCK_BARCODE);
if (sm != null && sm.CELL_ID > 0)
{
WH_CELL wc = this._P_WH_CELL.GetModel(sm.CELL_ID);
if (wc != null && wc.CELL_CODE.Contains("-"))
{
bResult = false;
sResult = string.Format("托盘条码{0}已经存在库存", lsSTORAGE_MAIN[0].STOCK_BARCODE);
return bResult;
}
}
try
{
this._P_Base_House.BeginTransaction(bTrans);
mMANAGE_MAIN.STOCK_BARCODE = lsSTORAGE_MAIN[0].STOCK_BARCODE;
this._P_MANAGE_MAIN.Add(mMANAGE_MAIN);
foreach (SiaSun.LMS.Model.MANAGE_LIST mMANAGE_LIST in lsMANAGE_LIST)
{
mMANAGE_LIST.MANAGE_ID = mMANAGE_MAIN.MANAGE_ID;
mMANAGE_LIST.PLAN_LIST_ID = 0;
this._P_MANAGE_LIST.Add(mMANAGE_LIST);
}
if (mWH_CELL_START != null)
{
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}", mWH_CELL_START.CELL_CODE, sResult);
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
}
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;
}
}
MANAGE_ID = mMANAGE_MAIN.MANAGE_ID;
if (bAutoSendControl && mWH_AREA_START != null && mWH_AREA_START.AREA_TYPE.ToLower() == "liku")
{
bResult = this.ManageDownLoad(MANAGE_ID, string.Empty, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
}
if (bComplete && (mWH_AREA_START == null || mWH_AREA_START.AREA_TYPE.ToLower() == "xuniku"))
{
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;
AddLog(sResult);
}
return bResult;
}
/// <summary>
/// 根据物料类型调度申请出库空托盘
/// 调用界面 MANAGE_STOCK_OUT.XAML
/// </summary>
/// <param name="mSYS_USER"></param>
/// <param name="GOODS_ID"></param>
/// <param name="GOODS_PROPERTY"></param>
/// <param name="QUANTITY"></param>
/// <param name="END_CELL_ID"></param>
/// <param name="bTrans"></param>
/// <param name="sResult"></param>
/// <returns></returns>
public bool ManageCreate_Stock_Out_Auot(Model.SYS_USER mSYS_USER,
string MANAGE_TYPE_CODE,
string GOODS_CODE,
string END_CELL_CODE,
bool bTrans,
out string sResult)
{
bool bResult = false;
sResult = string.Empty;
DataTable dt = null;
string strSql = string.Empty;
string cell_status = string.Empty;
string DeviceCode = "";
SiaSun.LMS.Model.WH_CELL mWH_CELL = this._P_WH_CELL.GetModel(END_CELL_CODE);
if (mWH_CELL == null)
{
bResult = false;
sResult = string.Format("系统不存在该货位编码'{0}'", END_CELL_CODE);
return bResult;
}
Model.GOODS_MAIN gOODS_MAIN = this._P_GOODS_MAIN.GetModel(GOODS_CODE);
if (gOODS_MAIN == null)
{
bResult = false;
sResult = string.Format("系统不存在该物料编码'{0}'", GOODS_CODE);
return bResult;
}
string GoodsName = gOODS_MAIN.GOODS_NAME;
int GoodsId = gOODS_MAIN.GOODS_ID;
int START_CELL_ID = 0;
int SCELL_ID = 0;
try
{
if (GOODS_CODE == "GTP")
{
cell_status = "Pallet";
}
else
{
cell_status = "Full";
}
//申请空托盘出库的顺序:
if (GOODS_CODE == "GTP")
{
dt = this.GetList(string.Format(@"SELECT CELL_ID FROM V_STORAGE_LIST WHERE RUN_STATUS ='Enable'
AND CELL_STATUS ='Pallet' AND GOODS_CODE = '{0}'
AND GOODS_TYPE_ID =2 and area_type='LiKu'", GOODS_CODE));
if (dt.Rows.Count == 0)
{
bResult = false;
sResult = string.Format("库区'{0}'不足,请补充!", GoodsName);
return bResult;
}
string ss = string.Format(@"select DEVICE_CODE, sum(ENABLE_NUM) PALLET_COUNT
from(select DEVICE_CODE, (case when RUN_STATUS = 'Enable' and CELL_STATUS ='Pallet' then 1 else 0 end)
ENABLE_NUM from WH_CELL where AREA_ID = 1 and DEVICE_CODE in (select start_device from IO_CONTROL_ROUTE
where END_DEVICE='{0}' and CONTROL_ROUTE_STATUS =1)) T group by DEVICE_CODE
order by PALLET_COUNT DESC, DEVICE_CODE", mWH_CELL.CELL_CODE);
DataTable dtGetMaxPallet = this.GetList(ss);
if (dtGetMaxPallet.Rows.Count == 0)
{
bResult = false;
sResult = string.Format("库区设备报警");
return bResult;
}
//获得空托盘数量最多的巷道
DeviceCode = dtGetMaxPallet.Rows[0]["DEVICE_CODE"].ToString();
//条件1:Double有货无任务且与下架物料一致,Normal无货无任务--选择Double实盘货位
strSql = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_STATUS = '{0}' and RUN_STATUS = 'Enable'
AND CELL_STATUS_NEAR = 'Nohave' and RUN_STATUS_NEAR = 'Enable'
AND DEVICE_CODE IN (SELECT START_DEVICE FROM IO_CONTROL_ROUTE
WHERE CONTROL_ROUTE_TYPE =2 AND CONTROL_ROUTE_STATUS =1 AND
END_DEVICE ='{1}' and START_DEVICE='{2}')",
cell_status, mWH_CELL.CELL_CODE, DeviceCode);
dt = this.GetList(strSql);
bResult = dt.Rows.Count > 0;
if (bResult)
{
START_CELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
this._P_Base_House.BeginTransaction(bTrans);
//生成任务
bResult = this.ManageCreate(mSYS_USER, 0, MANAGE_TYPE_CODE, string.Empty, START_CELL_ID, mWH_CELL.CELL_ID, false, true, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
this._P_Base_House.CommitTransaction(bTrans);
return bResult;
}
//条件2:Double有货无任务且与下架物料一致,Normal有货有任务--选择Double实盘货位
strSql = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_STATUS = '{0}' and RUN_STATUS = 'Enable'
AND (CELL_STATUS_NEAR='Pallet' or CELL_STATUS_NEAR='Near') AND RUN_STATUS_NEAR = 'Selected' AND DEVICE_CODE IN
(SELECT START_DEVICE FROM IO_CONTROL_ROUTE WHERE
CONTROL_ROUTE_TYPE =2 AND CONTROL_ROUTE_STATUS =1 AND
END_DEVICE ='{1}' and START_DEVICE='{2}')",
cell_status, mWH_CELL.CELL_CODE, DeviceCode);
dt = this.GetList(strSql);
bResult = dt.Rows.Count > 0;
if (bResult)
{
START_CELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
this._P_Base_House.BeginTransaction(bTrans);
//生成任务
bResult = this.ManageCreate(mSYS_USER, 0, MANAGE_TYPE_CODE, string.Empty, START_CELL_ID, mWH_CELL.CELL_ID, false, true, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
this._P_Base_House.CommitTransaction(bTrans);
return bResult;
}
//条件3:Double无任务,Normal有货无任务且与下架物料一致--选择Normal实盘货位
strSql = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
RUN_STATUS in ('Enable','Disable') AND CELL_STATUS_NEAR = '{0}'
and RUN_STATUS_NEAR = 'Enable' AND DEVICE_CODE IN
(SELECT START_DEVICE FROM IO_CONTROL_ROUTE WHERE CONTROL_ROUTE_TYPE =2
AND CONTROL_ROUTE_STATUS =1 AND END_DEVICE ='{1}' and START_DEVICE='{2}')",
cell_status, mWH_CELL.CELL_CODE, DeviceCode);
dt = this.GetList(strSql);
bResult = dt.Rows.Count > 0;
if (bResult)
{
START_CELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]);
this._P_Base_House.BeginTransaction(bTrans);
//生成任务
bResult = this.ManageCreate(mSYS_USER, 0, MANAGE_TYPE_CODE, string.Empty, START_CELL_ID, mWH_CELL.CELL_ID, false, true, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
this._P_Base_House.CommitTransaction(bTrans);
return bResult;
}
//条件4:空托盘申请出库顺序Normal,Near,Far
strSql = string.Format(@"SELECT * FROM V_STORAGE_LIST
WHERE RUN_STATUS ='Enable' AND CELL_STATUS ='Pallet' AND GOODS_TYPE_ID =2 and area_type='LiKu'
AND GOODS_CODE = '{1}' AND DEVICE_CODE IN (SELECT START_DEVICE FROM IO_CONTROL_ROUTE
WHERE CONTROL_ROUTE_TYPE =2 AND CONTROL_ROUTE_STATUS =1 AND END_DEVICE ='{0}' and START_DEVICE='{2}')
ORDER BY CELL_FORK_TYPE desc", mWH_CELL.CELL_CODE, GOODS_CODE, DeviceCode);
dt = this.GetList(strSql);
if (dt.Rows.Count == 0)
{
bResult = false;
sResult = "设备故障,请检查!";
return bResult;
}
else
{
//单伸货位和近端货位直接出库
if (dt.Rows[0]["CELL_FORK_TYPE"].ToString() == "Normal" || dt.Rows[0]["CELL_FORK_TYPE"].ToString() == "Near")
{
START_CELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID"]);
}
else
{
bResult = this.DoubleStockJudge(mWH_CELL.CELL_CODE, GOODS_CODE, out SCELL_ID, out sResult);
if (bResult)
{
START_CELL_ID = SCELL_ID;
}
else
{
bResult = false;
sResult = "设备故障,请检查!";
return bResult;
}
}
}
}
else
{
MANAGE_TYPE_CODE = "ManageOut";
dt = this.GetList(string.Format(@"SELECT CELL_ID FROM V_STORAGE_LIST WHERE RUN_STATUS ='Enable'
AND CELL_STATUS ='Full' AND GOODS_CODE = '{0}'
AND GOODS_TYPE_ID =1 and area_type='LiKu'", GOODS_CODE));
if (dt.Rows.Count == 0)
{
bResult = false;
sResult = string.Format("库区子'{0}'不足,请补充!", GoodsName);
return bResult;
}
//条件1:Double有货无任务且与下架物料一致,Normal无货无任务--选择Double实盘货位
strSql = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_STATUS = '{0}' and RUN_STATUS = 'Enable' and goods_id={2}
AND CELL_STATUS_NEAR = 'Nohave' and RUN_STATUS_NEAR = 'Enable'
AND DEVICE_CODE IN (SELECT START_DEVICE FROM IO_CONTROL_ROUTE
WHERE CONTROL_ROUTE_TYPE =2 AND CONTROL_ROUTE_STATUS =1 AND END_DEVICE ='{1}')",
cell_status, mWH_CELL.CELL_CODE, GoodsId);
dt = this.GetList(strSql);
bResult = dt.Rows.Count > 0;
if (bResult)
{
START_CELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
this._P_Base_House.BeginTransaction(bTrans);
//生成任务
bResult = this.ManageCreate(mSYS_USER, 0, MANAGE_TYPE_CODE, string.Empty, START_CELL_ID, mWH_CELL.CELL_ID, false, true, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
this._P_Base_House.CommitTransaction(bTrans);
return bResult;
}
//条件2:Double有货无任务且与下架物料一致,Normal有货有任务--选择Double实盘货位
strSql = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_STATUS = '{0}' and RUN_STATUS = 'Enable' and goods_id={2}
AND RUN_STATUS_NEAR = 'Selected' AND DEVICE_CODE IN
(SELECT START_DEVICE FROM IO_CONTROL_ROUTE WHERE
CONTROL_ROUTE_TYPE =2 AND CONTROL_ROUTE_STATUS =1 AND END_DEVICE ='{1}')",
cell_status, mWH_CELL.CELL_CODE, GoodsId);
dt = this.GetList(strSql);
bResult = dt.Rows.Count > 0;
if (bResult)
{
START_CELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
this._P_Base_House.BeginTransaction(bTrans);
//生成任务
bResult = this.ManageCreate(mSYS_USER, 0, MANAGE_TYPE_CODE, string.Empty, START_CELL_ID, mWH_CELL.CELL_ID, false, true, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
this._P_Base_House.CommitTransaction(bTrans);
return bResult;
}
//条件3:Double无任务,Normal有货无任务且与下架物料一致--选择Normal实盘货位
strSql = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE goods_id_near={2} and
RUN_STATUS in ('Enable','Disable') AND CELL_STATUS_NEAR = '{0}'
and RUN_STATUS_NEAR = 'Enable' AND DEVICE_CODE IN
(SELECT START_DEVICE FROM IO_CONTROL_ROUTE WHERE CONTROL_ROUTE_TYPE =2
AND CONTROL_ROUTE_STATUS =1 AND END_DEVICE ='{1}')",
cell_status, mWH_CELL.CELL_CODE, GoodsId);
dt = this.GetList(strSql);
bResult = dt.Rows.Count > 0;
if (bResult)
{
START_CELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]);
this._P_Base_House.BeginTransaction(bTrans);
//生成任务
bResult = this.ManageCreate(mSYS_USER, 0, MANAGE_TYPE_CODE, string.Empty, START_CELL_ID, mWH_CELL.CELL_ID, false, true, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
this._P_Base_House.CommitTransaction(bTrans);
return bResult;
}
//空托盘申请出库顺序Normal,Near,Far
strSql = string.Format(@"SELECT * FROM V_STORAGE_LIST
WHERE RUN_STATUS ='Enable' AND CELL_STATUS ='Full' AND GOODS_TYPE_ID =1 and area_type='LiKu'
AND GOODS_CODE = '{1}' AND DEVICE_CODE IN (SELECT START_DEVICE FROM IO_CONTROL_ROUTE
WHERE CONTROL_ROUTE_TYPE =2 AND CONTROL_ROUTE_STATUS =1 AND END_DEVICE ={0})
ORDER BY CELL_FORK_TYPE desc", mWH_CELL.CELL_CODE, GOODS_CODE);
//优先巷道
dt = this.GetList(strSql);
if (dt.Rows.Count == 0)
{
bResult = false;
sResult = "设备故障,请检查!";
return bResult;
}
else
{
//单伸货位和近端货位直接出库
if (dt.Rows[0]["CELL_FORK_TYPE"].ToString() == "Normal" || dt.Rows[0]["CELL_FORK_TYPE"].ToString() == "Near")
{
START_CELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID"]);
}
else
{
bResult = this.DoubleStockJudge(mWH_CELL.CELL_CODE, GOODS_CODE, out SCELL_ID, out sResult);
if (bResult)
{
START_CELL_ID = SCELL_ID;
}
else
{
bResult = false;
sResult = "库区设备故障,请检查!";
return bResult;
}
}
}
}
this._P_Base_House.BeginTransaction(bTrans);
//生成任务
bResult = this.ManageCreate(mSYS_USER, 0, MANAGE_TYPE_CODE, string.Empty, START_CELL_ID, mWH_CELL.CELL_ID, false, true, false, out sResult);
if (!bResult)
{
this._P_Base_House.RollBackTransaction(bTrans);
return bResult;
}
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 new 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)
{
sResult = string.Format("未能找到任务{0}", MANAGE_ID.ToString());
return bResult;
}
lock (lockObj)
{
try
{
this._P_Base_House.BeginTransaction(bTrans);
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);
if (mWH_CELL_START != null && (mWH_CELL_START.CELL_TYPE.TrimEnd() == Enum.CELL_TYPE.Cell.ToString()
|| mWH_CELL_START.CELL_STORAGE_TYPE.TrimEnd() == Enum.CELL_STORAGE_TYPE.Single.ToString()))
{
bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.START_CELL_ID,
SiaSun.LMS.Enum.CELL_STATUS.Nohave.ToString(),
SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(),
out sResult);
}
if (!bResult)
{
sResult = string.Format("更新起始位置{0}状态错误\n", mMANAGE_MAIN.START_CELL_ID.ToString());
return bResult;
}
if (mWH_CELL_END != null && (mWH_CELL_END.CELL_TYPE.TrimEnd() == Enum.CELL_TYPE.Cell.ToString()
|| mWH_CELL_END.CELL_STORAGE_TYPE.TrimEnd() == Enum.CELL_STORAGE_TYPE.Single.ToString()))
{
bResult = this._S_CellService.CellUpdateStatus(mMANAGE_MAIN.END_CELL_ID,
SiaSun.LMS.Enum.CELL_STATUS.Full.ToString(),
SiaSun.LMS.Enum.RUN_STATUS.Enable.ToString(),
out sResult);
}
if (!bResult)
{
sResult = string.Format("更新终止位置{0}状态错误\n", mMANAGE_MAIN.END_CELL_ID.ToString());
return bResult;
}
bResult = this.Invoke("StorageBase", "StorageMove", new object[] { mMANAGE_MAIN.STOCK_BARCODE, mMANAGE_MAIN.START_CELL_ID, mMANAGE_MAIN.END_CELL_ID }, out sResult);
if (!bResult)
{
sResult = string.Format("库存处理错误-{0}", sResult);
return bResult;
}
bResult = this.Invoke("StorageBase", "StorageDelete", new object[] { MANAGE_ID }, out sResult);
if (!bResult)
{
sResult = string.Format("库存处理错误-{0}", sResult);
return bResult;
}
bResult = base.ManageComplete(MANAGE_ID, false, out sResult);
string sTemp = string.Empty;
this._S_LEDService.AddLedLineTxt(mWH_CELL_END.CELL_CODE, 2, string.Format("{0} 出库完成", mMANAGE_MAIN.STOCK_BARCODE), out sTemp);
}
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;
}
/// <summary>双申,条件5生成移库任务
/// 双申,条件5生成移库任务
public bool DoubleManageMove(int CELL_ID_NEAR, string CellHeight, int iManageLevel, out string sResult)
{
bool bResult = true;
sResult = string.Empty;
string PnOrder = string.Empty;
string strResult = string.Empty;
int range = 0;
int rangemin = 0;
int[] rangeAry = null;
DataTable ManageMoveCellNormal = null;
DataTable ManageMoveCellDouble = null;
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = new Model.MANAGE_MAIN();
Model.WH_CELL mWH_CELL = this._P_WH_CELL.GetModel(CELL_ID_NEAR);
//通过近端货位检索近端物料的生产指令号
DataTable dtSlist = this.GetList(string.Format("select goods_id, goods_property1 from v_storage_list where cell_id={0}", CELL_ID_NEAR));
if (dtSlist.Rows.Count == 0)
{
sResult = string.Format("近端货位'{0}'无库存信息", mWH_CELL.CELL_CODE);
AddLog(sResult);
return false;
}
//PnOrder = dtSlist.Rows[0]["GOODS_PROPERTY1"].ToString();//可以不选
PnOrder = string.Format(@" goods_id = {0} and {1} ", Convert.ToInt32(dtSlist.Rows[0]["GOODS_ID"].ToString()), string.IsNullOrEmpty(dtSlist.Rows[0]["GOODS_PROPERTY1"].ToString()) ? " 1=1 " : string.Format(@"goods_property1 = {0}", dtSlist.Rows[0]["GOODS_PROPERTY1"].ToString()));
if (mWH_CELL.CELL_STATUS == "Full")
{
//双伸货位移库近端保证生产指令号配对
ManageMoveCellNormal = this.GetList(string.Format(@"select *from V_WH_CELL_DOUBLE_TO_NORMAL
where cell_model ='{1}' and cell_status in ('Full','Forbiden')
and run_status in ('Enable','Disable') and device_code = '{0}'
and cell_status_near = 'Nohave' and run_status_near = 'Enable'
and goods_property1='{2}' ORDER BY cell_y, cell_x,cell_z",
mWH_CELL.DEVICE_CODE, CellHeight, PnOrder));
if (ManageMoveCellNormal.Rows.Count == 0)
{
//双伸货位移库近端
ManageMoveCellNormal = this.GetList(string.Format(@"select *from V_WH_CELL_DOUBLE_TO_NORMAL
where cell_model ='{1}' and cell_status in ('Full','Forbiden')
and run_status in ('Enable','Disable') and device_code = '{0}'
and cell_status_near = 'Nohave' and run_status_near = 'Enable'
ORDER BY cell_y, cell_x,cell_z",
mWH_CELL.DEVICE_CODE, CellHeight));
if (ManageMoveCellNormal.Rows.Count == 0)
{
//双伸货位移库到远端
ManageMoveCellDouble = this.GetList(string.Format(@"select * from V_WH_CELL_DOUBLE_TO_NORMAL
where cell_model ='{1}' and cell_status = 'Nohave'
and run_status = 'Enable' and device_code = '{0}'
and cell_status_near = 'Nohave' and run_status_near = 'Enable'
ORDER BY cell_y, cell_x,cell_z", mWH_CELL.DEVICE_CODE, CellHeight));
rangeAry = new int[ManageMoveCellDouble.Rows.Count];
for (int i = 0; i < ManageMoveCellDouble.Rows.Count; i++)
{
range = Math.Abs(mWH_CELL.CELL_X - Convert.ToInt32(ManageMoveCellDouble.Rows[i]["CELL_X"])) + Math.Abs(mWH_CELL.CELL_Y - Convert.ToInt32(ManageMoveCellDouble.Rows[i]["CELL_Y"]));
rangeAry[i] = range;
}
if (ManageMoveCellDouble.Rows.Count > 0)
{
rangemin = SiaSun.LMS.Common.StringUtil.CheckMin(rangeAry);
}
}
else
{
rangeAry = new int[ManageMoveCellNormal.Rows.Count];
for (int i = 0; i < ManageMoveCellNormal.Rows.Count; i++)
{
range = Math.Abs(mWH_CELL.CELL_X - Convert.ToInt32(ManageMoveCellNormal.Rows[i]["CELL_X_NEAR"])) + Math.Abs(mWH_CELL.CELL_Y - Convert.ToInt32(ManageMoveCellNormal.Rows[i]["CELL_Y_NEAR"]));
rangeAry[i] = range;
}
rangemin = SiaSun.LMS.Common.StringUtil.CheckMin(rangeAry);
}
}
else
{
rangeAry = new int[ManageMoveCellNormal.Rows.Count];
for (int i = 0; i < ManageMoveCellNormal.Rows.Count; i++)
{
range = Math.Abs(mWH_CELL.CELL_X - Convert.ToInt32(ManageMoveCellNormal.Rows[i]["CELL_X_NEAR"])) + Math.Abs(mWH_CELL.CELL_Y - Convert.ToInt32(ManageMoveCellNormal.Rows[i]["CELL_Y_NEAR"]));
rangeAry[i] = range;
}
rangemin = SiaSun.LMS.Common.StringUtil.CheckMin(rangeAry);
}
}
else if (mWH_CELL.CELL_STATUS == "Pallet")
{
ManageMoveCellNormal = this.GetList(string.Format(@"select *from V_WH_CELL_DOUBLE_TO_NORMAL
where cell_model ='{1}' and cell_status in ('Pallet','Forbiden') and run_status in ('Enable','Disable')
and device_code = '{0}' and cell_status_near = 'Nohave' and run_status_near = 'Enable'
ORDER BY cell_y ASC, cell_x,cell_z", mWH_CELL.DEVICE_CODE, CellHeight));
if (ManageMoveCellNormal.Rows.Count == 0)
{
ManageMoveCellDouble = this.GetList(string.Format(@"select * from V_WH_CELL_DOUBLE_TO_NORMAL
where cell_model ='{1}' and cell_status = 'Nohave' and device_code = '{0}' and run_status = 'Enable' and
cell_status_near = 'Nohave' and run_status_near = 'Enable'
ORDER BY cell_y ASC, cell_x,cell_z", mWH_CELL.DEVICE_CODE, CellHeight));
if (ManageMoveCellDouble.Rows.Count ==0)
{
ManageMoveCellNormal = this.GetList(string.Format(@"select *from V_WH_CELL_DOUBLE_TO_NORMAL
where cell_model ='{1}' and cell_status ='Full' and run_status in ('Enable','Disable')
and device_code = '{0}' and cell_status_near = 'Nohave' and run_status_near = 'Enable'
ORDER BY cell_y ASC, cell_x,cell_z", mWH_CELL.DEVICE_CODE, CellHeight));
if (ManageMoveCellNormal.Rows.Count > 0)
{
rangeAry = new int[ManageMoveCellNormal.Rows.Count];
for (int i = 0; i < ManageMoveCellNormal.Rows.Count; i++)
{
range = Math.Abs(mWH_CELL.CELL_X - Convert.ToInt32(ManageMoveCellNormal.Rows[i]["CELL_X_NEAR"])) + Math.Abs(mWH_CELL.CELL_Y - Convert.ToInt32(ManageMoveCellNormal.Rows[i]["CELL_Y_NEAR"]));
rangeAry[i] = range;
}
rangemin = SiaSun.LMS.Common.StringUtil.CheckMin(rangeAry);
}
}
else
{
rangeAry = new int[ManageMoveCellDouble.Rows.Count];
for (int i = 0; i < ManageMoveCellDouble.Rows.Count; i++)
{
range = Math.Abs(mWH_CELL.CELL_X - Convert.ToInt32(ManageMoveCellDouble.Rows[i]["CELL_X"])) + Math.Abs(mWH_CELL.CELL_Y - Convert.ToInt32(ManageMoveCellDouble.Rows[i]["CELL_Y"]));
rangeAry[i] = range;
}
rangemin = SiaSun.LMS.Common.StringUtil.CheckMin(rangeAry);
}
}
else
{
rangeAry = new int[ManageMoveCellNormal.Rows.Count];
for (int i = 0; i < ManageMoveCellNormal.Rows.Count; i++)
{
range = Math.Abs(mWH_CELL.CELL_X - Convert.ToInt32(ManageMoveCellNormal.Rows[i]["CELL_X_NEAR"])) + Math.Abs(mWH_CELL.CELL_Y - Convert.ToInt32(ManageMoveCellNormal.Rows[i]["CELL_Y_NEAR"]));
rangeAry[i] = range;
}
rangemin = SiaSun.LMS.Common.StringUtil.CheckMin(rangeAry);
}
}
else
{
ManageMoveCellNormal = this.GetList(string.Format(@"select * from V_WH_CELL_DOUBLE_TO_NORMAL
where cell_model ='{1}' and cell_status in ('Bullet','Forbiden')
and run_status in ('Enable','Disable') and device_code = '{0}'
and cell_status_near = 'Nohave' and run_status_near = 'Enable'
ORDER BY cell_y ASC, cell_x,cell_z", mWH_CELL.DEVICE_CODE, CellHeight));
if (ManageMoveCellNormal.Rows.Count == 0)
{
ManageMoveCellDouble = this.GetList(string.Format(@"select * from V_WH_CELL_DOUBLE_TO_NORMAL
where cell_model ='{1}' and cell_status = 'Nohave' and device_code = '{0}'
and run_status = 'Enable' and cell_status_near = 'Nohave' and run_status_near = 'Enable'
ORDER BY cell_y ASC, cell_x,cell_z", mWH_CELL.DEVICE_CODE, CellHeight));
rangeAry = new int[ManageMoveCellDouble.Rows.Count];
for (int i = 0; i < ManageMoveCellDouble.Rows.Count; i++)
{
range = Math.Abs(mWH_CELL.CELL_X - Convert.ToInt32(ManageMoveCellDouble.Rows[i]["CELL_X"])) + Math.Abs(mWH_CELL.CELL_Y - Convert.ToInt32(ManageMoveCellDouble.Rows[i]["CELL_Y"]));
rangeAry[i] = range;
}
rangemin = SiaSun.LMS.Common.StringUtil.CheckMin(rangeAry);
}
else
{
rangeAry = new int[ManageMoveCellNormal.Rows.Count];
for (int i = 0; i < ManageMoveCellNormal.Rows.Count; i++)
{
range = Math.Abs(mWH_CELL.CELL_X - Convert.ToInt32(ManageMoveCellNormal.Rows[i]["CELL_X_NEAR"])) + Math.Abs(mWH_CELL.CELL_Y - Convert.ToInt32(ManageMoveCellNormal.Rows[i]["CELL_Y_NEAR"]));
rangeAry[i] = range;
}
rangemin = SiaSun.LMS.Common.StringUtil.CheckMin(rangeAry);
}
}
//近端有库存
DataTable ManageMove = this.GetList(string.Format(@"select * from V_STORAGE_LIST where cell_id = {0}", CELL_ID_NEAR));
if (ManageMove.Rows.Count > 0)
{
//优先移库到近端
if (ManageMoveCellNormal.Rows.Count > 0)
{
mMANAGE_MAIN.MANAGE_TYPE_CODE = "ManageMove";
mMANAGE_MAIN.STOCK_BARCODE = ManageMove.Rows[0]["STOCK_BARCODE"].ToString();
mMANAGE_MAIN.START_CELL_ID = Convert.ToInt32(ManageMove.Rows[0]["CELL_ID"]);
mMANAGE_MAIN.END_CELL_ID = Convert.ToInt32(ManageMoveCellNormal.Rows[rangemin]["CELL_ID_NEAR"]);
mMANAGE_MAIN.MANAGE_OPERATOR = "管理系统";
mMANAGE_MAIN.MANAGE_BEGIN_TIME = SiaSun.LMS.Common.StringUtil.GetDateTime();
mMANAGE_MAIN.MANAGE_STATUS = SiaSun.LMS.Enum.MANAGE_STATUS.WaitingSend.ToString();
//mMANAGE_MAIN.MANAGE_LEVEL = (iManageLevel + 8).ToString();
mMANAGE_MAIN.MANAGE_LEVEL = iManageLevel.ToString();
mMANAGE_MAIN.CELL_MODEL = CellHeight;
mMANAGE_MAIN.MANAGE_REMARK = string.Empty;
}
else if (ManageMoveCellDouble.Rows.Count > 0)
{
mMANAGE_MAIN.MANAGE_TYPE_CODE = "ManageMove";
mMANAGE_MAIN.STOCK_BARCODE = ManageMove.Rows[0]["STOCK_BARCODE"].ToString();
mMANAGE_MAIN.START_CELL_ID = Convert.ToInt32(ManageMove.Rows[0]["CELL_ID"]);
mMANAGE_MAIN.END_CELL_ID = Convert.ToInt32(ManageMoveCellDouble.Rows[rangemin]["CELL_ID_FAR"]);
mMANAGE_MAIN.MANAGE_OPERATOR = "自动移库";
mMANAGE_MAIN.MANAGE_BEGIN_TIME = SiaSun.LMS.Common.StringUtil.GetDateTime();
mMANAGE_MAIN.MANAGE_STATUS = SiaSun.LMS.Enum.MANAGE_STATUS.WaitingSend.ToString();
//mMANAGE_MAIN.MANAGE_LEVEL = (iManageLevel + 8).ToString();
mMANAGE_MAIN.MANAGE_LEVEL = iManageLevel.ToString();
mMANAGE_MAIN.CELL_MODEL = CellHeight;
mMANAGE_MAIN.MANAGE_REMARK = string.Empty;
}
else
{
sResult = string.Format("托盘号'{0}'未找到移库货位", ManageMove.Rows[0]["STOCK_BARCODE"].ToString());
AddLog(sResult);
return false;
}
}
else
{
sResult = string.Format("自动移库库存发生异常,货位'{0}'", mWH_CELL.CELL_CODE);
AddLog(sResult);
return false;
}
List<SiaSun.LMS.Model.MANAGE_LIST> lsMANAGE_LIST = new List<Model.MANAGE_LIST>();
for (int i = 0; i < ManageMove.Rows.Count; i++)
{
Model.MANAGE_LIST mANAGE_LIST = new Model.MANAGE_LIST()
{
GOODS_ID = Convert.ToInt32(ManageMove.Rows[i]["GOODS_ID"]),
STORAGE_LIST_ID = Convert.ToInt32(ManageMove.Rows[i]["STORAGE_LIST_ID"]),
GOODS_PROPERTY1 = ManageMove.Rows[i]["GOODS_PROPERTY1"].ToString(),
GOODS_PROPERTY2 = ManageMove.Rows[i]["GOODS_PROPERTY2"].ToString(),
GOODS_PROPERTY3 = ManageMove.Rows[i]["GOODS_PROPERTY3"].ToString(),
GOODS_PROPERTY4 = ManageMove.Rows[i]["GOODS_PROPERTY4"].ToString(),
MANAGE_LIST_QUANTITY = Convert.ToInt32(ManageMove.Rows[i]["STORAGE_LIST_QUANTITY"])
};
lsMANAGE_LIST.Add(mANAGE_LIST);
}
bResult = new ManageMove().ManageCreate(mMANAGE_MAIN, lsMANAGE_LIST, false, true, false, true, out strResult);
if (!bResult)
{
sResult = string.Format("托盘号'{0}'自动生成移库任务失败", ManageMove.Rows[0]["STOCK_BARCODE"].ToString());
AddLog(sResult);
return false;
}
return bResult;
}
/// <summary>双申,满足货物出库条件的双深
/// 双申,满足货物出库条件的双深
public bool DoubleManageJudge(string END_DEVICE_CODE, int STRAT_CELL_ID, int iManageLevel, out int SCELL_ID, out string sResult)
{
bool bResult = true;
sResult = string.Empty;
DataTable dt = null;
string strSQL = string.Empty;
SCELL_ID = 0;
if (END_DEVICE_CODE.StartsWith("140"))
{
END_DEVICE_CODE = "38001";
}
Model.WH_CELL mWH_CELL_START = this._P_WH_CELL.GetModel(STRAT_CELL_ID);
string CellHeight = mWH_CELL_START.CELL_MODEL;
//条件1.Double无货无任务,Normal有货无任务且与下架物料一致,选择Normal实盘货位
strSQL = string.Format(@"SELECT top 1 *FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_ID_NEAR = {0}
AND CELL_STATUS_NEAR IN ('Full','Pallet') and RUN_STATUS_NEAR = 'Enable'",
STRAT_CELL_ID);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]);
return bResult;
}
//条件2.Double有货无任务且与下架物料一致,Normal无货无任务,选择Double实盘货位
strSQL = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_ID_FAR = {0} AND CELL_STATUS IN ('Full','Pallet') and RUN_STATUS = 'Enable'
AND CELL_STATUS_NEAR = 'Nohave' and RUN_STATUS_NEAR IN ('Enable','Disable')",
STRAT_CELL_ID);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
return bResult;
}
//条件3.Double有货无任务且与下架物料一致,Normal有货有任务,选择Double实盘货位
strSQL = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_ID_FAR = {0} AND CELL_STATUS IN ('Full','Pallet') and RUN_STATUS = 'Enable'
AND CELL_STATUS_NEAR IN ('Full','Pallet') and RUN_STATUS_NEAR = 'Selected'",
STRAT_CELL_ID);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
return bResult;
}
//条件4.Double无任务,Normal有货无任务且与下架物料一致,选择Normal实盘货位
//strSQL = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
// CELL_ID_NEAR = {0} AND RUN_STATUS in ('Enable','Disable')
// AND CELL_STATUS_NEAR = 'Full' and RUN_STATUS_NEAR = 'Enable'",
// STRAT_CELL_ID);
//dt = this.GetList(strSQL);
//bResult = dt.Rows.Count > 0;
//if (bResult)
//{
// SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]);
// return bResult;
//}
//条件5.Double有货无任务且与下架物料一致,Normal有货无任务且与下架物料不一致,选择Double实盘货位。
//此时需要优先下达Normal移库任务,然后下达Double下架任务。
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_ID_FAR = {0} AND CELL_STATUS IN ('Full','Pallet') and RUN_STATUS = 'Enable'
AND CELL_STATUS_NEAR IN ('Full','Pallet') and RUN_STATUS_NEAR = 'Enable'
AND DEVICE_CODE IN (SELECT START_DEVICE FROM IO_CONTROL_ROUTE WHERE
CONTROL_ROUTE_TYPE=2 AND END_DEVICE='{1}' AND CONTROL_ROUTE_STATUS=1)",
STRAT_CELL_ID, END_DEVICE_CODE);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
bResult = this.DoubleManageMove(Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]), CellHeight, iManageLevel, out sResult);
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
return bResult;
}
else
{
bResult = false;
sResult = string.Format("未找到移库货位{0}", sResult);
//this._P_Base_House.RollBackTransaction(bTrans);
AddLog(sResult);
return bResult;
}
}
else
{
bResult = false;
sResult = string.Format("该托盘不符合出库条件,起始货位:{0}", mWH_CELL_START.DEVICE_CODE);
//this._P_Base_House.RollBackTransaction(bTrans);
AddLog(sResult);
return bResult;
}
//return bResult;
}
/// <summary>双申,满足母托盘出库条件的双深
/// 双申,满足母托盘出库条件的双深
public bool DoubleStockJudge(string END_DEVICE_CODE, string GoodsCode, out int SCELL_ID, out string sResult)
{
bool bResult = true;
sResult = string.Empty;
DataTable dt = null;
string cell_status = "";
string strSQL = string.Empty;
SCELL_ID = 0;
int GoodsId = 0;
if (GoodsCode == "GTP")
{
cell_status = "Pallet";
}
else
{
cell_status = "Full";
}
Model.GOODS_MAIN gOODS_MAIN = this._P_GOODS_MAIN.GetModel(GoodsCode);
if (gOODS_MAIN != null)
{
GoodsId = gOODS_MAIN.GOODS_ID;
}
//条件1.Double无货无任务,Normal有货无任务且与下架物料一致,选择Normal实盘货位
strSQL = string.Format(@"SELECT top 1 *FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_STATUS = 'Nohave' and RUN_STATUS = 'Enable'
AND CELL_STATUS_NEAR = '{0}' and goods_id_near={1}
and RUN_STATUS_NEAR = 'Enable'", cell_status, GoodsId);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]);
return bResult;
}
//条件2.Double有货无任务且与下架物料一致,Normal无货无任务,选择Double实盘货位
strSQL = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_STATUS = '{0}' and RUN_STATUS = 'Enable' and goods_id={1}
AND CELL_STATUS_NEAR = 'Nohave' and RUN_STATUS_NEAR = 'Enable'",
cell_status, GoodsId);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
return bResult;
}
//条件3.Double有货无任务且与下架物料一致,Normal有货有任务,选择Double实盘货位
strSQL = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_STATUS = '{0}' and RUN_STATUS = 'Enable'
AND RUN_STATUS_NEAR = 'Selected' and cell_status_near in ('Pallet', 'Full') and goods_id={1}",
cell_status, GoodsId);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
return bResult;
}
//条件4.Double无任务,Normal有货无任务且与下架物料一致,选择Normal实盘货位
strSQL = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
RUN_STATUS in ('Enable','Disable') and goods_id_near={1}
AND CELL_STATUS_NEAR = '{0}' and RUN_STATUS_NEAR = 'Enable'",
cell_status, GoodsId);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]);
return bResult;
}
//条件5.Double有货无任务且与下架物料一致,Normal有货无任务且与下架物料不一致,选择Double实盘货位。
//此时需要优先下达Normal移库任务,然后下达Double下架任务。
strSQL = string.Format(@"SELECT top 1 * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_STATUS IN ('{0}') and RUN_STATUS = 'Enable' and goods_id={1}
AND CELL_STATUS_NEAR IN ('{0}') and RUN_STATUS_NEAR = 'Enable'
AND DEVICE_CODE IN (SELECT START_DEVICE FROM IO_CONTROL_ROUTE WHERE
CONTROL_ROUTE_TYPE=2 AND END_DEVICE='{2}' AND CONTROL_ROUTE_STATUS=1)",
cell_status, GoodsId, END_DEVICE_CODE);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
bResult = this.DoubleManageMove(Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]), "low", 0, out sResult);
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
return bResult;
}
else
{
bResult = false;
sResult = string.Format("未找到移库货位{0}", sResult);
//this._P_Base_House.RollBackTransaction(bTrans);
AddLog(sResult);
return bResult;
}
}
else
{
bResult = false;
sResult = string.Format("该托盘不符合出库条件");
//this._P_Base_House.RollBackTransaction(bTrans);
AddLog(sResult);
return bResult;
}
//return bResult;
}
/// <summary>双申,满足空托盘出库条件的双深
/// 双申,满足空托盘出库条件的双深
public bool DoubleManageStockJudge(string END_DEVICE_CODE, int STRAT_CELL_ID, out int SCELL_ID, out string sResult)
{
bool bResult = true;
sResult = string.Empty;
DataTable dt = null;
string strSQL = string.Empty;
SCELL_ID = 0;
Model.WH_CELL mWH_CELL_START = this._P_WH_CELL.GetModel(STRAT_CELL_ID);
string CellHeight = mWH_CELL_START.CELL_MODEL;
//条件1.Double无货无任务,Normal有货无任务且与下架物料一致,选择Normal实盘货位
strSQL = string.Format(@"SELECT *FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_ID_NEAR = {0}
AND CELL_STATUS_NEAR = 'Pallet' and RUN_STATUS_NEAR = 'Enable'",
STRAT_CELL_ID);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]);
return bResult;
}
//条件2.Double有货无任务且与下架物料一致,Normal无货无任务,选择Double实盘货位
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_ID_FAR = {0} AND CELL_STATUS = 'Pallet' and RUN_STATUS = 'Enable'
AND CELL_STATUS_NEAR = 'Nohave' and RUN_STATUS_NEAR = 'Enable'",
STRAT_CELL_ID);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
return bResult;
}
//条件3.Double有货无任务且与下架物料一致,Normal有货有任务,选择Double实盘货位
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_ID_FAR = {0} AND CELL_STATUS = 'Pallet' and RUN_STATUS = 'Enable'
AND CELL_STATUS_NEAR in ('Pallet', 'Full') and RUN_STATUS_NEAR = 'Selected'",
STRAT_CELL_ID);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
return bResult;
}
//条件4.Double无任务,Normal有货无任务且与下架物料一致,选择Normal实盘货位
//strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
// CELL_ID_NEAR = {0} AND RUN_STATUS in ('Enable','Disable')
// AND CELL_STATUS_NEAR = 'Pallet' and RUN_STATUS_NEAR = 'Enable'",
// STRAT_CELL_ID);
//dt = this.GetList(strSQL);
//bResult = dt.Rows.Count > 0;
//if (bResult)
//{
// SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]);
// return bResult;
//}
//条件5.Double有货无任务且与下架物料一致,Normal有货无任务且与下架物料不一致,选择Double实盘货位。
//此时需要优先下达Normal移库任务,然后下达Double下架任务。
strSQL = string.Format(@"SELECT * FROM V_WH_CELL_DOUBLE_TO_NORMAL WHERE
CELL_ID_FAR = {0} AND CELL_STATUS='Pallet' and RUN_STATUS = 'Enable'
AND CELL_STATUS_NEAR IN ('Full','Pallet') and RUN_STATUS_NEAR = 'Enable'
AND DEVICE_CODE IN (SELECT START_DEVICE FROM IO_CONTROL_ROUTE WHERE
CONTROL_ROUTE_TYPE=2 AND END_DEVICE='{1}' AND CONTROL_ROUTE_STATUS=1)",
STRAT_CELL_ID, END_DEVICE_CODE);
dt = this.GetList(strSQL);
bResult = dt.Rows.Count > 0;
if (bResult)
{
bResult = this.DoubleManageMove(Convert.ToInt32(dt.Rows[0]["CELL_ID_NEAR"]), CellHeight, 0, out sResult);
if (bResult)
{
SCELL_ID = Convert.ToInt32(dt.Rows[0]["CELL_ID_FAR"]);
return bResult;
}
else
{
bResult = false;
sResult = string.Format("未找到移库货位{0}", sResult);
//this._P_Base_House.RollBackTransaction(bTrans);
AddLog(sResult);
return bResult;
}
}
else
{
bResult = false;
sResult = string.Format("该托盘不符合出库条件,起始货位:{0}", mWH_CELL_START.DEVICE_CODE);
//this._P_Base_House.RollBackTransaction(bTrans);
AddLog(sResult);
return bResult;
}
//return bResult;
}
}
}