1123 lines
47 KiB
C#
1123 lines
47 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;
|
|
using static System.Runtime.CompilerServices.RuntimeHelpers;
|
|
|
|
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)
|
|
{
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
try
|
|
{
|
|
var db = CommUnit.GetDbClient();
|
|
|
|
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 };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询特定单据部分
|
|
/// </summary>
|
|
/// <param name="cAccId">系统号</param>
|
|
/// <param name="cCardNum">单据类型编码</param>
|
|
/// <param name="input">查询条件</param>
|
|
/// <param name="cCardPostion">查询所属区域 H:表头,B:表体, L:列表</param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
[HttpPost]
|
|
[Route("api/U8/PU/{cCardNum}/Load")]
|
|
[Route("api/U8/PU/{cCardNum}/Load/{cCardPostion}")]
|
|
public async Task<BaseResult<dynamic>> Load(string cAccId, string cCardNum, [FromBody] Dictionary<string, object> input, string cCardPostion = "H")
|
|
{
|
|
var workId = SnowFlakeSingle.Instance.NextId();
|
|
|
|
try
|
|
{
|
|
_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);
|
|
}
|
|
|
|
var vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cCardNum);
|
|
|
|
if (vouchers == null)
|
|
{
|
|
throw new Exception("未能获取到单据配置信息");
|
|
}
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet,
|
|
IsAutoCloseConnection = true,
|
|
MoreSettings = new ConnMoreSettings()
|
|
{
|
|
IsWithNoLockQuery = true
|
|
}
|
|
});
|
|
|
|
var cBTQName = vouchers.cBTQName;
|
|
var cBWQName = vouchers.cBWQName;
|
|
var cBTTblName = vouchers.cBTTblName;
|
|
var cBWTblName = vouchers.cBWTblName;
|
|
var voucherIdFieldName = vouchers.voucherIdFieldName;
|
|
var vouchersIdFieldName = "";
|
|
var tableName = cBTQName;
|
|
var colsHeadList=new List<string>();
|
|
var colsBodyList=new List<string>();
|
|
var bExtHead = false;
|
|
var bExtBody = false;
|
|
|
|
if (cCardPostion == "H")
|
|
{
|
|
tableName = cBTQName;
|
|
}
|
|
|
|
if (cCardPostion == "B")
|
|
{
|
|
tableName = cBWQName;
|
|
}
|
|
|
|
if (cCardPostion == "L")
|
|
{
|
|
tableName = cBWQName;
|
|
}
|
|
|
|
|
|
|
|
var cDefWhere = vouchers.cDefWhere;
|
|
|
|
var query = db.Queryable<dynamic>().AS(cBTQName, cBTQName);
|
|
|
|
if (!string.IsNullOrWhiteSpace(cBWQName))
|
|
{
|
|
query.AddJoinInfo(cBWQName, cBWQName, $"{cBTQName}.[{voucherIdFieldName}]={cBWQName}.[{voucherIdFieldName}]");
|
|
|
|
var bodyCols = db.DbMaintenance.GetColumnInfosByTableName(cBWQName);
|
|
|
|
if (bodyCols != null && bodyCols.Count > 0)
|
|
{
|
|
colsBodyList.AddRange(from col in bodyCols where !col.DbColumnName.ToLower().Contains("ufts") && col.DbColumnName.ToLower()!=voucherIdFieldName select $"{cBWQName}.[{col.DbColumnName.ToLower()}]");
|
|
|
|
if (cCardPostion == "B" && !colsBodyList.Contains(voucherIdFieldName.ToLower()))
|
|
{
|
|
colsBodyList.Add($"{cBWQName}.[{voucherIdFieldName.ToLower()}]");
|
|
}
|
|
}
|
|
}
|
|
|
|
var headCols = db.DbMaintenance.GetColumnInfosByTableName(cBTQName);
|
|
|
|
if(headCols!=null && headCols.Count > 0)
|
|
{
|
|
colsHeadList.AddRange(from col in headCols where !col.DbColumnName.ToLower().Contains("ufts") select $"{cBTQName}.[{col.DbColumnName}]");
|
|
}
|
|
|
|
if (db.DbMaintenance.IsAnyTable($"{cBTTblName}_extradefine", false))
|
|
{
|
|
bExtHead = true;
|
|
var cols = db.DbMaintenance.GetColumnInfosByTableName($"{cBTTblName}_extradefine");
|
|
|
|
if (cols != null && cols.Count > 0)
|
|
{
|
|
foreach (var col in cols)
|
|
{
|
|
if (col.DbColumnName.ToLower().StartsWith("chdefine"))
|
|
{
|
|
colsHeadList.Add($"{cBTTblName}_extradefine.[{col.DbColumnName.ToLower()}]");
|
|
}
|
|
else
|
|
{
|
|
vouchersIdFieldName = col.DbColumnName;
|
|
}
|
|
}
|
|
}
|
|
|
|
query.AddJoinInfo($"{cBTTblName}_extradefine", $"{cBTTblName}_extradefine", $"{cBTQName}.[{voucherIdFieldName}]={cBTTblName}_extradefine.[{voucherIdFieldName}]");
|
|
}
|
|
|
|
if (db.DbMaintenance.IsAnyTable($"{cBWTblName}_extradefine", false))
|
|
{
|
|
bExtBody = true;
|
|
var cols= db.DbMaintenance.GetColumnInfosByTableName($"{cBWTblName}_extradefine");
|
|
|
|
if (cols != null && cols.Count > 0)
|
|
{
|
|
foreach (var col in cols)
|
|
{
|
|
if (col.DbColumnName.ToLower().StartsWith("cbdefine"))
|
|
{
|
|
colsBodyList.Add($"{cBWTblName}_extradefine.[{col.DbColumnName.ToLower()}]");
|
|
}
|
|
else
|
|
{
|
|
vouchersIdFieldName = col.DbColumnName;
|
|
}
|
|
}
|
|
}
|
|
|
|
query.AddJoinInfo($"{cBWTblName}_extradefine", $"{cBWTblName}_extradefine", $"{cBWQName}.[{vouchersIdFieldName}]={cBWTblName}_extradefine.[{vouchersIdFieldName}]");
|
|
}
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if (o.Key == "dModifyDate")
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = "caudittime",
|
|
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
|
FieldValue = $"{o.Value}"
|
|
});
|
|
}
|
|
else if(o.Key == "dModifyDate__2")
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = "caudittime",
|
|
ConditionalType = ConditionalType.LessThanOrEqual,
|
|
FieldValue = $"{o.Value}"
|
|
});
|
|
}
|
|
else if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
FieldValue = $"{o.Value}"
|
|
});
|
|
}
|
|
else if (o.Key.EndsWith("__2"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key.Replace("__2", "")}",
|
|
ConditionalType = ConditionalType.LessThanOrEqual,
|
|
FieldValue = $"{o.Value}"
|
|
});
|
|
}
|
|
else if (input.ContainsKey($"{o.Key}__2"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
|
FieldValue = $"{o.Value}"
|
|
});
|
|
}
|
|
else
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = o.Key,
|
|
ConditionalType = ConditionalType.Equal,
|
|
FieldValue = $"{o.Value}"
|
|
});
|
|
}
|
|
}
|
|
|
|
query.Where(conModels);
|
|
}
|
|
|
|
query.Where(cDefWhere);
|
|
|
|
if (cCardPostion == "H")
|
|
{
|
|
if (bExtHead)
|
|
{
|
|
query.Select($"{string.Join(",", colsHeadList)}").Distinct();
|
|
}
|
|
else
|
|
{
|
|
query.Select($"{string.Join(",", colsHeadList)}").Distinct();
|
|
}
|
|
}
|
|
|
|
if (cCardPostion == "B")
|
|
{
|
|
if (bExtBody)
|
|
{
|
|
query.Select($"{string.Join(",",colsBodyList)}").Distinct();
|
|
}
|
|
else
|
|
{
|
|
query.Select($"{string.Join(",", colsBodyList)}").Distinct();
|
|
}
|
|
}
|
|
|
|
if (cCardPostion == "L")
|
|
{
|
|
colsBodyList.AddRange(colsHeadList);
|
|
|
|
if (bExtBody)
|
|
{
|
|
query.Select($"{string.Join(",",colsBodyList)}").Distinct();
|
|
}
|
|
else
|
|
{
|
|
query.Select($"{string.Join(",", colsBodyList)}").Distinct();
|
|
}
|
|
}
|
|
|
|
_logInfo.Debug(query.ToSqlString());
|
|
|
|
return new BaseResult<dynamic>() { bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<dynamic> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|