diff --git a/B3CowButcherManageToSale/Rpcs/SaleOutStoreRpc.cs b/B3CowButcherManageToSale/Rpcs/SaleOutStoreRpc.cs index 26558db..97d8dbf 100644 --- a/B3CowButcherManageToSale/Rpcs/SaleOutStoreRpc.cs +++ b/B3CowButcherManageToSale/Rpcs/SaleOutStoreRpc.cs @@ -5,8 +5,10 @@ using System.Text; using BWP.B3CowButcherManage.BO; using BWP.B3CowButcherManage.Rpcs; using BWP.B3Frameworks.Utils; +using BWP.B3Sale.BL; using BWP.B3Sale.BO; using BWP.B3Sale.Utils; +using Forks.EnterpriseServices.BusinessInterfaces; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.EnterpriseServices.JsonRpc; @@ -178,6 +180,48 @@ namespace BWP.B3CowButcherManageToSale.Rpcs return 1; } + + [Rpc] + public static int SetFinishAssignState(long id, bool finish) + { + using (var session = Dmo.NewSession()) + { + var state = InnerBLUtil.GetDmoPropertyByID?>(session, typeof(SaleOutStore), "AssignState", id); + + if (finish && state == 配货状态.已配货) + return 1; + if (!finish && state == 配货状态.未配货) + return 1; + var bl = BIFactory.Create(session); + var dmo = bl.Load(id); + if (finish) + { + bl.FinishAssignGoods(dmo); + } + else + { + var query = new DQueryDom(new JoinAlias(typeof(WeightingInfor))); + query.Columns.Add(DQSelectColumn.Field("ID")); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("BillID", id), DQCondition.EQ("BillType", DmoTypeIDAttribute.GetID(typeof(SaleOutStore))))); + var wId = query.EExecuteScalar(session); + if (wId != null) + UpdateAssignStateByBillID(session,id); + bl.UnFinishAssignGoods(dmo); + } + session.Commit(); + } + return 1; + } + + private static void UpdateAssignStateByBillID(IDmoSession session, long billID) + { + var update2 = new DQUpdateDom(typeof(SaleOutStore)); + update2.Columns.Add(new DQUpdateColumn("RowVersion", DQExpression.Add(DQExpression.Field("RowVersion"), DQExpression.Value(1)))); + update2.Columns.Add(new DQUpdateColumn("AssignState", 配货状态.正在配货)); + update2.Where.Conditions.Add(DQCondition.EQ("ID", billID)); + session.ExecuteNonQuery(update2); + } + private static void UpdateAssignNumberByDetailID(IDmoSession session, long detailID,int packageNum) { var weightingInfo = GetWeightingInfor(session, detailID);