From b8f13a93039547aed8121b2d7aa6165cc28203d1 Mon Sep 17 00:00:00 2001 From: ddlucky Date: Fri, 7 Apr 2023 09:52:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=92=8C=E5=B7=9D=E5=AF=B9SAP=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + DSWeb.Common/DB/DS6Comm.cs | 29 ++-- DSWeb.Common/DB/DS6DataContext.cs | 4 +- .../Controllers/PublicInterfaceController.cs | 101 +++--------- DSWeb/Areas/CommMng/DAL/PubSysDAL.cs | 7 +- DSWeb/Areas/CommMng/DAL/PublicInterfaceDAL.cs | 145 ++++++++++++++++++ DSWeb/DSWeb.csproj | 1 + .../PublishProfiles/配置文件1.pubxml | 17 -- DSWeb/Web.config | 4 +- 9 files changed, 194 insertions(+), 116 deletions(-) create mode 100644 DSWeb/Areas/CommMng/DAL/PublicInterfaceDAL.cs delete mode 100644 DSWeb/Properties/PublishProfiles/配置文件1.pubxml diff --git a/.gitignore b/.gitignore index 1c9a181..1a672b1 100644 --- a/.gitignore +++ b/.gitignore @@ -240,3 +240,5 @@ ModelManifest.xml # FAKE - F# Make .fake/ +/.vs.rar +/DSWeb/Properties/PublishProfiles/配置文件1.pubxml diff --git a/DSWeb.Common/DB/DS6Comm.cs b/DSWeb.Common/DB/DS6Comm.cs index 1803d19..ec96648 100644 --- a/DSWeb.Common/DB/DS6Comm.cs +++ b/DSWeb.Common/DB/DS6Comm.cs @@ -25,6 +25,7 @@ namespace DSWeb.Common.DB { [Key] public string 客户简称 { get; set; } + public string 客户简称2 { get; set; } public string 客户状态 { get; set; } public string 客户价值 { get; set; } public string 客户性质 { get; set; } @@ -121,7 +122,9 @@ namespace DSWeb.Common.DB public string 企业代码 { get; set; } public string 国家代码 { get; set; } public string VGM代码 { get; set; } - public string 放单状态 { get; set; } + + //和川的客户信息库无此字段 + //public string 放单状态 { get; set; } public string 扣单状态 { get; set; } public string 大简云代码 { get; set; } public string 客商编码 { get; set; } @@ -130,7 +133,10 @@ namespace DSWeb.Common.DB } - public class csCust + public class csCustHead { + public List csCust { get; set; } + } + public class csCustInfo { /// /// 来源业务系统ID @@ -364,18 +370,19 @@ namespace DSWeb.Common.DB /// public string custOfficeCode { get; set; } - public csCustOfficeInfo CustOfficeInfo { get; set; } - public csCustInvoice CustInvoice { get; set; } - public List CustType { get; set; } + public List csCustOfficeInfo { get; set; } + public List csCustInvoices { get; set; } + public List csCustTypes { get; set; } public List CustContact { get; set; } - public List CustSales { get; set; } - public List CustAccount { get; set; } + public List csCustSaless { get; set; } + public List csCustAccounts { get; set; } public t_crm_client_md GetCrmClient() { var result = new t_crm_client_md(); result.bizCsCustId = bizCsCustId; result.客商编码 = custCode; - result.客户简称 = custAlias; + result.客户简称 = custAlias == null?"": custAlias.Length>10? custAlias.Substring(0,10): custAlias; + result.客户简称2 = custAlias; result.英文全称 = custNameEn; result.客户全称 = custNameCn; result.国家代码 = countryCode; @@ -399,9 +406,9 @@ namespace DSWeb.Common.DB result.录入日期 = createTime == null ? DateTime.Now : Convert.ToDateTime(createTime); result.备注 = remark; - result.代码= CustOfficeInfo.memoryCode==null?"": (CustOfficeInfo.memoryCode.Length>10 - ?CustOfficeInfo.memoryCode.Substring(0,10) - :CustOfficeInfo.memoryCode); + result.代码= csCustOfficeInfo==null?"": (csCustOfficeInfo[0].memoryCode.Length>10 + ? csCustOfficeInfo[0].memoryCode.Substring(0,10) + : csCustOfficeInfo[0].memoryCode); return result; } diff --git a/DSWeb.Common/DB/DS6DataContext.cs b/DSWeb.Common/DB/DS6DataContext.cs index 38aa8b2..3f3ba20 100644 --- a/DSWeb.Common/DB/DS6DataContext.cs +++ b/DSWeb.Common/DB/DS6DataContext.cs @@ -21,8 +21,8 @@ namespace DSWeb.Common.DB } public DbSet t_PublicInterface_Log { get; set; } - - + public DbSet t_crm_client { get; set; } + } diff --git a/DSWeb/Areas/CommMng/Controllers/PublicInterfaceController.cs b/DSWeb/Areas/CommMng/Controllers/PublicInterfaceController.cs index bce1f45..2bdd508 100644 --- a/DSWeb/Areas/CommMng/Controllers/PublicInterfaceController.cs +++ b/DSWeb/Areas/CommMng/Controllers/PublicInterfaceController.cs @@ -1,5 +1,7 @@ using Aspose.Words.Saving; using DSWeb.Areas.CommMng.DAL; +using DSWeb.Areas.CommMng.PublicInterfaceDAL; +using DSWeb.Areas.MvcShipping.Models.Message.VGM; using DSWeb.Common.DB; using DSWeb.MvcShipping.Helper; using HcUtility.Comm; @@ -8,28 +10,37 @@ using System.Collections.Generic; using System.Data.Entity.Core.Metadata.Edm; using System.Data.Entity.Migrations; using System.Diagnostics.Contracts; +using System.IO; using System.Linq; using System.Reflection; +using System.Text; using System.Web; using System.Web.Mvc; namespace DSWeb.Areas.CommMng.Controllers { - public class PublicInterfaceController + [JsonRequestBehavior] + public class PublicInterfaceController : Controller { - [HttpPost] - public InterfaceResult PostInterface(InterfaceParam param) { - try { + //[HttpPost] + public InterfaceResult PostInterface() { + + var sr = new StreamReader(Request.InputStream, Encoding.UTF8); + var strJson = sr.ReadToEnd(); + var param = JsonConvert.Deserialize(strJson); + try + { param.Save(); - Assembly assembly = Assembly.Load("DSWeb.Areas.CommMng.Controllers"); - var type = assembly.GetType("DSWeb.Areas.CommMng.Controllers.InterfaceBase." + param.PORTNAME); + Assembly assembly = Assembly.Load("DSWeb"); + var classname = "DSWeb.Areas.CommMng.PublicInterfaceDAL." + param.header.serviceCode; + var type = assembly.GetType(classname); Object obj = type.Assembly.CreateInstance(type.ToString()); var doset = type.GetMethod("DoSet"); - var _param = new object[]{ param}; + var _param = new object[]{ param.body }; InterfaceResult result = (InterfaceResult)doset.Invoke(obj,BindingFlags.Instance|BindingFlags.NonPublic,null, _param, null); return result; } catch (Exception e) { @@ -40,7 +51,7 @@ namespace DSWeb.Areas.CommMng.Controllers if (e.InnerException != null && e.InnerException.Message != null) { msg += "//InnerException.Message:" + e.InnerException.Message; } - var _rs= BasicDataRefDAL.SaveLog(msg, "", param.PORTNAME, "公开接口"); + var _rs= BasicDataRefDAL.SaveLog(msg, "", param.header.serviceCode, "公开接口"); var _rr = JsonConvert.Deserialize(_rs.Content); _r.errMsg = "未知错误,请联系相关人员,错误日志号【" + _rr.Data.ToString() + "】"; return _r; @@ -48,78 +59,4 @@ namespace DSWeb.Areas.CommMng.Controllers } } - public class InterfaceResult { - public string errCode { get; set; } - public string errMsg { get; set; } - - public InterfaceResult() { } - - public InterfaceResult(DBResult dbresult) { - if (dbresult.Success) - { - errCode = "0"; - } - else - { - errCode = "1"; - } - - errMsg = dbresult.Message + ";Data:" + JsonConvert.Serialize(dbresult.Data); - } - } - - public class InterfaceParam { - public string PORTNAME { get; set; } - public string GID { get; set; } - - public string Param { get; set; } - - public t_PublicInterface_Log_md getsaverec() { - var result = new t_PublicInterface_Log_md(); - result.GID= GID; - result.Param= Param; - result.PORTNAME = PORTNAME; - return result; - } - - public void Save() { - var saverec = getsaverec(); - if (string.IsNullOrWhiteSpace( saverec.Param) && string.IsNullOrWhiteSpace(saverec.PORTNAME)) - { - var cdc = new CommonDataContext(); - cdc.t_PublicInterface_Log.Add(saverec); - } - } - } - - public class InterfaceBase - { - public InterfaceBase() { } - - public InterfaceResult DoSet(InterfaceParam param) { - return new InterfaceResult(); - } - - //public static void SaveParam(InterfaceParam param) { - // param.Save(); - //} - - public class csCustInfo: InterfaceBase - { - public InterfaceResult DoSet(InterfaceParam param) - { - - var result = new DBResult(); - - //解析param.Param - var _str = param.Param; - - //向数据库保存 - - return new InterfaceResult(result); - } - - - } - } } \ No newline at end of file diff --git a/DSWeb/Areas/CommMng/DAL/PubSysDAL.cs b/DSWeb/Areas/CommMng/DAL/PubSysDAL.cs index f766c3e..a47e8d7 100644 --- a/DSWeb/Areas/CommMng/DAL/PubSysDAL.cs +++ b/DSWeb/Areas/CommMng/DAL/PubSysDAL.cs @@ -2,16 +2,20 @@ using System.Collections.Generic; using System.Data; using System.Data.Common; +using System.Data.Entity.Migrations; using System.Diagnostics; using System.Linq; +using System.ServiceModel.Configuration; using System.Text; using System.Web; using DSWeb.Areas.CommMng.Models; +using DSWeb.Common.DB; using DSWeb.EntityDA; using DSWeb.MvcShipping.Comm.Cookie; - +using DSWeb.MvcShipping.Helper; using HcUtility.Comm; using Microsoft.Practices.EnterpriseLibrary.Data; +using Newtonsoft.Json.Linq; namespace DSWeb.Areas.CommMng.DAL { @@ -222,5 +226,4 @@ namespace DSWeb.Areas.CommMng.DAL #endregion } - } \ No newline at end of file diff --git a/DSWeb/Areas/CommMng/DAL/PublicInterfaceDAL.cs b/DSWeb/Areas/CommMng/DAL/PublicInterfaceDAL.cs new file mode 100644 index 0000000..90aa723 --- /dev/null +++ b/DSWeb/Areas/CommMng/DAL/PublicInterfaceDAL.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using System.Data.Entity.Migrations; +using System.Diagnostics; +using System.Linq; +using System.ServiceModel.Configuration; +using System.Text; +using System.Web; +using DSWeb.Areas.CommMng.Models; +using DSWeb.Common.DB; +using DSWeb.EntityDA; +using DSWeb.MvcShipping.Comm.Cookie; +using DSWeb.MvcShipping.Helper; +using HcUtility.Comm; +using Microsoft.Practices.EnterpriseLibrary.Data; +using Newtonsoft.Json.Linq; + +namespace DSWeb.Areas.CommMng.PublicInterfaceDAL +{ + public class InterfaceResult + { + public string errCode { get; set; } + public string errMsg { get; set; } + + public InterfaceResult() { } + + public InterfaceResult(DBResult dbresult) + { + if (dbresult.Success) + { + errCode = "0"; + } + else + { + errCode = "1"; + } + + errMsg = dbresult.Message + ";Data:" + JsonConvert.Serialize(dbresult.Data); + } + } + + public class InterfaceParam + { + public Interface_Header header { get; set; } + + public object body { get; set; } + + public t_PublicInterface_Log_md getsaverec() + { + var result = new t_PublicInterface_Log_md(); + result.GID = Guid.NewGuid().ToString(); + result.Param = body.ToString(); + result.PORTNAME = header.serviceCode; + return result; + } + + public void Save() + { + var saverec = getsaverec(); + if (string.IsNullOrWhiteSpace(saverec.Param) && string.IsNullOrWhiteSpace(saverec.PORTNAME)) + { + var cdc = new DS6DataContext(); + cdc.t_PublicInterface_Log.Add(saverec); + } + } + } + public class Interface_Header + { + public string serviceCode { get; set; } + + } + + + public class InterfaceBase + { + public InterfaceBase() { } + + public virtual InterfaceResult DoSet(JObject paramObject) + { + return new InterfaceResult(); + } + + //public static void SaveParam(InterfaceParam param) { + // param.Save(); + //} + + + } + + public class KF_CUST_UPDATE : InterfaceBase + { + public override InterfaceResult DoSet(JObject paramObject) + { + var result = new DBResult(); + try { + var jsonstr= paramObject.ToString(); + csCustHead custhead = JsonConvert.Deserialize(jsonstr); + var custlist = custhead.csCust; + + var ds6 = new DS6DataContext(); + //解析param.Param + foreach (var cust in custlist) + { + var ds6cust = cust.GetCrmClient(); + + var currInfoclient = ds6.t_crm_client.Where(x => x.客商编码 == cust.custCode).ToList(); + + if (currInfoclient == null || currInfoclient.Count == 0) + ds6.t_crm_client.Where(x => x.客户全称 == cust.custNameCn).ToList(); + + if (currInfoclient == null || currInfoclient.Count == 0) + { + ds6.t_crm_client.Add(ds6cust); + } + else + { + var oldclient = currInfoclient[0]; + + //部分字段不更新 + ds6cust.客户简称 = oldclient.客户简称; + + ds6.t_crm_client.AddOrUpdate(ds6cust); + } + } + + if (custlist.Count > 0) + { + ds6.SaveChanges(); + } + }catch(Exception ex) + { + result.Success= false; + result.Message=ex.Message; + } + //向数据库保存 + result.Success = true; + result.Message = "保存成功"; + return new InterfaceResult(result); + } + + + } +} \ No newline at end of file diff --git a/DSWeb/DSWeb.csproj b/DSWeb/DSWeb.csproj index 96b0981..3c987fe 100644 --- a/DSWeb/DSWeb.csproj +++ b/DSWeb/DSWeb.csproj @@ -291,6 +291,7 @@ + diff --git a/DSWeb/Properties/PublishProfiles/配置文件1.pubxml b/DSWeb/Properties/PublishProfiles/配置文件1.pubxml deleted file mode 100644 index 09dbe6b..0000000 --- a/DSWeb/Properties/PublishProfiles/配置文件1.pubxml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - FileSystem - Release - Any CPU - - True - False - D:\DS7JIEKOU - True - - \ No newline at end of file diff --git a/DSWeb/Web.config b/DSWeb/Web.config index bfd6cc9..e8e76b9 100644 --- a/DSWeb/Web.config +++ b/DSWeb/Web.config @@ -67,11 +67,11 @@ - + - +