diff --git a/B3CowButcherManageToSale/TypeIOCs/SaleOutStoreBLTypeIoc.cs b/B3CowButcherManageToSale/TypeIOCs/SaleOutStoreBLTypeIoc.cs index 962cee1..105f4d1 100644 --- a/B3CowButcherManageToSale/TypeIOCs/SaleOutStoreBLTypeIoc.cs +++ b/B3CowButcherManageToSale/TypeIOCs/SaleOutStoreBLTypeIoc.cs @@ -108,4 +108,76 @@ namespace BWP.B3CowButcherManageToSale.TypeIOCs get { return string.Format("销售出库单No.{0}扫码信息到屠宰系统", BillID); } } } + + [TypeIOC(typeof(SaleOutStoreBL), typeof(SaleOutStoreBL.BillBLIOCs.AfterUnCheck))] + public class SaleOutStoreUnCheckBLTypeIoc : SaleOutStoreBL.BillBLIOCs.AfterUnCheck + { + public void Invoke(IDmoContext context, SaleOutStore dmo) + { + var task = new SaleInfoToButcherUnCheckTask(dmo.ID); + task.AddTaskUser_ID = BLContext.User.ID; + task.DomainUser_ID = DomainContext.Current.DomainUser.ID; + QueueTaskService.Add(task); + } + } + + [Serializable] + class SaleInfoToButcherUnCheckTask : QueueTaskBase + { + public long BillID { get; set; } + public long DomainUser_ID { get; set; } + + public SaleInfoToButcherUnCheckTask(long id) + { + BillID = id; + } + + public override bool PersistTask + { + get + { + return true; + } + } + + protected override bool SingleTaskInQueue + { + get + { + return true; + } + } + + public override void Execute(QueueTaskContext context) + { + using (var scope = new SpecialDomainUserBLScope(DomainUser_ID)) + { + using (var session = Dmo.NewSession()) + { + var codes = GetBarCodeInfos(session, BillID); + if(codes.Count > 0) + BarCodeProductRpc.ClearSaleInfo(codes); + } + } + } + + List GetBarCodeInfos(IDmoSession session, long id) + { + var detail = new JoinAlias(typeof(SaleOutStore_Detail)); + var bill = new JoinAlias(typeof(SaleOutStore)); + var scan = new JoinAlias(typeof(WeightingInfo_ScanDetail)); + var query = new DQueryDom(detail); + query.From.AddJoin(JoinType.Left, new DQDmoSource(bill), DQCondition.EQ(detail, "SaleOutStore_ID", bill, "ID")); + query.From.AddJoin(JoinType.Left, new DQDmoSource(scan), DQCondition.EQ(detail, "ID", scan, "Detail_ID")); + query.Columns.Add(DQSelectColumn.Field("BarCode", scan)); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(detail, "SaleOutStore_ID", id), DQCondition.IsNotNull(DQExpression.Field(scan, "ID")))); + query.Where.Conditions.Add(DQCondition.InEQ(scan, "BarCode", "")); + return query.EExecuteList(session); + } + + public override string Name + { + get { return string.Format("销售出库单No.{0}撤销清空条码销售信息到屠宰系统", BillID); } + } + } }