843 lines
36 KiB
C#
843 lines
36 KiB
C#
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 log4net;
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
using SqlSugar;
|
|
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.ST;
|
|
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
|
using UFIDA.U8.Framework.Api.Models;
|
|
using UFIDA.U8.Framework.Api.Unit;
|
|
|
|
namespace UFIDA.U8.Framework.Api.Controllers.U8
|
|
{
|
|
/// <summary>
|
|
/// 采购管理
|
|
/// </summary>
|
|
public class PUController : ApiController
|
|
{
|
|
/// <summary>
|
|
/// 日志组件
|
|
/// </summary>
|
|
protected 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="bPositive">红蓝标识:True,蓝字</param>
|
|
/// <param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
|
|
/// <param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
|
|
/// <param name="VoucherState">单据状态:2新增,1修改,0非编辑</param>
|
|
/// <param name="UserMode">CS 0,BS 1;一般CS</param>
|
|
/// <param name="sOverDetailsXml">为空</param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
[HttpPost]
|
|
[Route("api/U8/PU/{cCardNum}/VoucherSave")]
|
|
public async Task<BaseResult<string>> VoucherSave(string cAccId, string cCardNum, [FromBody] Dictionary<string, object> input, bool bPositive = true, string sBillType = null, string sBusType = "", int VoucherState = 2, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
|
|
{
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:新增,对接账套:{cAccId},数据:{input.ToJson()}");
|
|
|
|
//LoginParamter param;
|
|
|
|
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);
|
|
}
|
|
//else
|
|
//{
|
|
// param = await CommUnit.GetLoginParamter(cAccId);
|
|
//}
|
|
|
|
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_PU();
|
|
|
|
var res = await co.VoucherSave(baseLogin, input, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), bPositive, sBillType, sBusType, VoucherState, UserMode, sOverDetailsXml, bGetCode, codeKey, voucherInfo.bVerify, voucherInfo.bPrintDom,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 };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 审核单据(单号)
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="cCode">单号</param>
|
|
/// <param name="bPositive">红蓝标识:True,蓝字</param>
|
|
/// <param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
|
|
/// <param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
|
|
/// <param name="UserMode">CS 0,BS 1;一般CS</param>
|
|
/// <param name="sOverDetailsXml">为空</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("api/U8/PU/{cCardNum}/Confirm/Code")]
|
|
public async Task<BaseResult<string>> Confirm(string cAccId, string cCardNum, string cCode, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
|
|
{
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:审核,对接账套:{cAccId},单号:{cCode}");
|
|
|
|
//LoginParamter param;
|
|
|
|
if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin) || baseLogin == null)
|
|
{
|
|
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);
|
|
}
|
|
//else
|
|
//{
|
|
// param = await CommUnit.GetLoginParamter(cAccId);
|
|
//}
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息");
|
|
|
|
var voucherInfo = await db.Queryable<SysU8VoucherDefine>().FirstAsync(s => s.CardNumber == cCardNum);
|
|
|
|
var co = new clsVoucherCO_PU();
|
|
|
|
return await co.Confirm(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), cCode, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<string> { bSuccess = false, message = "审核失败", result = ex.Message };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 审核单据(ID)
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="voucherId">单据ID</param>
|
|
/// <param name="bPositive">红蓝标识:True,蓝字</param>
|
|
/// <param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
|
|
/// <param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
|
|
/// <param name="UserMode">CS 0,BS 1;一般CS</param>
|
|
/// <param name="sOverDetailsXml">为空</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("api/U8/PU/{cCardNum}/Confirm/ID")]
|
|
public async Task<BaseResult<string>> Confirm(string cAccId, string cCardNum, long voucherId, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
|
|
{
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:审核,对接账套:{cAccId},ID:{voucherId}");
|
|
|
|
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 co = new clsVoucherCO_PU();
|
|
|
|
return await co.Confirm(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), voucherId, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<string> { bSuccess = false, message = "审核失败", result = ex.Message };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 审核单据(批量)
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="input">报文</param>
|
|
/// <param name="bPositive">红蓝标识:True,蓝字</param>
|
|
/// <param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
|
|
/// <param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
|
|
/// <param name="UserMode">CS 0,BS 1;一般CS</param>
|
|
/// <param name="sOverDetailsXml">为空</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("api/U8/PU/{cCardNum}/Confirm")]
|
|
public async Task<BaseResult<List<BaseResult<string>>>> Confirm(string cAccId, string cCardNum, [FromBody] STInput input, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
|
|
{
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
if (input == null)
|
|
{
|
|
throw new Exception("参数不能为空");
|
|
}
|
|
|
|
var cCodes = input.cCode;
|
|
|
|
var voucherIds = input.voucherId;
|
|
|
|
if ((cCodes == null || cCodes.Count <= 0) && (voucherIds == null || voucherIds.Count <= 0))
|
|
{
|
|
throw new Exception("没有数据需要审核");
|
|
}
|
|
|
|
var strCode = "";
|
|
var strId = "";
|
|
|
|
var apiType = cCodes == null || cCodes.Count <= 0 ? 1 : 0;
|
|
|
|
if (cCodes != null && cCodes.Count > 0)
|
|
{
|
|
strCode = string.Join(",", cCodes);
|
|
}
|
|
|
|
if (voucherIds != null && voucherIds.Count > 0)
|
|
{
|
|
strId = string.Join(",", voucherIds);
|
|
}
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:审核,对接账套:{cAccId},单号:{strCode},ID:{strId}");
|
|
|
|
//LoginParamter param;
|
|
|
|
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);
|
|
}
|
|
//else
|
|
//{
|
|
// param = await CommUnit.GetLoginParamter(cAccId);
|
|
//}
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息");
|
|
|
|
var voucherInfo = await db.Queryable<SysU8VoucherDefine>().FirstAsync(s => s.CardNumber == cCardNum);
|
|
|
|
var co = new clsVoucherCO_PU();
|
|
|
|
var result = apiType == 0
|
|
? await co.Confirm(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), cCodes, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml)
|
|
: await co.Confirm(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), voucherIds, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
|
|
|
|
var res = new BaseResult<List<BaseResult<string>>>()
|
|
{
|
|
bSuccess = true,
|
|
message = "审核完成",
|
|
result = result
|
|
};
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<List<BaseResult<string>>> { bSuccess = false, message = ex.Message, result = null };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 弃审单据(单号)
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="cCode">单号</param>
|
|
/// <param name="bPositive">红蓝标识:True,蓝字</param>
|
|
/// <param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
|
|
/// <param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
|
|
/// <param name="UserMode">CS 0,BS 1;一般CS</param>
|
|
/// <param name="sOverDetailsXml">为空</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("api/U8/PU/{cCardNum}/CancelConfirm/Code")]
|
|
public async Task<BaseResult<string>> CancelConfirm(string cAccId, string cCardNum, string cCode, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
|
|
{
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:弃审,对接账套:{cAccId},单号:{cCode}");
|
|
|
|
if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin) || baseLogin == null)
|
|
{
|
|
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 co = new clsVoucherCO_PU();
|
|
|
|
return await co.CancelConfirm(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), cCode, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<string> { bSuccess = false, message = "弃审失败", result = ex.Message };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 弃审单据(ID)
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="voucherId">单据ID</param>
|
|
/// <param name="bPositive">红蓝标识:True,蓝字</param>
|
|
/// <param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
|
|
/// <param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
|
|
/// <param name="UserMode">CS 0,BS 1;一般CS</param>
|
|
/// <param name="sOverDetailsXml">为空</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("api/U8/PU/{cCardNum}/CancelConfirm/ID")]
|
|
public async Task<BaseResult<string>> CancelConfirm(string cAccId, string cCardNum, long voucherId, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
|
|
{
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:弃审,对接账套:{cAccId},ID:{voucherId}");
|
|
|
|
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 co = new clsVoucherCO_PU();
|
|
|
|
return await co.CancelConfirm(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), voucherId, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<string> { bSuccess = false, message = "弃审失败", result = ex.Message };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 弃审单据(批量)
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="input">报文</param>
|
|
/// <param name="bPositive">红蓝标识:True,蓝字</param>
|
|
/// <param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
|
|
/// <param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
|
|
/// <param name="UserMode">CS 0,BS 1;一般CS</param>
|
|
/// <param name="sOverDetailsXml">为空</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("api/U8/PU/{cCardNum}/CancelConfirm")]
|
|
public async Task<BaseResult<List<BaseResult<string>>>> CancelConfirm(string cAccId, string cCardNum, [FromBody] STInput input, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
|
|
{
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
if (input == null)
|
|
{
|
|
throw new Exception("参数不能为空");
|
|
}
|
|
|
|
var cCodes = input.cCode;
|
|
|
|
var voucherIds = input.voucherId;
|
|
|
|
if ((cCodes == null || cCodes.Count <= 0) && (voucherIds == null || voucherIds.Count <= 0))
|
|
{
|
|
throw new Exception("没有数据需要弃审");
|
|
}
|
|
|
|
var strCode = "";
|
|
var strId = "";
|
|
|
|
var apiType = cCodes == null || cCodes.Count <= 0 ? 1 : 0;
|
|
|
|
if (cCodes != null && cCodes.Count > 0)
|
|
{
|
|
strCode = string.Join(",", cCodes);
|
|
}
|
|
|
|
if (voucherIds != null && voucherIds.Count > 0)
|
|
{
|
|
strId = string.Join(",", voucherIds);
|
|
}
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:弃审,对接账套:{cAccId},单号:{strCode},ID:{strId}");
|
|
|
|
//LoginParamter param;
|
|
|
|
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);
|
|
}
|
|
//else
|
|
//{
|
|
// param = await CommUnit.GetLoginParamter(cAccId);
|
|
//}
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息");
|
|
|
|
var voucherInfo = await db.Queryable<SysU8VoucherDefine>().FirstAsync(s => s.CardNumber == cCardNum);
|
|
|
|
var co = new clsVoucherCO_PU();
|
|
|
|
var result = apiType == 0
|
|
? await co.CancelConfirm(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), cCodes, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml)
|
|
: await co.CancelConfirm(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), voucherIds, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
|
|
|
|
var res = new BaseResult<List<BaseResult<string>>>()
|
|
{
|
|
bSuccess = true,
|
|
message = "弃审完成",
|
|
result = result
|
|
};
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<List<BaseResult<string>>> { bSuccess = false, message = ex.Message, result = null };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除单据(单号)
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="cCode">单号</param>
|
|
/// <param name="bPositive">红蓝标识:True,蓝字</param>
|
|
/// <param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
|
|
/// <param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
|
|
/// <param name="UserMode">CS 0,BS 1;一般CS</param>
|
|
/// <param name="sOverDetailsXml">为空</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("api/U8/PU/{cCardNum}/Delete/Code")]
|
|
public async Task<BaseResult<string>> Delete(string cAccId, string cCardNum, string cCode, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
|
|
{
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:删除,对接账套:{cAccId},单号:{cCode}");
|
|
|
|
if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin) || baseLogin == null)
|
|
{
|
|
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 co = new clsVoucherCO_PU();
|
|
|
|
return await co.Delete(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), cCode, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<string> { bSuccess = false, message = "删除失败", result = ex.Message };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除单据(ID)
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="voucherId">单据ID</param>
|
|
/// <param name="bPositive">红蓝标识:True,蓝字</param>
|
|
/// <param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
|
|
/// <param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
|
|
/// <param name="UserMode">CS 0,BS 1;一般CS</param>
|
|
/// <param name="sOverDetailsXml">为空</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("api/U8/PU/{cCardNum}/Delete/ID")]
|
|
public async Task<BaseResult<string>> Delete(string cAccId, string cCardNum, long voucherId, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
|
|
{
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:删除,对接账套:{cAccId},ID:{voucherId}");
|
|
|
|
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 co = new clsVoucherCO_PU();
|
|
|
|
return await co.Delete(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), voucherId, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<string> { bSuccess = false, message = "删除失败", result = ex.Message };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除单据(批量)
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="input">报文</param>
|
|
/// <param name="bPositive">红蓝标识:True,蓝字</param>
|
|
/// <param name="sBillType">发票类型(普通发票 ppurbill,专用发票 purbill,运费发票 ypurbill);到货单类型(到货单 0,退货单 1,拒收单 2)</param>
|
|
/// <param name="sBusType">业务类型:普通采购,直运采购,受托代销</param>
|
|
/// <param name="UserMode">CS 0,BS 1;一般CS</param>
|
|
/// <param name="sOverDetailsXml">为空</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("api/U8/PU/{cCardNum}/Delete")]
|
|
public async Task<BaseResult<List<BaseResult<string>>>> Delete(string cAccId, string cCardNum, [FromBody] STInput input, bool bPositive = true, string sBillType = null, string sBusType = null, UseMode UserMode = UseMode.CS, string sOverDetailsXml = null)
|
|
{
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
if (input == null)
|
|
{
|
|
throw new Exception("参数不能为空");
|
|
}
|
|
|
|
var cCodes = input.cCode;
|
|
|
|
var voucherIds = input.voucherId;
|
|
|
|
if ((cCodes == null || cCodes.Count <= 0) && (voucherIds == null || voucherIds.Count <= 0))
|
|
{
|
|
throw new Exception("没有数据需要弃审");
|
|
}
|
|
|
|
var strCode = "";
|
|
var strId = "";
|
|
|
|
var apiType = cCodes == null || cCodes.Count <= 0 ? 1 : 0;
|
|
|
|
if (cCodes != null && cCodes.Count > 0)
|
|
{
|
|
strCode = string.Join(",", cCodes);
|
|
}
|
|
|
|
if (voucherIds != null && voucherIds.Count > 0)
|
|
{
|
|
strId = string.Join(",", voucherIds);
|
|
}
|
|
|
|
logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:删除,对接账套:{cAccId},单号:{strCode},ID:{strId}");
|
|
|
|
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 co = new clsVoucherCO_PU();
|
|
|
|
var result = apiType == 0
|
|
? await co.Delete(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), cCodes, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml)
|
|
: await co.Delete(baseLogin, cCardNum, (vouchertype)Convert.ToInt32(voucherInfo.VoucherType), voucherIds, bPositive, sBillType, sBusType, UserMode, sOverDetailsXml);
|
|
|
|
var res = new BaseResult<List<BaseResult<string>>>()
|
|
{
|
|
bSuccess = true,
|
|
message = "删除完成",
|
|
result = result
|
|
};
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<List<BaseResult<string>>> { bSuccess = false, message = ex.Message, result = null };
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|