From 4d48bbf980b2b9ceacc274dabc3976d64b6d1cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=95=8F=E5=81=A5=20=E9=82=B1?= Date: Thu, 9 Oct 2025 02:08:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=80=E5=94=AE=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=9F=A5=E8=AF=A2=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PU/clsVoucherCO_PU.cs | 195 ++++++++++++++ .../SA/ClsVoucherCO_SA.cs | 2 +- .../Workflow/ServiceProxy.cs | 121 ++++++++- UFIDA.U8.Framework.Api/App_Data/API_Meta.db | Bin 77824 -> 77824 bytes UFIDA.U8.Framework.Api/App_Data/U8API.xml | 81 +++++- .../Controllers/U8/PUController.cs | 222 +++++++++++++++- .../Controllers/U8/WorkflowController.cs | 246 +++++++++++++++++- 7 files changed, 848 insertions(+), 19 deletions(-) diff --git a/UFIDA.U8.Framework.Api.ControlObject/PU/clsVoucherCO_PU.cs b/UFIDA.U8.Framework.Api.ControlObject/PU/clsVoucherCO_PU.cs index 2b49c1b..0462ac1 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/PU/clsVoucherCO_PU.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/PU/clsVoucherCO_PU.cs @@ -925,5 +925,200 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU return res; } + + /// + /// 批量提交工作流(单号) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public async Task>> SubmintWf(BaseLogin baseLogin, string sCardNum, vouchertype enmVoucherType, List cCodes, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null) + { + _logInfo.Debug("开始输出登录信息"); + _logInfo.Debug(baseLogin._vbLogin.userToken); + + var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); + + var conn = baseLogin.Connection; + + var vouchers = CommonHelper.GetVouchers(conn, sCardNum); + + var resList = new List>(); + + foreach (var cCode in cCodes) + { + try + { + var strWhere = CommonHelper.GetPUVoucherWhereSqlByCode(vouchers, cCode); + + var curId = CommonHelper.GetVoucherId(conn, cCode, vouchers); + + var verifyResult = await SubmintWf(co, conn, enmVoucherType, cCode, curId, strWhere); + + resList.Add(verifyResult); + } + catch (Exception ex) + { + await Task.Delay(1); + _logInfo.Error(ex.Message, ex); + } + } + + return resList; + } + + /// + /// 批量提交工作流(ID) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public async Task>> SubmintWf(BaseLogin baseLogin, string sCardNum, vouchertype enmVoucherType, List vouchIds, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null) + { + var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); + + var conn = baseLogin.Connection; + + var vouchers = CommonHelper.GetVouchers(conn, sCardNum); + + var resList = new List>(); + + foreach (var vouchId in vouchIds) + { + var strWhere = CommonHelper.GetPUVoucherWhereSqlById(vouchers, vouchId); + + var cCode = CommonHelper.GetVoucherCode(conn, vouchId, vouchers); + + var verifyResult = await SubmintWf(co, conn, enmVoucherType, cCode, vouchId, strWhere); + + resList.Add(verifyResult); + } + + return resList; + } + + /// + /// 提交工作流(单号) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public async Task> SubmintWf(BaseLogin baseLogin, string sCardNum, vouchertype enmVoucherType, string cCode, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null) + { + var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); + + var conn = baseLogin.Connection; + + var vouchers = CommonHelper.GetVouchers(conn, sCardNum); + + var curId = CommonHelper.GetVoucherId(conn, cCode, vouchers); + + var strWhere = CommonHelper.GetPUVoucherWhereSqlByCode(vouchers, cCode); + + var verifyResult = await SubmintWf(co, conn, enmVoucherType, cCode, curId, strWhere); + + return verifyResult; + } + + /// + /// 提交工作流(ID) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public async Task> SubmintWf(BaseLogin baseLogin, string sCardNum, vouchertype enmVoucherType, long vouchId, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null) + { + var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); + + var conn = baseLogin.Connection; + + var vouchers = CommonHelper.GetVouchers(conn, sCardNum); + + var strWhere = CommonHelper.GetPUVoucherWhereSqlById(vouchers, vouchId); + + var cCode = CommonHelper.GetVoucherCode(conn, vouchId, vouchers); + + var verifyResult = await SubmintWf(co, conn, enmVoucherType, cCode, vouchId, strWhere); + + return verifyResult; + } + + /// + /// 提交工作流 + /// + /// + /// + /// + /// + /// + /// + /// + public async Task> SubmintWf(dynamic voucherCO, Connection conn, vouchertype sVouchType, string cCode, object vouchId, string strWhere) + { + IXMLDOMDocument2 domHead = new DOMDocument(); + IXMLDOMDocument2 domBody = new DOMDocument(); + IXMLDOMDocument2 domMsg = new DOMDocument(); + + _logInfo.Debug("开始获取单据数据..."); + voucherCO.GetVoucherData(ref domHead, ref domBody, strWhere); + + var res = new BaseResult + { + voucherCode = cCode, + voucherId = $"{vouchId}" + }; + + var errorMsg = ""; + + voucherCO.SubmintWf(domHead, ref errorMsg, vouchId); + + res.bSuccess = string.IsNullOrWhiteSpace(errorMsg); + + if (res.bSuccess) + { + res.message = "提交成功"; + res.result = res.voucherId; + + } + else + { + res.message = "提交失败"; + res.result = string.IsNullOrWhiteSpace(errorMsg) ? "未知错误" : errorMsg; + await Task.Delay(1); + } + + return res; + } } } diff --git a/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs b/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs index 01c7853..7b953ce 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs @@ -206,7 +206,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA IXMLDOMDocument2 domMsg = new DOMDocument(); _logInfo.Debug("开始获取单据数据..."); - voucherCo.GetVoucherData(ref domHead, ref domBody, vouchId, true, strWhere); + voucherCo.GetVoucherData(ref domHead, ref domBody, vouchId, true, ""); var res = new BaseResult { diff --git a/UFIDA.U8.Framework.Api.ControlObject/Workflow/ServiceProxy.cs b/UFIDA.U8.Framework.Api.ControlObject/Workflow/ServiceProxy.cs index 04bd47d..bdd698e 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/Workflow/ServiceProxy.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/Workflow/ServiceProxy.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using System.Web.UI.WebControls; using log4net; +using Newtonsoft.Json.Linq; using UFIDA.U8.Audit.ServiceProxy; using UFIDA.U8.Framework.Api.ControlObject.Common; using UFIDA.U8.Framework.Api.ControlObject.Entity; @@ -58,14 +59,26 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Workflow { var auditServiceProxy = new AuditServiceProxy(); - var isWfControled = false; + var isWfControled = IsFlowEnabled(login, bizObjectId, eventId); var errMsg = ""; - var res = auditServiceProxy.SubmitApplicationMessage(bizObjectId, eventId, voucherId, login._productContext.calledContext, ref isWfControled, ref errMsg); - - if (!res && !string.IsNullOrWhiteSpace(errMsg)) + if (isWfControled) { - throw new Exception(errMsg); + var context = new CalledContext() { subId = "PU", token = login.userToken }; + + var res = auditServiceProxy.SubmitApplicationMessage(bizObjectId, eventId, voucherId, context, + ref isWfControled, ref errMsg); + + if (!res && !string.IsNullOrWhiteSpace(errMsg)) + { + throw new Exception(errMsg); + } + + if (!res) + { + throw new Exception("审批流发生异常"); + } + } if (!isWfControled && !string.IsNullOrWhiteSpace(errMsg)) @@ -78,12 +91,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Workflow throw new Exception("当前单据无法进入工作流"); } - if (!res) - { - throw new Exception("审批流发生异常"); - } - - return new BaseResult { bSuccess = true, @@ -505,6 +512,98 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Workflow } } + /// + /// #提交审批流# + /// + /// + /// + /// + /// + /// + /// + public async Task> SubmitResubmitMessage(BaseLogin login, string cCardNum, string voucherCode, bool bUAP = false) + { + var voucherId = ""; + + try + { + var vouchers = CommonHelper.GetVouchers(login.Connection, cCardNum); + + voucherId = $"{CommonHelper.GetVoucherId(login.Connection, voucherCode, vouchers)}"; + + var bizObjectId = cCardNum; + + if (bUAP) + { + bizObjectId = $"UAPFORM.{bizObjectId}"; + } + + return await SubmitResubmitMessage(login, bizObjectId, voucherId, voucherCode); + } + catch (Exception ex) + { + _logInfo.Error($"审批流异常:{ex.Message}", ex); + + await Task.Delay(1); + + return new BaseResult + { + bSuccess = false, + message = "提交失败", + voucherCode = voucherCode, + voucherId = voucherId, + result = ex.Message + }; + } + } + + /// + /// #提交审批流# + /// + /// + /// + /// + /// + /// + /// + public async Task> SubmitResubmitMessage(BaseLogin login, string cCardNum, object voucherId, bool bUAP = false) + { + var voucherCode = ""; + + try + { + var vouchers = CommonHelper.GetVouchers(login.Connection, cCardNum); + + voucherCode = $"{CommonHelper.GetVoucherCode(login.Connection, voucherId, vouchers)}"; + + var bizObjectId = cCardNum; + + if (bUAP) + { + bizObjectId = $"UAPFORM.{bizObjectId}"; + } + + + return await SubmitResubmitMessage(login, bizObjectId, $"{voucherId}", voucherCode); + } + catch (Exception ex) + { + _logInfo.Error($"审批流异常:{ex.Message}", ex); + + await Task.Delay(1); + + return new BaseResult + { + bSuccess = false, + message = "提交失败", + voucherCode = voucherCode, + voucherId = $"{voucherId}", + result = ex.Message + }; + } + } + + /// /// #取得代办任务# /// diff --git a/UFIDA.U8.Framework.Api/App_Data/API_Meta.db b/UFIDA.U8.Framework.Api/App_Data/API_Meta.db index e3d12e7400f8fc38049fad30f9539f3d5ee6735e..76513c9c881312aa0650cc4c2ca3fcdbfd72964d 100644 GIT binary patch delta 67 zcmV-J0KETz-~@o+1dtm6S&wNUq1m5v%o(@-~$j2x|ata0UrVmy0L+h4iXR$ Z2>=ll4+sDN05~{eZ)ABfx6Cd9Gy%i560raP delta 45 zcmZp8z|!!5Wr8$g_(U0J#_){^@%D`Tn-AE#JYeSMJ2RbKfl+>A<1)VOXY?3N7y)kZ B4?q9_ diff --git a/UFIDA.U8.Framework.Api/App_Data/U8API.xml b/UFIDA.U8.Framework.Api/App_Data/U8API.xml index dd0c2e5..f819433 100644 --- a/UFIDA.U8.Framework.Api/App_Data/U8API.xml +++ b/UFIDA.U8.Framework.Api/App_Data/U8API.xml @@ -991,6 +991,48 @@ 为空 + + + 提交工作流(单号) + + 系统号 + 单据类型编码 + 单号 + 红蓝标识:True,蓝字 + 发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2) + 业务类型:普通采购,直运采购,受托代销 + CS 0,BS 1;一般CS + 为空 + + + + + 提交工作流(ID) + + 系统号 + 单据类型编码 + 单据ID + 红蓝标识:True,蓝字 + 发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2) + 业务类型:普通采购,直运采购,受托代销 + CS 0,BS 1;一般CS + 为空 + + + + + 提交工作流(批量) + + 系统号 + 单据类型编码 + 报文 + 红蓝标识:True,蓝字 + 发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2) + 业务类型:普通采购,直运采购,受托代销 + CS 0,BS 1;一般CS + 为空 + + 查询特定单据部分 @@ -1487,7 +1529,6 @@ 提交审批流(单号) - 系统注册号 单据类型编码 单据编号 审批事件 @@ -1516,6 +1557,44 @@ 是否UAP单据 + + + 退回提交人后重新提交(单号) + + 单据类型编码 + 单据ID + 系统注册号 + 是否UAP单据 + + + + + 退回提交人后重新提交(单号) + + 单据类型编码 + 单据编号 + 是否UAP单据 + + + + + 提交审批流(ID) + + 单据类型编码 + 单据ID + 系统注册号 + 是否UAP单据 + + + + + 提交审批流(ID) + + 单据类型编码 + 单据ID + 是否UAP单据 + + 登录参数 diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs index b08bfe3..779897b 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs @@ -772,7 +772,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 if ((cCodes == null || cCodes.Count <= 0) && (voucherIds == null || voucherIds.Count <= 0)) { - throw new Exception("没有数据需要弃审"); + throw new Exception("没有数据需要删除"); } var strCode = ""; @@ -839,6 +839,226 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } } + /// + /// 提交工作流(单号) + /// + /// 系统号 + /// 单据类型编码 + /// 单号 + /// 红蓝标识:True,蓝字 + /// 发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2) + /// 业务类型:普通采购,直运采购,受托代销 + /// CS 0,BS 1;一般CS + /// 为空 + /// + [HttpGet] + [Route("api/U8/PU/{cCardNum}/SubmintWf/Code")] + public async Task> SubmintWf(string cAccId, string cCardNum, string cCode, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null) + { + try + { + var db = CommUnit.GetDbClient(); + + var workId = SnowFlakeSingle.Instance.NextId(); + + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:提交工作流,对接账套:{cAccId},单号:{cCode}"); + + if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin) || baseLogin == null) + { + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + + baseLogin = new BaseLogin(); + + var param = await CommUnit.GetLoginParamter(cAccId); + + if (param == null) + { + throw new Exception("未能加载指定系统号的登录信息"); + } + + baseLogin.Init(param, false); + + _cache.Clear(); + + _cache.Set($"U8_{cAccId}", baseLogin); + } + + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + + var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); + + var co = new clsVoucherCO_PU(); + + return await co.SubmintWf(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), cCode, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + return new BaseResult { bSuccess = false, message = "提交工作流失败", result = ex.Message }; + } + } + + /// + /// 提交工作流(ID) + /// + /// 系统号 + /// 单据类型编码 + /// 单据ID + /// 红蓝标识:True,蓝字 + /// 发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2) + /// 业务类型:普通采购,直运采购,受托代销 + /// CS 0,BS 1;一般CS + /// 为空 + /// + [HttpGet] + [Route("api/U8/PU/{cCardNum}/SubmintWf/ID")] + public async Task> SubmintWf(string cAccId, string cCardNum, long voucherId, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null) + { + try + { + var db = CommUnit.GetDbClient(); + + var workId = SnowFlakeSingle.Instance.NextId(); + + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:提交工作流,对接账套:{cAccId},ID:{voucherId}"); + + if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) + { + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + + baseLogin = new BaseLogin(); + + var param = await CommUnit.GetLoginParamter(cAccId); + + if (param == null) + { + throw new Exception("未能加载指定系统号的登录信息"); + } + + baseLogin.Init(param, false); + + _cache.Clear(); + + _cache.Set($"U8_{cAccId}", baseLogin); + } + + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + + var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); + + var co = new clsVoucherCO_PU(); + + return await co.SubmintWf(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), voucherId, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + return new BaseResult { bSuccess = false, message = "提交工作流失败", result = ex.Message }; + } + } + + /// + /// 提交工作流(批量) + /// + /// 系统号 + /// 单据类型编码 + /// 报文 + /// 红蓝标识:True,蓝字 + /// 发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2) + /// 业务类型:普通采购,直运采购,受托代销 + /// CS 0,BS 1;一般CS + /// 为空 + /// + [HttpPost] + [Route("api/U8/PU/{cCardNum}/SubmintWf")] + public async Task>>> SubmintWf(string cAccId, string cCardNum, [FromBody] STInput input, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + var db = CommUnit.GetDbClient(); + + if (input == null) + { + throw new Exception("参数不能为空"); + } + + var cCodes = input.cCode; + + var voucherIds = input.voucherId; + + if ((cCodes == null || cCodes.Count <= 0) && (voucherIds == null || voucherIds.Count <= 0)) + { + throw new Exception("没有数据需要提交工作流"); + } + + var strCode = ""; + var strId = ""; + + var apiType = cCodes == null || cCodes.Count <= 0 ? 1 : 0; + + if (cCodes != null && cCodes.Count > 0) + { + strCode = string.Join(",", cCodes); + } + + if (voucherIds != null && voucherIds.Count > 0) + { + strId = string.Join(",", voucherIds); + } + + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:提交工作流,对接账套:{cAccId},单号:{strCode},ID:{strId}"); + + if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) + { + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + + baseLogin = new BaseLogin(); + + var param = await CommUnit.GetLoginParamter(cAccId); + + if (param == null) + { + throw new Exception("未能加载指定系统号的登录信息"); + } + + baseLogin.Init(param, false); + + _cache.Clear(); + + _cache.Set($"U8_{cAccId}", baseLogin); + } + + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + + var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); + + var co = new clsVoucherCO_PU(); + + var result = apiType == 0 + ? await co.Delete(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), cCodes, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml) + : await co.Delete(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), voucherIds, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); + + var res = new BaseResult>>() + { + bSuccess = true, + message = "提交工作流完成", + result = result + }; + + return res; + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + return new BaseResult>> { bSuccess = false, message = ex.Message, result = null }; + } + } + /// /// 查询特定单据部分 /// diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/WorkflowController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/WorkflowController.cs index 2885dbb..20d974f 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/WorkflowController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/WorkflowController.cs @@ -53,8 +53,6 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 _logInfo.Debug($"当前接口:api/U8/Workflow/SubmitApplicationMessage/Code,对接账套:{cAccId},单据:{cCardNum},事件:{eventId},单据编号:{cCode}"); - var db = CommUnit.GetDbClient(); - var workId = SnowFlakeSingle.Instance.NextId(); _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:提交审批流,对接账套:{cAccId},单据编号:{cCode}"); @@ -95,7 +93,6 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 /// /// 提交审批流(单号) /// - /// 系统注册号 /// 单据类型编码 /// 单据编号 /// 审批事件 @@ -177,8 +174,6 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 return await SubmitApplicationMessageToken(cCardNum, voucherId, eventId, bUap); } - var db = CommUnit.GetDbClient(); - var workId = SnowFlakeSingle.Instance.NextId(); _logInfo.Debug($"当前接口:api/U8/Workflow/SubmitApplicationMessage/Code,作业Id:{workId},对接账套:{cAccId},单据:{cCardNum},事件:{eventId},单据ID:{voucherId}"); @@ -281,5 +276,246 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } } + /// + /// 退回提交人后重新提交(单号) + /// + /// 单据类型编码 + /// 单据ID + /// 系统注册号 + /// 是否UAP单据 + /// + [HttpGet] + [Route("api/U8/Workflow/SubmitResubmitMessage/Code")] + public async Task> SubmitResubmitMessage(string cAccId, string cCardNum, string cCode, bool bUap = false) + { + try + { + if (Request.Headers.TryGetValues("userToken", out var userToken)) + { + return await SubmitResubmitMessageToken(cCardNum, cCode, bUap); + } + + _logInfo.Debug($"当前接口:api/U8/Workflow/SubmitResubmitMessage/Code,对接账套:{cAccId},单据:{cCardNum},单据编号:{cCode}"); + + var workId = SnowFlakeSingle.Instance.NextId(); + + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:提交审批流,对接账套:{cAccId},单据编号:{cCode}"); + + if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) + { + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + + baseLogin = new BaseLogin(); + + var param = await CommUnit.GetLoginParamter(cAccId); + + if (param == null) + { + throw new Exception("未能加载指定系统号的登录信息"); + } + + baseLogin.Init(param, true); + + _cache.Clear(); + + _cache.Set($"U8_{cAccId}", baseLogin); + } + + var services = new ServiceProxy(); + + return await services.SubmitResubmitMessage(baseLogin, cCardNum, cCode, bUap); + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + + } + } + + /// + /// 退回提交人后重新提交(单号) + /// + /// 单据类型编码 + /// 单据编号 + /// 是否UAP单据 + /// + [HttpGet] + [Route("api/U8/Workflow/SubmitResubmitMessage/Code/Token")] + public async Task> SubmitResubmitMessageToken(string cCardNum, string cCode, bool bUap = false) + { + try + { + var userToken = Request.Headers.GetValues("userToken").First(); + + if (string.IsNullOrWhiteSpace(userToken)) + { + throw new Exception("校验userToken失败"); + } + + _logInfo.Debug($"当前接口:api/U8/Workflow/SubmitResubmitMessage/Code/{userToken},单据:{cCardNum},单据编号:{cCode}"); + + var output = CommUnit.GetDecrypt(userToken).ToObject(); + + var token = CommUnit.GetDecrypt(output.userToken); + + var workId = SnowFlakeSingle.Instance.NextId(); + + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:新增,对接账套:{output.cAccId},单据编号:{cCode}"); + + if (!_cache.TryGetValue($"U8_{userToken}_{output.cAccId}", out BaseLogin baseLogin)) + { + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + + baseLogin = new BaseLogin(); + + baseLogin.Init(token, true, 5); + + try + { + _cache.Remove($"U8_{userToken}_{output.cAccId}"); + } + catch + { + _logInfo.Debug($"不存在[U8_{userToken}_{output.cAccId}]的缓存"); + } + + _cache.Set($"U8_{userToken}_{output.cAccId}", baseLogin); + } + + var services = new ServiceProxy(); + + return await services.SubmitResubmitMessage(baseLogin, cCardNum, cCode, bUap); + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + + } + } + + /// + /// 提交审批流(ID) + /// + /// 单据类型编码 + /// 单据ID + /// 系统注册号 + /// 是否UAP单据 + /// + [HttpGet] + [Route("api/U8/Workflow/SubmitResubmitMessage/ID")] + public async Task> SubmitResubmitMessage(string cAccId, string cCardNum, long voucherId, bool bUap = false) + { + try + { + if (Request.Headers.TryGetValues("userToken", out var userToken)) + { + return await SubmitResubmitMessageToken(cCardNum, voucherId, bUap); + } + + var workId = SnowFlakeSingle.Instance.NextId(); + + _logInfo.Debug($"当前接口:api/U8/Workflow/SubmitApplicationMessage/Code,作业Id:{workId},对接账套:{cAccId},单据:{cCardNum},单据ID:{voucherId}"); + + if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) + { + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + + baseLogin = new BaseLogin(); + + var param = await CommUnit.GetLoginParamter(cAccId); + + if (param == null) + { + throw new Exception("未能加载指定系统号的登录信息"); + } + + baseLogin.Init(param, false); + + _cache.Clear(); + + _cache.Set($"U8_{cAccId}", baseLogin); + } + + var services = new ServiceProxy(); + + return await services.SubmitResubmitMessage(baseLogin, cCardNum, voucherId, bUap); + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + + } + } + + /// + /// 提交审批流(ID) + /// + /// 单据类型编码 + /// 单据ID + /// 是否UAP单据 + /// + [HttpGet] + [Route("api/U8/Workflow/SubmitResubmitMessage/ID/Token")] + public async Task> SubmitResubmitMessageToken(string cCardNum, long voucherId, bool bUap = false) + { + try + { + var userToken = Request.Headers.GetValues("userToken").First(); + + if (string.IsNullOrWhiteSpace(userToken)) + { + throw new Exception("校验userToken失败"); + } + + _logInfo.Debug($"当前接口:api/U8/Workflow/SubmitApplicationMessage/ID/{userToken},单据:{cCardNum},单据ID:{voucherId}"); + + var output = CommUnit.GetDecrypt(userToken).ToObject(); + + var token = CommUnit.GetDecrypt(output.userToken); + + var workId = SnowFlakeSingle.Instance.NextId(); + + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:新增,对接账套:{output.cAccId},单据ID:{voucherId}"); + + if (!_cache.TryGetValue($"U8_{userToken}_{output.cAccId}", out BaseLogin baseLogin)) + { + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + + baseLogin = new BaseLogin(); + + baseLogin.Init(token, true, 5); + + try + { + _cache.Remove($"U8_{userToken}_{output.cAccId}"); + } + catch + { + _logInfo.Debug($"不存在[U8_{userToken}_{output.cAccId}]的缓存"); + } + + _cache.Set($"U8_{userToken}_{output.cAccId}", baseLogin); + } + + var services = new ServiceProxy(); + + return await services.SubmitResubmitMessage(baseLogin, cCardNum, voucherId, bUap); + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + + } + } + + } }