提交测试
This commit is contained in:
@@ -4,11 +4,15 @@ using MSXML2;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
|
||||||
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
||||||
using UFIDA.U8.Framework.Api.ControlObject.Entity;
|
using UFIDA.U8.Framework.Api.ControlObject.Entity;
|
||||||
using UFIDA.U8.Framework.Api.ControlObject.Json;
|
using UFIDA.U8.Framework.Api.ControlObject.Json;
|
||||||
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
||||||
|
// ReSharper disable StringLiteralTypo
|
||||||
|
// ReSharper disable CommentTypo
|
||||||
|
// ReSharper disable IdentifierTypo
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||||
{
|
{
|
||||||
@@ -20,7 +24,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
|||||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||||
|
|
||||||
|
|
||||||
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)
|
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)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -67,7 +71,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(newCode))
|
if (!string.IsNullOrWhiteSpace(newCode))
|
||||||
{
|
{
|
||||||
object value = CommonHelper.SetDomKeyValue(domHead, codeKey, newCode);
|
CommonHelper.SetDomKeyValue(domHead, codeKey, newCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,67 +88,87 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
|||||||
{
|
{
|
||||||
res.bSuccess = co.Insert(sVouchType, domHead, domBody, domPosition, ref errorMsg, baseLogin.Connection, ref vouchId, ref domMsg, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote);
|
res.bSuccess = co.Insert(sVouchType, domHead, domBody, domPosition, ref errorMsg, baseLogin.Connection, ref vouchId, ref domMsg, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
await Task.Delay(1);
|
await Task.Delay(1);
|
||||||
baseLogin.Connection.RollbackTrans();
|
baseLogin.Connection.RollbackTrans();
|
||||||
throw ex;
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.message = errorMsg;
|
||||||
|
|
||||||
|
if (res.bSuccess && bAudit)
|
||||||
|
{
|
||||||
|
errorMsg = "";
|
||||||
|
|
||||||
|
if (!co.Verify(sVouchType, vouchId,ref errorMsg, baseLogin.Connection))
|
||||||
|
{
|
||||||
|
baseLogin.Connection.RollbackTrans();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(errorMsg))
|
||||||
|
throw new Exception(errorMsg);
|
||||||
|
|
||||||
|
throw new Exception("审核单据时发生异常,请检查数据");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!res.bSuccess)
|
||||||
|
{
|
||||||
|
baseLogin.Connection.RollbackTrans();
|
||||||
|
|
||||||
|
if(!string.IsNullOrWhiteSpace(errorMsg))
|
||||||
|
throw new Exception(errorMsg);
|
||||||
|
|
||||||
|
throw new Exception(domMsg.xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
baseLogin.Connection.CommitTrans();
|
baseLogin.Connection.CommitTrans();
|
||||||
|
|
||||||
if (!res.bSuccess)
|
var rst = new Recordset();
|
||||||
|
rst.Open($"SELECT CardNumber,BTTblName,BTQName,BWTblName,BWQName,VchListQName,VchTblPrimarykeyNames,ReceiptNOFieldName FROM dbo.vouchers WITH(NOLOCK) WHERE CardNumber='{cCardNum}'", baseLogin.Connection);
|
||||||
|
|
||||||
|
if (rst.BOF || rst.EOF)
|
||||||
{
|
{
|
||||||
res.message = "新增失败";
|
res.bSuccess = false;
|
||||||
res.result = errorMsg;
|
res.result = $"已在U8生成单据ID为{vouchId}的单据,但是未能查询到该单据的配置信息!";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var rst = new Recordset();
|
rst.MoveFirst();
|
||||||
rst.Open($"SELECT CardNumber,BTTblName,BTQName,BWTblName,BWQName,VchListQName,VchTblPrimarykeyNames,ReceiptNOFieldName FROM dbo.vouchers WHERE CardNumber='{cCardNum}'", baseLogin.Connection);
|
var fieldName = $"{rst.Fields["VchTblPrimarykeyNames"].Value}";
|
||||||
|
var codeName = $"{rst.Fields["ReceiptNOFieldName"].Value}";
|
||||||
if (rst.BOF || rst.EOF)
|
if (string.IsNullOrWhiteSpace(fieldName) || string.IsNullOrWhiteSpace(codeName))
|
||||||
{
|
{
|
||||||
res.bSuccess = false;
|
res.voucherCode = $"{res.voucherId}";
|
||||||
res.result = $"已在U8生成单据ID为{vouchId}的单据,但是未能查询到该单据的配置信息!";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rst.MoveFirst();
|
if (codeName.Contains("{##}"))
|
||||||
var fieldName = $"{rst.Fields["VchTblPrimarykeyNames"].Value}";
|
|
||||||
var codeName = $"{rst.Fields["ReceiptNOFieldName"].Value}";
|
|
||||||
if (string.IsNullOrWhiteSpace(fieldName) || string.IsNullOrWhiteSpace(codeName))
|
|
||||||
{
|
{
|
||||||
res.voucherCode = $"{res.voucherId}";
|
codeName = codeName.Split('{', '#', '#', '}')[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
var strSql = $"SELECT {codeName} AS cCode FROM {rst.Fields["BTTblName"].Value} WITH(NOLOCK) WHERE {fieldName}='{vouchId}'";
|
||||||
|
rst.Close();
|
||||||
|
|
||||||
|
rst.Open(strSql, baseLogin.Connection);
|
||||||
|
|
||||||
|
if (rst.EOF || rst.BOF)
|
||||||
|
{
|
||||||
|
res.voucherCode = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (codeName.Contains("{##}"))
|
rst.MoveFirst();
|
||||||
{
|
res.voucherCode = $"{rst.Fields["cCode"].Value}";
|
||||||
codeName = codeName.Split('{', '#', '#', '}')[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
var strSql = $"SELECT {codeName} AS cCode FROM {rst.Fields["BTTblName"].Value} WHERE {fieldName}='{vouchId}'";
|
|
||||||
rst.Close();
|
|
||||||
|
|
||||||
rst.Open(strSql, baseLogin.Connection);
|
|
||||||
|
|
||||||
if (rst.EOF || rst.BOF)
|
|
||||||
{
|
|
||||||
res.voucherCode = "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rst.MoveFirst();
|
|
||||||
res.voucherCode = $"{rst.Fields["cCode"].Value}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.message = "新增成功";
|
|
||||||
res.result = vouchId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res.message = "新增成功";
|
||||||
|
res.result = vouchId;
|
||||||
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
//var bodys = dictionary.TryGetValue() dictionary["body"];
|
//var bodys = dictionary.TryGetValue() dictionary["body"];
|
||||||
@@ -205,7 +229,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
|||||||
|
|
||||||
domBody = bodys.ToDocument2(domBody);
|
domBody = bodys.ToDocument2(domBody);
|
||||||
|
|
||||||
IXMLDOMDocument2 domMsg = new DOMDocument();
|
//IXMLDOMDocument2 domMsg = new DOMDocument();
|
||||||
|
|
||||||
errorMsg = "";
|
errorMsg = "";
|
||||||
baseLogin.Connection.BeginTrans();
|
baseLogin.Connection.BeginTrans();
|
||||||
@@ -216,10 +240,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
|||||||
{
|
{
|
||||||
res.bSuccess = co.Update(sVouchType, domHead, domBody, domPosition);
|
res.bSuccess = co.Update(sVouchType, domHead, domBody, domPosition);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
baseLogin.Connection.RollbackTrans();
|
baseLogin.Connection.RollbackTrans();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res.bSuccess)
|
if (!res.bSuccess)
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ using UFIDA.U8.Framework.Api.Unit;
|
|||||||
|
|
||||||
namespace UFIDA.U8.Framework.Api.Controllers.U8
|
namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 平台功能
|
||||||
|
/// </summary>
|
||||||
public class DPController : ApiController
|
public class DPController : ApiController
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,24 +1,27 @@
|
|||||||
using log4net;
|
using log4net;
|
||||||
using log4net.Util;
|
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
using UFIDA.U8.Framework.Api.Common.Entity;
|
using UFIDA.U8.Framework.Api.Common.Entity;
|
||||||
using UFIDA.U8.Framework.Api.ControlObject.AP;
|
|
||||||
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
||||||
using UFIDA.U8.Framework.Api.ControlObject.Entity;
|
using UFIDA.U8.Framework.Api.ControlObject.Entity;
|
||||||
using UFIDA.U8.Framework.Api.ControlObject.Json;
|
using UFIDA.U8.Framework.Api.ControlObject.Json;
|
||||||
using UFIDA.U8.Framework.Api.ControlObject.ST;
|
using UFIDA.U8.Framework.Api.ControlObject.ST;
|
||||||
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
||||||
using UFIDA.U8.Framework.Api.Unit;
|
using UFIDA.U8.Framework.Api.Unit;
|
||||||
|
// ReSharper disable StringLiteralTypo
|
||||||
|
// ReSharper disable IdentifierTypo
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
namespace UFIDA.U8.Framework.Api.Controllers.U8
|
namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 库存管理
|
||||||
|
/// </summary>
|
||||||
public class STController : ApiController
|
public class STController : ApiController
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -31,14 +34,14 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增单据
|
/// 新增单据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cAccId"></param>
|
/// <param name="cAccId">系统号</param>
|
||||||
/// <param name="cCardNum"></param>
|
/// <param name="cCardNum">单据类型编码</param>
|
||||||
/// <param name="input"></param>
|
/// <param name="input">报文</param>
|
||||||
/// <param name="bCheck"></param>
|
/// <param name="bCheck">是否控制可用量</param>
|
||||||
/// <param name="bBeforCheckStock"></param>
|
/// <param name="bBeforCheckStock">是否检查可用量</param>
|
||||||
/// <param name="bIsRedVouch"></param>
|
/// <param name="bIsRedVouch">是否红字单据</param>
|
||||||
/// <param name="sAddedState"></param>
|
/// <param name="sAddedState">传空字符串</param>
|
||||||
/// <param name="bReMote"></param>
|
/// <param name="bReMote">是否远程</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("api/U8/ST/{cCardNum}/Insert")]
|
[Route("api/U8/ST/{cCardNum}/Insert")]
|
||||||
@@ -80,9 +83,9 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
|||||||
|
|
||||||
logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息");
|
logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息");
|
||||||
|
|
||||||
var voucherInfo = db.Queryable<SysU8VoucherDefine>().First(s => s.CardNumber == cCardNum);
|
var voucherInfo = await db.Queryable<SysU8VoucherDefine>().FirstAsync(s => s.CardNumber == cCardNum);
|
||||||
|
|
||||||
var defs = db.Queryable<SysU8FieldDefine>().Where(s => s.CardNumber == cCardNum && s.cPosition == "H" && s.bEnable==true).ToList(); //查询表头字段配置,供后续设置字段值
|
var defs = await db.Queryable<SysU8FieldDefine>().Where(s => s.CardNumber == cCardNum && s.cPosition == "H" && s.bEnable==true).ToListAsync(); //查询表头字段配置,供后续设置字段值
|
||||||
|
|
||||||
var dateKey = "";
|
var dateKey = "";
|
||||||
var exchKey = "";
|
var exchKey = "";
|
||||||
@@ -103,9 +106,9 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
|||||||
|
|
||||||
Exch exch;
|
Exch exch;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(exchKey) && input.ContainsKey(exchKey))
|
if (!string.IsNullOrWhiteSpace(exchKey) && input.TryGetValue(exchKey, out var value))
|
||||||
{
|
{
|
||||||
exch = CommonHelper.GetExch(dDate, param.cAccId, $"{input[exchKey]}", baseLogin.Connection);
|
exch = CommonHelper.GetExch(dDate, param.cAccId, $"{value}", baseLogin.Connection);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -156,7 +159,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
|||||||
throw new Exception("无表体数据!");
|
throw new Exception("无表体数据!");
|
||||||
|
|
||||||
logInfo.Debug($"作业Id:{workId}-----获取表体字段配置");
|
logInfo.Debug($"作业Id:{workId}-----获取表体字段配置");
|
||||||
var defsBody = db.Queryable<SysU8FieldDefine>().Where(s => s.CardNumber == cCardNum && s.cPosition == "B" && s.bEnable==true).ToList(); //获取表体的字段配置
|
var defsBody = await db.Queryable<SysU8FieldDefine>().Where(s => s.CardNumber == cCardNum && s.cPosition == "B" && s.bEnable==true).ToListAsync(); //获取表体的字段配置
|
||||||
|
|
||||||
var rowNo = 1;
|
var rowNo = 1;
|
||||||
|
|
||||||
@@ -237,59 +240,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
|||||||
|
|
||||||
var co = new USERPCO();
|
var co = new USERPCO();
|
||||||
|
|
||||||
var res = await co.Insert(baseLogin, input, cCardNum, voucherInfo.VoucherType, bGetCode, codeKey, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote);
|
var res = await co.Insert(baseLogin, input, cCardNum, voucherInfo.VoucherType, bGetCode, codeKey, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState, bReMote, voucherInfo.bVerify);
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logInfo.Error(ex.Message, ex);
|
|
||||||
|
|
||||||
return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新单据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cAccId"></param>
|
|
||||||
/// <param name="cCardNum"></param>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <param name="bCheck"></param>
|
|
||||||
/// <param name="bBeforCheckStock"></param>
|
|
||||||
/// <param name="bIsRedVouch"></param>
|
|
||||||
/// <param name="sAddedState"></param>
|
|
||||||
/// <param name="bUpdateNeedEas"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost]
|
|
||||||
[Route("api/U8/ST/{cCardNum}/Update")]
|
|
||||||
public async Task<BaseResult<string>> Update(string cAccId, string cCardNum, [FromBody] Dictionary<string, object> input, bool bCheck = true, bool bBeforCheckStock = true, bool bIsRedVouch = false, string sAddedState = "", bool bUpdateNeedEas = true)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin))
|
|
||||||
{
|
|
||||||
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 bo = new USERPCO();
|
|
||||||
|
|
||||||
var res = await bo.Update(baseLogin, input, "0412", "11", bCheck, bBeforCheckStock, bIsRedVouch, sAddedState,
|
|
||||||
bUpdateNeedEas);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user