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.
496 lines
19 KiB
496 lines
19 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using System.Data;
|
|
|
|
namespace SiaSun.LMS.WPFClient.TASK
|
|
{
|
|
public partial class ManagePlanDown_Out : AvalonDock.DocumentContent
|
|
{
|
|
int intPlanID = 0;
|
|
|
|
Model.MANAGE_TYPE mMANAGE_TYPE = null;
|
|
|
|
Model.PLAN_MAIN mPLAN_MAIN = null;
|
|
|
|
DataRowView[] listDataRowView = null;
|
|
|
|
string STORAGE_AREA_TYPE = string.Empty;
|
|
|
|
#region 构造函数
|
|
|
|
public ManagePlanDown_Out(int PLAN_ID, string MANAGE_TYPE_CODE, string AREA_TYPE)
|
|
{
|
|
InitializeComponent();
|
|
|
|
intPlanID = PLAN_ID;
|
|
|
|
STORAGE_AREA_TYPE = AREA_TYPE;
|
|
|
|
this.mMANAGE_TYPE = (Model.MANAGE_TYPE)MainApp._I_BaseService.GetModel("MANAGE_TYPE_SELECT_BY_MANAGE_TYPE_CODE", MANAGE_TYPE_CODE).RequestObject;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 系统方法
|
|
|
|
private void DocumentContent_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.InitManagePosotion(0);
|
|
|
|
if (intPlanID > 0)
|
|
{
|
|
mPLAN_MAIN = MainApp._I_PlanService.PlanGetModel(intPlanID);
|
|
|
|
if (mPLAN_MAIN == null)
|
|
{
|
|
MainApp._MessageDialog.Show(false, string.Format("计划索引[{0}]不存在", intPlanID));
|
|
}
|
|
}
|
|
|
|
this.PLAN_LIST_Bind(intPlanID);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MainApp._MessageDialog.ShowException(ex);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 自定义方法
|
|
|
|
private void InitManagePosotion( int goods_id)
|
|
{
|
|
//直接出库页面,不显示终止位置,不关联调度
|
|
if (this.mMANAGE_TYPE.MANAGE_TYPE_CODE.Equals(SiaSun.LMS.Enum.MANAGE_TYPE.ManageOut.ToString()))
|
|
{
|
|
this.ucManagePosition.Visibility = System.Windows.Visibility.Collapsed;
|
|
this.cbControl.IsChecked = false;
|
|
this.cbControl.Visibility = Visibility.Collapsed;
|
|
}
|
|
else
|
|
{
|
|
this.ucManagePosition.U_InitControl(mMANAGE_TYPE.MANAGE_TYPE_ID);
|
|
this.cbControl.IsChecked = true;
|
|
this.cbControl.Visibility = Visibility.Visible;
|
|
if (goods_id == 910)
|
|
{
|
|
this.ucManagePosition.U_END_POSITION_ID = 14596;
|
|
|
|
}
|
|
else
|
|
{
|
|
this.ucManagePosition.U_END_POSITION_ID = 13209;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Register_DataTable_Event()
|
|
{
|
|
//当输入列值改变后验证数据是否合法
|
|
foreach (TabItem tabItem in this.ucStorageGroup.tabSplitProperty.Items)
|
|
{
|
|
if (tabItem.HasContent)
|
|
{
|
|
DataTable tableSource = (tabItem.Content as UC.ucCommonDataGrid).U_DataSource.Table;
|
|
|
|
tableSource.ColumnChanged -= new DataColumnChangeEventHandler(table_ColumnChanged);
|
|
tableSource.ColumnChanged += new DataColumnChangeEventHandler(table_ColumnChanged);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void table_ColumnChanged(object sender, DataColumnChangeEventArgs e)
|
|
{
|
|
bool bResult = true;
|
|
string sResult = string.Empty;
|
|
//判断列
|
|
switch (e.Column.ColumnName)
|
|
{
|
|
case "MANAGE_LIST_QUANTITY":
|
|
|
|
bResult = (string.Empty != e.ProposedValue.ToString()) && Convert.ToDecimal(e.ProposedValue) > 0;
|
|
|
|
sResult = "请输入大于0的出库数量";
|
|
|
|
bResult = ( Convert.ToDecimal(e.ProposedValue) <= Convert.ToDecimal(e.Row["STORAGE_LIST_QUANTITY"]));
|
|
|
|
sResult = string.Format("出库数量不能大于库存数量!");
|
|
|
|
break;
|
|
}
|
|
if (bResult)
|
|
{
|
|
e.Row.RowError = null;
|
|
e.Row.SetColumnError(e.Column, null);
|
|
}
|
|
else
|
|
{
|
|
e.Row.RowError = "数据校验失败";
|
|
e.Row.SetColumnError(e.Column, sResult);
|
|
}
|
|
}
|
|
|
|
private void PLAN_LIST_Bind(int PLAN_ID)
|
|
{
|
|
//数据源属性
|
|
this.gridPlanList.U_Clear();
|
|
this.gridPlanList.U_WindowName = this.GetType().Name;
|
|
this.gridPlanList.U_TableName = "V_PLAN_LIST";
|
|
this.gridPlanList.U_XmlTableName = "V_PLAN_LIST";
|
|
this.gridPlanList.U_Fields = "*";
|
|
this.gridPlanList.U_Where = string.Format("PLAN_ID ={0} AND (PLAN_LIST_QUANTITY>PLAN_LIST_ORDERED_QUANTITY)", PLAN_ID);
|
|
this.gridPlanList.U_OrderField = "PLAN_LIST_ID";
|
|
|
|
this.gridPlanList.U_AllowChecked = true;
|
|
this.gridPlanList.U_AllowOperatData = false;
|
|
this.gridPlanList.U_AllowShowPage = false;
|
|
|
|
//拆分列属性
|
|
this.gridPlanList.U_SplitPropertyType = "GOODS_TYPE";
|
|
this.gridPlanList.U_SplitGroupColumn = "GOODS_TYPE_ID";
|
|
this.gridPlanList.U_SplitPropertyColumn = "GOODS_PROPERTY";
|
|
this.gridPlanList.U_SplitGroupHeader = "GOODS_TYPE.GOODS_TYPE_NAME";
|
|
|
|
//明细属性
|
|
//this.gridPlanList.U_DetailTableName = "PLAN_DETAIL";
|
|
//this.gridPlanList.U_DetailRelatvieColumn = "PLAN_LIST_ID";
|
|
|
|
try
|
|
{
|
|
this.gridPlanList.U_InitControl();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MainApp._MessageDialog.ShowException(ex);
|
|
}
|
|
}
|
|
|
|
private void StorageListBind(string QueryWhere)
|
|
{
|
|
this.ucStorageGroup.U_WindowName = this.GetType().Name;
|
|
this.ucStorageGroup.U_TableName = "V_STORAGE_LIST";
|
|
this.ucStorageGroup.U_XmlTableName = "V_STORAGE_LIST";
|
|
//this.ucStorageGroup.U_AppendFieldStyles = this.GetColumnDescriptionList();
|
|
this.ucStorageGroup.U_TotalColumnName = "STORAGE_LIST_QUANTITY";
|
|
this.ucStorageGroup.U_OrderField = "STOCK_BARCODE";
|
|
this.ucStorageGroup.U_Where = string.Format(" {0} AND {1}", QueryWhere, this.STORAGE_AREA_TYPE.Equals("XuNiKu") ? "1=1" : "RUN_STATUS = 'Enable'");
|
|
this.ucStorageGroup.U_AllowOperatData = false;
|
|
this.ucStorageGroup.U_AllowChecked = true;
|
|
this.ucStorageGroup.U_AllowShowPage = true;
|
|
|
|
//拆分列属性
|
|
this.ucStorageGroup.U_SplitPropertyType = "GOODS_TYPE";
|
|
this.ucStorageGroup.U_SplitGroupColumn = "GOODS_TYPE_ID";
|
|
this.ucStorageGroup.U_SplitGroupHeader = "GOODS_TYPE.GOODS_TYPE_NAME";
|
|
this.ucStorageGroup.U_SplitPropertyColumn = "GOODS_PROPERTY";
|
|
|
|
this.ucStorageGroup.U_InitControl();
|
|
|
|
this.Register_DataTable_Event();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 按钮事件
|
|
|
|
private void WrapPanel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Button btn = e.OriginalSource as Button;
|
|
if (btn != null)
|
|
{
|
|
switch (btn.Name)
|
|
{
|
|
case "btnConfirm":
|
|
this.CreateTask();
|
|
break;
|
|
case "btnQuery":
|
|
this.Query();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CreateTask()
|
|
{
|
|
bool boolResult = true;
|
|
|
|
string strResult = string.Empty;
|
|
|
|
try
|
|
{
|
|
if (this.ucManagePosition.Visibility == Visibility.Visible)
|
|
{
|
|
if (!this.ucManagePosition.U_CHECK_WAREHOUSE())
|
|
return;
|
|
}
|
|
|
|
listDataRowView = this.ucStorageGroup.U_GetCheckedDataRows();
|
|
|
|
this.ucStorageGroup.U_EndCurrentEdit();
|
|
|
|
#region 校验库存表单
|
|
|
|
if (listDataRowView.Length == 0)
|
|
{
|
|
MainApp._MessageDialog.Show(false, "请选中要出库的记录");
|
|
return;
|
|
}
|
|
|
|
//var list = from v in listDataRowView
|
|
// where Convert.ToDecimal(v["MANAGE_LIST_QUANTITY"]) > 0
|
|
// select v;
|
|
|
|
//if (list.Count() != listDataRowView.Length)
|
|
//{
|
|
// MainApp._MessageDialog.Show(false, "选中记录的出库数量必须大于0");
|
|
// return;
|
|
//}
|
|
|
|
//判断数据是否合法
|
|
if (this.ucStorageGroup.U_DataSource.HasErrors)
|
|
{
|
|
MainApp._MessageDialog.Show(false, "库存表单存在不合法的数据");
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获得所选托盘库存
|
|
|
|
//获得列表
|
|
IDictionary<string, Model.MANAGE_MAIN> dicStack = this.GetPalletKeyValuePair(listDataRowView);
|
|
|
|
if (dicStack.Count == 0)
|
|
{
|
|
MainApp._MessageDialog.Show(false, "检查所选库存是否存在");
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 校验计划表单
|
|
|
|
DataRowView[] drvPLAN_LIST = this.gridPlanList.U_GetCheckedDataRows();
|
|
|
|
if (drvPLAN_LIST.Length == 0)
|
|
{
|
|
MainApp._MessageDialog.Show(false, "请选中计划明细记录");
|
|
return;
|
|
}
|
|
|
|
List<Model.PLAN_LIST> listPLAN_LIST = new SiaSun.LMS.Common.CloneObjectValues().GetListFromDataTable<Model.PLAN_LIST>(drvPLAN_LIST, null);
|
|
DataTable dt_whcell = MainApp._I_BaseService.GetList(string.Format(@"select * from wh_cell where cell_id = {0}", this.ucManagePosition.U_END_POSITION_ID));
|
|
if (dt_whcell !=null && dt_whcell.Rows[0]["CELL_CODE"].ToString().Equals("12043"))
|
|
{
|
|
DataTable dtcontrol = MainApp._I_BaseService.GetList(string.Format(@"select * from io_control where end_device_code='12043'"));
|
|
if (dtcontrol.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dr in dtcontrol.Rows)
|
|
{
|
|
if (!dr["control_remark"].Equals(listPLAN_LIST[0].GOODS_PROPERTY1))
|
|
{
|
|
//判断该盘是否进主线
|
|
if (dr["control_status"].ToString().Equals("50"))
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
MainApp._MessageDialog.Show(false, "当前有未执行完的其他批次物料,请稍后再进行出库");
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
if (MainApp._MessageDialog.ShowDialog("确认下达任务") == Sid.Windows.Controls.TaskDialogResult.Ok)
|
|
{
|
|
//获得所有的选定的条码
|
|
foreach (KeyValuePair<string, Model.MANAGE_MAIN> stackCell in dicStack)
|
|
{
|
|
//获得起始位置
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = new Model.MANAGE_MAIN();
|
|
|
|
var value_ceLl_id = from v in listDataRowView
|
|
where v["STOCK_BARCODE"].ToString() == stackCell.Value.STOCK_BARCODE.ToString()
|
|
select v;
|
|
|
|
|
|
|
|
List<Model.MANAGE_LIST> listMANAGE_LIST = new SiaSun.LMS.Common.CloneObjectValues().GetListFromDataTable<Model.MANAGE_LIST>(value_ceLl_id.Cast<DataRowView>().ToArray(), null);
|
|
|
|
//if (this.ucManagePosition.U_END_POSITION_ID == 16646 || this.ucManagePosition.U_END_POSITION_ID == 13209)
|
|
//{
|
|
foreach(Model.MANAGE_LIST lst in listMANAGE_LIST)
|
|
{
|
|
DataTable dt = MainApp._I_BaseService.GetList(string.Format(@"select * from v_storage_list where stock_barcode='{0}' and goods_property1='{1}'", stackCell.Value.STOCK_BARCODE.ToString(), lst.GOODS_PROPERTY1));
|
|
lst.MANAGE_LIST_QUANTITY = Convert.ToDecimal(dt.Rows[0]["STORAGE_LIST_QUANTITY"].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
//}
|
|
//else if (this.ucManagePosition.U_END_POSITION_ID == 14596)
|
|
//{
|
|
// foreach (Model.MANAGE_LIST lst in listMANAGE_LIST)
|
|
// {
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
mMANAGE_MAIN.MANAGE_TYPE_CODE = mMANAGE_TYPE.MANAGE_TYPE_CODE.TrimEnd();
|
|
|
|
mMANAGE_MAIN.PLAN_ID = intPlanID;
|
|
|
|
mMANAGE_MAIN.PLAN_TYPE_CODE = this.mPLAN_MAIN.PLAN_TYPE_CODE;
|
|
|
|
mMANAGE_MAIN.STOCK_BARCODE = stackCell.Value.STOCK_BARCODE;
|
|
|
|
mMANAGE_MAIN.START_CELL_ID = stackCell.Value.START_CELL_ID;
|
|
|
|
//直接出库,不显示终止位置
|
|
//下架出库,选择终止站台
|
|
if (!this.mMANAGE_TYPE.MANAGE_TYPE_CODE.Equals(SiaSun.LMS.Enum.MANAGE_TYPE.ManageOut.ToString()))
|
|
{
|
|
mMANAGE_MAIN.END_CELL_ID = this.ucManagePosition.U_END_POSITION_ID;
|
|
}
|
|
else
|
|
{
|
|
mMANAGE_MAIN.END_CELL_ID = mMANAGE_MAIN.START_CELL_ID;
|
|
}
|
|
|
|
mMANAGE_MAIN.MANAGE_OPERATOR = MainApp._USER.USER_NAME;
|
|
|
|
mMANAGE_MAIN.MANAGE_BEGIN_TIME = SiaSun.LMS.Common.StringUtil.GetDateTime();
|
|
|
|
mMANAGE_MAIN.MANAGE_STATUS = SiaSun.LMS.Enum.MANAGE_STATUS.Waiting.ToString();
|
|
|
|
mMANAGE_MAIN.MANAGE_LEVEL = string.Empty;
|
|
|
|
mMANAGE_MAIN.MANAGE_REMARK = string.Empty;
|
|
|
|
boolResult = MainApp._I_BaseService.Invoke(mMANAGE_TYPE.MANAGE_TYPE_CLASS.TrimEnd(),
|
|
"ManageCreate",
|
|
new object[] {
|
|
mMANAGE_MAIN,
|
|
listPLAN_LIST,
|
|
listMANAGE_LIST,
|
|
true,
|
|
this.cbControl.IsChecked
|
|
},
|
|
out strResult);
|
|
|
|
//判断结果
|
|
if (!boolResult)
|
|
{
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
this.ucManagePosition.U_Update();
|
|
this.ucStorageGroup.U_Update();
|
|
this.gridPlanList.U_Update();
|
|
}
|
|
}
|
|
|
|
MainApp._MessageDialog.Show(boolResult, strResult);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MainApp._MessageDialog.ShowException(ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获得托盘集合列表
|
|
/// </summary>
|
|
/// <param name="listDataRowView"></param>
|
|
/// <returns></returns>
|
|
private IDictionary<string, Model.MANAGE_MAIN> GetPalletKeyValuePair(DataRowView[] listDataRowView)
|
|
{
|
|
IDictionary<string, Model.MANAGE_MAIN> dicStack = new Dictionary<string, Model.MANAGE_MAIN>();
|
|
foreach (DataRowView rowView in listDataRowView)
|
|
{
|
|
string stack = rowView["STOCK_BARCODE"].ToString();
|
|
if (!dicStack.ContainsKey(stack))
|
|
{
|
|
Model.MANAGE_MAIN mMANAGE_MAIN = new Model.MANAGE_MAIN();
|
|
|
|
mMANAGE_MAIN.CELL_MODEL = rowView["CELL_MODEL"].ToString();
|
|
|
|
mMANAGE_MAIN.STOCK_BARCODE = rowView["STOCK_BARCODE"].ToString();
|
|
|
|
mMANAGE_MAIN.START_CELL_ID = Convert.ToInt32(rowView["CELL_ID"]);
|
|
|
|
dicStack.Add(stack, mMANAGE_MAIN);
|
|
}
|
|
}
|
|
return dicStack;
|
|
}
|
|
|
|
private void Query()
|
|
{
|
|
DataRowView[] checkDataRowView = this.gridPlanList.U_GetCheckedDataRows();
|
|
|
|
if (checkDataRowView.Length == 0)
|
|
{
|
|
MainApp._MessageDialog.Show(false,"请选中计划明细记录");
|
|
return;
|
|
}
|
|
|
|
this.ucManagePosition.U_Refresh();
|
|
this.InitManagePosotion(Convert.ToInt32(checkDataRowView[0].Row.ItemArray[5]));
|
|
string sPLAN_LIST_ID = string.Empty;
|
|
|
|
foreach (DataRowView drv in checkDataRowView)
|
|
{
|
|
sPLAN_LIST_ID += drv["PLAN_LIST_ID"].ToString() + ",";
|
|
}
|
|
|
|
sPLAN_LIST_ID = sPLAN_LIST_ID.TrimEnd(',');
|
|
|
|
string GOODS_PROPERTY = string.Empty;
|
|
|
|
IList<SiaSun.LMS.Model.GOODS_PROPERTY> lsGOODS_PROPERTY = MainApp._I_GoodsService.GoodsPropertyGetListGoodsTypeID(this.gridPlanList.U_GetSelectedGoodsTypeID());
|
|
|
|
foreach (SiaSun.LMS.Model.GOODS_PROPERTY mGOODS_PROPERTY in lsGOODS_PROPERTY)
|
|
{
|
|
if( mGOODS_PROPERTY.GOODS_PROPERTY_KEYFLAG=="1")
|
|
GOODS_PROPERTY += string.Format(" AND ISNULL({0}.{1},ISNULL({2}.{1},'')) = ISNULL({2}.{1},'')", "PLAN_LIST", mGOODS_PROPERTY.GOODS_PROPERTY_FIELD, "V_STORAGE_LIST");
|
|
}
|
|
|
|
string sPLAN = " (SELECT count(0) FROM PLAN_LIST WHERE V_STORAGE_LIST.GOODS_ID= PLAN_LIST.GOODS_ID and isnull(V_STORAGE_LIST.GOODS_PROPERTY1,'')= PLAN_LIST.GOODS_PROPERTY1 {2} {0} AND PLAN_LIST_ID in ({1}))>0";
|
|
|
|
this.StorageListBind(string.Format(sPLAN, GOODS_PROPERTY, sPLAN_LIST_ID, this.STORAGE_AREA_TYPE == string.Empty ? string.Empty: string.Format(" AND V_STORAGE_LIST.AREA_TYPE = '{0}' ",this.STORAGE_AREA_TYPE) ));
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|