diff --git a/B3ClientService.Web/B3ClientService.Web.csproj b/B3ClientService.Web/B3ClientService.Web.csproj
index afd00fc..adaf9d7 100644
--- a/B3ClientService.Web/B3ClientService.Web.csproj
+++ b/B3ClientService.Web/B3ClientService.Web.csproj
@@ -126,16 +126,22 @@
ASPXCodeBehind
+
+ ASPXCodeBehind
+
+
+ ASPXCodeBehind
+
ASPXCodeBehind
ASPXCodeBehind
-
+
ASPXCodeBehind
-
+
ASPXCodeBehind
@@ -162,6 +168,9 @@
ASPXCodeBehind
+
+ ASPXCodeBehind
+
diff --git a/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInStoreLossAnalyse_/CarcassInStoreLossAnalyse.cs b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/CarcassInLossAnalyse.cs
similarity index 75%
rename from B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInStoreLossAnalyse_/CarcassInStoreLossAnalyse.cs
rename to B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/CarcassInLossAnalyse.cs
index e1de14b..849d999 100644
--- a/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInStoreLossAnalyse_/CarcassInStoreLossAnalyse.cs
+++ b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/CarcassInLossAnalyse.cs
@@ -21,14 +21,15 @@ using TSingSoft.WebPluginFramework;
using BWP.B3Frameworks.BO.MoneyTemplate;
using Forks.Utils;
using System.Web;
+using BWP.Web.Utils;
-namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInStoreLossAnalyse_
+namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInOutLossAnalyse_
{
- class CarcassInStoreLossAnalyse : ServerPage
+ class CarcassInLossAnalyse : ServerPage
{
protected override void OnInit(EventArgs e)
{
- if (!User.IsInRole("B3ClientService.报表展示.白条入库差异"))
+ if (!User.IsInRole("B3ClientService.报表展示.白条出入库差异"))
throw new SecurityException();
base.OnInit(e);
}
@@ -36,7 +37,7 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInStoreLossAnalyse_
DFBrowseGrid mBrowseGrid;
protected override void InitForm(HtmlForm form)
{
- form.EAdd(new PageTitle("白条入库差异"));
+ form.EAdd(new PageTitle("白条出入库差异"));
var queryPanel = new Panel();
queryPanel.Style.Add(HtmlTextWriterStyle.BackgroundColor, "white");
@@ -61,7 +62,7 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInStoreLossAnalyse_
string BuildUrl(string livestockID)
{
- var url = "~/B3ClientService/Reports/CarcassInStoreLossAnalyse_/InStoreDetail.aspx";
+ var url = "~/B3ClientService/Reports/CarcassInOutLossAnalyse_/InStoreDetail.aspx";
url = AspUtil.AddParamToUrl(url, "Date", dateInput.Text);
url = AspUtil.AddParamToUrl(url, "ProductBatchID", batchSelect.Value);
url = AspUtil.AddParamToUrl(url, "Livestock_ID", livestockID);
@@ -78,15 +79,29 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInStoreLossAnalyse_
ChoiceBox batchSelect;
DFDateInput dateInput;
+ HyperLink inStore, outStore;
private void AddQueryControl(Panel queryPanel)
{
var hp = queryPanel.EAdd(new Panel());
hp.Style.Add("float", "right");
hp.EAdd(new SimpleLabel("生产日期"));
- dateInput = hp.EAdd(new DFDateInput() { Date = DateTime.Today });
+ dateInput = hp.EAdd(new DFDateInput() { Date = DateTime.Today });
hp.EAdd(new SimpleLabel("生产批次"));
- batchSelect = hp.EAdd(new ChoiceBox(B3ClientServiceConsts.DataSources.生产批次) { EnableInputArgument = true, EnableTopItem = true, AutoPostBack = true, Width = Unit.Pixel(180) });
+ batchSelect = hp.EAdd(new ChoiceBox(B3ClientServiceConsts.DataSources.生产批次) { EnableInputArgument = true, EnableTopItem = true, Width = Unit.Pixel(180) });
hp.EAdd(new TSButton("开始查询", delegate { StartQuery(); }));
+
+ inStore = hp.EAdd(new HyperLink());
+ inStore.Text = "白条入库";
+ inStore.Style.Add("margin", "0px 10px");
+ inStore.Style.Add("font-size", "15px");
+ inStore.Style.Add("background-color", "#3CC24C");
+ inStore.Style.Add("color", "#FFFFFF");
+
+ outStore = hp.EAdd(new HyperLink());
+ outStore.Text = "白条出库";
+ outStore.Style.Add("margin-right", "10px");
+ outStore.Style.Add("font-size", "15px");
+ outStore.Style.Add("color", "blue");
}
private TitlePanel CreateResultTab()
@@ -95,7 +110,7 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInStoreLossAnalyse_
mBrowseGrid = result.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) });
mBrowseGrid.Columns.Add(new DFBrowseGridAutoColumn("Livestock_ID"));
var hPanel = result.EAdd(new HLayoutPanel());
- PageUtil.AddExcelExportPanel(hPanel, mBrowseGrid, "白条损耗");
+ PageUtil.AddExcelExportPanel(hPanel, mBrowseGrid, "入库损耗");
return result;
}
@@ -115,7 +130,7 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInStoreLossAnalyse_
query.GroupBy.Expressions.Add(DQExpression.Field(livestock, "Name"));
var gNumber = DQExpression.Sum(DQExpression.LogicCase(DQCondition.IsNotNull(DQExpression.Field("Livestock_ID")), DQExpression.Value(1), DQExpression.Value(0)));
query.Columns.Add(DQSelectColumn.Create(gNumber.ECastType(), "头数"));
- var gWeight=DQExpression.Subtract(DQExpression.Field("GradeWeight"),DQExpression.Value(4.2m));
+ var gWeight = DQExpression.Subtract(DQExpression.Field("GradeWeight"), DQExpression.Value(4.2m));
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(gWeight).ECastType(), "胴体重量"));
query.Columns.Add(DQSelectColumn.Create(DQExpression.Divide(DQExpression.Sum(gWeight), DQExpression.NullIfZero(gNumber)).ECastType?>(), "胴体均重"));
var iNumber = DQExpression.Sum(DQExpression.LogicCase(DQCondition.IsNotNull(DQExpression.Field("InStoreGoods_ID")), DQExpression.Value(1), DQExpression.Value(0)));
@@ -142,11 +157,36 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInStoreLossAnalyse_
mBrowseGrid.DataBind();
}
+ void BindHyperLink()
+ {
+ string date = string.Empty;
+ if (dateInput.Value.HasValue)
+ date = HttpUtility.UrlEncode(dateInput.Date.ToShortDateString());
+ var url = string.Format("CarcassInLossAnalyse.aspx?ProductBatch_ID={0}&ProductDate={1}", batchSelect.Value, date);
+ inStore.NavigateUrl = url;
+ outStore.NavigateUrl = url.Replace("In", "Out");
+ }
+
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!IsPostBack)
+ {
+ FillCondition();
StartQuery();
+ }
+ BindHyperLink();
+ }
+
+ void FillCondition()
+ {
+ if (!string.IsNullOrEmpty(Request.QueryString["ProductDate"]))
+ dateInput.Date = DateTime.Parse(Request.QueryString["ProductDate"]);
+ if (!string.IsNullOrEmpty(Request.QueryString["ProductBatch_ID"]))
+ {
+ var name = WebBLUtil.GetDmoPropertyByID(typeof(ProductBatch), "Name", long.Parse(Request.QueryString["ProductBatch_ID"]));
+ batchSelect.Fill(Request.QueryString["ProductBatch_ID"], name);
+ }
}
}
}
diff --git a/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/CarcassOutLossAnalyse.cs b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/CarcassOutLossAnalyse.cs
new file mode 100644
index 0000000..9ada90b
--- /dev/null
+++ b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/CarcassOutLossAnalyse.cs
@@ -0,0 +1,208 @@
+using BWP.B3ClientService;
+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.WebPluginFramework.Controls;
+using TSingSoft.WebPluginFramework.Pages;
+using TSingSoft.WebPluginFramework;
+using BWP.B3Frameworks.BO.MoneyTemplate;
+using Forks.Utils;
+using System.Web;
+using BWP.Web.Utils;
+
+namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInOutLossAnalyse_
+{
+ class CarcassOutLossAnalyse : 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());
+ mBrowseGrid.OnDetailDataBound = (tr, obj, index) =>
+ {
+ var row = obj as DFDataRow;
+ var lid = string.Format("{0}", row["InStoreGoods_ID"]);
+ var url = BuildUrl(string.Format("{0}", lid));
+ url = WpfPageUrl.ToGlobal(url);
+ url = AspUtil.AddParamToUrl(url, "Flag", "2");
+ SetCellAtt(tr.Cells[3], url, "出库明细");
+
+ url = AspUtil.UpdateUrlParam(url, "Flag", "1");
+ SetCellAtt(tr.Cells[5], url, "出库明细");
+ };
+ }
+
+ string BuildUrl(string goodsID)
+ {
+ var url = "~/B3ClientService/Reports/CarcassInOutLossAnalyse_/OutStoreDetail.aspx";
+ url = AspUtil.AddParamToUrl(url, "Date", dateInput.Text);
+ url = AspUtil.AddParamToUrl(url, "ProductBatchID", batchSelect.Value);
+ url = AspUtil.AddParamToUrl(url, "Goods_ID", goodsID);
+ return url;
+ }
+
+ void SetCellAtt(HtmlTableCell cell, string url, string title)
+ {
+ cell.Attributes["onclick"] = "OpenUrlInTopTab('" + url + "','" + title + "');";
+ cell.Style.Add("color", "blue");
+ cell.Style.Add("text-decoration", "underline");
+ cell.Style.Add("cursor", "pointer");
+ }
+
+ ChoiceBox batchSelect;
+ DFDateInput dateInput;
+ HyperLink inStore, outStore;
+ private void AddQueryControl(Panel queryPanel)
+ {
+ var hp = queryPanel.EAdd(new Panel());
+ hp.Style.Add("float", "right");
+ hp.EAdd(new SimpleLabel("生产日期"));
+ dateInput = hp.EAdd(new DFDateInput() { Date = DateTime.Today });
+ if (!string.IsNullOrEmpty(Request.QueryString["ProductDate"]))
+ dateInput.Date = DateTime.Parse(Request.QueryString["ProductDate"]);
+ hp.EAdd(new SimpleLabel("生产批次"));
+ batchSelect = hp.EAdd(new DFChoiceBox() { DataKind = B3ClientServiceConsts.DataSources.生产批次, EnableInputArgument = true, EnableTopItem = true, Width = Unit.Pixel(180) });
+ if (!string.IsNullOrEmpty(Request.QueryString["ProductBatch_ID"]))
+ {
+ var name = WebBLUtil.GetDmoPropertyByID(typeof(ProductBatch), "Name", long.Parse(Request.QueryString["ProductBatch_ID"]));
+ batchSelect.Fill(Request.QueryString["ProductBatch_ID"], name);
+ }
+ hp.EAdd(new TSButton("开始查询", delegate { StartQuery(); }));
+
+ inStore = hp.EAdd(new HyperLink());
+ inStore.Text = "白条入库";
+ inStore.Style.Add("margin", "0px 10px");
+ inStore.Style.Add("font-size", "15px");
+ inStore.Style.Add("color", "blue");
+
+ outStore = hp.EAdd(new HyperLink());
+ outStore.Text = "白条出库";
+ outStore.Style.Add("margin-right", "10px");
+ outStore.Style.Add("font-size", "15px");
+ outStore.Style.Add("background-color", "#3CC24C");
+ outStore.Style.Add("color", "#FFFFFF");
+ }
+
+ private TitlePanel CreateResultTab()
+ {
+ var result = new TitlePanel("查询结果");
+ mBrowseGrid = result.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) });
+ mBrowseGrid.Columns.Add(new DFBrowseGridAutoColumn("InStoreGoods_ID"));
+ var hPanel = result.EAdd(new HLayoutPanel());
+ PageUtil.AddExcelExportPanel(hPanel, mBrowseGrid, "白条出库损耗");
+ return result;
+ }
+
+ void StartQuery()
+ {
+ var main = new JoinAlias(typeof(CarcassFullInfo));
+ var goods = new JoinAlias(typeof(Goods));
+ var batch = new JoinAlias(typeof(ProductBatch));
+ var query = new DQueryDom(main);
+ query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, "InStoreGoods_ID", goods, "ID"));
+ query.From.AddJoin(JoinType.Left, new DQDmoSource(batch), DQCondition.EQ(main, "ProductBatch_ID", batch, "ID"));
+ query.Columns.Add(DQSelectColumn.Field("InStoreGoods_ID"));
+ query.GroupBy.Expressions.Add(DQExpression.Field("InStoreGoods_ID"));
+ query.Columns.Add(DQSelectColumn.Field("Name", goods, "存货名称"));
+ query.GroupBy.Expressions.Add(DQExpression.Field(goods, "Name"));
+
+ var inNumber = DQExpression.Sum(DQExpression.LogicCase(DQCondition.IsNull(DQExpression.Field("InStoreTime")), DQExpression.NULL, DQExpression.Value(1)));
+ var inWeight = DQExpression.Sum(DQExpression.LogicCase(DQCondition.IsNull(DQExpression.Field("InStoreTime")), DQExpression.NULL, DQExpression.Field("InStoreWeight")));
+ query.Columns.Add(DQSelectColumn.Create(inNumber.ECastType(), "入库头数"));
+ query.Columns.Add(DQSelectColumn.Create(inWeight.ECastType(), "入库重量"));
+
+ query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 1), DQExpression.Field("PickNumber"))).ECastType(), "销售出库|头数"));
+ query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 1), DQExpression.Field("PickWeight"))).ECastType(), "销售出库|重量"));
+
+ query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 0), DQExpression.Field("PickNumber"))).ECastType(), "分割领用|头数"));
+ query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 0), DQExpression.Field("PickWeight"))).ECastType(), "分割领用|重量"));
+
+ query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 2), DQExpression.Field("PickNumber"))).ECastType(), "条转段|头数"));
+ query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 2), DQExpression.Field("PickWeight"))).ECastType(), "条转段|重量"));
+
+ query.Columns.Add(DQSelectColumn.Sum("PickNumber", "合计|头数"));
+ query.Columns.Add(DQSelectColumn.Sum("PickWeight", "合计|重量"));
+
+ query.Columns.Add(DQSelectColumn.Create(DQExpression.Subtract(DQExpression.IfNull(inNumber, DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Sum(DQExpression.Field("PickNumber")), DQExpression.Value(0))).ECastType(), "损耗|头数"));
+ query.Columns.Add(DQSelectColumn.Create(DQExpression.Subtract(DQExpression.IfNull(inWeight, DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Sum(DQExpression.Field("PickWeight")), DQExpression.Value(0))).ECastType(), "损耗|重量"));
+
+ if (!batchSelect.IsEmpty)
+ query.Where.Conditions.Add(DQCondition.EQ("ProductBatch_ID", long.Parse(batchSelect.Value)));
+ if (!dateInput.IsEmpty)
+ query.Where.Conditions.Add(DQCondition.EQ(batch, "Date", dateInput.Date));
+ var args = new LoadArguments(query);
+ for (var i = 0; i < query.Columns.Count; i++)
+ {
+ if (i <= 1)
+ continue;
+ args.SumColumns.Add(i);
+ args.GroupSumColumns.Add(i);
+ }
+ mBrowseGrid.LoadArguments = args;
+ mBrowseGrid.DataBind();
+ }
+
+ void BindHyperLink()
+ {
+ string date = string.Empty;
+ if (dateInput.Value.HasValue)
+ date = HttpUtility.UrlEncode(dateInput.Date.ToShortDateString());
+ var url = string.Format("CarcassInLossAnalyse.aspx?ProductBatch_ID={0}&ProductDate={1}", batchSelect.Value, date);
+ inStore.NavigateUrl = url;
+ outStore.NavigateUrl = url.Replace("In", "Out");
+ }
+
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+ if (!IsPostBack)
+ {
+ FillCondition();
+ StartQuery();
+ }
+ BindHyperLink();
+ }
+
+ void FillCondition()
+ {
+ if (!string.IsNullOrEmpty(Request.QueryString["ProductDate"]))
+ dateInput.Date = DateTime.Parse(Request.QueryString["ProductDate"]);
+ if (!string.IsNullOrEmpty(Request.QueryString["ProductBatch_ID"]))
+ {
+ var name = WebBLUtil.GetDmoPropertyByID(typeof(ProductBatch), "Name", long.Parse(Request.QueryString["ProductBatch_ID"]));
+ batchSelect.Fill(Request.QueryString["ProductBatch_ID"], name);
+ }
+ }
+ }
+}
diff --git a/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInStoreLossAnalyse_/InStoreDetail.cs b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/InStoreDetail.cs
similarity index 98%
rename from B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInStoreLossAnalyse_/InStoreDetail.cs
rename to B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/InStoreDetail.cs
index c7d61cb..c5b1aab 100644
--- a/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInStoreLossAnalyse_/InStoreDetail.cs
+++ b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/InStoreDetail.cs
@@ -18,7 +18,7 @@ using Forks.Utils;
using BWP.B3Frameworks.BO.MoneyTemplate;
using Forks.EnterpriseServices.DataForm;
-namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInStoreLossAnalyse_
+namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInOutLossAnalyse_
{
class InStoreDetail : ServerPage
{
diff --git a/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/OutStoreDetail.cs b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/OutStoreDetail.cs
new file mode 100644
index 0000000..e6a26fe
--- /dev/null
+++ b/B3ClientService.Web/Pages/B3ClientService/Reports/CarcassInOutLossAnalyse_/OutStoreDetail.cs
@@ -0,0 +1,123 @@
+using BWP.B3ClientService.BO;
+using BWP.B3Frameworks.Utils;
+using BWP.Web.Utils;
+using Forks.EnterpriseServices.DomainObjects2;
+using Forks.EnterpriseServices.DomainObjects2.DQuery;
+using Forks.EnterpriseServices.SqlDoms;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Web.UI.HtmlControls;
+using System.Web.UI.WebControls;
+using TSingSoft.WebControls2;
+using TSingSoft.WebPluginFramework.Controls;
+using TSingSoft.WebPluginFramework.Pages;
+using TSingSoft.WebPluginFramework;
+using Forks.Utils;
+using BWP.B3Frameworks.BO.MoneyTemplate;
+using Forks.EnterpriseServices.DataForm;
+using BWP.B3ClientService.NamedValueTemplate;
+
+namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInOutLossAnalyse_
+{
+ class OutStoreDetail : ServerPage
+ {
+ long? GoodsID
+ {
+ get
+ {
+ if (string.IsNullOrEmpty(Request.QueryString["Goods_ID"]))
+ return null;
+ return long.Parse(Request.QueryString["Goods_ID"]);
+ }
+ }
+
+ DateTime? Date
+ {
+ get
+ {
+ if (string.IsNullOrEmpty(Request.QueryString["Date"]))
+ return null;
+ return DateTime.Parse(Request.QueryString["Date"]);
+ }
+ }
+
+ long? ProductBatchID
+ {
+ get
+ {
+ if (string.IsNullOrEmpty(Request.QueryString["ProductBatchID"]))
+ return null;
+ return long.Parse(Request.QueryString["ProductBatchID"]);
+ }
+ }
+
+ int Flag
+ {
+ get
+ {
+ return int.Parse(Request.QueryString["Flag"]);
+ }
+ }
+
+ DFBrowseGrid mBrowseGrid;
+ protected override void InitForm(HtmlForm form)
+ {
+ string lName = string.Empty;
+ if (GoodsID.HasValue)
+ lName = WebBLUtil.GetDmoPropertyByID(typeof(Goods), "Name", GoodsID.Value);
+ form.Controls.Add(new PageTitle(string.Format("{0}{1}明细", lName, Flag == 1 ? "领用" : "销售")));
+
+ mBrowseGrid = form.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) });
+ mBrowseGrid.Columns.Add(new DFBrowseGridAutoColumn());
+ }
+
+ void StartQuery()
+ {
+ var jF="InStoreGoods_ID";
+ if (Flag == 2)
+ jF = "SaleGoods_ID";
+ var main = new JoinAlias(typeof(CarcassFullInfo));
+ var goods = new JoinAlias(typeof(Goods));
+ var batch = new JoinAlias(typeof(ProductBatch));
+ var query = new DQueryDom(main);
+ query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, jF, goods, "ID"));
+ query.From.AddJoin(JoinType.Left, new DQDmoSource(batch), DQCondition.EQ(main, "ProductBatch_ID", batch, "ID"));
+ query.Columns.Add(DQSelectColumn.Field("Name", goods, "存货"));
+ query.GroupBy.Expressions.Add(DQExpression.Field(goods, "Name"));
+
+ query.Columns.Add(DQSelectColumn.Sum("PickNumber", "头数"));
+ query.Columns.Add(DQSelectColumn.Sum("PickWeight", "重量"));
+
+ query.Where.Conditions.Add(DQCondition.EQ("PickType", Flag == 1 ? 领用类型.分割领用 : 领用类型.白条销售));
+
+ if (ProductBatchID.HasValue)
+ query.Where.Conditions.Add(DQCondition.EQ("ProductBatch_ID", ProductBatchID));
+ if (Date.HasValue)
+ query.Where.Conditions.Add(DQCondition.EQ(batch, "Date", Date));
+ if (GoodsID.HasValue)
+ query.Where.Conditions.Add(DQCondition.EQ("InStoreGoods_ID", GoodsID));
+ else
+ query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("InStoreGoods_ID")));
+
+ var args = new LoadArguments(query);
+ for (var i = 0; i < query.Columns.Count; i++)
+ {
+ if (i <= 0)
+ continue;
+ args.SumColumns.Add(i);
+ args.GroupSumColumns.Add(i);
+ }
+ mBrowseGrid.LoadArguments = args;
+ mBrowseGrid.DataBind();
+ }
+
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+ if (!IsPostBack)
+ StartQuery();
+ }
+ }
+}
diff --git a/B3ClientService.Web/Pages/B3ClientService/ToolsPage.cs b/B3ClientService.Web/Pages/B3ClientService/ToolsPage.cs
new file mode 100644
index 0000000..7fc04dc
--- /dev/null
+++ b/B3ClientService.Web/Pages/B3ClientService/ToolsPage.cs
@@ -0,0 +1,47 @@
+using BWP.B3ClientService.BL;
+using BWP.B3ClientService.BO;
+using Forks.EnterpriseServices.DomainObjects2;
+using Forks.EnterpriseServices.DomainObjects2.DQuery;
+using Forks.EnterpriseServices.SqlDoms;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TSingSoft.WebControls2;
+using TSingSoft.WebPluginFramework.Pages;
+
+namespace BWP.Web.Pages.B3ClientService
+{
+ class ToolsPage : ServerPage
+ {
+ protected override void InitForm(System.Web.UI.HtmlControls.HtmlForm form)
+ {
+ var textbox = form.EAdd(new DFDateInput());
+ var range = form.EAdd(new DFTextBox());
+ var minID = form.EAdd(new DFTextBox());
+ form.Controls.Add(new TSButton("DO", delegate
+ {
+
+ using (var session = Dmo.NewSession())
+ {
+ var q = new DmoQuery(typeof(GradeAndWeight_Detail));
+ q.Range = SelectRange.Top(int.Parse(range.Text));
+ q.Where.Conditions.Add(DQCondition.EQ("Date", textbox.Date));
+ q.Where.Conditions.Add(DQCondition.GreaterThan("ID", long.Parse(minID.Text)));
+ q.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
+ var lst = session.ExecuteList(q).Cast();
+ foreach (var item in lst)
+ {
+ GradeAndWeightBL.InsertTraceBack(item, session);
+ }
+
+ session.Commit();
+ var mx = 0L;
+ if (lst.Any())
+ mx = lst.Max(x => x.ID);
+ AspUtil.Alert(this, lst.Count().ToString() + "Max_" + mx);
+ }
+ }));
+ }
+ }
+}
diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj
index ca27539..0b1f49b 100644
--- a/B3ClientService/B3ClientService.csproj
+++ b/B3ClientService/B3ClientService.csproj
@@ -136,7 +136,7 @@
-
+
diff --git a/B3ClientService/BO/Bill/ButcherTraceBackInfo.cs b/B3ClientService/BO/Bill/ButcherTraceBackInfo.cs
new file mode 100644
index 0000000..5cffc0e
--- /dev/null
+++ b/B3ClientService/BO/Bill/ButcherTraceBackInfo.cs
@@ -0,0 +1,25 @@
+using BWP.B3Frameworks.BO;
+using Forks.EnterpriseServices.DomainObjects2;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TSingSoft.WebPluginFramework;
+
+namespace BWP.B3ClientService.BO
+{
+ [BOClass]
+ public class ButcherTraceBackInfo
+ {
+ public long GID { get; set; }
+ public string Code { get; set; }
+ public string Goods_Name { get; set; }
+ public string ProductDate { get; set; }
+ public string PigFarmAddress { get; set; }
+ public string TestingNo { get; set; }
+ public string TestingMan { get; set; }
+ public string Farmer { get; set; }
+ public string ButcherBatch { get; set; }
+ public string ButcherTime { get; set; }
+ }
+}
diff --git a/B3ClientService/BO/Bill/ButcherTraceBackLog.cs b/B3ClientService/BO/Bill/ButcherTraceBackLog.cs
deleted file mode 100644
index 9bd5233..0000000
--- a/B3ClientService/BO/Bill/ButcherTraceBackLog.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using TSingSoft.WebPluginFramework;
-
-namespace BWP.B3ClientService.BO
-{
- [BOClass]
- public class ButcherTraceBackLog
- {
- public long GradeAndWeight_ID { get; set; }
- }
-}
diff --git a/B3ClientService/OfflinRpc/GradeAndWeightBL.cs b/B3ClientService/OfflinRpc/GradeAndWeightBL.cs
index 26a8c64..b5f8313 100644
--- a/B3ClientService/OfflinRpc/GradeAndWeightBL.cs
+++ b/B3ClientService/OfflinRpc/GradeAndWeightBL.cs
@@ -2,6 +2,7 @@
using BWP.B3Frameworks.Utils;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
+using Forks.EnterpriseServices.SqlDoms;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -21,6 +22,47 @@ namespace BWP.B3ClientService.BL
Update(id.Value, obj, session);
else
Insert(obj, session);
+ InsertTraceBack(obj, session);
+ }
+
+ public static void InsertTraceBack(GradeAndWeight_Detail obj, IDmoSession session)
+ {
+ var trace = new ButcherTraceBackInfo();
+ trace.Code = obj.BarCode;
+ trace.Goods_Name = obj.Technics == 0 ? "带皮白条" : "去皮白条";
+ trace.ProductDate = obj.Time.ToString("yyyyMMdd");
+ trace.ButcherTime = obj.Date.Value.ToString("yyyyMMdd");
+ trace.ButcherBatch = string.Format("{0}{1:000}", trace.ButcherTime, obj.Index);
+ trace.GID = obj.ID;
+
+ if (obj.OrderDetail_ID.HasValue)
+ {
+ var order = new JoinAlias(typeof(OrderDetail));
+ var weight = new JoinAlias(typeof(WeightBill));
+ var wf = new JoinAlias(typeof(WeightBill_FarmerDetail));
+ var query = new DQueryDom(order);
+ query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.EQ(order, "WeightBill_ID", weight, "ID"));
+ query.From.AddJoin(JoinType.Left, new DQDmoSource(wf), DQCondition.And(DQCondition.EQ(wf, "DeleteState", false), DQCondition.EQ(weight, "ID", wf, "WeightBill_ID")));
+
+ query.Columns.Add(DQSelectColumn.Field("Farmer_Name", wf));
+ query.Columns.Add(DQSelectColumn.Field("Farmer_Address", wf));
+ query.Columns.Add(DQSelectColumn.Field("AnimalTestNumber", weight));
+ query.Columns.Add(DQSelectColumn.Field("AnimalTestMan", weight));
+
+ query.Where.Conditions.Add(DQCondition.EQ(order, "ID", obj.OrderDetail_ID));
+ query.Range = SelectRange.Top(1);
+ using (var reader = session.ExecuteReader(query))
+ {
+ if (reader.Read())
+ {
+ trace.Farmer = (string)reader[0];
+ trace.PigFarmAddress = (string)reader[1];
+ trace.TestingNo = (string)reader[2];
+ trace.TestingMan = (string)reader[3];
+ }
+ }
+ }
+ session.Insert(trace);
}
static long? GetID(string code, IDmoSession session)
diff --git a/B3ClientService/OfflinRpc/SectionStoreDetailRpc.cs b/B3ClientService/OfflinRpc/SectionStoreDetailRpc.cs
index e8787a5..9815b21 100644
--- a/B3ClientService/OfflinRpc/SectionStoreDetailRpc.cs
+++ b/B3ClientService/OfflinRpc/SectionStoreDetailRpc.cs
@@ -17,11 +17,13 @@ namespace BWP.B3ClientService.Rpcs
public static class SectionStoreDetailRpc
{
[Rpc(RpcFlags.SkipAuth)]
- public static int Insert(string json)
+ public static string Insert(string json)
{
var arr = JsonConvert.DeserializeObject>(json);
if (arr.Count == 0)
- return 0;
+ return "无转段信息";
+ var tp = new List>();
+ var list = new List();
using (var session = Dmo.NewSession())
{
var query = new DQueryDom(new JoinAlias(typeof(CarcassFullInfo)));
@@ -31,8 +33,6 @@ namespace BWP.B3ClientService.Rpcs
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNull(DQExpression.Field("PickTime")), DQCondition.InList(DQExpression.Field("BarCode"), arr.Select(x => DQExpression.Value(x.BarCode)).ToArray())));
var config = GetSectionConfig(session);
- var tp = new List>();
- var list = new List();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
@@ -59,15 +59,28 @@ namespace BWP.B3ClientService.Rpcs
list.Add(e2);
}
}
- foreach (var item in list)
- session.Insert(item);
+ if (list.Any())
+ {
+ foreach (var item in list)
+ session.Insert(item);
- foreach (var item in tp)
- SetCarcassTakeOut(session, item);
+ foreach (var item in tp)
+ SetCarcassTakeOut(session, item);
- session.Commit();
+ session.Commit();
+ }
}
- return arr.Count;
+
+ if (tp.Count == arr.Count)
+ return string.Format("成功,本次转段{0}头", arr.Count);
+ if (tp.Count == 0)
+ return string.Format("无转段信息,扫码重复", arr.Count);
+ var msg = string.Empty;
+ if (tp.Count > 0)
+ msg = string.Format("本次转段{0}头 ", tp.Count);
+ if (tp.Count < arr.Count)
+ msg += string.Format("重复{0}头", arr.Count - tp.Count);
+ return msg;
}
static void SetCarcassTakeOut(IDmoSession session, Tuple item)
diff --git a/B3ClientService/Tasks/SyncCarcassInStoreToTrackBack.cs b/B3ClientService/Tasks/SyncCarcassInStoreToTrackBack.cs
index e3468a9..9e31931 100644
--- a/B3ClientService/Tasks/SyncCarcassInStoreToTrackBack.cs
+++ b/B3ClientService/Tasks/SyncCarcassInStoreToTrackBack.cs
@@ -40,7 +40,7 @@ namespace BWP.B3ClientService.Tasks
var arr = JsonConvert.SerializeObject(infos);
TraceBackInfoUtil.Insert(sUrl, arr);
}
- DeleteSyncd(session, list.Min(x => x.ID), list.Max(x => x.ID));
+ DeleteSyncd (session, list.Min(x => x.ID), list.Max(x => x.ID),"ID");
}
List GetUnSyncdInfo(IDmoSession session)
@@ -54,10 +54,10 @@ namespace BWP.B3ClientService.Tasks
return list.Select(x => new TraceBackInStoreInfo { ID = x.Item1, Code = x.Item2, InStoreDate = x.Item3 }).ToList();
}
- void DeleteSyncd(IDmoSession session, long min, long max)
+ void DeleteSyncd(IDmoSession session, long min, long max,string idF)
{
- var delete = new DQDeleteDom(typeof(SyncCarcassInStoreLog));
- delete.Where.Conditions.Add(DQCondition.Between("ID", min, max));
+ var delete = new DQDeleteDom(typeof(T));
+ delete.Where.Conditions.Add(DQCondition.Between(idF, min, max));
session.ExecuteNonQuery(delete);
}
@@ -69,133 +69,21 @@ namespace BWP.B3ClientService.Tasks
return;
var arr = JsonConvert.SerializeObject(list);
TraceBackInfoUtil.Insert(sUrl, arr);
- foreach (var item in list)
- session.Insert(new ButcherTraceBackLog { GradeAndWeight_ID = item.ID });
+ DeleteSyncd(session, list.Min(x => x.GID), list.Max(x => x.GID), "GID");
}
- List GetTraceBackInfo(IDmoSession session)
+ IEnumerable GetTraceBackInfo(IDmoSession session)
{
- var list = new List();
-
- var main = new JoinAlias(typeof(GradeAndWeight_Detail));
- var log = new JoinAlias(typeof(ButcherTraceBackLog));
- var detail = new JoinAlias(typeof(OrderDetail));
- var weight = new JoinAlias(typeof(WeightBill));
- var query = new DQueryDom(main);
- query.From.AddJoin(JoinType.Left, new DQDmoSource(log), DQCondition.EQ(main, "ID", log, "GradeAndWeight_ID"));
- query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "OrderDetail_ID", detail, "ID"));
- query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.EQ(detail, "WeightBill_ID", weight, "ID"));
- var wd = WeightFramerTemp.Register(query, weight);
- var wf = new JoinAlias("_farmerQ2", typeof(WeightBill_FarmerDetail));
- var farmer = new JoinAlias(typeof(Farmer));
- query.From.AddJoin(JoinType.Left, new DQDmoSource(wf), DQCondition.EQ(wd, "FID", wf, "ID"));
- query.From.AddJoin(JoinType.Left, new DQDmoSource(farmer), DQCondition.EQ(wf, "Farmer_ID", farmer, "ID"));
- query.Columns.Add(DQSelectColumn.Field("BarCode"));
- query.Columns.Add(DQSelectColumn.Field("Technics"));
- query.Columns.Add(DQSelectColumn.Field("Time"));
- query.Columns.Add(DQSelectColumn.Field("Date"));
- query.Columns.Add(DQSelectColumn.Field("Index"));
- query.Columns.Add(DQSelectColumn.Field("AnimalTestNumber", weight));
- query.Columns.Add(DQSelectColumn.Field("AnimalTestMan", weight));
- query.Columns.Add(DQSelectColumn.Field("Name", farmer));
- query.Columns.Add(DQSelectColumn.Field("Address", farmer));
- query.Columns.Add(DQSelectColumn.Field("Farmer_Name", wf));
- query.Columns.Add(DQSelectColumn.Field("Farmer_Address", wf));
- query.Columns.Add(DQSelectColumn.Field("ID"));
+ var query = new DmoQuery(typeof(ButcherTraceBackInfo));
+ query.OrderBy.Expressions.Add(DQOrderByExpression.Create("GID"));
query.Range = SelectRange.Top(500);
- query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
- query.Where.Conditions.Add(DQCondition.And(DQCondition.InEQ(DQExpression.Field("BarCode"), DQExpression.Value("")), DQCondition.IsNull(DQExpression.Field(log, "GradeAndWeight_ID"))));
- query.Where.Conditions.Add(DQCondition.GreaterThan("Date", new DateTime(2018, 5, 12)));
- using (var reader = session.ExecuteReader(query))
- {
- while (reader.Read())
- {
- var info = new TraceBackInfo();
- info.Code = (string)reader[0];
- info.Goods_Name = (short)reader[1] == 0 ? "带皮白条" : "去皮白条";
- info.ProductDate = string.Format("{0:yyyyMMdd}", reader[2]);
- info.ExpirationTime = "0-4℃ 4日";
- info.ProductCompany = "青岛万福集团股份有限公司";
- info.CompanyAddress = "青岛莱西市珠海路五号";
- info.CompanyTel = "0532-55650698";
- info.ButcherTime = string.Format("{0:yyyyMMdd}", reader[3]);
- info.ButcherBatch = string.Format("{0}{1:000}", info.ButcherTime, reader[4]);
- info.TestingNo = (string)reader[5];
- info.TestingMan = (string)reader[6];
- if (!string.IsNullOrEmpty(info.TestingNo))
- info.TestingResult = "合格";
- info.Farmer = (string)reader[7];
- info.PigFarmAddress = (string)reader[8];
- if (string.IsNullOrEmpty(info.Farmer))
- info.Farmer = (string)reader[9];
- if (string.IsNullOrEmpty(info.PigFarmAddress))
- info.PigFarmAddress = (string)reader[10];
- info.ID = (long)reader[11];
- list.Add(info);
- }
- }
-
- return list;
+ return session.ExecuteList(query).Cast();
}
public string Name
{
get { return "抽取白条信息到追溯服务器"; }
}
-
- class WeightFramerTemp
- {
- public long WeightID { get; set; }
- public long FID { get; set; }
-
- public static JoinAlias Register(DQueryDom root, JoinAlias weight)
- {
- var query = new DQueryDom(new JoinAlias("_farmer1", typeof(WeightBill_FarmerDetail)));
- query.Columns.Add(DQSelectColumn.Field("WeightBill_ID"));
- query.Columns.Add(DQSelectColumn.Max("ID"));
- query.GroupBy.Expressions.Add(DQExpression.Field("WeightBill_ID"));
- query.Where.Conditions.Add(DQCondition.EQ("DeleteState", false));
-
- var alias = new JoinAlias(typeof(WeightFramerTemp));
- root.RegisterQueryTable(typeof(WeightFramerTemp), new string[] { "WeightID", "FID" }, query);
- root.From.AddJoin(JoinType.Left, new DQDmoSource(alias), DQCondition.EQ(weight, "ID", alias, "WeightID"));
- return alias;
- }
- }
- }
-
- class TraceBackInfo
- {
- [JsonIgnore]
- public long ID { get; set; }
- //[LogicName("条码")]
- public string Code { get; set; }
- //[LogicName("产品名称")]
- public string Goods_Name { get; set; }
- //[LogicName("生产日期")]
- public string ProductDate { get; set; }
- //[LogicName("保质期")]
- public string ExpirationTime { get; set; }
- //[LogicName("生产厂家")]
- public string ProductCompany { get; set; }
- //[LogicName("生产厂址")]
- public string CompanyAddress { get; set; }
- //[LogicName("电话")]
- public string CompanyTel { get; set; }
- //[LogicName("生猪产地")]
- public string PigFarmAddress { get; set; }
- //[LogicName("动检证号")]
- public string TestingNo { get; set; }
- //[LogicName("动检结果")]
- public string TestingResult { get; set; }
- //[LogicName("动检人员")]
- public string TestingMan { get; set; }
- //[LogicName("养殖户")]
- public string Farmer { get; set; }
- //[LogicName("屠宰批次")]
- public string ButcherBatch { get; set; }
- //[LogicName("屠宰时间")]
- public string ButcherTime { get; set; }
}
class TraceBackInStoreInfo
diff --git a/WebFolder/config/plugins/B3ClientService.plugin b/WebFolder/config/plugins/B3ClientService.plugin
index cbbfbae..07d813c 100644
--- a/WebFolder/config/plugins/B3ClientService.plugin
+++ b/WebFolder/config/plugins/B3ClientService.plugin
@@ -48,7 +48,7 @@
-
+
@@ -136,7 +136,7 @@
-
+