diff --git a/B3ClientService.Web/B3ClientService.Web.csproj b/B3ClientService.Web/B3ClientService.Web.csproj index 4f58425..205e26e 100644 --- a/B3ClientService.Web/B3ClientService.Web.csproj +++ b/B3ClientService.Web/B3ClientService.Web.csproj @@ -73,11 +73,21 @@ + + ASPXCodeBehind + + + ASPXCodeBehind + + + ASPXCodeBehind + ASPXCodeBehind + diff --git a/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassLossAnalyse_/CarcassLossAnalyse.cs b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassLossAnalyse_/CarcassLossAnalyse.cs new file mode 100644 index 0000000..7d8a3aa --- /dev/null +++ b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassLossAnalyse_/CarcassLossAnalyse.cs @@ -0,0 +1,117 @@ +using BWP.B3ClientService; +using BWP.B3ClientService.BO; +using BWP.B3Frameworks.Utils; +using BWP.Web.Utils; +using BWP.Web.WebControls; +using Forks.EnterpriseServices.DataForm; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.SqlDoms; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security; +using System.Text; +using System.Web.UI; +using System.Web.UI.HtmlControls; +using System.Web.UI.WebControls; +using TSingSoft.WebControls2; +using TSingSoft.WebPluginFramework.Controls; +using TSingSoft.WebPluginFramework.Pages; +using TSingSoft.WebPluginFramework; + +namespace BWP.Web.Pages.B3ClientService.Reports.CarcassLossAnalyse_ +{ + class CarcassLossAnalyse : ServerPage + { + protected override void OnInit(EventArgs e) + { + if (!User.IsInRole("B3ClientService.报表展示.白条损耗")) + throw new SecurityException(); + base.OnInit(e); + } + + DFBrowseGrid mBrowseGrid; + protected override void InitForm(HtmlForm form) + { + form.EAdd(new PageTitle("白条损耗")); + + var queryPanel = new Panel(); + queryPanel.Style.Add(HtmlTextWriterStyle.BackgroundColor, "white"); + queryPanel.CssClass = "QueryPanel PrintInVisible"; + form.Controls.Add(queryPanel); + + AddQueryControl(queryPanel); + + var mZone = new TitlePanelZone(); + form.Controls.Add(mZone); + + mZone.Add(CreateResultTab()); + } + + ChoiceBox batchSelect; + private void AddQueryControl(Panel queryPanel) + { + var hp = queryPanel.EAdd(new Panel()); + hp.Style.Add("float", "right"); + hp.EAdd(new SimpleLabel("生产批次")); + batchSelect = hp.EAdd(new ChoiceBox(B3ClientServiceConsts.DataSources.生产批次) { EnableInputArgument = true, EnableTopItem = true, AutoPostBack = true, Width = Unit.Pixel(180) }); + var batch = GetYesterdayBatch(); + if (!string.IsNullOrEmpty(batch)) + batchSelect.Fill(batch, batch); + batchSelect.SelectedValueChanged += delegate + { + StartQuery(); + }; + } + + string GetYesterdayBatch() + { + var dom = new DQueryDom(new JoinAlias(typeof(ProductBatch))); + dom.Columns.Add(DQSelectColumn.Field("Name")); + dom.OrderBy.Expressions.Add(DQOrderByExpression.Create("Date", true)); + dom.Where.Conditions.Add(DQCondition.LessThan("Date", DateTime.Today)); + dom.Range = SelectRange.Top(1); + return dom.EExecuteScalar(); + } + + private TitlePanel CreateResultTab() + { + var result = new TitlePanel("查询结果"); + mBrowseGrid = result.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) }); + mBrowseGrid.Columns.Add(new DFBrowseGridAutoColumn()); + return result; + } + + void StartQuery() + { + var dtdj = new JoinAlias(typeof(GradeAndWeight_Detail)); + var btrk = new JoinAlias(typeof(TrunksIousOutInStoreRecord)); + var query = new DQueryDom(dtdj); + query.From.AddJoin(JoinType.Left, new DQDmoSource(btrk), DQCondition.EQ(dtdj, "BarCode", btrk, "BarCode")); + query.Columns.Add(DQSelectColumn.Field("BarCode", "条码")); + query.Columns.Add(DQSelectColumn.Field("Livestock_Name", "胴体级别")); + query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "头数")); + query.Columns.Add(DQSelectColumn.Field("Weight", dtdj, "胴体重量")); + query.Columns.Add(DQSelectColumn.Field("Goods_Name", btrk, "存货名称")); + query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(btrk, "Weight"), "入库重量")); + query.Columns.Add(DQSelectColumn.Create(DQExpression.Subtract(DQExpression.Field(dtdj, "Weight"), DQExpression.IfNull(DQExpression.Field(btrk, "Weight"), DQExpression.Value(0))), "损耗")); + if (!string.IsNullOrEmpty(batchSelect.DisplayValue)) + query.Where.Conditions.Add(DQCondition.EQ(btrk, "ProductBatch", batchSelect.DisplayValue)); + var args = new LoadArguments(query); + args.SumColumns.Add(2); + args.SumColumns.Add(3); + args.SumColumns.Add(5); + args.SumColumns.Add(6); + mBrowseGrid.LoadArguments = args; + mBrowseGrid.DataBind(); + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if (!IsPostBack) + StartQuery(); + } + } +} diff --git a/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassStoreAnalyse_/CarcassStoreAnalyse.cs b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassStoreAnalyse_/CarcassStoreAnalyse.cs new file mode 100644 index 0000000..e8763e1 --- /dev/null +++ b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassStoreAnalyse_/CarcassStoreAnalyse.cs @@ -0,0 +1,139 @@ +using BWP.B3ClientService.BO; +using BWP.B3Frameworks.Utils; +using BWP.Web.WebControls; +using Forks.EnterpriseServices.DataForm; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.SqlDoms; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security; +using System.Text; +using System.Web.UI; +using System.Web.UI.HtmlControls; +using System.Web.UI.WebControls; +using TSingSoft.WebControls2; +using TSingSoft.WebControls2.DFGrids; +using TSingSoft.WebPluginFramework.Controls; +using TSingSoft.WebPluginFramework.Pages; +using TSingSoft.WebPluginFramework; +using System.Web; + +namespace BWP.Web.Pages.B3ClientService.Reports.CarcassStoreAnalyse_ +{ + class CarcassStoreAnalyse : ServerPage + { + protected override void OnInit(EventArgs e) + { + if (!User.IsInRole("B3ClientService.报表展示.白条库存")) + throw new SecurityException(); + base.OnInit(e); + } + + string SelectBatch { get { return Request.QueryString["BatchName"]; } } + + DFBrowseGrid mBrowseGrid; + protected override void InitForm(HtmlForm form) + { + form.EAdd(new PageTitle("白条库存")); + + var queryPanel = new Panel(); + queryPanel.Style.Add(HtmlTextWriterStyle.BackgroundColor, "white"); + queryPanel.CssClass = "QueryPanel PrintInVisible"; + form.Controls.Add(queryPanel); + + AddQueryControl(queryPanel); + + var mZone = new TitlePanelZone(); + form.Controls.Add(mZone); + + mZone.Add(CreateResultTab()); + } + + private void AddQueryControl(Panel queryPanel) + { + var hp = queryPanel.EAdd(new Panel()); + hp.Style.Add("float", "right"); + var batchNames = GetBatchNames(); + var url = Request.Url.ToString(); + foreach (var item in batchNames) + { + var hl = hp.EAdd(new HyperLink() { Text = item }); + hl.Style.Add("margin-right", "10px"); + hl.Style.Add("font-size", "15px"); + hl.NavigateUrl = AspUtil.UpdateUrlParam(url, "BatchName", HttpUtility.UrlEncode(item)); + if (item == SelectBatch) + { + hl.Style.Add("background-color", "#3CC24C"); + hl.Style.Add("color", "#FFFFFF"); + } + } + var all = hp.EAdd(new HyperLink() { Text = "全部" }); + all.Style.Add("margin-right", "10px"); + all.Style.Add("font-size", "15px"); + all.NavigateUrl = AspUtil.RemoveUrlParam(url, "BatchName"); + if (string.IsNullOrEmpty(SelectBatch)) + { + all.Style.Add("background-color", "#3CC24C"); + all.Style.Add("color", "#FFFFFF"); + } + } + + List GetBatchNames() + { +#if DEBUG + return new List { "20170809", "20170810", "20170811", "20170812" }; +#endif + var btrk = new JoinAlias(typeof(TrunksIousOutInStoreRecord)); + var btly = new JoinAlias(typeof(MaterialRequisitionRecord)); + var query = new DQueryDom(btrk); + query.From.AddJoin(JoinType.Left, new DQDmoSource(btly), DQCondition.EQ(btrk, "BarCode", btly, "BarCode")); + query.Columns.Add(DQSelectColumn.Field("ProductBatch")); + query.GroupBy.Expressions.Add(DQExpression.Field("ProductBatch")); + query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field(btly, "BarCode"))); + query.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field("ProductBatch"))); + query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ProductBatch")); + return query.EExecuteList(); + } + + private TitlePanel CreateResultTab() + { + var result = new TitlePanel("查询结果"); + mBrowseGrid = result.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) }); + mBrowseGrid.Columns.Add(new DFBrowseGridAutoColumn()); + return result; + } + + void StartQuery() + { + var btrk = new JoinAlias(typeof(TrunksIousOutInStoreRecord)); + var btly = new JoinAlias(typeof(MaterialRequisitionRecord)); + var query = new DQueryDom(btrk); + query.From.AddJoin(JoinType.Left, new DQDmoSource(btly), DQCondition.EQ(btrk, "BarCode", btly, "BarCode")); + query.Columns.Add(DQSelectColumn.Field("ProductBatch", "生产批次")); + query.Columns.Add(DQSelectColumn.Field("BarCode", "条码")); + query.Columns.Add(DQSelectColumn.Field("Goods_Name", "存货名称")); + query.Columns.Add(DQSelectColumn.Field("Number", "头数")); + query.Columns.Add(DQSelectColumn.Field("Weight", "重量")); + //query.GroupBy.Expressions.Add(DQExpression.Field("ProductBatch")); + //query.GroupBy.Expressions.Add(DQExpression.Field("BarCode")); + //query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Name")); + query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field(btly, "BarCode"))); + if (!string.IsNullOrEmpty(SelectBatch)) + query.Where.Conditions.Add(DQCondition.EQ("ProductBatch", SelectBatch)); + var args = new LoadArguments(query); + args.SumColumns.Add(3); + args.SumColumns.Add(4); + mBrowseGrid.LoadArguments = args; + mBrowseGrid.DataBind(); + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if (!IsPostBack) + StartQuery(); + } + } +} diff --git a/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassTrendAnalyse_/CarcassTrendAnalyse.cs b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassTrendAnalyse_/CarcassTrendAnalyse.cs new file mode 100644 index 0000000..62f2f9e --- /dev/null +++ b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassTrendAnalyse_/CarcassTrendAnalyse.cs @@ -0,0 +1,141 @@ +using BWP.B3ClientService; +using BWP.B3ClientService.BO; +using BWP.B3Frameworks.Utils; +using BWP.Web.Utils; +using BWP.Web.WebControls; +using Forks.EnterpriseServices.DataForm; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.SqlDoms; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security; +using System.Text; +using System.Web.UI; +using System.Web.UI.HtmlControls; +using System.Web.UI.WebControls; +using TSingSoft.WebControls2; +using TSingSoft.WebPluginFramework.Controls; +using TSingSoft.WebPluginFramework.Pages; +using TSingSoft.WebPluginFramework; + +namespace BWP.Web.Pages.B3ClientService.Reports.CarcassTrendAnalyse_ +{ + class CarcassTrendAnalyse : ServerPage + { + protected override void OnInit(EventArgs e) + { + if (!User.IsInRole("B3ClientService.报表展示.白条流向")) + throw new SecurityException(); + base.OnInit(e); + } + + DFBrowseGrid mBrowseGrid; + protected override void InitForm(HtmlForm form) + { + form.EAdd(new PageTitle("白条流向")); + + var queryPanel = new Panel(); + queryPanel.Style.Add(HtmlTextWriterStyle.BackgroundColor, "white"); + queryPanel.CssClass = "QueryPanel PrintInVisible"; + form.Controls.Add(queryPanel); + + AddQueryControl(queryPanel); + + var mZone = new TitlePanelZone(); + form.Controls.Add(mZone); + + mZone.Add(CreateResultTab()); + } + + DateInput dateInput; + private void AddQueryControl(Panel queryPanel) + { + var hp = queryPanel.EAdd(new Panel()); + hp.Style.Add("float", "right"); + hp.EAdd(new SimpleLabel("出库日期")); + dateInput = hp.EAdd(new DateInput() { Width = Unit.Pixel(100) }); + dateInput.Style.Add("margin-right", "10px"); + var btn = hp.EAdd(new TSButton("开始查询", delegate { StartQuery(); })); + btn.Style.Add("padding", "5px 10px"); + btn.Style.Add("margin-right", "10px"); + var rbtn = hp.EAdd(new RedirectTSButton("清除条件")); + rbtn.Style.Add("padding", "5px 10px"); + rbtn.Style.Add("margin-right", "10px"); + } + + private TitlePanel CreateResultTab() + { + var result = new TitlePanel("查询结果"); + mBrowseGrid = result.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) }); + mBrowseGrid.Columns.Add(new DFBrowseGridAutoColumn()); + return result; + } + + void StartQuery() + { + var query = new DQueryDom(new JoinAlias(typeof(UnionTemp))); + UnionTemp.Register(query, dateInput.Value); + + query.Columns.Add(DQSelectColumn.Field("OutType", "出库类型")); + query.Columns.Add(DQSelectColumn.Field("Date", "出库日期")); + query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Value(1)), "头数")); + query.Columns.Add(DQSelectColumn.Sum("InStoreWeight", "入库重量")); + query.Columns.Add(DQSelectColumn.Sum("OutStoreWeight", "出库重量")); + query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Subtract(DQExpression.IfNull(DQExpression.Field("InStoreWeight"), DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Field("OutStoreWeight"), DQExpression.Value(0)))), "损耗")); + query.GroupBy.Expressions.Add(DQExpression.Field("OutType")); + query.GroupBy.Expressions.Add(DQExpression.Field("Date")); + if (!dateInput.IsEmpty) + query.Where.Conditions.Add(DQCondition.EQ("Date", dateInput.Date)); + var args = new LoadArguments(query); + args.SumColumns.Add(2); + args.GroupSumColumns.Add(2); + args.SumColumns.Add(3); + args.SumColumns.Add(4); + args.SumColumns.Add(5); + args.GroupSumColumns.Add(6); + mBrowseGrid.LoadArguments = args; + mBrowseGrid.DataBind(); + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if (!IsPostBack) + StartQuery(); + } + } + + class UnionTemp + { + public string OutType { get; set; } + + public DateTime? Date { get; set; } + + public decimal? InStoreWeight { get; set; } + + public decimal? OutStoreWeight { get; set; } + + public static void Register(DQueryDom root, DateTime? date) + { + root.RegisterQueryTable(typeof(UnionTemp), new string[] { "OutType", "Date", "InStoreWeight", "OutStoreWeight" }, GetLinYong(date)); + } + + static DQueryDom GetLinYong(DateTime? date) + { + var btly = new JoinAlias("_linyong", typeof(MaterialRequisitionRecord)); + var btrk = new JoinAlias(typeof(TrunksIousOutInStoreRecord)); + var query = new DQueryDom(btly); + var dateExp = DQExpression.Snippet("CAST([_linyong].[CreateTime] as date)"); + query.From.AddJoin(JoinType.Left, new DQDmoSource(btrk), DQCondition.EQ(btrk, "BarCode", btly, "BarCode")); + query.Columns.Add(DQSelectColumn.Create(DQExpression.Value("分割领用"), "OutType")); + query.Columns.Add(DQSelectColumn.Create(dateExp, "Date")); + query.Columns.Add(DQSelectColumn.Field("Weight", btrk, "InStoreWeight")); + query.Columns.Add(DQSelectColumn.Field("Weight", btly, "OutStoreWeight")); + if (date.HasValue) + query.Where.Conditions.Add(DQCondition.EQ(dateExp, DQExpression.Value(date))); + return query; + } + } +} diff --git a/B3ClientService.Web/PluginClass.cs b/B3ClientService.Web/PluginClass.cs index c562ce2..8b3abfd 100644 --- a/B3ClientService.Web/PluginClass.cs +++ b/B3ClientService.Web/PluginClass.cs @@ -1,4 +1,5 @@ -using System; +using BWP.Web.Utils; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -11,6 +12,7 @@ namespace BWP.B3ClientService { public void OnInit() { + B3ClientServiceChoiceBoxDataProvider.Register(); } } } diff --git a/B3ClientService.Web/Utils/B3ClientServiceChoiceBoxDataProvider.cs b/B3ClientService.Web/Utils/B3ClientServiceChoiceBoxDataProvider.cs new file mode 100644 index 0000000..155636c --- /dev/null +++ b/B3ClientService.Web/Utils/B3ClientServiceChoiceBoxDataProvider.cs @@ -0,0 +1,32 @@ +using BWP.B3ClientService; +using BWP.B3ClientService.BO; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using TSingSoft.WebControls2; +using TSingSoft.WebPluginFramework; + +namespace BWP.Web.Utils +{ + public static class B3ClientServiceChoiceBoxDataProvider + { + public static void Register() + { + ChoiceBoxSettings.Register(B3ClientServiceConsts.DataSources.生产批次, argu => + { + var dom = new DQueryDom(new JoinAlias(typeof(ProductBatch))); + dom.Columns.Add(DQSelectColumn.Field("Name")); + + if (!string.IsNullOrWhiteSpace(argu.InputArgument)) + { + dom.Where.Conditions.Add(DQCondition.Like("Name", argu.InputArgument)); + } + dom.OrderBy.Expressions.Add(DQOrderByExpression.Create("Date", true)); + return dom.EExecuteList().Select(x => new TSingSoft.WebControls2.WordPair(x)); + }); + } + } +} diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj index f2c7e08..f634fae 100644 --- a/B3ClientService/B3ClientService.csproj +++ b/B3ClientService/B3ClientService.csproj @@ -70,6 +70,7 @@ + diff --git a/B3ClientService/B3ClientServiceConsts.cs b/B3ClientService/B3ClientServiceConsts.cs new file mode 100644 index 0000000..025964f --- /dev/null +++ b/B3ClientService/B3ClientServiceConsts.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.B3ClientService +{ + public static class B3ClientServiceConsts + { + public static class DataSources + { + internal const string Prefix = "B3ClientService_"; + public const string 生产批次 = Prefix + "生产批次"; + } + } +} diff --git a/B3ClientService/BO/BaseInfo/ProductBatch.cs b/B3ClientService/BO/BaseInfo/ProductBatch.cs index 4e2e3ea..fc0c2f9 100644 --- a/B3ClientService/BO/BaseInfo/ProductBatch.cs +++ b/B3ClientService/BO/BaseInfo/ProductBatch.cs @@ -14,5 +14,6 @@ namespace BWP.B3ClientService.BO { public long ID { get; set; } public string Name { get; set; } + public DateTime? Date { get; set; } } } diff --git a/B3ClientService/Tasks/SyncInfoFromServer.cs b/B3ClientService/Tasks/SyncInfoFromServer.cs index 620255f..b862950 100644 --- a/B3ClientService/Tasks/SyncInfoFromServer.cs +++ b/B3ClientService/Tasks/SyncInfoFromServer.cs @@ -86,6 +86,7 @@ namespace BWP.B3ClientService.Tasks private void SyncProductBatch() { var json = RpcFacade.Call("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/SyncProductBatch"); + json = json.ESerializeDateTime(); var list = JsonConvert.DeserializeObject>(json); using (var context = new TransactionContext()) { diff --git a/WebFolder/config/plugins/B3ClientService.plugin b/WebFolder/config/plugins/B3ClientService.plugin index 00c25c9..f5d7b01 100644 --- a/WebFolder/config/plugins/B3ClientService.plugin +++ b/WebFolder/config/plugins/B3ClientService.plugin @@ -34,11 +34,19 @@ + + + + + + + +