yu.wu 3 years ago
parent
commit
4cfe123218
  1. 23
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs
  2. 50
      src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs
  3. 7
      src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml
  4. 5
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs
  5. 39
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs
  6. 2
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettleAccountEntityBase.cs
  7. 52
      src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/ReportDetailBase.cs
  8. 33
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpPartDapperRepository.cs
  9. 149
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs
  10. 5
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDiffDapperRepository.cs
  11. 1
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleFisDiffDetailDapperRepository.cs
  12. 80
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs
  13. 4
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDiffExportService.cs
  14. 6
      src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

23
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs

@ -170,29 +170,6 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
var entityList = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
var _ls = entityList.Where(p=>p.EndDate.ToString().Contains("9999")).GroupBy(p => new { p.MaterialCode, p.CustomerCode,p.Type }).Select(p=>p.FirstOrDefault());
// List<PriceList> _ls = new List<PriceList>();
//foreach (var itm in matialCodeList)
//{
// var priceList= entityList.Where(p => p.MaterialCode == itm).Distinct().ToList();
// var _list =priceList.OrderBy(p => p.BeginDate).ToList();
// int i = 0;//查询下条记录
// foreach (var price in _list)
// {
// i++;
// if (_list.Count == i)
// {
// price.EndDate = DateTime.MaxValue;
// break;
// }
// else
// {
// var _nextPrice = _list[i];
// price.EndDate = _nextPrice.BeginDate.AddDays(-1);
// }
// _ls.Add(price);
// }
//}
foreach (var itm in _ls)
{
itm.Update(GuidGenerator.Create(),version);

50
src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs

@ -305,6 +305,44 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
return _taskid;
}
/// <summary>
/// 大众发票与结算核对明细表
/// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpGet]
[Route("InvoiceSettledDetailDiff-Make")]
[DisableRequestSizeLimit]
public async Task<string> InvoiceSettledDetailDiffMake(
string version,
string materialCode,
string begin,
string end,
string cp7begin,
string cp7end,
string kenncode,
string chassisNumber
)
{
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value =string.IsNullOrEmpty(version) ?string.Empty:version });
customConditionList.Add(new CustomCondition() { Name = "MaterialCode", Value = string.IsNullOrEmpty(materialCode) ?string.Empty: materialCode });
customConditionList.Add(new CustomCondition() { Name = "BeginTime", Value = string.IsNullOrEmpty(begin) ? string.Empty : materialCode });
customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = string.IsNullOrEmpty(end) ? string.Empty : materialCode });
customConditionList.Add(new CustomCondition() { Name = "Cp7BeginTime", Value = string.IsNullOrEmpty(cp7begin) ? string.Empty : cp7begin });
customConditionList.Add(new CustomCondition() { Name = "Cp7EndTime", Value = string.IsNullOrEmpty(cp7end) ? string.Empty : cp7end });
customConditionList.Add(new CustomCondition() { Name = "KennCode", Value = string.IsNullOrEmpty(kenncode) ? string.Empty : kenncode });
customConditionList.Add(new CustomCondition() { Name = "ChassisNumber", Value = string.IsNullOrEmpty(chassisNumber) ? string.Empty : chassisNumber });
var _taskid = await _service.ExportEnqueueAsync("大众发票与结算核对明细表", ExportExtentsion.Excel, CurrentUser, typeof(InvoiceSettledDetailDiffExportService), customConditionList, (rs) =>
{
});
return _taskid;
}
/// <summary>
/// 3.大众准时化结算数量差异比对表
/// </summary>
@ -350,18 +388,6 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
return _taskid;
}
/// <summary>
/// 结算总成和ERP总成价格对比
/// </summary>

7
src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml

@ -2484,6 +2484,13 @@
<param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
<returns></returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.InvoiceSettledDetailDiffMake(System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String)">
<summary>
大众发票与结算核对明细表
</summary>
<param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
<returns></returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.SettleFisDiffExportMake(System.String,System.String,System.String,System.String)">
<summary>
3.大众准时化结算数量差异比对表

5
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs

@ -8,6 +8,11 @@ using Win.Sfs.Shared.DomainBase;
namespace Win.Sfs.SettleAccount.Entities.Prices
{
public class ErpPrice
{
public string SapErpPartCode { set; get; }
public decimal SapPrice { set; get; }
}
public class PriceList:FullAuditedAggregateRootBase<Guid>
{
public PriceList()

39
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs

@ -78,20 +78,37 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
var pricelist = GetPriceList(version);
List<PriceList> _list = new List<PriceList>();
foreach (var itm in pricelist)
{
var entity = entities.FirstOrDefault(p => p.Type == itm.Type && p.CustomerCode == itm.CustomerCode && p.MaterialCode == p.MaterialCode);
if (entity != null)
{
itm.Price = entity.Price;
entities.Remove(entity);
}
}
//var LeftJoin = from emp in ListOfEmployees
// join dept in ListOfDepartment
// on emp.DeptID equals dept.ID into JoinedEmpDept
// from dept in JoinedEmpDept.DefaultIfEmpty()
var add= from itm1 in entities join itm2 in pricelist
on new { itm1.Type, itm1.CustomerCode, itm1.MaterialCode } equals new { itm2.Type, itm2.CustomerCode, itm2.MaterialCode }
into temp from itm3 in temp.DefaultIfEmpty() where itm3 == null select itm1;
var update = from itm1 in entities
join itm2 in pricelist
on new { itm1.Type, itm1.CustomerCode, itm1.MaterialCode } equals new { itm2.Type, itm2.CustomerCode, itm2.MaterialCode }
where itm1.Price != itm2.Price
select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode,itm2.Type, itm2.ParentId, itm2.Version);
await _repository.GetDbContext().BulkInsertAsync<PriceList>(entities);
await _repository.GetDbContext().BulkUpdateAsync(update.ToList());
await _repository.GetDbContext().BulkInsertAsync<PriceList>(add.ToList());
var _first = _versionRepository.FirstOrDefault(p => p.Version == version);

2
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettleAccountEntityBase.cs

@ -12,7 +12,7 @@ namespace Win.Sfs.SettleAccount.Entities
public class CacheManager
{
public static List<Material> CacheMaterials { set; get; }
public static List<PriceList> CachePriceList { set; get; }
public static List<ErpPrice> CachePriceList { set; get; }
}
public interface ISettleAccountEntityBase

52
src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/ReportDetailBase.cs

@ -10,32 +10,32 @@ namespace Win.Sfs.SettleAccount.Reports
public class ReportDetailBase
{
[ExporterHeader(DisplayName = "交货单号 ")]
public string WmsBillNum { set; get; }
[ExporterHeader(DisplayName = "实际发货日期 ")]
public DateTime CP5Time { set; get; }
[ExporterHeader(DisplayName = "KENN号")]
public string KENNCode { set; get; }
[ExporterHeader(DisplayName = "底盘号")]
public string ChassisNumber { set; get; }
[ExporterHeader(DisplayName = "交货状态 ")]
public string WmsState { set; get; }
[ExporterHeader(DisplayName = "物料号")]
public string SapMaterialCode { set; get; }
[ExporterHeader(DisplayName = "物料描述 ")]
public string MaterialDesc { set; get; }
[ExporterHeader(DisplayName = "客户物料 ")]
public string MaterialCode { set; get; }
[ExporterHeader(DisplayName = "组件组物料 ")]
public string ParentSapMaterialCode { set; get; }
[ExporterHeader(DisplayName = "组件组物料描述 ")]
public string ParentMaterialDesc { set; get; }
[ExporterHeader(DisplayName = "物料组(车型) ")]
public string MaterialGroup { set; get; }
[ExporterHeader(DisplayName = "定价 ")]
public decimal Price { set; get; }
[ExporterHeader(DisplayName = "金额 ")]
public decimal Amt { set; get; }
public virtual string WmsBillNum { set; get; }
public virtual DateTime CP5Time { set; get; }
public virtual string KENNCode { set; get; }
public virtual string ChassisNumber { set; get; }
public virtual string WmsState { set; get; }
public virtual string SapMaterialCode { set; get; }
public virtual string MaterialDesc { set; get; }
public virtual string MaterialCode { set; get; }
public virtual string ParentSapMaterialCode { set; get; }
public virtual string ParentMaterialDesc { set; get; }
public virtual string MaterialGroup { set; get; }
public virtual decimal Price { set; get; }
public virtual decimal Amt { set; get; }
}

33
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpPartDapperRepository.cs

@ -15,7 +15,7 @@ using Win.Sfs.SettleAccount.Reports;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
/// <summary>
/// 主数据Dapper表
@ -27,10 +27,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
public virtual List<T> GetDiffReport<T>(List<T> childList) where T : ReportDetailBase, new()
public virtual List<T> GetSapList<T>(List<T> childList) where T : ReportDetailBase, new()
{
List<Material> _materialList = new List<Material>();
List<PriceList> _priceList = new List<PriceList>();
List<ErpPrice> _priceList = new List<ErpPrice>();
if (CacheManager.CacheMaterials != null)
{
_materialList = CacheManager.CacheMaterials;
@ -45,10 +45,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
else
{
_priceList = DbConnection.Query<PriceList>("select MaterialCode,Price from Set_PriceList where version=(select max(version) from set_Set_PriceListVersion)").ToList();
_priceList = DbConnection.Query<ErpPrice>("select Price SapPrice, MaterialCode SapErpPartCode from Set_PriceList where version=(select max(version) from Set_PriceListVersion)").ToList();
}
List<T> _list = new List<T>();
List <T> _list = new List<T>();
foreach (var itm in childList)
{
var parentMaterial = new T();
@ -63,11 +65,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
parentMaterial.ParentSapMaterialCode = itm.ParentSapMaterialCode;
parentMaterial.ParentMaterialDesc = itm.ParentMaterialDesc;
var _price = _priceList.Where(p => p.MaterialCode == itm.ParentSapMaterialCode).FirstOrDefault();
var _price = _priceList.Where(p => p.SapErpPartCode == itm.ParentSapMaterialCode).FirstOrDefault();
if (_price != null)
{
parentMaterial.Price = _price.Price;
parentMaterial.Amt = _price.Price;
parentMaterial.Price = _price.SapPrice;
parentMaterial.Amt = _price.SapPrice;
}
var _material = _materialList.Where(p => p.MaterialCode == itm.ParentSapMaterialCode).FirstOrDefault();
if (_material != null)
@ -81,5 +84,19 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
return _list;
}
public virtual List<ErpPrice> GetErpPartCodePriceList(string version)
{
string str = "SELECT\n" +
" ErpMaterialCode SapErpPartCode,\n" +
" SUM( PRICE ) SapPrice \n" +
" FROM \n" +
" Set_MaterialRelationshipDetail A\n" +
" LEFT JOIN ( SELECT SUM( AMT )/ SUM( Qty ) PRICE, MaterialCode FROM Set_Invoice WHERE VERSION = '{0}' GROUP BY MaterialCode ) B ON A.SettleMaterialCode = B.MaterialCode \n" +
"GROUP BY\n" +
" ErpMaterialCode";
var _list = DbConnection.Query<ErpPrice>(string.Format(str, version));
return _list.ToList();
}
}
}

149
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs

@ -1,4 +1,6 @@
using Magicodes.ExporterAndImporter.Core;
using Dapper;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using System;
using System.Collections.Generic;
using System.Linq;
@ -11,18 +13,53 @@ using Win.Sfs.SettleAccount.Reports;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
public class InvoiceSettledDetilDiff : ReportDetailBase
[ExcelExporter(MaxRowNumberOnASheet = 500000)]
public class InvoiceSettledDetailDiff
: ReportDetailBase
{
//结算数量
[ExporterHeader(DisplayName = "交货单号 ")]
public override string WmsBillNum { set; get; }
[ExporterHeader(DisplayName = "实际发货日期 ")]
public override DateTime CP5Time { set; get; }
[ExporterHeader(DisplayName = "KENN号")]
public override string KENNCode { set; get; }
[ExporterHeader(DisplayName = "底盘号")]
public override string ChassisNumber { set; get; }
[ExporterHeader(DisplayName = "交货状态 ")]
public override string WmsState { set; get; }
[ExporterHeader(DisplayName = "物料号")]
public override string SapMaterialCode { set; get; }
[ExporterHeader(DisplayName = "物料描述 ")]
public override string MaterialDesc { set; get; }
[ExporterHeader(DisplayName = "客户物料 ")]
public override string MaterialCode { set; get; }
[ExporterHeader(DisplayName = "组件组物料 ")]
public override string ParentSapMaterialCode { set; get; }
[ExporterHeader(DisplayName = "组件组物料描述 ")]
public override string ParentMaterialDesc { set; get; }
[ExporterHeader(DisplayName = "物料组(车型) ")]
public override string MaterialGroup { set; get; }
[ExporterHeader(DisplayName = "定价 ")]
public override decimal Price { set; get; }
[ExporterHeader(DisplayName = "金额 ")]
public override decimal Amt { set; get; }
//发运数量
[ExporterHeader(DisplayName = "M100数量")]
public decimal Qty { set; get; }
//结算数量
[ExporterHeader(DisplayName = "结算数量")]
public decimal SettleQty { set; get; }
public decimal SettledQty { set; get; }
//结算日期
[ExporterHeader(DisplayName = "结算日期")]
public decimal CP7Time { set; get; }
public DateTime CP7Time { set; get; }
//结算与发货差异
[ExporterHeader(DisplayName = "结算与发货差异")]
public decimal DiffFisQty{ set; get; }
public decimal DiffSettleFisQty{ set; get; }
//结算与开票差异
[ExporterHeader(DisplayName = "结算与开票差异")]
public decimal DiffSettleInvQty { set; get; }
@ -42,8 +79,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
[ExporterHeader(DisplayName = "单价差异")]
public decimal DiffPrice { set; get; }
//总金额差异
[ExporterHeader(DisplayName = "交货单号 ")]
[ExporterHeader(DisplayName = "总金额差异")]
public decimal AmtDiffPrice { set; get; }
@ -51,20 +87,107 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
public class InvoiceSettledDetailDiffDapperRepository: DapperRepository<SettleAccountDbContext>, ITransientDependency
/// <summary>
/// 2.大众发票与结算核对明细表-准时化
/// </summary>
public class InvoiceSettledDetailDiffDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{
public InvoiceSettledDetailDiffDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public virtual List<InvoiceSettledDetilDiff> GetInvoiceSettledDetailDiffReportList(string version, string year, string tablename, string materialcode)
public virtual List<InvoiceSettledDetailDiff> GetInvoiceSettledDetailDiffReportList(string version, string materialCode, string begin, string end ,string cp7begin,string cp7end,string kennCode,string chassisNumber)
{
List<InvoiceSettledDetilDiff> _list = new List<InvoiceSettledDetilDiff>();
List<InvoiceSettledDetailDiff> _list = new List<InvoiceSettledDetailDiff>();
string condition = " where 1=1 ";
if (!string.IsNullOrEmpty(materialCode))
{
condition += string.Format(" d.MaterialCode='{0}' ", materialCode);
}
if (!string.IsNullOrEmpty(begin))
{
condition += string.Format(" a.BeginTime>='{0}' ", begin);
}
if (!string.IsNullOrEmpty(end))
{
condition += string.Format(" a.BeginTime<='{0}' ", end);
}
if (!string.IsNullOrEmpty(cp7begin))
{
condition += string.Format(" B.cp7Time>='{0}' ", cp7begin);
}
if (!string.IsNullOrEmpty(cp7end))
{
condition += string.Format(" B.cp7Time<='{0}' ", cp7end);
}
if (!string.IsNullOrEmpty(kennCode))
{
condition += string.Format(" B.kenncode='{0}' ", kennCode);
}
if (!string.IsNullOrEmpty(chassisNumber))
{
condition += string.Format(" B.chassisNumber='{0}' ", chassisNumber);
}
string str =
"SELECT\n" +
" temp1.*,\n" +
" TEMP2.Price,(\n" +
" Isnull( temp2.Price, 0 ) * isnull( temp1.Qty, 0 )) Amt \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" b.YEAR,\n" +
" b.KENNCode,\n" +
" b.MaterialCode,\n" +
" b.Model,\n" +
" b.ChassisNumber,\n" +
" a.Qty,\n" +
" a.BeginTime CP5Time,\n" +
" a.ChassisNumber2,\n" +
" B.CP7 CP7Time,\n" +
" B.QTY SettledQty,\n" +
" a.ErpMaterialCode ParentSapMaterialCode,\n" +
" a.WMSState,\n" +
" a.WMSBillNum,\n" +
" d.MaterialCode SapMaterialCode,\n" +
" d.MaterialDesc MaterialDesc,\n" +
" d.EstimateTypeDesc MaterialGroup,\n" +
" e.MaterialDesc ParentMaterialDesc,\n" +
" c.InvoicePrice,\n" +
" ( c.InvoicePrice * a.qty ) InvoiceAmt,\n" +
" ( c.InvoicePrice * a.Qty ) SettleAmt,\n" +
" a.Qty - IsNull( B.Qty, 0 ) DiffSettleFisQty,\n" +
" 0 DiffSettleInvQty \n" +
" FROM\n" +
" ( SELECT * FROM Set_Settle b WHERE b.Version = '{0}' ) b\n" +
" INNER JOIN Set_fis a ON b.ChassisNumber = a.ChassisNumber2 \n" +
" AND b.KENNCode = a.KENNCode \n" +
" AND b.MaterialCode = a.ItemCode\n" +
" LEFT JOIN ( SELECT SUM( amt )/ SUM( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE version = '{0}' GROUP BY materialcode ) c ON a.ItemCode = c.MaterialCode\n" +
" LEFT JOIN set_material d ON a.ItemCode = d.CustomerPartCode\n" +
" LEFT JOIN set_material e ON a.ErpMaterialCode = e.MaterialCode {1} \n" +
" ) TEMP1\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" Price,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_PriceList \n" +
"WHERE\n" +
" version = ( SELECT Max( Version ) FROM Set_PriceList )) TEMP2 ON TEMP1.SapMaterialCode = TEMP2.MaterialCode";
var _sql = string.Format(str, version,condition);
var _query = DbConnection.Query<InvoiceSettledDetailDiff>(_sql, null, null, true, 1200, null);
_list=_query.ToList();
string str = string.Empty;
return _list;
}
}

5
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDiffDapperRepository.cs

@ -52,10 +52,11 @@ string.Format(" '{0}' as Version ,", version)+"\n" +
" (\n" +
" b.InvoiceQty - ISnull(\n" +
" c.Qty,\n" +
" IsNull( d.qty, 0 ))) DiffQty,\n" +
" IsNull( d.qty, 0 ))) DiffQty,\n" +
" g.MaterialCode AS SapMaterialCode,\n" +
" g.MaterialDesc AS MaterialDesc \n" +
" g.MaterialDesc AS MaterialDesc, \n" +
" g.EstimateTypeDesc as SapMaterialGroup \n " +
" FROM\n" +
" (\n" +
" SELECT\n" +

1
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleFisDiffDetailDapperRepository.cs

@ -37,6 +37,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
[ExporterHeader(DisplayName = "M100数量" )]
public decimal Qty { set; get; }
[ExporterHeader(DisplayName = "差异")]
public decimal DiffQty { set; get; }
[ExporterHeader(DisplayName = "开票单价" )]
public decimal Price{ set; get; }

80
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.DependencyInjection;
using Win.Sfs.SettleAccount.Reports.InvoiceSettledDiffs;
using Win.Sfs.SettleAccount.Repository.SettleAccount;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
namespace SettleAccount.Job.Services
{
/// <summary>
/// 2.大众发票与结算核对明细表-准时化
/// </summary>
public class InvoiceSettledDetailDiffExportService : ITransientDependency, IExportJob
{
private readonly InvoiceSettledDetailDiffDapperRepository _dapperRepository;
private readonly ErpPartDapperRepository _erpdapperRepository;
private readonly OutputService _outputService;
private readonly InputService _inputService;
public InvoiceSettledDetailDiffExportService(
ErpPartDapperRepository erpdapperRepository,
InvoiceSettledDetailDiffDapperRepository dapperRepository,
OutputService outputService,
InputService inputService
)
{
_inputService = inputService;
_outputService = outputService;
_erpdapperRepository= erpdapperRepository;
//_repository = repository;
//_versionRepository = versionRepository;
_dapperRepository =dapperRepository;
}
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list)
{
var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value;
var materialCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value;
var begin = p_list.Where(p => p.Name == "BeginTime").FirstOrDefault().Value;
var end = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value;
var cp7begin = p_list.Where(p => p.Name == "Cp7BeginTime").FirstOrDefault().Value;
var cp7end = p_list.Where(p => p.Name == "Cp7EndTime").FirstOrDefault().Value;
var kenncode = p_list.Where(p => p.Name == "KennCode").FirstOrDefault().Value;
var chassisNumber = p_list.Where(p => p.Name == "ChassisNumber").FirstOrDefault().Value;
var _ls = _dapperRepository.GetInvoiceSettledDetailDiffReportList(version, materialCode, begin, end, cp7begin, cp7end, kenncode, chassisNumber);
var _list = _ls.GroupBy(p => p.ParentSapMaterialCode).Select(p => p.FirstOrDefault()).ToList();
var rangeList = _erpdapperRepository.GetSapList<InvoiceSettledDetailDiff>(_list);
rangeList.ForEach(p => {
p.Qty = 1;
p.InvoiceQty = 1;
p.SettledQty = 1;
p.DiffSettleFisQty = 0;
p.DiffSettleInvQty = 0;
});
_ls.AddRange(rangeList);
_ls.OrderBy(p => new { p.ChassisNumber, p.KENNCode });
_outputService.Export<InvoiceSettledDetailDiff>(id, string.Format("大众发票与结算核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _ls);
//_repository.Insert(_list);
//_versionRepository.Insert(_id, version, customerCode, customerCode, string.Empty, string.Empty, projectName);
return id.ToString();
}
}
}

4
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDiffExportService.cs

@ -66,12 +66,12 @@ namespace SettleAccount.Job.Services
SettleQty =itm. SettleQty ,
CP7ScrapQty =itm. CP7ScrapQty ,
ClaimQty =itm. ClaimQty ,
DiffQty =itm. DiffQty ,
DiffQty = itm.InvoiceQty-itm.SettleQty-itm.CP7ScrapQty-itm.ClaimQty,//开票数量-结算数量-CP7报废数量-索赔数量
SalePrice =itm. SalePrice ,
DiffPrice =itm. DiffPrice ,
SapMaterialCode =itm.SapMaterialCode ,
MaterialDesc=itm.MaterialDesc,
SapMaterialGroup=itm.SapMaterialGroup,
Factory = itm.Factory,

6
src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

@ -119,8 +119,14 @@ namespace Win.Sfs.SettleAccount
return implementationFactory.GetService<SettleSparePartExportService>();
}
if (key.Equals(typeof(InvoiceSettledDetailDiffExportService).FullName))
{
return implementationFactory.GetService<InvoiceSettledDetailDiffExportService>();
}
else
{
throw new ArgumentException($"Not Support key:{key}");
}
}; return accesor;

Loading…
Cancel
Save