diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsUnInterface.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsUnInterface.cs index de29448c..463a8571 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsUnInterface.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsUnInterface.cs @@ -305,11 +305,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS checkList.Add(new ErrorExportDto() { Message = string.Format("结算号:{0}物料号:{1}实际出库数量不等于结算数量不能同步Sap", itm.BillNum, itm.MaterialCode) }); } - - var _count = entities.Count(p => p.State==2); - - if (_count > 1) { throw new BusinessException("8989", "记录中有已经完成记录!"); @@ -350,7 +346,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS _erpDapper.InsertWmsSum(entities, _version, _accountDate); } } - return ApplicationConsts.SuccessStr; ; + return ApplicationConsts.SuccessStr; } [HttpPost] [Route("Export")] 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 index 99f97b1d..116c1313 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsDapperRepository.cs @@ -16,7 +16,30 @@ using Win.Sfs.SettleAccount.Reports; namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { - + + + public class SalesStockSum + { + public string Version {set;get;} + public string PartCode {set;get;} + public string LocCode {set;get;} + public decimal StartQty {set;get;} + public decimal InQty {set;get;} + + public decimal OutQty {set;get;} + + public decimal EndQty {set;get;} + + public string Remark {set;get;} + public DateTime CreateTime {set;get;} + + public string OperName {set;get;} + + public DateTime StartTime { set; get; } + + public DateTime EndTime { set; get; } + } + public class SalesStock { @@ -43,6 +66,18 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report return _list.ToList(); + } + + + public virtual List GetSalesStockSum(string locCode) + { + string str = " select * from TM_PG_TIME_STOCK_DETAIL where LocCode ='{0}'"; + str=string.Format(str, locCode); + + var _list = DbConnection.Query(str); + return _list.ToList(); + + } //public virtual Dictionary GetSapList(List childList, string version, bool isNotHistoryPart = false) where T : ReportDetailBase, new() 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 759d92ea..671635d0 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 @@ -572,6 +572,29 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " SapMaterialCode,\n" + " IsBack,\n" + " Price \n" + +" union all\n" + +" SELECT\n" + +" '4009' LOGN,\n" + +" '一次性销售' AS Type,\n" + +" '一次性销售' Client,\n" + +" 'Z15' CODE,\n" + +" '10' SaleCode,\n" + +" Extend ClientCode,\n" + +" BillNum,\n" + +" SapMaterialCode,\n" + +" SUM( Qty ) Qty,\n" + +" 0 IsBack,\n" + +" Price \n" + +" FROM\n" + +" Set_WmsOneTimeSaleOutPutDetial\n" + +" WHERE\n" + +" \n" + +" VERSION = '{0}' \n" + +" GROUP BY\n" + +" BillNum,\n" + +" SapMaterialCode,\n" + +" Price, \n" + +" Extend\n" + " ) temp\n" + " LEFT JOIN ( SELECT max( Id ) Id, MaterialCode, MaterialDesc, EstimateType, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, EstimateType ) temp2 ON temp.MaterialCode = temp2.MaterialCode \n" + " ) t1 UNION ALL\n" + @@ -819,6 +842,36 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " SapMaterialCode,\n" + " IsBack,\n" + " Price \n" + +" union all\n" + +" SELECT\n" + +" '4009' LOGN,\n" + +" '一次性销售' AS Type,\n" + +" '一次性销售' Client,\n" + +" 'Z15' CODE,\n" + +" '10' SaleCode,\n" + +" Extend ClientCode,\n" + +" BillNum,\n" + +" SapMaterialCode,\n" + +" SUM( RealityNumber ) Qty,\n" + +" 0 IsBack,\n" + +" Price \n" + +" FROM\n" + +" Set_WmsOneTimeSaleOutPutDetial\n" + +" WHERE\n" + +" \n" + +" VERSION = '{0}' \n" + +" AND State = 2 \n" + +" GROUP BY\n" + +" BillNum,\n" + +" SapMaterialCode,\n" + +" Price, \n" + +" Extend \n"+ + + + + + + " ) temp\n" + " LEFT JOIN ( SELECT max( Id ) Id, MaterialCode, MaterialDesc, EstimateType, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, EstimateType ) temp2 ON temp.MaterialCode = temp2.MaterialCode \n" + " ) t2 \n" + @@ -826,6 +879,18 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " ORDER BY\n" + " 客户,出库类型,结算单;"; + + + + + + + + + + + + _sql = string.Format(_sql, version); var _query = DbConnection.Query(_sql, null, null, true, 1200, null); return _query.ToList(); 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 a93f45be..26e5cb9f 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs @@ -5,12 +5,17 @@ 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 UnSettledSum { + [ExporterHeader(DisplayName = "版本")] + public string 版本 { set; get; } + [ExporterHeader(DisplayName = "库位 ")] public string 库位 {set;get;} [ExporterHeader(DisplayName = "物料组编码 ")] @@ -37,11 +42,12 @@ namespace SettleAccount.Job.Services.Report public string 差异 { set; get; } } - public class UnSettledSumService + public class UnSettledSumService : ITransientDependency, IExportJob { private readonly HQHSettledDetailDapperRepository _hqkanbanDapper; private readonly KanbanUnSettledDapperRepository _kanbanDapper; private readonly UnSettledDetailDapperRepository _dapper; + private readonly WmsDapperRepository _wmsDapper; private readonly OutputService _outputService; private readonly ErpPartDapperRepository _erpDapper; public UnSettledSumService( @@ -49,7 +55,8 @@ namespace SettleAccount.Job.Services.Report KanbanUnSettledDapperRepository kanbanDapper, UnSettledDetailDapperRepository dapper, OutputService outputService, - ErpPartDapperRepository erpDapper + ErpPartDapperRepository erpDapper, + WmsDapperRepository _wmsDapper ) { _hqkanbanDapper = hqkanbanDapper; @@ -59,27 +66,38 @@ namespace SettleAccount.Job.Services.Report _erpDapper = erpDapper; } + public string ExportFile(Guid id, List exportName, List p_list) + { + GetReport(id,exportName,p_list); + return id.ToString(); + + } + + + + + public List GetFisSum(Guid id, List exportName, List p_list) { var _first = exportName.FirstOrDefault(); var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; - var customerCode = p_list.Where(p => p.Name == "CustomerCode").FirstOrDefault().Value; + 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 == "SapMaterialCode").FirstOrDefault().Value; + //var sapcode = p_list.Where(p => p.Name == "SapMaterialCode").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 kenncode = p_list.Where(p => p.Name == "KennCode").FirstOrDefault().Value; - var chassisNumber = p_list.Where(p => p.Name == "ChassisNumber").FirstOrDefault().Value; - var sapCode = p_list.Where(p => p.Name == "SapCode").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 sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value; //var cp7begin = p_list.Where(p => p.Name == "CP7Begin").FirstOrDefault().Value; //var cp7end = p_list.Where(p => p.Name == "CP7End").FirstOrDefault().Value; - var _list = _dapper.GetDiffReport(DateTime.Now.Year.ToString(), begin, end, customerCode, version, materailCode, materialGroup, sapcode); + var _list = _dapper.GetDiffReport(DateTime.Now.Year.ToString(), begin, end, "", version, materailCode, materialGroup, ""); var _ls = _list.Where(p => p.Flag != "L").Where(p => p.ParentSapMaterialCode != p.SapMaterialCode).GroupBy(p => new { p.KENNCode, p.ChassisNumber, p.ParentSapMaterialCode }).Select(p => p.FirstOrDefault()).ToList(); var _lst = _erpDapper.GetSapList(_ls, version, false); _lst.ForEach(p => @@ -99,30 +117,30 @@ namespace SettleAccount.Job.Services.Report _list = _list.Where(p => _groupList.Contains(p.MaterialGroup)).ToList(); } } - if (!string.IsNullOrEmpty(kenncode)) - { - var _groupList = kenncode.Split(new char[] { '\n' }).Distinct().ToList(); - if (_groupList.Count() > 0) - { - _list = _list.Where(p => _groupList.Contains(p.KENNCode)).ToList(); - } - } - if (!string.IsNullOrEmpty(chassisNumber)) - { - var _groupList = chassisNumber.Split(new char[] { '\n' }).Distinct().ToList(); - if (_groupList.Count() > 0) - { - _list = _list.Where(p => _groupList.Contains(p.ChassisNumber)).ToList(); - } - } - if (!string.IsNullOrEmpty(sapCode)) - { - var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); - if (_groupList.Count() > 0) - { - _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); - } - } + //if (!string.IsNullOrEmpty(kenncode)) + //{ + // var _groupList = kenncode.Split(new char[] { '\n' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _list = _list.Where(p => _groupList.Contains(p.KENNCode)).ToList(); + // } + //} + //if (!string.IsNullOrEmpty(chassisNumber)) + //{ + // var _groupList = chassisNumber.Split(new char[] { '\n' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _list = _list.Where(p => _groupList.Contains(p.ChassisNumber)).ToList(); + // } + //} + //if (!string.IsNullOrEmpty(sapCode)) + //{ + // var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); + // } + //} if (!string.IsNullOrEmpty(materailCode)) { var _groupList = materailCode.Split(new char[] { '\n' }).Distinct().ToList(); @@ -131,13 +149,15 @@ namespace SettleAccount.Job.Services.Report _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); } } - var _fislist= _lst.GroupBy(p =>new { p.SapMaterialCode,p.MaterialDesc,p.MaterialGroup,p.MaterialCode }) - .Select(p => new UnSettledSum - { 物料号= p.Key.SapMaterialCode, - 客户物料=p.Key.MaterialCode, - 物料描述=p.Key.MaterialDesc, - 物料组车型=p.Key.MaterialGroup, - SAS未结明细汇总= p.Sum(p => p.Qty).ToString() + var _fislist = _lst.GroupBy(p => new { p.SapMaterialCode, p.MaterialDesc, p.MaterialGroup, p.MaterialCode }) + .Select(p => new UnSettledSum + { + 版本 = version, + 物料号 = p.Key.SapMaterialCode, + 客户物料 = p.Key.MaterialCode, + 物料描述 = p.Key.MaterialDesc, + 物料组车型 = p.Key.MaterialGroup, + SAS未结明细汇总 = p.Sum(p => p.Qty).ToString() }).ToList(); return _fislist; @@ -146,15 +166,13 @@ namespace SettleAccount.Job.Services.Report { var _filename = exportName.FirstOrDefault(); var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; - var begin = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value; - var end = p_list.Where(p => p.Name == "EndTime").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 materailCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value; var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value; - var materialCode = p_list.Where(p => p.Name == "MatialCode").FirstOrDefault().Value; - var sapCode = p_list.Where(p => p.Name == "SAPCode").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 version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; //var customerCode = p_list.Where(p => p.Name == "CustomerCode").FirstOrDefault().Value; //var materailCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value; @@ -166,24 +184,21 @@ namespace SettleAccount.Job.Services.Report //var chassisNumber = p_list.Where(p => p.Name == "ChassisNumber").FirstOrDefault().Value; //var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value; - - - var _ls = _kanbanDapper.GetKanbanReportList(version, begin, end, iscontionversion); - - if (!string.IsNullOrEmpty(sapCode)) - { - var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); - if (_groupList.Count() > 0) - { - _ls = _ls.Where(p => _groupList.Contains(p.SapCode)).ToList(); - } - } - if (!string.IsNullOrEmpty(materialCode)) + //if (!string.IsNullOrEmpty(sapCode)) + //{ + // var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _ls = _ls.Where(p => _groupList.Contains(p.SapCode)).ToList(); + // } + //} + + if (!string.IsNullOrEmpty(materailCode)) { - var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList(); + var _groupList = materailCode.Split(new char[] { '\n' }).Distinct().ToList(); if (_groupList.Count() > 0) { _ls = _ls.Where(p => _groupList.Contains(p.CustomerPartCode)).ToList(); @@ -199,9 +214,10 @@ namespace SettleAccount.Job.Services.Report } - var kanbanList= _ls.GroupBy(p => new { p.SapCode, p.MaterialDesc, p.MaterialGroup, p.CustomerPartCode }) + var kanbanList = _ls.GroupBy(p => new { p.SapCode, p.MaterialDesc, p.MaterialGroup, p.CustomerPartCode }) .Select(p => new UnSettledSum { + 版本 = version, 物料号 = p.Key.SapCode, 客户物料 = p.Key.CustomerPartCode, 物料描述 = p.Key.MaterialDesc, @@ -223,8 +239,8 @@ namespace SettleAccount.Job.Services.Report 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 begin = p_list.Where(p => p.Name == "BeginTime").FirstOrDefault().Value; - var end = p_list.Where(p => p.Name == "EndTime").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 sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value; @@ -244,6 +260,7 @@ namespace SettleAccount.Job.Services.Report var kanbanList = _ls.GroupBy(p => new { p.Sap编码, p.零件中文名称, p.物料组, p.客户物料号 }) .Select(p => new UnSettledSum { + 版本=version, 物料号 = p.Key.Sap编码, 客户物料 = p.Key.客户物料号, 物料描述 = p.Key.零件中文名称, @@ -254,6 +271,42 @@ namespace SettleAccount.Job.Services.Report return kanbanList; } + + + + + public List GetReport(Guid id, List exportName, List p_list) + { + List _ls = new List(); + _ls.AddRange(GetFisSum(id, exportName, p_list)); + _ls.AddRange(GetHQKanbanSum(id, exportName, p_list)); + _ls.AddRange(GetKanbanSum(id, exportName, p_list)); + + + var _lst = _wmsDapper.GetSalesStockSum("pljs"); + var query = from itm in _ls join itm1 in _lst on new { Version = itm.版本, PartCode = itm.物料号 } equals new { Version = itm1.Version, PartCode = itm1.PartCode } + into temp from tm in temp.DefaultIfEmpty() + select new UnSettledSum { + + 版本 = itm.版本, + 物料号 = itm.物料号, + 客户物料 = itm.客户物料, + 物料描述 = itm.物料描述, + 物料组车型 = itm.物料组车型, + SAS未结明细汇总 = itm.SAS未结明细汇总, + WMS期初库存 = tm == null ? "0" : tm.StartQty.ToString(), + WMS期末库存 = tm == null ? "0" : tm.EndQty.ToString(), + 库位 = tm == null ? "" : tm.LocCode, + 本月减少 = tm == null ? "" : tm.OutQty.ToString(), + 本月增加 = tm == null ? "" : tm.InQty.ToString(), + + + + + + }; + return query.ToList(); + } } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs index a34ac671..189c98af 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs @@ -219,10 +219,20 @@ namespace Win.Sfs.SettleAccount { return implementationFactory.GetService(); } + + if (key.Equals(typeof(UnSettledSumService).FullName)) + { + return implementationFactory.GetService(); + } + + else { throw new ArgumentException($"Not Support key:{key}"); } + + + }; return accesor; });