44673626
3 years ago
7 changed files with 537 additions and 32 deletions
@ -0,0 +1,154 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Caching.Distributed; |
||||
|
using AutoMapper; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.Guids; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Caching; |
||||
|
|
||||
|
using Volo.Abp.ObjectMapping; |
||||
|
using Win.Sfs.SettleAccount.ExcelImporter; |
||||
|
using Win.Sfs.Shared.CacheBase; |
||||
|
using Win.Utils; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Win.Sfs.BaseData.ImportExcelCommon; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using EFCore.BulkExtensions; |
||||
|
using System.IO; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Win.Sfs.SettleAccount.Entities.SettleAccountVersion; |
||||
|
using Win.Sfs.SettleAccount.FISes; |
||||
|
using Win.Sfs.Shared.Enums.SettleAccount; |
||||
|
using Win.Sfs.Shared.Filter; |
||||
|
using Shouldly; |
||||
|
using Magicodes.ExporterAndImporter.Csv; |
||||
|
using Magicodes.ExporterAndImporter.Core; |
||||
|
using Magicodes.ExporterAndImporter.Excel; |
||||
|
using System.Data.Common; |
||||
|
using Volo.Abp.Uow; |
||||
|
using Volo.Abp; |
||||
|
using Win.Abp.Snowflakes; |
||||
|
using Win.Sfs.SettleAccount.CommonManagers; |
||||
|
using Win.Sfs.SettleAccount.ExportReports; |
||||
|
using Win.Sfs.SettleAccount.Constant; |
||||
|
using Win.Sfs.SettleAccount.MaterialRelationships; |
||||
|
using Win.Sfs.SettleAccount.Entities.TaskJobs; |
||||
|
using Magicodes.ExporterAndImporter.Core.Models; |
||||
|
|
||||
|
using TaskJob.Services; |
||||
|
using TaskJob.EventArgs; |
||||
|
using Win.Sfs.SettleAccount.Entities.WMS; |
||||
|
using Win.Sfs.SettleAccount.Entities.Wms; |
||||
|
using Win.Sfs.SettleAccount.Repository; |
||||
|
using WY.NewJit.Extends.PaiGe.WMS; |
||||
|
using System.Text.RegularExpressions; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.WMS |
||||
|
{ |
||||
|
public class WmsOutputSum |
||||
|
{ |
||||
|
[ImporterHeader(Name = "物料号", AutoTrim = true)] |
||||
|
//物料号
|
||||
|
public string MaterialCode { set; get; } |
||||
|
[ImporterHeader(Name = "物料描述", AutoTrim = true)] |
||||
|
//物料描述
|
||||
|
public string MaterialDesc { set; get; } |
||||
|
[ImporterHeader(Name = "物料组(车型)", AutoTrim = true)] |
||||
|
//物料组(车型)
|
||||
|
public string MaterialGroup { set; get; } |
||||
|
[ImporterHeader(Name = "结算数量")] |
||||
|
public decimal Qty { set; get; } |
||||
|
[ImporterHeader(Name = "单价")] |
||||
|
public decimal Price { set; get; } |
||||
|
[ImporterHeader(Name = "金额")] |
||||
|
public decimal Amt { set; get; } |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
[Route("api/settleaccount/WmsOutputSum")] |
||||
|
[Authorize(SettleAccountPermissions.WMSJIT.Default)] |
||||
|
public class WmsOutputSumAppService: SettleAccountApplicationBase<WmsJitOutPutDetial> |
||||
|
{ |
||||
|
private readonly TaskJobService _service; |
||||
|
private readonly IExcelImportAppService _excelImportService; |
||||
|
private readonly ISettleAccountBranchEfCoreRepository<TaskJob, Guid> _job; |
||||
|
public WmsOutputSumAppService( |
||||
|
IExcelImportAppService excelImportService, |
||||
|
ISettleAccountBranchEfCoreRepository<TaskJob, Guid> job, |
||||
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
||||
|
ICommonManager commonManager, |
||||
|
IDistributedCache<WmsJitOutPutDetial> cache |
||||
|
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
||||
|
{ |
||||
|
_job = job; |
||||
|
|
||||
|
_excelImportService = excelImportService; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
//public async Task<string> GetWmsSum(WmsJitOutPutDetial input)
|
||||
|
//{
|
||||
|
// var jobList= _job.Where(p => p.Type == input.Version).ToList();
|
||||
|
|
||||
|
// var _fileList= jobList.Where(p=>p.Name == "准时化结算核对明细" && Regex.Replace(p.FileName, @"^[A-Z]+[0-9]+$", string.Empty)==string.Empty);
|
||||
|
|
||||
|
|
||||
|
// List<WmsJitOutPutDetial> _lst = new List<WmsJitOutPutDetial>();
|
||||
|
// foreach (var filename in _fileList)
|
||||
|
// {
|
||||
|
// string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename.RealDownFileName;
|
||||
|
// ExcelHelper _excelHelper = new ExcelHelper(fileSavePath);
|
||||
|
// var _list = _excelHelper.ExcelToList<WmsJitOutPutDetial>();
|
||||
|
// var _ls1 = _list.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList();
|
||||
|
|
||||
|
// _ls1.GroupBy(p=>new {p.MaterialCode,p. })
|
||||
|
// foreach (var itm in _ls1)
|
||||
|
// {
|
||||
|
// var _detail = new List<WmsOutputSum>();
|
||||
|
// }
|
||||
|
|
||||
|
// //var _lsCopy = new List<WmsJitOutPutDetial>();
|
||||
|
// //foreach (var itm in _list)
|
||||
|
// //{
|
||||
|
// // WmsJitOutPutDetial _detail = new WmsJitOutPutDetial(
|
||||
|
// // GuidGenerator.Create(),
|
||||
|
// // itm.WmsBillNum,
|
||||
|
// // itm.KennCode,
|
||||
|
// // itm.ChassisNumber,
|
||||
|
// // itm.MaterialCode,
|
||||
|
// // itm.MaterialDesc,
|
||||
|
// // itm.MaterialGroup,
|
||||
|
// // string.Empty,
|
||||
|
// // string.Empty,
|
||||
|
// // 0,
|
||||
|
// // string.Empty,
|
||||
|
// // string.Empty,
|
||||
|
// // input.Version,
|
||||
|
// // itm.ParentMaterialCode,
|
||||
|
// // itm.BillNum,
|
||||
|
// // GuidGenerator.Create()
|
||||
|
// // , string.Empty
|
||||
|
// // , itm.Qty
|
||||
|
// // );
|
||||
|
// // _lsCopy.Add(_detail);
|
||||
|
// //}
|
||||
|
// //_lst.AddRange(_lsCopy.ToArray());
|
||||
|
// }
|
||||
|
//}
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,235 @@ |
|||||
|
using Magicodes.ExporterAndImporter.Core; |
||||
|
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.Reports.InvoiceSettledDiffs; |
||||
|
using Win.Sfs.SettleAccount.Repository.SettleAccount; |
||||
|
using Win.Sfs.SettleAccount.Repository.SettleAccountJob; |
||||
|
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; |
||||
|
namespace SettleAccount.Job.Services.Report |
||||
|
{ |
||||
|
public class WmsOutputSum |
||||
|
{ |
||||
|
[ImporterHeader(Name = "物料号", AutoTrim = true)] |
||||
|
//物料号
|
||||
|
public string MaterialCode { set; get; } |
||||
|
[ImporterHeader(Name = "物料描述", AutoTrim = true)] |
||||
|
//物料描述
|
||||
|
public string MaterialDesc { set; get; } |
||||
|
[ImporterHeader(Name = "物料组(车型)", AutoTrim = true)] |
||||
|
//物料组(车型)
|
||||
|
public string MaterialGroup { set; get; } |
||||
|
[ImporterHeader(Name = "结算数量")] |
||||
|
public decimal Qty { set; get; } |
||||
|
[ImporterHeader(Name = "单价")] |
||||
|
public decimal Price { set; get; } |
||||
|
[ImporterHeader(Name = "金额")] |
||||
|
public decimal Amt { set; get; } |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
public class WmsOutputSumExportService |
||||
|
: ITransientDependency, IExportJob |
||||
|
{ |
||||
|
|
||||
|
private readonly InvoiceSettledDetailDiffDapperRepository _dapperRepository; |
||||
|
private readonly ErpPartDapperRepository _erpdapperRepository; |
||||
|
|
||||
|
private readonly OutputService _outputService; |
||||
|
private readonly InputService _inputService; |
||||
|
|
||||
|
public WmsOutputSumExportService( |
||||
|
|
||||
|
ErpPartDapperRepository erpdapperRepository, |
||||
|
InvoiceSettledDetailDiffDapperRepository dapperRepository, |
||||
|
OutputService outputService, |
||||
|
InputService inputService |
||||
|
) |
||||
|
{ |
||||
|
_inputService = inputService; |
||||
|
_outputService = outputService; |
||||
|
_erpdapperRepository = erpdapperRepository; |
||||
|
//_repository = repository;
|
||||
|
//_versionRepository = versionRepository;
|
||||
|
_dapperRepository = dapperRepository; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list) |
||||
|
{ |
||||
|
|
||||
|
return id.ToString(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
//public List<WmsOutputSum> InvoiceSettledDetailExportFile(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 begin = p_list.Where(p => p.Name == "BeginTime").FirstOrDefault().Value;
|
||||
|
// //var end = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value;
|
||||
|
// //var cp7begin = p_list.Where(p => p.Name == "Cp7BeginTime").FirstOrDefault().Value;
|
||||
|
// //var cp7end = p_list.Where(p => p.Name == "Cp7EndTime").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 materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value;
|
||||
|
// //var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value;
|
||||
|
// //var _ls = _dapperRepository.GetInvoiceSettledDetailDiffReportList(version, materialCode, begin, end, cp7begin, cp7end, kenncode, chassisNumber, materialGroup);
|
||||
|
// //var _list = _ls.Where(p => p.ParentSapMaterialCode != p.SapMaterialCode).GroupBy(p => new { p.ParentSapMaterialCode, p.ChassisNumber, p.KENNCode })
|
||||
|
// //.Select(p => p.FirstOrDefault()).ToList();
|
||||
|
// //var rangeList = _erpdapperRepository.GetSapList<InvoiceSettledDetailDiff>(_list, version, true);
|
||||
|
// //var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version);
|
||||
|
|
||||
|
// //if (_ls.Count > 0)
|
||||
|
// //{
|
||||
|
// // var erpPriceList = _ls.Where(p => p.ParentSapMaterialCode != p.SapMaterialCode)
|
||||
|
// // .GroupBy(p => new { p.ParentSapMaterialCode, p.ChassisNumber, p.KENNCode })
|
||||
|
// // .Select(p => new { ParentSapMaterialCode = p.Key.ParentSapMaterialCode, ChassisNumber = p.Key.ChassisNumber, KENNCode = p.Key.KENNCode, Price = p.Sum(itm => itm.InvoiceAmt) }).ToList();
|
||||
|
|
||||
|
|
||||
|
|
||||
|
// // var rangList = from itm1 in rangeList
|
||||
|
// // join itm2 in erpPriceList
|
||||
|
// // on new { itm1.ParentSapMaterialCode, itm1.KENNCode, itm1.ChassisNumber }
|
||||
|
// // equals new { itm2.ParentSapMaterialCode, itm2.KENNCode, itm2.ChassisNumber }
|
||||
|
// // into temp1
|
||||
|
// // from tm1 in temp1.DefaultIfEmpty()
|
||||
|
// // select new InvoiceSettledDetailDiff
|
||||
|
// // {
|
||||
|
// // WmsBillNum = itm1.WmsBillNum,
|
||||
|
// // CP5Time = itm1.CP5Time,
|
||||
|
// // KENNCode = itm1.KENNCode,
|
||||
|
// // ChassisNumber = itm1.ChassisNumber,
|
||||
|
// // WmsState = itm1.WmsState,
|
||||
|
// // SapMaterialCode = itm1.SapMaterialCode,
|
||||
|
// // MaterialDesc = itm1.MaterialDesc,
|
||||
|
// // MaterialCode = itm1.MaterialCode,
|
||||
|
// // ParentSapMaterialCode = itm1.ParentSapMaterialCode,
|
||||
|
// // ParentMaterialDesc = itm1.ParentMaterialDesc,
|
||||
|
// // MaterialGroup = itm1.MaterialGroup,
|
||||
|
// // Price = itm1.Price,
|
||||
|
// // Amt = itm1.Amt,
|
||||
|
// // Qty = 1,
|
||||
|
// // SettledQty = 1,
|
||||
|
// // CP7Time = itm1.CP7Time,
|
||||
|
// // DiffSettleFisQty = 0,
|
||||
|
// // DiffSettleInvQty = 0,
|
||||
|
// // InvoiceQty = 1,
|
||||
|
// // InvoicePrice = itm1 == null ? 0 : tm1.Price,
|
||||
|
// // InvoiceAmt = itm1 == null ? 0 : tm1.Price,
|
||||
|
// // SettleAmt = itm1 == null ? 0 : tm1.Price,
|
||||
|
// // DiffPrice = itm1 == null ? 0 - itm1.Price : tm1.Price - itm1.Price
|
||||
|
// // };
|
||||
|
|
||||
|
// // rangeList = rangList.ToList();
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
// // foreach (var itm in diffList)
|
||||
|
// // {
|
||||
|
// // var _first = _ls.FirstOrDefault(p => p.MaterialCode == itm.MaterialCode);
|
||||
|
// // if (_first != null)
|
||||
|
// // {
|
||||
|
// // _first.InvoiceQty = _first.SettledQty + itm.DiffQty;
|
||||
|
// // _first.DiffSettleInvQty = itm.DiffQty;
|
||||
|
// // }
|
||||
|
// // }
|
||||
|
|
||||
|
// // foreach (var itm in _ls)
|
||||
|
// // {
|
||||
|
// // itm.InvoiceAmt = Math.Round(itm.InvoiceQty * itm.InvoicePrice, 2);
|
||||
|
// // itm.DiffPrice = itm.Price - itm.InvoicePrice;
|
||||
|
// // }
|
||||
|
// // _ls.AddRange(rangeList);
|
||||
|
|
||||
|
// // //var list1 = _ls.GroupBy(p => new { p.ChassisNumber, p.MaterialCode, p.SettleReadyQty }).Select(p => new { SettleQty = p.Key.SettleReadyQty, MaterialCode = p.Key.MaterialCode, ChassisNumber = p.Key.ChassisNumber, Qty = p.Sum(itm => itm.Qty) }).Where(p => p.Qty > 1).ToList();
|
||||
|
// // //foreach (var itm in list1)
|
||||
|
// // //{
|
||||
|
// // // var _first = _ls.FirstOrDefault(p => p.ChassisNumber == itm.ChassisNumber && p.MaterialCode == itm.MaterialCode && p.SettleReadyQty == itm.SettleQty);
|
||||
|
// // // if (_first != null)
|
||||
|
// // // {
|
||||
|
// // // _first.DiffSettleFisQty = itm.Qty - itm.SettleQty;
|
||||
|
// // // }
|
||||
|
// // //}
|
||||
|
|
||||
|
|
||||
|
// // 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();
|
||||
|
// // }
|
||||
|
// // }
|
||||
|
// // if (!string.IsNullOrEmpty(kenncode))
|
||||
|
// // {
|
||||
|
// // var _groupList = kenncode.Split("\n").ToList();
|
||||
|
// // if (_groupList.Count() > 0)
|
||||
|
// // {
|
||||
|
// // _ls = _ls.Where(p => _groupList.Contains(p.KENNCode)).ToList();
|
||||
|
// // }
|
||||
|
// // }
|
||||
|
// // if (!string.IsNullOrEmpty(chassisNumber))
|
||||
|
// // {
|
||||
|
// // var _groupList = chassisNumber.Split("\n").ToList();
|
||||
|
// // if (_groupList.Count() > 0)
|
||||
|
// // {
|
||||
|
// // _ls = _ls.Where(p => _groupList.Contains(p.ChassisNumber)).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.MaterialCode)).ToList();
|
||||
|
// // }
|
||||
|
// // }
|
||||
|
// // if (!string.IsNullOrEmpty(sapCode))
|
||||
|
// // {
|
||||
|
// // var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
|
||||
|
// // if (_groupList.Count() > 0)
|
||||
|
// // {
|
||||
|
// // _ls = _ls.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList();
|
||||
|
// // }
|
||||
|
// // }
|
||||
|
|
||||
|
// // //.Select(p => p.FirstOrDefault());
|
||||
|
// // _ls = _ls.OrderBy(p => p.ChassisNumber).ThenBy(p => p.KENNCode).ThenBy(p => p.SapMaterialCode).ToList();
|
||||
|
|
||||
|
// //}
|
||||
|
|
||||
|
// //_ls=_ls.Where(p => p.SapMaterialCode == p.MaterialCode).ToList();
|
||||
|
// //var _lstSum= _ls.GroupBy(p => new { p.MaterialGroup, p.MaterialCode, p.InvoicePrice, p.InvoiceAmt,p.MaterialDesc })
|
||||
|
// // .Select(p => new WmsOutputSum
|
||||
|
// // {
|
||||
|
// // MaterialCode=p.Key.MaterialCode,
|
||||
|
// // MaterialGroup=p.Key.MaterialGroup,
|
||||
|
// // Price=p.Key.InvoicePrice,
|
||||
|
// // Amt=p.Sum(p=>p.InvoiceAmt),
|
||||
|
// // MaterialDesc=p.Key.MaterialDesc,
|
||||
|
// // Qty=p.Sum(p=>p.Qty)
|
||||
|
|
||||
|
|
||||
|
// // });
|
||||
|
|
||||
|
// //return _lstSum;
|
||||
|
//}
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
Loading…
Reference in new issue