Administrator
3 years ago
3 changed files with 284 additions and 113 deletions
@ -1,109 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using TaskJob.EventArgs; |
|||
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; |
|||
|
|||
namespace SettleAccount.Job.Services.Report |
|||
{ |
|||
public class UnSettledSumService |
|||
{ |
|||
|
|||
private readonly UnSettledDetailDapperRepository _dapper; |
|||
private readonly OutputService _outputService; |
|||
private readonly ErpPartDapperRepository _erpDapper; |
|||
public UnSettledSumService( |
|||
UnSettledDetailDapperRepository dapper, |
|||
OutputService outputService, |
|||
ErpPartDapperRepository erpDapper |
|||
) |
|||
{ |
|||
_dapper = dapper; |
|||
_outputService = outputService; |
|||
_erpDapper = erpDapper; |
|||
} |
|||
|
|||
|
|||
//public string GetFisSum(Guid id, List<string> exportName, List<CustomCondition> 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 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 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 _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 =>
|
|||
// {
|
|||
|
|||
// p.Qty = 1;
|
|||
// p.DiffAMT = Math.Round(p.Qty * p.Price, 2);
|
|||
// p.DiffQty = 1;
|
|||
// }
|
|||
// );
|
|||
|
|||
// if (!string.IsNullOrEmpty(materialGroup))
|
|||
// {
|
|||
// var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList();
|
|||
// if (_groupList.Count() > 0)
|
|||
// {
|
|||
// _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(materailCode))
|
|||
// {
|
|||
// var _groupList = materailCode.Split(new char[] { '\n' }).Distinct().ToList();
|
|||
// if (_groupList.Count() > 0)
|
|||
// {
|
|||
// _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList();
|
|||
// }
|
|||
// }
|
|||
// _lst.GroupBy(p=>sapcode).Select()
|
|||
|
|||
|
|||
//}
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
} |
@ -0,0 +1,258 @@ |
|||
using Magicodes.ExporterAndImporter.Core; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using TaskJob.EventArgs; |
|||
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 = "物料组车型")] |
|||
public string 物料组车型 {set;get;} |
|||
[ExporterHeader(DisplayName = "物料号")] |
|||
public string 物料号 {set;get;} |
|||
[ExporterHeader(DisplayName = "物料描述")] |
|||
public string 物料描述 {set;get;} |
|||
[ExporterHeader(DisplayName = "客户物料")] |
|||
public string 客户物料 {set;get;} |
|||
[ExporterHeader(DisplayName = "WMS期初库存")] |
|||
public string WMS期初库存 {set;get;} |
|||
[ExporterHeader(DisplayName = "本月增加")] |
|||
public string 本月增加 {set;get;} |
|||
[ExporterHeader(DisplayName = "本月减少")] |
|||
public string 本月减少 {set;get;} |
|||
[ExporterHeader(DisplayName = "WMS期末库存")] |
|||
public string WMS期末库存 {set;get;} |
|||
[ExporterHeader(DisplayName = "SAS未结明细汇总")] |
|||
public string SAS未结明细汇总 {set;get;} |
|||
[ExporterHeader(DisplayName = "差异")] |
|||
public string 差异 { set; get; } |
|||
} |
|||
|
|||
public class UnSettledSumService |
|||
{ |
|||
private readonly HQHSettledDetailDapperRepository _hqkanbanDapper; |
|||
private readonly KanbanUnSettledDapperRepository _kanbanDapper; |
|||
private readonly UnSettledDetailDapperRepository _dapper; |
|||
private readonly OutputService _outputService; |
|||
private readonly ErpPartDapperRepository _erpDapper; |
|||
public UnSettledSumService( |
|||
HQHSettledDetailDapperRepository hqkanbanDapper, |
|||
KanbanUnSettledDapperRepository kanbanDapper, |
|||
UnSettledDetailDapperRepository dapper, |
|||
OutputService outputService, |
|||
ErpPartDapperRepository erpDapper |
|||
) |
|||
{ |
|||
_hqkanbanDapper = hqkanbanDapper; |
|||
_kanbanDapper = kanbanDapper; |
|||
_dapper = dapper; |
|||
_outputService = outputService; |
|||
_erpDapper = erpDapper; |
|||
} |
|||
|
|||
|
|||
public List<UnSettledSum> GetFisSum(Guid id, List<string> exportName, List<CustomCondition> 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 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 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 _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 => |
|||
{ |
|||
|
|||
p.Qty = 1; |
|||
p.DiffAMT = Math.Round(p.Qty * p.Price, 2); |
|||
p.DiffQty = 1; |
|||
} |
|||
); |
|||
|
|||
if (!string.IsNullOrEmpty(materialGroup)) |
|||
{ |
|||
var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList(); |
|||
if (_groupList.Count() > 0) |
|||
{ |
|||
_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(materailCode)) |
|||
{ |
|||
var _groupList = materailCode.Split(new char[] { '\n' }).Distinct().ToList(); |
|||
if (_groupList.Count() > 0) |
|||
{ |
|||
_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() |
|||
|
|||
}).ToList(); |
|||
return _fislist; |
|||
} |
|||
public List<UnSettledSum> GetKanbanSum(Guid id, List<string> exportName, List<CustomCondition> p_list) |
|||
{ |
|||
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 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 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;
|
|||
//var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").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 _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)) |
|||
{ |
|||
var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList(); |
|||
if (_groupList.Count() > 0) |
|||
{ |
|||
_ls = _ls.Where(p => _groupList.Contains(p.CustomerPartCode)).ToList(); |
|||
} |
|||
} |
|||
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(); |
|||
} |
|||
} |
|||
|
|||
|
|||
var kanbanList= _ls.GroupBy(p => new { p.SapCode, p.MaterialDesc, p.MaterialGroup, p.CustomerPartCode }) |
|||
.Select(p => new UnSettledSum |
|||
{ |
|||
物料号 = p.Key.SapCode, |
|||
客户物料 = p.Key.CustomerPartCode, |
|||
物料描述 = p.Key.MaterialDesc, |
|||
物料组车型 = p.Key.MaterialGroup, |
|||
SAS未结明细汇总 = p.Sum(p => p.WMSDeliveryQty).ToString() |
|||
|
|||
}).ToList(); |
|||
|
|||
|
|||
|
|||
return kanbanList; |
|||
} |
|||
|
|||
|
|||
|
|||
public List<UnSettledSum> GetHQKanbanSum(Guid id, List<string> exportName, List<CustomCondition> p_list) |
|||
{ |
|||
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 begin = p_list.Where(p => p.Name == "BeginTime").FirstOrDefault().Value; |
|||
var end = p_list.Where(p => p.Name == "EndTime").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; |
|||
var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value; |
|||
//有发货无结算,单独拿出去,财务要求
|
|||
var _ls = _hqkanbanDapper.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup); |
|||
if (!string.IsNullOrEmpty(sapCode)) |
|||
{ |
|||
var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); |
|||
if (_groupList.Count() > 0) |
|||
{ |
|||
_ls = _ls.Where(p => _groupList.Contains(p.Sap编码)).ToList(); |
|||
} |
|||
} |
|||
|
|||
var kanbanList = _ls.GroupBy(p => new { p.Sap编码, p.零件中文名称, p.物料组, p.客户物料号 }) |
|||
.Select(p => new UnSettledSum |
|||
{ |
|||
物料号 = p.Key.Sap编码, |
|||
客户物料 = p.Key.客户物料号, |
|||
物料描述 = p.Key.零件中文名称, |
|||
物料组车型 = p.Key.物料组, |
|||
SAS未结明细汇总 = p.Sum(p => p.发货数量).ToString() |
|||
|
|||
}).ToList(); |
|||
|
|||
return kanbanList; |
|||
} |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue