增加审核参数

This commit is contained in:
qmj
2025-08-28 00:44:34 +08:00
parent b2121a1afb
commit 0720f7a904
24 changed files with 3549 additions and 140 deletions
@@ -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
{
/// <summary>
/// 日志组件
/// </summary>
private readonly ILog _logInfo = LogManager.GetLogger("logInfo");
private static readonly MemoryCache _cache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(10) });
/// <summary>
/// 保存单据
/// </summary>
/// <param name="cAccId">系统号</param>
/// <param name="cCardNum">单据类型编码</param>
/// <param name="input">报文</param>
/// <param name="VoucherState">单据状态:0新增,1修改</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
[HttpPost]
[Route("api/U8/SA/{cCardNum}/Save")]
public async Task<BaseResult<string>> Save(string cAccId, string cCardNum, [FromBody] Dictionary<string, object> 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<SysU8VoucherDefine>().FirstAsync(s => s.CardNumber == cCardNum);
var defs = await db.Queryable<SysU8FieldDefine>().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<Dictionary<string, object>>(); //读取表体的数据
if (bodyData == null || bodyData.Count <= 0)
throw new Exception("无表体数据!");
_logInfo.Debug($"作业Id:{workId}-----获取表体字段配置");
var defsBody = await db.Queryable<SysU8FieldDefine>().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<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
}
}
}
}