From e97160f49f618074766d7df9fecb45fd51496fb6 Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 11 Apr 2022 16:31:24 +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/TaskListDto.cs | 2 +- .../Entities/WMS/WmsDetailCancelInterface.cs | 228 ++++++++++++++++++ .../Report/WmsOutputSumDapperRepository.cs | 200 +++++++++++++++ 3 files changed, 429 insertions(+), 1 deletion(-) create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailCancelInterface.cs diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs index 8410800e..a19dc421 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs @@ -234,9 +234,9 @@ namespace Win.Sfs.SettleAccount.Entities [ImporterHeader(Name = "开票金额")] [ExporterHeader(DisplayName = "开票金额")] public decimal Amt { set; get; } - + } /// /// 大众备件出库单 /// diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailCancelInterface.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailCancelInterface.cs new file mode 100644 index 00000000..44cd02b3 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailCancelInterface.cs @@ -0,0 +1,228 @@ + +using EFCore.BulkExtensions; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Shouldly; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Uow; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.Wms; +using Win.Sfs.SettleAccount.Entities.Wms.WmsSumOutput; +using Win.Sfs.SettleAccount.Reports; +using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; +using Win.Sfs.Shared.DomainBase; +using Win.Sfs.Shared.Filter; + +namespace Win.Sfs.SettleAccount.Entities.WMS +{ + [Authorize(SettleAccountPermissions.WMSJIT.Default)] + [Route("api/settleaccount/WMSOutputDetailCancelDiffReport")] + public class WMSOutputDetailCancelDiffReportAppService : + SettleAccountApplicationBase + { + private readonly ISettleAccountBranchEfCoreRepository _wmsRepository; + private readonly WmsOutputSumDapperRepository _dapper; + private readonly IExcelImportAppService _excelImportService; + + private readonly ErpSumOutputDapperRepository _erpDapper; + /// + /// + /// + /// + /// + + public WMSOutputDetailCancelDiffReportAppService( + WmsOutputSumDapperRepository dapper, + ISettleAccountBranchEfCoreRepository wmsRepository, + ISettleAccountBranchEfCoreRepository job, + IExcelImportAppService excelImportService, + IDistributedCache cache, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager, + ErpSumOutputDapperRepository erpDapper + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) + { + _erpDapper = erpDapper; + _wmsRepository = wmsRepository; + _dapper = dapper; + _excelImportService = excelImportService; + + } + + [HttpGet] + [Route("Make")] + [UnitOfWork(false)] + public async Task ReportMake(string version, DateTime accountDate) + { + var _ls = _dapper.GetWmsSumCancelReportList(version, "0");//报表 + + var _count = _wmsRepository.Count(p => p.Version == version && p.State > 0); + if (_count > 0) + { + throw new BusinessException("8899", "不能重新生成此版本!"); + } + else + { + var query = _wmsRepository.Where(p => p.Version == version); + await query.BatchDeleteAsync(); + } + List _lst = new List(); + if (_ls != null && _ls.Count() > 0) + { + foreach (var itm in _ls) + { + _lst.Add(new WmsDetailDiffReport( + Guid.NewGuid(), + itm.客户, + itm.出库类型, + version, + itm.结算单, + itm.通用代码号, + itm.物料号, + itm.结算数量, + itm.实际出库数量, + itm.差异数量, + itm.物料组编码, + itm.物料组车型, + itm.物料描述, + itm.备注, + 0)); + } + } + await _wmsRepository.GetDbContext().BulkInsertAsync(_lst); + return ApplicationConsts.SuccessStr; + } + /// + /// Wms汇总合计明细 + /// + /// + /// + [HttpPost] + [Route("WmsDetailReport")] + + virtual public async Task> GetListAsync(WmsRequestDetailReportDto input) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); + //客户过滤 + if (!string.IsNullOrEmpty(input.Client)) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Client", Logic = EnumFilterLogic.And, Value = input.Client }); + } + //出库类型 + if (!string.IsNullOrEmpty(input.Type)) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Type", Logic = EnumFilterLogic.And, Value = input.Type }); + } + var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, + input.SkipCount, true); + var totalCount = await GetCountAsync(input); + return new PagedResultDto(totalCount, entities); + } + + + private async Task GetCountAsync(WmsRequestDetailReportDto input) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); + return await _wmsRepository.GetCountByFilterAsync(GuidGenerator.Create(), input.Filters); + } + [HttpPost] + [Route("ModifyTaskState")] + + public virtual async Task ModifyTaskState(List guids) + { + if (guids != null && guids.Count() > 0) + { + var str = "DECLARE @return_value int \n" + + "EXEC @return_value = [dbo].[p_wms_interface_cancel]\n" + + "@billnum = N'{0}', \n" + + "@type = {1}, \n" + + "@date = N'{2}', \n" + + "@switchcode = N'{3}', \n" + + "@partcode = N'{4}' \n" + + "SELECT 'Return Value' = @return_value "; + + var _ls = _wmsRepository.Where(p => guids.Contains(p.Id)); + foreach (var itm in _ls) + { + var sql = string.Format(str, itm.BillNum, itm.Type, DateTime.Now, itm.SwitchCode, itm.MaterialCode); + _wmsRepository.GetDbContext().Database.SetCommandTimeout(300); + await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( + sql + ); + } + } + //_wmsRepository.Where(p => p.BillNum ==) + return true; + } + //[HttpPost] + //[Route("Output")] + + //virtual public async Task OutputAsync(WmsRequestDetailReportDto input) + //{ + // var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, int.MaxValue, + // 0, true); + // List _ls = new List(); + // if (entities.Count() > 0) + // { + // var _entity = entities.FirstOrDefault(); + // if (_entity != null) + // { + // var _version = _entity.Version; + // var _accountDate = _entity.AccountDate; + // _erpDapper.InsertWmsSum(_ls, _version, _accountDate); + // } + // } + // return true; + //} + [HttpPost] + [Route("Export")] + virtual public async Task ExportAsync(WmsRequestDetailReportDto input) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); + //客户过滤 + if (!string.IsNullOrEmpty(input.Client)) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Client", Logic = EnumFilterLogic.And, Value = input.Client }); + } + //出库类型 + if (!string.IsNullOrEmpty(input.Type)) + { + input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Type", Logic = EnumFilterLogic.And, Value = input.Type }); + } + var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, int.MaxValue, + 0, true); + var dtoDetails = ObjectMapper.Map, List>(entities); + IExporter _excel = new ExcelExporter(); + byte[] result = null; + var _fileName = string.Format("撤销清单报表_{0}.xlsx", Guid.NewGuid().ToString()); + result = await _excel.ExportAsByteArray(dtoDetails); + result.ShouldNotBeNull(); + //保存导出文件到服务器存成二进制 + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = _fileName, + Content = result + } + ); + return _fileName; + } + + + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs index 43109b34..70306950 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs @@ -1336,6 +1336,206 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report + + + public virtual List GetWmsSumCancelReportList(string version, string state) + { + + + + var _sql = "SELECT\n" + + " ROW_NUMBER()OVER(ORDER BY Type DESC) 行号 ,\n" + + " temp1.Client 客户,\n" + + " temp1.Type 出库类型,\n" + + " temp1.BillNum 结算单,\n" + + " temp1.MaterialCode 物料号,\n" + + " temp1.CNumber 通用代码号,\n" + + " Isnull( temp1.Qty, 0 ) 结算数量,\n" + + " Isnull( temp1.OutputQty, 0 ) 实际出库数量,\n" + + " Isnull( temp1.Qty, 0 )- Isnull( temp1.OutputQty, 0 ) 差异数量,\n" + + " temp1.Price 开票单价,\n" + + " Round( Isnull( temp1.Qty, 0 )* temp1.Price, 2 ) 结算金额,\n" + + " Round(( Isnull( temp1.Qty, 0 )- Isnull( temp1.OutputQty, 0 ))* temp1.Price, 2 ) WMS待出库金额, \n" + + " temp2.EstimateType 物料组编码, \n" + + " temp2.EstimateTypeDesc 物料组车型, \n" + + " temp2.MaterialDesc 物料描述, \n" + + " temp1.remark 备注 \n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " '大众准时化出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " Qty,\n" + + " 0 OutputQty,\n" + + " 0 IsBack,\n" + + " Price,\n" + + " ChassisNumber CNumber, \n" + + " Remark \n" + + " FROM\n" + + " Set_WmsJitOutPutDetial \n" + + " WHERE\n" + + " VERSION = '{0}' \n" + + " AND State = 4 UNION ALL\n" + + " SELECT\n" + + " '大众看板出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " Qty Qty,\n" + + " 0 OutputQty,\n" + + " 0 IsBack,\n" + + " Price,\n" + + " Kanban CNumber, \n" + + " Remark \n" + + " FROM\n" + + " Set_WmsKanbanOutPutDetial \n" + + " WHERE\n" + + " VERSION = '{0}' \n" + + " AND State = 4 UNION ALL\n" + + " SELECT\n" + + " '大众无看板出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " SapMaterialCode MaterialCode,\n" + + " Qty Qty,\n" + + " RealityNumber OutputQty,\n" + + " 0 IsBack,\n" + + " Price,\n" + + " '' CNumber, \n" + + " Remark \n" + + " FROM\n" + + " Set_WmsWithOutKanbanOutPutDetial \n" + + " WHERE\n" + + " VERSION = '{0}' \n" + + " AND State = 4 UNION ALL\n" + + " SELECT\n" + + " '大众备件汇总出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " Qty Qty,\n" + + " RealityNumber OutputQty,\n" + + " 1 IsBack,\n" + + " Price,\n" + + " '' CNumber, \n" + + " Remark \n" + + " FROM\n" + + " Set_WmsSharePartOutPutDetial \n" + + " WHERE\n" + + " VERSION = '{0}' \n" + + " AND State = 4 UNION ALL\n" + + " SELECT\n" + + " '大众备件条码出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " Qty Qty,\n" + + " 0 OutPutQty,\n" + + " 1 IsBack,\n" + + " Price,\n" + + " OrderBillNum CNumber, \n" + + " Remark \n" + + " FROM\n" + + " Set_WmsSharePart90OutPutDetial \n" + + " WHERE\n" + + " VERSION = '{0}' \n" + + " AND State = 4 UNION ALL\n" + + " SELECT\n" + + " '红旗看板出库' AS Type,\n" + + " '红旗' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " Qty Qty,\n" + + " 0 OutPutQty,\n" + + " 0 IsBack,\n" + + " Price,\n" + + " Kanban CNumber, \n" + + " Remark \n" + + " FROM\n" + + " Set_WmsHQHKanbanOutPutDetial \n" + + " WHERE\n" + + " VERSION = '{0}' \n" + + " AND State = 4 UNION ALL\n" + + " SELECT\n" + + " '红旗一轿手工出库' AS Type,\n" + + " '红旗' Client,\n" + + " BillNum,\n" + + " SapMaterialCode MaterialCode,\n" + + " Qty,\n" + + " RealityNumber OutputQty,\n" + + " IsBack,\n" + + " Price,\n" + + " '' CNumber, \n" + + " Remark \n" + + " FROM\n" + + " Set_WmsHQWithOutKanbanOutPutDetial \n" + + " WHERE\n" + + " IsBack = 0 \n" + + " AND VERSION = '{0}' \n" + + " AND State = 4 UNION ALL\n" + + " SELECT\n" + + " '红旗一轿手工出库(备件)' AS Type,\n" + + " '红旗' Client,\n" + + " BillNum,\n" + + " SapMaterialCode,\n" + + " Qty Qty,\n" + + " RealityNumber OutputQty,\n" + + " IsBack,\n" + + " Price,\n" + + " '' CNumber ,\n" + + " Remark \n" + + " FROM\n" + + " Set_WmsHQWithOutKanbanOutPutDetial \n" + + " WHERE\n" + + " IsBack = 1 \n" + + " AND VERSION = '{0}' \n" + + " AND State = 4 \n" + + + "UNION ALL\n" + +"SELECT\n" + +" '一次性销售' AS TYPE,\n" + +" '一次性销售' Client,\n" + +" BillNum,\n" + +" SapMaterialCode,\n" + +" Qty Qty,\n" + +" RealityNumber OutputQty,\n" + +" 0 IsBack,\n" + +" Price,\n" + +" '' CNumber,\n" + +" Remark \n" + +"FROM\n" + +" Set_WmsHQWithOutKanbanOutPutDetial \n" + +"WHERE\n" + +" VERSION = '{0}' \n" + +" AND State = 4" + + + + + + + + + + + + " ) temp1 \n" + + " LEFT JOIN(SELECT max(Id) Id, MaterialCode, MaterialDesc, EstimateType, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, EstimateType) temp2 ON temp1.MaterialCode = temp2.MaterialCode "; + + + _sql = string.Format(_sql, version, state); + + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + + return _query.ToList(); + } + + + + + + }