From c59767319c7f25d17a41514bf2195c88f3b0e5c2 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 4 Jan 2022 17:17:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/WMS/WMSKanbanAppService.cs | 2 - .../Entities/WMS/WMSSharePartAppService.cs | 78 ++++++- .../ReportServices/ReportMakeService.cs | 97 ++++++++- .../SettleAccount.Application.xml | 26 +++ .../Entities/WMS/TaskList.cs | 91 +++++++- .../SettleSparePartDapperReportRepository.cs | 63 ++++++ ...leSparePartExtendDapperReportRepository.cs | 202 ++++++++++++++++++ .../Report/UnSettledDetailDapperRepository.cs | 8 +- .../Report/WmsDapperRepository.cs | 86 ++++++++ .../Services/Report/KanBanUnSettledExport.cs | 37 ++-- .../Services/Report/UnsettledDetailReport.cs | 8 + 11 files changed, 649 insertions(+), 49 deletions(-) create mode 100644 src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartExtendDapperReportRepository.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs index 6211c46c..6539124a 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs @@ -505,8 +505,6 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts { checkList.Add(new ErrorExportDto() { Message = string.Format("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number) }); } - - if (checkList.Count > 0) { diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs index b91cfc52..2e1d2f33 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs @@ -59,7 +59,6 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts public class WMSSharePartAppService : SettleAccountApplicationBase { - private readonly ISettleAccountBranchEfCoreRepository _wmsRepository; private readonly ISettleAccountBranchEfCoreRepository _wmsVersionRepository; private readonly WMSEfCoreRepository _wmsefRespository; @@ -182,7 +181,6 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts public async Task WmsSharePartOutPut(WmsJitRequestDto input) { var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); - var _joblist = _job.Where(p => input.Guids.Contains(p.Id) && p.FileName == "已确认").ToList(); if (_joblist.Count() > 0) { @@ -193,26 +191,54 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); var _list = _excelHelper.ExcelToList(); - foreach (var itm in _list) + if (_list.Count() > 0) { - itm.SetId(GuidGenerator.Create()); + var _lsAry = _list.GroupBy(p => new + { + p.MaterialCode, + p.MaterialGroup, + p.OrderBillNum, + p.MaterialDesc, + p.Version, + p.WmsBillNum, + }).Select(p => new + WmsSharePartOutPutDetial( + GuidGenerator.Create(), + p.Key.WmsBillNum, + p.Key.OrderBillNum, + p.Key.MaterialCode, + p.Key.MaterialDesc, + p.Key.MaterialGroup, + string.Empty, + string.Empty, + 0, + string.Empty, + string.Empty, + string.Empty, + p.Key.MaterialCode, + _billNum, + GuidGenerator.Create(), + string.Empty, + p.Sum(itm => itm.Qty) + )); + _lst.AddRange(_lsAry.ToArray()); } - _lst.AddRange(_list.ToArray()); } - var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); + var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version).ToListAsync(); - var error = from itm1 in outPutDetail - join itm2 in _ls1 on + var error = from itm1 in outPutDetail + join itm2 in _lst on new { itm1.MaterialCode, itm1.OrderBillNum } equals new { itm2.MaterialCode, itm2.OrderBillNum } select itm1; + var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); if (errList.Count() == 0) { - var query = from itm1 in _ls1 + var query = from itm1 in _lst join itm2 in outPutDetail on new { itm1.MaterialCode, itm1.OrderBillNum } equals @@ -221,6 +247,35 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts where tm1 == null select itm1; var _wmslst = query.ToList(); + _wmslst = _wmslst.GroupBy(p => new + { + p.MaterialCode, + p.MaterialGroup, + p.OrderBillNum, + p.MaterialDesc, + p.Version, + p.WmsBillNum, + }).Select(p => new + WmsSharePartOutPutDetial( + GuidGenerator.Create(), + p.Key.WmsBillNum, + p.Key.OrderBillNum, + p.Key.MaterialCode, + p.Key.MaterialDesc, + p.Key.MaterialGroup, + string.Empty, + string.Empty, + 0, + string.Empty, + string.Empty, + string.Empty, + p.Key.MaterialCode, + _billNum, + GuidGenerator.Create(), + string.Empty, + p.Sum(itm => itm.Qty) + )).ToList(); + foreach (var itm in _wmslst) { itm.BillNum = _billNum; @@ -361,6 +416,9 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts ExportImporter _exportImporter = new ExportImporter(); var result = await _exportImporter.ExtendExcelImport(files, _excelImportService); List _lst = new List(); + + + var _lsCopy = new List(); foreach (var itm in result) { @@ -382,7 +440,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts itm.BillNum, GuidGenerator.Create() , string.Empty - , itm.Qty.Value + , itm.Qty ); _lsCopy.Add(_detail); } 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 3d8f9d2b..738fcef2 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -167,7 +167,7 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = input.Begin.ToString() }); customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = input.End.ToString() }); - var _taskid = await _service.ExportEnqueueAsync("无条码看板结算输出", ExportExtentsion.Excel, input.Version, string.Empty, CurrentUser, typeof(SettleKBWithOutCodeExportService), customConditionList, (rs) => + var _taskid = await _service.ExportEnqueueAsync("无条码看板结算输出", ExportExtentsion.Excel, input.Version,string.Empty, CurrentUser, typeof(SettleKBWithOutCodeExportService), customConditionList, (rs) => { }); return _taskid; @@ -211,28 +211,103 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices }); return _taskid; } + /// + /// 无订单备件结算输出 + /// + /// 采购订单号 + /// 厂内物料号 + /// 版本 + /// + /// + /// 物料代码 + /// + /// + /// + /// + [HttpGet] + [Route("SettleSparePartExportExtend")] + [DisableRequestSizeLimit] + + public async Task SettledSparePartExtend(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 ?? "0" }); + 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("无订单备件结算输出", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettleSparePartExportService), customConditionList, (rs) => + { + + }); + return _taskid; + } + + + + + + + + + + + + #endregion - + [HttpGet] - [Route("SettleSparePartExport")] + [Route("SharePartUnSettledExport")] [DisableRequestSizeLimit] public async Task SharePartUnSettled( string sapCode, string version, DateTime begin, DateTime end) { - List customConditionList = new List(); customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty }); - customConditionList.Add(new CustomCondition() { Name = "SAPCode", Value = sapCode ?? 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, version, string.Empty, CurrentUser, typeof(SharePartUnSettledExport), customConditionList, (rs) => + { + + }); + return _taskid; + } + - var _taskid = await _service.ExportEnqueueAsync("备件未结对比", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SharePartUnSettledExport), customConditionList, (rs) => + /// + /// 看板未结输出 + /// + /// + /// + /// + /// + /// + /// + [HttpGet] + [Route("KanbanUnSettledExport")] + [DisableRequestSizeLimit] + + public async Task KanbanUnSettled(string sapCode, string version, + DateTime begin, DateTime end,string materialGroup) + { + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "SAPCode", Value = sapCode ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() }); + customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() }); + customConditionList.Add(new CustomCondition() { Name = "MaterialGroup", Value = materialGroup }); + var _taskid = await _service.ExportEnqueueAsync("看板未结明细", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(KanBanUnSettledExport), customConditionList, (rs) => { }); @@ -241,6 +316,10 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices + + + + /// /// 未结算对比 /// @@ -446,7 +525,6 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices customConditionList.Add(new CustomCondition() { Name = "Cp7EndTime", Value = string.IsNullOrEmpty(request.Cp7End) ? string.Empty : request.Cp7End }); customConditionList.Add(new CustomCondition() { Name = "KennCode", Value = string.IsNullOrEmpty(request.Kenncode) ? string.Empty : request.Kenncode }); customConditionList.Add(new CustomCondition() { Name = "ChassisNumber", Value = string.IsNullOrEmpty(request.ChassisNumber) ? string.Empty : request.ChassisNumber }); - customConditionList.Add(new CustomCondition() { Name = "MaterialGroup", Value = string.IsNullOrEmpty(request.MaterialGroup) ? string.Empty : request.MaterialGroup }); customConditionList.Add(new CustomCondition() { Name = "SapCode", Value = string.IsNullOrEmpty(request.SapCode) ? string.Empty : request.SapCode }); var _taskid = await _service.ExportEnqueueAsync("准时化结算数量差异比对输出", ExportExtentsion.Excel,request.Version, string.IsNullOrEmpty(request.MaterialGroup) ? string.Empty : request.MaterialGroup, CurrentUser, typeof(UnInvoiceSettledDetailDiffExportService), customConditionList, (rs) => @@ -479,7 +557,6 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices customConditionList.Add(new CustomCondition() { Name = "MaterialCode", Value = !string.IsNullOrEmpty(input.MaterialCode)? input.MaterialCode :string.Empty }); customConditionList.Add(new CustomCondition() { Name = "MaterialGroup", Value = !string.IsNullOrEmpty(input.MaterialGroup)? input.MaterialGroup :string.Empty }); customConditionList.Add(new CustomCondition() { Name = "SapMaterialCode", Value =string.Empty }); - customConditionList.Add(new CustomCondition() { Name = "Begin", Value = !string.IsNullOrEmpty(input.Begin)?string.Empty: input.Begin }); customConditionList.Add(new CustomCondition() { Name = "End", Value = !string.IsNullOrEmpty(input.End)?string.Empty: input.End }); customConditionList.Add(new CustomCondition() { Name = "KennCode", Value = string.IsNullOrEmpty(input.Kenncode) ? string.Empty : input.Kenncode }); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml index 7a08862f..9b114084 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml @@ -2969,6 +2969,32 @@ + + + 无订单备件结算输出 + + 采购订单号 + 厂内物料号 + 版本 + + + 物料代码 + + + + + + + + 看板未结输出 + + + + + + + + 1.大众发票与结算核对汇总表 diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs index 8c1b5c0d..e33503e3 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs @@ -308,7 +308,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS /// /// 扩展字段2 /// - [ImporterHeader(Name = "扩展字段2", IsIgnore = true)] + [ImporterHeader(Name = "订单日期")] public string Extend2 { set; get; } /// /// 扩展字段3 @@ -439,7 +439,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS [ImporterHeader(Name = "版本号",IsIgnore =true)] public string Version { set; get; } [ImporterHeader(Name = "开票数量")] - public decimal? Qty { set; get; } + public decimal Qty { set; get; } [ImporterHeader(Name = "数量", IsIgnore = true)] public string BillNum { set; get; } @@ -454,7 +454,94 @@ namespace Win.Sfs.SettleAccount.Entities.WMS + public class WmsSharePartOutPutDetial2: FullAuditedAggregateRootBase + { + public WmsSharePartOutPutDetial2() + { + } + + public WmsSharePartOutPutDetial2(Guid id, string wmsBillNum, string orderBillNum, string materialCode, string materialDesc, string materialGroup, string outPut, string inPut, int state, string extend1, string extend2, string extend3, string parentMaterialCode, string billNum, Guid taskId, string remark, decimal qty) + { + Id = id; + //WmsBillNum = wmsBillNum; + //OrderBillNum = orderBillNum; + MaterialCode = materialCode; + MaterialDesc = materialDesc; + //MaterialGroup = materialGroup; + OutPut = outPut; + InPut = inPut; + State = state; + Extend1 = extend1; + Extend2 = extend2; + Version = extend3; + //ParentMaterialCode = parentMaterialCode; + BillNum = billNum; + TaskId = taskId; + Remark = remark; + Qty = qty; + } + + + public void SetId(Guid id) + { + Id = id; + } + + + //[ImporterHeader(Name = "组件组物料")] + //public string ParentMaterialCode { set; get; } + //[ImporterHeader(Name = "交货单号")] + //public string WmsBillNum { set; get; } + //[ImporterHeader(Name = "采购订单号")] + ////KENN号 + //public string OrderBillNum { set; get; } + [ImporterHeader(Name = "SAP编码")] + //物料号 + public string MaterialCode { set; get; } + [ImporterHeader(Name = "物料描述")] + //物料描述 + public string MaterialDesc { set; get; } + //[ImporterHeader(Name = "物料组(车型)",IsIgnore =true)] + ////物料组(车型) + //public string MaterialGroup { set; get; } + [ImporterHeader(Name = "出库库位", IsIgnore = true)] + //出库库位 + public string OutPut { set; get; } + [ImporterHeader(Name = "入库库位", IsIgnore = true)] + //入库库位 + public string InPut { set; get; } + [ImporterHeader(Name = "状态", IsIgnore = true)] + public int State { get; set; } + [ImporterHeader(Name = "物料代码")] + /// + /// 扩展字段1 + /// + public string Extend1 { set; get; } + /// + /// 扩展字段2 + /// + [ImporterHeader(Name = "扩展字段2", IsIgnore = true)] + public string Extend2 { set; get; } + /// + /// 扩展字段3 + /// + [ImporterHeader(Name = "版本号", IsIgnore = true)] + public string Version { set; get; } + [ImporterHeader(Name = "开票数量")] + public decimal InvoiceQty { set; get; } + [ImporterHeader(Name = "出库数量", IsIgnore = true)] + public decimal Qty { set; get; } + [ImporterHeader(Name = "已出数量", IsIgnore = true)] + public decimal OutQty { set; get; } + [ImporterHeader(Name = "数量", IsIgnore = true)] + public string BillNum { set; get; } + + + public Guid TaskId { set; get; } + + + } 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 index b5122dbd..aabc648c 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs @@ -80,6 +80,69 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } + public virtual List GetSettleSparePartNoOrderList(string purchaseOrderNo, string version, string sapCode, string matialCode, + 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.WMSDeliveryNote,--交货单号 \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" + + " a.InvoicedQty as InvoicedQty,--开票数量 \n" + + " (c.ReceiptQty-d.Amt) as SettleInvoiceDiffQty,--发货与开票差异 \n" + + " d.InvoicePrice,--开票单价 \n" + + " 0 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 = '{0}' 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 addwhere = string.Empty; + string addSqlStr = string.Format(sqlString, version); + //if (!string.IsNullOrEmpty(purchaseOrderNo)) + //{ + // addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo); + //} + //else if (!string.IsNullOrEmpty(sapCode)) + //{ + // addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode); + //} + //else if (!string.IsNullOrEmpty(matialCode)) + //{ + // addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode); + //} + //else if (!string.IsNullOrEmpty(begintime)&& !string.IsNullOrEmpty(endtime)) + //{ + // addwhere += string.Format(" AND OrderDate BETWEEN '{0}' AND '{1}' ", begintime, endtime); + //} + + 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(); + + } + + + + } /// diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartExtendDapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartExtendDapperReportRepository.cs new file mode 100644 index 00000000..56aa3814 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartExtendDapperReportRepository.cs @@ -0,0 +1,202 @@ +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 SettleSparePartExtendDapperReportRepository : DapperRepository, ITransientDependency + { + public SettleSparePartExtendDapperReportRepository(IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { } + + //public async Task SettledSparePart(string purchaseOrderNo, string sapCode, string version, string customerCode, string factory, string matialCode, + //string state, DateTime begin, DateTime end) + + public virtual List GetSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, + 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.WMSDeliveryNote,--交货单号 \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" + + " a.InvoicedQty as InvoicedQty,--开票数量 \n" + + " (c.ReceiptQty-d.Amt) as SettleInvoiceDiffQty,--发货与开票差异 \n" + + " d.InvoicePrice,--开票单价 \n" + + " 0 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 = '{0}' 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 addwhere = string.Empty; + string addSqlStr = string.Format(sqlString, version); + //if (!string.IsNullOrEmpty(purchaseOrderNo)) + //{ + // addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo); + //} + //else if (!string.IsNullOrEmpty(sapCode)) + //{ + // addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode); + //} + //else if (!string.IsNullOrEmpty(matialCode)) + //{ + // addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode); + //} + //else if (!string.IsNullOrEmpty(begintime)&& !string.IsNullOrEmpty(endtime)) + //{ + // addwhere += string.Format(" AND OrderDate BETWEEN '{0}' AND '{1}' ", begintime, endtime); + //} + + 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 GetSettleSparePartNoOrderList(string purchaseOrderNo, string version, string sapCode, string matialCode, + 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.WMSDeliveryNote,--交货单号 \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" + + " a.InvoicedQty as InvoicedQty,--开票数量 \n" + + " (c.ReceiptQty-d.Amt) as SettleInvoiceDiffQty,--发货与开票差异 \n" + + " d.InvoicePrice,--开票单价 \n" + + " 0 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 = '{0}' 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 addwhere = string.Empty; + string addSqlStr = string.Format(sqlString, version); + //if (!string.IsNullOrEmpty(purchaseOrderNo)) + //{ + // addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo); + //} + //else if (!string.IsNullOrEmpty(sapCode)) + //{ + // addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode); + //} + //else if (!string.IsNullOrEmpty(matialCode)) + //{ + // addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode); + //} + //else if (!string.IsNullOrEmpty(begintime)&& !string.IsNullOrEmpty(endtime)) + //{ + // addwhere += string.Format(" AND OrderDate BETWEEN '{0}' AND '{1}' ", begintime, endtime); + //} + + 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(); + + } + + + + + } + + ///// + ///// 大众看板有条码报表 + ///// + ////[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.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettledDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettledDetailDapperRepository.cs index ce81b4b1..9c6b8400 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettledDetailDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettledDetailDapperRepository.cs @@ -39,10 +39,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { str += string.Format(" and beginTime<'{0}' ", end); } - if (!string.IsNullOrEmpty(materialCode)) - { - str += string.Format(" and ItemCode='{0}' ", materialCode); - } + //if (!string.IsNullOrEmpty(materialCode)) + //{ + // str += string.Format(" and ItemCode='{0}' ", materialCode); + //} //string str2 = " "; //if (!string.IsNullOrEmpty(sapCode)) //{ diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs new file mode 100644 index 00000000..99f97b1d --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs @@ -0,0 +1,86 @@ +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; +using Win.Sfs.SettleAccount.Entities; +using Win.Sfs.SettleAccount.Entities.Materials; +using Win.Sfs.SettleAccount.Entities.Prices; +using Win.Sfs.SettleAccount.Reports; + +namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report +{ + + + + public class SalesStock + { + public string SapCode { set; get; } + public decimal Qty { set; get; } + } + + /// + /// 主数据Dapper表 + /// + public class WmsDapperRepository : DapperRepository, ITransientDependency + { + public WmsDapperRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + + } + + + public virtual List GetSalesStock() + { + string str = " select SUM(Qty) Qty,PartCode SapCode from TS_STOCK_DETAIL where AreaCode='SALE' group by PartCode "; + + var _list = DbConnection.Query(str); + return _list.ToList(); + + + } + + //public virtual Dictionary GetSapList(List childList, string version, bool isNotHistoryPart = false) where T : ReportDetailBase, new() + //{ + + // return tmpList; + //} + //public virtual List 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(string.Format(str, version)); + // return _list.ToList(); + //} + //public virtual List GetSettleInvoiceDiff(string version) + //{ + // var str = "SELECT\n" + + // " * \n" + + // " FROM\n" + + // " (\n" + + // " SELECT\n" + + // " b.MaterialCode,\n" + + // " InvocieQty-SettleQty DiffQty \n" + + // " FROM\n" + + // " ( SELECT sum( Qty ) SettleQty, MaterialCode FROM Set_Settle a WHERE version = '{0}' GROUP BY MaterialCode ) a\n" + + // " INNER JOIN ( SELECT SUM( QTY ) InvocieQty, MaterialCode FROM Set_Invoice WHERE version = '{0}' GROUP BY MaterialCode ) b ON a.MaterialCode = b.MaterialCode \n" + + // " ) temp \n" + + // " WHERE\n" + + // " temp.DiffQty <>0"; + // var _list = DbConnection.Query(string.Format(str, version)); + // return _list.ToList(); + //} + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs index 79d7326e..df5edd16 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/KanBanUnSettledExport.cs @@ -37,13 +37,8 @@ namespace SettleAccount.Job.Services.Report { var _filename = exportName.FirstOrDefault(); 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 materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value; var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value; var _ls = _dapper.GetKanbanReportList(version, begin,end); @@ -55,15 +50,15 @@ namespace SettleAccount.Job.Services.Report { _ls = _ls.Where(p => _groupList.Contains(p.MaterialGroup)).ToList(); } - } - if (!string.IsNullOrEmpty(materialCode)) - { - var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList(); - if (_groupList.Count() > 0) - { - _ls = _ls.Where(p => _groupList.Contains(p.CustomerPartCode)).ToList(); - } } + //if (!string.IsNullOrEmpty(materialCode)) + //{ + // var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _ls = _ls.Where(p => _groupList.Contains(p.CustomerPartCode)).ToList(); + // } + //} if (!string.IsNullOrEmpty(sapCode)) { var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); @@ -80,14 +75,14 @@ namespace SettleAccount.Job.Services.Report _lst = _lst.Where(p => _groupList.Contains(p.MaterialGroup)).ToList(); } } - if (!string.IsNullOrEmpty(materialCode)) - { - var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList(); - if (_groupList.Count() > 0) - { - _lst = _lst.Where(p => _groupList.Contains(p.MaterialCode)).ToList(); - } - } + //if (!string.IsNullOrEmpty(materialCode)) + //{ + // var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _lst = _lst.Where(p => _groupList.Contains(p.MaterialCode)).ToList(); + // } + //} if (!string.IsNullOrEmpty(sapCode)) { var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnsettledDetailReport.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnsettledDetailReport.cs index 69e8be37..6a28534d 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnsettledDetailReport.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnsettledDetailReport.cs @@ -93,6 +93,14 @@ namespace SettleAccount.Job.Services.Report _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); } } + if (!string.IsNullOrEmpty(materailCode)) + { + var _groupList = materailCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); + } + } _list = _list.OrderBy(p => p.ChassisNumber).ThenBy(p => p.SapMaterialCode).ThenBy(p => p.Flag).ToList(); _outputService.Export(id, _first, _list); return id.ToString();