增加交易唯一码,方便在网络状态不佳的情况下重新获取操作结果

This commit is contained in:
qmj
2026-05-26 08:45:24 +08:00
parent 8208ba7488
commit 42e6579447
30 changed files with 2891 additions and 374 deletions
@@ -13,28 +13,31 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
{
public class BEHelper
{
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
protected readonly ILog _logInfo = LogManager.GetLogger("logInfo");
private readonly dynamic _be;
private readonly PropertyInfo[] _props;
private string _invCode;
private string _free1;
private string _free2;
private string _free3;
private string _free4;
private string _free5;
private string _free6;
private string _free7;
private string _free8;
private string _free9;
private string _free10;
private string _invCode="";
private string _free1 = "";
private string _free2 = "";
private string _free3 = "";
private string _free4 = "";
private string _free5 = "";
private string _free6 = "";
private string _free7 = "";
private string _free8 = "";
private string _free9 = "";
private string _free10 = "";
private int _bomVersion;
private readonly string _cCardNum;
public BEHelper(dynamic be)
public BEHelper(dynamic be, string cCardNum="")
{
_be = be;
var tp = be.GetType();
_props = tp.GetProperties();
_cCardNum = cCardNum;
}
public void SetValue(Dictionary<string,object> dictionary)
@@ -42,7 +45,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
foreach (var key in dictionary.Keys)
{
if(key != "body")
logInfo.Debug($"正在设置字段:{key}--{dictionary[key]}");
_logInfo.Debug($"正在设置字段:{key}--{dictionary[key]}");
if (key.Contains("define") && !key.Contains("chdefine") && !key.Contains("cbdefine"))
{
@@ -60,7 +63,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
{
_be.ExtendUserDefineItem[defineCode] = dictionary[key];
}
} else if (key.Contains("cbdefine"))
}
else if (key.Contains("cbdefine"))
{
var defineCode = int.Parse(key.Replace("cbdefine", ""));
@@ -68,7 +72,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
{
_be.ExtendUserDefineItem[defineCode] = dictionary[key];
}
}else if (key.Contains("free"))
}
else if (key.Contains("free"))
{
var freeCode = int.Parse(key.Replace("free", ""));
@@ -80,7 +85,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
if (string.Equals(key, "invCode", StringComparison.OrdinalIgnoreCase))
{
_invCode = $"{dictionary[key]}";
}else if (string.Equals(key, "bomversion", StringComparison.OrdinalIgnoreCase))
}
else if (string.Equals(key, "bomversion", StringComparison.OrdinalIgnoreCase))
{
_bomVersion = int.Parse($"{dictionary[key]}");
}
@@ -141,5 +147,14 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
{
_be.SetBomId(_be.PartId, _bomVersion);
}
public void SetMoAllocateId()
{
if (_cCardNum == "MO39")
{
_be.SetMoAllocateId(_be.PartId);
}
}
}
}
@@ -1,17 +1,15 @@
using System;
using ADODB;
using GetComObj;
using log4net;
using Microsoft.VisualBasic.CompilerServices;
using MSXML2;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Web.UI.WebControls;
using ADODB;
using GetComObj;
using log4net;
using Microsoft.VisualBasic.CompilerServices;
using MSXML2;
using Newtonsoft.Json.Linq;
using UFIDA.U8.Framework.Api.Common.Entity;
using UFIDA.U8.Framework.Api.ControlObject.Entity;
using UFIDA.U8.Framework.Api.ControlObject.Json;
@@ -89,7 +87,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
return obj;
}
public static dynamic ToVoucherData(this Dictionary<string,object> dict,dynamic obj)
public static dynamic ToVoucherData(this Dictionary<string, object> dict, dynamic obj)
{
foreach (var dictKey in dict.Keys)
{
@@ -215,7 +213,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
// //}
//}
public static IXMLDOMDocument2 ToDocument2(this Dictionary<string,object> dictionary,IXMLDOMDocument2 domDocument2=null)
public static IXMLDOMDocument2 ToDocument2(this Dictionary<string, object> dictionary, IXMLDOMDocument2 domDocument2 = null)
{
if (domDocument2 == null)
@@ -233,7 +231,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
}
public static IXMLDOMNode SetRowData(this Dictionary<string, object> dictionary, IXMLDOMDocument2 domDocument2 = null,string bodyKey="body")
public static IXMLDOMNode SetRowData(this Dictionary<string, object> dictionary, IXMLDOMDocument2 domDocument2 = null, string bodyKey = "body")
{
if (domDocument2 == null)
{
@@ -244,7 +242,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
foreach (var key in dictionary.Keys)
{
if(key==bodyKey)
if (key == bodyKey)
continue;
var attr = domDocument2.createAttribute(key);
@@ -304,16 +302,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
return root;
}
public static object SetDomKeyValue(this IXMLDOMDocument2 domDocument2,string key,object value)
public static object SetDomKeyValue(this IXMLDOMDocument2 domDocument2, string key, object value)
{
var node= domDocument2.selectSingleNode("//z:row");
var node = domDocument2.selectSingleNode("//z:row");
if (node == null)
return null;
var attr = domDocument2.createAttribute(key);
attr.nodeValue=value;
attr.nodeValue = value;
node.attributes.setNamedItem(attr);
@@ -325,9 +323,9 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
{
if (dictionary.ContainsKey(bodyKey))
{
var body= dictionary[bodyKey].ToJson().ToList<Dictionary<string,object>>();
var body = dictionary[bodyKey].ToJson().ToList<Dictionary<string, object>>();
dictionary[bodyKey] = body;
dictionary[bodyKey] = body;
}
}
@@ -568,9 +566,11 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
var val = cPrecision == null
? dt.Compute(calcFormula, "")
: Math.Round(Convert.ToDecimal(dt.Compute(calcFormula, "")), cPrecision ?? 6); //计算公式结果
: Math.Round(Convert.ToDecimal(dt.Compute(calcFormula, "")), cPrecision ?? 6, MidpointRounding.AwayFromZero); //计算公式结果
dict[def.FieldName] = val;
_logInfo.Debug($"字段:{def.FieldName}公式:{calcFormula},公式结果:{val}");
}
catch (Exception ex)
{
@@ -657,7 +657,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
/// <param name="cCardNum">单据类型编码</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static VouchersInfo GetVouchers(Connection conn,string cCardNum)
public static VouchersInfo GetVouchers(Connection conn, string cCardNum)
{
if (conn == null) throw new ArgumentNullException(nameof(conn));
if (cCardNum == null) throw new ArgumentNullException(nameof(cCardNum));
@@ -698,7 +698,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
}
res.cCodeFieldName = codeName;
res.voucherIdFieldName= $"{rst.Fields["VchTblPrimarykeyNames"].Value}";
res.voucherIdFieldName = $"{rst.Fields["VchTblPrimarykeyNames"].Value}";
rst.Close();
@@ -713,7 +713,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
/// <param name="vouchers">单据配置信息</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static string GetVoucherCode(Connection conn,object voucherId, VouchersInfo vouchers)
public static string GetVoucherCode(Connection conn, object voucherId, VouchersInfo vouchers)
{
if (conn == null) throw new ArgumentNullException(nameof(conn));
if (voucherId == null) throw new ArgumentNullException(nameof(voucherId));
@@ -742,6 +742,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
var cCode = $"{rst.Fields["cCode"].Value}";
rst.Close();
return cCode;
}
@@ -785,6 +787,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
var voucherId = rst.Fields["ID"].Value;
rst.Close();
return voucherId;
}
@@ -797,7 +801,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
/// <param name="eventId">事件Id</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static string GetEventId(Connection conn, string cCardNum,string eventId,bool bUAP =false)
public static string GetEventId(Connection conn, string cCardNum, string eventId, bool bUAP = false)
{
if (conn == null) throw new ArgumentNullException(nameof(conn));
if (cCardNum == null) throw new ArgumentNullException(nameof(cCardNum));
@@ -824,11 +828,13 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
var voucherId = rst.Fields["cBizEventId"].Value;
rst.Close();
return voucherId;
}
public static string GetVoucherWhereSqlByCode(VouchersInfo vouchers,string cVoucherCode)
public static string GetVoucherWhereSqlByCode(VouchersInfo vouchers, string cVoucherCode)
{
var tableName = vouchers.cBTTblName;
var fieldName = vouchers.voucherIdFieldName;
@@ -865,11 +871,11 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
return $"{cDefWhere} AND {tableName}.{fieldName}='{voucherId}'";
}
public static string GetQuerySql(VouchersInfo vouchers, Dictionary<string, object> input, string cCardPostion="H")
public static string GetQuerySql(VouchersInfo vouchers, Dictionary<string, object> input, string cCardPostion = "H")
{
var cBTQName = vouchers.cBTQName;
var cBWQName = vouchers.cBWQName;
var voucherIdFieldName = vouchers.voucherIdFieldName;
var tableName = cBTQName;