@ -5,12 +5,17 @@ using System.Linq;
using System.Text ;
using System.Text ;
using System.Threading.Tasks ;
using System.Threading.Tasks ;
using TaskJob.EventArgs ;
using TaskJob.EventArgs ;
using TaskJob.Interfaces ;
using Volo.Abp.DependencyInjection ;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report ;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report ;
namespace SettleAccount.Job.Services.Report
namespace SettleAccount.Job.Services.Report
{
{
public class UnSettledSum
public class UnSettledSum
{
{
[ExporterHeader(DisplayName = "版本")]
public string 版 本 { set ; get ; }
[ExporterHeader(DisplayName = "库位 ")]
[ExporterHeader(DisplayName = "库位 ")]
public string 库 位 { set ; get ; }
public string 库 位 { set ; get ; }
[ExporterHeader(DisplayName = "物料组编码 ")]
[ExporterHeader(DisplayName = "物料组编码 ")]
@ -37,11 +42,12 @@ namespace SettleAccount.Job.Services.Report
public string 差 异 { set ; get ; }
public string 差 异 { set ; get ; }
}
}
public class UnSettledSumService
public class UnSettledSumService : ITransientDependency , IExportJob
{
{
private readonly HQHSettledDetailDapperRepository _ hqkanbanDapper ;
private readonly HQHSettledDetailDapperRepository _ hqkanbanDapper ;
private readonly KanbanUnSettledDapperRepository _ kanbanDapper ;
private readonly KanbanUnSettledDapperRepository _ kanbanDapper ;
private readonly UnSettledDetailDapperRepository _d apper ;
private readonly UnSettledDetailDapperRepository _d apper ;
private readonly WmsDapperRepository _ wmsDapper ;
private readonly OutputService _ outputService ;
private readonly OutputService _ outputService ;
private readonly ErpPartDapperRepository _ erpDapper ;
private readonly ErpPartDapperRepository _ erpDapper ;
public UnSettledSumService (
public UnSettledSumService (
@ -49,7 +55,8 @@ namespace SettleAccount.Job.Services.Report
KanbanUnSettledDapperRepository kanbanDapper ,
KanbanUnSettledDapperRepository kanbanDapper ,
UnSettledDetailDapperRepository dapper ,
UnSettledDetailDapperRepository dapper ,
OutputService outputService ,
OutputService outputService ,
ErpPartDapperRepository erpDapper
ErpPartDapperRepository erpDapper ,
WmsDapperRepository _ wmsDapper
)
)
{
{
_ hqkanbanDapper = hqkanbanDapper ;
_ hqkanbanDapper = hqkanbanDapper ;
@ -59,27 +66,38 @@ namespace SettleAccount.Job.Services.Report
_ erpDapper = erpDapper ;
_ erpDapper = erpDapper ;
}
}
public string ExportFile ( Guid id , List < string > exportName , List < CustomCondition > p_list )
{
GetReport ( id , exportName , p_list ) ;
return id . ToString ( ) ;
}
public List < UnSettledSum > GetFisSum ( Guid id , List < string > exportName , List < CustomCondition > p_list )
public List < UnSettledSum > GetFisSum ( Guid id , List < string > exportName , List < CustomCondition > p_list )
{
{
var _f irst = exportName . FirstOrDefault ( ) ;
var _f irst = exportName . FirstOrDefault ( ) ;
var version = p_list . Where ( p = > p . Name = = "Version" ) . 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 ;
var materailCode = p_list . Where ( p = > p . Name = = "MaterialCode" ) . FirstOrDefault ( ) . Value ;
var materialGroup = p_list . Where ( p = > p . Name = = "MaterialGroup" ) . 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 begin = p_list . Where ( p = > p . Name = = "Begin" ) . FirstOrDefault ( ) . Value ;
var end = p_list . Where ( p = > p . Name = = "End" ) . 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 kenncode = p_list.Where(p => p.Name == "KennCode").FirstOrDefault().Value;
var chassisNumber = p_list . Where ( p = > p . Name = = "ChassisNumber" ) . 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 sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value;
//var cp7begin = p_list.Where(p => p.Name == "CP7Begin").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 cp7end = p_list.Where(p => p.Name == "CP7End").FirstOrDefault().Value;
var _l ist = _d apper . GetDiffReport ( DateTime . Now . Year . ToString ( ) , begin , end , customerCode , version , materailCode , materialGroup , sapcode ) ;
var _l ist = _d apper . GetDiffReport ( DateTime . Now . Year . ToString ( ) , begin , end , "" , version , materailCode , materialGroup , "" ) ;
var _l s = _l ist . 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 _l s = _l ist . 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 _l st = _ erpDapper . GetSapList ( _l s , version , false ) ;
var _l st = _ erpDapper . GetSapList ( _l s , version , false ) ;
_l st . ForEach ( p = >
_l st . ForEach ( p = >
@ -99,30 +117,30 @@ namespace SettleAccount.Job.Services.Report
_l ist = _l ist . Where ( p = > _ groupList . Contains ( p . MaterialGroup ) ) . ToList ( ) ;
_l ist = _l ist . Where ( p = > _ groupList . Contains ( p . MaterialGroup ) ) . ToList ( ) ;
}
}
}
}
if ( ! string . IsNullOrEmpty ( kenncode ) )
//if (!string.IsNullOrEmpty(kenncode))
{
//{
var _ groupList = kenncode . Split ( new char [ ] { '\n' } ) . Distinct ( ) . ToList ( ) ;
// var _groupList = kenncode.Split(new char[] { '\n' }).Distinct().ToList();
if ( _ groupList . Count ( ) > 0 )
// if (_groupList.Count() > 0)
{
// {
_l ist = _l ist . Where ( p = > _ groupList . Contains ( p . KENNCode ) ) . ToList ( ) ;
// _list = _list.Where(p => _groupList.Contains(p.KENNCode)).ToList();
}
// }
}
//}
if ( ! string . IsNullOrEmpty ( chassisNumber ) )
//if (!string.IsNullOrEmpty(chassisNumber))
{
//{
var _ groupList = chassisNumber . Split ( new char [ ] { '\n' } ) . Distinct ( ) . ToList ( ) ;
// var _groupList = chassisNumber.Split(new char[] { '\n' }).Distinct().ToList();
if ( _ groupList . Count ( ) > 0 )
// if (_groupList.Count() > 0)
{
// {
_l ist = _l ist . Where ( p = > _ groupList . Contains ( p . ChassisNumber ) ) . ToList ( ) ;
// _list = _list.Where(p => _groupList.Contains(p.ChassisNumber)).ToList();
}
// }
}
//}
if ( ! string . IsNullOrEmpty ( sapCode ) )
//if (!string.IsNullOrEmpty(sapCode))
{
//{
var _ groupList = sapCode . Split ( new char [ ] { '\n' } ) . Distinct ( ) . ToList ( ) ;
// var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
if ( _ groupList . Count ( ) > 0 )
// if (_groupList.Count() > 0)
{
// {
_l ist = _l ist . Where ( p = > _ groupList . Contains ( p . SapMaterialCode ) ) . ToList ( ) ;
// _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList();
}
// }
}
//}
if ( ! string . IsNullOrEmpty ( materailCode ) )
if ( ! string . IsNullOrEmpty ( materailCode ) )
{
{
var _ groupList = materailCode . Split ( new char [ ] { '\n' } ) . Distinct ( ) . ToList ( ) ;
var _ groupList = materailCode . Split ( new char [ ] { '\n' } ) . Distinct ( ) . ToList ( ) ;
@ -131,13 +149,15 @@ namespace SettleAccount.Job.Services.Report
_l ist = _l ist . Where ( p = > _ groupList . Contains ( p . SapMaterialCode ) ) . ToList ( ) ;
_l ist = _l ist . Where ( p = > _ groupList . Contains ( p . SapMaterialCode ) ) . ToList ( ) ;
}
}
}
}
var _f islist = _l st . GroupBy ( p = > new { p . SapMaterialCode , p . MaterialDesc , p . MaterialGroup , p . MaterialCode } )
var _f islist = _l st . GroupBy ( p = > new { p . SapMaterialCode , p . MaterialDesc , p . MaterialGroup , p . MaterialCode } )
. Select ( p = > new UnSettledSum
. Select ( p = > new UnSettledSum
{ 物 料 号 = p . Key . SapMaterialCode ,
{
客 户 物 料 = p . Key . MaterialCode ,
版 本 = version ,
物 料 描 述 = p . Key . MaterialDesc ,
物 料 号 = p . Key . SapMaterialCode ,
物 料 组 车 型 = p . Key . MaterialGroup ,
客 户 物 料 = p . Key . MaterialCode ,
SAS未结明细汇总 = p . Sum ( p = > p . Qty ) . ToString ( )
物 料 描 述 = p . Key . MaterialDesc ,
物 料 组 车 型 = p . Key . MaterialGroup ,
SAS未结明细汇总 = p . Sum ( p = > p . Qty ) . ToString ( )
} ) . ToList ( ) ;
} ) . ToList ( ) ;
return _f islist ;
return _f islist ;
@ -146,15 +166,13 @@ namespace SettleAccount.Job.Services.Report
{
{
var _f ilename = exportName . FirstOrDefault ( ) ;
var _f ilename = exportName . FirstOrDefault ( ) ;
var version = p_list . Where ( p = > p . Name = = "Version" ) . FirstOrDefault ( ) . Value ;
var version = p_list . Where ( p = > p . Name = = "Version" ) . FirstOrDefault ( ) . Value ;
var begin = p_list . Where ( p = > p . Name = = "BegingTime" ) . FirstOrDefault ( ) . Value ;
var begin = p_list . Where ( p = > p . Name = = "Begin" ) . FirstOrDefault ( ) . Value ;
var end = p_list . Where ( p = > p . Name = = "EndTime" ) . 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 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 iscontionversion = p_list . Where ( p = > p . Name = = "IsContainVersion" ) . FirstOrDefault ( ) . Value ;
//var version = p_list.Where(p => p.Name == "Version").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 customerCode = p_list.Where(p => p.Name == "CustomerCode").FirstOrDefault().Value;
//var materailCode = p_list.Where(p => p.Name == "MaterialCode").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 chassisNumber = p_list.Where(p => p.Name == "ChassisNumber").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 _l s = _ kanbanDapper . GetKanbanReportList ( version , begin , end , iscontionversion ) ;
var _l s = _ kanbanDapper . GetKanbanReportList ( version , begin , end , iscontionversion ) ;
if ( ! string . IsNullOrEmpty ( sapCode ) )
{
var _ groupList = sapCode . Split ( new char [ ] { '\n' } ) . Distinct ( ) . ToList ( ) ;
if ( _ groupList . Count ( ) > 0 )
{
_l s = _l s . 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 = materai lCode . Split ( new char [ ] { '\n' } ) . Distinct ( ) . ToList ( ) ;
if ( _ groupList . Count ( ) > 0 )
if ( _ groupList . Count ( ) > 0 )
{
{
_l s = _l s . Where ( p = > _ groupList . Contains ( p . CustomerPartCode ) ) . ToList ( ) ;
_l s = _l s . Where ( p = > _ groupList . Contains ( p . CustomerPartCode ) ) . ToList ( ) ;
@ -199,9 +214,10 @@ namespace SettleAccount.Job.Services.Report
}
}
var kanbanList = _l s . GroupBy ( p = > new { p . SapCode , p . MaterialDesc , p . MaterialGroup , p . CustomerPartCode } )
var kanbanList = _l s . GroupBy ( p = > new { p . SapCode , p . MaterialDesc , p . MaterialGroup , p . CustomerPartCode } )
. Select ( p = > new UnSettledSum
. Select ( p = > new UnSettledSum
{
{
版 本 = version ,
物 料 号 = p . Key . SapCode ,
物 料 号 = p . Key . SapCode ,
客 户 物 料 = p . Key . CustomerPartCode ,
客 户 物 料 = p . Key . CustomerPartCode ,
物 料 描 述 = p . Key . MaterialDesc ,
物 料 描 述 = p . Key . MaterialDesc ,
@ -223,8 +239,8 @@ namespace SettleAccount.Job.Services.Report
var version = p_list . Where ( p = > p . Name = = "Version" ) . FirstOrDefault ( ) . Value ;
var version = p_list . Where ( p = > p . Name = = "Version" ) . FirstOrDefault ( ) . Value ;
var materialCode = p_list . Where ( p = > p . Name = = "MaterialCode" ) . 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 = = "BeginTime " ) . FirstOrDefault ( ) . Value ;
var begin = p_list . Where ( p = > p . Name = = "Begin" ) . FirstOrDefault ( ) . Value ;
var end = p_list . Where ( p = > p . Name = = "EndTime " ) . 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 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 sapCode = p_list . Where ( p = > p . Name = = "SapCode" ) . FirstOrDefault ( ) . Value ;
@ -244,6 +260,7 @@ namespace SettleAccount.Job.Services.Report
var kanbanList = _l s . GroupBy ( p = > new { p . Sap编码 , p . 零 件 中 文 名 称 , p . 物 料 组 , p . 客 户 物 料 号 } )
var kanbanList = _l s . GroupBy ( p = > new { p . Sap编码 , p . 零 件 中 文 名 称 , p . 物 料 组 , p . 客 户 物 料 号 } )
. Select ( p = > new UnSettledSum
. Select ( p = > new UnSettledSum
{
{
版 本 = version ,
物 料 号 = p . Key . Sap编码 ,
物 料 号 = p . Key . Sap编码 ,
客 户 物 料 = p . Key . 客 户 物 料 号 ,
客 户 物 料 = p . Key . 客 户 物 料 号 ,
物 料 描 述 = p . Key . 零 件 中 文 名 称 ,
物 料 描 述 = p . Key . 零 件 中 文 名 称 ,
@ -254,6 +271,42 @@ namespace SettleAccount.Job.Services.Report
return kanbanList ;
return kanbanList ;
}
}
public List < UnSettledSum > GetReport ( Guid id , List < string > exportName , List < CustomCondition > p_list )
{
List < UnSettledSum > _l s = new List < UnSettledSum > ( ) ;
_l s . AddRange ( GetFisSum ( id , exportName , p_list ) ) ;
_l s . AddRange ( GetHQKanbanSum ( id , exportName , p_list ) ) ;
_l s . AddRange ( GetKanbanSum ( id , exportName , p_list ) ) ;
var _l st = _ wmsDapper . GetSalesStockSum ( "pljs" ) ;
var query = from itm in _l s join itm1 in _l st 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 ( ) ;
}
}
}
}
}