From 484dd589d3319532867f8c2c814185e1bbe59296 Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Thu, 25 Nov 2021 22:29:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E4=BC=97=E5=A4=87=E4=BB=B6=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ApiHostMigrationsDbContextModelSnapshot.cs | 175 +++++++++++++++++- .../ReportServices/ReportMakeService.cs | 42 ++++- .../SettleAccount.Application.xml | 15 ++ .../Entities/WMS-SparePart/WMSSparePart.cs | 8 +- .../SettleKBWithCodeDapperReportRepository.cs | 1 + .../SettleSparePartDapperReportRepository.cs | 116 ++++++++++++ .../Report/SettleSparePartExportService.cs | 43 +++++ 7 files changed, 393 insertions(+), 7 deletions(-) create mode 100644 src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs diff --git a/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Migrations/SettleAccountHttpApiHostMigrationsDbContextModelSnapshot.cs b/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Migrations/SettleAccountHttpApiHostMigrationsDbContextModelSnapshot.cs index 07fef7e1..e75ee765 100644 --- a/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Migrations/SettleAccountHttpApiHostMigrationsDbContextModelSnapshot.cs +++ b/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Migrations/SettleAccountHttpApiHostMigrationsDbContextModelSnapshot.cs @@ -6689,7 +6689,7 @@ namespace Win.Sfs.SettleAccount.Migrations .IsUnique() .HasFilter("IsDeleted=0"); - b.ToTable("Set_WMSSparePart"); + b.ToTable("Set_SparePart"); }); modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.VWSparePart.SparePartVersion", b => @@ -7001,6 +7001,179 @@ namespace Win.Sfs.SettleAccount.Migrations b.ToTable("Set_WMSKanBanSettle_Version"); }); + modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.WMS_SparePart.WMSSparePart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AccountNum") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("AmountNoTax") + .HasColumnType("decimal(18,2)"); + + b.Property("BatchNo") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("BranchId") + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("DeliveryLineNum") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("DeliveryOrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("Extend") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExtraProperties") + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("Factory") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FactoryName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("GermanInvoiceNo") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("InvoicedQty") + .HasColumnType("decimal(18,2)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("LineNumber") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MaterialCode") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("MaterialDesc") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Period") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("PurchaseOrderNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PurchaseOrderNoItem") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PurchaseOrderNoText") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PurchasePriceNoTax") + .HasColumnType("decimal(18,2)"); + + b.Property("PurchaseType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ReceiptQty") + .HasColumnType("decimal(18,2)"); + + b.Property("Remark") + .HasColumnType("nvarchar(max)"); + + b.Property("SpareDate") + .HasColumnType("datetime2"); + + b.Property("TaxCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TaxRate") + .HasColumnType("decimal(18,2)"); + + b.Property("Unit") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Version") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("WMSDeliverGoodsState") + .HasColumnType("nvarchar(max)"); + + b.Property("WMSDeliveryNote") + .HasColumnType("nvarchar(max)"); + + b.Property("WMSKanBanState") + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("Version", "PurchaseOrderNo", "MaterialCode") + .IsUnique() + .HasFilter("IsDeleted=0"); + + b.ToTable("Set_WMSSparePart"); + }); + modelBuilder.Entity("Win.Sfs.SettleAccount.EstimatedInventories.EstimatedInventoryDetail", b => { b.Property("Id") diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs index 27dfbbaf..c7819047 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -73,7 +73,7 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices _service = service; } - #region 派格结算报表 + #region 派格大众看板-备件结算报表 /// /// 有条码看板结算核对 /// @@ -106,7 +106,45 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() }); customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() }); - var _taskid = await _service.ExportEnqueueAsync("未结算对比", ExportExtentsion.Excel, CurrentUser, typeof(UnSettledExportService), customConditionList, (rs) => + var _taskid = await _service.ExportEnqueueAsync("大众看板结算与交货核对明细表", ExportExtentsion.Excel, CurrentUser, typeof(SettleKBWithCodeExportService), customConditionList, (rs) => + { + }); + return _taskid; + } + + /// + /// 大众备件结算核对明细表 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [HttpGet] + [Route("SettlSparePartExport")] + [DisableRequestSizeLimit] + + public async Task SettledSparePart(string year, string period, string version, string customerCode, string factory, string matialCode, + string state, DateTime begin, DateTime end) + { + + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = customerCode ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "Factory", Value = factory ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "State", Value = state ?? "0" }); + customConditionList.Add(new CustomCondition() { Name = "MatialCode", Value = matialCode ?? "0" }); + customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "大众备件结算核对" }); + customConditionList.Add(new CustomCondition() { Name = "Year", Value = year ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() }); + customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() }); + + var _taskid = await _service.ExportEnqueueAsync("大众备件结算核对明细表", ExportExtentsion.Excel, CurrentUser, typeof(SettleSparePartExportService), customConditionList, (rs) => { }); return _taskid; diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml index fff539fc..a6e9ff12 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml @@ -2421,6 +2421,21 @@ + + + 大众备件结算核对明细表 + + + + + + + + + + + + 未结算对比 diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS-SparePart/WMSSparePart.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS-SparePart/WMSSparePart.cs index 6497f2c3..693a5871 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS-SparePart/WMSSparePart.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS-SparePart/WMSSparePart.cs @@ -66,7 +66,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS_SparePart /// /// 期间 /// - [Display(Name = "期间")] + [Display(Name = "交货日期")] public string Period { set; get; } /// /// 版本号 @@ -105,7 +105,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS_SparePart /// /// 收货数量 /// - [Display(Name = "收货数量")] + [Display(Name = "发货数量")] public decimal ReceiptQty { get; set; } /// @@ -141,7 +141,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS_SparePart /// /// 日期 /// - [Display(Name = "日期")] + [Display(Name = "订单日期")] public DateTime SpareDate { get; set; } /// /// 交货单号 @@ -195,7 +195,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS_SparePart public string Extend { set; get; } /// - /// WMS交货单 + /// WMS采购订单号 /// public string WMSDeliveryNote { set; get; } diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs index f8fd418c..65f29f21 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs @@ -30,6 +30,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " SELECT\n" + " c.WMSDeliveryNote,--交货单号\n" + " c.WMSActualGoodsDate,--实际发货日期\n" + + " a.Kanban,--条码号\n" + " b.MaterialCode SapMaterialCode,--厂内物料号\n" + " b.MaterialDesc,--物料描述\n" + diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs new file mode 100644 index 00000000..1b5f0691 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs @@ -0,0 +1,116 @@ +using Dapper; +using Magicodes.ExporterAndImporter.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Repositories.Dapper; +using Volo.Abp.EntityFrameworkCore; + +namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report +{ + public class SettleSparePartDapperReportRepository : DapperRepository, ITransientDependency + { + public SettleSparePartDapperReportRepository(IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { } + + public virtual List GetSettleSparePartReportList(string state, string version, string year, string customcode, + string begintime, string endtime) + { + string sqlString = "SELECT\n" + + " * ,\n" + + " (Price-InvoicePrice) as InvoiceDiffPrice, --单价差异\n" + + " ISNULL( Price * ReceiptQty-InvoiceMoney, 0 ) AS SumDiffMoney --总金额差异\n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " c.Period as WMSDeliveryDate,--交货日期\n" + + " c.DeliveryOrderNo,--交货单号\n" + + " c.SpareDate as OrderDate,--订单日期\n" + + " a.PurchaseOrderNo,--采购订单号\n" + + " b.MaterialCode as SAPCode,--SAP编码,即厂内物料号\n" + + " a.MaterialCode,--物料代码\n" + + " b.MaterialDesc,--物料描述\n" + + " a.PurchaseOrderNoText,--采购订单文本\n" + + " c.ReceiptQty,-- 发货数量\n" + + " d.Amt as InvoicedQty,--开票数量\n" + + " (c.ReceiptQty-d.Amt) as SettleInvoiceDiffQty,--发货与开票差异\n" + + " d.InvoicePrice,--开票单价\n" + + " (a.ReceiptQty * d.InvoicePrice) as InvoiceMoney --开票金额\n" + + " \n" + + " FROM\n" + + " Set_SparePart AS a\n" + + " LEFT JOIN Set_material AS b ON a.MaterialCode= b.CustomerPartCode\n" + + " LEFT JOIN Set_WMSSparePart c ON a.PurchaseOrderNo= c.WMSDeliveryNote \n" + + " AND a.MaterialCode= c.MaterialCode\n" + + " LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode,Amt FROM set_invoice WHERE version = '202109' GROUP BY materialcode,Amt ) d ON a.MaterialCode= d.MaterialCode \n" + + " ) TEMP1\n" + + " LEFT JOIN ( SELECT Price, --定价\n" + + " MaterialCode --厂内物料号\n" + + " FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode"; + string _sql = string.Format(sqlString, version); + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + return _query.ToList(); + + } + + } + + /// + /// 大众看板有条码报表 + /// + //[ExcelExporter(Name = "未结明细", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)] + public class SettleSparePartExport + { + [ExporterHeader(DisplayName = "交货日期")] + public string WMSDeliveryDate { set; get; } + + [ExporterHeader(DisplayName = "交货单号")] + public string DeliveryOrderNo { set; get; } + + [ExporterHeader(DisplayName = "订单日期")] + public DateTime OrderDate{ set; get; } + + [ExporterHeader(DisplayName = "采购订单号")] + public string PurchaseOrderNo { set; get; } + + [ExporterHeader(DisplayName = "SAP编码")] + public string SAPCode { set; get; } + + [ExporterHeader(DisplayName = "物料代码")] + public string MaterialCode { set; get; } + + [ExporterHeader(DisplayName = "物料描述")] + public string MaterialDesc { set; get; } + + [ExporterHeader(DisplayName = "采购订单文本")] + public string PurchaseOrderNoText { set; get; } + + [ExporterHeader(DisplayName = "发货数量")] + public decimal ReceiptQty { set; get; } + + [ExporterHeader(DisplayName = "开票数量")] + public decimal InvoicedQty { set; get; } + + [ExporterHeader(DisplayName = "发货与开票差异")] + public decimal SettleInvoiceDiffQty { set; get; } + + [ExporterHeader(DisplayName = "开票单价")] + public decimal InvoicePrice { set; get; } + + [ExporterHeader(DisplayName = "开票金额")] + public decimal InvoiceMoney { set; get; } + [ExporterHeader(DisplayName = "定价")] + public decimal Price { set; get; } + + [ExporterHeader(DisplayName = "单价差异")] + public decimal InvoiceDiffPrice { set; get; } + + [ExporterHeader(DisplayName = "总金额差异")] + public decimal SumDiffMoney { set; get; } + + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs new file mode 100644 index 00000000..6acfc899 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs @@ -0,0 +1,43 @@ +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.Repository.SettleAccountJob.Report; + +namespace SettleAccount.Job.Services.Report +{ + public class SettleSparePartExportService : ITransientDependency, IExportJob + { + private readonly SettleSparePartDapperReportRepository _dapper; + private readonly OutputService _outputService; + + public SettleSparePartExportService(SettleSparePartDapperReportRepository dapper, OutputService outputService) + { + _dapper = dapper; + _outputService = outputService; + } + + + public string ExportFile(Guid id, List exportName, List p_list) + { + var year = p_list.Where(p => p.Name == "Year").FirstOrDefault().Value; + var state = p_list.Where(p => p.Name == "State").FirstOrDefault().Value; + var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; + var customerCode = p_list.Where(p => p.Name == "CustomerCode").FirstOrDefault().Value; + var beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value; + var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; + + var _list = _dapper.GetSettleSparePartReportList(state, version, year, customerCode, beginTime, endTime); + + _outputService.Export(id, string.Format("大众备件结算核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _list); + + return id.ToString(); + } + + + } +}