Browse Source

更新版本

master
zhaoxinyu 10 months ago
parent
commit
54f5814c44
  1. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs
  2. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs
  3. 548
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/InvoiceSyncQadInvocable.cs

@ -42,9 +42,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
{
return;
}
var invoiceSyncQads = _settleAccountDbContext.Set<InvoiceSyncQad>().Where(t => t.TaskState != 2).OrderBy(t => t.CreationTime).Take(1000).ToList();
if (!invoiceSyncQads.Any())
{
_globalConfigOptions.IsSyncInvoiceQadState = false;

5
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs

@ -123,12 +123,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
ediFlagErrEntities.ForEach(t => t.IsHaveSeData = true);
await db.BulkUpdateAsync<BBAC_SE_EDI>(ediFlagErrEntities).ConfigureAwait(false);
}
}
}
/// <summary>

548
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -31,7 +31,9 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Omu.ValueInjecter;
using Org.BouncyCastle.Asn1.Cmp;
using RestSharp.Extensions;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR;
using Shouldly;
@ -85,7 +87,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly TaskJobService _service;
private readonly Volo.Abp.ObjectMapping.IObjectMapper _maper;
protected readonly IExcelImportAppService _excelImportService;
public VmiAppService(IConfiguration cfg,
IServiceProvider serviceProvider,
IGuidGenerator guidGenerator,
@ -105,7 +107,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
ILogger<VmiAppService> logger,
IExcelImportAppService excelImportService,
TaskJobService service
)
@ -240,7 +242,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost]
public async Task<PagedResultDto<VmiBalanceSumDetailDto>> Balance(RequestDto input)
{
var first= input.Filters.FirstOrDefault(p => p.Column == "BillTime");
var first = input.Filters.FirstOrDefault(p => p.Column == "BillTime");
if (first != null)
{
input.Filters.Remove(first);
@ -249,7 +251,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var entities = await _vmiBalanceSumDetailRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
var totalCount = await _vmiBalanceSumDetailRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
var dtos = _maper.Map<List<VmiBalanceSumDetail>, List<VmiBalanceSumDetailDto>>(entities);
dtos=dtos.OrderByDescending(p => p.BillTime).ToList();
dtos = dtos.OrderByDescending(p => p.BillTime).ToList();
return new PagedResultDto<VmiBalanceSumDetailDto>(totalCount, dtos);
}
@ -261,7 +263,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
var entities = await _vmiBalanceSumDetailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount, true).ConfigureAwait(false);
var dtos = _maper.Map<List<VmiBalanceSumDetail>, List<VmiBalanceSumDetailDto>>(entities);
dtos=dtos.OrderByDescending(p => p.BillTime).ToList();
dtos = dtos.OrderByDescending(p => p.BillTime).ToList();
var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx";
var content = this.GetContent(dtos, "库存余额");
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
@ -397,7 +399,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost]
public async Task<PagedResultDto<VmiLog>> Log(LogRequestDto input)
{
var entities = await _logRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount).ConfigureAwait(false);
var totalCount = await _logRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
@ -503,10 +505,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
) on new { temp1.VinCode, temp1.RealPartCode } equals new { temp2.VinCode, temp2.RealPartCode }
where temp1.ChangedQty > 0
select temp1).ToList();
var entities = result.Where(p => p.BillTime >= DateTime.Parse(beginDate) && p.BillTime <= DateTime.Parse(endDate) && p.LogType == VmiLogType.Type100).ToList();
var fileName = $"补货数据_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx";
var content = this.GetContent(entities, "补货数据_");
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
@ -628,7 +630,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
log.ChangedTime = log.Id.ToDateTime().Value.ToLocalTime();
if (log.ChangedQty >= decimal.Zero)
{
if(log.LogType != VmiLogType.Type100)
if (log.LogType != VmiLogType.Type100)
{
log.Qty = log.ChangedQty;
log.LogType = VmiLogType.Type500;
@ -636,21 +638,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
else
{
log.Qty = log.ChangedQty;
log.Qty = log.ChangedQty;
log.ChangedType = VmiType.In;
}
}
else
{
if(log.LogType != VmiLogType.Type100)
if (log.LogType != VmiLogType.Type100)
{
log.Qty = -log.Qty;
log.LogType = VmiLogType.Type600;
log.ChangedType = VmiType.Out;
}
}
log.ChangedBy = this._currentUser.UserName;
}
@ -763,6 +765,526 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
/// <summary>
/// 入库导入导入
/// </summary>
/// <param name="files"></param>
[HttpPost]
public async Task<IActionResult> ImportSE(List<IFormFile> files, EnumBusinessType businessType)
{
try
{
using var ms = new MemoryStream();
var file = files.FirstOrDefault();
await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false);
var data = ms.ToArray();
var tupleList = this.ImportInternal<VmiLog>(data);
if (tupleList.Any(o => o.Item2.Count > 0))
{
using var workbook = new XLWorkbook(new MemoryStream(data));
var ws = workbook.Worksheets.FirstOrDefault();
var header = ws.Row(1);
var errorIndex = ws.ColumnsUsed().Count() + 1;
header.Cell(errorIndex).Value = "提示信息";
for (int i = 0; i < ws.RowsUsed().Count() - 1; i++)
{
ws.Row(i + 2).Cell(errorIndex).Value = string.Join(',', tupleList[i].Item2.Select(o => o.ErrorMessage));
}
SetStyle(ws);
using var stream = new MemoryStream();
workbook.SaveAs(stream);
stream.Seek(0, SeekOrigin.Begin);
var fileName = $"{file.Name}_错误信息.xlsx";
await this._fileContainer.SaveAsync(fileName, stream, true).ConfigureAwait(false);
return new JsonResult(new { code = 400, message = "输入异常", fileName });
}
var logList = tupleList.Select(o => o.Item1).ToList();
logList.AsParallel().ForEach(Update);
if (businessType == EnumBusinessType.JisBBAC)
{
List<BBAC_SE_DETAIL> seDetails = new List<BBAC_SE_DETAIL>();
foreach (var item in logList)
{
if (item.DeliverSubBillType == EnumDeliverSubBillType.BBAC || item.DeliverSubBillType == EnumDeliverSubBillType.BBAC)
{
BBAC_SE_DETAIL seDetail = new BBAC_SE_DETAIL();
seDetail.SetId(item.Id);
seDetail.BeginDate = DateTime.Now;
seDetail.CreationTime = DateTime.Now;
seDetail.IsDeleted = false;
seDetail.Version = int.Parse(item.BillTime?.ToString("yyyyMM"));
seDetail.ShippingDate = (DateTime)item.BillTime;
seDetail.Qty = item.Qty;
seDetail.IsHaveEdiData = false;
seDetail.BusinessType = EnumBusinessType.JisBBAC;
seDetail.AssembleData = (DateTime)item.AssembleData;
seDetail.BillType = 0;
seDetail.DeliverBillType = (EnumDeliverBjBmpBillType)item.DeliverBillType;
seDetail.DeliverSubBillType = (EnumDeliverSubBillType)item.DeliverSubBillType;
seDetail.ProType = 0;
seDetail.State = 0;
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ErpToLoc = item.ErpToLoc;
seDetail.Qty = item.Qty;
seDetail.VinCode = item.VinCode;
seDetail.PN = item.VinCode;
seDetail.LU = item.CustPartCode;
seDetail.CustPartCode = item.CustPartCode;
seDetail.BillTime = item.BillTime;
seDetail.Remark = "期初初始化";
seDetails.Add(seDetail);
}
if (item.DeliverSubBillType == EnumDeliverSubBillType.BBAC || item.DeliverSubBillType == EnumDeliverSubBillType.BBAC)
{
BBAC_SE_DETAIL seDetail = new BBAC_SE_DETAIL();
seDetail.SetId(item.Id);
seDetail.BeginDate = DateTime.Now;
seDetail.CreationTime = DateTime.Now;
seDetail.IsDeleted = false;
seDetail.Version = int.Parse(item.BillTime?.ToString("yyyyMM"));
seDetail.ShippingDate = (DateTime)item.BillTime;
seDetail.Qty = item.Qty;
seDetail.IsHaveEdiData = false;
seDetail.BusinessType = EnumBusinessType.MaiDanJianBBAC;
seDetail.AssembleData = (DateTime)item.AssembleData;
seDetail.BillType = 0;
seDetail.DeliverBillType = (EnumDeliverBjBmpBillType)item.DeliverBillType;
seDetail.DeliverSubBillType = (EnumDeliverSubBillType)item.DeliverSubBillType;
seDetail.ProType = 0;
seDetail.State = 0;
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ErpToLoc = item.ErpToLoc;
seDetail.Qty = item.Qty;
seDetail.VinCode = item.VinCode;
seDetail.PN = item.VinCode;
seDetail.LU = item.CustPartCode;
seDetail.CustPartCode = item.CustPartCode;
seDetail.BillTime = item.BillTime;
seDetail.Remark = "期初初始化";
seDetails.Add(seDetail);
}
}
var result = await CheckBusinessJISLocation(seDetails,businessType).ConfigureAwait(false);
if (result != "ok")
{
return new JsonResult(new { code = 400, message = "发运数据有不再" + result + "库位中" });
}
return await BeginTran(seDetails, logList).ConfigureAwait(false);
}
if (businessType == EnumBusinessType.JisHBPO )
{
List<HBPO_SE_DETAIL> seDetails = new List<HBPO_SE_DETAIL>();
foreach (var item in logList)
{
if (item.DeliverSubBillType == EnumDeliverSubBillType.HBPO || item.DeliverSubBillType == EnumDeliverSubBillType.HBPO)
{
HBPO_SE_DETAIL seDetail = new HBPO_SE_DETAIL();
seDetail.SetId(item.Id);
seDetail.BeginDate = DateTime.Now;
seDetail.CreationTime = DateTime.Now;
seDetail.IsDeleted = false;
seDetail.Version = int.Parse(item.BillTime?.ToString("yyyyMM"));
seDetail.ShippingDate = (DateTime)item.BillTime;
seDetail.Qty = item.Qty;
seDetail.IsHaveEdiData = false;
seDetail.BusinessType = EnumBusinessType.JisHBPO;
seDetail.AssembleData = (DateTime)item.AssembleData;
seDetail.BillType = 0;
seDetail.DeliverBillType = (EnumDeliverBjBmpBillType)item.DeliverBillType;
seDetail.DeliverSubBillType = (EnumDeliverSubBillType)item.DeliverSubBillType;
seDetail.ProType = 0;
seDetail.State = 0;
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ErpToLoc = item.ErpToLoc;
seDetail.Qty = item.Qty;
seDetail.VinCode = item.VinCode;
seDetail.PN = item.VinCode;
seDetail.LU = item.CustPartCode;
seDetail.CustPartCode = item.CustPartCode;
seDetail.BillTime = item.BillTime;
seDetail.Remark = "期初初始化";
seDetails.Add(seDetail);
}
}
var result = await CheckBusinessJISLocation(seDetails, businessType).ConfigureAwait(false);
if (result != "ok")
{
return new JsonResult(new { code = 400, message = "发运数据有不再" + result + "库位中" });
}
return await BeginTran(seDetails, logList).ConfigureAwait(false);
}
if (businessType == EnumBusinessType.MaiDanJianHBPO)
{
List<HBPO_SE_DETAIL> seDetails = new List<HBPO_SE_DETAIL>();
foreach (var item in logList)
{
if (item.DeliverSubBillType == EnumDeliverSubBillType.HBPO || item.DeliverSubBillType == EnumDeliverSubBillType.HBPO)
{
HBPO_SE_DETAIL seDetail = new HBPO_SE_DETAIL();
seDetail.SetId(item.Id);
seDetail.BeginDate = DateTime.Now;
seDetail.CreationTime = DateTime.Now;
seDetail.IsDeleted = false;
seDetail.Version = int.Parse(item.BillTime?.ToString("yyyyMM"));
seDetail.ShippingDate = (DateTime)item.BillTime;
seDetail.Qty = item.Qty;
seDetail.IsHaveEdiData = false;
seDetail.BusinessType = EnumBusinessType.MaiDanJianHBPO;
seDetail.AssembleData = (DateTime)item.AssembleData;
seDetail.BillType = 0;
seDetail.DeliverBillType = (EnumDeliverBjBmpBillType)item.DeliverBillType;
seDetail.DeliverSubBillType = (EnumDeliverSubBillType)item.DeliverSubBillType;
seDetail.ProType = 0;
seDetail.State = 0;
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ErpToLoc = item.ErpToLoc;
seDetail.Qty = item.Qty;
seDetail.VinCode = item.VinCode;
seDetail.PN = item.VinCode;
seDetail.LU = item.CustPartCode;
seDetail.CustPartCode = item.CustPartCode;
seDetail.BillTime = item.BillTime;
seDetail.Remark = "期初初始化";
seDetails.Add(seDetail);
}
}
}
if (businessType == EnumBusinessType.ZhiGongJianBBAC)
{
List<PUB_SE_DETAIL> seDetails = new List<PUB_SE_DETAIL>();
foreach (var item in logList)
{
if (item.DeliverSubBillType == EnumDeliverSubBillType.JIT直供件BBAC)
{
PUB_SE_DETAIL seDetail = new PUB_SE_DETAIL();
seDetail.SetId(item.Id);
seDetail.BeginDate = DateTime.Now;
seDetail.CreationTime = DateTime.Now;
seDetail.IsDeleted = false;
seDetail.Version = int.Parse(item.BillTime?.ToString("yyyyMM"));
seDetail.ShippingDate = (DateTime)item.BillTime;
seDetail.Qty = item.Qty;
seDetail.BusinessType = EnumBusinessType.ZhiGongJianBBAC;
seDetail.AssembleData = (DateTime)item.AssembleData;
seDetail.BillType = 0;
seDetail.DeliverBillType = (EnumDeliverBjBmpBillType)item.DeliverBillType;
seDetail.DeliverSubBillType = (EnumDeliverSubBillType)item.DeliverSubBillType;
seDetail.ProType = 0;
seDetail.State = 0;
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ToErpLocCode = item.ErpToLoc;
seDetail.Qty = item.Qty;
seDetail.PN = item.VinCode;
seDetail.LU = item.CustPartCode;
seDetail.CustPartCode = item.CustPartCode;
seDetail.BillTime = item.BillTime;
seDetail.Remark = "期初初始化";
seDetails.Add(seDetail);
}
}
return await BeginTran(seDetails, logList).ConfigureAwait(false);
}
if (businessType == EnumBusinessType.ZhiGongJianHBPO)
{
List<PUB_SE_DETAIL> seDetails = new List<PUB_SE_DETAIL>();
foreach (var item in logList)
{
if (item.DeliverSubBillType == EnumDeliverSubBillType.JIT直供件HBPO)
{
PUB_SE_DETAIL seDetail = new PUB_SE_DETAIL();
seDetail.SetId(item.Id);
seDetail.BeginDate = DateTime.Now;
seDetail.CreationTime = DateTime.Now;
seDetail.IsDeleted = false;
seDetail.Version = int.Parse(item.BillTime?.ToString("yyyyMM"));
seDetail.ShippingDate = (DateTime)item.BillTime;
seDetail.Qty = item.Qty;
seDetail.BusinessType = EnumBusinessType.ZhiGongJianHBPO;
seDetail.AssembleData = (DateTime)item.AssembleData;
seDetail.BillType = 0;
seDetail.DeliverBillType = (EnumDeliverBjBmpBillType)item.DeliverBillType;
seDetail.DeliverSubBillType = (EnumDeliverSubBillType)item.DeliverSubBillType;
seDetail.ProType = 0;
seDetail.State = 0;
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ToErpLocCode = item.ErpToLoc;
seDetail.Qty = item.Qty;
seDetail.PN = item.VinCode;
seDetail.LU = item.CustPartCode;
seDetail.CustPartCode = item.CustPartCode;
seDetail.BillTime = item.BillTime;
seDetail.Remark = "期初初始化";
seDetails.Add(seDetail);
}
}
return await BeginTran(seDetails, logList).ConfigureAwait(false);
}
if (businessType == EnumBusinessType.BeiJian)
{
List<PUB_SE_DETAIL> seDetails = new List<PUB_SE_DETAIL>();
foreach (var item in logList)
{
if (item.DeliverSubBillType == EnumDeliverSubBillType.4S备件BBAC)
{
PUB_SE_DETAIL seDetail = new PUB_SE_DETAIL();
seDetail.SetId(item.Id);
seDetail.BeginDate = DateTime.Now;
seDetail.CreationTime = DateTime.Now;
seDetail.IsDeleted = false;
seDetail.Version = int.Parse(item.BillTime?.ToString("yyyyMM"));
seDetail.ShippingDate = (DateTime)item.BillTime;
seDetail.Qty = item.Qty;
seDetail.BusinessType = EnumBusinessType.BeiJian;
seDetail.AssembleData = (DateTime)item.AssembleData;
seDetail.BillType = 0;
seDetail.DeliverBillType = (EnumDeliverBjBmpBillType)item.DeliverBillType;
seDetail.DeliverSubBillType = (EnumDeliverSubBillType)item.DeliverSubBillType;
seDetail.ProType = 0;
seDetail.State = 0;
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ToErpLocCode = item.ErpToLoc;
seDetail.Qty = item.Qty;
seDetail.PN = item.VinCode;
seDetail.LU = item.CustPartCode;
seDetail.CustPartCode = item.CustPartCode;
seDetail.BillTime = item.BillTime;
seDetail.Remark = "期初初始化";
seDetails.Add(seDetail);
}
}
return await BeginTran(seDetails, logList).ConfigureAwait(false);
}
if (businessType == EnumBusinessType.YinDuJian)
{
List<PUB_SE_DETAIL> seDetails = new List<PUB_SE_DETAIL>();
foreach (var item in logList)
{
if (item.DeliverSubBillType == EnumDeliverSubBillType.BBAC)
{
PUB_SE_DETAIL seDetail = new PUB_SE_DETAIL();
seDetail.SetId(item.Id);
seDetail.BeginDate = DateTime.Now;
seDetail.CreationTime = DateTime.Now;
seDetail.IsDeleted = false;
seDetail.Version = int.Parse(item.BillTime?.ToString("yyyyMM"));
seDetail.ShippingDate = (DateTime)item.BillTime;
seDetail.Qty = item.Qty;
seDetail.BusinessType = EnumBusinessType.YinDuJian;
seDetail.AssembleData = (DateTime)item.AssembleData;
seDetail.BillType = 0;
seDetail.DeliverBillType = (EnumDeliverBjBmpBillType)item.DeliverBillType;
seDetail.DeliverSubBillType = (EnumDeliverSubBillType)item.DeliverSubBillType;
seDetail.ProType = 0;
seDetail.State = 0;
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ToErpLocCode = item.ErpToLoc;
seDetail.Qty = item.Qty;
seDetail.PN = item.VinCode;
seDetail.LU = item.CustPartCode;
seDetail.CustPartCode = item.CustPartCode;
seDetail.BillTime = item.BillTime;
seDetail.Remark = "期初初始化";
seDetails.Add(seDetail);
}
}
return await BeginTran(seDetails, logList).ConfigureAwait(false);
}
return new JsonResult(new { code = 200, message = "ok" });
}
catch (Exception ex)
{
this._logger.LogError(ex.ToString());
return new JsonResult(new { code = 500, data = ex.ToString(), message = ex.Message }); ;
}
}
/// <summary>
/// 提交事务
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="p_list"></param>
/// <param name="logList"></param>
/// <returns></returns>
private async Task<IActionResult> BeginTran<T>(List<T> p_list, List<VmiLog> logList) where T : SE_BASE, new()
{
//var messageList = logList.Select(log => new VmiMessage { Message = JsonSerializer.Serialize(log) }).ToList();
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var context = new SettleAccountDbContext(options);
var st = new Stopwatch();
st.Start();
try
{
using var transaction = context.Database.BeginTransaction();
var value = _codeRepository.FirstOrDefault(p => p.Project == "库存账期").Value;
foreach (var itm in logList)
{
itm.Version = GetVersionByBillTime(itm.BillTime.Value, value);
}
await context.BulkInsertAsync(p_list).ConfigureAwait(false);
await context.BulkInsertAsync(logList).ConfigureAwait(false);
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex.ToString());
return new JsonResult(new { code = 500, message = ex.ToString() });
}
finally
{
st.Stop();
this._logger.LogInformation($"事务结束,耗时 ${st.ElapsedMilliseconds / 1000 / 60}分钟");
}
return new JsonResult(new { code = 200, message = "ok" });
}
/// <summary>
/// JIS业务校验库位
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="p_list"></param>
/// <param name="enumBusinessType"></param>
/// <returns></returns>
private async Task<string> CheckBusinessJISLocation<T>(List<T> p_list, EnumBusinessType enumBusinessType) where T : JisSeBase, new()
{
var locList = _codeRepository.Where(p => p.Project == "库位").ToList();
switch (enumBusinessType)
{
case EnumBusinessType.JisBBAC:
locList = locList.Where(p =>
p.Value == "JisBBAC顺义" ||
p.Value == "JisBBAC" ||
p.Value == "MaiDanJianBBAC" ||
p.Value == "MaiDanJianBBAC顺义"
).ToList();
break;
case EnumBusinessType.JisHBPO:
locList = locList.Where(p =>
p.Value == "JisHBPO"
).ToList();
break;
case EnumBusinessType.MaiDanJianHBPO:
locList = locList.Where(p => p.Value == "MaiDanJianHBPO").ToList();
break;
case EnumBusinessType.ZhiGongJianBBAC:
locList = locList.Where(p => p.Value == "ZhiGongJianBBAC顺义" || p.Value == "ZhiGongJianBBAC").ToList();
break;
case EnumBusinessType.ZhiGongJianHBPO:
locList = locList.Where(p => p.Value == "ZhiGongJianHBPO").ToList();
break;
case EnumBusinessType.BeiJian:
locList = locList.Where(p => p.Value =="BeiJian").ToList();
break;
case EnumBusinessType.YinDuJian:
locList = locList.Where(p => p.Value == "YinDuJian").ToList();
break;
}
var locs = locList.Select(p => p.Description).ToList();
if (p_list.Any(p => !locs.Contains(p.ErpToLoc)))
{
return string.Join(",", locs);
}
return "ok" ;
}
/// <summary>
/// JIS业务校验库位
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="p_list"></param>
/// <param name="enumBusinessType"></param>
/// <returns></returns>
private async Task<string> CheckBusinessPUBLocation<T>(List<PUB_SE_DETAIL> p_list, EnumBusinessType enumBusinessType)
{
var locList = _codeRepository.Where(p => p.Project == "库位").ToList();
switch (enumBusinessType)
{
case EnumBusinessType.JisBBAC:
locList = locList.Where(p =>
p.Value == "JisBBAC顺义" ||
p.Value == "JisBBAC" ||
p.Value == "MaiDanJianBBAC" ||
p.Value == "MaiDanJianBBAC顺义"
).ToList();
break;
case EnumBusinessType.JisHBPO:
locList = locList.Where(p =>
p.Value == "JisHBPO"
).ToList();
break;
case EnumBusinessType.MaiDanJianHBPO:
locList = locList.Where(p => p.Value == "MaiDanJianHBPO").ToList();
break;
case EnumBusinessType.ZhiGongJianBBAC:
locList = locList.Where(p => p.Value == "ZhiGongJianBBAC顺义" || p.Value == "ZhiGongJianBBAC").ToList();
break;
case EnumBusinessType.ZhiGongJianHBPO:
locList = locList.Where(p => p.Value == "ZhiGongJianHBPO").ToList();
break;
case EnumBusinessType.BeiJian:
locList = locList.Where(p => p.Value == "BeiJian").ToList();
break;
case EnumBusinessType.YinDuJian:
locList = locList.Where(p => p.Value == "YinDuJian").ToList();
break;
}
var locs = locList.Select(p => p.Description).ToList();
if (p_list.Any(p => !locs.Contains(p.ToErpLocCode)))
{
return string.Join(",",locs) ;
}
return "ok";
}
/// <summary>
/// 库存调整导入

Loading…
Cancel
Save