Browse Source

更新版本

FoShanPG
Administrator 3 years ago
parent
commit
5fad441973
  1. 30
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsUnInterface.cs
  2. 109
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSum.cs
  3. 258
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs

30
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsUnInterface.cs

@ -22,6 +22,7 @@ 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.ExportReports;
using Win.Sfs.SettleAccount.Reports;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
using Win.Sfs.Shared.DomainBase;
@ -258,7 +259,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS
[HttpPost]
[Route("SyncSap")]
[UnitOfWork(false)]
virtual public async Task<bool> OutputAsync(WmsRequestDetailReportDto input)
virtual public async Task<string> OutputAsync(WmsRequestDetailReportDto input)
{
@ -290,15 +291,36 @@ namespace Win.Sfs.SettleAccount.Entities.WMS
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version });//不能跨区间出库
var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, int.MaxValue,
0, true);
var checkList = new List<ErrorExportDto>();
var en1= entities.Where(p => p.OutputQty == 0).ToList();
foreach(var itm in en1)
{
checkList.Add(new ErrorExportDto() { Message = string.Format("结算号:{0}物料号:{1}实际出库数量为0不能同步Sap", itm.BillNum, itm.MaterialCode) });
}
var en2=entities.Where(p => p.OutputQty != p.Qty && p.OutputQty>0).ToList();
foreach (var itm in en2)
{
checkList.Add(new ErrorExportDto() { Message = string.Format("结算号:{0}物料号:{1}实际出库数量不等于结算数量不能同步Sap", itm.BillNum, itm.MaterialCode) });
}
var _count= entities.Count(p => p.State==2);
var _count = entities.Count(p => p.State==2);
if (_count > 1)
{
throw new BusinessException("8989", "记录中有已经完成记录!");
return false;
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
int lineNumber = 1;
foreach (var itm in entities)
{
@ -328,7 +350,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS
_erpDapper.InsertWmsSum(entities, _version, _accountDate);
}
}
return true;
return ApplicationConsts.SuccessStr; ;
}
[HttpPost]
[Route("Export")]

109
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSum.cs

@ -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()
//}
}
}

258
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs

@ -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…
Cancel
Save