93 lines
2.8 KiB
C#
93 lines
2.8 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 车间管理
|
|
/// </summary>
|
|
public class SFCController : ApiController
|
|
{
|
|
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
|
|
|
private static MemoryCache _cache = new MemoryCache(new MemoryCacheOptions() { ExpirationScanFrequency = TimeSpan.FromMinutes(10) });
|
|
|
|
/// <summary>
|
|
/// 新增单据
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="voucherData">报文数据</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("api/U8/SFC/Save")]
|
|
public async Task<BaseResult<dynamic>> Save(string cAccId,string cCardNum, [FromBody] Dictionary<string, object> input)
|
|
{
|
|
try
|
|
{
|
|
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<dynamic> {bSuccess = false,message = ex.Message,result = ex.StackTrace};
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|