|
|
|
@ -0,0 +1,58 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using BWP.B3CowButcherManage.BO; |
|
|
|
using BWP.B3CowButcherManageToSale.Utils; |
|
|
|
using BWP.B3Frameworks; |
|
|
|
using BWP.B3Frameworks.Utils; |
|
|
|
using BWP.B3Sale.BO; |
|
|
|
using BWP.Web.Pages.B3Sale.Bills.ReturnInStore_; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
|
using Forks.EnterpriseServices.SqlDoms; |
|
|
|
|
|
|
|
namespace BWP.Web.Pages.TypeIOCs |
|
|
|
{ |
|
|
|
[TypeIOC(typeof(ReturnInStoreEdit), typeof(ReturnInStoreEdit.IAddDetailByBarCode))] |
|
|
|
public class AddDetailByBarCode : ReturnInStoreEdit.IAddDetailByBarCode |
|
|
|
{ |
|
|
|
public void Invoke(string barCode,ReturnInStore inStore) |
|
|
|
{ |
|
|
|
var left = new JoinAlias("_l", typeof(BarCodeProductionInfo)); |
|
|
|
var right = new JoinAlias("_r", typeof(BarCodeProductionInfo)); |
|
|
|
var query = new DQueryDom(left); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(right), DQCondition.EQ(left, "ID", right, "PackageID")); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ(left, "BarCode", barCode)); |
|
|
|
var arr = new string[] { "Goods_ID", "Weight", "Product_Batch" }; |
|
|
|
foreach (var f in arr) |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.LogicCase(DQCondition.EQ(left, "BarType", 3), DQExpression.Field(right, f), DQExpression.Field(left, f)), f)); |
|
|
|
var list = new List<Tuple<long,decimal,string>>(); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
{ |
|
|
|
while (reader.Read()) |
|
|
|
{ |
|
|
|
var tuple = new Tuple<long, decimal, string>((long)reader[0], (decimal)reader[1], (string)reader[2]); |
|
|
|
list.Add(tuple); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
foreach (var goodsGroup in list.GroupBy(x=>x.Item1)) |
|
|
|
{ |
|
|
|
foreach (var batchGroup in goodsGroup.GroupBy(x=>x.Item3)) |
|
|
|
{ |
|
|
|
var detail = new ReturnInStore_Detail(); |
|
|
|
detail.SaleGoods_ID = goodsGroup.Key; |
|
|
|
var tuple = CommonQuery.GetGoodsBatch(batchGroup.Key, goodsGroup.Key); |
|
|
|
if (tuple != null) |
|
|
|
detail.GoodsBatch_ID = tuple.Item1; |
|
|
|
detail.UnitNum = batchGroup.Sum(x=>x.Item2); |
|
|
|
DmoUtil.RefreshDependency(detail, "SaleGoods_ID"); |
|
|
|
inStore.Details.Add(detail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |