标签:des style blog http color io os ar for
/// <summary> /// 读头数据处理 /// </summary> private void HandleData(Symbol.Barcode.ReaderData TheReaderData) { //定单适配 if (tc_container.SelectedIndex == 1) { txtWmsNo.Text = TheReaderData.Text; BindOrderDetailGrid(txtWmsNo.Text.Trim()); btnAdaptor_Click(null, null); } }
private void BindOrderDetailGrid(string wmsID) { lv_Order.Items.Clear(); try { _allOrderDetail = _repository.GetOrderDetail(wmsID); if (_allOrderDetail.Any()) { foreach (OrderDetail detail in _allOrderDetail) { ListViewItem item = new ListViewItem(); item.SubItems[0].Text = detail.StyleNo; item.SubItems.Add(detail.Size); item.SubItems.Add(detail.OrderNum.ToString());//订单数 lv_Order.Items.Add(item); } } } catch (Exception ex) { MessageBox.Show("查询出错:" + ex.Message); btnExit_Click(null, null); } }
//批量适配 private void btnAdaptor_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtWmsNo.Text.Trim()) || txtWmsNo.Text == "扫描WMS单号…") { MessageBox.Show("请先扫描wmsID。", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); return; } if (_repository.ExitsWmsID(txtWmsNo.Text.Trim())) { DialogResult result = MessageBox.Show("该单号已经适配过了,是否继续?", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); if (result != DialogResult.OK) { lv_Adaptor.Items.Clear(); return; } } _differenceQty = 0; _list.Clear(); try{ _goodList = _repository.GetGoodsList(string.Join(",",_allOrderDetail.Select(c=>"‘"+c.StyleNo+"‘").ToArray())); } catch (Exception ex) { MessageBox.Show("查询出错:" + ex.Message); btnExit_Click(null, null); } if (_goodList.Any()) { _allOrderDetail.ForEach(order => BindAdaptorGrid(_goodList.Where(c => c.StyleNo == order.StyleNo).ToList(), order.Size, order.OrderNum, false)); } if (_list.Any()) { _list.ForEach(o => lv_Adaptor.Items.Add(o)); btnSave.Enabled = true; lbl_difNum.Text = "总差异数:" + _differenceQty; lblMsg.Text = "适配成功,请保存!"; } else { btnSave.Enabled = false; lblMsg.Text = "适配失败,请先维护库存!"; } }
/// <summary> /// 绑定适配表 /// 如果数量相等,则按照库位匹配 /// </summary> /// <param name="orderNum">订单数</param> /// <param name="isSingle">是否单款</param> private void BindAdaptorGrid(List<PDA_TGoods> goodsByStyleNo,string size,int orderNum,bool isSingle) { lv_Adaptor.Items.Clear(); lblMsg.Text = string.Empty; _orderNum = orderNum; List<GoodsSummary> summary_goods = GetGoodsSummary(goodsByStyleNo); if (summary_goods.Any()) { int stockSumNum = goodsByStyleNo.Count(); //库存数总和 bool isBreak = false; //差异数算法:[订单数>=库存数总和-->差异数=订单数-库存数;订单数<库存数总和-->差异数=0] int singleDifNum = (_orderNum >= stockSumNum ? _orderNum - stockSumNum : 0); _differenceQty += singleDifNum; if (isSingle) lbl_difNum.Text = "单款差异:" + singleDifNum; foreach (var g in summary_goods) { ListViewItem item = new ListViewItem(); item.SubItems[0].Text = g.StyleNo; //库位 item.SubItems.Add(g.StockNo.ToString()); //库存数 item.SubItems.Add(g.SkuNum.ToString()); //库存数 //适配数算法: //(1)订单数>=库存数总和-->适配数=库存数; //(2)订单数<库存数总和-->适配数=任意库位的数量的分配(必须=订单数) int adaptorNum = 0; if (_orderNum >= stockSumNum) adaptorNum = g.SkuNum; else adaptorNum = GetAdaptorNum(_orderNum, g.SkuNum, out isBreak); item.SubItems.Add(adaptorNum.ToString()); //item.SubItems.Add(g.Sku); //条码[不可见] item.SubItems.Add(size); //尺码[不可见] if (isSingle) lv_Adaptor.Items.Add(item); else _list.Add(item); if (isBreak) break;//适配到,则不再进行其他库位的适配 } } } //计算适配数 private int GetAdaptorNum(int orderNum, int stockNum,out bool isBreak) { int adptorNum = 0; if (orderNum >= stockNum) { adptorNum = stockNum; isBreak = false; } else { adptorNum = _orderNum; isBreak = true; } _orderNum = _orderNum - stockNum; if (_orderNum == 0) isBreak = true; return adptorNum; }
/// <summary> /// 按款汇总商品总数,并做排序 /// </summary> /// <param name="PDA_TGoods"></param> /// <returns></returns> private static List<GoodsSummary> GetGoodsSummary(List<PDA_TGoods> goods) { List<GoodsSummary> summary_goods = new List<GoodsSummary>(); foreach (var g in goods.GroupBy(o => new { o.StockNo, o.StyleNo })) { GoodsSummary gt = new GoodsSummary(); gt.SkuNum = g.Count(); gt.StockNo = g.First().StockNo; gt.StyleNo = g.First().StyleNo; summary_goods.Add(gt); } //库存量大优先;同等数量,库位优先策略 return summary_goods.OrderByDescending(o => o.SkuNum).ThenBy(o => o.StockNo).ToList(); }
(2)订单数<库存数总和 则 适配数 = 任意库位的数量的分配(必须=订单数)
(3)库存量大的库位优先适配;同等数量的库位,库位编号小的优先适配策略标签:des style blog http color io os ar for
原文地址:http://www.cnblogs.com/jackyfee/p/4048906.html