diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs index fb452056..f664b6e1 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs @@ -446,8 +446,9 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts var checkList = new List(); ExportImporter _exportImporter = new ExportImporter(); var result = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); + //检验1:导入模板中的第一页签数据不能为空 - if (result == null || result.Count == 0) + if (result == null || result.Count() == 0) { checkList.Add(new ErrorExportDto(version, "红旗批量出库单导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty)); } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs index d06b8188..5d01ac30 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs @@ -414,9 +414,11 @@ namespace Win.Sfs.SettleAccount.Entities.WMS var _billNum = "BCar" + DateTime.Now.ToString("yyyyMMddhhmmss"); var checkList = new List(); ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); + var result_org = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); + //过滤掉物料号为空的数据 + var result = result_org.Where(p => !string.IsNullOrEmpty(p.MaterialCode)); //检验1:导入模板中的第一页签数据不能为空 - if (result == null || result.Count == 0) + if (result == null || result.Count() == 0) { checkList.Add(new ErrorExportDto(version, "轿车出库单导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty)); } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOneTimeSaleOutputAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOneTimeSaleOutputAppService.cs index 3079fb60..ef026f53 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOneTimeSaleOutputAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOneTimeSaleOutputAppService.cs @@ -211,7 +211,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS [UnitOfWork(false)] public async Task WmsKanbanOutPut([FromForm] IFormFileCollection files, string version) { - + var checkList = new List(); var _billNum = "OTS" + DateTime.Now.ToString("yyyyMMddhhmmss"); @@ -219,11 +219,19 @@ namespace Win.Sfs.SettleAccount.Entities.WMS ExportImporter _exportImporter = new ExportImporter(); //只取导入模板第一个页签 - var _list = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); + var _list_org = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); + // 根据物料号是否为空,过滤EXCEL自带的空行 + var _list = _list_org.Where(p => !string.IsNullOrEmpty(p.SapMaterialCode)); + - if (_list == null || _list.Count == 0) + //检验1:导入模板中的第一页签数据不能为空 + if (_list == null || _list.Count() == 0) + { + checkList.Add(new ErrorExportDto(version, "一次性寄售销售导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty)); + } + if (checkList.Count > 0) { - throw new BusinessException("导入模板数据不能为空!"); + return await ExportErrorReportAsync(checkList); } ////插入数据前检验 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 cbe620ce..04af0f28 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -252,6 +252,45 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices }); return _taskid; } + + /// + /// 大众备件未结明细 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [HttpGet] + [Route("UnSettleSparePartExport")] + [DisableRequestSizeLimit] + + public async Task UnSettledSparePart(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("大众备件未结输出", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettleUnSparePartExportService), customConditionList, (rs) => + { + + }); + return _taskid; + } #endregion /// /// 无订单备件结算输出 diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs index e29f9803..12d4d2be 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs @@ -53,81 +53,58 @@ namespace SettleAccount.Job.Services.Report var _forwardls_withcode = _dapper.GetWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); //反向对比,即大众备件未结(有单号),包含有发货有结算并且发货数量大于结算数量的数据也整合到未结中 - var _reversels_withcode = _dapper.GetReverseWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); - - - var stockList = _wmsDapper.GetSalesStock(); - - //针对无单号备件,求和汇总显示 - var _forwardls_nocode = _dapper.GetNoCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); - var queryStockList_nocode = from itm in _forwardls_nocode - join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 - from tm1 in temp1.DefaultIfEmpty() - select new SettleSparePartExport( - itm.SAP编码, - itm.物料代码, - itm.物料描述, - itm.发货数量, - itm.收货数量, - itm.开票数量, - itm.收货与开票差异, - itm.开票单价, - itm.开票金额, - itm.定价, - itm.单价差异, - itm.差异总金额, - tm1 == null ? 0 : tm1.Qty - ); - - //不管有单号备件还是无单号备件,财务要求全部按照零件汇总求和显示,并和寄售库存比对 - var _forwardls = _dapper.GetForwardSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); - //按照零件号汇总数量,有一列显示寄售库数量 - - var queryStockList = from itm in _forwardls - join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 - from tm1 in temp1.DefaultIfEmpty() - select new SettleSparePartExport( - itm.SAP编码, - itm.物料代码, - itm.物料描述, - itm.发货数量, - itm.收货数量, - itm.开票数量, - itm.收货与开票差异, - itm.开票单价, - itm.开票金额, - itm.定价, - itm.单价差异, - itm.差异总金额, - tm1 == null ? 0 : tm1.Qty - ); - - - - //var diffList = _dapper.GetSettleSparePartSumQtyDiff(version); - //if (diffList != null) - //{ - // foreach (var itm in diffList) - // { - // var _first = _ls.FirstOrDefault(p => p.采购订单号 == itm.订单号 && p.物料代码==itm.物料号); - // if (_first != null) - // { - // _first.开票数量 = _first.发货数量 + itm.数量差异;//开票数量(结算数量+差异) - // _first.数量差异 = itm.数量差异; + //var _reversels_withcode = _dapper.GetReverseWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + + + //var stockList = _wmsDapper.GetSalesStock(); + + ////针对无单号备件,求和汇总显示 + //var _forwardls_nocode = _dapper.GetNoCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + //var queryStockList_nocode = from itm in _forwardls_nocode + // join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 + // from tm1 in temp1.DefaultIfEmpty() + // select new SettleSparePartExport( + // itm.SAP编码, + // itm.物料代码, + // itm.物料描述, + // itm.发货数量, + // itm.收货数量, + // itm.开票数量, + // itm.收货与开票差异, + // itm.开票单价, + // itm.开票金额, + // itm.定价, + // itm.单价差异, + // itm.差异总金额, + // tm1 == null ? 0 : tm1.Qty + // ); + + ////不管有单号备件还是无单号备件,财务要求全部按照零件汇总求和显示,并和寄售库存比对 + //var _forwardls = _dapper.GetForwardSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + ////按照零件号汇总数量,有一列显示寄售库数量 + + //var queryStockList = from itm in _forwardls + // join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 + // from tm1 in temp1.DefaultIfEmpty() + // select new SettleSparePartExport( + // itm.SAP编码, + // itm.物料代码, + // itm.物料描述, + // itm.发货数量, + // itm.收货数量, + // itm.开票数量, + // itm.收货与开票差异, + // itm.开票单价, + // itm.开票金额, + // itm.定价, + // itm.单价差异, + // itm.差异总金额, + // tm1 == null ? 0 : tm1.Qty + // ); + - // } - // } - //} - //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(); @@ -164,12 +141,12 @@ namespace SettleAccount.Job.Services.Report var result = _exporter.Append(_ls.ToList(), "大众备件明细数据") .SeparateBySheet() .Append(_forwardls_withcode.ToList(), "有结算无发货对比") - .SeparateBySheet() - .Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)") - .SeparateBySheet() - .Append(queryStockList_nocode.ToList(), "大众备件无单号汇总") - .SeparateBySheet() - .Append(queryStockList.ToList(), "零件汇总比对寄售库存") + // .SeparateBySheet() + //.Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)") + // .SeparateBySheet() + // .Append(queryStockList_nocode.ToList(), "大众备件无单号汇总") + // .SeparateBySheet() + //.Append(queryStockList.ToList(), "零件汇总比对寄售库存") .ExportAppendDataAsByteArray(); result.ShouldNotBeNull(); _fileContainer.SaveAsync(fileName, result.Result, true); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleUnSparePartExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleUnSparePartExportService.cs new file mode 100644 index 00000000..afed0166 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleUnSparePartExportService.cs @@ -0,0 +1,143 @@ +using Magicodes.ExporterAndImporter.Excel; +using Shouldly; +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.BlobStoring; +using Volo.Abp.DependencyInjection; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; + +namespace SettleAccount.Job.Services.Report +{ + public class SettleUnSparePartExportService : ITransientDependency, IExportJob + { + private readonly SettleSparePartDapperReportRepository _dapper; + private readonly OutputService _outputService; + private readonly ErpPartDapperRepository _erpdapperRepository; + private readonly IBlobContainer _fileContainer; + private readonly WmsDapperRepository _wmsDapper; + + + public SettleUnSparePartExportService(SettleSparePartDapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService + , WmsDapperRepository wmsDapper + , IBlobContainer fileContainer) + { + _dapper = dapper; + _outputService = outputService; + _erpdapperRepository = erpdapperRepository; + _fileContainer = fileContainer; + _wmsDapper = wmsDapper; + } + + + 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 iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; + + + //反向对比,即大众备件未结(有单号),包含有发货有结算并且发货数量大于结算数量的数据也整合到未结中 + var _reversels_withcode = _dapper.GetReverseWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + + + var stockList = _wmsDapper.GetSalesStock(); + + //针对无单号备件,求和汇总显示 + var _forwardls_nocode = _dapper.GetNoCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + var queryStockList_nocode = from itm in _forwardls_nocode + join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 + from tm1 in temp1.DefaultIfEmpty() + select new SettleSparePartExport( + itm.SAP编码, + itm.物料代码, + itm.物料描述, + itm.发货数量, + itm.收货数量, + itm.开票数量, + itm.收货与开票差异, + itm.开票单价, + itm.开票金额, + itm.定价, + itm.单价差异, + itm.差异总金额, + tm1 == null ? 0 : tm1.Qty + ); + + //不管有单号备件还是无单号备件,财务要求全部按照零件汇总求和显示,并和寄售库存比对 + var _forwardls = _dapper.GetForwardSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + //按照零件号汇总数量,有一列显示寄售库数量 + + var queryStockList = from itm in _forwardls + join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 + from tm1 in temp1.DefaultIfEmpty() + select new SettleSparePartExport( + itm.SAP编码, + itm.物料代码, + itm.物料描述, + itm.发货数量, + itm.收货数量, + itm.开票数量, + itm.收货与开票差异, + itm.开票单价, + itm.开票金额, + itm.定价, + itm.单价差异, + itm.差异总金额, + tm1 == null ? 0 : tm1.Qty + ); + + + if (!string.IsNullOrEmpty(sapCode)) + { + var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _reversels_withcode = _reversels_withcode.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) + { + _reversels_withcode = _reversels_withcode.Where(p => _groupList.Contains(p.采购订单号)).ToList(); + } + } + + + ExcelExporter _exporter = new ExcelExporter();//导出Excel + var result = _exporter.Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)") + .SeparateBySheet() + .Append(queryStockList_nocode.ToList(), "大众备件无单号汇总") + .SeparateBySheet() + .Append(queryStockList.ToList(), "零件汇总比对寄售库存") + .ExportAppendDataAsByteArray(); + result.ShouldNotBeNull(); + _fileContainer.SaveAsync(fileName, result.Result, true); + + + return id.ToString(); + } + + + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs index d3dd9de6..76bb0038 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs @@ -174,7 +174,11 @@ namespace SettleAccount.Job.Services.Report var materailCode = p_list.Where(p => p.Name == "MaterialCode").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 iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; + //var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; + var iscontionversion = "1";//不分版本,全查 + + + //var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; //var customerCode = p_list.Where(p => p.Name == "CustomerCode").FirstOrDefault().Value; @@ -241,14 +245,15 @@ 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 kanban = p_list.Where(p => p.Name == "Kanban").FirstOrDefault().Value; + //var kanban = p_list.Where(p => p.Name == "Kanban").FirstOrDefault().Value; var begin = p_list.Where(p => p.Name == "Begin").FirstOrDefault().Value; var end = p_list.Where(p => p.Name == "End").FirstOrDefault().Value; var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value; - var acceptNo = p_list.Where(p => p.Name == "AcceptNo").FirstOrDefault().Value; + //var acceptNo = p_list.Where(p => p.Name == "AcceptNo").FirstOrDefault().Value; var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value; - var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value; - var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; + //var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value; + //var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; + var iscontionversion = "1";//不分区间,全查 //有发货无结算,单独拿出去,财务要求 var _ls = _hqkanbanDapper.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion); if (!string.IsNullOrEmpty(sapCode)) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs index 189c98af..28ab9839 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs @@ -119,6 +119,11 @@ namespace Win.Sfs.SettleAccount { return implementationFactory.GetService(); } + //大众备件未结明细 + if (key.Equals(typeof(SettleUnSparePartExportService).FullName)) + { + return implementationFactory.GetService(); + } //大众备件90天核对明细 if (key.Equals(typeof(SettleSparePart90ExportService).FullName)) {