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.
248 lines
12 KiB
248 lines
12 KiB
using System;
|
|
using System.Reflection;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
|
|
namespace SiaSun.LMS.Implement
|
|
{
|
|
/// <summary>
|
|
/// 申请出库
|
|
/// </summary>
|
|
public class ApplyOut : ApplyBase
|
|
{
|
|
public bool ApplyHandle(Model.IO_CONTROL_APPLY mIO_CONTROL_APPLY, out string sResult)
|
|
{
|
|
bool bResult = true;
|
|
sResult = string.Empty;
|
|
int START_CELL_ID = 0;
|
|
int end_cell_id = 0;
|
|
string strSQL=string.Empty;
|
|
|
|
string applycell = string.Empty;
|
|
string sql4=string.Empty;
|
|
string sql5=string.Empty;
|
|
string sql3= string.Empty;
|
|
DataTable dt4;
|
|
DataTable dt5;
|
|
try
|
|
{
|
|
//string STOCK_BARCODE =mIO_CONTROL_APPLY.STOCK_BARCODE.ToUpper();
|
|
string[] GOODS_PROPERTY1 = new string[18];
|
|
|
|
|
|
applycell = "0" + mIO_CONTROL_APPLY.DEVICE_CODE.TrimEnd().Substring(1, 1) + "-"
|
|
+ mIO_CONTROL_APPLY.DEVICE_CODE.TrimEnd().Substring(2, 2) + "-" + "0"
|
|
+ mIO_CONTROL_APPLY.DEVICE_CODE.TrimEnd().Substring(4, 1);
|
|
|
|
this._log.Fatal(string.Format("成功申请{0} {1} {2} {3}", mIO_CONTROL_APPLY.CONTROL_APPLY_ID, applycell, mIO_CONTROL_APPLY.CONTROL_ID,mIO_CONTROL_APPLY.DEVICE_CODE));
|
|
|
|
//查申请翻转货位的库存
|
|
string sql1 = string.Format("select * from v_storage_list where CELL_CODE='{0}'", applycell);
|
|
DataTable dt1 = this.GetList(sql1);
|
|
//查申请站台ID
|
|
if (mIO_CONTROL_APPLY.DEVICE_CODE.Equals("12001")|| mIO_CONTROL_APPLY.DEVICE_CODE.Equals("12002") || mIO_CONTROL_APPLY.DEVICE_CODE.Equals("12003"))
|
|
{
|
|
sql3 = string.Format("select * from wh_cell where cell_code='{0}'", mIO_CONTROL_APPLY.DEVICE_CODE);
|
|
}
|
|
else
|
|
{
|
|
sql3 = string.Format("select * from wh_cell where cell_code='{0}'", applycell);
|
|
|
|
}
|
|
DataTable dt3 = this.GetList(sql3);
|
|
|
|
#region 查管理和调度任务
|
|
if (!string.IsNullOrEmpty(mIO_CONTROL_APPLY.STOCK_BARCODE))
|
|
{
|
|
//查管理任务
|
|
sql4 = string.Format("select * from manage_main where stock_barcode='{0}'", mIO_CONTROL_APPLY.STOCK_BARCODE);
|
|
dt4 = this.GetList(sql4);
|
|
//查调度任务
|
|
sql5 = string.Format("select * from io_control where stock_barcode='{0}'", mIO_CONTROL_APPLY.STOCK_BARCODE);
|
|
dt5 = this.GetList(sql5);
|
|
}
|
|
else
|
|
{
|
|
//查管理任务
|
|
sql4 = string.Format("select * from manage_main where stock_barcode='{0}'", mIO_CONTROL_APPLY.STOCK_BARCODE);
|
|
dt4 = this.GetList(sql4);
|
|
//查调度任务
|
|
sql5 = string.Format("select * from io_control where stock_barcode='{0}'", mIO_CONTROL_APPLY.STOCK_BARCODE);
|
|
dt5 = this.GetList(sql5);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 查CELL_ID
|
|
///查CELL_ID
|
|
string sql7 = string.Format("SELECT CELL_ID FROM WH_CELL WHERE CELL_CODE = '{0}'",mIO_CONTROL_APPLY.DEVICE_CODE);
|
|
DataTable dt7 = this.GetList(sql7);
|
|
#endregion
|
|
|
|
//查翻转机构库存,CELL_LOGICAL_NAME是FZ就是翻转货位
|
|
string sqlfz = string.Format("select * from wh_cell where cell_status='Nohave' and run_status='Enable' and CELL_LOGICAL_NAME = 'FZ'");
|
|
DataTable dtfz = this.GetList(sqlfz);
|
|
///查库内空盘数量,如果无,就回库
|
|
string sql8 = string.Format("select * from v_storage_list where CELL_STATUS='Pallet' and AREA_TYPE = 'LiKu'");
|
|
DataTable dt8 = this.GetList(sql8);
|
|
///查库内空盘数量,如果无,就回库
|
|
string sql9 = string.Format("select * from v_manage where manage_type_code='StockIn'");
|
|
DataTable dt9 = this.GetList(sql9);
|
|
///查库内空盘入库数量
|
|
string sqlwj = string.Format("select * from WH_CELL where logic_id='1' and cell_status='Nohave' and run_status='Enable'");
|
|
DataTable dt_wj = this.GetList(sqlwj);
|
|
string STOCK_BARCODE = mIO_CONTROL_APPLY.STOCK_BARCODE.TrimEnd();
|
|
///前几位是箱码,要把箱码长度去掉
|
|
for (int i=0; i<STOCK_BARCODE.Length-22; i++)
|
|
{
|
|
string strSQL1 = string.Format(@"select * from v_storage_list where
|
|
goods_property6='已翻转' and
|
|
run_status!='selected' and
|
|
goods_property1='{0}' and goods_property2='{1}' order by update_time",
|
|
/*0 方向 L R*/"L",
|
|
/*2*/mIO_CONTROL_APPLY.STOCK_BARCODE.Substring(21, 1));
|
|
string strSQL2 = string.Format(@"select * from v_storage_list where
|
|
goods_property6='已翻转' and
|
|
run_status!='selected' and
|
|
goods_property1='{0}' and goods_property2='{1}' order by update_time",
|
|
/*0 方向 L R*/"R",
|
|
/*2*/mIO_CONTROL_APPLY.STOCK_BARCODE.Substring(21, 1));
|
|
int bb = (STOCK_BARCODE.Length - 21) / 2;
|
|
|
|
DataTable dtstorage1 = base.GetList(strSQL1);
|
|
DataTable dtstorage2 = base.GetList(strSQL2);
|
|
if (i == 0)
|
|
{
|
|
if (dtstorage1.Rows.Count < bb || dtstorage2.Rows.Count < bb)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("库存不足");
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
strSQL = string.Format(@"select * from v_storage_list where
|
|
goods_property6='已翻转' and
|
|
run_status!='selected' and
|
|
goods_property1='{0}' and goods_property2='{1}' order by update_time",
|
|
/*0 方向 L R*/mIO_CONTROL_APPLY.STOCK_BARCODE.Substring(22+i, 1),
|
|
/*2*/mIO_CONTROL_APPLY.STOCK_BARCODE.Substring(21, 1));
|
|
|
|
// int aa = (STOCK_BARCODE.Length - 21) / 2;
|
|
DataTable dtstorage = base.GetList(strSQL);
|
|
|
|
//if (dtstorage.Rows.Count < STOCK_BARCODE.Length - 21)
|
|
//{
|
|
// bResult = false;
|
|
|
|
// sResult = string.Format("库存不足");
|
|
|
|
// return bResult;
|
|
//}
|
|
string CELL_MODEL = string.Empty;
|
|
////电气申请出盘 16003绑定12002
|
|
if (mIO_CONTROL_APPLY.DEVICE_CODE == "12002")
|
|
{
|
|
//调用出库managedownout
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = new Model.MANAGE_MAIN();
|
|
List<Model.MANAGE_LIST> listMANAGE_LIST = new List<Model.MANAGE_LIST>();
|
|
Model.MANAGE_LIST mANAGE_LIST = new Model.MANAGE_LIST();
|
|
|
|
mMANAGE_MAIN.MANAGE_TYPE_CODE = "ManageDownOut";
|
|
|
|
mMANAGE_MAIN.STOCK_BARCODE = dtstorage.Rows[0]["STOCK_BARCODE"].ToString();
|
|
|
|
mMANAGE_MAIN.CELL_MODEL = "0";
|
|
|
|
mMANAGE_MAIN.START_CELL_ID =Convert.ToInt32(dtstorage.Rows[0]["CELL_ID"]);
|
|
|
|
mMANAGE_MAIN.END_CELL_ID = 13210;
|
|
|
|
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.FULL_FLAG = "1";
|
|
|
|
mMANAGE_MAIN.MANAGE_LEVEL = string.Empty;
|
|
|
|
mMANAGE_MAIN.MANAGE_REMARK = string.Empty;
|
|
|
|
////根据物料条码里面哪几位能看出是什么物料,获取goods_id
|
|
mANAGE_LIST.GOODS_ID = Convert.ToInt32(dtstorage.Rows[0]["GOODS_ID"]);
|
|
|
|
mANAGE_LIST.MANAGE_ID = 0;
|
|
mANAGE_LIST.PLAN_LIST_ID = 0;
|
|
mANAGE_LIST.MANAGE_LIST_QUANTITY = 1;
|
|
mANAGE_LIST.MANAGE_LIST_REMARK = "";
|
|
mANAGE_LIST.STORAGE_LIST_ID = Convert.ToInt32(dtstorage.Rows[0]["STORAGE_LIST_ID"]);
|
|
mANAGE_LIST.MANAGE_LIST_ID = 0;
|
|
mANAGE_LIST.GOODS_PROPERTY1 = dtstorage.Rows[0]["GOODS_PROPERTY1"].ToString();
|
|
mANAGE_LIST.GOODS_PROPERTY2 = mIO_CONTROL_APPLY.STOCK_BARCODE.Substring(21, 1);
|
|
//出库时,给箱码,保存到出入库记录
|
|
mANAGE_LIST.GOODS_PROPERTY5 = mIO_CONTROL_APPLY.STOCK_BARCODE.Substring(0,21);
|
|
mANAGE_LIST.GOODS_PROPERTY6 = dtstorage.Rows[0]["GOODS_PROPERTY6"].ToString();
|
|
|
|
listMANAGE_LIST.Add(mANAGE_LIST);
|
|
|
|
|
|
////入到正常货位里面,logic_area=0传入,实际是用CELL_LOGIC_NAME来找的翻转货位,CELL表里面用CELL_LOGIC_NAME为FZ标记翻转货位,
|
|
bResult = new ManageDownOut().ManageCreate(mMANAGE_MAIN, listMANAGE_LIST, true, true, out sResult);
|
|
if (!bResult)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("托盘条码[{0}]未能生成出库任务!", mIO_CONTROL_APPLY.STOCK_BARCODE);
|
|
|
|
return bResult;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = ex.Message;
|
|
|
|
this._log.Fatal(string.Format("调用方法{0}发生异常。", MethodBase.GetCurrentMethod().Name), ex);
|
|
}
|
|
|
|
finally
|
|
{
|
|
if (!bResult)
|
|
{
|
|
////南侧入口申请失败或者东侧碟盘申请失败送到出口
|
|
//if (mIO_CONTROL_APPLY.DEVICE_CODE == "12094" )
|
|
//{
|
|
// this.CreateApplyExceptionTask(mIO_CONTROL_APPLY,"12097",sResult);
|
|
//}
|
|
////南侧入口申请失败或者东侧碟盘申请失败送到出口
|
|
//if (mIO_CONTROL_APPLY.DEVICE_CODE == "12052")
|
|
//{
|
|
// this.CreateApplyExceptionTask(mIO_CONTROL_APPLY, "12101", sResult);
|
|
//}
|
|
////ManageBase led = new ManageBase();
|
|
//// led.updateLedText(START_CELL_ID, 1, sResult);
|
|
|
|
}
|
|
//南侧入口申请失败或者东侧碟盘申请失败送到出口
|
|
//if (!sResult.Equals("路径不通或无可用巷道,查看是否有报警或货位已满"))
|
|
//{
|
|
this.WriteHisData(mIO_CONTROL_APPLY, sResult);
|
|
//}
|
|
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
}
|
|
}
|