From 185b82b49cdd701352613701e282f3c5d58e2bd5 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Tue, 12 Jun 2018 09:25:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=B6=E7=8C=AA=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- B3ClientService/B3ClientService.csproj | 1 + .../B3ClientServiceOnLineConfig.cs | 9 +++ B3ClientService/NamedValueTemplate.cs | 1 + B3ClientService/Rpcs/PickOutConfirmRpc.cs | 55 +++++++++++++++++++ .../Tasks/AutoCreateProductBatchTask.cs | 36 ++++++++---- .../config/NamedValue/B3ClientService.xml | 1 + 6 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 B3ClientService/Rpcs/PickOutConfirmRpc.cs diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj index 3bf2568..cdb24f9 100644 --- a/B3ClientService/B3ClientService.csproj +++ b/B3ClientService/B3ClientService.csproj @@ -224,6 +224,7 @@ + diff --git a/B3ClientService/B3ClientServiceOnLineConfig.cs b/B3ClientService/B3ClientServiceOnLineConfig.cs index cd17b8f..e2281d5 100644 --- a/B3ClientService/B3ClientServiceOnLineConfig.cs +++ b/B3ClientService/B3ClientServiceOnLineConfig.cs @@ -27,6 +27,15 @@ namespace BWP.B3ClientService set { _traceBackUrl = value; } } + private StringConfigRef _productBatchRole = new StringConfigRef(""); + [LogicName("自动生成批次模板")] + [ConfigurationItemGroup("MES系统")] + [ConfigurationItemDescription("自动生成批次 日期追加部分用英文半角逗号分开")] + public StringConfigRef ProductBatchRole + { + get { return _productBatchRole; } + set { _productBatchRole = value; } + } } } diff --git a/B3ClientService/NamedValueTemplate.cs b/B3ClientService/NamedValueTemplate.cs index a592223..f2ed0ff 100644 --- a/B3ClientService/NamedValueTemplate.cs +++ b/B3ClientService/NamedValueTemplate.cs @@ -21,6 +21,7 @@ namespace BWP.B3ClientService.NamedValueTemplate public static readonly NamedValue<终端> 白条领用 = new NamedValue<终端>(1); public static readonly NamedValue<终端> 分割生产 = new NamedValue<终端>(2); public static readonly NamedValue<终端> 分割入库 = new NamedValue<终端>(3); + public static readonly NamedValue<终端> 赶猪确认 = new NamedValue<终端>(103); } public sealed class 适用客户端 diff --git a/B3ClientService/Rpcs/PickOutConfirmRpc.cs b/B3ClientService/Rpcs/PickOutConfirmRpc.cs new file mode 100644 index 0000000..58a1c38 --- /dev/null +++ b/B3ClientService/Rpcs/PickOutConfirmRpc.cs @@ -0,0 +1,55 @@ +using BWP.B3ClientService.BO; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.JsonRpc; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.B3ClientService.Rpcs +{ + [Rpc] + public static class PickOutConfirmRpc + { + [Rpc(RpcFlags.SkipAuth)] + public static string GetList(DateTime date) + { + var query = new DQueryDom(new JoinAlias(typeof(OrderDetail))); + query.Columns.Add(DQSelectColumn.Field("ID")); + query.Columns.Add(DQSelectColumn.Field("Order")); + query.Columns.Add(DQSelectColumn.Field("PlanNumber")); + query.Columns.Add(DQSelectColumn.Field("LiveColonyHouse_Name")); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("DeleteState", false), DQCondition.EQ("IsHurryButcher", false), DQCondition.EQ("Date", date))); + var list = new List(); + using (var session = Dmo.NewSession()) + { + using (var reader = session.ExecuteReader(query)) + { + while (reader.Read()) + { + var entity = new PickOutConfirmDmo(); + entity.ID = (long)reader[0]; + entity.Order = (int)reader[1]; + entity.PlanNumber = (int)reader[2]; + entity.LiveColonyHouse_Name = (string)reader[3]; + list.Add(entity); + } + } + } + return JsonConvert.SerializeObject(list); + } + + class PickOutConfirmDmo + { + public long ID { get; set; } + + public int Order { get; set; } + + public int PlanNumber { get; set; } + + public string LiveColonyHouse_Name { get; set; } + } + } +} diff --git a/B3ClientService/Tasks/AutoCreateProductBatchTask.cs b/B3ClientService/Tasks/AutoCreateProductBatchTask.cs index ff4f76c..dab949c 100644 --- a/B3ClientService/Tasks/AutoCreateProductBatchTask.cs +++ b/B3ClientService/Tasks/AutoCreateProductBatchTask.cs @@ -16,22 +16,34 @@ namespace BWP.B3ClientService.Tasks { public void Execute() { - var exist = Exist(); - if (exist) - return; - var bl = BIFactory.Create(); - var entity = new ProductBatch(); - bl.InitNewDmo(entity); - entity.Name = DateTime.Today.ToString("yyyyMMdd"); ; - entity.Date = DateTime.Today; - bl.Insert(entity); + var role = new B3ClientServiceOnLineConfig().ProductBatchRole.Value; + var arr = role.Split(new char[] { ',' }).ToList(); + if (arr.Count == 0) + arr.Add(""); + using (var session = Dmo.NewSession()) + { + var bl = BIFactory.Create(session); + foreach (var item in arr) + { + var name = DateTime.Today.ToString("yyyyMMdd") + item; + if (Exist(session, name)) + continue; + var entity = new ProductBatch(); + bl.InitNewDmo(entity); + entity.Name = name; + entity.Date = DateTime.Today; + bl.Insert(entity); + } + session.Commit(); + } } - bool Exist() + bool Exist(IDmoSession session, string name) { var query = new DQueryDom(new JoinAlias(typeof(ProductBatch))); - query.Where.Conditions.Add(DQCondition.EQ("Date", DateTime.Today)); - return query.EExists(); + query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "c")); + query.Where.Conditions.Add(DQCondition.EQ("Name", name)); + return query.EExecuteScalar(session) != null; } public string Name diff --git a/WebFolder/config/NamedValue/B3ClientService.xml b/WebFolder/config/NamedValue/B3ClientService.xml index 254c1e4..d035171 100644 --- a/WebFolder/config/NamedValue/B3ClientService.xml +++ b/WebFolder/config/NamedValue/B3ClientService.xml @@ -12,6 +12,7 @@ +