From 928ec7dd69742641ecabbff0d6baa691d71955cc Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Sat, 20 Oct 2018 11:42:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=20=E6=89=93=E5=8D=B0=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../B3ButcherManageToSale.Web.csproj | 3 + .../SaleOutStockAnalyse2.cs | 36 +- .../SaleOutStockPrint2.cs | 369 ++++++++++++++++++ .../SaleOutStockAnalyse.cs | 48 ++- .../SaleOutStockAnalyse_/SaleOutStockPrint.cs | 54 ++- .../SaleOutStockAnalyse_/ShowGoodsCustomer.cs | 23 +- .../SaleOutStockPrint2.xml | 22 ++ .../SaleOutStockPrintOnlyGoods.xml | 27 ++ 8 files changed, 546 insertions(+), 36 deletions(-) create mode 100644 B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse2_/SaleOutStockPrint2.cs create mode 100644 WebFolder/config/billreports/B3ButcherManageToSale/SaleOutStockPrint2.xml create mode 100644 WebFolder/config/billreports/B3ButcherManageToSale/SaleOutStockPrintOnlyGoods.xml diff --git a/B3ButcherManageToSale.Web/B3ButcherManageToSale.Web.csproj b/B3ButcherManageToSale.Web/B3ButcherManageToSale.Web.csproj index 30aed19..7f4e991 100644 --- a/B3ButcherManageToSale.Web/B3ButcherManageToSale.Web.csproj +++ b/B3ButcherManageToSale.Web/B3ButcherManageToSale.Web.csproj @@ -122,6 +122,9 @@ ASPXCodeBehind + + ASPXCodeBehind + ASPXCodeBehind diff --git a/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse2_/SaleOutStockAnalyse2.cs b/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse2_/SaleOutStockAnalyse2.cs index 346d89c..0d40a02 100644 --- a/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse2_/SaleOutStockAnalyse2.cs +++ b/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse2_/SaleOutStockAnalyse2.cs @@ -122,6 +122,8 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse2_ { get { + if (ViewState["TakeGoodsType"] == null) + return 0; return (int)ViewState["TakeGoodsType"]; } set @@ -146,16 +148,19 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse2_ return hPanel; } - //protected override void AddToolboxPanel(HLayoutPanel hbox) - //{ - // if (EnablePrint) - // { - // var printPage = "SaleOutStockPrint.aspx?MinDate=" + "'+__QueryContainer.getControl('MinLoadTime').value+'&MaxDate=" + "'+__QueryContainer.getControl('MaxLoadTime').value+'&" + "'+__QueryContainer.getQueryString(['DeliverGoodsLine_ID','SequenceNumber','SaleGoods_ID','BillState'])+'"; - // hbox.Add(new TSButton("预览")).OnClientClick = "preventEventDefault(event);Preview('" + printPage + "')"; - // hbox.Add(new TSButton("打印")).OnClientClick = "preventEventDefault(event);Print('" + printPage + "')"; - // } - // AddExcelExport(hbox); - //} + TSButton previewBtn, printBtn; + protected override void AddToolboxPanel(HLayoutPanel hbox) + { + if (EnablePrint) + { + var printPage = "SaleOutStockPrint2.aspx?MinDate=" + "'+__QueryContainer.getControl('MinLoadTime').value+'&MaxDate=" + "'+__QueryContainer.getControl('MaxLoadTime').value+'&" + "'+__QueryContainer.getQueryString(['DeliverGoodsLine_ID','SequenceNumber','SaleGoods_ID'])+'&TakeGoodsType=" + TakeGoodsType.ToString(); + previewBtn = hbox.Add(new TSButton("预览")); + previewBtn.OnClientClick = "preventEventDefault(event);Preview('" + printPage + "')"; + printBtn = hbox.Add(new TSButton("打印")); + printBtn.OnClientClick = "preventEventDefault(event);Print('" + printPage + "')"; + } + AddExcelExport(hbox); + } void AddQueryButtons(VLayoutPanel vbox) { @@ -173,6 +178,10 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse2_ void StartQuery(int type) { TakeGoodsType = type; + var old = string.Format("TakeGoodsType={0}", type == 0 ? 1 : 0); + var replace = string.Format("TakeGoodsType={0}", type); + previewBtn.OnClientClick = ReplaceLast(previewBtn.OnClientClick, old, replace); + printBtn.OnClientClick = ReplaceLast(printBtn.OnClientClick, old, replace); mDFGrid.SortField = null; mDFGrid.SortDirection = SortDirection.Ascending; mDFGrid.CurrentPage = 0; @@ -180,6 +189,13 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse2_ mQueryControls.SaveLast(); } + string ReplaceLast(string str, string old, string replace) + { + if (!str.Contains(replace)) + return str.Replace(old, replace); + return str; + } + Dictionary fileDic = new Dictionary(); public override PagedDFDataTable GetPagedDFDataTable(QuerySettings settings) { diff --git a/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse2_/SaleOutStockPrint2.cs b/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse2_/SaleOutStockPrint2.cs new file mode 100644 index 0000000..d49c271 --- /dev/null +++ b/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse2_/SaleOutStockPrint2.cs @@ -0,0 +1,369 @@ +using BWP.B3Frameworks.Utils; +using BWP.B3Sale.BO; +using Forks.EnterpriseServices; +using Forks.EnterpriseServices.DataForm; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.Utils; +using Forks.Utils.IO; +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Web.UI; +using System.Web.UI.HtmlControls; +using TSingSoft.WebControls2; +using TSingSoft.WebControls2.BillReports; +using TSingSoft.WebPluginFramework; +using WebUnit = System.Web.UI.WebControls.Unit; +using StockUpClass = BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_.SaleOutStockAnalyse.StockUpClass; +using Forks.EnterpriseServices.SqlDoms; +using BWP.B3Frameworks.BO.NamedValueTemplate; +using BWP.B3Sale.Utils; +using BWP.B3ButcherManage.BO; + +namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse2_ +{ + class SaleOutStockPrint2 : PrintPageBase + { + public DateTime? MinDate + { + get + { + if (string.IsNullOrEmpty(Request.QueryString["MinDate"])) + return null; + return DateTime.Parse(Request.QueryString["MinDate"]); + } + } + + public DateTime? MaxDate + { + get + { + if (string.IsNullOrEmpty(Request.QueryString["MaxDate"])) + return null; + return DateTime.Parse(Request.QueryString["MaxDate"]) + new TimeSpan(23, 59, 29); + } + } + + public IEnumerable Goods_IDs + { + get + { + if (string.IsNullOrEmpty(Request.QueryString["SaleGoods_ID"])) + return new List(); + return Request.QueryString["SaleGoods_ID"].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)); + } + } + + public IEnumerable DeliverGoodsLine_IDs + { + get + { + if (string.IsNullOrEmpty(Request.QueryString["DeliverGoodsLine_ID"])) + return new List(); + return Request.QueryString["DeliverGoodsLine_ID"].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)); + } + } + + public string Sequence + { + get + { + return Request.QueryString["SequenceNumber"].Trim(); + } + } + + public short TakeGoodsType + { + get + { + return short.Parse(Request.QueryString["TakeGoodsType"]); + } + } + + string GetTemplateFile() + { + return PrintUtil.GetTemplateFile(PluginName, GetType().Name + ".xml"); + } + + protected override void InitForm(System.Web.UI.HtmlControls.HtmlForm form) + { + Control pageContainer = CreatePageContainer(CreateReport()); + form.Controls.Add(pageContainer); + } + + private int pagesCount; + private int slipPages; + private WebUnit pageHeight = WebUnit.Empty; + private Control CreatePageContainer(Control control) + { + foreach (Control ctrl in control.Controls) + { + BillReport r = ctrl as BillReport; + if (r != null) + { + pagesCount += r.PagesCount; + if (pageHeight == WebUnit.Empty) + pageHeight = r.PageHeight; + } + } + HtmlGenericControl result = new HtmlGenericControl("div"); + result.Style[HtmlTextWriterStyle.Width] = "100%"; + result.Style[HtmlTextWriterStyle.Padding] = "0cm"; + result.Style[HtmlTextWriterStyle.BorderWidth] = "0cm"; + result.Style[HtmlTextWriterStyle.Margin] = "0cm"; + if (!pageHeight.IsEmpty) + { + result.Style[HtmlTextWriterStyle.Top] = new WebUnit((pageHeight.Value * slipPages), pageHeight.Type).ToString(); + result.Style[HtmlTextWriterStyle.Position] = "absolute"; + } + result.Controls.Add(control); + slipPages = pagesCount; + return result; + } + + private Control CreateReport() + { + var result = new TemplateBillReport(); + var parameters = new Dictionary(); + AddParameters(parameters); + + var autoAdd = new Dictionary(); + foreach (KeyValuePair pair in parameters) + { + if (pair.Value != null && pair.Value is ICollection) + { + string newKey = pair.Key + "_RecordCount"; + if (!parameters.ContainsKey(newKey)) + autoAdd.Add(newKey, ((ICollection)pair.Value).Count); + } + } + foreach (KeyValuePair pair in autoAdd) + { + parameters.Add(pair.Key, pair.Value); + } + + var printTemplateFile = Path.Combine(Wpf.Settings.ConfigFolder, GetTemplateFile()); + result.ParseTemplate(FS.OpenRead(printTemplateFile), parameters); + return result; + } + + void AddParameters(IDictionary dic) + { + dic.Add("$Details", GetList().ToList()); + dic.Add("$DetailType", typeof(ProductDiffPrint)); + } + + IEnumerable GetList() + { + long? maxSeque = null; + if (!string.IsNullOrEmpty(Sequence)) + { + var arr = Sequence.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)); + if (arr.Any()) + maxSeque = arr.Max(); + } + IEnumerable data; + List products; + using (var session = Dmo.NewSession()) + { + if (DeliverGoodsLine_IDs.Any()) + { + var m = GetMaxLine(session, DeliverGoodsLine_IDs); + if (m.HasValue && maxSeque.HasValue && m > maxSeque) + maxSeque = m; + } + + data = GetMainInfo(maxSeque, Goods_IDs, MinDate, MaxDate, session); + products = GetInStoreNumber(Goods_IDs, MinDate, MaxDate, session); + } + + foreach (var item in data) + { + var first = products.FirstOrDefault(x => x.Goods_ID == item.Goods_ID); + if (first != null) + { + if (item.TakeGoods_Type == 配送方式.客户自运) + { + item.ProductMain = Math.Min((item.OrderMain ?? 0).Value, (first.MainNumber ?? 0).Value); + first.MainNumber -= item.ProductMain; + + item.ProductSecond = Math.Min((item.OrderSecond ?? 0).Value, (first.SecondNumber ?? 0).Value); + first.SecondNumber -= item.ProductSecond; + } + else + { + item.ProductMain = first.MainNumber; + item.ProductSecond = first.SecondNumber; + } + if (item.ProductMain == 0) + item.ProductMain = null; + if (item.ProductSecond == 0) + item.ProductSecond = null; + } + } + data = data.Where(x => x.TakeGoods_Type == TakeGoodsType); + return data; + } + + + long? GetMaxLine(IDmoSession session, IEnumerable ids) + { + var query = new DQueryDom(new JoinAlias(typeof(DeliverGoodsLine))); + query.Columns.Add(DQSelectColumn.Max("SequenceNumber")); + query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ID"), ids.Select(x => DQExpression.Value(x)).ToArray())); + return query.EExecuteScalar(session); + } + + List GetInStoreNumber(IEnumerable goodsIDs, DateTime? start, DateTime? end, IDmoSession session) + { + var main = new JoinAlias(typeof(Output)); + var detail = new JoinAlias(typeof(Output_Detail)); + var config = new JoinAlias(typeof(GoodsViewConfig)); + var query = new DQueryDom(main); + query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "Output_ID")); + query.From.AddJoin(JoinType.Inner, new DQDmoSource(config), DQCondition.EQ(detail, "Goods_ID", config, "Goods_ID")); + + query.Columns.Add(DQSelectColumn.Field("Goods_ID", detail)); + query.Columns.Add(DQSelectColumn.Sum(detail, "Number")); + query.Columns.Add(DQSelectColumn.Sum(detail, "SecondNumber")); + query.GroupBy.Expressions.Add(DQExpression.Field(detail, "Goods_ID")); + + + query.Where.Conditions.Add(DQCondition.InEQ("BillState", 单据状态.已作废)); + if (start.HasValue) + query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("Date", start)); + if (start.HasValue) + query.Where.Conditions.Add(DQCondition.LessThanOrEqual("Date", end)); + if (goodsIDs.Any()) + query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(detail, "Goods_ID"), goodsIDs.Select(x => DQExpression.Value(x)).ToArray())); + var list = new List(); + using (var reader = session.ExecuteReader(query)) + { + while (reader.Read()) + { + list.Add(new MinObj + { + Goods_ID = (long)reader[0], + MainNumber = (Money?)reader[1], + SecondNumber = (Money?)reader[2] + }); + } + } + return list; + } + + List GetMainInfo(long? seque, IEnumerable goodsIDs, DateTime? minDate, DateTime? maxDate, IDmoSession session) + { + var main = new JoinAlias("_m", typeof(SaleOutStore)); + var detail = new JoinAlias("_d", typeof(SaleOutStore_Detail)); + var config = new JoinAlias("_g1", typeof(GoodsViewConfig)); + var customer = new JoinAlias("_c1", typeof(CustomerViewConfig)); + var query = new DQueryDom(main); + query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID")); + query.From.AddJoin(JoinType.Inner, new DQDmoSource(config), DQCondition.EQ(config, "Goods_ID", detail, "SaleGoods_ID")); + query.From.AddJoin(JoinType.Left, new DQDmoSource(customer), DQCondition.EQ(main, "Customer_ID", customer, "Customer_ID")); + query.Columns.Add(DQSelectColumn.Field("SaleGoods_ID", detail)); + query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); + query.Columns.Add(DQSelectColumn.Field("Unit", detail)); + query.Columns.Add(DQSelectColumn.Field("Goods_SecondUnit", detail)); + query.Columns.Add(DQSelectColumn.Field("TakeGoods_Type")); + foreach (var c in query.Columns) + query.GroupBy.Expressions.Add(c.Expression); + + query.Columns.Add(DQSelectColumn.Sum(detail, "UnitNum")); + query.Columns.Add(DQSelectColumn.Sum(detail, "SecondNumber")); + + query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field(customer, "Customer_ID"))); + if (minDate.HasValue) + query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(main, "LoadTime", minDate.Value)); + if (maxDate.HasValue) + query.Where.Conditions.Add(DQCondition.LessThanOrEqual(main, "LoadTime", maxDate.Value)); + if (goodsIDs.Any()) + query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(detail, "SaleGoods_ID"), goodsIDs.Select(x => DQExpression.Value(x)).ToArray())); + + query.Where.Conditions.Add(DQCondition.InEQ(main, "BillState", 单据状态.已作废)); + if (seque.HasValue) + query.Where.Conditions.Add(DQCondition.LessThanOrEqual(main, "SequenceNumber", seque)); + query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(main, "TakeGoods_Type"), DQExpression.Value(配送方式.公司配送), DQExpression.Value(配送方式.客户自运))); + query.OrderBy.Expressions.Add(DQOrderByExpression.Create("TakeGoods_Type", true)); + var list = new List(); + using (var reader = session.ExecuteReader(query)) + { + while (reader.Read()) + { + var entity = new ProductDiffPrint(); + entity.Goods_ID = (long)reader[0]; + entity.Goods_Name = (string)reader[1]; + entity.Unit = (string)reader[2]; + entity.SecondUnit = (string)reader[3]; + entity.TakeGoods_Type = (NamedValue<配送方式>)reader[4]; + entity.OrderMain = (Money?)reader[5]; + entity.OrderSecond = (Money?)reader[6]; + + list.Add(entity); + } + } + return list; + } + + class MinObj + { + public long Goods_ID { get; set; } + public Money? MainNumber { get; set; } + public Money? SecondNumber { get; set; } + } + } + + [DFClass, Serializable] + [LogicName("备货打印")] + public class ProductDiffPrint + { + public long Goods_ID { get; set; } + public NamedValue<配送方式>? TakeGoods_Type { get; set; } + + [LogicName("存货名称")] + public string Goods_Name { get; set; } + [LogicName("单位")] + public string Unit { get; set; } + [LogicName("辅单位")] + public string SecondUnit { get; set; } + [LogicName("订货数量")] + public Money? OrderMain { get; set; } + [LogicName("订货辅数量")] + public Money? OrderSecond { get; set; } + [LogicName("产出数量")] + public Money? ProductMain { get; set; } + [LogicName("产出辅数量")] + public Money? ProductSecond { get; set; } + [LogicName("差异数量")] + public Money? ProductMainDiff + { + get + { + if (OrderMain == null) + return null; + var diff = OrderMain - (ProductMain ?? 0).Value; + if (diff > 0) + return diff; + return null; + } + } + [LogicName("差异辅数量")] + public Money? ProductSecondDiff + { + get + { + if (OrderSecond == null) + return null; + var diff = OrderSecond - (ProductSecond ?? 0).Value; + if (diff > 0) + return diff; + return null; + } + } + } +} diff --git a/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/SaleOutStockAnalyse.cs b/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/SaleOutStockAnalyse.cs index a6641ec..cdf328d 100644 --- a/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/SaleOutStockAnalyse.cs +++ b/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/SaleOutStockAnalyse.cs @@ -123,7 +123,8 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ billStateDp.Items.Add(new ListItem("已审核", "20")); billStateDp.SelectedIndex = 1; - onlyGoodsCheck = hPanel.Add(new DFCheckBox() { TextAlign = TextAlign.Left, Text = "按存货" }); + onlyGoodsCheck = hPanel.Add(new DFCheckBox() { TextAlign = TextAlign.Left, Text = "按存货", ClientIDMode = ClientIDMode.Static }); + onlyGoodsCheck.ID = "onlyGoodsCheck"; onlyGoodsCheck.InputAttributes.Add("style", "width:15px;height:15px;"); return hPanel; } @@ -132,7 +133,7 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ { if (EnablePrint) { - var printPage = "SaleOutStockPrint.aspx?MinDate=" + "'+__QueryContainer.getControl('MinLoadTime').value+'&MaxDate=" + "'+__QueryContainer.getControl('MaxLoadTime').value+'&" + "'+__QueryContainer.getQueryString(['DeliverGoodsLine_ID','SequenceNumber','SaleGoods_ID','BillState'])+'"; + var printPage = "SaleOutStockPrint.aspx?MinDate=" + "'+__QueryContainer.getControl('MinLoadTime').value+'&MaxDate=" + "'+__QueryContainer.getControl('MaxLoadTime').value+'&onlyGoods=" + "'+$('#onlyGoodsCheck')[0].checked+'" + "&'+__QueryContainer.getQueryString(['DeliverGoodsLine_ID','SequenceNumber','SaleGoods_ID','BillState'])+'"; hbox.Add(new TSButton("预览")).OnClientClick = "preventEventDefault(event);Preview('" + printPage + "')"; hbox.Add(new TSButton("打印")).OnClientClick = "preventEventDefault(event);Print('" + printPage + "')"; } @@ -149,15 +150,12 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ short? billState = null; if (!string.IsNullOrEmpty(billStateDp.SelectedValue)) billState = short.Parse(billStateDp.SelectedValue); - IEnumerable seques = new List(); - if (!string.IsNullOrEmpty(sequenceInput)) - seques = sequenceInput.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)); List data; List products; List stockInfo; using (var session = Dmo.NewSession()) { - data = GetMainInfo(line, seques, goodsIds, minDate, maxDate, billState, session); + data = GetMainInfo(line, sequenceInput, goodsIds, minDate, maxDate, billState, session); products = GetInStoreNumber(goodsIds, minDate, maxDate, session); stockInfo = GetStockInfo(goodsIds, minDate, maxDate, session); }; @@ -362,7 +360,7 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ return list; } - List GetMainInfo(IEnumerable line, IEnumerable seques, IEnumerable goodsIDs, DateTime? minDate, DateTime? maxDate, short? billStateDp, IDmoSession session) + List GetMainInfo(IEnumerable line, string seques, IEnumerable goodsIDs, DateTime? minDate, DateTime? maxDate, short? billStateDp, IDmoSession session) { var main = new JoinAlias("_m", typeof(SaleOutStore)); var detail = new JoinAlias("_d", typeof(SaleOutStore_Detail)); @@ -408,8 +406,21 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ query.Where.Conditions.Add(DQCondition.EQ(main, "BillState", billStateDp)); else query.Where.Conditions.Add(DQCondition.InEQ(main, "BillState", 单据状态.已作废)); - if (seques.Any()) - query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(main, "SequenceNumber"), seques.Select(x => DQExpression.Value(x)).ToArray())); + if (!string.IsNullOrEmpty(seques)) + { + if (seques.Contains('-') && seques.Contains(',')) + throw new Exception("不允许同时使用 - 和 ,同时查询"); + if (seques.Contains('-')) + { + var arr = seques.Split(new char[] { '-' }); + query.Where.Conditions.Add(DQCondition.Between("SequenceNumber", long.Parse(string.IsNullOrEmpty(arr[0]) ? "0" : arr[0]), long.Parse(string.IsNullOrEmpty(arr[1]) ? "10000" : arr[1]))); + } + else + { + var arr = seques.Split(new char[] { ',' }); + query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("SequenceNumber"), arr.Select(x => DQExpression.Value(long.Parse(x))).ToArray())); + } + } query.Where.Conditions.Add(DQCondition.EQ(main, "TakeGoods_Type", 配送方式.公司配送)); var list = new List(); @@ -443,7 +454,7 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ public Money? StockSecondNumber { get; set; } public Money? StockNumber { get; set; } - public static void Register(DQueryDom root, IEnumerable line, IEnumerable seques, IEnumerable goodsIDs, DateTime? minDate, DateTime? maxDate, short? billStateDp) + public static void Register(DQueryDom root, IEnumerable line, string seques, IEnumerable goodsIDs, DateTime? minDate, DateTime? maxDate, short? billStateDp) { var main = new JoinAlias("_tMain", typeof(SaleOutStore)); var detail = new JoinAlias("_tDetail", typeof(SaleOutStore_Detail)); @@ -470,8 +481,21 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ query.Where.Conditions.Add(DQCondition.EQ(main, "BillState", billStateDp)); else query.Where.Conditions.Add(DQCondition.InEQ(main, "BillState", 单据状态.已作废)); - if (seques.Any()) - query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(main, "SequenceNumber"), seques.Select(x => DQExpression.Value(x)).ToArray())); + if (!string.IsNullOrEmpty(seques)) + { + if (seques.Contains('-') && seques.Contains(',')) + throw new Exception("不允许同时使用 - 和 ,同时查询"); + if (seques.Contains('-')) + { + var arr = seques.Split(new char[] { '-' }); + query.Where.Conditions.Add(DQCondition.Between(DQExpression.Field(main, "SequenceNumber"), long.Parse(string.IsNullOrEmpty(arr[0]) ? "0" : arr[0]), long.Parse(string.IsNullOrEmpty(arr[1]) ? "10000" : arr[1]))); + } + else + { + var arr = seques.Split(new char[] { ',' }); + query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(main, "SequenceNumber"), arr.Select(x => DQExpression.Value(long.Parse(x))).ToArray())); + } + } query.Where.Conditions.Add(DQCondition.EQ(main, "TakeGoods_Type", 配送方式.公司配送)); root.RegisterQueryTable(typeof(StockUpClass), new string[] { "DetailID", "StockSecondNumber", "StockNumber" }, query); diff --git a/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/SaleOutStockPrint.cs b/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/SaleOutStockPrint.cs index 3413192..ab19480 100644 --- a/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/SaleOutStockPrint.cs +++ b/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/SaleOutStockPrint.cs @@ -67,13 +67,19 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ } } - public IEnumerable Sequence + public string Sequence { get { - if (string.IsNullOrEmpty(Request.QueryString["SequenceNumber"])) - return new List(); - return Request.QueryString["SequenceNumber"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)); + return Request.QueryString["SequenceNumber"]; + } + } + + public bool onlyGoods + { + get + { + return bool.Parse(Request.QueryString["onlyGoods"]); } } @@ -89,7 +95,7 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ string GetTemplateFile() { - return PrintUtil.GetTemplateFile(PluginName, GetType().Name + ".xml"); + return PrintUtil.GetTemplateFile(PluginName, GetType().Name + (onlyGoods ? "OnlyGoods" : "") + ".xml"); } protected override void InitForm(System.Web.UI.HtmlControls.HtmlForm form) @@ -204,8 +210,21 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ query.Where.Conditions.Add(DQCondition.EQ(main, "BillState", BillState)); else query.Where.Conditions.Add(DQCondition.InEQ(main, "BillState", 单据状态.已作废)); - if (Sequence.Any()) - query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(main, "SequenceNumber"), Sequence.Select(x => DQExpression.Value(x)).ToArray())); + if (!string.IsNullOrEmpty(Sequence)) + { + if (Sequence.Contains('-') && Sequence.Contains(',')) + throw new Exception("不允许同时使用 - 和 ,同时查询"); + if (Sequence.Contains('-')) + { + var arr = Sequence.Split(new char[] { '-' }); + query.Where.Conditions.Add(DQCondition.Between(DQExpression.Field(main, "SequenceNumber"), long.Parse(string.IsNullOrEmpty(arr[0]) ? "0" : arr[0]), long.Parse(string.IsNullOrEmpty(arr[1]) ? "10000" : arr[1]))); + } + else + { + var arr = Sequence.Split(new char[] { ',' }); + query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(main, "SequenceNumber"), arr.Select(x => DQExpression.Value(long.Parse(x))).ToArray())); + } + } query.Where.Conditions.Add(DQCondition.EQ(main, "TakeGoods_Type", 配送方式.公司配送)); var list = new List(); @@ -230,8 +249,27 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ } } } + var result = new List(); + if (onlyGoods) + { + foreach (var g in list.GroupBy(x => x.Goods_Name)) + { + var first = g.First(); + var entity = new PrintTemp(); + entity.Goods_Name = first.Goods_Name; + entity.Unit = first.Unit; + entity.SecondUnit = first.SecondUnit; + entity.OrderMain = g.Sum(x => (x.OrderMain ?? 0).Value); + entity.OrderSecond = g.Sum(x => (x.OrderSecond ?? 0).Value); + entity.StockNumber = g.Sum(x => (x.StockNumber ?? 0).Value); + entity.StockSecondNumber = g.Sum(x => (x.StockSecondNumber ?? 0).Value); + result.Add(entity); + } + } + else + result = list; - return list; + return result; } } diff --git a/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/ShowGoodsCustomer.cs b/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/ShowGoodsCustomer.cs index 42d56e3..121eb62 100644 --- a/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/ShowGoodsCustomer.cs +++ b/B3ButcherManageToSale.Web/Pages/B3ButcherManageToSale/Reports/SaleOutStockAnalyse_/ShowGoodsCustomer.cs @@ -58,13 +58,11 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ } } - public IEnumerable Sequence + public string Sequence { get { - if (string.IsNullOrEmpty(Request.QueryString["Sequence"])) - return new List(); - return Request.QueryString["Sequence"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)); + return Request.QueryString["Sequence"]; } } @@ -125,8 +123,21 @@ namespace BWP.Web.Pages.B3ButcherManageToSale.Reports.SaleOutStockAnalyse_ query.Where.Conditions.Add(DQCondition.EQ(main, "BillState", BillState)); else query.Where.Conditions.Add(DQCondition.InEQ(main, "BillState", 单据状态.已作废)); - if (Sequence.Any()) - query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("SequenceNumber"), Sequence.Select(x => DQExpression.Value(x)).ToArray())); + if (!string.IsNullOrEmpty(Sequence)) + { + if (Sequence.Contains('-') && Sequence.Contains(',')) + throw new Exception("不允许同时使用 - 和 ,同时查询"); + if (Sequence.Contains('-')) + { + var arr = Sequence.Split(new char[] { '-' }); + query.Where.Conditions.Add(DQCondition.Between(DQExpression.Field(main, "SequenceNumber"), long.Parse(string.IsNullOrEmpty(arr[0]) ? "0" : arr[0]), long.Parse(string.IsNullOrEmpty(arr[1]) ? "10000" : arr[1]))); + } + else + { + var arr = Sequence.Split(new char[] { ',' }); + query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field(main, "SequenceNumber"), arr.Select(x => DQExpression.Value(long.Parse(x))).ToArray())); + } + } query.Where.Conditions.Add(DQCondition.EQ(main, "TakeGoods_Type", 配送方式.公司配送)); return query; } diff --git a/WebFolder/config/billreports/B3ButcherManageToSale/SaleOutStockPrint2.xml b/WebFolder/config/billreports/B3ButcherManageToSale/SaleOutStockPrint2.xml new file mode 100644 index 0000000..8ed7761 --- /dev/null +++ b/WebFolder/config/billreports/B3ButcherManageToSale/SaleOutStockPrint2.xml @@ -0,0 +1,22 @@ + + + + + + 产出差异 + + + + + + + + + + + + + + + + diff --git a/WebFolder/config/billreports/B3ButcherManageToSale/SaleOutStockPrintOnlyGoods.xml b/WebFolder/config/billreports/B3ButcherManageToSale/SaleOutStockPrintOnlyGoods.xml new file mode 100644 index 0000000..498df09 --- /dev/null +++ b/WebFolder/config/billreports/B3ButcherManageToSale/SaleOutStockPrintOnlyGoods.xml @@ -0,0 +1,27 @@ + + + + + + 备货单 + + + + + + + + + + + + + + + + +