|
|
|
@ -0,0 +1,203 @@ |
|
|
|
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.WebControls; |
|
|
|
using TSingSoft.WebControls2; |
|
|
|
using TSingSoft.WebPluginFramework.Controls; |
|
|
|
using TSingSoft.WebPluginFramework.Pages; |
|
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
using Forks.Utils; |
|
|
|
|
|
|
|
namespace BWP.Web.Pages.B3ClientService.Reports.SegmentProductAnalyse_ |
|
|
|
{ |
|
|
|
class SegmentInStoreAnalyse : ServerPage |
|
|
|
{ |
|
|
|
protected override void OnInit(EventArgs e) |
|
|
|
{ |
|
|
|
if (!User.IsInRole("B3ClientService.报表展示.分割入库分析")) |
|
|
|
throw new SecurityException(); |
|
|
|
base.OnInit(e); |
|
|
|
} |
|
|
|
|
|
|
|
DFBrowseGrid mBrowseGrid; |
|
|
|
protected override void InitForm(System.Web.UI.HtmlControls.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; |
|
|
|
DFCheckBox showDetail; |
|
|
|
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, Width = Unit.Pixel(180) }); |
|
|
|
showDetail = hp.EAdd(new DFCheckBox() { Text = "查看明细" }); |
|
|
|
showDetail.InputAttributes.Add("style", "width:15px;height:15px;"); |
|
|
|
hp.EAdd(new TSButton("开始查询", delegate { StartQuery(); })); |
|
|
|
} |
|
|
|
|
|
|
|
private void StartQuery() |
|
|
|
{ |
|
|
|
long? productBatci = null; |
|
|
|
if (!batchSelect.IsEmpty) |
|
|
|
productBatci = long.Parse(batchSelect.Value); |
|
|
|
|
|
|
|
var main = new JoinAlias(typeof(TempClass)); |
|
|
|
var goods = new JoinAlias(typeof(Goods)); |
|
|
|
var unit = new JoinAlias(typeof(WorkUnit)); |
|
|
|
var productBatch = new JoinAlias(typeof(ProductBatch)); |
|
|
|
var query = new DQueryDom(main); |
|
|
|
TempClass.Regist(query, productBatci); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, "Goods_ID", goods, "ID")); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(unit), DQCondition.EQ(main, "WorkUnit_ID", unit, "ID")); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(productBatch), DQCondition.EQ(main, "ProductBatch_ID", productBatch, "ID")); |
|
|
|
|
|
|
|
if (showDetail.Checked) |
|
|
|
{ |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode", "条码")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(productBatch, "Name"), "生产批次")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ProductTime", "生产时间")); |
|
|
|
if (query.OrderBy.Expressions.Count == 0) |
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ProductTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(unit, "Name"), "工作单元")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("InStoreTime", "入库时间")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BackTime", "退库时间")); |
|
|
|
} |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.LogicCase(DQCondition.EQ("Flag", 1), DQExpression.Value("入库"), DQExpression.Value("退库")).ECastType<string>(), "标识")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goods, "Code"), "存货编码")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goods, "Name"), "存货名称")); |
|
|
|
if (!showDetail.Checked) |
|
|
|
{ |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("Flag")); |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field(goods, "Code")); |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field(goods, "Name")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Field("Number")), "数量")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Field("Weight")).ECastType<Money<decimal>?>(), "重量")); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Field("Number"), "数量")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Field("Weight").ECastType<Money<decimal>?>(), "重量")); |
|
|
|
} |
|
|
|
|
|
|
|
if (!batchSelect.IsEmpty) |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("ProductBatch_ID", long.Parse(batchSelect.Value))); |
|
|
|
var args = new LoadArguments(query); |
|
|
|
for (var i = query.Columns.Count - 2; i <= query.Columns.Count - 1; i++) |
|
|
|
{ |
|
|
|
args.SumColumns.Add(i); |
|
|
|
if (!showDetail.Checked) |
|
|
|
args.GroupSumColumns.Add(i); |
|
|
|
} |
|
|
|
mBrowseGrid.LoadArguments = args; |
|
|
|
mBrowseGrid.DataBind(); |
|
|
|
} |
|
|
|
|
|
|
|
private TitlePanel CreateResultTab() |
|
|
|
{ |
|
|
|
var result = new TitlePanel("查询结果"); |
|
|
|
mBrowseGrid = result.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) }); |
|
|
|
mBrowseGrid.Columns.Add(new DFBrowseGridAutoColumn()); |
|
|
|
var hPanel = result.EAdd(new HLayoutPanel()); |
|
|
|
PageUtil.AddExcelExportPanel(hPanel, mBrowseGrid, "分割入库分析"); |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class TempClass |
|
|
|
{ |
|
|
|
public long ProductBatch_ID { get; set; } |
|
|
|
|
|
|
|
public long? WorkUnit_ID { get; set; } |
|
|
|
|
|
|
|
public long Goods_ID { get; set; } |
|
|
|
|
|
|
|
public string BarCode { get; set; } |
|
|
|
|
|
|
|
public DateTime ProductTime { get; set; } |
|
|
|
|
|
|
|
public DateTime? InStoreTime { get; set; } |
|
|
|
|
|
|
|
public DateTime? BackTime { get; set; } |
|
|
|
|
|
|
|
public int Number { get; set; } |
|
|
|
|
|
|
|
public Money<decimal> Weight { get; set; } |
|
|
|
|
|
|
|
public int Flag { get; set; } |
|
|
|
|
|
|
|
public static void Regist(DQueryDom root, long? productBatchID) |
|
|
|
{ |
|
|
|
var q1 = GetInStore(productBatchID); |
|
|
|
var q2 = GetBackStore(productBatchID); |
|
|
|
q1.UnionNext.Select = q2; |
|
|
|
q1.UnionNext.Type = UnionType.All; |
|
|
|
|
|
|
|
root.RegisterQueryTable(typeof(TempClass), new string[] { "ProductBatch_ID", "WorkUnit_ID", "Goods_ID", "BarCode", "ProductTime", "InStoreTime", "BackTime", "Number", "Weight", "Flag" }, q1); |
|
|
|
} |
|
|
|
|
|
|
|
static DQueryDom GetInStore(long? productBatchID) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(SegmentProductionInfo))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("WorkUnit_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ProductTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("InStoreTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BackTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "Number")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "Flag")); |
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("InStoreTime")), DQCondition.IsNull(DQExpression.Field("BackTime")))); |
|
|
|
if (productBatchID.HasValue) |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("ProductBatch_ID", productBatchID.Value)); |
|
|
|
return query; |
|
|
|
} |
|
|
|
|
|
|
|
static DQueryDom GetBackStore(long? productBatchID) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(SegmentProductionInfo))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("WorkUnit_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ProductTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("InStoreTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BackTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(-1), "Number")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Multiply(DQExpression.Field("Weight"), DQExpression.Value(-1)), "Weight")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(-1), "Flag")); |
|
|
|
query.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field("BackTime"))); |
|
|
|
if (productBatchID.HasValue) |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("ProductBatch_ID", productBatchID.Value)); |
|
|
|
return query; |
|
|
|
} |
|
|
|
} |
|
|
|
} |