|
|
|
@ -21,6 +21,7 @@ using Forks.EnterpriseServices.SqlDoms; |
|
|
|
using BWP.B3ClientService.NamedValueTemplate; |
|
|
|
using Forks.Utils; |
|
|
|
using TSingSoft.WebPluginFramework.Exports; |
|
|
|
using BWP.B3ClientService; |
|
|
|
|
|
|
|
namespace BWP.Web.Pages.B3ClientService.Reports.CarcassGradeAnalyse_ |
|
|
|
{ |
|
|
|
@ -51,10 +52,13 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassGradeAnalyse_ |
|
|
|
} |
|
|
|
|
|
|
|
DateInput butcherDate; |
|
|
|
ChoiceBox batchSelect; |
|
|
|
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.生产批次) { Width = Unit.Pixel(160), EnableTopItem = true, EnableInputArgument = true }); |
|
|
|
hp.EAdd(new SimpleLabel("屠宰日期")); |
|
|
|
butcherDate = hp.EAdd(new DateInput() { Date = DateTime.Today, Width = Unit.Pixel(100) }); |
|
|
|
butcherDate.Style.Add("margin-right", "30px"); |
|
|
|
@ -155,21 +159,16 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassGradeAnalyse_ |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
List<TempData> GetAllData() |
|
|
|
List<TempData> GetInOutInfo() |
|
|
|
{ |
|
|
|
var main = new JoinAlias(typeof(CarcassFullInfo)); |
|
|
|
var livestock = new JoinAlias(typeof(Livestock)); |
|
|
|
var inGoods = new JoinAlias("iGoods", typeof(Goods)); |
|
|
|
var outGoods = new JoinAlias("oGoods", typeof(Goods)); |
|
|
|
var batch = new JoinAlias(typeof(ProductBatch)); |
|
|
|
var query = new DQueryDom(main); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(livestock), DQCondition.EQ(main, "Livestock_ID", livestock, "ID")); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(inGoods), DQCondition.EQ(main, "InStoreGoods_ID", inGoods, "ID")); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(outGoods), DQCondition.EQ(main, "SaleGoods_ID", outGoods, "ID")); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(batch), DQCondition.EQ(main, "ProductBatch_ID", batch, "ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Livestock_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Name", livestock)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("GradeWeight")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("InStoreGoods_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Name", inGoods)); |
|
|
|
@ -179,12 +178,46 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassGradeAnalyse_ |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Name", outGoods)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("PickWeight")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ButcherDate")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Date", batch)); |
|
|
|
|
|
|
|
if (butcherDate.Value.HasValue) |
|
|
|
query.Where.Conditions.Add(DQCondition.Or(DQCondition.EQ("ButcherDate", butcherDate.Date), DQCondition.EQ(batch, "Date", butcherDate.Date))); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ(batch, "Date", butcherDate.Date)); |
|
|
|
if (!batchSelect.IsEmpty) |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("ProductBatch_ID", long.Parse(batchSelect.Value))); |
|
|
|
var list = new List<TempData>(); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
{ |
|
|
|
while (reader.Read()) |
|
|
|
{ |
|
|
|
var entity = new TempData(); |
|
|
|
entity.IGoods_ID = (long?)reader[0]; |
|
|
|
entity.IGoods_Name = (string)reader[1]; |
|
|
|
entity.IWeight = (decimal?)reader[2]; |
|
|
|
|
|
|
|
entity.OGoods_ID = (long?)reader[3]; |
|
|
|
entity.OGoods_Name = (string)reader[4]; |
|
|
|
entity.OWeight = (decimal?)reader[5]; |
|
|
|
list.Add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
List<TempData> GetGradeInfo() |
|
|
|
{ |
|
|
|
var main = new JoinAlias(typeof(CarcassFullInfo)); |
|
|
|
var livestock = new JoinAlias(typeof(Livestock)); |
|
|
|
var query = new DQueryDom(main); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(livestock), DQCondition.EQ(main, "Livestock_ID", livestock, "ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Livestock_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Name", livestock)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("GradeWeight")); |
|
|
|
|
|
|
|
if (butcherDate.Value.HasValue) |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("ButcherDate", butcherDate.Date)); |
|
|
|
if (!batchSelect.IsEmpty) |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("GradeProductBatch_ID", long.Parse(batchSelect.Value))); |
|
|
|
var list = new List<TempData>(); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
@ -192,34 +225,10 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassGradeAnalyse_ |
|
|
|
{ |
|
|
|
while (reader.Read()) |
|
|
|
{ |
|
|
|
var dt1 = (DateTime?)reader[9]; |
|
|
|
var dt2 = (DateTime?)reader[10]; |
|
|
|
var isButcherData = butcherDate.Value == null; |
|
|
|
var isBatchData = isButcherData; |
|
|
|
if (butcherDate.Value.HasValue) |
|
|
|
{ |
|
|
|
if (dt1 == null || dt1 != butcherDate.Date) |
|
|
|
isButcherData = false; |
|
|
|
if (dt2 == null || dt2 != butcherDate.Date) |
|
|
|
isBatchData = false; |
|
|
|
} |
|
|
|
var entity = new TempData(); |
|
|
|
if (isButcherData) |
|
|
|
{ |
|
|
|
entity.Livestock_ID = (long?)reader[0]; |
|
|
|
entity.Livestock_Name = (string)reader[1]; |
|
|
|
entity.LWeight = (decimal?)reader[2]; |
|
|
|
} |
|
|
|
if (isBatchData) |
|
|
|
{ |
|
|
|
entity.IGoods_ID = (long?)reader[3]; |
|
|
|
entity.IGoods_Name = (string)reader[4]; |
|
|
|
entity.IWeight = (decimal?)reader[5]; |
|
|
|
|
|
|
|
entity.OGoods_ID = (long?)reader[6]; |
|
|
|
entity.OGoods_Name = (string)reader[7]; |
|
|
|
entity.OWeight = (decimal?)reader[8]; |
|
|
|
} |
|
|
|
entity.Livestock_ID = (long?)reader[0]; |
|
|
|
entity.Livestock_Name = (string)reader[1]; |
|
|
|
entity.LWeight = (decimal?)reader[2]; |
|
|
|
list.Add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -231,16 +240,16 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassGradeAnalyse_ |
|
|
|
{ |
|
|
|
var table = new DFDataTable(); |
|
|
|
AddTableHead(table); |
|
|
|
var list = GetAllData(); |
|
|
|
var combine = CombineList(list); |
|
|
|
var combine = CombineList(); |
|
|
|
FillTable(table, combine); |
|
|
|
return table; |
|
|
|
} |
|
|
|
|
|
|
|
private List<TempData> CombineList(List<TempData> list) |
|
|
|
private List<TempData> CombineList() |
|
|
|
{ |
|
|
|
var gradeInfo = GetGradeInfo(); |
|
|
|
var combine = new List<TempData>(); |
|
|
|
var l = list.Where(x => x.Livestock_ID.HasValue).GroupBy(x => x.Livestock_ID).OrderBy(x => x.Key); |
|
|
|
var l = gradeInfo.GroupBy(x => x.Livestock_ID).OrderBy(x => x.Key); |
|
|
|
foreach (var g in l) |
|
|
|
{ |
|
|
|
var e = new TempData(); |
|
|
|
@ -250,7 +259,8 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassGradeAnalyse_ |
|
|
|
combine.Add(e); |
|
|
|
} |
|
|
|
|
|
|
|
var i = list.Where(x => x.IGoods_ID.HasValue).GroupBy(x => x.IGoods_ID).OrderBy(x => x.Key); |
|
|
|
var inOutInfo = GetInOutInfo(); |
|
|
|
var i = inOutInfo.Where(x => x.IGoods_ID.HasValue).GroupBy(x => x.IGoods_ID).OrderBy(x => x.Key); |
|
|
|
var n = 0; |
|
|
|
foreach (var g in i) |
|
|
|
{ |
|
|
|
@ -263,7 +273,7 @@ namespace BWP.Web.Pages.B3ClientService.Reports.CarcassGradeAnalyse_ |
|
|
|
n++; |
|
|
|
} |
|
|
|
|
|
|
|
var o = list.Where(x => x.OGoods_ID.HasValue).GroupBy(x => x.OGoods_ID).OrderBy(x => x.Key); |
|
|
|
var o = inOutInfo.Where(x => x.OGoods_ID.HasValue).GroupBy(x => x.OGoods_ID).OrderBy(x => x.Key); |
|
|
|
n = 0; |
|
|
|
foreach (var g in o) |
|
|
|
{ |
|
|
|
|