|
|
@ -45,34 +45,25 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
var main = new JoinAlias(typeof(SaleOutStore)); |
|
|
var main = new JoinAlias(typeof(SaleOutStore)); |
|
|
var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog)); |
|
|
var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog)); |
|
|
var detail = new JoinAlias(typeof(SaleOutStore_Detail)); |
|
|
var detail = new JoinAlias(typeof(SaleOutStore_Detail)); |
|
|
var weight = new JoinAlias(typeof(WeightingInfor)); |
|
|
|
|
|
var scan = new JoinAlias(typeof(WeightingInfo_ScanDetail)); |
|
|
var scan = new JoinAlias(typeof(WeightingInfo_ScanDetail)); |
|
|
var temp = new JoinAlias(typeof(Temp)); |
|
|
|
|
|
var query = new DQueryDom(main); |
|
|
var query = new DQueryDom(main); |
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(main, "ID", relate, "SaleOutStore_ID")); |
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(main, "ID", relate, "SaleOutStore_ID")); |
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID")); |
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID")); |
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.And(DQCondition.EQ(detail, "ID", weight, "DetailID"), DQCondition.EQ(weight, "BillType", DmoTypeIDAttribute.GetID(typeof(SaleOutStore))))); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(scan), DQCondition.And(DQCondition.EQ(detail, "ID", scan, "Detail_ID"), DQCondition.EQ(weight, "ID", scan, "WeightingInfo_ID"))); |
|
|
|
|
|
query.RegisterQueryTable(typeof(Temp), new string[] { "GroupID", "Weight" }, Temp.GetQueryDom()); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(temp), DQCondition.EQ(detail, "ID", temp, "GroupID")); |
|
|
|
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(scan), DQCondition.EQ(detail, "ID", scan, "Detail_ID")); |
|
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", main)); |
|
|
query.Columns.Add(DQSelectColumn.Field("ID", main)); |
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode", scan)); |
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode", scan)); |
|
|
query.Columns.Add(DQSelectColumn.Field("NetWeight", weight)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", detail)); |
|
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight", scan)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID", scan)); |
|
|
query.Columns.Add(DQSelectColumn.Field("LoadTime", main)); |
|
|
query.Columns.Add(DQSelectColumn.Field("LoadTime", main)); |
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Code", detail)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight", temp)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Code", scan)); |
|
|
|
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.IsNull(DQExpression.Field(relate, "SaleOutStore_ID")), DQCondition.IsNotNull(DQExpression.Field(scan, "ID")))); |
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.IsNull(DQExpression.Field(relate, "SaleOutStore_ID")), DQCondition.IsNotNull(DQExpression.Field(scan, "ID")))); |
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(main, "ID")); |
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(main, "ID")); |
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(weight, "NetWeight", true)); |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
using (var session = Dmo.NewSession()) |
|
|
{ |
|
|
{ |
|
|
var list = new List<CarcassSaleOutStoreObj>(); |
|
|
var list = new List<CarcassSaleOutStoreObj>(); |
|
|
var ids = new List<long>(); |
|
|
var ids = new List<long>(); |
|
|
var discont = new Dictionary<long, decimal>(); |
|
|
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
{ |
|
|
{ |
|
|
while (reader.Read()) |
|
|
while (reader.Read()) |
|
|
@ -82,18 +73,10 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
ids.Add(id); |
|
|
ids.Add(id); |
|
|
var entity = new CarcassSaleOutStoreObj(); |
|
|
var entity = new CarcassSaleOutStoreObj(); |
|
|
entity.BarCode = (string)reader[1]; |
|
|
entity.BarCode = (string)reader[1]; |
|
|
var wv = ((Money<decimal>?)reader[2]).EToDecimal(); |
|
|
|
|
|
entity.GroupID = (long)reader[3]; |
|
|
|
|
|
if (wv < 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var first = list.FirstOrDefault(x => x.GroupID == entity.GroupID && x.BarCode == entity.BarCode); |
|
|
|
|
|
if (first != null) |
|
|
|
|
|
list.Remove(first); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
entity.Weight = (decimal?)reader[2]; |
|
|
|
|
|
entity.ProductBatch_ID = (long?)reader[3]; |
|
|
entity.Time = (DateTime?)reader[4]; |
|
|
entity.Time = (DateTime?)reader[4]; |
|
|
entity.SaleGoods_Code = (string)reader[5]; |
|
|
entity.SaleGoods_Code = (string)reader[5]; |
|
|
entity.Weight = (decimal?)reader[6]; |
|
|
|
|
|
list.Add(entity); |
|
|
list.Add(entity); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -101,18 +84,6 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
return; |
|
|
return; |
|
|
if (list.Any()) |
|
|
if (list.Any()) |
|
|
{ |
|
|
{ |
|
|
foreach (var g in list.GroupBy(x => x.GroupID)) |
|
|
|
|
|
{ |
|
|
|
|
|
var first = true; |
|
|
|
|
|
foreach (var item in g) |
|
|
|
|
|
{ |
|
|
|
|
|
if (first) |
|
|
|
|
|
first = false; |
|
|
|
|
|
else |
|
|
|
|
|
item.Weight = 0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var slist = TraceBackInfoUtil.SplitList(list, 1000); |
|
|
var slist = TraceBackInfoUtil.SplitList(list, 1000); |
|
|
foreach (var items in slist) |
|
|
foreach (var items in slist) |
|
|
{ |
|
|
{ |
|
|
@ -132,31 +103,6 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
{ |
|
|
{ |
|
|
get { return "上传审核的销售出库扫码信息到MES"; } |
|
|
get { return "上传审核的销售出库扫码信息到MES"; } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class Temp |
|
|
|
|
|
{ |
|
|
|
|
|
public long GroupID { get; set; } |
|
|
|
|
|
public decimal? Weight { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public static DQueryDom GetQueryDom() |
|
|
|
|
|
{ |
|
|
|
|
|
var main = new JoinAlias(typeof(SaleOutStore)); |
|
|
|
|
|
var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog)); |
|
|
|
|
|
var detail = new JoinAlias(typeof(SaleOutStore_Detail)); |
|
|
|
|
|
var weight = new JoinAlias(typeof(WeightingInfor)); |
|
|
|
|
|
var query = new DQueryDom(main); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(main, "ID", relate, "SaleOutStore_ID")); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID")); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.And(DQCondition.EQ(detail, "ID", weight, "DetailID"), DQCondition.EQ(weight, "BillType", DmoTypeIDAttribute.GetID(typeof(SaleOutStore))))); |
|
|
|
|
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", detail)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Sum(weight, "NetWeight")); |
|
|
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field(detail, "ID")); |
|
|
|
|
|
|
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.IsNull(DQExpression.Field(relate, "SaleOutStore_ID")), DQCondition.IsNotNull(DQExpression.Field(weight, "ID")))); |
|
|
|
|
|
return query; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class CarcassSaleOutStoreObj |
|
|
class CarcassSaleOutStoreObj |
|
|
@ -164,7 +110,7 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
public string BarCode { get; set; } |
|
|
public string BarCode { get; set; } |
|
|
public decimal? Weight { get; set; } |
|
|
public decimal? Weight { get; set; } |
|
|
public DateTime? Time { get; set; } |
|
|
public DateTime? Time { get; set; } |
|
|
public long? GroupID { get; set; } |
|
|
|
|
|
public string SaleGoods_Code { get; set; } |
|
|
public string SaleGoods_Code { get; set; } |
|
|
|
|
|
public long? ProductBatch_ID { get; set; } |
|
|
} |
|
|
} |
|
|
} |
|
|
} |