|
|
|
@ -18,6 +18,8 @@ using TSingSoft.WebPluginFramework.Controls; |
|
|
|
using TSingSoft.WebPluginFramework.Pages; |
|
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
using Forks.Utils; |
|
|
|
using TSingSoft.WebPluginFramework.Exports; |
|
|
|
using TSingSoft.WebControls2.DFGrids; |
|
|
|
|
|
|
|
namespace BWP.Web.Pages.B3ClientService.Reports.SegmentProductAnalyse_ |
|
|
|
{ |
|
|
|
@ -63,16 +65,16 @@ namespace BWP.Web.Pages.B3ClientService.Reports.SegmentProductAnalyse_ |
|
|
|
|
|
|
|
private void StartQuery() |
|
|
|
{ |
|
|
|
long? productBatci = null; |
|
|
|
long? productBatchID = null; |
|
|
|
if (!batchSelect.IsEmpty) |
|
|
|
productBatci = long.Parse(batchSelect.Value); |
|
|
|
productBatchID = 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); |
|
|
|
TempClass.Regist(query, productBatchID); |
|
|
|
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")); |
|
|
|
@ -105,9 +107,6 @@ namespace BWP.Web.Pages.B3ClientService.Reports.SegmentProductAnalyse_ |
|
|
|
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++) |
|
|
|
{ |
|
|
|
@ -125,9 +124,70 @@ namespace BWP.Web.Pages.B3ClientService.Reports.SegmentProductAnalyse_ |
|
|
|
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, "分割入库分析"); |
|
|
|
AddExcelExportPanel(hPanel, mBrowseGrid, "分割入库分析"); |
|
|
|
mBrowseGrid.DataFilter = (table) => |
|
|
|
{ |
|
|
|
var sumRowInfo = GetSumRowValue(); |
|
|
|
|
|
|
|
table.SumRow["数量"] = sumRowInfo.Item1; |
|
|
|
table.SumRow["重量"] = sumRowInfo.Item2; |
|
|
|
}; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
Tuple<int, Money<decimal>> GetSumRowValue() |
|
|
|
{ |
|
|
|
long? productBatchID = null; |
|
|
|
if (!batchSelect.IsEmpty) |
|
|
|
productBatchID = long.Parse(batchSelect.Value); |
|
|
|
var query = TempClass.GetInStore(productBatchID); |
|
|
|
query.Columns.Clear(); |
|
|
|
query.Columns.Add(DQSelectColumn.Count("Number")); |
|
|
|
query.Columns.Add(DQSelectColumn.Sum("Weight")); |
|
|
|
int num = 0; |
|
|
|
Money<decimal> weight = 0; |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
{ |
|
|
|
if (reader.Read()) |
|
|
|
{ |
|
|
|
num = Convert.ToInt32(reader[0]); |
|
|
|
weight = Convert.ToDecimal(reader[1] ?? 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return new Tuple<int, Money<decimal>>(num, weight); |
|
|
|
} |
|
|
|
|
|
|
|
void AddExcelExportPanel(HLayoutPanel toolbar, DFBrowseGrid mBrowseGrid, string title) |
|
|
|
{ |
|
|
|
var exporter = new Exporter(); |
|
|
|
toolbar.Add(new TSButton("导出到Excel", delegate |
|
|
|
{ |
|
|
|
var lastQuery = mBrowseGrid.LastQuery; |
|
|
|
if (lastQuery == null) |
|
|
|
throw new Exception("请先进行查询"); |
|
|
|
var dom = new LoadArguments((DQueryDom)lastQuery.DQuery.Clone()); |
|
|
|
foreach (var colIndex in lastQuery.SumColumns) |
|
|
|
dom.SumColumns.Add(colIndex); |
|
|
|
foreach (var colIndex in lastQuery.GroupSumColumns) |
|
|
|
dom.GroupSumColumns.Add(colIndex); |
|
|
|
dom.DQuery.Range = SelectRange.All; |
|
|
|
string fileName = title + ".xlsx"; |
|
|
|
exporter.Export(new QueryResultExcelExporter(fileName, GetQueryResult(dom))); |
|
|
|
})); |
|
|
|
toolbar.Add(exporter); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryResult GetQueryResult(LoadArguments arg) |
|
|
|
{ |
|
|
|
var data = new DFDataTableEditor().Load(arg); |
|
|
|
var sumRowInfo = GetSumRowValue(); |
|
|
|
data.Data.SumRow["数量"] = sumRowInfo.Item1; |
|
|
|
data.Data.SumRow["重量"] = sumRowInfo.Item2; |
|
|
|
return new QueryResult(data.TotalCount, data.Data.Rows, data.Data.Columns, arg.SumColumns.Any() ? data.Data.SumRow : null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class TempClass |
|
|
|
@ -162,7 +222,7 @@ namespace BWP.Web.Pages.B3ClientService.Reports.SegmentProductAnalyse_ |
|
|
|
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) |
|
|
|
public static DQueryDom GetInStore(long? productBatchID) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(SegmentProductionInfo))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID")); |
|
|
|
|