diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj index 077664d..b745dec 100644 --- a/B3ClientService/B3ClientService.csproj +++ b/B3ClientService/B3ClientService.csproj @@ -163,6 +163,7 @@ + diff --git a/B3ClientService/BO/BaseInfo/Car.cs b/B3ClientService/BO/BaseInfo/Car.cs index 900fc98..1444aff 100644 --- a/B3ClientService/BO/BaseInfo/Car.cs +++ b/B3ClientService/BO/BaseInfo/Car.cs @@ -10,5 +10,7 @@ namespace BWP.B3ClientService.BO public class Car : BaseInfo { public string Driver_IDCard { get; set; } + + public int? Standard { get; set; } } } diff --git a/B3ClientService/BO/Bill/WeightBill/WashCarPrint.cs b/B3ClientService/BO/Bill/WeightBill/WashCarPrint.cs new file mode 100644 index 0000000..ab22c99 --- /dev/null +++ b/B3ClientService/BO/Bill/WeightBill/WashCarPrint.cs @@ -0,0 +1,33 @@ +using Forks.EnterpriseServices.DataDictionary; +using Forks.EnterpriseServices.DomainObjects2; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3ClientService.BO +{ + [BOClass] + public class WashCarPrint + { + [DbColumn(Index = IndexType.Normal)] + public long BillID { get; set; } + + public DateTime Date { get; set; } + + public DateTime LastPrintTime { get; set; } + + public int RowIndex { get; set; } + + public int PrintDegree { get; set; } + + public string CarNumber { get; set; } + + public int CarSize { get; set; } + + public decimal Fee { get; set; } + + public string WeightMan { get; set; } + } +} diff --git a/B3ClientService/Rpcs/SelfHelpRpc.cs b/B3ClientService/Rpcs/SelfHelpRpc.cs index 0d72908..5648e64 100644 --- a/B3ClientService/Rpcs/SelfHelpRpc.cs +++ b/B3ClientService/Rpcs/SelfHelpRpc.cs @@ -61,7 +61,7 @@ namespace BWP.B3ClientService.Rpcs q1.From.AddJoin(JoinType.Left, new DQDmoSource(employee1), DQCondition.EQ(employee1, "ID", m1, "Employee_ID")); q1.Columns.Add(DQSelectColumn.Field("ID")); q1.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "BillType")); - q1.Columns.Add(DQSelectColumn.Field("Name",car1)); + q1.Columns.Add(DQSelectColumn.Field("Name", car1)); q1.Columns.Add(DQSelectColumn.Field("Number", d1)); q1.Columns.Add(DQSelectColumn.Field("WeighTime")); q1.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("PrintNumber", 0), DQCondition.EQ("DeleteState", false))); @@ -83,7 +83,7 @@ namespace BWP.B3ClientService.Rpcs q1.From.AddJoin(JoinType.Left, new DQDmoSource(employee2), DQCondition.EQ(m1, "employeeID", employee2, "ID")); q1.Columns.Add(DQSelectColumn.Field("ID")); q1.Columns.Add(DQSelectColumn.Create(DQExpression.Value(0), "BillType")); - q1.Columns.Add(DQSelectColumn.Field("Name",car2)); + q1.Columns.Add(DQSelectColumn.Field("Name", car2)); q1.Columns.Add(DQSelectColumn.Field("number", d1)); q1.Columns.Add(DQSelectColumn.Field("BillTime")); q1.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("WeightBill_ID"))); @@ -234,6 +234,114 @@ namespace BWP.B3ClientService.Rpcs } } + [Rpc(RpcFlags.SkipAuth)] + public static string GetWashPrintEntity(long id, decimal fee) + { + WashCarPrint enitity; + using (var session = Dmo.NewSession()) + { + if (Exist(session, id)) + { + UpdatePrint(session, id, fee); + enitity = LoadCarPrint(session, id); + } + else + enitity = InsertPrint(session, id, fee); + session.Commit(); + } + return JsonConvert.SerializeObject(enitity); + } + + static bool Exist(IDmoSession session, long billID) + { + var query = new DQueryDom(new JoinAlias(typeof(WashCarPrint))); + query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "c")); + query.Where.Conditions.Add(DQCondition.EQ("BillID", billID)); + return query.EExecuteScalar() != null; + } + + static void UpdatePrint(IDmoSession session, long id, decimal fee) + { + var update = new DQUpdateDom(typeof(WashCarPrint)); + update.Where.Conditions.Add(DQCondition.EQ("BillID", id)); + update.Columns.Add(new DQUpdateColumn("Fee", fee)); + update.Columns.Add(new DQUpdateColumn("LastPrintTime", DateTime.Today)); + update.Columns.Add(new DQUpdateColumn("PrintDegree", DQExpression.Add(DQExpression.Field("PrintDegree"), DQExpression.Value(1)))); + session.ExecuteNonQuery(update); + } + + static WashCarPrint LoadCarPrint(IDmoSession session, long id) + { + var dom = new DmoQuery(typeof(WashCarPrint)); + dom.Where.Conditions.Add(DQCondition.EQ("BillID", id)); + return (WashCarPrint)session.ExecuteScalar(dom); + } + + static WashCarPrint InsertPrint(IDmoSession session, long id, decimal fee) + { + var entity = new WashCarPrint(); + var obj = GetMinWeightInfo(session, id); + entity.BillID = id; + entity.CarNumber = obj.Item1; + entity.CarSize = obj.Item3; + entity.WeightMan = obj.Item2; + entity.Date = obj.Item4; + entity.Fee = fee; + entity.LastPrintTime = DateTime.Now; + entity.PrintDegree = 1; + entity.RowIndex = GetTodayNumber(session, entity.Date); + session.Insert(entity); + return entity; + } + + static Tuple GetMinWeightInfo(IDmoSession session, long id) + { + var main = new JoinAlias(typeof(WeightBill)); + var car = new JoinAlias(typeof(Car)); + var query = new DQueryDom(main); + query.From.AddJoin(JoinType.Left, new DQDmoSource(car), DQCondition.EQ(main, "Car_ID", car, "ID")); + query.Where.Conditions.Add(DQCondition.EQ("ID", id)); + query.Columns.Add(DQSelectColumn.Field("Car_Name")); + query.Columns.Add(DQSelectColumn.Field("Creator")); + query.Columns.Add(DQSelectColumn.Field("Standard", car)); + query.Columns.Add(DQSelectColumn.Field("WeighTime")); + using (var reader = session.ExecuteReader(query)) + { + if (reader.Read()) + { + var carName = (string)reader[0]; + var creator = (string)reader[1]; + var standard = (int)(reader[2] ?? 0); + var date = (DateTime)reader[3]; + return new Tuple(carName, creator, standard, date.Date); + } + } + return new Tuple(string.Empty, string.Empty, 0, DateTime.Today); + } + + static int GetTodayNumber(IDmoSession session, DateTime date) + { + var query = new DQueryDom(new JoinAlias(typeof(WashCarPrint))); + query.Columns.Add(DQSelectColumn.Max("RowIndex")); + query.Where.Conditions.Add(DQCondition.EQ("Date", date)); + var maxID = session.ExecuteScalar(query); + if (maxID == null) + return 1; + return (int)maxID + 1; + } + + [Rpc(RpcFlags.SkipAuth)] + public static int? GetCarStandad(long id) + { + var main = new JoinAlias(typeof(WeightBill)); + var car = new JoinAlias(typeof(Car)); + var query = new DQueryDom(main); + query.From.AddJoin(JoinType.Left, new DQDmoSource(car), DQCondition.EQ(main, "Car_ID", car, "ID")); + query.Where.Conditions.Add(DQCondition.EQ("ID", id)); + query.Columns.Add(DQSelectColumn.Field("Standard", car)); + return query.EExecuteScalar(); + } + class ViewEntity { public long ID { get; set; } diff --git a/B3ClientService/Tasks/SyncInfoFromServer.cs b/B3ClientService/Tasks/SyncInfoFromServer.cs index f128e6c..c1945cf 100644 --- a/B3ClientService/Tasks/SyncInfoFromServer.cs +++ b/B3ClientService/Tasks/SyncInfoFromServer.cs @@ -83,24 +83,24 @@ namespace BWP.B3ClientService.Tasks // } //} -// private void SyncProductBatch() -// { -// var json = RpcFacade.Call("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/SyncProductBatch"); -// json = json.ESerializeDateTime(); -// var list = JsonConvert.DeserializeObject>(json); -// using (var context = new TransactionContext()) -// { -// var sql1 = @"truncate table [B3ClientService_ProductBatch];"; -// context.Session.ExecuteSqlNonQuery(sql1); -// foreach (ProductBatch dmo in list) -// { -//// var dmo = new ProductBatch(); -//// dmo.Name = name; -// context.Session.Insert(dmo); -// } -// context.Commit(); -// } -// } + // private void SyncProductBatch() + // { + // var json = RpcFacade.Call("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/SyncProductBatch"); + // json = json.ESerializeDateTime(); + // var list = JsonConvert.DeserializeObject>(json); + // using (var context = new TransactionContext()) + // { + // var sql1 = @"truncate table [B3ClientService_ProductBatch];"; + // context.Session.ExecuteSqlNonQuery(sql1); + // foreach (ProductBatch dmo in list) + // { + //// var dmo = new ProductBatch(); + //// dmo.Name = name; + // context.Session.Insert(dmo); + // } + // context.Commit(); + // } + // } //private void SyncWorkUnit() //{ @@ -211,7 +211,7 @@ namespace BWP.B3ClientService.Tasks } context.Commit(); } - } + } void SyncSupplier() { @@ -260,7 +260,7 @@ namespace BWP.B3ClientService.Tasks } context.Commit(); } - } + } void SyncBaseInfo(string rpcMethodName, string rpcClassName = null) where T : BWP.B3ClientService.BO.BaseInfo, new() @@ -283,6 +283,9 @@ namespace BWP.B3ClientService.Tasks { var car = entity as Car; car.Driver_IDCard = o.Get("Driver_IDCard"); + var standard = o.Get("Remark"); + if (!string.IsNullOrEmpty(standard))//不支持NamedValue 这里用Remark传值 + car.Standard = int.Parse(standard); context.Session.Insert(car); } else