|
|
|
@ -54,6 +54,7 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
private void ResetTable(DFDataTable table) |
|
|
|
{ |
|
|
|
decimal sum皮肉重量 = 0; |
|
|
|
decimal dcmz = 0m; |
|
|
|
foreach (DFDataRow row in table.Rows) |
|
|
|
{ |
|
|
|
try |
|
|
|
@ -64,67 +65,23 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
row["皮肉重量"] = 皮肉重量; |
|
|
|
sum皮肉重量 += (皮肉重量 ?? 0); |
|
|
|
|
|
|
|
var 到厂毛重 = objToDecimal(row["到厂毛重"]); |
|
|
|
var 到厂毛重 = objToDecimal(row["_RW"]); |
|
|
|
dcmz += 到厂毛重; |
|
|
|
row["皮肉比"] = Math.Round((double)(皮肉重量 / 到厂毛重 * 100), 2); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
|
|
|
|
} |
|
|
|
try |
|
|
|
{ |
|
|
|
table.SumRow["皮肉重量"] = sum皮肉重量; |
|
|
|
if (dcmz != 0) |
|
|
|
table.SumRow["皮肉比"] = (Money<金额>?)(sum皮肉重量 / dcmz * 100); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
SetCommonDivSumTable(table, "核算单价", "核算金额", "到厂毛重"); |
|
|
|
SetCommonDivSumTable(table, "付款单价", "付款金额", "到厂毛重"); |
|
|
|
SetCommonDivSumTable(table, "单头盈亏", "盈亏", "收购头数"); |
|
|
|
SetCommonDivSumTable(table, "均重", "到厂毛重", "收购头数"); |
|
|
|
SetCommonDivSumTable(table, "损耗比", "损耗", "原发毛重", true); |
|
|
|
SetCommonDivSumTable(table, "皮肉比", "皮肉重量", "到厂毛重", true); |
|
|
|
SetCommonDivSumTable(table, "成本单价", "成本金额", "到厂毛重"); |
|
|
|
|
|
|
|
Set占比(table); |
|
|
|
|
|
|
|
if (_checkbox.Items.FindByText("死亡头数").Selected) |
|
|
|
{ |
|
|
|
var n = 0; |
|
|
|
foreach (DFDataRow row in table.Rows) |
|
|
|
{ |
|
|
|
n += Convert.ToInt32(row["死亡头数"] ?? 0); |
|
|
|
} |
|
|
|
table.SumRow["死亡头数"] = n; |
|
|
|
} |
|
|
|
|
|
|
|
//if (_checkbox.Items.FindByText("人工费").Selected)
|
|
|
|
//{
|
|
|
|
// Money<金额> n = 0m;
|
|
|
|
// foreach (DFDataRow row in table.Rows)
|
|
|
|
// {
|
|
|
|
// n += Convert.ToDecimal(row["人工费"] ?? 0);
|
|
|
|
// }
|
|
|
|
// table.SumRow["人工费"] = n;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//if (_checkbox.Items.FindByText("运费").Selected)
|
|
|
|
//{
|
|
|
|
// Money<金额> n = 0;
|
|
|
|
// foreach (DFDataRow row in table.Rows)
|
|
|
|
// {
|
|
|
|
// n += Convert.ToDecimal(row["运费"] ?? 0);
|
|
|
|
// }
|
|
|
|
// table.SumRow["运费"] = n;
|
|
|
|
//}
|
|
|
|
//if (_checkbox.Items.FindByText("里程").Selected)
|
|
|
|
//{
|
|
|
|
// decimal n = 0;
|
|
|
|
// foreach (DFDataRow row in table.Rows)
|
|
|
|
// {
|
|
|
|
// n += Convert.ToDecimal(row["里程"] ?? 0);
|
|
|
|
// }
|
|
|
|
// table.SumRow["里程"] = n;
|
|
|
|
//}
|
|
|
|
|
|
|
|
// Set占比(table,);
|
|
|
|
ColumnNames.Remove("_RW"); |
|
|
|
table.Columns.RemoveAt(table.Columns.Count - 1); |
|
|
|
} |
|
|
|
|
|
|
|
private void Set占比(DFDataTable table) |
|
|
|
@ -169,20 +126,6 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void SetCommonDivSumTable(DFDataTable table, string sumname, string chu, string chuyi, bool mul100 = false) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
var m100 = 1; |
|
|
|
if (mul100) |
|
|
|
m100 = 100; |
|
|
|
var value = (Money<金额>?)(objToDecimal(table.SumRow[chu]) / objToDecimal(table.SumRow[chuyi]) * m100); |
|
|
|
|
|
|
|
table.SumRow[sumname] = value; |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
|
|
|
|
decimal objToDecimal(object obj) |
|
|
|
{ |
|
|
|
if (obj == null) |
|
|
|
@ -269,6 +212,7 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
_checkbox.Items.Add(new ListItem("宰前扣款", "ExceptionMoney")); |
|
|
|
_checkbox.Items.Add(new ListItem("宰后扣款", "宰后扣款")); |
|
|
|
_checkbox.Items.Add(new ListItem("死猪扣款", "DeadPigRewardMoney")); |
|
|
|
_checkbox.Items.Add(new ListItem("经检费", "JingJianFee")); |
|
|
|
|
|
|
|
_checkbox.Items.Add(new ListItem("付款金额", "ActualMoney")); |
|
|
|
_checkbox.Items.Add(new ListItem("核算金额", "Money")); |
|
|
|
@ -347,17 +291,20 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
var query = base.GetQueryDom(); |
|
|
|
var bill = JoinAlias.Create("bill"); |
|
|
|
|
|
|
|
tempUnionDom.Register(query); |
|
|
|
var unionAlias = new JoinAlias("tempUnionDom", typeof(tempUnionDom)); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(unionAlias), DQCondition.EQ(bill, "ID", unionAlias, "StatPay_ID")); |
|
|
|
|
|
|
|
var weight = new JoinAlias("mainweight", typeof(WeighBill)); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.EQ(bill, "Weigh_ID", weight, "ID")); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.EQ(unionAlias, "Weigh_ID", weight, "ID")); |
|
|
|
var abnormalRecord = new JoinAlias("war", typeof(AbnormalRecordingTemp)); |
|
|
|
query.RegisterQueryTable(typeof(AbnormalRecordingTemp), new string[] { "Weigh_ID", "DeathNumber" }, AbnormalRecordingTemp.GetQueryDom()); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(abnormalRecord), DQCondition.EQ(weight, "ID", abnormalRecord, "Weigh_ID"));//死亡
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(abnormalRecord), DQCondition.And(DQCondition.EQ(unionAlias, "UnionType", 1), DQCondition.EQ(weight, "ID", abnormalRecord, "Weigh_ID")));//死亡
|
|
|
|
|
|
|
|
var hotFreshInput = mQueryContainer.GetInput("HotFreshType"); |
|
|
|
if (hotFreshInput != null) |
|
|
|
ButcherOrderTemp.AddJoinWithCondition(query, weight, hotFreshInput); |
|
|
|
tempUnionDom.Register(query); |
|
|
|
var unionAlias = new JoinAlias("tempUnionDom", typeof(tempUnionDom)); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(unionAlias), DQCondition.EQ(bill, "ID", unionAlias, "StatPay_ID")); |
|
|
|
|
|
|
|
var costRecord = new JoinAlias(typeof(CostRecordTemp)); |
|
|
|
CostRecordTemp.Register(query); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(costRecord), DQCondition.And(DQCondition.EQ(unionAlias, "UnionType", 1), DQCondition.EQ(bill, "Weigh_ID", costRecord, "WeightBill_ID"))); |
|
|
|
@ -372,7 +319,8 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
var 盈亏 = DQExpression.Subtract(DQExpression.Subtract(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, "Money"))), DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, "ActualMoney")))), DQExpression.Sum(DQExpression.Add(DQExpression.IfNull(DQExpression.Field(costRecord, "TransferFee"), DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Field(costRecord, "JingJiFee"), DQExpression.Value(0))))); |
|
|
|
var costMoney = DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Add(DQExpression.Add(DQExpression.IfNull(DQExpression.Field(costRecord, "TransferFee"), DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Field(costRecord, "JingJiFee"), DQExpression.Value(0))), DQExpression.IfNull(DQExpression.Field(unionAlias, "ActualMoney"), DQExpression.Value(0))))); |
|
|
|
var sumColumn = new List<string>(); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Snippet<string>("ROW_NUMBER() OVER(order by [bill].[Date])"), "序号")); |
|
|
|
var 收购头数 = DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, "RealNumber"))); |
|
|
|
foreach (ListItem field in _checkbox.Items) |
|
|
|
{ |
|
|
|
if (field.Selected) |
|
|
|
@ -384,9 +332,8 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field(weight, "Zone_Name")); |
|
|
|
break; |
|
|
|
case "死亡头数": |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(abnormalRecord, field.Value), field.Text)); |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field(weight, "ID")); |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field(abnormalRecord, field.Value)); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Field(abnormalRecord, field.Value)), field.Text)); |
|
|
|
sumColumn.Add(field.Text); |
|
|
|
break; |
|
|
|
case "收购日期": |
|
|
|
case "收购类型": |
|
|
|
@ -405,7 +352,9 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
sumColumn.Add(field.Text); |
|
|
|
break; |
|
|
|
case "均重": |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, "RealWeight"))).ESafeDivide(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, "RealNumber")))).ECastType<Money<金额>>(), "均重")); |
|
|
|
var avgWeight = 收购重量.ESafeDivide(收购头数).ECastType<Money<金额>>(); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(avgWeight, "均重")); |
|
|
|
CustomSumColumns.Add("均重", avgWeight); |
|
|
|
break; |
|
|
|
|
|
|
|
case "收购头数": |
|
|
|
@ -413,12 +362,24 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
case "到厂毛重": |
|
|
|
case "付款金额": |
|
|
|
case "核算金额": |
|
|
|
case "核算单价": |
|
|
|
case "付款单价": |
|
|
|
case "宰前扣款": |
|
|
|
case "死猪扣款": |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, field.Value))), field.Text)); |
|
|
|
|
|
|
|
sumColumn.Add(field.Text); |
|
|
|
break; |
|
|
|
case "核算单价": |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, field.Value))), field.Text)); |
|
|
|
var s1 = DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, "Money"))).ESafeDivide(收购重量).ECastType<Money<二位小数>?>(); |
|
|
|
CustomSumColumns.Add("核算单价", s1); |
|
|
|
break; |
|
|
|
case "付款单价": |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, field.Value))), field.Text)); |
|
|
|
var s2 = DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, "ActualMoney"))).ESafeDivide(收购重量).ECastType<Money<二位小数>?>(); |
|
|
|
CustomSumColumns.Add("付款单价", s2); |
|
|
|
break; |
|
|
|
case "经检费": |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(weight, field.Value))).ECastType<Money<二位小数>?>(), field.Text)); |
|
|
|
sumColumn.Add(field.Text); |
|
|
|
break; |
|
|
|
case "成本金额": |
|
|
|
@ -428,9 +389,9 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
break; |
|
|
|
|
|
|
|
case "成本单价": |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Divide(costMoney, DQExpression.NullIfZero(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, "RealWeight"))))).ECastType<Money<二位小数>?>(), field.Text)); |
|
|
|
|
|
|
|
sumColumn.Add(field.Text); |
|
|
|
var costPrice = costMoney.ESafeDivide(收购重量).ECastType<Money<二位小数>?>(); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(costPrice, field.Text)); |
|
|
|
CustomSumColumns.Add("成本单价", costPrice); |
|
|
|
break; |
|
|
|
|
|
|
|
case "盈亏": |
|
|
|
@ -439,10 +400,10 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
sumColumn.Add(field.Text); |
|
|
|
break; |
|
|
|
case "单头盈亏": |
|
|
|
var 收购头数 = DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ(unionAlias, "UnionType", 1), DQExpression.Field(unionAlias, "RealNumber"))); |
|
|
|
var 单头盈亏 = 盈亏.ESafeDivide(收购头数).ECastType<Money<金额>>(); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(单头盈亏, "单头盈亏")); |
|
|
|
|
|
|
|
CustomSumColumns.Add("单头盈亏", 单头盈亏); |
|
|
|
// sumColumn.Add(field.Text);
|
|
|
|
break; |
|
|
|
|
|
|
|
@ -462,6 +423,8 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
case "损耗比": |
|
|
|
var 损耗比 = DQExpression.Multiply(损耗.ESafeDivide(榜前重量), DQExpression.Value(100)).ECastType<Money<金额>>(); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(损耗比, "损耗比")); |
|
|
|
var shS = DQExpression.Sum(DQExpression.Subtract(DQExpression.Field(unionAlias, "ShackWeight"), DQExpression.Field(unionAlias, "RealWeight"))); |
|
|
|
CustomSumColumns.Add("损耗比", DQExpression.Multiply(shS.ESafeDivide(榜前重量), DQExpression.Value(100)).ECastType<Money<金额>>()); |
|
|
|
break; |
|
|
|
|
|
|
|
case "皮重": |
|
|
|
@ -725,16 +688,14 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Field(unionAlias, "RealWeight")), "_RW")); |
|
|
|
foreach (var c in query.Columns) |
|
|
|
ColumnNames.Add(c.Name); |
|
|
|
foreach (var c in sumColumn) |
|
|
|
{ |
|
|
|
SumColumnNames.Add(c); |
|
|
|
GroupSumColumnNamnes.Add(c); |
|
|
|
// SubtotalGroupColumnNames.Add(c);
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return query; |
|
|
|
} |
|
|
|
|
|
|
|
@ -777,6 +738,7 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
#region prop
|
|
|
|
public int UnionType { get; set; } |
|
|
|
public long StatPay_ID { get; set; } |
|
|
|
public long? Weigh_ID { get; set; } |
|
|
|
|
|
|
|
public decimal? RealNumber { get; set; } |
|
|
|
public decimal? ShackWeight { get; set; } |
|
|
|
@ -844,6 +806,7 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value<int>(1), "UnionType")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", "StatPay_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weigh_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("RealNumber", "RealNumber")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ShackWeight", "ShackWeight")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("RealWeight", "RealWeight")); |
|
|
|
@ -909,9 +872,11 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
query.From.AddJoin(JoinType.Inner, new DQDmoSource(bill), DQCondition.EQ(bill, "ID", detail, "StatPay_ID")); |
|
|
|
|
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field(detail, "StatPay_ID")); |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field(bill, "Weigh_ID")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value<int>(2), "UnionType")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("StatPay_ID", detail, "StatPay_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weigh_ID", bill, "Weigh_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.NULL, "RealNumber")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.NULL, "ShackWeight")); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.NULL, "RealWeight")); |
|
|
|
@ -1009,7 +974,7 @@ namespace BWP.Web.Pages.B3QingDaoWanFu.Reports |
|
|
|
public static void Register(DQueryDom root) |
|
|
|
{ |
|
|
|
var butcherQuery = GetUnionDom(); |
|
|
|
root.RegisterQueryTable(typeof(tempUnionDom), new string[] { "UnionType", "StatPay_ID", "RealNumber", "ShackWeight", "RealWeight", "ActualMoney", "Money", "RawPrice", "ActualPrice", "ExceptionMoney", "OtherRewardMoney", "DeadPigRewardMoney", "Bo1Number", "Bo1Weight", "Bo2Number", "Bo2Weight", "Bo3Number", "Bo3Weight", "Bo4Number", "Bo4Weight", "Bo5Number", "Bo5Weight", "Tang1Number", "Tang1Weight", "Tang2Number", "Tang2Weight", "Tang3Number", "Tang3Weight", "Tang4Number", "Tang4Weight", "Tang5Number", "Tang5Weight", "Price1", "Price2", "Price3", "Price4", "Price5", "Bo1Money", "Bo2Money", "Bo3Money", "Bo4Money", "Bo5Money", "Tang1Money", "Tang2Money", "Tang3Money", "Tang4Money", "Tang5Money", "TotalMoney", "TotalWeight" }, butcherQuery); |
|
|
|
root.RegisterQueryTable(typeof(tempUnionDom), new string[] { "UnionType", "StatPay_ID", "Weigh_ID", "RealNumber", "ShackWeight", "RealWeight", "ActualMoney", "Money", "RawPrice", "ActualPrice", "ExceptionMoney", "OtherRewardMoney", "DeadPigRewardMoney", "Bo1Number", "Bo1Weight", "Bo2Number", "Bo2Weight", "Bo3Number", "Bo3Weight", "Bo4Number", "Bo4Weight", "Bo5Number", "Bo5Weight", "Tang1Number", "Tang1Weight", "Tang2Number", "Tang2Weight", "Tang3Number", "Tang3Weight", "Tang4Number", "Tang4Weight", "Tang5Number", "Tang5Weight", "Price1", "Price2", "Price3", "Price4", "Price5", "Bo1Money", "Bo2Money", "Bo3Money", "Bo4Money", "Bo5Money", "Tang1Money", "Tang2Money", "Tang3Money", "Tang4Money", "Tang5Money", "TotalMoney", "TotalWeight" }, butcherQuery); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|