1.修复调拨单无法自动审核其他出入库单的问题
2.调整登录,去除多次试错
This commit is contained in:
@@ -3,6 +3,9 @@ using log4net;
|
||||
using MSXML2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Tasks;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Entity;
|
||||
@@ -21,7 +24,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
/// </summary>
|
||||
public class USERPCO
|
||||
{
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
private readonly ILog _logInfo = LogManager.GetLogger("_logInfo");
|
||||
|
||||
/// <summary>
|
||||
/// 新增单据
|
||||
@@ -41,15 +44,15 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
/// <param name="bPrintDom"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public async Task<BaseResult<string>> Insert(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cCardNum, string sVouchType, bool bGetCode = false, string codeKey = "", bool bCheck = true, bool bBeforCheckStock = true, bool bIsRedVouch = false, string sAddedState = "", bool bReMote = false, bool bAudit = false, bool bPrintDom = false)
|
||||
public async Task<BaseResult<string>> Insert(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cCardNum, string sVouchType, bool bGetCode = false, string codeKey = "", bool bCheck = true, bool bBeforCheckStock = true, bool bIsRedVouch = false, string sAddedState = "", bool bReMote = false, bool bAudit = false, bool bPrintDom = false,bool bVerify=false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var co = "USERPCO.VoucherCO".GetComObject();
|
||||
|
||||
var errorMsg = "";
|
||||
logInfo.Debug("开始输出登录信息");
|
||||
logInfo.Debug(baseLogin._vbLogin.userToken);
|
||||
_logInfo.Debug("开始输出登录信息");
|
||||
_logInfo.Debug(baseLogin._vbLogin.userToken);
|
||||
|
||||
if (!co.IniLogin(baseLogin._vbLogin, ref errorMsg))
|
||||
{
|
||||
@@ -65,7 +68,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
|
||||
try
|
||||
{
|
||||
logInfo.Debug("开始获取单据默认模板...");
|
||||
_logInfo.Debug("开始获取单据默认模板...");
|
||||
|
||||
if (!co.GetDefaultVoucherDom(sVouchType, cCardNum, ref domHead, ref domBody, ref domPosition, ref errorMsg) || !string.IsNullOrWhiteSpace(errorMsg))
|
||||
{
|
||||
@@ -74,11 +77,11 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error($"获取单据默认模板失败,错误信息:{ex.Message}", ex);
|
||||
_logInfo.Error($"获取单据默认模板失败,错误信息:{ex.Message}", ex);
|
||||
|
||||
errorMsg = "";
|
||||
|
||||
logInfo.Debug($"开始读取单据数据,当前单据编码:{cCardNum}");
|
||||
_logInfo.Debug($"开始读取单据数据,当前单据编码:{cCardNum}");
|
||||
|
||||
if (!co.Load(sVouchType, "1=2", ref domHead, ref domBody, ref domPosition, ref errorMsg, true) || !string.IsNullOrWhiteSpace(errorMsg))
|
||||
{
|
||||
@@ -87,7 +90,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
|
||||
}
|
||||
|
||||
logInfo.Debug("填充表头DOM...");
|
||||
_logInfo.Debug("填充表头DOM...");
|
||||
|
||||
domHead = dictionary.ToDocument2(domHead);
|
||||
|
||||
@@ -108,7 +111,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
errorMsg = "";
|
||||
var newCode = co.GetNewVouchCode(sVouchType, domHead, ref errorMsg);
|
||||
|
||||
logInfo.Debug($"获取新单号:{newCode}");
|
||||
_logInfo.Debug($"获取新单号:{newCode}");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(newCode))
|
||||
{
|
||||
@@ -116,7 +119,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
}
|
||||
}
|
||||
|
||||
logInfo.Debug("填充表体DOM...");
|
||||
_logInfo.Debug("填充表体DOM...");
|
||||
domBody = dictionarys.ToDocument2(domBody);
|
||||
|
||||
IXMLDOMDocument2 domMsg = new DOMDocument();
|
||||
@@ -132,29 +135,31 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
{
|
||||
if (bPrintDom)
|
||||
{
|
||||
logInfo.Debug("开始输入DOM...");
|
||||
_logInfo.Debug("开始输入DOM...");
|
||||
|
||||
logInfo.Debug(domHead.xml);
|
||||
_logInfo.Debug(domHead.xml);
|
||||
|
||||
logInfo.Debug(domBody.xml);
|
||||
_logInfo.Debug(domBody.xml);
|
||||
|
||||
logInfo.Debug(domPosition.xml);
|
||||
_logInfo.Debug(domPosition.xml);
|
||||
}
|
||||
|
||||
logInfo.Debug("执行插入操作...");
|
||||
_logInfo.Debug("执行插入操作...");
|
||||
res.bSuccess = co.Insert(sVouchType, domHead, domBody, null, ref errorMsg, baseLogin.Connection, ref vouchId, ref domMsg, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote);
|
||||
|
||||
if (res.bSuccess)
|
||||
{
|
||||
res.voucherId = $"{vouchId}";
|
||||
logInfo.Debug($"操作完成,操作结果:成功!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]");
|
||||
_logInfo.Debug($"操作完成,操作结果:成功!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]");
|
||||
|
||||
res.voucherCode = CommonHelper.GetVoucherCode(baseLogin.Connection, vouchId, vouchers);
|
||||
|
||||
if (bAudit)
|
||||
{
|
||||
var res2 = co.Verify(sVouchType, vouchId, ref errorMsg, baseLogin.Connection, null, ref domMsg);
|
||||
_logInfo.Debug($"当前单据号:{res.voucherCode},开始审核操作");
|
||||
|
||||
var res2 = co.Verify(sVouchType, vouchId, ref errorMsg, baseLogin.Connection, null, ref domMsg);
|
||||
|
||||
if (!res2)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(errorMsg))
|
||||
@@ -165,6 +170,94 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
|
||||
throw new Exception("审核单据时发生异常,请检查数据");
|
||||
}
|
||||
|
||||
_logInfo.Debug($"当前单据号:{res.voucherCode},操作完成,操作结果:成功!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]");
|
||||
|
||||
if (bVerify && cCardNum=="0304")
|
||||
{
|
||||
_logInfo.Debug($"0304,当前单据号:{res.voucherCode},开始审核其他出入库单据");
|
||||
|
||||
var strSql = $"select ID,cCode from RdRecord09 where (isnull(iverifystate,0)=0 or dVeriDate is null) and cSource='调拨' and cBusCode='{res.voucherCode}'";
|
||||
|
||||
var rst = new Recordset();
|
||||
|
||||
rst.Open(strSql, baseLogin.Connection);
|
||||
|
||||
if (!rst.BOF && !rst.EOF)
|
||||
{
|
||||
var outId = $"{rst.Fields["ID"].Value}";
|
||||
var outCode = $"{rst.Fields["cCode"].Value}";
|
||||
|
||||
errorMsg = "";
|
||||
domMsg = new DOMDocument();
|
||||
|
||||
_logInfo.Debug($"0304,当前单据号:{res.voucherCode},其他出库单:{outCode},开始审核其他出库单");
|
||||
|
||||
var resOut = co.Verify("09", outId, ref errorMsg, baseLogin.Connection, null, ref domMsg);
|
||||
|
||||
if (!resOut)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(errorMsg))
|
||||
throw new Exception($"审核其他出库单时发生异常,错误信息:{errorMsg}");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(domMsg.xml))
|
||||
throw new Exception($"审核其他出库单时发生异常,零出库控制:{domMsg.xml}");
|
||||
|
||||
throw new Exception("审核其他出库单时发生异常,请检查数据");
|
||||
}
|
||||
|
||||
_logInfo.Debug($"0304,当前单据号:{res.voucherCode},其他出库单:{outCode},审核其他出库单完成,操作结果:成功!------[{outId}]------[{errorMsg}]------[{domMsg.xml}]");
|
||||
}
|
||||
|
||||
rst.Close();
|
||||
|
||||
strSql = $"select ID,cCode from RdRecord08 where (isnull(iverifystate,0)=0 or dVeriDate is null) and cSource='调拨' and cBusCode='{res.voucherCode}'";
|
||||
|
||||
var rst2 = new Recordset();
|
||||
|
||||
rst2.Open(strSql, baseLogin.Connection);
|
||||
|
||||
if (!rst2.BOF && !rst2.EOF)
|
||||
{
|
||||
var inId = $"{rst2.Fields["ID"].Value}";
|
||||
var inCode = $"{rst2.Fields["cCode"].Value}";
|
||||
|
||||
errorMsg = "";
|
||||
domMsg = new DOMDocument();
|
||||
|
||||
_logInfo.Debug($"0304,当前单据号:{res.voucherCode},其他入库单:{inId},开始审核其他入库单");
|
||||
|
||||
var resIn = co.Verify("08", inId, ref errorMsg, baseLogin.Connection, null, ref domMsg);
|
||||
|
||||
if (!resIn)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(errorMsg))
|
||||
throw new Exception($"审核其他入库单时发生异常,错误信息:{errorMsg}");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(domMsg.xml))
|
||||
throw new Exception($"审核其他入库单时发生异常,零出库控制:{domMsg.xml}");
|
||||
|
||||
throw new Exception("审核其他入库单时发生异常,请检查数据");
|
||||
}
|
||||
|
||||
_logInfo.Debug($"0304,当前单据号:{res.voucherCode},其他入库单:{inCode},审核其他入库单完成,操作结果:成功!------[{inId}]------[{errorMsg}]------[{domMsg.xml}]");
|
||||
}
|
||||
|
||||
rst2.Close();
|
||||
}
|
||||
|
||||
//try
|
||||
//{
|
||||
// var strSql = $"UPDATE {vouchers.cBTTblName} SET cHandler = '{dictionary["cmaker"]}' WHERE {vouchers.voucherIdFieldName}={vouchId}";
|
||||
|
||||
// object rsts = new Recordset();
|
||||
|
||||
// baseLogin.Connection.Execute(strSql, out rsts);
|
||||
//}
|
||||
//catch(Exception ex)
|
||||
//{
|
||||
// _logInfo.Error($"更新审核人时发生异常,错误信息:{ex.Message}", ex);
|
||||
//}
|
||||
}
|
||||
|
||||
baseLogin.Connection.CommitTrans();
|
||||
@@ -174,7 +267,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
}
|
||||
else
|
||||
{
|
||||
logInfo.Debug($"操作完成,操作结果:失败!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]");
|
||||
_logInfo.Debug($"操作完成,操作结果:失败!------[{vouchId}]------[{errorMsg}]------[{domMsg.xml}]");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(errorMsg))
|
||||
throw new Exception(errorMsg);
|
||||
@@ -197,7 +290,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
_logInfo.Error(ex.Message, ex);
|
||||
|
||||
await Task.Delay(1);
|
||||
|
||||
@@ -265,13 +358,13 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
|
||||
if (bPrintDom)
|
||||
{
|
||||
logInfo.Debug("开始输入DOM...");
|
||||
_logInfo.Debug("开始输入DOM...");
|
||||
|
||||
logInfo.Debug(domHead.xml);
|
||||
_logInfo.Debug(domHead.xml);
|
||||
|
||||
logInfo.Debug(domBody.xml);
|
||||
_logInfo.Debug(domBody.xml);
|
||||
|
||||
logInfo.Debug(domPosition.xml);
|
||||
_logInfo.Debug(domPosition.xml);
|
||||
}
|
||||
|
||||
//IXMLDOMDocument2 domMsg = new DOMDocument();
|
||||
@@ -312,7 +405,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
_logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
|
||||
}
|
||||
|
||||
@@ -91,9 +91,21 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
/// <exception cref="Exception"></exception>
|
||||
public void Init(LoginParamter paramter, bool bMon = true, int traceTimes = 0)
|
||||
{
|
||||
var lastError = "";
|
||||
|
||||
|
||||
if (traceTimes > 5)
|
||||
throw new Exception("U8登录异常");
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(lastError))
|
||||
{
|
||||
throw new Exception("U8登录异常");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(lastError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
@@ -126,7 +138,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
|
||||
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}");
|
||||
throw new Exception($"U8登录失败---{_vbLogin.ShareString}");
|
||||
}
|
||||
|
||||
_logInfo.Debug($"VB--开始创建连接对象:{_vbLogin.userToken}");
|
||||
@@ -381,7 +393,9 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
{
|
||||
_logInfo.Error($"重试次数:{traceTimes},错误信息:{ex.Message}", ex);
|
||||
|
||||
Init(paramter, bMon, traceTimes + 1);
|
||||
lastError = ex.Message;
|
||||
|
||||
//Init(paramter, bMon, traceTimes + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,8 @@
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -244,5 +246,8 @@
|
||||
<Name>UFIDA.U8.Framework.Api.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -12,4 +12,22 @@
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.serviceModel>
|
||||
<bindings>
|
||||
<basicHttpBinding>
|
||||
<binding name="U8LoginServicesSoap" />
|
||||
<binding name="U8LoginServicesSoap1" />
|
||||
</basicHttpBinding>
|
||||
</bindings>
|
||||
<client>
|
||||
<endpoint address="http://192.168.110.62/U8Application/U8LoginServices.asmx"
|
||||
binding="basicHttpBinding" bindingConfiguration="U8LoginServicesSoap"
|
||||
contract="UFIDA.U8.Framework.Api.U8Service.U8LoginServicesSoap"
|
||||
name="U8LoginServicesSoap" />
|
||||
<endpoint address="http://192.168.110.62/U8Application/U8LoginServices.asmx"
|
||||
binding="basicHttpBinding" bindingConfiguration="U8LoginServicesSoap1"
|
||||
contract="UFIDA.U8.Framework.U8Service.U8LoginServicesSoap"
|
||||
name="U8LoginServicesSoap1" />
|
||||
</client>
|
||||
</system.serviceModel>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user