1.修复多账套对接时报工切换账套不生效(严重bug)
2.切换底层逻辑,增加外部增加数据源的接口 3.增加缓存,减少频繁登录导致可能存在的突发数据库连接异常
This commit is contained in:
@@ -0,0 +1,186 @@
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Models;
|
||||
using UFIDA.U8.Framework.Api.Models;
|
||||
using UFIDA.U8.Framework.Api.Unit;
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable IdentifierTypo
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.Controllers
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 公共服务
|
||||
/// </summary>
|
||||
public class CommonController : ApiController
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志对象
|
||||
/// </summary>
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
/// <summary>
|
||||
/// 获取加密字符串
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("api/Common/GetEncryptString")]
|
||||
public BaseResult<string> GetEncryptString(string input)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new BaseResult<string> { bSuccess = true, message = "加密成功", result = CommUnit.GetEncrypt(input) };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<string> { bSuccess = true, message = "加密失败", result = ex.Message };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取解密字符串
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("api/Common/GetDecryptString")]
|
||||
public BaseResult<string> GetDecryptString(string input)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new BaseResult<string> { bSuccess = true, message = "解密成功", result = CommUnit.GetDecrypt(input) };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<string> { bSuccess = true, message = "解密失败", result =ex.Message };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取对接账套设置
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/Common/GetAccountConfig")]
|
||||
public async Task<BaseResult<dynamic>> GetAccountConfig([FromBody]U8AccountConfigInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = CommUnit.GetDbClient();
|
||||
|
||||
var res=await db.Queryable<Common.Entity.SysU8AccountConfig>()
|
||||
.Where(a => a.cAccountNo == input.cAccId)
|
||||
.FirstAsync();
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = false, message = "查询成功", result = res };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = false, message = "查询失败", result = ex.Message };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增对接账套设置
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/Common/AddAccountConfig")]
|
||||
public async Task<BaseResult<dynamic>> AddAccountConfig([FromBody] AddU8AccountConfigInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = CommUnit.GetDbClient();
|
||||
|
||||
var isExists = await db.Queryable<SysU8AccountConfig>().AnyAsync(a => a.cAccountNo == input.cAccountNo);
|
||||
|
||||
if (isExists)
|
||||
{
|
||||
throw new Exception($"已存在系统号为{input.cAccountNo}的数据");
|
||||
}
|
||||
|
||||
var id = await db.Insertable(input).ExecuteReturnIdentityAsync();
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = true, message = "新增成功", result = id };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = false, message = "新增失败", result = ex.Message };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新对接账套设置
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/Common/UpdateAccountConfig")]
|
||||
public async Task<BaseResult<dynamic>> UpdateAccountConfig([FromBody]AddU8AccountConfigInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = CommUnit.GetDbClient();
|
||||
|
||||
var isExists = await db.Queryable<Common.Entity.SysU8AccountConfig>().AnyAsync(a => a.Id==input.Id);
|
||||
|
||||
if (!isExists)
|
||||
{
|
||||
throw new Exception($"不存在系统号为{input.cAccountNo}的数据");
|
||||
}
|
||||
|
||||
var id = await db.Updateable(input).ExecuteCommandAsync();
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = true, message = "更新成功", result = id };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = false, message = "更新失败", result = ex.Message };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取对接账套设置列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/Common/ListAccountConfig")]
|
||||
public async Task<BaseResult<dynamic>> ListAccountConfig([FromBody] ListU8AccountConfigInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = CommUnit.GetDbClient();
|
||||
|
||||
var res =await db.Queryable<Common.Entity.SysU8AccountConfig>()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.cAccId), a => a.cAccountNo == input.cAccId)
|
||||
.ToListAsync();
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = true, message = "查询成功", result = res };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = false, message = "查询失败", result = ex.Message };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,18 @@
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using SqlSugar;
|
||||
using UFIDA.U8.Framework.Api.Common.Unit.GM;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Models;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
||||
using UFIDA.U8.Framework.Api.Unit;
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
{
|
||||
@@ -16,6 +23,8 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
{
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
private static MemoryCache _cache = new MemoryCache(new MemoryCacheOptions() { ExpirationScanFrequency = TimeSpan.FromMinutes(10) });
|
||||
|
||||
/// <summary>
|
||||
/// 新增单据
|
||||
/// </summary>
|
||||
@@ -25,19 +34,56 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/U8/SFC/Save")]
|
||||
public BaseResult<string> Save(string cAccId,string cCardNum, [FromBody] Dictionary<string, object> voucherData)
|
||||
public async Task<BaseResult<dynamic>> Save(string cAccId,string cCardNum, [FromBody] Dictionary<string, object> input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db=
|
||||
if (!_cache.TryGetValue($"U8M_Single", out BaseLogin baseLogin))
|
||||
{
|
||||
baseLogin = new BaseLogin();
|
||||
|
||||
var param = await CommUnit.GetLoginParamter(cAccId);
|
||||
|
||||
if (param == null)
|
||||
{
|
||||
throw new Exception("未能加载指定系统号的登录信息");
|
||||
}
|
||||
|
||||
baseLogin.Init(param);
|
||||
|
||||
_cache.Set("U8M_Single", baseLogin);
|
||||
}
|
||||
else
|
||||
{
|
||||
var param = await CommUnit.GetLoginParamter(cAccId);
|
||||
|
||||
if (param == null)
|
||||
{
|
||||
throw new Exception("未能加载指定系统号的登录信息");
|
||||
}
|
||||
|
||||
if (!baseLogin.CheckAccId(param.pAccId))
|
||||
{
|
||||
baseLogin.ShutDown();
|
||||
baseLogin.Init(param);
|
||||
}
|
||||
_cache.Remove("U8M_Single");
|
||||
_cache.Set("U8M_Single", baseLogin);
|
||||
}
|
||||
|
||||
var bf = new MoRoutingBill();
|
||||
|
||||
var res=bf.Save( cCardNum, input);
|
||||
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<string>(){bSuccess = false,message = ex.Message,result = ex.StackTrace};
|
||||
return new BaseResult<dynamic> {bSuccess = false,message = ex.Message,result = ex.StackTrace};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.Controllers
|
||||
{
|
||||
public class ValuesController : ApiController
|
||||
{
|
||||
// GET api/values
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
// GET api/values/5
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
}
|
||||
|
||||
// POST api/values
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT api/values/5
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/values/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user