|
|
|
@ -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<string>(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<int?>(), "入库头数")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(inWeight.ECastType<decimal?>(), "入库重量")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 1), DQExpression.Field("PickNumber"))).ECastType<decimal?>(), "销售出库|头数")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 1), DQExpression.Field("PickWeight"))).ECastType<decimal?>(), "销售出库|重量")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 0), DQExpression.Field("PickNumber"))).ECastType<decimal?>(), "分割领用|头数")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 0), DQExpression.Field("PickWeight"))).ECastType<decimal?>(), "分割领用|重量")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 2), DQExpression.Field("PickNumber"))).ECastType<decimal?>(), "条转段|头数")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("PickType", 2), DQExpression.Field("PickWeight"))).ECastType<decimal?>(), "条转段|重量")); |
|
|
|
|
|
|
|
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<decimal?>(), "损耗|头数")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Subtract(DQExpression.IfNull(inWeight, DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Sum(DQExpression.Field("PickWeight")), DQExpression.Value(0))).ECastType<decimal?>(), "损耗|重量")); |
|
|
|
|
|
|
|
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<string>(typeof(ProductBatch), "Name", long.Parse(Request.QueryString["ProductBatch_ID"])); |
|
|
|
batchSelect.Fill(Request.QueryString["ProductBatch_ID"], name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |