From b0be43e335924bd8cc5025143656dbf479f7cbc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=95=8F=E5=81=A5=20=E9=82=B1?= Date: Wed, 21 May 2025 21:55:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=A5U8=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E4=BA=BA=E4=B8=BA=E5=9F=BA=E7=A1=80=E7=9A=84=E5=88=B6=E5=8D=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD(ST)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ServerUpdate/App.config | 6 + ServerUpdate/Entity/AppFile.cs | 12 + ServerUpdate/Form1.Designer.cs | 40 ++++ ServerUpdate/Form1.cs | 20 ++ ServerUpdate/Program.cs | 22 ++ ServerUpdate/Properties/AssemblyInfo.cs | 33 +++ ServerUpdate/Properties/Resources.Designer.cs | 71 ++++++ ServerUpdate/Properties/Resources.resx | 117 +++++++++ ServerUpdate/Properties/Settings.Designer.cs | 30 +++ ServerUpdate/Properties/Settings.settings | 7 + ServerUpdate/ServerUpdate.csproj | 82 +++++++ .../U8M/BaseLogin.cs | 140 +++++++++-- ...FIDA.U8.Framework.Api.ControlObject.csproj | 1 + UFIDA.U8.Framework.Api.sln | 6 + UFIDA.U8.Framework.Api/App_Data/API_Meta.db | Bin 77824 -> 77824 bytes UFIDA.U8.Framework.Api/App_Data/U8API.xml | 83 ++++++- .../App_Start/SwaggerConfig.cs | 4 +- .../Controllers/U8/DPController.cs | 99 +++++++- .../Controllers/U8/STController.cs | 226 +++++++++++++++++- UFIDA.U8.Framework.Api/Entity/LoginInput.cs | 55 +++++ .../{Models => Entity}/SFCInput.cs | 0 .../{Models => Entity}/STInput.cs | 0 .../U8AccountConfigInput.cs | 0 .../UFIDA.U8.Framework.Api.csproj | 7 +- UFIDA.U8.Framework.Api/Unit/CommUnit.cs | 18 +- 25 files changed, 1038 insertions(+), 41 deletions(-) create mode 100644 ServerUpdate/App.config create mode 100644 ServerUpdate/Entity/AppFile.cs create mode 100644 ServerUpdate/Form1.Designer.cs create mode 100644 ServerUpdate/Form1.cs create mode 100644 ServerUpdate/Program.cs create mode 100644 ServerUpdate/Properties/AssemblyInfo.cs create mode 100644 ServerUpdate/Properties/Resources.Designer.cs create mode 100644 ServerUpdate/Properties/Resources.resx create mode 100644 ServerUpdate/Properties/Settings.Designer.cs create mode 100644 ServerUpdate/Properties/Settings.settings create mode 100644 ServerUpdate/ServerUpdate.csproj create mode 100644 UFIDA.U8.Framework.Api/Entity/LoginInput.cs rename UFIDA.U8.Framework.Api/{Models => Entity}/SFCInput.cs (100%) rename UFIDA.U8.Framework.Api/{Models => Entity}/STInput.cs (100%) rename UFIDA.U8.Framework.Api/{Models => Entity}/U8AccountConfigInput.cs (100%) diff --git a/ServerUpdate/App.config b/ServerUpdate/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/ServerUpdate/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ServerUpdate/Entity/AppFile.cs b/ServerUpdate/Entity/AppFile.cs new file mode 100644 index 0000000..fe729a0 --- /dev/null +++ b/ServerUpdate/Entity/AppFile.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServerUpdate.Entity +{ + internal class AppFile + { + } +} diff --git a/ServerUpdate/Form1.Designer.cs b/ServerUpdate/Form1.Designer.cs new file mode 100644 index 0000000..af6d68f --- /dev/null +++ b/ServerUpdate/Form1.Designer.cs @@ -0,0 +1,40 @@ +namespace ServerUpdate +{ + partial class Form1 + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/ServerUpdate/Form1.cs b/ServerUpdate/Form1.cs new file mode 100644 index 0000000..11c2759 --- /dev/null +++ b/ServerUpdate/Form1.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ServerUpdate +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} diff --git a/ServerUpdate/Program.cs b/ServerUpdate/Program.cs new file mode 100644 index 0000000..2cdb7ed --- /dev/null +++ b/ServerUpdate/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ServerUpdate +{ + internal static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/ServerUpdate/Properties/AssemblyInfo.cs b/ServerUpdate/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1dbd378 --- /dev/null +++ b/ServerUpdate/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("ServerUpdate")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ServerUpdate")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("d78f0d4e-86ae-4fe8-a212-e7b6ef75c514")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ServerUpdate/Properties/Resources.Designer.cs b/ServerUpdate/Properties/Resources.Designer.cs new file mode 100644 index 0000000..370bad3 --- /dev/null +++ b/ServerUpdate/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace ServerUpdate.Properties +{ + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ServerUpdate.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/ServerUpdate/Properties/Resources.resx b/ServerUpdate/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/ServerUpdate/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ServerUpdate/Properties/Settings.Designer.cs b/ServerUpdate/Properties/Settings.Designer.cs new file mode 100644 index 0000000..254bb8f --- /dev/null +++ b/ServerUpdate/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ServerUpdate.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/ServerUpdate/Properties/Settings.settings b/ServerUpdate/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/ServerUpdate/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ServerUpdate/ServerUpdate.csproj b/ServerUpdate/ServerUpdate.csproj new file mode 100644 index 0000000..20e7c0f --- /dev/null +++ b/ServerUpdate/ServerUpdate.csproj @@ -0,0 +1,82 @@ + + + + + Debug + AnyCPU + {D78F0D4E-86AE-4FE8-A212-E7B6EF75C514} + WinExe + ServerUpdate + ServerUpdate + v4.8 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs b/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs index 73e1ee6..32b9efd 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs @@ -1,4 +1,5 @@ using System; +using System.Web.UI.WebControls; using ADODB; using log4net; using UFIDA.U8.Framework.Api.ControlObject.Entity; @@ -266,23 +267,128 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M } } + public void Init(string userToken, bool bMon = true, int traceTimes = 0) + { + if (traceTimes > 5) + throw new Exception("U8登录异常"); + + try + { + //if (!string.IsNullOrWhiteSpace(ThreadContext.ServerToken)) + //{ + // ThreadContext.ServerToken = null; + //} + + //if (!string.IsNullOrWhiteSpace(ThreadContext.U8LoginInfo!=null)) + //{ + // ThreadContext.U8LoginInfo = null; + //} + + if (string.IsNullOrWhiteSpace(userToken)) throw new ArgumentNullException(nameof(userToken)); + + if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken)) + { + Cryptography.m_userToken = ""; + } + + if (bMon) + { + +#if DEBUG + _vbLogin = new VBLogin(); + _vbLogin.ClearError(); + logInfo.Debug($"VB--开始进行U8登录:{userToken}"); + if (!_vbLogin.ConstructLogin(userToken)) + { + throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}"); + } + _netLogin = new NetLogin(); + _productContext = _netLogin.Login("DP", _vbLogin.userToken); + if (_productContext == null) + { + logInfo.Debug($"Net--U8上下文构建失败---{_netLogin.ErrDescript}"); + + logInfo.Debug($"Net--开始进行上下文构建:{userToken}"); + _productContext = _netLogin.Login("DP", _vbLogin.userToken); + //throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}"); + } + logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}"); + ClientUserContext.Instance.RefreshContext(); + + logInfo.Debug("Net--完成生产制造登录进程"); + +#else + _netLogin = new NetLogin(); + + logInfo.Debug($"Net--开始进行U8登录:{paramter.cSrv}--{paramter.pUserId}--{paramter.pAccId}"); + + if (!_netLogin.login(paramter.pSubId, paramter.pUserId, paramter.pPassword, paramter.cSrv, paramter.pDate, paramter.pAccId, paramter.cSerial) && string.IsNullOrWhiteSpace(_netLogin.userToken)) + { + throw new Exception($"Net--U8登录失败---{_netLogin.ErrDescript}"); + } + + logInfo.Debug($"Net--开始进行上下文构建:{_netLogin.userToken}"); + + _productContext = _netLogin.SubLogin("DP"); + + if (_productContext == null) + { + throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}"); + } + + + logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}"); + + ClientUserContext.Instance.RefreshContext(); + + logInfo.Debug("Net--完成生产制造登录进程"); + + return; + +#endif + } + + _vbLogin = new VBLogin(); + + _vbLogin.ClearError(); + logInfo.Debug($"VB--开始进行U8登录:{userToken}"); + if (!_vbLogin.ConstructLogin(userToken)) + { + throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}"); + } + logInfo.Debug($"VB--开始创建连接对象:{_vbLogin.userToken}"); + Connection = new Connection(); + Connection.Open(_vbLogin.UfDbName); + logInfo.Debug("VB--完成登录进程"); + return; + } + catch (Exception ex) + { + logInfo.Error($"重试次数:{traceTimes},错误信息:{ex.Message}", ex); + + if (ex.Message == "VB--U8登录失败---登录使用时间超过系统预置时间,请重新登录!") + { + throw new Exception("登录使用时间超过系统预置时间,请重新登录!"); + } + + Init(userToken, bMon, traceTimes + 1); + } + } + public void ShutDown() - { - U8LoginInfoPool.Clear(); - - ThreadContext.ServerToken = null; - - _vbLogin?.ShutDown(); - _productContext=null; - _netLogin?.SubLogout("DP"); - _netLogin?.ShutDown(); - _vbLogin = null; - _netLogin = null; + { + U8LoginInfoPool.Clear(); + ThreadContext.ServerToken = null; + _vbLogin?.ShutDown(); + _productContext=null; + _netLogin?.SubLogout("DP"); + _netLogin?.ShutDown(); + _vbLogin = null; + _netLogin = null; + } + public bool CheckAccId(string cAccId) + { + return _vbLogin.get_cAcc_Id() == cAccId; + } } - - public bool CheckAccId(string cAccId) - { - return _vbLogin.get_cAcc_Id() == cAccId; - } - } } diff --git a/UFIDA.U8.Framework.Api.ControlObject/UFIDA.U8.Framework.Api.ControlObject.csproj b/UFIDA.U8.Framework.Api.ControlObject/UFIDA.U8.Framework.Api.ControlObject.csproj index 0121aee..602aaff 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/UFIDA.U8.Framework.Api.ControlObject.csproj +++ b/UFIDA.U8.Framework.Api.ControlObject/UFIDA.U8.Framework.Api.ControlObject.csproj @@ -22,6 +22,7 @@ prompt 4 x86 + bin\Debug\UFIDA.U8.Framework.Api.ControlObject.xml pdbonly diff --git a/UFIDA.U8.Framework.Api.sln b/UFIDA.U8.Framework.Api.sln index bbf26f4..0a2db2c 100644 --- a/UFIDA.U8.Framework.Api.sln +++ b/UFIDA.U8.Framework.Api.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoucherPlugTest", "VoucherP EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebUpdate", "WebUpdate\WebUpdate.csproj", "{7861F8D1-F5A9-4AE5-9E60-1772D2B4A074}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerUpdate", "ServerUpdate\ServerUpdate.csproj", "{D78F0D4E-86AE-4FE8-A212-E7B6EF75C514}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +47,10 @@ Global {7861F8D1-F5A9-4AE5-9E60-1772D2B4A074}.Debug|Any CPU.Build.0 = Debug|Any CPU {7861F8D1-F5A9-4AE5-9E60-1772D2B4A074}.Release|Any CPU.ActiveCfg = Release|Any CPU {7861F8D1-F5A9-4AE5-9E60-1772D2B4A074}.Release|Any CPU.Build.0 = Release|Any CPU + {D78F0D4E-86AE-4FE8-A212-E7B6EF75C514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D78F0D4E-86AE-4FE8-A212-E7B6EF75C514}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D78F0D4E-86AE-4FE8-A212-E7B6EF75C514}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D78F0D4E-86AE-4FE8-A212-E7B6EF75C514}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/UFIDA.U8.Framework.Api/App_Data/API_Meta.db b/UFIDA.U8.Framework.Api/App_Data/API_Meta.db index 9fabfeab3d7ff5aa4e90d566ca063b8f4c47497f..7bbfe91e4bb6b1e4c36609df8493404e2c45db95 100644 GIT binary patch delta 33 pcmZp8z|!!5Wr8%L??f4AM&FGI+5L>1lh5=Uu$UU?nJ${J007HO3()`o delta 33 pcmZp8z|!!5Wr8%L_e2?IM(>RY+5L - + U8登录接口 - + 系统号 + 登录参数 + + + + + U8登录接口 + + 用户令牌 @@ -673,21 +681,21 @@ - 新增对接账套设置 + 注册对接系统 - 更新对接账套设置 + 更新对接系统 - 获取对接账套设置列表 + 获取对接系统列表 @@ -1015,6 +1023,19 @@ 是否远程 + + + 新增单据 + + 单据类型编码 + 报文 + 是否控制可用量 + 是否检查可用量 + 是否红字单据 + 传空字符串 + 是否远程 + + 审核单据(单号) @@ -1139,6 +1160,51 @@ 日志组件 + + + 登录参数 + + + + + 用户名 + + + + + 密码 + + + + + 登录日期,影响各接口制单的默认日期 + + + + + 用户令牌参数 + + + + + 用户令牌 + + + + + 登录输出参数 + + + + + 系统号 + + + + + 用户令牌 + + 缺少程序集全局处理事件 @@ -1224,6 +1290,13 @@ + + + 获取用户令牌 + + 用户令牌 + + 跨域加载 diff --git a/UFIDA.U8.Framework.Api/App_Start/SwaggerConfig.cs b/UFIDA.U8.Framework.Api/App_Start/SwaggerConfig.cs index ab10e93..bd52bff 100644 --- a/UFIDA.U8.Framework.Api/App_Start/SwaggerConfig.cs +++ b/UFIDA.U8.Framework.Api/App_Start/SwaggerConfig.cs @@ -39,8 +39,8 @@ namespace UFIDA.U8.Framework.Api c.CustomProvider((defaultProvider) => new SwaggerCacheProvider(defaultProvider, $@"{AppDomain.CurrentDomain.BaseDirectory}\App_Data\U8API.xml")); c.SingleApiVersion("v1", "U8API"); c.IncludeXmlComments($@"{AppDomain.CurrentDomain.BaseDirectory}\App_Data\U8API.xml"); - TokenRequiredHeaderParameter.HeaderKey = "account_token"; - TokenRequiredHeaderParameter.Description = "ÁîÅÆ"; + TokenRequiredHeaderParameter.HeaderKey = "userToken"; + TokenRequiredHeaderParameter.Description = "Óû§ÁîÅÆ"; c.OperationFilter(); // If you want the output Swagger docs to be indented properly, enable the "PrettyPrint" option. diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs index 31b77da..66366d3 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs @@ -1,10 +1,14 @@ using System; using System.Threading.Tasks; using System.Web.Http; +using System.Web.Http.Description; +using System.Web.UI.WebControls; using log4net; using UFIDA.U8.Framework.Api.ControlObject.Common; using UFIDA.U8.Framework.Api.ControlObject.Entity; +using UFIDA.U8.Framework.Api.ControlObject.Json; using UFIDA.U8.Framework.Api.ControlObject.U8M; +using UFIDA.U8.Framework.Api.Entity; using UFIDA.U8.Framework.Api.Models; using UFIDA.U8.Framework.Api.Unit; @@ -23,26 +27,53 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 /// /// U8登录接口 /// - /// + /// 系统号 + /// 登录参数 /// [HttpPost] [Route("api/U8/DP/Login")] - public async Task> Login( [FromBody] LoginParamter input) + public async Task> Login(string cAccId, [FromBody] LoginInput input) { try { - var logn = new BaseLogin(); + logInfo.Debug($"当前接口:api/U8/DP/Login,参数:{input.ToJson()}"); - logn.Init(input, false); + var db = CommUnit.GetDbClient(); - var userToken = logn.userToken; + var account = await db.Queryable().FirstAsync(a => a.Status == StatusEnum.Enable && a.cAccountNo == cAccId); + + if (account == null) + { + throw new Exception($"未能找到[{cAccId}]的配置信息"); + } + + var param = new LoginParamter() + { + cSrv = account.cSrv, + pAccId = account.cAcc_DataSource, + pDate = string.IsNullOrWhiteSpace(input.pDate) ? $"{DateTime.Today:yyyy-MM-dd}" : input.pDate, + pPassword = string.IsNullOrWhiteSpace(input.pPassword) ? "" : CommUnit.GetDecrypt(input.pPassword), + pYearId = string.IsNullOrWhiteSpace(input.pDate) ? $"{DateTime.Today.Year}" : $"{DateTime.Parse(input.pDate).Year}", + pSubId = "DP", + pUserId = input.pUserId + }; + + var login = new BaseLogin(); + + login.Init(param, false); + + var userToken = login.userToken; if (!string.IsNullOrWhiteSpace(userToken)) { - return new BaseResult() { bSuccess = true, message = "登录成功", result = userToken }; - } + var output = new LoginOutput + { + cAccId = cAccId, + userToken = CommUnit.GetEncrypt(userToken) + }; - await Task.Delay(1); + return new BaseResult() { bSuccess = true, message = "登录成功", result = CommUnit.GetEncrypt(output.ToJson()) }; + } throw new Exception("未知错误,请检查系统日志"); @@ -51,9 +82,52 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 { logInfo.Error(ex.Message, ex); + await Task.Delay(1); + + return new BaseResult { bSuccess = false, message = "登录失败", result = ex.Message }; + } + + } + + + /// + /// U8登录接口 + /// + /// 用户令牌 + /// + [HttpPost] + [Route("api/U8/DP/Login/Token")] + public async Task> Login([FromBody] UserTokenInput input) + { + try + { + + logInfo.Debug($"当前接口:api/U8/DP/Login/Token,参数:{input.ToJson()}"); + + var token = CommUnit.GetUserToken(input.userToken); + + var login = new BaseLogin(); + + login.Init(token, false); + + var userToken = login.userToken; + + if (!string.IsNullOrWhiteSpace(userToken)) + { + return new BaseResult() { bSuccess = true, message = "登录成功", result = "登录成功" }; + } + + throw new Exception("未知错误,请检查系统日志"); + + } + catch (Exception ex) + { + logInfo.Error(ex.Message, ex); + + await Task.Delay(1); + return new BaseResult { bSuccess = false, message = "登录失败", result = ex.Message }; } - } @@ -138,6 +212,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 /// [HttpGet] [Route("api/U8/DP/GetDecryptString")] + [ApiExplorerSettings(IgnoreApi = true)] public async Task> GetDecryptString(string input) { try @@ -155,7 +230,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } /// - /// 新增对接账套设置 + /// 注册对接系统 /// /// /// @@ -202,7 +277,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } /// - /// 更新对接账套设置 + /// 更新对接系统 /// /// /// @@ -248,7 +323,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } /// - /// 获取对接账套设置列表 + /// 获取对接系统列表 /// /// /// diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs index 915ac65..ae2007a 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs @@ -4,7 +4,9 @@ using SqlSugar; using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Threading.Tasks; +using System.Web; using System.Web.Http; using UFIDA.U8.Framework.Api.Common.Entity; using UFIDA.U8.Framework.Api.ControlObject.Common; @@ -12,6 +14,7 @@ using UFIDA.U8.Framework.Api.ControlObject.Entity; using UFIDA.U8.Framework.Api.ControlObject.Json; using UFIDA.U8.Framework.Api.ControlObject.ST; using UFIDA.U8.Framework.Api.ControlObject.U8M; +using UFIDA.U8.Framework.Api.Entity; using UFIDA.U8.Framework.Api.Models; using UFIDA.U8.Framework.Api.Unit; // ReSharper disable StringLiteralTypo @@ -46,7 +49,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 /// [HttpPost] [Route("api/U8/ST/{cCardNum}/Insert")] - public async Task> Insert(string cAccId, string cCardNum,[FromBody] Dictionary input, bool bCheck = true,bool bBeforCheckStock=true,bool bIsRedVouch=false,string sAddedState="",bool bReMote=false) + public async Task> Insert(string cAccId ,string cCardNum,[FromBody] Dictionary input, bool bCheck = true,bool bBeforCheckStock=true,bool bIsRedVouch=false,string sAddedState="",bool bReMote=false) { try { @@ -254,6 +257,227 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } + /// + /// 新增单据 + /// + /// 单据类型编码 + /// 报文 + /// 是否控制可用量 + /// 是否检查可用量 + /// 是否红字单据 + /// 传空字符串 + /// 是否远程 + /// + [HttpPost] + [Route("api/U8/ST/{cCardNum}/Insert/Token")] + public async Task> Insert2(string cCardNum, [FromBody] Dictionary input, bool bCheck = true, bool bBeforCheckStock = true, bool bIsRedVouch = false, string sAddedState = "", bool bReMote = false) + { + try + { + var userToken = Request.Headers.GetValues("userToken").First(); + + logInfo.Debug($"当前接口:api/U8/ST/{cCardNum}/Insert/{userToken},参数:{input.ToJson()}"); + + var output = CommUnit.GetDecrypt(userToken).ToObject(); + + var token = CommUnit.GetDecrypt(output.userToken); + + var db = CommUnit.GetDbClient(); + + var workId = SnowFlakeSingle.Instance.NextId(); + + logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:新增,对接账套:{output.cAccId},数据:{input.ToJson()}"); + + //LoginParamter param; + + if (!_cache.TryGetValue($"U8_{userToken}_{output.cAccId}", out BaseLogin baseLogin)) + { + logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + + baseLogin = new BaseLogin(); + + baseLogin.Init(token, false, 5); + + _cache.Clear(); + + _cache.Set($"U8_{userToken}_{output.cAccId}", baseLogin); + } + //else + //{ + // param = await CommUnit.GetLoginParamter(cAccId); + //} + + logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + + var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); + + var defs = await db.Queryable().Where(s => s.CardNumber == cCardNum && s.cPosition == "H" && s.bEnable == true).ToListAsync(); //查询表头字段配置,供后续设置字段值 + + var dateKey = ""; + var exchKey = ""; + if (defs.Any(a => a.bDate == true && a.cPosition == "H")) + dateKey = defs.Where(a => a.bDate == true && a.cPosition == "H").Select(a => a.FieldName).First(); + + if (defs.Any(a => a.bPrice == true && a.cPosition == "H")) + exchKey = defs.Where(a => a.bPrice == true && a.cPosition == "H").Select(a => a.FieldName).First(); + + var dDate = DateTime.Today; + if (!string.IsNullOrWhiteSpace(dateKey)) + { + if (!DateTime.TryParse($"{input[dateKey]}", out dDate)) + { + dDate = DateTime.Today; + } + } + + Exch exch; + + if (!string.IsNullOrWhiteSpace(exchKey) && input.TryGetValue(exchKey, out var value)) + { + exch = CommonHelper.GetExch(dDate, output.cAccId, $"{value}", baseLogin.Connection); + } + else + { + exch = null; + } + + + var newNumber = ""; + var bGetCode = false; + var codeKey = ""; + + if (defs.Any(a => a.bDefault == true && a.cPosition == "H" && a.DefaultValue == "单号" && a.bEnable == true)) + { + bGetCode = true; + codeKey = defs + .Where(a => a.bDefault == true && a.cPosition == "H" && a.DefaultValue == "单号" && + a.bEnable == true).Select(a => a.FieldName).First(); + + logInfo.Debug($"作业Id:{workId}-----配置获取单号"); + } + else + { + logInfo.Debug($"作业Id:{workId}-----没有单号需要自动指定"); + } + + #region 调整日期,去掉时间部分 + + if (input.ContainsKey("ddate")) + { + logInfo.Debug($"作业Id:{workId}-----调整日期,去掉时间部分"); + input["ddate"] = $"{Convert.ToDateTime(input["ddate"]):yyyy-MM-dd}"; + } + + if (input.ContainsKey("dtvdate")) + { + logInfo.Debug($"作业Id:{workId}-----调整日期,去掉时间部分"); + input["dtvdate"] = $"{Convert.ToDateTime(input["dtvdate"]):yyyy-MM-dd}"; + } + + #endregion + logInfo.Debug($"作业Id:{workId}-----设置表头数据"); + input.SetDictionaryData(defs, baseLogin.Connection, newNumber, 1, exch); + + logInfo.Debug($"作业Id:{workId}-----读取表体数据"); + var bodyData = input[voucherInfo.BodyName].ToJson().ToList>(); //读取表体的数据 + + if (bodyData == null || bodyData.Count <= 0) + throw new Exception("无表体数据!"); + + logInfo.Debug($"作业Id:{workId}-----获取表体字段配置"); + var defsBody = await db.Queryable().Where(s => s.CardNumber == cCardNum && s.cPosition == "B" && s.bEnable == true).ToListAsync(); //获取表体的字段配置 + + var rowNo = 1; + + foreach (var body in bodyData) + { + logInfo.Debug($"作业Id:{workId}-----设置第{rowNo}行单据数据"); + body.SetDictionaryData(defsBody, baseLogin.Connection, newNumber, rowNo, exch); + + rowNo++; + + // 根据存货档案是否批次管理调整批次号 + if (body.ContainsKey("binvbatch") && body.ContainsKey("cbatch")) + { + logInfo.Debug($"作业Id:{workId}-----第{rowNo}行根据存货档案是否批次管理调整批次号"); + if (body["binvbatch"] == null || body["binvbatch"] == DBNull.Value || !body["binvbatch"].ToBoolean()) + { + body["cbatch"] = ""; + } + } + + // 根据存货档案是否批次管理调整批次号(调拨单) + if (body.ContainsKey("binvbatch") && body.ContainsKey("ctvbatch")) + { + logInfo.Debug($"作业Id:{workId}-----第{rowNo}行根据存货档案是否批次管理调整批次号(调拨单)"); + if (body["binvbatch"] == null || body["binvbatch"] == DBNull.Value || !body["binvbatch"].ToBoolean()) + { + body["ctvbatch"] = ""; + } + } + + // 根据存货档案是否保质期管理调整生产日期和失效日期 + if (body.ContainsKey("binvquality") && body.ContainsKey("dmadedate")) + { + logInfo.Debug($"作业Id:{workId}-----第{rowNo}行根据存货档案是否保质期管理调整生产日期和失效日期"); + + if (body["binvquality"] == null || body["binvquality"] == DBNull.Value || !body["binvquality"].ToBoolean()) + { + if (cCardNum == "0304") + { + body["dmadedate"] = ""; + } + else + { + body["dmadedate"] = ""; + } + } + else + { + if (body.ContainsKey("cmassunit") && body.ContainsKey("imassdate")) + { + switch ($"{body["cmassunit"]}") + { + case "1" when cCardNum != "0304": + body["dvdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddYears(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}"; + break; + case "1" when cCardNum == "0304": + body["ddisdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddYears(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}"; + break; + case "2" when cCardNum != "0304": + body["dvdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddMonths(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}"; + break; + case "2" when cCardNum == "0304": + body["ddisdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddMonths(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}"; + break; + case "3" when cCardNum != "0304": + body["dvdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddDays(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}"; + break; + case "3" when cCardNum == "0304": + body["ddisdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddDays(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}"; + break; + } + } + } + } + } + + input[voucherInfo.BodyName] = bodyData; + + var co = new USERPCO(); + + var res = await co.Insert(baseLogin, input, cCardNum, voucherInfo.VoucherType, bGetCode, codeKey, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote, voucherInfo.bVerify, voucherInfo.bPrintDom); + + return res; + } + catch (Exception ex) + { + logInfo.Error(ex.Message, ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + ///// ///// 修改单据 ///// diff --git a/UFIDA.U8.Framework.Api/Entity/LoginInput.cs b/UFIDA.U8.Framework.Api/Entity/LoginInput.cs new file mode 100644 index 0000000..76b68ce --- /dev/null +++ b/UFIDA.U8.Framework.Api/Entity/LoginInput.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace UFIDA.U8.Framework.Api.Entity +{ + /// + /// 登录参数 + /// + public class LoginInput + { + /// + /// 用户名 + /// + public string pUserId { get; set; } + + /// + /// 密码 + /// + public string pPassword { get; set; } = ""; + + /// + /// 登录日期,影响各接口制单的默认日期 + /// + public string pDate { get; set; } = $"{DateTime.Today:yyyy-MM-dd}"; + } + + /// + /// 用户令牌参数 + /// + public class UserTokenInput + { + /// + /// 用户令牌 + /// + public string userToken { get; set; } + } + + /// + /// 登录输出参数 + /// + public class LoginOutput + { + /// + /// 系统号 + /// + public string cAccId { get; set; } + + /// + /// 用户令牌 + /// + public string userToken { get; set; } + } +} \ No newline at end of file diff --git a/UFIDA.U8.Framework.Api/Models/SFCInput.cs b/UFIDA.U8.Framework.Api/Entity/SFCInput.cs similarity index 100% rename from UFIDA.U8.Framework.Api/Models/SFCInput.cs rename to UFIDA.U8.Framework.Api/Entity/SFCInput.cs diff --git a/UFIDA.U8.Framework.Api/Models/STInput.cs b/UFIDA.U8.Framework.Api/Entity/STInput.cs similarity index 100% rename from UFIDA.U8.Framework.Api/Models/STInput.cs rename to UFIDA.U8.Framework.Api/Entity/STInput.cs diff --git a/UFIDA.U8.Framework.Api/Models/U8AccountConfigInput.cs b/UFIDA.U8.Framework.Api/Entity/U8AccountConfigInput.cs similarity index 100% rename from UFIDA.U8.Framework.Api/Models/U8AccountConfigInput.cs rename to UFIDA.U8.Framework.Api/Entity/U8AccountConfigInput.cs diff --git a/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj b/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj index 9999079..57809dc 100644 --- a/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj +++ b/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj @@ -419,12 +419,13 @@ + Global.asax - - - + + + diff --git a/UFIDA.U8.Framework.Api/Unit/CommUnit.cs b/UFIDA.U8.Framework.Api/Unit/CommUnit.cs index 28a78d2..61cc084 100644 --- a/UFIDA.U8.Framework.Api/Unit/CommUnit.cs +++ b/UFIDA.U8.Framework.Api/Unit/CommUnit.cs @@ -5,10 +5,14 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using System.Web; +using System.Web.UI.WebControls; using Microsoft.Data.Sqlite; using SqlSugar; using UFIDA.U8.Framework.Api.Common.Unit.GM; using UFIDA.U8.Framework.Api.ControlObject.Entity; +using UFIDA.U8.Framework.Api.ControlObject.Json; +using UFIDA.U8.Framework.Api.Entity; +using UFIDA.U8.Framework.Api.Models; namespace UFIDA.U8.Framework.Api.Unit { @@ -126,9 +130,21 @@ namespace UFIDA.U8.Framework.Api.Unit return param; } - return null; } + /// + /// 获取用户令牌 + /// + /// 用户令牌 + /// + public static string GetUserToken(string userToken) + { + var output = CommUnit.GetDecrypt(userToken).ToObject(); + + var token = CommUnit.GetDecrypt(output.userToken); + + return token; + } } } \ No newline at end of file