diff --git a/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.Development.json b/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.Development.json index b6574412..8bcc29a5 100644 --- a/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.Development.json +++ b/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.Development.json @@ -7,11 +7,11 @@ // "SettleAccountService": "Server=LAPTOP-V3U07C2O;Database=SettleAccountService;user id=sa;Password=1q2w!@#;" //}, "ConnectionStrings": { - "Default": "Server=127.0.0.1;Database=ABP;user id=sa;Password=1", - "SettleAccountService": "Server=127.0.0.1;Database=SettleAccountService1;user id=sa;Password=1;" - //"Default": "Server=192.168.0.140;Database=ABP;User ID=sa;Password=Microsoft2008;", - //"SettleAccountService": "Server=192.168.0.140;Database=SettleAccountService;user id=sa;password=Microsoft2008;", - //"Wms": "Server=192.168.0.140;Database=CPAT_WMS_TEST;user id=sa;password=Microsoft2008;" + //"Default": "Server=127.0.0.1;Database=ABP;user id=sa;Password=1", + //"SettleAccountService": "Server=127.0.0.1;Database=SettleAccountService;user id=sa;Password=1;" + "Default": "Server=192.168.0.67;Database=ABP;User ID=sa;Password=Microsoft2008;", + "SettleAccountService": "Server=192.168.0.67;Database=SettleAccountService;user id=sa;password=Microsoft2008;", + "Wms": "Server=192.168.0.140;Database=CPAT_WMS_TEST;user id=sa;password=Microsoft2008;" }, "Logging": { "LogLevel": { diff --git a/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json b/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json index 49bec457..4f6dcfdb 100644 --- a/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json +++ b/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json @@ -7,10 +7,10 @@ // "SettleAccountService": "Server=LAPTOP-V3U07C2O;Database=SettleAccountService;user id=sa;Password=1q2w!@#;" //}, "ConnectionStrings": { - "Default": "Server=127.0.0.1;Database=ABP;user id=sa;Password=1", - "SettleAccountService": "Server=127.0.0.1;Database=SettleAccountService1;user id=sa;Password=1;", - //"Default": "Server=192.168.0.140;Database=ABP;User ID=sa;Password=Microsoft2008;", - //"SettleAccountService": "Server=192.168.0.140;Database=SettleAccountService;user id=sa;password=Microsoft2008;", + //"Default": "Server=127.0.0.1;Database=ABP;user id=sa;Password=1", + //"SettleAccountService": "Server=127.0.0.1;Database=SettleAccountService;user id=sa;Password=1;", + "Default": "Server=192.168.0.67;Database=ABP;User ID=sa;Password=Microsoft2008;", + "SettleAccountService": "Server=192.168.0.67;Database=SettleAccountService;user id=sa;password=Microsoft2008;", "Wms": "Server=192.168.0.140;Database=CPAT_WMS_TEST;user id=sa;password=Microsoft2008;" }, 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 e3a1be91..e6b027c5 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs @@ -47,6 +47,7 @@ using Win.Sfs.SettleAccount.Entities.WMS; using Win.Sfs.SettleAccount.Entities.Wms; using Win.Sfs.SettleAccount.Repository; using WY.NewJit.Extends.PaiGe.WMS; +using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; namespace Win.Sfs.SettleAccount.Entities.SettleAccounts { @@ -162,24 +163,117 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts foreach (var itm in _joblist) { itm.FileName = "已确认"; - } - foreach (var itm in _joblist) - { await _job.UpdateAsync(itm); } - var _count=await _job.BatchUpdateAsync(_joblist.ToList()); - if (_count > 0) + + return true; + } + + /// + /// 选择任务,生成出库单,只包含已确认的单据 + /// + /// + /// + /// + [HttpPost] + [Route("WmsWithOutKanbanOutPut")] + public async Task WmsWithOutKanbanOutPut(WmsJitRequestDto input) + { + var _billNum = "KA" + DateTime.Now.ToString("yyyyMMddhhmmss"); + + var _joblist = _job.Where(p => input.Guids.Contains(p.Id) && p.FileName == "已确认").ToList(); + if (_joblist.Count() > 0) { - return true; - } - return false; + var fileList = _joblist.Select(p => p.RealDownFileName).ToList(); + List _lst = new List(); + foreach (var filename in fileList) + { + 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) + { + + var _entity= new WmsKanbanOutPutDetial(GuidGenerator.Create(), string.Empty, string.Empty, itm.MaterialCode, itm.MaterialDesc + , itm.SapMaterialGroup, string.Empty, string.Empty, 0, string.Empty, string.Empty, itm.Version, itm.SapMaterialCode, + _billNum, Guid.Empty, string.Empty, itm.InvoiceQty + ); + + _lst.Add(_entity); + } + + } + + var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version && p.Kanban==string.Empty).ToListAsync(); + + //var error = from itm1 in outPutDetail + // join itm2 in _ls1 on + // new { itm1.MaterialCode, itm1.Kanban } + // equals + // new { itm2.MaterialCode, itm2.Kanban } + // 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 + // join itm2 in outPutDetail on + // new { itm1.MaterialCode, itm1.Kanban } + // equals + // new { itm2.MaterialCode, itm2.Kanban } into temp1 + // from tm1 in temp1.DefaultIfEmpty() + // where tm1 == null + // select itm1; + // var _wmslst = query.ToList(); + // foreach (var itm in _lst) + // { + // itm.BillNum = _billNum; + // } + await _wmsRepository.GetDbContext().BulkInsertAsync(_lst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); + int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); + if (_count == 0) + { + var _version = new WmsKanbanOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); + + await _wmsVersionRepository.InsertAsync(_version, true); + } + + foreach (var job in _joblist) + { + job.FileName = _billNum; + await _job.UpdateAsync(job); + } + } + //else + //{ + // StringBuilder _buffer = new StringBuilder(); + // foreach (var itm in errList) + // { + // _buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number); + // } + // var _errinfo = _buffer.ToString(); + + // foreach (var job in _joblist) + // { + // job.FileName = _errinfo; + // await _job.UpdateAsync(job); + // } + //} + //} + //else + //{ + // _billNum = string.Empty; + //} + return ApplicationConsts.SuccessStr; ; } - /// - /// 选择任务,生成出库单,只包含已确认的单据 - /// - /// - /// - /// + + + /// + /// 选择任务,生成出库单,只包含已确认的单据 + /// + /// + /// + /// [HttpPost] [Route("WmsKanbanOutPut")] public async Task WmsKanbanOutPut(WmsJitRequestDto input) @@ -198,7 +292,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts var _list = _excelHelper.ExcelToList(); foreach (var itm in _list) { - itm.SetId(GuidGenerator.Create()); + itm.SetId(GuidGenerator.Create(),string.Empty); } _lst.AddRange(_list.ToArray()); } @@ -390,6 +484,38 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); + + + var error = from itm1 in outPutDetail + join itm2 in _ls1 on + new { itm1.MaterialCode, itm1.Kanban } + equals + new { itm2.MaterialCode, itm2.Kanban } + select itm1; + var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); + + var checkList = new List(); + foreach (var itm in errList) + { + checkList.Add(new ErrorExportDto() { Message = string.Format("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number) }); + } + + + if (checkList.Count > 0) + { + + return await ExportErrorReportAsync(checkList); + } + + + + + + + + + + var query = from itm1 in _ls1 join itm2 in outPutDetail on new { itm1.MaterialCode, itm1.Kanban } 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 4add56fd..6fa83fb9 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs @@ -56,8 +56,8 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts [AllowAnonymous] [Route("api/settleaccount/wmsSharePartoutput")] - public class WMSSharePartAppService : - ApplicationService + public class WMSSharePartAppService : + SettleAccountApplicationBase { private readonly ISettleAccountBranchEfCoreRepository _wmsRepository; @@ -84,8 +84,11 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts ISettleAccountBranchEfCoreRepository wmsVersionRepository, WMSEfCoreRepository wmsefRespository, WMSEfCoreRepository wmstbRespository, - IExcelImportAppService excelImportService - ) + IExcelImportAppService excelImportService, + IDistributedCache cache, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) { _excelImportService = excelImportService; _job = job; @@ -388,6 +391,33 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); + + var error = from itm1 in outPutDetail + join itm2 in _ls1 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) }); + + var checkList = new List(); + foreach (var itm in errList) + { + checkList.Add(new ErrorExportDto() { Message = string.Format("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number) }); + } + + + if (checkList.Count > 0) + { + + return await ExportErrorReportAsync(checkList); + } + + + + + + var query = from itm1 in _ls1 join itm2 in outPutDetail on new { itm1.MaterialCode, itm1.OrderBillNum } 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 380bae42..24047cb6 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -149,6 +149,30 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices return _taskid; } + [HttpPost] + [Route("SettleKanBan-WithOutCode")] + [DisableRequestSizeLimit] + + public async Task SettledKanBanWithOutCode(BaseKanbanReqestDto input) + { + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "Version", Value = input.Version ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = input.CustomerCode ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "CustomerPartCode", Value = input.CustomerPartCode ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "State", Value = input.State ?? "0" }); + customConditionList.Add(new CustomCondition() { Name = "EstimateTypeDesc", Value = input.EstimateTypeDesc ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "有条码看板结算核对" }); + customConditionList.Add(new CustomCondition() { Name = "Kanban", Value = input.KanBan ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "SapMaterialCode", Value = input.SapMaterialCode ?? string.Empty }); + 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) => + { + }); + 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 f3115353..7a08862f 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml @@ -1672,7 +1672,7 @@ wms出库 - + @@ -1739,7 +1739,7 @@ wms出库 - + @@ -1770,6 +1770,14 @@ 上传的文件(前端已经限制只能上传一个附件) + + + 选择任务,生成出库单,只包含已确认的单据 + + + + + 选择任务,生成出库单,只包含已确认的单据 @@ -1799,7 +1807,7 @@ wms出库 - + 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 b7075954..5a288fba 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs @@ -257,9 +257,10 @@ namespace Win.Sfs.SettleAccount.Entities.WMS Remark = remark; Qty = qty; } - public void SetId(Guid id) + public void SetId(Guid id,string remark) { Id = id; + Remark = remark; } @@ -272,7 +273,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS public string ParentMaterialCode { set; get; } [ImporterHeader(Name = "交货单号")] public string WmsBillNum { set; get; } - [ImporterHeader(Name = "看板号")] + [ImporterHeader(Name = "条码号")] //KENN号 public string Kanban { set; get; } @@ -285,15 +286,15 @@ namespace Win.Sfs.SettleAccount.Entities.WMS [ImporterHeader(Name = "物料组(车型)")] //物料组(车型) public string MaterialGroup { set; get; } - [ImporterHeader(Name = "出库库位")] + [ImporterHeader(Name = "出库库位",IsIgnore =true)] //出库库位 public string OutPut { set; get; } - [ImporterHeader(Name = "入库库位")] + [ImporterHeader(Name = "入库库位", IsIgnore = true)] //入库库位 public string InPut { set; get; } [ImporterHeader(Name = "状态")] public int State { get; set; } - [ImporterHeader(Name = "扩展字段1")] + [ImporterHeader(Name = "扩展字段1", IsIgnore = true)] /// /// 扩展字段1 /// @@ -301,17 +302,17 @@ namespace Win.Sfs.SettleAccount.Entities.WMS /// /// 扩展字段2 /// - [ImporterHeader(Name = "扩展字段2")] + [ImporterHeader(Name = "扩展字段2", IsIgnore = true)] public string Extend2 { set; get; } /// /// 扩展字段3 /// - [ImporterHeader(Name = "版本号")] + [ImporterHeader(Name = "版本号", IsIgnore = true)] public string Version { set; get; } - [ImporterHeader(Name = "数量")] + [ImporterHeader(Name = "结算数量",IsIgnore =true)] public decimal? Qty { set; get; } - [ImporterHeader(Name = "数量", IsIgnore = true)] + [ImporterHeader(Name = "单据", IsIgnore = true)] public string BillNum { set; get; } diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs index ad223d09..111a2d66 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/KanbanUnSettledDapperRepository.cs @@ -15,6 +15,50 @@ using Win.Sfs.SettleAccount.FISes; namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { + + public class SettleKBWithOutCode + { + // Factory MaterialCode InvoiceQty InvoiceAmt InvoicePrice SapMaterialCode MaterialDesc SapMaterialGroup DiffPrice SalePrice SocketQty + + + + [ExporterHeader(DisplayName = "期间")] + public string Version { get; set; } + [ExporterHeader(DisplayName = "物料组")] + public string SapMaterialGroup { get; set; } + [ExporterHeader(DisplayName = "SAP编号")] + public string SapMaterialCode { get; set; } + [ExporterHeader(DisplayName = "工厂")] + public string Factory { get; set; } + [ExporterHeader(DisplayName = "零件编号")] + public string MaterialCode { get; set; } + [ExporterHeader(DisplayName = "零件名称")] + public string MaterialDesc { get; set; } + [ExporterHeader(DisplayName = "开票数量")] + public decimal InvoiceQty { get; set; } + [ExporterHeader(DisplayName = "金额")] + public decimal InvoiceAmt { get; set; } + [ExporterHeader(DisplayName = "开票单价")] + public decimal InvoicePrice { get; set; } + [ExporterHeader(DisplayName = "库存数量")] + public decimal SocketQty { get; set; } + //[ExporterHeader(DisplayName = "数量差")] + //public decimal DiffQty { get; set; } + //[ExporterHeader(DisplayName = "CP7报废")] + //public decimal CP7ScrapQty { get; set; } + //[ExporterHeader(DisplayName = "索赔/退货")] + //public decimal ClaimQty { get; set; } + [ExporterHeader(DisplayName = "定价")] + public decimal SalePrice { get; set; } + [ExporterHeader(DisplayName = "价格差异")] + public decimal DiffPrice { get; set; } + } + + + + + + public class KanbanUnSettled { [ExporterHeader(DisplayName = "交货单号")] @@ -73,7 +117,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report - + public class KanbanUnSettledDapperRepository : DapperRepository, ITransientDependency { @@ -81,7 +125,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { } - public virtual List GetKanbanReportList( string version, string begintime, string endtime) + public virtual List GetKanbanReportList(string version, string begintime, string endtime) { string sql = " SELECT\n" + @@ -110,12 +154,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " ) TEMP1\n" + " LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT MAX( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode"; string str = string.Empty; - str += " where 1=1 "; + str += " where 1=1 "; var _query = DbConnection.Query(sql, null, null, true, 1200, null); var _list = _query.ToList(); return _list; } - public virtual List GetNoKanbanReportList( string version, string begintime, string endtime) + public virtual List GetNoKanbanReportList(string version, string begintime, string endtime) { var sql = "SELECT\n" + " TEMP1.*,\n" + @@ -144,6 +188,103 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report var _list = _query.ToList(); return _list; } + public virtual List GetNoKanbanSettleDetail(string version, string begintime, string endtime) + { + var sql = + + " SELECT\n" + + " '{0}' Version ,"+ + " temp1.Factory,\n" + + " temp1.MaterialCode,\n" + + " temp1.InvoiceQty,\n" + + " temp1.InvoiceAmt,\n" + + " temp1.InvoicePrice,\n" + + " temp1.SapMaterialCode,\n" + + " temp1.MaterialDesc,\n" + + " temp1.SapMaterialGroup,\n" + + " temp1.InvoicePrice - ISNULL( temp2.Price, 0 ) AS DiffPrice,\n" + + " temp2.Price AS SalePrice \n" + + " FROM\n" + + " (\n" + + " SELECT\n" + + " b.Factory,\n" + + " b.MaterialCode,\n" + + " b.InvoiceQty,\n" + + " b.InvoiceAmt,\n" + + " b.InvoicePrice,\n" + + " g.MaterialCode AS SapMaterialCode,\n" + + " g.MaterialDesc,\n" + + " g.EstimateTypeDesc AS SapMaterialGroup \n" + + " FROM\n" + + " (\n" + + " SELECT\n" + + " Factory,\n" + + " MaterialCode,\n" + + " SUM( Qty ) AS InvoiceQty,\n" + + " SUM( Amt ) AS InvoiceAmt,\n" + + " SUM( Amt ) / SUM( Qty ) AS InvoicePrice \n" + + " FROM\n" + + " Set_Invoice \n" + + " WHERE\n" + + " ( Version = '{0}' ) \n" + + " GROUP BY\n" + + " MaterialCode,\n" + + " Factory \n" + + " ) AS b\n" + + " LEFT OUTER JOIN ( SELECT SUM( Qty ) AS Qty, MaterialCode FROM Set_Settle WHERE ( Version = '{0}' ) GROUP BY MaterialCode ) AS c ON b.MaterialCode = c.MaterialCode\n" + + " LEFT OUTER JOIN (\n" + + " SELECT\n" + + " Id,\n" + + " YEAR,\n" + + " Period,\n" + + " Version,\n" + + " Type,\n" + + " MaterialCode,\n" + + " MaterialDesc,\n" + + " Qty,\n" + + " Amt,\n" + + " Extend,\n" + + " ExtraProperties,\n" + + " ConcurrencyStamp,\n" + + " CreationTime,\n" + + " CreatorId,\n" + + " LastModificationTime,\n" + + " LastModifierId,\n" + + " IsDeleted,\n" + + " DeleterId,\n" + + " DeletionTime,\n" + + " BranchId,\n" + + " Enabled,\n" + + " Remark \n" + + " FROM\n" + + " Set_ScrapClaims \n" + + " WHERE\n" + + " ( Version = '{0}' )) AS e ON b.MaterialCode = e.MaterialCode\n" + + " LEFT OUTER JOIN Set_material AS g ON b.MaterialCode = g.CustomerPartCode \n" + + " ) AS temp1\n" + + " LEFT OUTER JOIN (\n" + + " SELECT\n" + + " Price,\n" + + " MaterialCode \n" + + " FROM\n" + + " Set_PriceList \n" + + " WHERE\n" + + " (\n" + + " Version = ( SELECT MAX( Version ) AS Expr1 FROM Set_PriceListVersion ))) AS temp2 ON temp1.SapMaterialCode = temp2.MaterialCode \n" + + "WHERE\n" + + " (\n" + + " temp1.SapMaterialGroup IN ( '柱护板成品-NCS', '高光盖板成品-BORA', '高光盖板成品-A SUV', '高光盖板成品-B9 ACC', '成品-NCS NF装饰条', '成品-Q3 HG' ))"; + string str = string.Empty; + str += " where 1=1 "; + sql = string.Format(sql, version); + var _query = DbConnection.Query(sql, null, null, true, 1200, null); + var _list = _query.ToList(); + return _list; + + + + + } } } 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 cab4eb02..b89de6ea 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 @@ -71,7 +71,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " LEFT JOIN ( SELECT Price, --定价\n" + " MaterialCode --厂内物料号\n" + " FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapMaterialCode= TEMP2.MaterialCode \n" + - "WHERE 1=1 {1}"; + "WHERE 1=1 "; string addwhere = string.Empty; string addSqlStr = string.Format(sqlString, version); //if (!string.IsNullOrEmpty(kanBan)) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleKBWithCodeExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleKBWithCodeExportService.cs index cf8eb52b..27b450a3 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleKBWithCodeExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleKBWithCodeExportService.cs @@ -48,9 +48,12 @@ namespace SettleAccount.Job.Services.Report foreach (var itm in diffList) { var _first = _list.FirstOrDefault(p => p.MaterialCode == itm.MaterialCode); - _first.InvoiceDiffQty = _first.SettleNumber + itm.DiffQty;//开票数量(结算数量+差异) - _first.InvoiceMoney = _first.InvoiceDiffQty * _first.InvoicePrice;//开票总金额(开票数量*开票单价) - _first.SumDiffMoney = (_first.SettleNumber * _first.Price) - _first.InvoiceMoney;//总金额差异(结算金额-开票金额) + if (_first != null) + { + _first.InvoiceDiffQty = _first.SettleNumber + itm.DiffQty;//开票数量(结算数量+差异) + _first.InvoiceMoney = _first.InvoiceDiffQty * _first.InvoicePrice;//开票总金额(开票数量*开票单价) + _first.SumDiffMoney = (_first.SettleNumber * _first.Price) - _first.InvoiceMoney;//总金额差异(结算金额-开票金额) + } } } if (!string.IsNullOrEmpty(materialGroup)) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleKBWithOutCodeExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleKBWithOutCodeExportService.cs new file mode 100644 index 00000000..37b785f8 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleKBWithOutCodeExportService.cs @@ -0,0 +1,111 @@ +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 SettleKBWithOutCodeExportService : ITransientDependency, IExportJob + { + private readonly KanbanUnSettledDapperRepository _dapper; + private readonly OutputService _outputService; + private readonly ErpPartDapperRepository _erpdapperRepository; + + public SettleKBWithOutCodeExportService(KanbanUnSettledDapperRepository dapper, + OutputService outputService, + ErpPartDapperRepository erpdapperRepository) + { + _dapper = dapper; + _outputService = outputService; + _erpdapperRepository = erpdapperRepository; + } + + + public string ExportFile(Guid id, List exportName, List p_list) + { + + var _filename = exportName.FirstOrDefault(); + var sapMaterialCode = p_list.Where(p => p.Name == "SapMaterialCode").FirstOrDefault().Value; + + + var customerPartCode = p_list.Where(p => p.Name == "CustomerPartCode").FirstOrDefault().Value; + var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; + var materialGroup = p_list.Where(p => p.Name == "EstimateTypeDesc").FirstOrDefault().Value; + var kanban = p_list.Where(p => p.Name == "Kanban").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.GetNoKanbanSettleDetail(version, beginTime, endTime); + //var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version); + //if (diffList != null) + //{ + // foreach (var itm in diffList) + // { + // var _first = _list.FirstOrDefault(p => p.MaterialCode == itm.MaterialCode); + // _first.InvoiceDiffQty = _first.SettleNumber + itm.DiffQty;//开票数量(结算数量+差异) + // _first.InvoiceMoney = _first.InvoiceDiffQty * _first.InvoicePrice;//开票总金额(开票数量*开票单价) + // _first.SumDiffMoney = (_first.SettleNumber * _first.Price) - _first.InvoiceMoney;//总金额差异(结算金额-开票金额) + // } + //} + if (!string.IsNullOrEmpty(materialGroup)) + { + var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _list = _list.Where(p => _groupList.Contains(p.SapMaterialGroup)).ToList(); + } + } + + if (!string.IsNullOrEmpty(sapMaterialCode)) + { + var _groupList = sapMaterialCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); + } + } + + if (!string.IsNullOrEmpty(customerPartCode)) + { + var _groupList = customerPartCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); + } + } + + //if (!string.IsNullOrEmpty(beginTime)) + //{ + // _list = _list.Where(p => DateTime.Parse(beginTime)<=p.ActualGoodsDate).ToList(); + //} + //if (!string.IsNullOrEmpty(endTime)) + //{ + // _list = _list.Where(p => DateTime.Parse(endTime) >= p.ActualGoodsDate).ToList(); + //} + + //if (!string.IsNullOrEmpty(kanban)) + //{ + // var _groupList = kanban.Split(new char[] { '\n' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _list = _list.Where(p => _groupList.Contains(p.Kanban)).ToList(); + // } + //} + + + + + _outputService.Export(id,_filename , _list); + + return id.ToString(); + } + + + } +} 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 cf100c2e..81de8f03 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs @@ -26,7 +26,7 @@ namespace SettleAccount.Job.Services.Report public string ExportFile(Guid id, List exportName, List p_list) { - var year = p_list.Where(p => p.Name == "Year").FirstOrDefault().Value; + 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; @@ -40,9 +40,12 @@ namespace SettleAccount.Job.Services.Report foreach (var itm in diffList) { var _first = _list.FirstOrDefault(p => p.MaterialCode == itm.MaterialCode); - _first.InvoicedQty = _first.InvoicedQty + itm.DiffQty;//开票数量(结算数量+差异) - _first.InvoiceMoney =Math.Round(_first.InvoicedQty * _first.InvoicePrice,2);//开票总金额(开票数量*开票单价) - _first.SumDiffMoney = (_first.ReceiptQty * _first.Price) - _first.InvoiceMoney;//总金额差异(结算金额-开票金额) + if (_first != null) + { + _first.InvoicedQty = _first.InvoicedQty + itm.DiffQty;//开票数量(结算数量+差异) + _first.InvoiceMoney = Math.Round(_first.InvoicedQty * _first.InvoicePrice, 2);//开票总金额(开票数量*开票单价) + _first.SumDiffMoney = (_first.ReceiptQty * _first.Price) - _first.InvoiceMoney;//总金额差异(结算金额-开票金额) + } } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs index 639da150..5de1afde 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs @@ -140,6 +140,13 @@ namespace Win.Sfs.SettleAccount { return implementationFactory.GetService(); } + if (key.Equals(typeof(SettleKBWithOutCodeExportService).FullName)) + { + return implementationFactory.GetService(); + } + + + else {