From 3a155501c1b56ff0fb6f0c00dfc4dc5078a8453f Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Mon, 24 Jan 2022 13:52:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=B6=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=B9=E6=8D=AE=E5=AE=A2=E6=88=B7=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VWSparePart/SparePartAppService.cs | 47 ++++- .../ReportServices/ReportMakeService.cs | 43 +++++ .../SettleAccount.Application.xml | 15 ++ .../Entities/VWSparePart/SparePart.cs | 3 +- ...SettleSparePart90DapperReportRepository.cs | 178 ++++++++++++++++++ .../Report/SettleSparePart90ExportService.cs | 100 ++++++++++ .../SettleAccountJobModule.cs | 7 +- 7 files changed, 390 insertions(+), 3 deletions(-) create mode 100644 src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/VWSparePart/SparePartAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/VWSparePart/SparePartAppService.cs index 709caf29..48745ce2 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/VWSparePart/SparePartAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/VWSparePart/SparePartAppService.cs @@ -101,7 +101,52 @@ namespace Win.Sfs.SettleAccount.Entities.VWSparePart _bomList.Add(new SparePartVersion(_id, branchId, year, period, version, customerCode)); foreach (var itm in entityList) { - itm.SetValue(GuidGenerator.Create(), branchId, year, period, version); + itm.SetValue(GuidGenerator.Create(), branchId, year, period, version,"not90"); + } + if (checkList.Count > 0) + { + return await ExportErrorReportAsync(checkList); + } + await _repository.GetDbContext().BulkInsertAsync(entityList); + await _versionRepository.GetDbContext().BulkInsertAsync(_bomList); + return ApplicationConsts.SuccessStr; + } + + [HttpPost] + [Route("ExcelImport90")] + [DisableRequestSizeLimit] + [Authorize(SettleAccountPermissions.SettleAccounts.Create)] + public async Task SparePartUploadExcelImport90([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode) + { + if (string.IsNullOrEmpty(version)) + { + throw new BusinessException("版本不能空,必须传入!"); + } + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var entityList = ObjectMapper.Map, List>(result); + //删除版本 + var _versionQuery = _versionRepository.Where(p => p.Version == version); + await _versionQuery.BatchDeleteAsync(); + //删除明细 + var _query = _repository.Where(p => p.Version == version); + await _query.BatchDeleteAsync(); + //插入数据前检验 + var checkList = new List(); + var _group = entityList.GroupBy(x => new { x.LineNumber, x.MaterialCode, x.Version }).Select(p => new { Count = p.Count(), LineNumber = p.Key.LineNumber, MaterialCode = p.Key.MaterialCode }); + foreach (var itm in _group) + { + if (string.IsNullOrEmpty(itm.MaterialCode)) + { + checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("导入的行号为{0}的物料代码为空,请检查!", itm.LineNumber), string.Empty)); + } + } + var _id = GuidGenerator.Create(); + var _bomList = new List(); + _bomList.Add(new SparePartVersion(_id, branchId, year, period, version, customerCode)); + foreach (var itm in entityList) + { + itm.SetValue(GuidGenerator.Create(), branchId, year, period, version, "is90"); } if (checkList.Count > 0) { 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 ae60aaae..b899e503 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -210,6 +210,49 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices }); return _taskid; } + + #region 大众备件0-90天和90天以上输出 + + /// + /// 大众备件0-90天报表输出 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [HttpGet] + [Route("SettleSparePart90Export")] + [DisableRequestSizeLimit] + + public async Task SettledSparePart90(string purchaseOrderNo, string sapCode, 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 = "PurchaseOrderNo", Value = purchaseOrderNo ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "SAPCode", Value = sapCode ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = customerCode ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "State", Value = state ?? "0" }); + customConditionList.Add(new CustomCondition() { Name = "MatialCode", Value = matialCode ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "大众备件结算核对" }); + customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() }); + customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() }); + + var _taskid = await _service.ExportEnqueueAsync("(0-90天)大众备件结算输出", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettleSparePart90ExportService), customConditionList, (rs) => + { + + }); + return _taskid; + } + + #endregion /// /// 无订单备件结算输出 /// diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml index d8f46b72..8b309cd4 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml @@ -3591,6 +3591,21 @@ + + + 大众备件0-90天报表输出 + + + + + + + + + + + + 无订单备件结算输出 diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/VWSparePart/SparePart.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/VWSparePart/SparePart.cs index caa70da8..1a9aa5a2 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/VWSparePart/SparePart.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/VWSparePart/SparePart.cs @@ -16,13 +16,14 @@ namespace Win.Sfs.SettleAccount.Entities.VWSparePart public SparePart() { } - public void SetValue(Guid guid, Guid branchId, string year, string peroid, string version) + public void SetValue(Guid guid, Guid branchId, string year, string peroid, string version,string extend) { Period = peroid; Year = year; Id = guid; Version = version; BranchId = branchId; + Extend = extend; } public SparePart(Guid Id, string year, string period, string version, string lineNumber, string purchaseType,string purchaseOrderNo, string purchaseOrderNoItem, string purchaseOrderNoText, diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs new file mode 100644 index 00000000..3d46d1b4 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs @@ -0,0 +1,178 @@ +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 +{ + /// + /// 根据虚拟单号0-90天的是按照SAP物料号进行先进先出操作 + /// + public class SettleSparePart90DapperReportRepository : DapperRepository, ITransientDependency + { + public SettleSparePart90DapperReportRepository(IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { } + + + public virtual List GetSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, + string begintime, string endtime) + { + string sqlString = + "SELECT\n" + + " temp1.期间,\n" + + " temp1.交货单号,\n" + + " temp1.发货日期,\n" + + " temp1.采购订单号,\n" + + " temp1.SAP编码,\n" + + " temp1.物料代码,\n" + + " temp1.物料描述,\n" + + " temp1.物料组,\n" + + " temp1.开票单价,\n" + + " temp1.数量差异,\n" + + " temp1.发货数量,\n" + + " temp1.开票数量,\n" + + " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + + " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 \n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " a.Version AS 期间,\n" + + " b.WMSDeliveryNote AS 交货单号,\n" + + " b.SpareDate AS 发货日期,\n" + + " b.PurchaseOrderNo AS 采购订单号,\n" + + " c.MaterialCode AS SAP编码,\n" + + " b.MaterialCode AS 物料代码,\n" + + " c.MaterialDesc AS 物料描述,\n" + + " c.EstimateTypeDesc AS 物料组,\n" + + " a.PurchasePriceNoTax AS 开票单价,\n" + + " 0 AS 数量差异,\n" + + " ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + + " ISNULL( b.ReceiptQty, 0 ) AS 开票数量 \n" + + " FROM\n" + + " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode, Version, PurchasePriceNoTax FROM Set_SparePart GROUP BY PurchaseOrderNo, MaterialCode, Version, PurchasePriceNoTax ) AS a\n" + + " LEFT OUTER JOIN (\n" + + " SELECT\n" + + " WMSDeliveryNote,\n" + + " SpareDate,\n" + + " MaterialCode,\n" + + " ReceiptQty,\n" + + " PurchaseOrderNo \n" + + " FROM\n" + + " Set_WMSSparePart \n" + + " WHERE\n" + + " PurchaseOrderNo != 'BM' \n" + + " AND PurchaseOrderNo LIKE '%D30%' \n" + + " OR PurchaseOrderNo LIKE '%D60%' \n" + + " OR PurchaseOrderNo LIKE '%D90%' \n" + + " ) AS b ON a.MaterialCode = b.MaterialCode\n" + + " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + + " WHERE\n" + + " ( a.Version = '{0}' ) \n" + + " ) AS temp1\n" + + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + + "WHERE\n" + + " temp1.SAP编码 IS NULL"; + string addwhere = string.Empty; + string addSqlStr = string.Format(sqlString, version); + + string _sql = string.Format(addSqlStr, addwhere); + //string _sql = string.Format(sqlString, version); + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + return _query.ToList(); + + } + + + public virtual List GetSettleSparePart90SumQtyDiff(string version) + { + string sqlString = "SELECT\n" + + " ISNULL( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ), 0 ) 数量差异,\n" + + " a.PurchaseOrderNo 订单号,\n" + + " a.MaterialCode 物料号 \n" + + "FROM\n" + + " ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Version = '{0}' GROUP BY PurchaseOrderNo, MaterialCode ) A\n" + + " LEFT JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) B ON A.MaterialCode = B.MaterialCode"; + string addwhere = string.Empty; + string addSqlStr = string.Format(sqlString, version); + + + string _sql = string.Format(addSqlStr, addwhere); + + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + return _query.ToList(); + + } + + + + + } + + + + + + + + + + + + public class SparePart90SumQtyDiff + { + public decimal 数量差异 { set; get; } + public string 订单号 { set; get; } + public string 物料号 { set; get; } + } + + + + + + + + /// + /// 大众看板有条码报表 + /// + //[ExcelExporter(Name = "未结明细", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)] + public class SettleSparePart90Export + { + + [ExporterHeader(DisplayName = "期间 ")] + public string 期间 { set; get; } + [ExporterHeader(DisplayName = "交货单号 ")] + public string 交货单号 { set; get; } + [ExporterHeader(DisplayName = "发货日期")] + public string 发货日期 { set; get; } + [ExporterHeader(DisplayName = "采购订单号")] + public string 采购订单号 { set; get; } + [ExporterHeader(DisplayName = "SAP编码")] + public string SAP编码 { set; get; } + [ExporterHeader(DisplayName = "物料代码")] + public string 物料代码 { set; get; } + [ExporterHeader(DisplayName = "物料描述")] + public string 物料描述 { set; get; } + [ExporterHeader(DisplayName = "物料组")] + public string 物料组 { set; get; } + [ExporterHeader(DisplayName = "开票单价")] + public decimal 开票单价 { set; get; } + [ExporterHeader(DisplayName = "数量差异")] + public decimal 数量差异 { set; get; } + [ExporterHeader(DisplayName = "发货数量")] + public decimal 发货数量 { set; get; } + [ExporterHeader(DisplayName = "开票数量")] + public decimal 开票数量 { set; get; } + [ExporterHeader(DisplayName = "定价")] + public decimal 定价 { set; get; } + [ExporterHeader(DisplayName = "单价差异")] + public decimal 单价差异 { set; get; } + + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs new file mode 100644 index 00000000..24ec5b54 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs @@ -0,0 +1,100 @@ +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 SettleSparePart90ExportService : ITransientDependency, IExportJob + { + private readonly SettleSparePart90DapperReportRepository _dapper; + private readonly OutputService _outputService; + private readonly ErpPartDapperRepository _erpdapperRepository; + + public SettleSparePart90ExportService(SettleSparePart90DapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService) + { + _dapper = dapper; + _outputService = outputService; + _erpdapperRepository = erpdapperRepository; + } + + + public string ExportFile(Guid id, List exportName, List p_list) + { + var fileName = exportName.FirstOrDefault(); + var purchaseOrderNo = p_list.Where(p => p.Name == "PurchaseOrderNo").FirstOrDefault().Value; + var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; + var sapCode = p_list.Where(p => p.Name == "SAPCode").FirstOrDefault().Value; + var matialCode = p_list.Where(p => p.Name == "MatialCode").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 _ls = _dapper.GetSettleSparePart90ReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + //var diffList = _dapper.GetSettleSparePart90SumQtyDiff(version); + //if (diffList != null) + //{ + // foreach (var itm in diffList) + // { + // var _first = _ls.FirstOrDefault(p => p.物料代码 == itm.物料号); + // if (_first != null) + // { + // _first.开票数量 = _first.发货数量 + itm.数量差异;//开票数量(结算数量+差异) + // _first.数量差异 = itm.数量差异; + + // } + // } + //} + + //if (!string.IsNullOrEmpty(materialGroup)) + //{ + // var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _ls = _ls.Where(p => _groupList.Contains(p.MaterialGroup)).ToList(); + // } + //} + if (!string.IsNullOrEmpty(sapCode)) + { + var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _ls = _ls.Where(p => _groupList.Contains(p.SAP编码)).ToList(); + } + } + if (!string.IsNullOrEmpty(matialCode)) + { + var _groupList = matialCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _ls = _ls.Where(p => _groupList.Contains(p.物料代码)).ToList(); + } + } + //if (!string.IsNullOrEmpty(purchaseOrderNo)) + //{ + // var _groupList = purchaseOrderNo.Split(new char[] { '\n' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _ls = _ls.Where(p => _groupList.Contains(p.采购订单号)).ToList(); + // } + //} + + + + + + + + + _outputService.Export(id, fileName, _ls); + + + return id.ToString(); + } + + + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs index ec87041d..af68f4ed 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs @@ -118,7 +118,12 @@ namespace Win.Sfs.SettleAccount if (key.Equals(typeof(SettleSparePartExportService).FullName)) { return implementationFactory.GetService(); - } + } + //大众备件90天核对明细 + if (key.Equals(typeof(SettleSparePart90ExportService).FullName)) + { + return implementationFactory.GetService(); + } if (key.Equals(typeof(InvoiceSettledDetailDiffExportService).FullName)) { return implementationFactory.GetService();