Browse Source

分割品业务调整。

master
yibo 7 years ago
parent
commit
8ab19d515a
2 changed files with 75 additions and 13 deletions
  1. +68
    -8
      B3ClientService.Web/Pages/B3ClientService/Reports/SegmentProductAnalyse_/SegmentInStoreAnalyse.cs
  2. +7
    -5
      B3ClientService/Tasks/UpdateLoad/UploadProductInStore.cs

+ 68
- 8
B3ClientService.Web/Pages/B3ClientService/Reports/SegmentProductAnalyse_/SegmentInStoreAnalyse.cs View File

@ -18,6 +18,8 @@ using TSingSoft.WebPluginFramework.Controls;
using TSingSoft.WebPluginFramework.Pages; using TSingSoft.WebPluginFramework.Pages;
using TSingSoft.WebPluginFramework; using TSingSoft.WebPluginFramework;
using Forks.Utils; using Forks.Utils;
using TSingSoft.WebPluginFramework.Exports;
using TSingSoft.WebControls2.DFGrids;
namespace BWP.Web.Pages.B3ClientService.Reports.SegmentProductAnalyse_ namespace BWP.Web.Pages.B3ClientService.Reports.SegmentProductAnalyse_
{ {
@ -63,16 +65,16 @@ namespace BWP.Web.Pages.B3ClientService.Reports.SegmentProductAnalyse_
private void StartQuery() private void StartQuery()
{ {
long? productBatci = null;
long? productBatchID = null;
if (!batchSelect.IsEmpty) if (!batchSelect.IsEmpty)
productBatci = long.Parse(batchSelect.Value);
productBatchID = long.Parse(batchSelect.Value);
var main = new JoinAlias(typeof(TempClass)); var main = new JoinAlias(typeof(TempClass));
var goods = new JoinAlias(typeof(Goods)); var goods = new JoinAlias(typeof(Goods));
var unit = new JoinAlias(typeof(WorkUnit)); var unit = new JoinAlias(typeof(WorkUnit));
var productBatch = new JoinAlias(typeof(ProductBatch)); var productBatch = new JoinAlias(typeof(ProductBatch));
var query = new DQueryDom(main); 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(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(unit), DQCondition.EQ(main, "WorkUnit_ID", unit, "ID"));
query.From.AddJoin(JoinType.Left, new DQDmoSource(productBatch), DQCondition.EQ(main, "ProductBatch_ID", productBatch, "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("Number"), "数量"));
query.Columns.Add(DQSelectColumn.Create(DQExpression.Field("Weight").ECastType<Money<decimal>?>(), "重量")); 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); var args = new LoadArguments(query);
for (var i = query.Columns.Count - 2; i <= query.Columns.Count - 1; i++) 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 = result.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) });
mBrowseGrid.Columns.Add(new DFBrowseGridAutoColumn()); mBrowseGrid.Columns.Add(new DFBrowseGridAutoColumn());
var hPanel = result.EAdd(new HLayoutPanel()); 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; 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 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); 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))); var query = new DQueryDom(new JoinAlias(typeof(SegmentProductionInfo)));
query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID")); query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID"));


+ 7
- 5
B3ClientService/Tasks/UpdateLoad/UploadProductInStore.cs View File

@ -90,6 +90,7 @@ namespace BWP.B3ClientService.Tasks
query.Columns.Add(DQSelectColumn.Field("Name", batch)); query.Columns.Add(DQSelectColumn.Field("Name", batch));
query.Columns.Add(DQSelectColumn.Field("Code", store)); query.Columns.Add(DQSelectColumn.Field("Code", store));
query.Columns.Add(DQSelectColumn.Field("Code", goods)); query.Columns.Add(DQSelectColumn.Field("Code", goods));
query.Columns.Add(DQSelectColumn.Create(DQExpression.LogicCase(DQCondition.IsNull(DQExpression.Field("BackTime")), DQExpression.Value(1), DQExpression.Value(0)), "back"));
query.Columns.Add(DQSelectColumn.Field("Weight")); query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Columns.Add(DQSelectColumn.Field("RowVersion")); query.Columns.Add(DQSelectColumn.Field("RowVersion"));
query.Columns.Add(DQSelectColumn.Field("ID")); query.Columns.Add(DQSelectColumn.Field("ID"));
@ -104,10 +105,11 @@ namespace BWP.B3ClientService.Tasks
detail.ProductBatch = (string)reader[0]; detail.ProductBatch = (string)reader[0];
detail.StoreCode = (string)reader[1]; detail.StoreCode = (string)reader[1];
detail.Goods_Code = (string)reader[2]; detail.Goods_Code = (string)reader[2];
detail.Number = (decimal?)reader[3];
detail.SecondNumber = 1;
detail.RowVersion = (int)reader[4];
detail.ID = (long)reader[5];
var need = Convert.ToInt32(reader[3]);
detail.Number = need * (decimal?)reader[4];
detail.SecondNumber = need * 1;
detail.RowVersion = (int)reader[5];
detail.ID = (long)reader[6];
list.Add(detail); list.Add(detail);
} }
} }
@ -117,7 +119,7 @@ namespace BWP.B3ClientService.Tasks
void UpdateAsSync(IDmoSession session, ProductInStoreJson item) void UpdateAsSync(IDmoSession session, ProductInStoreJson item)
{ {
var update = new DQUpdateDom(typeof(ProductInStoreJson));
var update = new DQUpdateDom(typeof(SegmentProductionInfo));
update.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("ID", item.ID), DQCondition.EQ("RowVersion", item.RowVersion))); update.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("ID", item.ID), DQCondition.EQ("RowVersion", item.RowVersion)));
update.Columns.Add(new DQUpdateColumn("IsSync", true)); update.Columns.Add(new DQUpdateColumn("IsSync", true));
session.ExecuteNonQuery(update); session.ExecuteNonQuery(update);


Loading…
Cancel
Save