diff --git a/UFIDA.U8.Framework.Api.ControlObject/Common/CommonHelper.cs b/UFIDA.U8.Framework.Api.ControlObject/Common/CommonHelper.cs index 4c7e267..469e9c9 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/Common/CommonHelper.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/Common/CommonHelper.cs @@ -864,5 +864,35 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common var cDefWhere = vouchers.cDefWhere; return $"{cDefWhere} AND {tableName}.{fieldName}='{voucherId}'"; } + + public static string GetQuerySql(VouchersInfo vouchers, Dictionary input, string cCardPostion="H") + { + var cBTQName = vouchers.cBTQName; + var cBWQName = vouchers.cBWQName; + + var voucherIdFieldName = vouchers.voucherIdFieldName; + var tableName = cBTQName; + + if (cCardPostion == "H") + { + tableName = cBWQName; + } + + if (cCardPostion == "B") + { + tableName = cBWQName; + } + + var cDefWhere = vouchers.cDefWhere; + + if (string.IsNullOrWhiteSpace(cDefWhere)) + { + cDefWhere = "1=1"; + } + + var strSql = $"SELECT DISTINCT {tableName}.* FROM {cBTQName} {cBTQName} LEFT JOIN {cBWQName} {cBWQName} ON {cBTQName}.[{voucherIdFieldName}]={cBWQName}.[{voucherIdFieldName}] WHERE {cDefWhere} "; + + return strSql; + } } } diff --git a/UFIDA.U8.Framework.Api.ControlObject/PU/clsVoucherCO_PU.cs b/UFIDA.U8.Framework.Api.ControlObject/PU/clsVoucherCO_PU.cs index 7ab68bf..2b49c1b 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/PU/clsVoucherCO_PU.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/PU/clsVoucherCO_PU.cs @@ -24,7 +24,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU /// public class clsVoucherCO_PU { - protected readonly ILog logInfo = LogManager.GetLogger("logInfo"); + protected readonly ILog _logInfo = LogManager.GetLogger("logInfo"); private dynamic InitCo(BaseLogin login, vouchertype enmVoucherType, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null) { @@ -71,8 +71,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU try { var errorMsg = ""; - logInfo.Debug("开始输出登录信息"); - logInfo.Debug(baseLogin._vbLogin.userToken); + _logInfo.Debug("开始输出登录信息"); + _logInfo.Debug(baseLogin._vbLogin.userToken); var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); @@ -80,10 +80,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU IXMLDOMDocument2 domBody = new DOMDocument(); IXMLDOMDocument2 domCur = new DOMDocument(); - logInfo.Debug("开始获取单据默认模板..."); + _logInfo.Debug("开始获取单据默认模板..."); co.GetVoucherData(ref domHead, ref domBody, "1=2"); - logInfo.Debug("填充表头DOM..."); + _logInfo.Debug("填充表头DOM..."); domHead = dictionary.ToDocument2(domHead); @@ -109,7 +109,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU throw new Exception(errorMsg); } - logInfo.Debug($"获取新单号:{newCode}"); + _logInfo.Debug($"获取新单号:{newCode}"); if (!string.IsNullOrWhiteSpace(newCode)) { @@ -117,16 +117,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU } } - logInfo.Debug("填充表体DOM..."); + _logInfo.Debug("填充表体DOM..."); domBody = dictionarys.ToDocument2(domBody); if (bPrintDom) { - logInfo.Debug("开始输入DOM..."); + _logInfo.Debug("开始输入DOM..."); - logInfo.Debug(domHead.xml); + _logInfo.Debug(domHead.xml); - logInfo.Debug(domBody.xml); + _logInfo.Debug(domBody.xml); } object vouchId = ""; @@ -136,16 +136,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU - logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}"); + _logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}"); - logInfo.Debug("开始查询单据配置..."); + _logInfo.Debug("开始查询单据配置..."); var vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cardNumber); var res = new BaseResult(); if (bAudit) { - logInfo.Debug("开始事务..."); + _logInfo.Debug("开始事务..."); co.bOutTrans = true; baseLogin.Connection.BeginTrans(); @@ -154,16 +154,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU try { - logInfo.Debug("开始保存..."); + _logInfo.Debug("开始保存..."); errorMsg = bAudit ? (string)co.VoucherSave2(ref domHead, ref domBody, VoucherState, ref vouchId, sOverDetailsXml, ref domMsg) : (string)co.VoucherSave(ref domHead, ref domBody, VoucherState, ref vouchId, ref curDom, UserMode, sOverDetailsXml, ref domMsg); - logInfo.Debug("保存结束..."); - logInfo.Debug(errorMsg); - logInfo.Debug($"{vouchId}"); + _logInfo.Debug("保存结束..."); + _logInfo.Debug(errorMsg); + _logInfo.Debug($"{vouchId}"); res.bSuccess = string.IsNullOrWhiteSpace(errorMsg) && !string.IsNullOrWhiteSpace($"{vouchId}"); @@ -229,7 +229,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU res.message = "保存成功"; - logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}"); + _logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}"); var strWhere = CommonHelper.GetVoucherWhereSqlById(vouchers, vouchId); @@ -258,7 +258,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU if (bAudit) { - logInfo.Debug("提交事务..."); + _logInfo.Debug("提交事务..."); baseLogin.Connection.CommitTrans(); } @@ -270,7 +270,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); await Task.Delay(1); @@ -294,8 +294,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU /// public async Task>> Confirm(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); + _logInfo.Debug("开始输出登录信息"); + _logInfo.Debug(baseLogin._vbLogin.userToken); var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); @@ -320,7 +320,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU catch (Exception ex) { await Task.Delay(1); - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); } } @@ -445,7 +445,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU IXMLDOMDocument2 domBody = new DOMDocument(); IXMLDOMDocument2 domMsg = new DOMDocument(); - logInfo.Debug("开始获取单据数据..."); + _logInfo.Debug("开始获取单据数据..."); voucherCO.GetVoucherData(ref domHead, ref domBody, strWhere); var res = new BaseResult @@ -525,8 +525,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU /// public async Task>> CancelConfirm(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); + _logInfo.Debug("开始输出登录信息"); + _logInfo.Debug(baseLogin._vbLogin.userToken); var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); @@ -551,7 +551,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU catch (Exception ex) { await Task.Delay(1); - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); } } @@ -673,7 +673,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU IXMLDOMDocument2 domBody = new DOMDocument(); IXMLDOMDocument2 domMsg = new DOMDocument(); - logInfo.Debug("开始获取单据数据..."); + _logInfo.Debug("开始获取单据数据..."); voucherCO.GetVoucherData(ref domHead, ref domBody, strWhere); var res = new BaseResult @@ -749,8 +749,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU /// public async Task>> Delete(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); + _logInfo.Debug("开始输出登录信息"); + _logInfo.Debug(baseLogin._vbLogin.userToken); var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); @@ -775,7 +775,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU catch (Exception ex) { await Task.Delay(1); - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); } } @@ -897,7 +897,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.PU IXMLDOMDocument2 domBody = new DOMDocument(); IXMLDOMDocument2 domMsg = new DOMDocument(); - logInfo.Debug("开始获取单据数据..."); + _logInfo.Debug("开始获取单据数据..."); voucherCO.GetVoucherData(ref domHead, ref domBody, strWhere); var res = new BaseResult diff --git a/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs b/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs index dfe9cf4..6569ff9 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs @@ -1,11 +1,15 @@ -using log4net; +using ADODB; +using log4net; using MSXML2; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Web.UI.WebControls; using UFGeneralFilterOCX; +using UFIDA.U8.Framework.Api.ControlObject.Common; using UFIDA.U8.Framework.Api.ControlObject.Entity; using UFIDA.U8.Framework.Api.ControlObject.PU; using UFIDA.U8.Framework.Api.ControlObject.U8M; @@ -17,32 +21,241 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA /// public class ClsVoucherCO_SA { - protected readonly ILog logInfo = LogManager.GetLogger("logInfo"); + protected readonly ILog _logInfo = LogManager.GetLogger("logInfo"); - public async Task> Save(BaseLogin baseLogin, Dictionary dictionary, string cardNumber, string VoucherState, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool iswfcontrolled = false, string cFlowFieldName = "IsWfControlled") + private dynamic InitCo(BaseLogin login, int enmVoucherType) + { + var errorMsg = ""; + + dynamic objr = new object(); + var aaa = ""; + + var co = "VoucherCO_Sa.ClsVoucherCO_SA".GetComObject(); + + co.Init(enmVoucherType: enmVoucherType, oLogin: ref login._vbLogin, oConn: ref login.Connection); + + return co; + } + + public async Task> Save(BaseLogin baseLogin, Dictionary dictionary, string cardNumber, VoucherTypeSA enmVoucherType,int VoucherState=0, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool iswfcontrolled = false, string cFlowFieldName = "IsWfControlled") { try { var errorMsg = ""; - logInfo.Debug("开始输出登录信息"); - logInfo.Debug(baseLogin._vbLogin.userToken); + _logInfo.Debug("开始输出登录信息"); + _logInfo.Debug(baseLogin._vbLogin.userToken); - //var co = InitCo(baseLogin, enmVoucherType, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml); + var co = InitCo(baseLogin, (int)enmVoucherType); IXMLDOMDocument2 domHead = new DOMDocument(); IXMLDOMDocument2 domBody = new DOMDocument(); IXMLDOMDocument2 domCur = new DOMDocument(); - return new BaseResult(); + _logInfo.Debug("开始获取单据默认模板..."); + co.GetVoucherData(ref domHead, ref domBody, null, true, "1=2"); + + _logInfo.Debug("填充表头DOM..."); + + domHead = dictionary.ToDocument2(domHead); + + if (!dictionary.TryGetValue("body", out var bodys)) + { + await Task.Delay(1); + throw new Exception("无法获取表体数据"); + } + + if (!(bodys is List> dictionarys) || dictionarys.Count <= 0) + { + await Task.Delay(1); + throw new Exception("无法获取表体数据"); + } + + if (bGetCode) + { + errorMsg = ""; + var newCode = ""; + + if (!co.GetVoucherNO(ref domHead, ref newCode, ref errorMsg)) + { + throw new Exception(errorMsg); + } + + _logInfo.Debug($"获取新单号:{newCode}"); + + if (!string.IsNullOrWhiteSpace(newCode)) + { + domHead.SetDomKeyValue(codeKey, newCode); + } + } + + _logInfo.Debug("填充表体DOM..."); + domBody = dictionarys.ToDocument2(domBody); + + object vouchId = ""; + IXMLDOMDocument2 domMsg = new DOMDocument(); + IXMLDOMDocument2 curDom = new DOMDocument(); + + _logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}"); + + _logInfo.Debug("开始查询单据配置..."); + var vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cardNumber); + + var res = new BaseResult(); + + baseLogin.Connection.BeginTrans(); + + try + { + + _logInfo.Debug("开始保存..."); + + errorMsg = co.Save(ref domHead, ref domBody, VoucherState, ref vouchId,ref domCur); + + + _logInfo.Debug("保存结束..."); + _logInfo.Debug(errorMsg); + _logInfo.Debug($"{vouchId}"); + + res.bSuccess = string.IsNullOrWhiteSpace(errorMsg) && !string.IsNullOrWhiteSpace($"{vouchId}"); + + if (!res.bSuccess) + { + if (!string.IsNullOrWhiteSpace(errorMsg)) + { + throw new Exception(errorMsg); + } + + if (!string.IsNullOrWhiteSpace(domMsg.xml)) + { + throw new Exception(domMsg.xml); + } + + if (!string.IsNullOrWhiteSpace(curDom.xml)) + { + throw new Exception(curDom.xml); + } + + throw new Exception("未知错误"); + + } + + if (iswfcontrolled == false && VoucherState == 2) + { + var strSql = $"UPDATE {vouchers.cBTTblName} SET {cFlowFieldName} = 0 WHERE {vouchers.voucherIdFieldName}={vouchId}"; + + object rsts = new Recordset(); + + baseLogin.Connection.Execute(strSql, out rsts); + } + + + res.voucherCode = CommonHelper.GetVoucherCode(baseLogin.Connection, vouchId, vouchers); + res.voucherId = $"{vouchId}"; + res.result = errorMsg; + + } + catch (Exception) + { + try + { + if (bAudit) + baseLogin.Connection.RollbackTrans(); + } + catch (Exception ex) + { + Trace.WriteLine(ex.Message); + } + + throw; + } + + + if (!res.bSuccess) + { + res.message = "保存失败"; + if (bAudit) + baseLogin.Connection.RollbackTrans(); + return res; + } + + res.message = "保存成功"; + + _logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}"); + + var strWhere = CommonHelper.GetVoucherWhereSqlById(vouchers, vouchId); + + if (res.bSuccess && bAudit) + { + try + { + errorMsg = VerifyVouch(co, baseLogin.Connection, enmVoucherType, res.voucherCode, res.voucherId, strWhere, true); + + if (!string.IsNullOrWhiteSpace(errorMsg)) + { + baseLogin.Connection.RollbackTrans(); + + throw new Exception(errorMsg); + } + } + catch (Exception) + { + baseLogin.Connection.RollbackTrans(); + res.bSuccess = false; + throw; + } + } + + _logInfo.Debug("提交事务..."); + + baseLogin.Connection.CommitTrans(); + + + return res; + + } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); await Task.Delay(1); return new BaseResult { bSuccess = false, message = "保存失败", result = ex.Message }; } } + + public async Task> VerifyVouch(dynamic voucherCO, Connection conn, VoucherTypeSA sVouchType, string cCode, object vouchId, string strWhere,bool bVerify) + { + IXMLDOMDocument2 domHead = new DOMDocument(); + IXMLDOMDocument2 domBody = new DOMDocument(); + IXMLDOMDocument2 domMsg = new DOMDocument(); + + _logInfo.Debug("开始获取单据数据..."); + voucherCO.GetVoucherData(ref domHead, ref domBody, vouchId, true, strWhere); + + var res = new BaseResult + { + voucherCode = cCode, + voucherId = $"{vouchId}" + }; + + var errorMsg = voucherCO.VerifyVouch(ref domHead, bVerify); + + res.bSuccess = string.IsNullOrWhiteSpace(errorMsg); + + if (res.bSuccess) + { + res.message = "审核成功"; + res.result = res.voucherId; + + } + else + { + res.message = "审核失败"; + res.result = string.IsNullOrWhiteSpace(errorMsg) ? domMsg.xml : errorMsg; + } + + return res; + } } } diff --git a/UFIDA.U8.Framework.Api.ControlObject/SA/VoucherTypeSA.cs b/UFIDA.U8.Framework.Api.ControlObject/SA/VoucherTypeSA.cs index dc93866..68ef045 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/SA/VoucherTypeSA.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/SA/VoucherTypeSA.cs @@ -12,5 +12,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA /// 发货单蓝字 /// DispatchBlue=9, + + SaleBillCommBlue = 2, + SaleBillCommRed = 3, + SaleBillDirect = 4, + SaleBillSpecBlue = 0, + SaleBillSpecRed = 1 + + + + + } } diff --git a/UFIDA.U8.Framework.Api.ControlObject/ST/USERPCO.cs b/UFIDA.U8.Framework.Api.ControlObject/ST/USERPCO.cs index be6fc5d..6a1b428 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/ST/USERPCO.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/ST/USERPCO.cs @@ -67,8 +67,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST { logInfo.Debug("开始获取单据默认模板..."); - if (!co.GetDefaultVoucherDom(sVouchType, cCardNum, ref domHead, ref domBody, ref domPosition, - ref errorMsg) || !string.IsNullOrWhiteSpace(errorMsg)) + if (!co.GetDefaultVoucherDom(sVouchType, cCardNum, ref domHead, ref domBody, ref domPosition, ref errorMsg) || !string.IsNullOrWhiteSpace(errorMsg)) { throw new Exception(errorMsg); } @@ -158,8 +157,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST if (!res2) { - baseLogin.Connection.RollbackTrans(); - if (!string.IsNullOrWhiteSpace(errorMsg)) throw new Exception(errorMsg); @@ -168,12 +165,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST throw new Exception("审核单据时发生异常,请检查数据"); } - - baseLogin.Connection.CommitTrans(); - - res.message = "新增成功"; } + baseLogin.Connection.CommitTrans(); + res.message = "新增成功"; } @@ -181,8 +176,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST { logInfo.Debug($"操作完成,操作结果:失败!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]"); - baseLogin.Connection.RollbackTrans(); - if (!string.IsNullOrWhiteSpace(errorMsg)) throw new Exception(errorMsg); diff --git a/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs b/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs index 143df16..4b3d9bd 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs @@ -249,11 +249,28 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M #endif } - _vbLogin = new VBLogin(); - _vbLogin.ClearError(); - _logInfo.Debug($"VB--开始进行U8登录:{_netLogin.userToken}"); - _vbLogin.ConstructLogin(_netLogin.userToken); + if (_netLogin != null) + { + _vbLogin = new VBLogin(); + + _vbLogin.ClearError(); + _logInfo.Debug($"VB--开始进行U8登录:{_netLogin.userToken}"); + _vbLogin.ConstructLogin(_netLogin.userToken); + } + else if(_vbLogin==null) + { + _vbLogin = new VBLogin(); + + _vbLogin.ClearError(); + + _logInfo.Debug($"VB--开始进行U8登录:{paramter.cSrv}--{paramter.pUserId}--{paramter.pAccId}"); + + if (!_vbLogin.Login(paramter.pSubId, paramter.pAccId, paramter.pYearId, paramter.pUserId, paramter.pPassword, paramter.pDate, paramter.cSrv, paramter.cSerial) && string.IsNullOrWhiteSpace(_vbLogin.userToken)) + { + throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}"); + } + } var taskId = DateTime.Now.Ticks.ToString(); _logInfo.Debug($"VB--设置参数:{taskId}"); diff --git a/UFIDA.U8.Framework.Api.ControlObject/U8M/MOrder.cs b/UFIDA.U8.Framework.Api.ControlObject/U8M/MOrder.cs index 61d514a..89b0b3a 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/U8M/MOrder.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/U8M/MOrder.cs @@ -2,6 +2,8 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Data; +using System.Linq; using UFIDA.U8.Framework.Api.ControlObject.Common; using UFIDA.U8.Framework.Api.ControlObject.Entity; using UFIDA.U8.Framework.Api.ControlObject.Json; @@ -174,6 +176,31 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M } + public BaseResult LoadData(string cCardNum, List inputs) + { + try + { + var dataSet = new MOrderDs(); + + if (inputs == null || inputs.Count <= 0) + throw new Exception("查询未返回任何结果"); + + foreach (var ds in inputs.Select(input => MOMExecutor.BFMOrder_LoadData("LoadById", input, new DefaultContextContainer()))) + { + dataSet.Merge(ds); + } + + return new BaseResult() { bSuccess = true, message = "查询成功", result = dataSet }; + + } + catch (Exception ex) + { + logInfo.Error(ex.Message, ex); + + return new BaseResult() { bSuccess = false, message = "删除失败", result = ex.Message }; + } + } + //public BaseResult Verify(string cCardNum, List inputs) //{ // try diff --git a/UFIDA.U8.Framework.Api/App_Data/API_Meta.db b/UFIDA.U8.Framework.Api/App_Data/API_Meta.db index 065dcc6..c735af3 100644 Binary files a/UFIDA.U8.Framework.Api/App_Data/API_Meta.db and b/UFIDA.U8.Framework.Api/App_Data/API_Meta.db differ diff --git a/UFIDA.U8.Framework.Api/App_Data/Customer.json b/UFIDA.U8.Framework.Api/App_Data/Customer.json new file mode 100644 index 0000000..03f4e1e --- /dev/null +++ b/UFIDA.U8.Framework.Api/App_Data/Customer.json @@ -0,0 +1 @@ +[{"TableName":"Customer","FieldName":"cCusCode","AsName":"cCusCode"}] \ No newline at end of file diff --git a/UFIDA.U8.Framework.Api/App_Data/Inventory.json b/UFIDA.U8.Framework.Api/App_Data/Inventory.json new file mode 100644 index 0000000..d222d81 --- /dev/null +++ b/UFIDA.U8.Framework.Api/App_Data/Inventory.json @@ -0,0 +1,117 @@ +[ + { + "TableName": "Inventory", + "FieldName": "cInvCCode", + "AsName": "cInvCCode" + }, + { + "TableName": "Inventory", + "FieldName": "cInvCode", + "AsName": "cInvCode" + }, + { + "TableName": "Inventory", + "FieldName": "cInvName", + "AsName": "cInvName" + }, + { + "TableName": "Inventory", + "FieldName": "cInvStd", + "AsName": "cInvStd" + }, + { + "TableName": "Inventory", + "FieldName": "cComUnitCode", + "AsName": "cComUnitCode" + }, + { + "TableName": "Inventory", + "FieldName": "cAssComUnitCode", + "AsName": "cAssComUnitCode" + }, + { + "TableName": "Inventory", + "FieldName": "cGroupCode", + "AsName": "cGroupCode" + }, + { + "TableName": "Inventory", + "FieldName": "cBarCode", + "AsName": "cBarCode" + }, + { + "TableName": "Inventory", + "FieldName": "iTaxRate", + "AsName": "iTaxRate" + }, + { + "TableName": "Inventory", + "FieldName": "iTestStyle", + "AsName": "iTestStyle" + }, + { + "TableName": "Inventory", + "FieldName": "fLength", + "AsName": "fLength" + }, + { + "TableName": "Inventory", + "FieldName": "fWidth", + "AsName": "fWidth" + }, + { + "TableName": "Inventory", + "FieldName": "fHeight", + "AsName": "fHeight" + }, + { + "TableName": "Inventory", + "FieldName": "dModifyDate", + "AsName": "dModifyDate" + }, + { + "TableName": "Inventory", + "FieldName": "cModifyPerson", + "AsName": "cModifyPerson" + }, + { + "TableName": "Inventory", + "FieldName": "bSelf", + "AsName": "bSelf" + }, + { + "TableName": "Inventory", + "FieldName": "bPurchase", + "AsName": "bPurchase" + }, + { + "TableName": "Inventory", + "FieldName": "dSDate", + "AsName": "dSDate" + }, + { + "TableName": "Inventory", + "FieldName": "dEDate", + "AsName": "dEDate" + }, + { + "TableName": "Inventory", + "FieldName": "dModifyDate", + "AsName": "dModifyDate" + }, + { + "TableName": "Inventory", + "FieldName": "cDefWareHouse", + "AsName": "cDefWareHouse" + }, + { + "TableName": "Inventory", + "FieldName": "cPackingType", + "AsName": "cPackingType" + }, + { + "TableName": "Inventory", + "FieldName": "cInvDepCode", + "AsName": "cInvDepCode" + } +] \ No newline at end of file diff --git a/UFIDA.U8.Framework.Api/App_Data/MO21.json b/UFIDA.U8.Framework.Api/App_Data/MO21.json new file mode 100644 index 0000000..4196b9d --- /dev/null +++ b/UFIDA.U8.Framework.Api/App_Data/MO21.json @@ -0,0 +1 @@ +[{"TableName":"Inventory","FieldName":"cInvCCode","AsName":"ParentID"}] \ No newline at end of file diff --git a/UFIDA.U8.Framework.Api/App_Data/U8API.xml b/UFIDA.U8.Framework.Api/App_Data/U8API.xml index 4201b5a..875ccb9 100644 --- a/UFIDA.U8.Framework.Api/App_Data/U8API.xml +++ b/UFIDA.U8.Framework.Api/App_Data/U8API.xml @@ -568,6 +568,104 @@ + + + 基础资料 + + + + + 日志组件 + + + + + 查询存货档案 + + + + + + + + 查询计量单位档案 + + + + + + + + 查询部门档案 + + + + + + + + 查询仓库档案 + + + + + + + + 查询存货分类档案 + + + + + + + + 查询供应商档案 + + + + + + + + 查询供应商分类档案 + + + + + + + + 查询客户档案 + + + + + + + + 查询客户分类档案 + + + + + + + + 查询人员档案 + + + + + + + + 查询标准工序资料 + + + + + 应收应付管理 @@ -615,7 +713,7 @@ 平台功能 - + 日志组件 @@ -684,17 +782,60 @@ + + + 上传配置 + + + + + + + + 下载配置 + + + + + + + 查询日志 + + + + 生产订单 + + + 日志组件 + + + + + 查询生产订单 + + + + + + + + 查询生产订单子件用料表 + + + + + 采购管理 - + 日志组件 @@ -841,6 +982,33 @@ 为空 + + + 查询特定单据部分 + + 系统号 + 单据类型编码 + 查询条件 + 查询所属区域 H:表头,B:表体 + + + + + + 日志组件 + + + + + 保存单据 + + 系统号 + 单据类型编码 + 报文 + 单据状态:0新增,1修改 + + + 车间管理 @@ -1114,7 +1282,7 @@ 日志组件 - + 新增单据 @@ -1126,9 +1294,10 @@ 是否红字单据 传空字符串 是否远程 + 是否生成时审核 - + 新增单据 @@ -1139,6 +1308,7 @@ 是否红字单据 传空字符串 是否远程 + 是否生成时审核 @@ -1354,6 +1524,11 @@ 用户令牌 + + + 登录参数 + + 缺少程序集全局处理事件 diff --git a/UFIDA.U8.Framework.Api/App_Data/来料报检单模板.json b/UFIDA.U8.Framework.Api/App_Data/来料报检单模板.json new file mode 100644 index 0000000..1eb3833 --- /dev/null +++ b/UFIDA.U8.Framework.Api/App_Data/来料报检单模板.json @@ -0,0 +1,46 @@ +{ + "CVOUCHTYPE": "QM01", + "CINSPECTCODE": "0000000001", + "CSOURCECODE": "0000000001", + "CSOURCEID": 1000000001, + "DARRIVALDATE": "2014-12-03", + "CDEPCODE": "0401", + "CINSPECTDEPCODE": "0401", + "CDEPNAME": "采购部", + "CINSPECTDEPNAME": "采购部", + "DDATE": "2014-12-03", + "CTIME": "11:42:39", + "CVENCODE": "01002", + "CVENNAME": "深圳辰环手机配件有限公司", + "CVENABBNAME": "辰环手机配件", + "CSOURCE": "到货单", + "IVTID": 351, + "CMAKER": "demo", + "CCHECKTYPECODE": "ARR", + "CCHECKTYPENAME": "采购检验", + "body": [ + { + "SOURCEAUTOID": 1000000001, + "ITESTSTYLE": 3, + "CINVCODE": "010204", + "CINVNAME": "大容量存储器", + "CCOMUNITCODE": "0501", + "CCOMUNITNAME": "个", + "CUNITID": "0501", + "CUNITNAME": "个", + "FCHANGRATE": 1, + "FQUANTITY": 100, + "FNUM": 100, + "BFLAG": 1, + "IORDERTYPE": "0", + "CPOCODE": "0000000009", + "FSUMCHECKQTY": 100, + "FSUMCHECKNUM": 100, + "IGROUPTYPE": "1", + "FUNCHECKQTY": 0, + "FUNCHECKNUM": 0, + "FBCCHECKQTY": 0, + "FBCCHECKNUM": 0 + } + ] +} \ No newline at end of file diff --git a/UFIDA.U8.Framework.Api/App_Data/销售发票模板.json b/UFIDA.U8.Framework.Api/App_Data/销售发票模板.json new file mode 100644 index 0000000..f40fa42 --- /dev/null +++ b/UFIDA.U8.Framework.Api/App_Data/销售发票模板.json @@ -0,0 +1,298 @@ +{ + "ivouchstate": "", + "csysbarcode": "", + "ccurrentauditor": "", + "ivtid": "17", + "ufts": "", + "csource": "销售", + "ccrechpname" :"", + "cinfotypecode": "", + "cstcode": "06", + "retail_id": "", + "csaleout": "", + "crdcode": "", + "cdepcode": "0304", + "ccuscode": "0901", + "cpaycode": "", + "cstname": "电子商务", + "ccusabbname": "淘宝", + "ccusaddress": "", + "ccusfax": "", + "ccusbank": "", + "ccusaccount": "", + "ccusperson": "", + "ccuspersoncode": "", + "ccusoaddress": "", + "bcashsale": "0", + "ccuspaycond": "", + "cpersoncode": "030401", + "ccusotype": "", + "sbvid": "0", + "csbvcode": "0000000056", + "cvouchtype": "27", + "ddate": "2025-08-26", + "csocode": "0000000176", + "cdefine1": "", + "cdefine2": "", + "cdefine3": "", + "cmaker": "demo", + "cverifier": "", + "cdepname": "电子商务", + "cpersonname": "何彤", + "iexchrate": "1", + "itaxrate": "17.00", + "cbillver": "", + "cmemo": "", + "cpayname": "", + "breturnflag": "0", + "bfirst": "0", + "cbustype": "普通销售", + "cbcode": "001", + "cexch_name": "人民币", + "cinvalider": "", + "cbname": "中行光华路支行", + "cbaccount": "9800031344000", + "ccusregcode": "", + "icuscreline": "0.00", + "iarmoney": "", + "cdefine4": "", + "cdefine5": "", + "cdefine6": "", + "cdefine7": "", + "cdefine8": "", + "cdefine9": "", + "cdefine10": "", + "cdefine11": "", + "cdefine12": "", + "cdefine13": "", + "cdefine14": "", + "cdefine15": "", + "cdefine16": "", + "citem_class": "", + "citemcode": "", + "ccusname": "淘宝网", + "clastcusname": "", + "idisp": "1", + "cdlcode": "0000000072", + "caccounter": "", + "cchecker": "", + "bpayment": "", + "ccusdefine1": "", + "ccusdefine2": "", + "ccusdefine3": "", + "ccusdefine4": "", + "ccusdefine5": "", + "ccusdefine6": "", + "ccusdefine7": "", + "ccusdefine8": "", + "ccusdefine9": "", + "ccusdefine10": "", + "ccusdefine11": "", + "ccusdefine12": "", + "ccusdefine13": "", + "ccusdefine14": "", + "ccusdefine15": "", + "ccusdefine16": "", + "cauthid": "", + "csccode": "", + "cscname": "", + "cshipaddress": "", + "cpayment": "", + "cvouchtype2": "", + "cvouchname": "销售普通发票", + "ccccode": "", + "cdccode": "", + "caddcode": "", + "cdeliverunit": "", + "cbooktype": "", + "cbookdepcode": "", + "ccushand": "", + "ccusphone": "", + "ccontactname": "", + "cmobilephone": "", + "cofficephone": "", + "iflowid": "0", + "cflowname": "", + "cgcroutecode": "", + "cgcroutename": "", + "cgatheringplan": "", + "cgatheringplanname": "", + "dcreditstart": "", + "icreditdays": "", + "dgatheringdate": "", + "bcredit": "否", + "cmodifier": "", + "dmoddate": "", + "dverifydate": "", + "csscode": "", + "cssname": "", + "itaxbillstate": "", + "ctaxbillcode": "", + "ccustomerphone": "", + "ccreditcuscode": "0901", + "ccreditcusname": "淘宝网", + "ioutgolden": "", + "iverifystate": "0", + "ireturncount": "", + "icreditstate": "", + "iswfcontrolled": "0", + "dcreatesystime": "", + "dverifysystime": "", + "dmodifysystime": "", + "iprintcount": "", + "bnottogoldtax": "0", + "cebtrnumber": "", + "cebbuyer": "", + "cebbuyernote": "", + "cebprovince": "", + "cebcity": "", + "cebdistrict": "", + "cinvoicecusname": "", + "cgoldtaxcusname": "", + "darverifydate": "", + "darverifysystime": "", + "chdefine1": "", + "keyextend_t_sbvid_salebillvouch_extradefine_sbvid": "", + "c154": "", + "editprop": "A", + "caddph": "北京市海淀区北清路68号", + "cunitname": "星空电子公司", + "cmyregcode": "110101020100011", + "dsverifydate": "2015-01-02", + "isfsupplymulti": "1", + "isfminsupply": "1", + "boverconsignment": "0", + "bcheckvdate": "0", + "saveafterok": "0", + "body": [ + { + "irowno": "1", + "csocode": "0000000176", + "cordercode": "0000000176", + "iorderrowno": "1", + "cwhcode": "50", + "cwhname": "网购仓", + "cinvcode": "0330", + "cinvname": "三星手机S3", + "csettleall": "未关闭", + "bsettleall": "0", + "itb": "0", + "cinvm_unit": "台", + "iquantity": "1.00", + "igrouptype": "0", + "iinvexchrate": ".000000", + "fretsum": "0", + "cgroupcode": "01", + "itaxrate": "17.00", + "inewquantity": "1.00", + "inewmoney": "597.44", + "inewtax": "101.56", + "bsalepricefree1": "False", + "bsalepricefree10": "False", + "bsalepricefree2": "False", + "bsalepricefree3": "False", + "bsalepricefree4": "False", + "bsalepricefree5": "False", + "bsalepricefree6": "False", + "bsalepricefree7": "False", + "bsalepricefree8": "False", + "bsalepricefree9": "False", + "bfree1": "False", + "bfree10": "False", + "bfree2": "False", + "bfree3": "False", + "bfree4": "False", + "bfree5": "False", + "bfree6": "False", + "bfree7": "False", + "bfree8": "False", + "bfree9": "False", + "inewsum": "699", + "inewnatmoney": "597.44", + "inewnattax": "101.56", + "btracksalebill": "0", + "fretqtywkp": "0", + "inewnatsum": "699", + "foutquantity": "0", + "iretquantity": "0", + "isettlequantity": "0", + "isettlenum": "0", + "iquotedprice": "999.00", + "bbatchcreate": "False", + "bbatchproperty1": "False", + "bbatchproperty10": "False", + "bbatchproperty2": "False", + "bbatchproperty3": "False", + "bbatchproperty4": "False", + "bbatchproperty5": "False", + "bbatchproperty6": "False", + "bbatchproperty7": "False", + "bbatchproperty8": "False", + "bbatchproperty9": "False", + "itaxunitprice": "699.00", + "iunitprice": "597.44", + "imoney": "597.44", + "fretailrealamount": ".000000000", + "fretailsettleamount": ".000000000", + "itax": "101.56", + "isum": "699.00", + "inatunitprice": "597.44", + "inatmoney": "597.44", + "inattax": "101.56", + "bservice": "False", + "binvtype": "False", + "inatsum": "699.00", + "fsaleprice": "0.00", + "kl": "69.97", + "kl2": "100.00", + "dkl1": "30.03", + "dkl2": "0.00", + "idiscount": "300.00", + "inewdiscount": "300", + "inewnatdiscount": "300", + "inatdiscount": "300.00", + "bgsp": "0", + "btrack": "False", + "binvbatch": "False", + "binvquality": "False", + "bqaneedcheck": "0", + "bqaurgency": "0", + "bproxywh": "False", + "csrpolicy": "PE", + "dlid": "1000000100", + "idlsid": "1000000160", + "isosid": "1000000320", + "ibatch": "0", + "icorid": "1000000160", + "idemandseq": "1", + "idemandtype": "1", + "cdemandcode": "0000000176", + "cdemandid": "1000000320", + "cbdlcode": "0000000072", + "bptomodel": "否", + "binvmodel": "否", + "bsaleprice": "1", + "bgift": "0", + "selcol": "Y", + "editprop": "A", + "inattaxunitprice": "699.00", + "cfree1": "", + "cfree2": "", + "cfree3": "", + "cfree4": "", + "cfree5": "", + "cfree6": "", + "cfree7": "", + "cfree8": "", + "cfree9": "", + "cfree10": "", + "tbquantity": "0", + "cfactorycode": "", + "iexchsum": "0", + "imoneysum": "0", + "cmassunit": "0", + "bcheckbatch": "0", + "bcosting": "1" + } + ] +} \ No newline at end of file diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/AAController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/AAController.cs new file mode 100644 index 0000000..0df3a2c --- /dev/null +++ b/UFIDA.U8.Framework.Api/Controllers/U8/AAController.cs @@ -0,0 +1,1563 @@ +using log4net; +using Microsoft.Extensions.Caching.Memory; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Web.Http; +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.Unit; + +// ReSharper disable InconsistentNaming + +namespace UFIDA.U8.Framework.Api.Controllers.U8 +{ + /// + /// 基础资料 + /// + public class AAController : ApiController + { + /// + /// 日志组件 + /// + private readonly ILog _logInfo = LogManager.GetLogger("logInfo"); + + private static readonly MemoryCache _cache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(10) }); + + /// + /// 查询存货档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/Inventory/Load")] + public async Task> Inventory_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:Inventory,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 inventoryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"App_Data/Inventory.json")); + + var inventorys = inventoryTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, ConfigId = cAccId, ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("Inventory", "Inventory") + .AddJoinInfo("Inventory_Sub", "Inventory_Sub", "Inventory.cInvCode=Inventory_Sub.cInvSubCode"); + + if (db.DbMaintenance.IsAnyTable("Inventory_extradefine", false)) + { + query.AddJoinInfo("Inventory_extradefine", "Inventory_extradefine", + "Inventory.cInvCode=Inventory_extradefine.cInvCode"); + } + + if (input != null) + { + var conModels = new List(); + + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key == "cInvCode" && input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = "Inventory.cInvCode", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key == "cInvCode") + { + conModels.Add(new ConditionalModel + { + FieldName = "Inventory.cInvCode", + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key == "cInvCode__2") + { + conModels.Add(new ConditionalModel + { + FieldName = "Inventory.cInvCode", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (inventorys != null && inventorys.Count > 0) + { + var selector = new List(); + + foreach (var inventory in inventorys) + { + var model = new SelectModel() { FieldName = $"{inventory.TableName}.{inventory.FieldName}" }; + + if (inventory.AsName != null && !string.IsNullOrWhiteSpace(inventory.AsName)) + { + model.AsName = inventory.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询计量单位档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/ComputationUnit/Load")] + public async Task> ComputationUnit_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:ComputationUnit,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 computationunitTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/ComputationUnit.json")); + + var computationunits = computationunitTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("ComputationUnit", "ComputationUnit"); + + + if (input != null) + { + var conModels = new List(); + + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + }else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (computationunits != null && computationunits.Count > 0) + { + var selector = new List(); + + foreach (var computationunit in computationunits) + { + var model = new SelectModel() { FieldName = $"{computationunit.TableName}.{computationunit.FieldName}" }; + + if (computationunit.AsName != null && !string.IsNullOrWhiteSpace(computationunit.AsName)) + { + model.AsName = computationunit.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询部门档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/Department/Load")] + public async Task> Department_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:Department,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 departmentTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Department.json")); + + var departments = departmentTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("Department", "Department"); + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (departments != null && departments.Count > 0) + { + var selector = new List(); + + foreach (var department in departments) + { + var model = new SelectModel() { FieldName = $"{department.TableName}.{department.FieldName}" }; + + if (department.AsName != null && !string.IsNullOrWhiteSpace(department.AsName)) + { + model.AsName = department.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询仓库档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/Warehouse/Load")] + public async Task> Warehouse_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:Warehouse,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 warehouseTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Warehouse.json")); + + var warehouses = warehouseTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("Warehouse", "Warehouse"); + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (warehouses != null && warehouses.Count > 0) + { + var selector = new List(); + + foreach (var warehouse in warehouses) + { + var model = new SelectModel() { FieldName = $"{warehouse.TableName}.{warehouse.FieldName}" }; + + if (warehouse.AsName != null && !string.IsNullOrWhiteSpace(warehouse.AsName)) + { + model.AsName = warehouse.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询存货分类档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/InventoryClass/Load")] + public async Task> InventoryClass_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:InventoryClass,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 inventoryclassTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/InventoryClass.json")); + + var inventoryclasss = inventoryclassTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("InventoryClass", "InventoryClass"); + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (inventoryclasss != null && inventoryclasss.Count > 0) + { + var selector = new List(); + + foreach (var inventoryclass in inventoryclasss) + { + var model = new SelectModel() { FieldName = $"{inventoryclass.TableName}.{inventoryclass.FieldName}" }; + + if (inventoryclass.AsName != null && !string.IsNullOrWhiteSpace(inventoryclass.AsName)) + { + model.AsName = inventoryclass.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询供应商档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/Vendor/Load")] + public async Task> Vendor_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:Vendor,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 vendorTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Vendor.json")); + + var vendors = vendorTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("Vendor", "Vendor"); + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (vendors != null && vendors.Count > 0) + { + var selector = new List(); + + foreach (var vendor in vendors) + { + var model = new SelectModel() { FieldName = $"{vendor.TableName}.{vendor.FieldName}" }; + + if (vendor.AsName != null && !string.IsNullOrWhiteSpace(vendor.AsName)) + { + model.AsName = vendor.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询供应商分类档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/VendorClass/Load")] + public async Task> VendorClass_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:VendorClass,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/VendorClass.json")); + + var querys = queryTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("VendorClass", "VendorClass"); + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (querys != null && querys.Count > 0) + { + var selector = new List(); + + foreach (var q in querys) + { + var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" }; + + if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName)) + { + model.AsName = q.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询客户档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/Customer/Load")] + public async Task> Customer_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:Customer,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Customer.json")); + + var querys = queryTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("Customer", "Customer"); + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (querys != null && querys.Count > 0) + { + var selector = new List(); + + foreach (var q in querys) + { + var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" }; + + if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName)) + { + model.AsName = q.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询客户分类档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/CustomerClass/Load")] + public async Task> CustomerClass_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:CustomerClass,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/CustomerClass.json")); + + var querys = queryTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("CustomerClass", "CustomerClass"); + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (querys != null && querys.Count > 0) + { + var selector = new List(); + + foreach (var q in querys) + { + var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" }; + + if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName)) + { + model.AsName = q.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询人员档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/Person/Load")] + public async Task> Person_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:CustomerClass,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Person.json")); + + var querys = queryTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("hr_hi_person", "hr_hi_person"); + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (querys != null && querys.Count > 0) + { + var selector = new List(); + + foreach (var q in querys) + { + var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" }; + + if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName)) + { + model.AsName = q.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询标准工序资料 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/Operation/Load")] + public async Task> Operation_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----档案:Operation,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Operation.json")); + + var querys = queryTxt.ToObject>(); + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var query = db.Queryable().AS("sfc_operation", "sfc_operation"); + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (querys != null && querys.Count > 0) + { + var selector = new List(); + + foreach (var q in querys) + { + var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" }; + + if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName)) + { + model.AsName = q.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); + + return new BaseResult + { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + } +} diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs index aa2148f..8aad8c8 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs @@ -1,9 +1,14 @@ using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; using System.Threading.Tasks; +using System.Web; using System.Web.Http; using System.Web.Http.Description; using System.Web.UI.WebControls; using log4net; +using Microsoft.Extensions.Hosting; using UFIDA.U8.Framework.Api.ControlObject.Common; using UFIDA.U8.Framework.Api.ControlObject.Entity; using UFIDA.U8.Framework.Api.ControlObject.Json; @@ -22,7 +27,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 /// /// 日志组件 /// - protected readonly ILog logInfo = LogManager.GetLogger("logInfo"); + protected readonly ILog _logInfo = LogManager.GetLogger("logInfo"); /// /// U8登录接口 @@ -36,7 +41,8 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 { try { - logInfo.Debug($"当前接口:api/U8/DP/Login,参数:{input.ToJson()}"); + + _logInfo.Debug($"当前接口:api/U8/DP/Login,参数:{input.ToJson()}"); var db = CommUnit.GetDbClient(); @@ -81,7 +87,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); await Task.Delay(1); @@ -90,7 +96,6 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } - /// /// U8登录接口 /// @@ -103,7 +108,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 try { - logInfo.Debug($"当前接口:api/U8/DP/Login/Token,参数:{input.ToJson()}"); + _logInfo.Debug($"当前接口:api/U8/DP/Login/Token,参数:{input.ToJson()}"); var token = CommUnit.GetUserToken(input.userToken); @@ -123,7 +128,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); await Task.Delay(1); @@ -149,7 +154,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "登录失败", result = ex.Message }; } @@ -176,7 +181,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "查询失败", result = ex.Message }; } @@ -200,7 +205,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "加密失败", result = ex.Message }; } @@ -224,7 +229,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "解密失败", result = ex.Message }; } @@ -259,7 +264,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Debug($"密码未加密:{ex.Message},将进行密码加密"); + _logInfo.Debug($"密码未加密:{ex.Message},将进行密码加密"); input.cPassword = CommUnit.GetEncrypt(input.cPassword); } @@ -270,7 +275,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "新增失败", result = ex.Message }; } @@ -306,7 +311,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Debug($"密码未加密:{ex.Message},将进行密码加密"); + _logInfo.Debug($"密码未加密:{ex.Message},将进行密码加密"); input.cPassword = CommUnit.GetEncrypt(input.cPassword); } @@ -317,7 +322,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "更新失败", result = ex.Message }; } @@ -344,10 +349,110 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "查询失败", result = ex.Message }; } } + + /// + /// 上传配置 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/DP/UploadConfig")] + public async Task> UploadConfig(string cKey,[FromBody] List> inputs) + { + try + { + var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"App_Data/{cKey}.json"); + + File.WriteAllText(fileName, inputs.ToJson()); + + return new BaseResult() + { + result = "上传成功", + message = "上传成功", + bSuccess = true + }; + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + await Task.Delay(1); + + return new BaseResult { bSuccess = false, message = "查询失败", result = ex.Message }; + } + + } + + /// + /// 下载配置 + /// + /// + /// + [HttpPost] + [Route("api/U8/DP/DownloadConfig")] + public async Task> DownloadConfig(string cKey) + { + try + { + var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"App_Data/{cKey}.json"); + + var txt=File.ReadAllText(fileName ); + + return new BaseResult() + { + result = txt, + message = "上传成功", + bSuccess = true + }; + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + await Task.Delay(1); + + return new BaseResult { bSuccess = false, message = "查询失败", result = ex.Message }; + } + + } + + /// + /// 查询日志 + /// + /// + /// + [HttpGet] + [Route("api/U8/DP/LoadLog")] + public async Task LoadLog(string dDate) + { + try + { + if (!DateTime.TryParse(dDate, out var cDate)) + { + throw new Exception("日期格式错误"); + } + + var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Log/Log_{cDate:yyyyMMdd}.log"); + + var txt = File.ReadAllLines(fileName); + + return string.Join(Environment.NewLine, txt); + + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + await Task.Delay(1); + + return ex.Message; + } + } } } diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/MOController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/MOController.cs index fb27900..02b6b4b 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/MOController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/MOController.cs @@ -1,9 +1,17 @@ -using System; +using log4net; +using Microsoft.Extensions.Caching.Memory; +using SqlSugar; +using System; using System.Collections.Generic; +using System.IO; using System.Linq; -using System.Net; -using System.Net.Http; +using System.Threading.Tasks; using System.Web.Http; +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.Unit; namespace UFIDA.U8.Framework.Api.Controllers.U8 { @@ -12,6 +20,363 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 /// public class MOController : ApiController { - + /// + /// 日志组件 + /// + private readonly ILog _logInfo = LogManager.GetLogger("logInfo"); + + private static readonly MemoryCache _cache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(10) }); + + /// + /// 查询生产订单 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/MO/MO21/Load")] + public async Task> MO21_Load(string cAccId,[FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken!= "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----单据:MO21,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var mo21Txt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/MO21.json")); + + var mo21s = mo21Txt.ToObject>(); + + var query = db.Queryable().AS("v_mom_order_wf", "v_mom_order_wf") + .AddJoinInfo("v_mom_orderdetail_wf", "v_mom_orderdetail_wf", "v_mom_order_wf.MoId=v_mom_orderdetail_wf.MoId"); + + if (db.DbMaintenance.IsAnyTable("mom_order_extradefine", false)) + { + query.AddJoinInfo("mom_order_extradefine", "mom_order_extradefine", + "v_mom_order_wf.MoId=mom_order_extradefine.MoId"); + } + + if (db.DbMaintenance.IsAnyTable("mom_orderdetail_extradefine", false)) + { + query.AddJoinInfo("mom_orderdetail_extradefine", "mom_order_extradefine", + "v_mom_orderdetail_wf.MoDId=mom_orderdetail_extradefine.MoDId"); + } + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if (o.Key == "MoId" && input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = "v_mom_order_wf.MoId", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key == "MoId") + { + conModels.Add(new ConditionalModel + { + FieldName = "v_mom_order_wf.MoId", + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key == "MoId__2") + { + conModels.Add(new ConditionalModel + { + FieldName = "v_mom_order_wf.MoId", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + }else if (o.Key == "MoDId" && input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = "v_mom_orderdetail_wf.MoDId", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key == "MoDId") + { + conModels.Add(new ConditionalModel + { + FieldName = "v_mom_orderdetail_wf.MoDId", + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key == "MoDId__2") + { + conModels.Add(new ConditionalModel + { + FieldName = "v_mom_orderdetail_wf.MoDId", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (mo21s != null && mo21s.Count > 0) + { + var selector = new List(); + + foreach (var mo21 in mo21s) + { + var model = new SelectModel() { FieldName = $"{mo21.TableName}.{mo21.FieldName}" }; + + if (mo21.AsName != null && !string.IsNullOrWhiteSpace(mo21.AsName)) + { + model.AsName = mo21.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + return new BaseResult { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + await Task.Delay(1); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } + + /// + /// 查询生产订单子件用料表 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/MO/MO2101/Load")] + public async Task> MO2101_Load(string cAccId, [FromBody] Dictionary input) + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + //var userToken = Request.Headers.GetValues("userToken").First(); + + //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") + //{ + // throw new Exception("调用信息不正确,请确认参数"); + //} + + _logInfo.Debug($"作业Id:{workId}-----单据:MO2101,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + + 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 db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var mo2101Txt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/MO2101.json")); + + var mo2101s = mo2101Txt.ToObject>(); + + var query = db.Queryable().AS("mom_moallocate", "mom_moallocate"); + + if (db.DbMaintenance.IsAnyTable("mom_moallocate_extradefine", false)) + { + query.AddJoinInfo("mom_moallocate_extradefine", "mom_moallocate_extradefinemom_moallocate_extradefine", + "om_moallocate.AllocateId=mom_moallocate_extradefine.AllocateId"); + } + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if (o.Key == "AllocateId" && input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = "mom_moallocate.AllocateId", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key == "AllocateId") + { + conModels.Add(new ConditionalModel + { + FieldName = "mom_moallocate.AllocateId", + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key == "AllocateId__2") + { + conModels.Add(new ConditionalModel + { + FieldName = "mom_moallocate.AllocateId", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + if (mo2101s != null && mo2101s.Count > 0) + { + var selector = new List(); + + foreach (var mo2101 in mo2101s) + { + var model = new SelectModel() { FieldName = $"{mo2101.TableName}.{mo2101.FieldName}" }; + + if (mo2101.AsName != null && !string.IsNullOrWhiteSpace(mo2101.AsName)) + { + model.AsName = mo2101.AsName; + } + + selector.Add(model); + } + + query.Select(selector); + } + + return new BaseResult { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + + } + catch (Exception ex) + { + _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + + await Task.Delay(1); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } } } diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs index 455a23c..c6351b9 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs @@ -17,6 +17,7 @@ using UFIDA.U8.Framework.Api.ControlObject.ST; using UFIDA.U8.Framework.Api.ControlObject.U8M; using UFIDA.U8.Framework.Api.Models; using UFIDA.U8.Framework.Api.Unit; +using static System.Runtime.CompilerServices.RuntimeHelpers; namespace UFIDA.U8.Framework.Api.Controllers.U8 { @@ -28,7 +29,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 /// /// 日志组件 /// - protected readonly ILog logInfo = LogManager.GetLogger("logInfo"); + protected readonly ILog _logInfo = LogManager.GetLogger("logInfo"); private static readonly MemoryCache _cache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(10) }); @@ -56,13 +57,13 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 var workId = SnowFlakeSingle.Instance.NextId(); - logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:新增,对接账套:{cAccId},数据:{input.ToJson()}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:新增,对接账套:{cAccId},数据:{input.ToJson()}"); //LoginParamter param; if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) { - logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); baseLogin = new BaseLogin(); @@ -84,7 +85,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 // param = await CommUnit.GetLoginParamter(cAccId); //} - logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); @@ -100,45 +101,45 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 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}-----配置获取单号"); + _logInfo.Debug($"作业Id:{workId}-----配置获取单号"); } else { - logInfo.Debug($"作业Id:{workId}-----没有单号需要自动指定"); + _logInfo.Debug($"作业Id:{workId}-----没有单号需要自动指定"); } #region 调整日期,去掉时间部分 if (input.ContainsKey("ddate")) { - logInfo.Debug($"作业Id:{workId}-----调整日期,去掉时间部分"); + _logInfo.Debug($"作业Id:{workId}-----调整日期,去掉时间部分"); input["ddate"] = $"{Convert.ToDateTime(input["ddate"]):yyyy-MM-dd}"; } if (input.ContainsKey("dtvdate")) { - logInfo.Debug($"作业Id:{workId}-----调整日期,去掉时间部分"); + _logInfo.Debug($"作业Id:{workId}-----调整日期,去掉时间部分"); input["dtvdate"] = $"{Convert.ToDateTime(input["dtvdate"]):yyyy-MM-dd}"; } #endregion - logInfo.Debug($"作业Id:{workId}-----设置表头数据"); + _logInfo.Debug($"作业Id:{workId}-----设置表头数据"); input.SetDictionaryData(defs, baseLogin.Connection, newNumber); - logInfo.Debug($"作业Id:{workId}-----读取表体数据"); + _logInfo.Debug($"作业Id:{workId}-----读取表体数据"); var bodyData = input[voucherInfo.BodyName].ToJson().ToList>(); //读取表体的数据 if (bodyData == null || bodyData.Count <= 0) throw new Exception("无表体数据!"); - logInfo.Debug($"作业Id:{workId}-----获取表体字段配置"); + _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}行单据数据"); + _logInfo.Debug($"作业Id:{workId}-----设置第{rowNo}行单据数据"); body.SetDictionaryData(defsBody, baseLogin.Connection, newNumber, rowNo); rowNo++; @@ -154,7 +155,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; } @@ -182,13 +183,13 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 var workId = SnowFlakeSingle.Instance.NextId(); - logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:审核,对接账套:{cAccId},单号:{cCode}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:审核,对接账套:{cAccId},单号:{cCode}"); //LoginParamter param; if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin) || baseLogin == null) { - logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); baseLogin = new BaseLogin(); @@ -210,7 +211,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 // param = await CommUnit.GetLoginParamter(cAccId); //} - logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); @@ -220,7 +221,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "审核失败", result = ex.Message }; } @@ -248,11 +249,11 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 var workId = SnowFlakeSingle.Instance.NextId(); - logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:审核,对接账套:{cAccId},ID:{voucherId}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:审核,对接账套:{cAccId},ID:{voucherId}"); if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) { - logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); baseLogin = new BaseLogin(); @@ -270,7 +271,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 _cache.Set($"U8_{cAccId}", baseLogin); } - logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); @@ -280,7 +281,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "审核失败", result = ex.Message }; } @@ -337,13 +338,13 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 strId = string.Join(",", voucherIds); } - logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:审核,对接账套:{cAccId},单号:{strCode},ID:{strId}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:审核,对接账套:{cAccId},单号:{strCode},ID:{strId}"); //LoginParamter param; if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) { - logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); baseLogin = new BaseLogin(); @@ -365,7 +366,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 // param = await CommUnit.GetLoginParamter(cAccId); //} - logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); @@ -386,7 +387,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult>> { bSuccess = false, message = ex.Message, result = null }; } @@ -414,11 +415,11 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 var workId = SnowFlakeSingle.Instance.NextId(); - logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:弃审,对接账套:{cAccId},单号:{cCode}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:弃审,对接账套:{cAccId},单号:{cCode}"); if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin) || baseLogin == null) { - logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); baseLogin = new BaseLogin(); @@ -436,7 +437,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 _cache.Set($"U8_{cAccId}", baseLogin); } - logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); @@ -446,7 +447,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "弃审失败", result = ex.Message }; } @@ -474,11 +475,11 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 var workId = SnowFlakeSingle.Instance.NextId(); - logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:弃审,对接账套:{cAccId},ID:{voucherId}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:弃审,对接账套:{cAccId},ID:{voucherId}"); if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) { - logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); baseLogin = new BaseLogin(); @@ -496,7 +497,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 _cache.Set($"U8_{cAccId}", baseLogin); } - logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); @@ -506,7 +507,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "弃审失败", result = ex.Message }; } @@ -563,13 +564,13 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 strId = string.Join(",", voucherIds); } - logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:弃审,对接账套:{cAccId},单号:{strCode},ID:{strId}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:弃审,对接账套:{cAccId},单号:{strCode},ID:{strId}"); //LoginParamter param; if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) { - logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); baseLogin = new BaseLogin(); @@ -591,7 +592,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 // param = await CommUnit.GetLoginParamter(cAccId); //} - logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); @@ -612,7 +613,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult>> { bSuccess = false, message = ex.Message, result = null }; } @@ -640,11 +641,11 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 var workId = SnowFlakeSingle.Instance.NextId(); - logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:删除,对接账套:{cAccId},单号:{cCode}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:删除,对接账套:{cAccId},单号:{cCode}"); if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin) || baseLogin == null) { - logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); baseLogin = new BaseLogin(); @@ -662,7 +663,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 _cache.Set($"U8_{cAccId}", baseLogin); } - logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); @@ -672,7 +673,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "删除失败", result = ex.Message }; } @@ -700,11 +701,11 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 var workId = SnowFlakeSingle.Instance.NextId(); - logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:删除,对接账套:{cAccId},ID:{voucherId}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:删除,对接账套:{cAccId},ID:{voucherId}"); if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) { - logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); baseLogin = new BaseLogin(); @@ -722,7 +723,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 _cache.Set($"U8_{cAccId}", baseLogin); } - logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); @@ -732,7 +733,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "删除失败", result = ex.Message }; } @@ -754,12 +755,12 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/PU/{cCardNum}/Delete")] public async Task>>> Delete(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(); - var workId = SnowFlakeSingle.Instance.NextId(); - if (input == null) { throw new Exception("参数不能为空"); @@ -789,11 +790,11 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 strId = string.Join(",", voucherIds); } - logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:删除,对接账套:{cAccId},单号:{strCode},ID:{strId}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:删除,对接账套:{cAccId},单号:{strCode},ID:{strId}"); if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) { - logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); baseLogin = new BaseLogin(); @@ -811,7 +812,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 _cache.Set($"U8_{cAccId}", baseLogin); } - logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); + _logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息"); var voucherInfo = await db.Queryable().FirstAsync(s => s.CardNumber == cCardNum); @@ -832,11 +833,259 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } catch (Exception ex) { - logInfo.Error(ex.Message, ex); + _logInfo.Error(ex.Message, ex); return new BaseResult>> { bSuccess = false, message = ex.Message, result = null }; } } + /// + /// 查询特定单据部分 + /// + /// 系统号 + /// 单据类型编码 + /// 查询条件 + /// 查询所属区域 H:表头,B:表体 + /// + /// + [HttpPost] + [Route("api/U8/PU/{cCardNum}/Load")] + [Route("api/U8/PU/{cCardNum}/Load/{cCardPostion}")] + public async Task> Load(string cAccId, string cCardNum, [FromBody] Dictionary input, string cCardPostion = "H") + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + 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 vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cCardNum); + + if (vouchers == null) + { + throw new Exception("未能获取到单据配置信息"); + } + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet + }); + + var cBTQName = vouchers.cBTQName; + var cBWQName = vouchers.cBWQName; + var cBTTblName = vouchers.cBTTblName; + var cBWTblName = vouchers.cBWTblName; + var voucherIdFieldName = vouchers.voucherIdFieldName; + var vouchersIdFieldName = ""; + var tableName = cBTQName; + var colsHeadList=new List(); + var colsBodyList=new List(); + var bExtHead = false; + var bExtBody = false; + + if (cCardPostion == "H") + { + tableName = cBWQName; + } + + if (cCardPostion == "B") + { + tableName = cBWQName; + } + + var cDefWhere = vouchers.cDefWhere; + + var query = db.Queryable().AS(cBTQName, cBTQName); + + if (!string.IsNullOrWhiteSpace(cBWQName)) + { + query.AddJoinInfo(cBWQName, cBWQName, $"{cBTQName}.[{voucherIdFieldName}]={cBWQName}.[{voucherIdFieldName}]"); + + var bodyCols = db.DbMaintenance.GetColumnInfosByTableName(cBWQName); + + if (bodyCols != null && bodyCols.Count > 0) + { + colsBodyList.AddRange(from col in bodyCols where !col.DbColumnName.ToLower().Contains("ufts") && col.DbColumnName.ToLower()!=voucherIdFieldName select $"{cBWQName}.[{col.DbColumnName}]"); + } + } + + var headCols = db.DbMaintenance.GetColumnInfosByTableName(cBTQName); + + if(headCols!=null && headCols.Count > 0) + { + colsHeadList.AddRange(from col in headCols where !col.DbColumnName.ToLower().Contains("ufts") select $"{cBTQName}.[{col.DbColumnName}]"); + } + + if (db.DbMaintenance.IsAnyTable($"{cBTTblName}_extradefine", false)) + { + bExtHead = true; + var cols = db.DbMaintenance.GetColumnInfosByTableName($"{cBTTblName}_extradefine"); + + if (cols != null && cols.Count > 0) + { + foreach (var col in cols) + { + if (col.DbColumnName.ToLower().StartsWith("chdefine")) + { + colsHeadList.Add($"{cBTTblName}_extradefine.[{col.DbColumnName.ToLower()}]"); + } + else + { + vouchersIdFieldName = col.DbColumnName; + } + } + } + + query.AddJoinInfo($"{cBTTblName}_extradefine", $"{cBTTblName}_extradefine", $"{cBTQName}.[{voucherIdFieldName}]={cBTTblName}_extradefine.[{voucherIdFieldName}]"); + } + + if (db.DbMaintenance.IsAnyTable($"{cBWTblName}_extradefine", false)) + { + bExtBody = true; + var cols= db.DbMaintenance.GetColumnInfosByTableName($"{cBWTblName}_extradefine"); + + if (cols != null && cols.Count > 0) + { + foreach (var col in cols) + { + if (col.DbColumnName.ToLower().StartsWith("cbdefine")) + { + colsBodyList.Add($"{cBWTblName}_extradefine.[{col.DbColumnName.ToLower()}]"); + } + else + { + vouchersIdFieldName = col.DbColumnName; + } + } + } + + query.AddJoinInfo($"{cBWTblName}_extradefine", $"{cBWTblName}_extradefine", $"{cBWQName}.[{vouchersIdFieldName}]={cBWTblName}_extradefine.[{vouchersIdFieldName}]"); + } + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if (o.Key == "dModifyDate") + { + conModels.Add(new ConditionalModel + { + FieldName = "caudittime", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if(o.Key == "dModifyDate__2") + { + conModels.Add(new ConditionalModel + { + FieldName = "caudittime", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + query.Where(cDefWhere); + + if (cCardPostion == "H") + { + if (bExtHead) + { + query.Select($"{string.Join(",", colsHeadList)}").Distinct(); + } + else + { + query.Select($"{string.Join(",", colsHeadList)}").Distinct(); + } + } + + if (cCardPostion == "B") + { + if (bExtBody) + { + query.Select($"{string.Join(",",colsBodyList)}").Distinct(); + } + else + { + query.Select($"{string.Join(",", colsBodyList)}").Distinct(); + } + } + + _logInfo.Debug(query.ToSqlString()); + + return new BaseResult() { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + } + 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/Controllers/U8/SAController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/SAController.cs new file mode 100644 index 0000000..0227bc8 --- /dev/null +++ b/UFIDA.U8.Framework.Api/Controllers/U8/SAController.cs @@ -0,0 +1,150 @@ +using log4net; +using Microsoft.Extensions.Caching.Memory; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using System.Web.Http; +using System.Web.UI.WebControls; +using UFIDA.U8.Framework.Api.Common.Entity; +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.PU; +using UFIDA.U8.Framework.Api.ControlObject.SA; +using UFIDA.U8.Framework.Api.ControlObject.U8M; +using UFIDA.U8.Framework.Api.Unit; + +namespace UFIDA.U8.Framework.Api.Controllers.U8 +{ + public class SAController : ApiController + { + + /// + /// 日志组件 + /// + private readonly ILog _logInfo = LogManager.GetLogger("logInfo"); + + private static readonly MemoryCache _cache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(10) }); + + /// + /// 保存单据 + /// + /// 系统号 + /// 单据类型编码 + /// 报文 + /// 单据状态:0新增,1修改 + /// + /// + [HttpPost] + [Route("api/U8/SA/{cCardNum}/Save")] + public async Task> Save(string cAccId, string cCardNum, [FromBody] Dictionary input, int VoucherState = 0) + { + try + { + var db = CommUnit.GetDbClient(); + + var workId = SnowFlakeSingle.Instance.NextId(); + + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:新增,对接账套:{cAccId},数据:{input.ToJson()}"); + + 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 defs = await db.Queryable().Where(s => s.CardNumber == cCardNum && s.cPosition == "H" && s.bEnable == true).ToListAsync(); //查询表头字段配置,供后续设置字段值 + + + 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); + + _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); + + rowNo++; + } + + input[voucherInfo.BodyName] = bodyData; + + var co = new ClsVoucherCO_SA(); + + var res = await co.Save(baseLogin, input, cCardNum, (VoucherTypeSA)Convert.ToInt32(voucherInfo.VoucherType), VoucherState,bGetCode, codeKey, voucherInfo.bVerify, voucherInfo.iswfcontrolled, voucherInfo.cFlowFieldName); + + 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/Controllers/U8/STController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs index c93f698..e475ec5 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs @@ -4,9 +4,7 @@ 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; @@ -46,10 +44,11 @@ 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,bool? bVerify=null) { try { @@ -244,7 +243,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 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); + var res = await co.Insert(baseLogin, input, cCardNum, voucherInfo.VoucherType, bGetCode, codeKey, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote, bVerify??voucherInfo.bVerify,voucherInfo.bPrintDom); return res; } @@ -267,10 +266,11 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 /// 是否红字单据 /// 传空字符串 /// 是否远程 + /// 是否生成时审核 /// [HttpPost] [Route("api/U8/ST/{cCardNum}/Insert/Token")] - public async Task> InsertToken(string cCardNum, [FromBody] Dictionary input, bool bCheck = true, bool bBeforCheckStock = true, bool bIsRedVouch = false, string sAddedState = "", bool bReMote = false) + public async Task> InsertToken(string cCardNum, [FromBody] Dictionary input, bool bCheck = true, bool bBeforCheckStock = true, bool bIsRedVouch = false, string sAddedState = "", bool bReMote = false, bool? bVerify = null) { try { @@ -468,7 +468,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 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); + var res = await co.Insert(baseLogin, input, cCardNum, voucherInfo.VoucherType, bGetCode, codeKey, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote, bVerify??voucherInfo.bVerify, voucherInfo.bPrintDom); return res; } diff --git a/UFIDA.U8.Framework.Api/Entity/AA/InventoryOutput.cs b/UFIDA.U8.Framework.Api/Entity/AA/InventoryOutput.cs new file mode 100644 index 0000000..fba88de --- /dev/null +++ b/UFIDA.U8.Framework.Api/Entity/AA/InventoryOutput.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace UFIDA.U8.Framework.Api.Entity.AA +{ + public class InventoryOutput + { + public dynamic Inventory { get; set; } + + public dynamic Inventory_Sub { get; set; } + + } +} \ No newline at end of file diff --git a/UFIDA.U8.Framework.Api/Entity/QuerySelect.cs b/UFIDA.U8.Framework.Api/Entity/QuerySelect.cs new file mode 100644 index 0000000..d29703a --- /dev/null +++ b/UFIDA.U8.Framework.Api/Entity/QuerySelect.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace UFIDA.U8.Framework.Api.Entity +{ + public class QuerySelect + { + public string TableName { get; set; } + + public string FieldName { get; set; } + + public string AsName { get; set; } + } +} \ No newline at end of file diff --git a/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj b/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj index 3aebdba..a17a2f6 100644 --- a/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj +++ b/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj @@ -71,6 +71,10 @@ ..\packages\EntityFramework.6.5.1\lib\net45\EntityFramework.SqlServer.dll + + D:\U8SOFT\Interop\Interop.VoucherCO_Sa.dll + True + ..\packages\log4net.3.0.3\lib\net462\log4net.dll @@ -413,14 +417,18 @@ + + + + Global.asax @@ -436,6 +444,7 @@ PreserveNewest + @@ -487,11 +496,19 @@ PreserveNewest - - - - - + + + + + + + + + PreserveNewest + + + PreserveNewest + Designer diff --git a/VoucherPlugTest/TestClass.cs b/VoucherPlugTest/TestClass.cs index 9d5f003..82b3461 100644 --- a/VoucherPlugTest/TestClass.cs +++ b/VoucherPlugTest/TestClass.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; -using Interop.UAPvouchercontrol130; +using Interop.UAPvouchercontrol85; using Microsoft.VisualBasic; namespace VoucherPlugTest