|
|
|
@ -0,0 +1,235 @@ |
|
|
|
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; |
|
|
|
using System.Web; |
|
|
|
|
|
|
|
namespace BWP.Web.Pages.B3ClientService.Reports.CarcassInOutStoreAnalyse_ |
|
|
|
{ |
|
|
|
class CarcassInOutStoreAnalyse : 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 gName = (string)row["Goods_Name"]; |
|
|
|
var url = BuildUrl(string.Format("{0}", row["Goods_ID"])); |
|
|
|
url = WpfPageUrl.ToGlobal(url); |
|
|
|
url = AspUtil.AddParamToUrl(url, "flag", "0"); |
|
|
|
SetCellAtt(tr.Cells[4], url, "进销存明细"); |
|
|
|
|
|
|
|
url = AspUtil.UpdateUrlParam(url, "flag", "1"); |
|
|
|
SetCellAtt(tr.Cells[6], url, "进销存明细"); |
|
|
|
|
|
|
|
url = AspUtil.UpdateUrlParam(url, "flag", "2"); |
|
|
|
SetCellAtt(tr.Cells[7], url, "进销存明细"); |
|
|
|
|
|
|
|
url = AspUtil.UpdateUrlParam(url, "flag", "-1"); |
|
|
|
SetCellAtt(tr.Cells[9], url, "进销存明细"); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
string BuildUrl(string goodsID) |
|
|
|
{ |
|
|
|
var url = "~/B3ClientService/Reports/CarcassInOutStoreAnalyse_/CarcassDetailDialog.aspx"; |
|
|
|
url = AspUtil.AddParamToUrl(url, "Start", HttpUtility.UrlEncode(startTime.ToString("yyyy/MM/dd"))); |
|
|
|
url = AspUtil.AddParamToUrl(url, "End", HttpUtility.UrlEncode(endTime.ToString("yyyy/MM/dd"))); |
|
|
|
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"); |
|
|
|
} |
|
|
|
|
|
|
|
DFDateInput startInput; |
|
|
|
DFDateInput endInput; |
|
|
|
DateTime startTime; |
|
|
|
DateTime endTime; |
|
|
|
private void AddQueryControl(Panel queryPanel) |
|
|
|
{ |
|
|
|
var hPanel = queryPanel.EAdd(new Panel()); |
|
|
|
hPanel.Style.Add("float", "right"); |
|
|
|
hPanel.EAdd(new SimpleLabel("期间")); |
|
|
|
startInput = hPanel.EAdd(new DFDateInput() { Date = DateTime.Today }); |
|
|
|
hPanel.EAdd(new LiteralControl("-")); |
|
|
|
endInput = hPanel.EAdd(new DFDateInput() { Date = DateTime.Today, DefaultTime = DateInputDefaultTime.maxValue }); |
|
|
|
hPanel.EAdd(new TSButton("开始查询", delegate { StartQuery(); })); |
|
|
|
hPanel.EAdd(new RedirectTSButton("清除条件")); |
|
|
|
} |
|
|
|
|
|
|
|
private TitlePanel CreateResultTab() |
|
|
|
{ |
|
|
|
var result = new TitlePanel("查询结果"); |
|
|
|
mBrowseGrid = result.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) }); |
|
|
|
mBrowseGrid.Columns.Add(new DFBrowseGridAutoColumn("Goods_ID")); |
|
|
|
var hPanel = result.EAdd(new HLayoutPanel()); |
|
|
|
PageUtil.AddExcelExportPanel(hPanel, mBrowseGrid, "白条进销存"); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
void StartQuery() |
|
|
|
{ |
|
|
|
startTime = new DateTime(2017, 10, 10); |
|
|
|
endTime = DateTime.Today + new TimeSpan(23, 59, 59); |
|
|
|
if (startInput.Value.HasValue) |
|
|
|
startTime = startInput.Date; |
|
|
|
if (endInput.Value.HasValue) |
|
|
|
endTime = endInput.Date; |
|
|
|
var sumColumns = new List<int>(); |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(UnionTemp))); |
|
|
|
query.RegisterQueryTable(typeof(UnionTemp), new string[] { "Goods_ID", "Weight", "Time", "Flag" }, GetUnionDom(endTime)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Code", "存货编码")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Name", "存货名称")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Spec", "存货规格")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.LessThan("Time", startTime), DQExpression.LogicCase(DQCondition.EQ("Flag", 0), DQExpression.Value(1), DQExpression.Value(-1)))).ECastType<int>(), "期初头数")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.GreaterThanOrEqual("Time", startTime), DQCondition.EQ("Flag", 0)), DQExpression.Value(1))).ECastType<int>(), "本期增加头数|成品入库")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.GreaterThanOrEqual("Time", startTime), DQCondition.EQ("Flag", 0)), DQExpression.Value(1))).ECastType<int>(), "本期增加头数|合计")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.GreaterThanOrEqual("Time", startTime), DQCondition.EQ("Flag", 1)), DQExpression.Value(1))).ECastType<int>(), "本期减少头数|分割领用")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.GreaterThanOrEqual("Time", startTime), DQCondition.EQ("Flag", 2)), DQExpression.Value(1))).ECastType<int>(), "本期减少头数|销售出库")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.GreaterThanOrEqual("Time", startTime), DQCondition.InEQ("Flag", 0)), DQExpression.Value(1))).ECastType<int>(), "本期减少头数|合计")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("Flag", 0), DQExpression.Value(1), DQExpression.Value(-1))).ECastType<int>(), "期末头数")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.LessThan("Time", startTime), DQExpression.LogicCase(DQCondition.EQ("Flag", 0), DQExpression.Field("Weight"), DQExpression.Multiply(DQExpression.Value(-1), DQExpression.Field("Weight"))))).ECastType<decimal>(), "期初重量")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.GreaterThanOrEqual("Time", startTime), DQCondition.EQ("Flag", 0)), DQExpression.Field("Weight"))).ECastType<decimal>(), "本期增加重量|成品入库")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.GreaterThanOrEqual("Time", startTime), DQCondition.EQ("Flag", 0)), DQExpression.Field("Weight"))).ECastType<decimal>(), "本期增加重量|合计")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.GreaterThanOrEqual("Time", startTime), DQCondition.EQ("Flag", 1)), DQExpression.Field("Weight"))).ECastType<decimal>(), "本期减少重量|分割领用")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.GreaterThanOrEqual("Time", startTime), DQCondition.EQ("Flag", 2)), DQExpression.Field("Weight"))).ECastType<decimal>(), "本期减少重量|销售出库")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.GreaterThanOrEqual("Time", startTime), DQCondition.InEQ("Flag", 0)), DQExpression.Field("Weight"))).ECastType<decimal>(), "本期减少重量|合计")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("Flag", 0), DQExpression.Field("Weight"), DQExpression.Multiply(DQExpression.Value(-1), DQExpression.Field("Weight")))).ECastType<decimal>(), "期末重量")); |
|
|
|
|
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("Goods_ID")); |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Code")); |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Name")); |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("Goods_Spec")); |
|
|
|
|
|
|
|
query.Having.Conditions.Add(DQCondition.Or(DQCondition.InEQ(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("Flag", 0), DQExpression.Value(1), DQExpression.Value(-1))), DQExpression.Value(0)), DQCondition.InEQ(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("Flag", 0), DQExpression.Field("Weight"), DQExpression.Multiply(DQExpression.Value(-1), DQExpression.Field("Weight")))), DQExpression.Value(0)))); |
|
|
|
var args = new LoadArguments(query); |
|
|
|
for (var idx = 4; idx < query.Columns.Count; idx++) |
|
|
|
{ |
|
|
|
args.SumColumns.Add(idx); |
|
|
|
args.GroupSumColumns.Add(idx); |
|
|
|
} |
|
|
|
mBrowseGrid.LoadArguments = args; |
|
|
|
mBrowseGrid.DataBind(); |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnLoad(EventArgs e) |
|
|
|
{ |
|
|
|
base.OnLoad(e); |
|
|
|
if (!IsPostBack) |
|
|
|
StartQuery(); |
|
|
|
} |
|
|
|
|
|
|
|
[DFClass] |
|
|
|
class UnionTemp |
|
|
|
{ |
|
|
|
public long Goods_ID { get; set; } |
|
|
|
public decimal Weight { get; set; } |
|
|
|
public DateTime Time { get; set; } |
|
|
|
public int Flag { get; set; } |
|
|
|
|
|
|
|
[ReferenceTo(typeof(Goods), "Name")] |
|
|
|
[Join("Goods_ID", "ID")] |
|
|
|
public string Goods_Name { get; set; } |
|
|
|
|
|
|
|
[ReferenceTo(typeof(Goods), "Code")] |
|
|
|
[Join("Goods_ID", "ID")] |
|
|
|
public string Goods_Code { get; set; } |
|
|
|
|
|
|
|
[ReferenceTo(typeof(Goods), "Spec")] |
|
|
|
[Join("Goods_ID", "ID")] |
|
|
|
public string Goods_Spec { get; set; } |
|
|
|
} |
|
|
|
|
|
|
|
DQueryDom GetUnionDom(DateTime endTime) |
|
|
|
{ |
|
|
|
var u1 = GetInStore(endTime); |
|
|
|
var u2 = GetPickOutStore(endTime); |
|
|
|
u1.UnionNext.Select = u2; |
|
|
|
u1.UnionNext.Type = UnionType.All; |
|
|
|
u2.UnionNext.Select = GetSaleOutStore(endTime); |
|
|
|
u2.UnionNext.Type = UnionType.All; |
|
|
|
return u1; |
|
|
|
} |
|
|
|
|
|
|
|
DQueryDom GetInStore(DateTime endTime) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias("_inStore", typeof(CarcassFullInfo))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("InStoreGoods_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("InStoreWeight")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("InStoreTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(0), "Falg")); |
|
|
|
query.Where.Conditions.Add(DQCondition.LessThanOrEqual("InStoreTime", endTime)); |
|
|
|
return query; |
|
|
|
} |
|
|
|
|
|
|
|
DQueryDom GetPickOutStore(DateTime endTime) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias("_pickOut", typeof(CarcassFullInfo))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("InStoreGoods_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("PickWeight")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("PickTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "Falg")); |
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("PickType", 0), DQCondition.LessThanOrEqual("PickTime", endTime))); |
|
|
|
return query; |
|
|
|
} |
|
|
|
|
|
|
|
DQueryDom GetSaleOutStore(DateTime endTime) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias("_saleOut", typeof(CarcassFullInfo))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("SaleGoods_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("PickWeight")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("PickTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(2), "Falg")); |
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("PickType", 1), DQCondition.LessThanOrEqual("PickTime", endTime))); |
|
|
|
return query; |
|
|
|
} |
|
|
|
} |
|
|
|
} |