Browse Source

备件相关代码根据客户需求更改

FoShanPG
44673626 3 years ago
parent
commit
3a155501c1
  1. 47
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/VWSparePart/SparePartAppService.cs
  2. 43
      src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs
  3. 15
      src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml
  4. 3
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/VWSparePart/SparePart.cs
  5. 178
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs
  6. 100
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs
  7. 5
      src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

47
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/VWSparePart/SparePartAppService.cs

@ -101,7 +101,52 @@ namespace Win.Sfs.SettleAccount.Entities.VWSparePart
_bomList.Add(new SparePartVersion(_id, branchId, year, period, version, customerCode));
foreach (var itm in entityList)
{
itm.SetValue(GuidGenerator.Create(), branchId, year, period, version);
itm.SetValue(GuidGenerator.Create(), branchId, year, period, version,"not90");
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
await _repository.GetDbContext().BulkInsertAsync<SparePart>(entityList);
await _versionRepository.GetDbContext().BulkInsertAsync(_bomList);
return ApplicationConsts.SuccessStr;
}
[HttpPost]
[Route("ExcelImport90")]
[DisableRequestSizeLimit]
[Authorize(SettleAccountPermissions.SettleAccounts.Create)]
public async Task<string> SparePartUploadExcelImport90([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode)
{
if (string.IsNullOrEmpty(version))
{
throw new BusinessException("版本不能空,必须传入!");
}
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<SparePartImportDto>(files, _excelImportService);
var entityList = ObjectMapper.Map<List<SparePartImportDto>, List<SparePart>>(result);
//删除版本
var _versionQuery = _versionRepository.Where(p => p.Version == version);
await _versionQuery.BatchDeleteAsync();
//删除明细
var _query = _repository.Where(p => p.Version == version);
await _query.BatchDeleteAsync();
//插入数据前检验
var checkList = new List<ErrorExportDto>();
var _group = entityList.GroupBy(x => new { x.LineNumber, x.MaterialCode, x.Version }).Select(p => new { Count = p.Count(), LineNumber = p.Key.LineNumber, MaterialCode = p.Key.MaterialCode });
foreach (var itm in _group)
{
if (string.IsNullOrEmpty(itm.MaterialCode))
{
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("导入的行号为{0}的物料代码为空,请检查!", itm.LineNumber), string.Empty));
}
}
var _id = GuidGenerator.Create();
var _bomList = new List<SparePartVersion>();
_bomList.Add(new SparePartVersion(_id, branchId, year, period, version, customerCode));
foreach (var itm in entityList)
{
itm.SetValue(GuidGenerator.Create(), branchId, year, period, version, "is90");
}
if (checkList.Count > 0)
{

43
src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs

@ -210,6 +210,49 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
});
return _taskid;
}
#region 大众备件0-90天和90天以上输出
/// <summary>
/// 大众备件0-90天报表输出
/// </summary>
/// <param name="purchaseOrderNo"></param>
/// <param name="sapCode"></param>
/// <param name="version"></param>
/// <param name="customerCode"></param>
/// <param name="factory"></param>
/// <param name="matialCode"></param>
/// <param name="state"></param>
/// <param name="begin"></param>
/// <param name="end"></param>
/// <returns></returns>
[HttpGet]
[Route("SettleSparePart90Export")]
[DisableRequestSizeLimit]
public async Task<string> SettledSparePart90(string purchaseOrderNo, string sapCode, string version, string customerCode, string factory, string matialCode,
string state, DateTime begin, DateTime end)
{
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "PurchaseOrderNo", Value = purchaseOrderNo ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "SAPCode", Value = sapCode ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = customerCode ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "State", Value = state ?? "0" });
customConditionList.Add(new CustomCondition() { Name = "MatialCode", Value = matialCode ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "大众备件结算核对" });
customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() });
customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() });
var _taskid = await _service.ExportEnqueueAsync("(0-90天)大众备件结算输出", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettleSparePart90ExportService), customConditionList, (rs) =>
{
});
return _taskid;
}
#endregion
/// <summary>
/// 无订单备件结算输出
/// </summary>

15
src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml

@ -3591,6 +3591,21 @@
<param name="end"></param>
<returns></returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.SettledSparePart90(System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.DateTime,System.DateTime)">
<summary>
大众备件0-90天报表输出
</summary>
<param name="purchaseOrderNo"></param>
<param name="sapCode"></param>
<param name="version"></param>
<param name="customerCode"></param>
<param name="factory"></param>
<param name="matialCode"></param>
<param name="state"></param>
<param name="begin"></param>
<param name="end"></param>
<returns></returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.SettledSparePartExtend(System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.DateTime,System.DateTime)">
<summary>
无订单备件结算输出

3
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/VWSparePart/SparePart.cs

@ -16,13 +16,14 @@ namespace Win.Sfs.SettleAccount.Entities.VWSparePart
public SparePart()
{ }
public void SetValue(Guid guid, Guid branchId, string year, string peroid, string version)
public void SetValue(Guid guid, Guid branchId, string year, string peroid, string version,string extend)
{
Period = peroid;
Year = year;
Id = guid;
Version = version;
BranchId = branchId;
Extend = extend;
}
public SparePart(Guid Id, string year, string period, string version, string lineNumber,
string purchaseType,string purchaseOrderNo, string purchaseOrderNoItem, string purchaseOrderNoText,

178
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs

@ -0,0 +1,178 @@
using Dapper;
using Magicodes.ExporterAndImporter.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories.Dapper;
using Volo.Abp.EntityFrameworkCore;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
/// <summary>
/// 根据虚拟单号0-90天的是按照SAP物料号进行先进先出操作
/// </summary>
public class SettleSparePart90DapperReportRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{
public SettleSparePart90DapperReportRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider)
: base(dbContextProvider)
{ }
public virtual List<SettleSparePart90Export> GetSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode,
string begintime, string endtime)
{
string sqlString =
"SELECT\n" +
" temp1.期间,\n" +
" temp1.交货单号,\n" +
" temp1.发货日期,\n" +
" temp1.采购订单号,\n" +
" temp1.SAP编码,\n" +
" temp1.物料代码,\n" +
" temp1.物料描述,\n" +
" temp1.物料组,\n" +
" temp1.开票单价,\n" +
" temp1.数量差异,\n" +
" temp1.发货数量,\n" +
" temp1.开票数量,\n" +
" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" +
" temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.Version AS 期间,\n" +
" b.WMSDeliveryNote AS 交货单号,\n" +
" b.SpareDate AS 发货日期,\n" +
" b.PurchaseOrderNo AS 采购订单号,\n" +
" c.MaterialCode AS SAP编码,\n" +
" b.MaterialCode AS 物料代码,\n" +
" c.MaterialDesc AS 物料描述,\n" +
" c.EstimateTypeDesc AS 物料组,\n" +
" a.PurchasePriceNoTax AS 开票单价,\n" +
" 0 AS 数量差异,\n" +
" ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" +
" ISNULL( b.ReceiptQty, 0 ) AS 开票数量 \n" +
" FROM\n" +
" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode, Version, PurchasePriceNoTax FROM Set_SparePart GROUP BY PurchaseOrderNo, MaterialCode, Version, PurchasePriceNoTax ) AS a\n" +
" LEFT OUTER JOIN (\n" +
" SELECT\n" +
" WMSDeliveryNote,\n" +
" SpareDate,\n" +
" MaterialCode,\n" +
" ReceiptQty,\n" +
" PurchaseOrderNo \n" +
" FROM\n" +
" Set_WMSSparePart \n" +
" WHERE\n" +
" PurchaseOrderNo != 'BM' \n" +
" AND PurchaseOrderNo LIKE '%D30%' \n" +
" OR PurchaseOrderNo LIKE '%D60%' \n" +
" OR PurchaseOrderNo LIKE '%D90%' \n" +
" ) AS b ON a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" +
" ( a.Version = '{0}' ) \n" +
" ) AS temp1\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
"WHERE\n" +
" temp1.SAP编码 IS NULL";
string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version);
string _sql = string.Format(addSqlStr, addwhere);
//string _sql = string.Format(sqlString, version);
var _query = DbConnection.Query<SettleSparePart90Export>(_sql, null, null, true, 1200, null);
return _query.ToList();
}
public virtual List<SparePart90SumQtyDiff> GetSettleSparePart90SumQtyDiff(string version)
{
string sqlString = "SELECT\n" +
" ISNULL( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ), 0 ) 数量差异,\n" +
" a.PurchaseOrderNo 订单号,\n" +
" a.MaterialCode 物料号 \n" +
"FROM\n" +
" ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Version = '{0}' GROUP BY PurchaseOrderNo, MaterialCode ) A\n" +
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) B ON A.MaterialCode = B.MaterialCode";
string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version);
string _sql = string.Format(addSqlStr, addwhere);
var _query = DbConnection.Query<SparePart90SumQtyDiff>(_sql, null, null, true, 1200, null);
return _query.ToList();
}
}
public class SparePart90SumQtyDiff
{
public decimal { set; get; }
public string { set; get; }
public string { set; get; }
}
/// <summary>
/// 大众看板有条码报表
/// </summary>
//[ExcelExporter(Name = "未结明细", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)]
public class SettleSparePart90Export
{
[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 = "SAP编码")]
public string SAP编码 { set; get; }
[ExporterHeader(DisplayName = "物料代码")]
public string { set; get; }
[ExporterHeader(DisplayName = "物料描述")]
public string { set; get; }
[ExporterHeader(DisplayName = "物料组")]
public string { set; get; }
[ExporterHeader(DisplayName = "开票单价")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "数量差异")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "发货数量")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "开票数量")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "定价")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "单价差异")]
public decimal { set; get; }
}
}

100
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs

@ -0,0 +1,100 @@
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.Repository.SettleAccountJob.Report;
namespace SettleAccount.Job.Services.Report
{
public class SettleSparePart90ExportService : ITransientDependency, IExportJob
{
private readonly SettleSparePart90DapperReportRepository _dapper;
private readonly OutputService _outputService;
private readonly ErpPartDapperRepository _erpdapperRepository;
public SettleSparePart90ExportService(SettleSparePart90DapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService)
{
_dapper = dapper;
_outputService = outputService;
_erpdapperRepository = erpdapperRepository;
}
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list)
{
var fileName = exportName.FirstOrDefault();
var purchaseOrderNo = p_list.Where(p => p.Name == "PurchaseOrderNo").FirstOrDefault().Value;
var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value;
var sapCode = p_list.Where(p => p.Name == "SAPCode").FirstOrDefault().Value;
var matialCode = p_list.Where(p => p.Name == "MatialCode").FirstOrDefault().Value;
var beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value;
var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value;
var _ls = _dapper.GetSettleSparePart90ReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
//var diffList = _dapper.GetSettleSparePart90SumQtyDiff(version);
//if (diffList != null)
//{
// foreach (var itm in diffList)
// {
// var _first = _ls.FirstOrDefault(p => p.物料代码 == itm.物料号);
// if (_first != null)
// {
// _first.开票数量 = _first.发货数量 + itm.数量差异;//开票数量(结算数量+差异)
// _first.数量差异 = itm.数量差异;
// }
// }
//}
//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(sapCode))
{
var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_ls = _ls.Where(p => _groupList.Contains(p.SAP编码)).ToList();
}
}
if (!string.IsNullOrEmpty(matialCode))
{
var _groupList = matialCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_ls = _ls.Where(p => _groupList.Contains(p.)).ToList();
}
}
//if (!string.IsNullOrEmpty(purchaseOrderNo))
//{
// var _groupList = purchaseOrderNo.Split(new char[] { '\n' }).Distinct().ToList();
// if (_groupList.Count() > 0)
// {
// _ls = _ls.Where(p => _groupList.Contains(p.采购订单号)).ToList();
// }
//}
_outputService.Export<SettleSparePart90Export>(id, fileName, _ls);
return id.ToString();
}
}
}

5
src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

@ -119,6 +119,11 @@ namespace Win.Sfs.SettleAccount
{
return implementationFactory.GetService<SettleSparePartExportService>();
}
//大众备件90天核对明细
if (key.Equals(typeof(SettleSparePart90ExportService).FullName))
{
return implementationFactory.GetService<SettleSparePart90ExportService>();
}
if (key.Equals(typeof(InvoiceSettledDetailDiffExportService).FullName))
{
return implementationFactory.GetService<InvoiceSettledDetailDiffExportService>();

Loading…
Cancel
Save