diff --git a/ButcherFactory.BO/Base/WorkerGoodsSetProfile.cs b/ButcherFactory.BO/Base/WorkerGoodsSetProfile.cs new file mode 100644 index 0000000..fb3d3a3 --- /dev/null +++ b/ButcherFactory.BO/Base/WorkerGoodsSetProfile.cs @@ -0,0 +1,20 @@ +using Forks.EnterpriseServices.DataDictionary; +using Forks.EnterpriseServices.DomainObjects2; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ButcherFactory.BO +{ + [MapToTable("Butcher_WorkerGoodsSetProfile")] + [DBIndex("IDX_Butcher_WorkerGoodsSet_Clustered", "Worker_ID", false, 0)] + [DBIndexType("IDX_Butcher_WorkerGoodsSet_Clustered", IndexType.Clustered)] + public class WorkerGoodsSetProfile + { + public long Worker_ID { get; set; } + + public long ClientGoodsSet_Detail_ID { get; set; } + } +} diff --git a/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs b/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs new file mode 100644 index 0000000..790eb69 --- /dev/null +++ b/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs @@ -0,0 +1,36 @@ +using Forks.EnterpriseServices.DomainObjects2; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ButcherFactory.BO +{ + [MapToTable("Butcher_ClientGoodsSet")] + public class ClientGoodsSet : BaseInfo + { + private List mDetails = new List(); + [NonDmoProperty] + public List Details { get { return mDetails; } } + + [NonDmoProperty] + public bool Stopped { get; set; } + } + + [MapToTable("Butcher_ClientGoodsSet_Detail")] + public class ClientGoodsSet_Detail + { + public long ClientGoodsSet_ID { get; set; } + + public long ID { get; set; } + + public long Goods_ID { get; set; } + + public decimal? StandardWeight { get; set; } + + public decimal? StandardWeightUp { get; set; } + + public decimal? StandardWeightLow { get; set; } + } +} diff --git a/ButcherFactory.BO/BaseInfo/Goods.cs b/ButcherFactory.BO/BaseInfo/Goods.cs index 354a803..082d673 100644 --- a/ButcherFactory.BO/BaseInfo/Goods.cs +++ b/ButcherFactory.BO/BaseInfo/Goods.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace ButcherFactory.BO { [MapToTable("Butcher_Goods")] - public class Goods:BaseInfo + public class Goods : BaseInfo { public string MainUnit { get; set; } diff --git a/ButcherFactory.BO/ButcherFactory.BO.csproj b/ButcherFactory.BO/ButcherFactory.BO.csproj index 55bdb4a..2bc77cb 100644 --- a/ButcherFactory.BO/ButcherFactory.BO.csproj +++ b/ButcherFactory.BO/ButcherFactory.BO.csproj @@ -56,13 +56,16 @@ + - + + + diff --git a/ButcherFactory.BO/Enums/ApplyClient.cs b/ButcherFactory.BO/Enums/ApplyClient.cs new file mode 100644 index 0000000..9c19d13 --- /dev/null +++ b/ButcherFactory.BO/Enums/ApplyClient.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ButcherFactory.BO +{ + public enum ApplyClient + { + 白条出入库 = 0, + 分割品 = 1, + 副产品 = 2, + } +} diff --git a/ButcherFactory.BO/Base/DriveType.cs b/ButcherFactory.BO/Enums/DriveType.cs similarity index 100% rename from ButcherFactory.BO/Base/DriveType.cs rename to ButcherFactory.BO/Enums/DriveType.cs diff --git a/ButcherFactory.BO/Rpcs/BaseInfoSyncRpc.cs b/ButcherFactory.BO/Rpcs/BaseInfoSyncRpc.cs index 2588fb3..5fc5783 100644 --- a/ButcherFactory.BO/Rpcs/BaseInfoSyncRpc.cs +++ b/ButcherFactory.BO/Rpcs/BaseInfoSyncRpc.cs @@ -1,5 +1,6 @@ using ButcherFactory.BO.Utils; using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.JsonRpc.Client; using Newtonsoft.Json; using System; @@ -38,17 +39,38 @@ namespace ButcherFactory.BO.Rpcs } } - public static void SyncGoodsByTag(string tag) + public static void SyncGoodsByTag(ApplyClient applyClient) { - //var json = RpcFacade.Call(baseInfoRpcPath + "SyncGoods"); - //var list = JsonConvert.DeserializeObject>(json); - //using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection)) - //{ - // TruncateTable(typeof(Goods), session); - // foreach (var item in list) - // session.Insert(item); - // session.Commit(); - //} + var json = RpcFacade.Call(baseInfoRpcPath + "SyncClientGoodsSetByClient", (short)applyClient); + var list = JsonConvert.DeserializeObject>(json); + using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection)) + { + foreach (var item in list) + { + DeleteOld(item.ID, session); + if (!item.Stopped) + Insert(item, session); + } + session.Commit(); + } + } + + static void DeleteOld(long id, IDmoSession session) + { + var detail = new DQDeleteDom(typeof(ClientGoodsSet_Detail)); + detail.Where.Conditions.Add(DQCondition.EQ("ClientGoodsSet_ID", id)); + session.ExecuteNonQuery(detail); + + var main = new DQDeleteDom(typeof(ClientGoodsSet)); + main.Where.Conditions.Add(DQCondition.EQ("ID", id)); + session.ExecuteNonQuery(main); + } + + static void Insert(ClientGoodsSet entity, IDmoSession session) + { + session.Insert(entity); + foreach (var detail in entity.Details) + session.Insert(detail); } } } diff --git a/ButcherFactory.BO/Utils/LoginUtil.cs b/ButcherFactory.BO/Utils/LoginUtil.cs index abbb067..4b1485c 100644 --- a/ButcherFactory.BO/Utils/LoginUtil.cs +++ b/ButcherFactory.BO/Utils/LoginUtil.cs @@ -86,7 +86,7 @@ namespace ButcherFactory.BO.Utils const string loginMethod = "/MainSystem/B3ClientService/Rpcs/LoginRpc/Login"; var r = RpcFacade.Call(loginMethod, name, pwd); if (r == 0) - throw new Exception("工号输入错误"); + throw new Exception("用户名密码错误"); else if (r == -1) throw new Exception("账号被停用"); AppContext.Worker.ID = r; diff --git a/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs b/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs index 256ab2c..d6075b7 100644 --- a/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs +++ b/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs @@ -32,7 +32,7 @@ namespace ButcherFactory.CarcassInStore_ { if (netStateWatch1.NetState) { - BaseInfoSyncRpc.SyncGoodsByTag(""); + BaseInfoSyncRpc.SyncGoodsByTag(ApplyClient.白条出入库); BaseInfoSyncRpc.SyncBaseInfo(); BaseInfoSyncRpc.SyncBaseInfo(); } diff --git a/ButcherFactory.Login/Login.cs b/ButcherFactory.Login/Login.cs index 660dc50..a452940 100644 --- a/ButcherFactory.Login/Login.cs +++ b/ButcherFactory.Login/Login.cs @@ -17,6 +17,9 @@ namespace ButcherFactory.Login public Login() { InitializeComponent(); +#if DEBUG + pwdBox.Text = "123"; +#endif try { userNameBox.Text = AppContext.Worker.Name;