zhouhongjun 5 months ago
parent
commit
cf249a357b
  1. 23
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  2. 23
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  3. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  4. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  5. 22
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs
  6. 629
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  7. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs
  8. 9
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SecMatchSummaryDapperReportRepository.cs

23
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs

@ -113,31 +113,13 @@ namespace Win.Sfs.SettleAccount.Bases
input.Filters.Remove(itm);
}
}
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
var dtoDetails = ObjectMapper.Map<List<TEntityDetail>, List<TEntityDetailExportDto>>(entities);
var classDisplayName = typeof(TEntityDetailExportDto).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(TEntityDetailExportDto).Name;
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx";
byte[] result = null;
//switch (input.FileType)
//{
// case 0:
// result = await _csv.ExportAsByteArray(dtoDetails).ConfigureAwait(false);
// break;
// case 1:
// result = await _excel.ExportAsByteArray(dtoDetails).ConfigureAwait(false);
// break;
//}
result = await _excel.ExportAsByteArray(dtoDetails).ConfigureAwait(false);
result.ShouldNotBeNull();
@ -176,11 +158,6 @@ namespace Win.Sfs.SettleAccount.Bases
var entitys = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount).ConfigureAwait(false);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<TEntity>, List<TEntityDto>>(entitys);
return new PagedResultDto<TEntityDto>(totalCount, dtos);
}
[UnitOfWork(false)]

23
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs

@ -173,7 +173,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
else//二次开票
{
var flag = await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
{
KeyCode = p.KeyCode,
Version = p.Version,
SettleBillNum = p.SettleBillNum,
LU = p.LU,
PN = p.PN,
Site = p.Site,
Qty = p.Qty,
Price = p.Price,
BusinessType = p.BusinessType,
IsReturn = "",
InvGroupNum = p.InvGroupNum,
SettleDate = p.SettleDate,
GroupNum = p.GroupNum,
ContractDocID = string.Empty,
PartCode = p.PartCode
}).ToList();//不能结算
var falg = await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
//var flag = await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
}
}
}

9
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -1841,9 +1841,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if ( first.BusinessType == EnumBusinessType.YinDuJian || first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
{
if (jitunsettle != null)
{
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
{
jitunsettle = jitunsettle.Where(p => p.State == "可结算").ToList();
_excel.Append(jitunsettle, "未结零件汇总");
}
else
{
_excel.Append(jitunsettle, "未结零件汇总");
}
}
if (m != null)
{
_excel.Append(m, "发票结算分组对应");//发票分组对应结算号

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs

@ -235,7 +235,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
PartCode = p.PartCode
}).ToList();//不能结算
await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType,notlist).ConfigureAwait(false);
}

22
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs

@ -129,7 +129,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
LU = g.Key.LU,
Qty = g.Sum(p => p.Qty),
};
var invs = SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, query.ToList());
var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
{
KeyCode = p.KeyCode,
Version = p.Version,
SettleBillNum = p.SettleBillNum,
LU = p.LU,
PN = p.PN,
Site = p.Site,
Qty = p.Qty,
Price = p.Price,
BusinessType = p.BusinessType,
IsReturn = "",
InvGroupNum = p.InvGroupNum,
SettleDate = p.SettleDate,
GroupNum = p.GroupNum,
ContractDocID = string.Empty,
PartCode = p.PartCode
}).ToList();//不能结算
var invs = FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
//var invs = SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, query.ToList());
if (invs.Count > 0)
{
main.State = SettleBillState.;

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

@ -53,6 +53,7 @@ using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.BlobStoring;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Guids;
@ -65,10 +66,12 @@ using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.Entities.CodeSettings;
using Win.Sfs.SettleAccount.Entities.SecMatch;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared;
using Win.Sfs.Shared.DomainBase;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
@ -316,11 +319,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return await ExtendExcel<VmiBalanceSumDetailDto>.WriteDataToExcelInParallel("库存余额", dtos, 500000).ConfigureAwait(false);
//return fileName;
}
@ -727,49 +725,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
log.ChangedBy = this._currentUser.UserName;
}
//private int GetVersionByTimeSpan(DateTime p_begintime,DateTime p_endtime, string p_day)
//{
// var before = p_billtime.Year;
// var last = before - 1;
// DateTime lastYear = DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//上期时间
// DateTime beforeYear = DateTime.ParseExact(string.Format("{0}-12-{1} 07:59:59", before, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//这期时间
// //var result = seDetails
// // .Select(log =>
// // {
// string version = null;
// if (p_billtime >= lastYear && p_billtime <= lastYear.AddMonths(1))
// {
// version = $"{before.ToString()}01";
// }
// else if (p_billtime >= lastYear.AddMonths(1) && p_billtime <= lastYear.AddMonths(2))
// { version = $"{before.ToString()}02"; }
// else if (p_billtime >= lastYear.AddMonths(2) && p_billtime <= lastYear.AddMonths(3))
// { version = $"{before.ToString()}03"; }
// else if (p_billtime >= lastYear.AddMonths(3) && p_billtime <= lastYear.AddMonths(4))
// { version = $"{before.ToString()}04"; }
// else if (p_billtime >= lastYear.AddMonths(4) && p_billtime <= lastYear.AddMonths(5))
// { version = $"{before.ToString()}05"; }
// else if (p_billtime >= lastYear.AddMonths(5) && p_billtime <= lastYear.AddMonths(6))
// { version = $"{before.ToString()}06"; }
// else if (p_billtime >= lastYear.AddMonths(6) && p_billtime <= lastYear.AddMonths(7))
// { version = $"{before.ToString()}07"; }
// else if (p_billtime >= lastYear.AddMonths(7) && p_billtime <= lastYear.AddMonths(8))
// { version = $"{before.ToString()}08"; }
// else if (p_billtime >= lastYear.AddMonths(8) && p_billtime <= lastYear.AddMonths(9))
// { version = $"{before.ToString()}09"; }
// else if (p_billtime >= lastYear.AddMonths(9) && p_billtime <= lastYear.AddMonths(10))
// { version = $"{before.ToString()}10"; }
// else if (p_billtime >= lastYear.AddMonths(10) && p_billtime <= lastYear.AddMonths(11))
// { version = $"{before.ToString()}11"; }
// else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= beforeYear)
// { version = $"{before.ToString()}12"; }
// if (string.IsNullOrEmpty(version))
// {
// return 200802;//找不到的数据默认写到这个区间
// }
// return int.Parse(version);
//}
private int GetVersionByBillTime(DateTime p_billtime, string p_day)
{
@ -1273,7 +1229,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
itm.BillTime = DateTime.Now;
itm.ChangedTime = DateTime.Now;
itm.LogType = itm.Qty > 0 ? VmiLogType.Type100 : VmiLogType.Type300;
itm.LogType = itm.Qty > 0 ? VmiLogType.Type100 : VmiLogType.Type400;
itm.ChangedQty = itm.Qty;
itm.Version = GetVersionByBillTime(itm.BillTime.Value, value);
}
@ -1430,279 +1386,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
logList.AsParallel().ForEach(Update);
//List<BBAC_SE_DETAIL> seDetails = new List<BBAC_SE_DETAIL>();
//List<HBPO_SE_DETAIL> hbpo_seDetails=new List<HBPO_SE_DETAIL>();
//List<PUB_SE_DETAIL> pub_seDetails=new List<PUB_SE_DETAIL>();
//foreach (var item in logList)
//{
// if(item.DeliverBillType== EnumDeliverBjBmpBillType.JIS件&&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(DateTime.Now.ToString("yyyyMM"));
// seDetail.ShippingDate = (DateTime)DateTime.Now;
// 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= DateTime.Now;
// seDetail.Remark = "期初初始化";
// seDetails.Add(seDetail);
// }
// if (item.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && 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(DateTime.Now.ToString("yyyyMM"));
// seDetail.ShippingDate = (DateTime)DateTime.Now;
// 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 = DateTime.Now;
// seDetail.Remark = "期初初始化";
// seDetails.Add(seDetail);
// }
// if (item.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && 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(DateTime.Now.ToString("yyyyMM"));
// seDetail.ShippingDate = (DateTime)DateTime.Now;
// 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 = DateTime.Now;
// seDetail.Remark = "期初初始化";
// hbpo_seDetails.Add(seDetail);
// }
// if (item.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && 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(DateTime.Now.ToString("yyyyMM"));
// seDetail.ShippingDate = (DateTime)DateTime.Now;
// 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 = DateTime.Now;
// seDetail.Remark = "期初初始化";
// hbpo_seDetails.Add(seDetail);
// }
// if (item.DeliverBillType == EnumDeliverBjBmpBillType.JIT直供件 && 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(DateTime.Now?.ToString("yyyyMM"));
// seDetail.ShippingDate = (DateTime)DateTime.Now;
// seDetail.Qty = item.Qty;
// //seDetail.IsHaveEdiData = false;
// 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.VinCode = item.VinCode;
// seDetail.PN = item.VinCode;
// seDetail.LU = item.CustPartCode;
// seDetail.CustPartCode = item.CustPartCode;
// seDetail.BillTime = DateTime.Now;
// seDetail.Remark = "期初初始化";
// pub_seDetails.Add(seDetail);
// }
// if (item.DeliverBillType == EnumDeliverBjBmpBillType.JIT直供件 && 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(DateTime.Now?.ToString("yyyyMM"));
// seDetail.ShippingDate = (DateTime)DateTime.Now;
// seDetail.Qty = item.Qty;
// //seDetail.IsHaveEdiData = false;
// 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.VinCode = item.VinCode;
// seDetail.PN = item.VinCode;
// seDetail.LU = item.CustPartCode;
// seDetail.CustPartCode = item.CustPartCode;
// seDetail.BillTime = DateTime.Now;
// seDetail.Remark = "期初初始化";
// pub_seDetails.Add(seDetail);
// }
// if (item.DeliverBillType == EnumDeliverBjBmpBillType.北汽4S备件 && 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(DateTime.Now?.ToString("yyyyMM"));
// seDetail.ShippingDate = (DateTime)DateTime.Now;
// seDetail.Qty = item.Qty;
// //seDetail.IsHaveEdiData = false;
// 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.VinCode = item.VinCode;
// seDetail.PN = item.VinCode;
// seDetail.LU = item.CustPartCode;
// seDetail.CustPartCode = item.CustPartCode;
// seDetail.BillTime = DateTime.Now;
// seDetail.Remark = "期初初始化";
// pub_seDetails.Add(seDetail);
// }
// if (item.DeliverBillType == EnumDeliverBjBmpBillType.印度件 && 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(DateTime.Now?.ToString("yyyyMM"));
// seDetail.ShippingDate = (DateTime)DateTime.Now;
// seDetail.Qty = item.Qty;
// //seDetail.IsHaveEdiData = false;
// 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.VinCode = item.VinCode;
// seDetail.PN = item.VinCode;
// seDetail.LU = item.CustPartCode;
// seDetail.CustPartCode = item.CustPartCode;
// seDetail.BillTime = DateTime.Now;
// seDetail.Remark = "期初初始化";
// pub_seDetails.Add(seDetail);
// }
//}
//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);
@ -1711,22 +1394,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
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(logList).ConfigureAwait(false);
//await context.BulkInsertAsync(messageList).ConfigureAwait(false);
//await context.BulkInsertAsync(seDetails).ConfigureAwait(false);
//await context.BulkInsertAsync(hbpo_seDetails).ConfigureAwait(false);
//await context.BulkInsertAsync(pub_seDetails).ConfigureAwait(false);
transaction.Commit();
}
catch (Exception ex)
@ -1789,10 +1462,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
using var context = new SettleAccountDbContext(options);
var st = new Stopwatch();
st.Start();
try
{
//导入日志和消息
@ -1822,6 +1491,262 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
}
private async Task<List<ShipReceiveSum>> GetBusinessSum(IServiceProvider serviceProvider,EnumBusinessType p_businessType, string sebegin, string seend, string sabegin, string saend)
{
List<ShipReceiveSum> ls = new List<ShipReceiveSum>();
var connectionString = serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new Microsoft.Data.SqlClient.SqlConnection(connectionString);
connection.Open();
var command = connection.CreateCommand();
string satablename = string.Empty;
string setablename = string.Empty;
string sanottablename = string.Empty;
string businesstype = string.Empty;
switch (p_businessType)
{
case EnumBusinessType.JisBBAC:
satablename = "Set_BBAC_CAN_SA_DETAIL";
setablename = "Set_BBAC_SE_DETAIL";
sanottablename= "Set_BBAC_NOT_SA_DETAIL";
break;
case EnumBusinessType.JisHBPO:
satablename = "Set_HBPO_CAN_SA_DETAIL";
setablename = "Set_HBPO_SE_DETAIL";
sanottablename = "Set_HBPO_NOT_SA_DETAIL";
break;
case EnumBusinessType.MaiDanJianHBPO:
satablename = "Set_HBPO_CAN_SA_DETAIL";
setablename = "Set_HBPO_SE_DETAIL";
sanottablename = "Set_HBPO_NOT_SA_DETAIL";
break;
case EnumBusinessType.MaiDanJianBBAC:
satablename = "Set_BBAC_CAN_SA_DETAIL";
setablename = "Set_BBAC_SE_DETAIL";
sanottablename = "Set_BBAC_NOT_SA_DETAIL";
break;
default:
satablename = "Set_PUB_CAN_SA_DETAIL";
setablename = "Set_PUB_SE_DETAIL";
sanottablename = "Set_PUB_NOT_SA_DETAIL";
break;
}
string sql =
"select lu,\n" +
"SUM(BSEQty) BSEQty\n" +
",SUM(BRETQty) BRETQty\n" +
",SUM(SEQTY) SEQTY\n" +
",SUM(RETQty) RETQty\n" +
",SUM(CANQty) CANQty\n" +
",SUM(NOTQty) NOTQty\n" +
",SUM(SE_SA_CAN_QTY) SE_SA_CAN_QTY\n" +
",SUM(SE_SA_NOT_QTY) SE_SA_NOT_QTY\n" +
",SUM(ONLY_SE_QTY) ONLY_SE_QTY\n" +
",SUM(ONLY_SA_QTY) ONLY_SA_QTY\n" +
",SUM(INVQty) INVQty\n" +
"FROM (\n" +
"select temp1.*,case WHEN ISNULL(TEMP2.InvbillNum,'')<>'' THEN isnull(temp2.Qty,0) ELSE 0 END invQty from (\n" +
"select LU,PN,\n" +
"ISNULL([10],0) BSEQty,\n" +
"ISNULL([20],0) BRETQty,\n" +
"isnull([100],0) SEQty ,\n" +
"isnull([150],0) RETQty,\n" +
"isnull([200],0) CANQty,\n" +
"isnull([800],0) NOTQty,\n" +
"case when ISNULL([10],0)+isnull([20],0)+isnull([100],0)+ISNULL([150],0)-ISNULL([200],0)=0 then ISNULL([100],0)\n" +
"ELSE 0 END SE_SA_CAN_QTY,\n" +
"case when ISNULL([10],0)+isnull([20],0)+isnull([100],0)+ISNULL([150],0)-ISNULL([800],0)=0 then ISNULL([100],0)\n" +
"ELSE 0 END SE_SA_NOT_QTY,\n" +
"case when ISNULL([10],0)+isnull([20],0)+isnull([100],0)+ISNULL([150],0)-ISNULL([200],0)-ISNULL([800],0)>0 then ISNULL([100],0)\n" +
"ElSE 0 END SE_SA_DIFF_QTY,\n" +
"case when ISNULL([10],0)+isnull([20],0)+isnull([100],0)+ISNULL([150],0)-ISNULL([200],0)-ISNULL([800],0)=isnull([100],0)+ISNULL([150],0) then \n" +
"ISNULL([10],0)+isnull([20],0)+isnull([100],0)+ISNULL([150],0)-ISNULL([200],0)-ISNULL([800],0)\n" +
"ElSE 0 END ONLY_SE_QTY,\n" +
"case when ISNULL([10],0)+isnull([20],0)+isnull([100],0)+ISNULL([150],0)-ISNULL([200],0)-ISNULL([800],0)=-ISNULL([200],0)-ISNULL([800],0) then \n" +
"ISNULL([200],0)+ISNULL([800],0) \n" +
"ElSE 0 END ONLY_SA_QTY \n" +
"from (\n" +
"SELECT LU,PN,BusinessType,Qty,10 Type \n" +
$"from {setablename} A WITH(NOLOCK) where BusinessType={(int)p_businessType} AND Qty>0 AND REMARK='期初初始化' \n";
if (!string.IsNullOrEmpty(sebegin))
{
sql += $" AND BillTime >= '{sebegin}'\n";
}
if (!string.IsNullOrEmpty(seend))
{
sql += $" AND BillTime <='{seend}'\n";
}
sql +=
"UNION ALL\n" +
"SELECT LU,PN,BusinessType,Qty,20 Type\n" +
$"from {setablename} A WITH(NOLOCK) where BusinessType={(int)p_businessType} AND Qty<0 and Remark='期初初始化' \n";
if (!string.IsNullOrEmpty(sebegin))
{
sql += $" AND BillTime >= '{sebegin}'\n";
}
if (!string.IsNullOrEmpty(seend))
{
sql += $" AND BillTime <='{seend}'\n";
}
sql +=
"UNION ALL\n" +
"SELECT LU,PN,BusinessType,Qty,100 Type\n" +
$"from {setablename} A WITH(NOLOCK) where BusinessType={(int)p_businessType} AND Qty>0 AND REMARK<>'期初初始化' \n";
if (!string.IsNullOrEmpty(sebegin))
{
sql += $" AND BillTime >= '{sebegin}'\n";
}
if (!string.IsNullOrEmpty(seend))
{
sql += $" AND BillTime <='{seend}'\n";
}
sql += "UNION ALL\n" +
"SELECT LU,PN,BusinessType,Qty,150 Type\n" +
$"from {setablename} A WITH(NOLOCK) where BusinessType={(int)p_businessType} AND Qty<0 and Remark<>'期初初始化' \n";
if (!string.IsNullOrEmpty(sebegin))
{
sql += $" AND BillTime >= '{sebegin}'\n";
}
if (!string.IsNullOrEmpty(seend))
{
sql += $" AND BillTime <='{seend}'\n";
}
sql += "UNION ALL\n" +
"SELECT LU,PN,BusinessType,Qty,200 Type\n" +
$"from {satablename} A WITH(NOLOCK) WHERE BusinessType={(int)p_businessType} \n";
if (!string.IsNullOrEmpty(sabegin))
{
sql += $" AND SettleDate >='{sabegin}'\n";
}
if (!string.IsNullOrEmpty(saend))
{
sql += $" AND SettleDate <='{saend}'\n";
}
sql += "UNION ALL\n" +
"SELECT LU,PN,BusinessType,Qty,800 Type\n" +
$"from {sanottablename} A WITH(NOLOCK) WHERE BusinessType={(int)p_businessType} \n";
if (!string.IsNullOrEmpty(sabegin))
{
sql += $" AND SettleDate >='{sabegin}'\n";
}
if (!string.IsNullOrEmpty(saend))
{
sql += $" AND SettleDate <='{saend}'\n";
}
sql += ") a\n" +
"PIVOT (\n" +
"SUM(qty)\n" +
"FOR Type IN ([10],[20],[100],[150],[200],[800])\n" +
") AS piv\n" +
$") temp1 left join (select LU,PN,InvbillNum,Qty from {satablename} where BusinessType={(int)p_businessType}) temp2 on temp1.PN=temp2.PN and temp1.LU=temp2.LU\n" +
") tempsum group by LU\n";
command.CommandText = sql;
command.CommandTimeout = 1200;
var reader = command.ExecuteReader();
while (reader.Read())
{
ShipReceiveSum shipReceiveSum = new ShipReceiveSum();
shipReceiveSum.LU = reader.GetString(0);
shipReceiveSum.PartCode = "";
shipReceiveSum.BusinessType = p_businessType.ToString();
shipReceiveSum.BSEQty = reader.GetDecimal(1).ToString();
shipReceiveSum.BRETQty = reader.GetDecimal(2).ToString();
shipReceiveSum.SEQTY = reader.GetDecimal(3).ToString();
shipReceiveSum.RETQty = reader.GetDecimal(4).ToString();
shipReceiveSum.CANQty = reader.GetDecimal(5).ToString();
shipReceiveSum.NOTQty = reader.GetDecimal(6).ToString();
shipReceiveSum.SE_SA_CAN_QTY = reader.GetDecimal(7).ToString();
shipReceiveSum.SE_SA_NOT_QTY = reader.GetDecimal(8).ToString();
shipReceiveSum.ONLY_SE_QTY = reader.GetDecimal(9).ToString();
shipReceiveSum.ONLY_SA_QTY = reader.GetDecimal(10).ToString();
shipReceiveSum.INVQty = reader.GetDecimal(11).ToString();
ls.Add(shipReceiveSum);
// result += reader.GetString(0) + "," + reader.GetInt64(1) + "," + reader.GetInt64(2) + "," + reader.GetInt64(3) + "," + reader.GetInt64(4) + "," + reader.GetInt64(5) + "," + reader.GetInt64(6) + "," + reader.GetInt64(7) + "," + reader.GetInt64(8) + "," + reader.GetInt64(9) + "," + reader.GetInt64(10) + "," + reader.GetInt64(11) + "," + reader.GetInt64(12) + "," + reader.GetInt64(13) + "," + reader.GetInt64(14) + "\n";
}
reader.Close();
connection.Close();
return ls;
}
[HttpPost]
public async Task<string> GetReceiveShipSum(string sebegin, string seend, string sabegin, string saend)
{
ConcurrentBag<ShipReceiveSum> bagList = new ConcurrentBag<ShipReceiveSum>();
List<EnumBusinessType> list = new List<EnumBusinessType>();
list.Add(EnumBusinessType.JisBBAC);
list.Add(EnumBusinessType.JisHBPO);
list.Add(EnumBusinessType.MaiDanJianHBPO);
list.Add(EnumBusinessType.MaiDanJianBBAC);
list.Add(EnumBusinessType.BeiJian);
list.Add(EnumBusinessType.ZhiGongJianHBPO);
list.Add(EnumBusinessType.ZhiGongJianBBAC);
list.Add(EnumBusinessType.YinDuJian);
Parallel.ForEach(list, async chunk =>
{
var ls = await GetBusinessSum(this._serviceProvider, chunk, sebegin, seend, sabegin, saend).ConfigureAwait(false);
foreach (var itm in ls)
{
bagList.Add(itm);
}
});
var entities=bagList.ToList<ShipReceiveSum>();
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
byte[] result = null;
result = await _excel.ExportAsByteArray(entities).ConfigureAwait(false);
result.ShouldNotBeNull();
string _fileName = $"收发存汇总{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
).ConfigureAwait(false);
return _fileName;
}
private async Task InvokeInternal(IServiceProvider serviceProvider)
{
var batchSize = 10000;
@ -2214,14 +2139,48 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public string ErpToLoc { set; get; }
[Display(Name = "数量")]
public decimal Qty { set; get; }
}
public class ShipReceiveSum
{
[Display(Name = "客户零件号")]
public string LU { set; get; }
[Display(Name = "厂内零件号")]
public string PartCode { set; get; }
[Display(Name = "业务类型")]
public string BusinessType { set; get; }
[Display(Name = "期初发货数量")]
public string BSEQty { set; get; }
[Display(Name = "期初退货数量")]
public string BRETQty { set; get; }
[Display(Name = "实际发货数量")]
public string SEQTY { set; get; }
[Display(Name = "实际退货数量")]
public string RETQty { set; get; }
[Display(Name = "可结数量")]
public string CANQty { set; get; }
[Display(Name = "不可结数量")]
public string NOTQty { set; get; }
[Display(Name = "有发有结有价格数量")]
public string SE_SA_CAN_QTY { set; get; }
[Display(Name = "有发有结无价格数量")]
public string SE_SA_NOT_QTY { set; get; }
[Display(Name = "有发运无结算数量")]
public string ONLY_SE_QTY { set; get; }
[Display(Name = "有结算无发运数量")]
public string ONLY_SA_QTY { set; get; }
[Display(Name = "已开票数量")]
public string INVQty { set; get; }
}
// 扩展方法类,用于为IEnumerable类型添加额外功能

7
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs

@ -128,6 +128,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
var result1 = notlist.Where(p => p.Price != 0);
if (!result1.Any())
{
throw new UserFriendlyException("都是没有价格数据!","400");
}
//if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.YinDuJian || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)
//{
// var ls = p_list.Select(p => p.GroupNum).Distinct().ToList();

9
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SecMatchSummaryDapperReportRepository.cs

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Dapper;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories.Dapper;
using Volo.Abp.EntityFrameworkCore;
@ -99,6 +100,14 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
//return _ls;
}
}
}

Loading…
Cancel
Save