44673626 3 years ago
parent
commit
f1aadd2831
  1. 2
      .vs/VSWorkspaceState.json
  2. BIN
      .vs/Win.Sfs.SmartSettlementSystem.PG/v16/.suo
  3. 36
      src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs
  4. 11
      src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml
  5. 9
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettleAccountEntityBase.cs
  6. 7
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/UnSettle/UnSettleDetailReport.cs
  7. 11
      src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/ReportDetailBase.cs
  8. 85
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpPartDapperRepository.cs
  9. 124
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDiffDapperRepository.cs
  10. 2
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleFisDiffDetailDapperRepository.cs
  11. 159
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettleDiffDapperRepository.cs
  12. 175
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettledDetailDapperRepository.cs
  13. 20
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/OutputService.cs
  14. 8
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDiffExportService.cs
  15. 139
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleFisDiffExportService.cs
  16. BIN
      src/Shared/Win.Abp.Snowflakes/obj/Debug/netcoreapp5/Win.Abp.Snowflakes.csproj.AssemblyReference.cache
  17. BIN
      src/Shared/Win.Sfs.Shared/obj/Debug/netcoreapp5/Win.Sfs.Shared.csproj.AssemblyReference.cache

2
.vs/VSWorkspaceState.json

@ -2,6 +2,6 @@
"ExpandedNodes": [
""
],
"SelectedNode": "\\WY.NewJit.sln (src\\Modules\\派格FIS\\WY.NewJit.sln)",
"SelectedNode": "\\SettleAccount.sln (src\\SettleAccount.sln)",
"PreviewInSolutionExplorer": false
}

BIN
.vs/Win.Sfs.SmartSettlementSystem.PG/v16/.suo

Binary file not shown.

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

@ -55,10 +55,7 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
ISettleAccountBranchEfCoreRepository<SettlementPartVersion, Guid> settlementPartVersionrepository,
ISettleAccountBranchEfCoreRepository<FISVersion, Guid> fisVersionrepository,
ISettleAccountBranchEfCoreRepository<ItemInvoicePriceVersion, Guid> itemInvoicePriceVersionrepository,
//ISettleAccountBranchEfCoreRepository<Material, Guid> materialRepository,
//ISettleAccountBranchEfCoreRepository<InvoiceSettledDiff, Guid> repository,
//ISettleAccountBranchEfCoreRepository<InvoiceSettledDiffVersion, Guid> versionRepository,
//IDistributedCache<InvoiceSettledDiff> cache,
IExcelImportAppService excelImportService,
//ISnowflakeIdGenerator snowflakeIdGenerator,
//ICommonManager commonManager,
@ -236,7 +233,7 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
/// <summary>
/// 导入功能
/// 1.大众发票与结算核对汇总表
/// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
@ -264,14 +261,14 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "结算与开票数据对比" });
customConditionList.Add(new CustomCondition() { Name = "Year", Value = year ?? DateTime.Now.Year.ToString() });
var _taskid = await _service.ExportEnqueueAsync("结算与开票数据对比", ExportExtentsion.Excel, CurrentUser, typeof(InvoiceSettledDiffExportService), customConditionList, (rs) =>
var _taskid = await _service.ExportEnqueueAsync("大众发票与结算核对汇总表", ExportExtentsion.Excel, CurrentUser, typeof(InvoiceSettledDiffExportService), customConditionList, (rs) =>
{
});
return _taskid;
}
/// <summary>
/// 导入功能
/// 3.大众准时化结算数量差异比对表
/// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
@ -293,9 +290,34 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
}
/// <summary>
///6.大众准时化未结差异比对表
/// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpGet]
[Route("UnSettleDiffExport-Make")]
[DisableRequestSizeLimit]
public async Task<string> UnSettleDiffExportServiceMake(string version, string materialCode, string begin, string end)
{
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = version });
customConditionList.Add(new CustomCondition() { Name = "MaterialCode", Value = materialCode });
customConditionList.Add(new CustomCondition() { Name = "BeginTime", Value = begin });
customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end });
var _taskid = await _service.ExportEnqueueAsync("大众准时化未结差异比对表", ExportExtentsion.Excel, CurrentUser, typeof(UnSettleDiffExportService), customConditionList, (rs) =>
{
});
return _taskid;
}

11
src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml

@ -2449,18 +2449,25 @@
</member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.InvoiceSettledDiffMake(System.String,System.String,System.String,System.String,System.String,System.String,System.String)">
<summary>
导入功能
1.大众发票与结算核对汇总表
</summary>
<param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
<returns></returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.SettleFisDiffExportMake(System.String,System.String,System.String,System.String)">
<summary>
导入功能
3.大众准时化结算数量差异比对表
</summary>
<param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
<returns></returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.UnSettleDiffExportServiceMake(System.String,System.String,System.String,System.String)">
<summary>
6.大众准时化未结差异比对表
</summary>
<param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
<returns></returns>
</member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.SettledPartAndErpPartPriceDiffMake(System.String,System.String)">
<summary>
结算总成和ERP总成价格对比

9
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettleAccountEntityBase.cs

@ -3,9 +3,18 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.SettleAccount.Entities.Prices;
namespace Win.Sfs.SettleAccount.Entities
{
public class CacheManager
{
public static List<Material> CacheMaterials { set; get; }
public static List<PriceList> CachePriceList { set; get; }
}
public interface ISettleAccountEntityBase
{
public string Version { set; get; }

7
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/UnSettle/UnSettleDetailReport.cs

@ -12,14 +12,11 @@ namespace Win.Sfs.SettleAccount.Entities.UnSettle
{
[ExporterHeader(DisplayName = "结算平台未结数量 ")]
public decimal Qty { set; get; }
[ExporterHeader(DisplayName = "定价 ")]
public decimal Price { set; get; }
[ExporterHeader(DisplayName = "金额 ")]
public decimal Amt { set; get; }
[ExporterHeader(DisplayName = "漏结标识 ")]
public string Flag { set; get; }
[ExporterHeader(DisplayName = "漏结期间 ")]
public string UNSettleVersion { set; get; }
public string UnSettleVersion { set; get; }
[ExporterHeader(DisplayName = "说明 ")]
public string Remark { set; get; }

11
src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/ReportDetailBase.cs

@ -7,6 +7,7 @@ using System.Threading.Tasks;
namespace Win.Sfs.SettleAccount.Reports
{
public class ReportDetailBase
{
[ExporterHeader(DisplayName = "交货单号 ")]
@ -17,7 +18,7 @@ namespace Win.Sfs.SettleAccount.Reports
public string KENNCode { set; get; }
[ExporterHeader(DisplayName = "底盘号")]
public string ChassisNumber { set; get; }
[ExporterHeader(DisplayName = "M100交货状态 ")]
[ExporterHeader(DisplayName = "交货状态 ")]
public string WmsState { set; get; }
[ExporterHeader(DisplayName = "物料号")]
public string SapMaterialCode { set; get; }
@ -26,13 +27,15 @@ namespace Win.Sfs.SettleAccount.Reports
[ExporterHeader(DisplayName = "客户物料 ")]
public string MaterialCode { set; get; }
[ExporterHeader(DisplayName = "组件组物料 ")]
public string ParentMaterialCode { set; get; }
public string ParentSapMaterialCode { set; get; }
[ExporterHeader(DisplayName = "组件组物料描述 ")]
public string ParentMaterialDesc { set; get; }
[ExporterHeader(DisplayName = "物料组(车型) ")]
public string MaterialGroup { set; get; }
[ExporterHeader(DisplayName = "定价 ")]
public decimal Price { set; get; }
[ExporterHeader(DisplayName = "金额 ")]
public decimal Amt { set; get; }
}

85
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpPartDapperRepository.cs

@ -0,0 +1,85 @@
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;
using Win.Sfs.SettleAccount.Entities;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.Reports;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
/// <summary>
/// 主数据Dapper表
/// </summary>
public class ErpPartDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{
public ErpPartDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public virtual List<T> GetDiffReport<T>(List<T> childList) where T : ReportDetailBase, new()
{
List<Material> _materialList = new List<Material>();
List<PriceList> _priceList = new List<PriceList>();
if (CacheManager.CacheMaterials != null)
{
_materialList = CacheManager.CacheMaterials;
}
else
{
_materialList = DbConnection.Query<Material>("select * from set_material").ToList();
}
if (CacheManager.CachePriceList != null)
{
_priceList = CacheManager.CachePriceList;
}
else
{
_priceList = DbConnection.Query<PriceList>("select MaterialCode,Price from Set_PriceList where version=(select max(version) from set_Set_PriceListVersion)").ToList();
}
List<T> _list = new List<T>();
foreach (var itm in childList)
{
var parentMaterial = new T();
parentMaterial.WmsBillNum = itm.WmsBillNum;
parentMaterial.CP5Time = itm.CP5Time;
parentMaterial.KENNCode = itm.KENNCode;
parentMaterial.ChassisNumber = itm.ChassisNumber;
parentMaterial.WmsState = itm.WmsState;
parentMaterial.SapMaterialCode = itm.ParentSapMaterialCode;
parentMaterial.MaterialDesc = itm.ParentMaterialDesc;
parentMaterial.MaterialCode = itm.ParentSapMaterialCode;
parentMaterial.ParentSapMaterialCode = itm.ParentSapMaterialCode;
parentMaterial.ParentMaterialDesc = itm.ParentMaterialDesc;
var _price = _priceList.Where(p => p.MaterialCode == itm.ParentSapMaterialCode).FirstOrDefault();
if (_price != null)
{
parentMaterial.Price = _price.Price;
parentMaterial.Amt = _price.Price;
}
var _material = _materialList.Where(p => p.MaterialCode == itm.ParentSapMaterialCode).FirstOrDefault();
if (_material != null)
{
parentMaterial.MaterialGroup = _material.EstimateTypeDesc;
}
_list.Add(parentMaterial);
}
return _list;
}
}
}

124
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDiffDapperRepository.cs

@ -11,6 +11,11 @@ using Win.Sfs.SettleAccount.Reports.InvoiceSettledDiffs;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob
{
/// <summary>
/// 1.大众发票与结算汇总核对表-UPdate
/// </summary>
public class InvoiceSettledDiffDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{
public InvoiceSettledDiffDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider)
@ -20,74 +25,73 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob
public virtual List<InvoiceSettledDiff> GetInvoiceSettledDiffReportList(string version,string year, string tablename ,string materialcode)
{
//string str = string.Empty;
//str += " where 1=1 ";
////if (!string.IsNullOrEmpty(year))
////{
//// str += string.Format(" and year='{0}' ", year);
////}
//if (!string.IsNullOrEmpty(version))
//{
// str += string.Format(" and version='{0}' ", version);
//}
//// string sqlString = "select "+ string.Format(" {0} as Version ,",version) + "a.MaterialCode,isnull(b.qty,0) InvoiceQty,isnull(c.qty,0) SettleQty, (isnull(b.qty,0)-isnull(c.qty,0)) as DiffQty from (\n" +
//// " select distinct MaterialCode from( \n"+
////"select distinct MaterialCode from Set_Invoice {0}\n" +
//// "union all\n" +
//// "select distinct MaterialCode from {1} {0}\n" +
//// ") temp \n"+
//// ") as a\n" +
//// "left join\n" +
//// "\n" +
//// "(select SUM(QTY) qty,MaterialCode from Set_Invoice {0} GROUP BY MaterialCode) b on a.MaterialCode=b.MaterialCode\n" +
//// "\n" +
//// "left join\n" +
//// "(select SUM(QTY) qty,MaterialCode from {1} {0} GROUP BY MaterialCode) c on a.MaterialCode=c.MaterialCode";
string sqlString =
"SELECT \n" + string.Format(" '{0}' as Version ,", version) + "\n" +
" b.*,\n" +
" ISnull(\n" +
" c.Qty,\n" +
" IsNull( d.qty, 0 )) SettleQty,\n" +
"CASE\n" +
" \n" +
" WHEN e.Type = 'CP7报废' THEN\n" +
" isnull( e.Qty, 0 ) ELSE 0 \n" +
" END AS CP7ScrapQty,\n" +
"CASE\n" +
" \n" +
" WHEN e.Type = '索赔' THEN\n" +
" isnull( e.Qty, 0 ) ELSE 0 \n" +
" END AS ClaimQty,\n" +
" (\n" +
" b.InvoiceQty - ISnull(\n" +
" c.Qty,\n" +
" IsNull( d.qty, 0 ))) DiffQty,\n" +
" Isnull( f.Price, 0 ) SalePrice,\n" +
" b.InvoicePrice - Isnull( f.Price, 0 ) DiffPrice,\n" +
" '' AS SapMaterialCode \n" +
"SELECT\n" +
" temp1.*, temp1.InvoicePrice - Isnull( temp2.Price, 0 ) DiffPrice , \n" +
" temp2.Price SalePrice\n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" Factory, MaterialCode,\n" +
" SUM( QTY ) InvoiceQty,\n" +
" sum( amt ) InvoiceAmt,\n" +
" sum( amt )/ sum( Qty ) InvoicePrice \n" +
string.Format(" '{0}' as Version ,", version)+"\n" +
" b.*,\n" +
" ISnull(\n" +
" c.Qty,\n" +
" IsNull( d.qty, 0 )) SettleQty,\n" +
" CASE\n" +
" \n" +
" WHEN e.Type = 'CP7报废' THEN\n" +
" isnull( e.Qty, 0 ) ELSE 0 \n" +
" END AS CP7ScrapQty,\n" +
" CASE\n" +
" \n" +
" WHEN e.Type = '索赔' THEN\n" +
" isnull( e.Qty, 0 ) ELSE 0 \n" +
" END AS ClaimQty,\n" +
" (\n" +
" b.InvoiceQty - ISnull(\n" +
" c.Qty,\n" +
" IsNull( d.qty, 0 ))) DiffQty,\n" +
//" Isnull( f.Price, 0 ) SalePrice,\n" +
//" b.InvoicePrice - Isnull( f.Price, 0 ) DiffPrice,\n" +
" g.MaterialCode AS SapMaterialCode,\n" +
" g.MaterialDesc AS MaterialDesc \n" +
" FROM\n" +
" (\n" +
" SELECT\n" +
" Factory,\n" +
" MaterialCode,\n" +
" SUM( QTY ) InvoiceQty,\n" +
" sum( amt ) InvoiceAmt,\n" +
" sum( amt )/ sum( Qty ) InvoicePrice \n" +
" FROM\n" +
" Set_Invoice \n" +
" WHERE\n" +
" version = '{0}' \n" +
" GROUP BY\n" +
" MaterialCode,\n" +
" Factory \n" +
" ) b\n" +
" LEFT JOIN ( SELECT SUM( QTY ) Qty, MaterialCode FROM Set_settle WHERE version = '{0}' GROUP BY MaterialCode ) c ON b.MaterialCode = c.MaterialCode\n" +
" LEFT JOIN ( SELECT SUM( QTY ) qty, MaterialCode FROM Set_KanbanSettle WHERE version = '{0}' GROUP BY MaterialCode ) d ON b.MaterialCode = d.MaterialCode\n" +
" LEFT JOIN ( SELECT * FROM Set_ScrapClaims WHERE version = '{0}' ) e ON b.MaterialCode = e.MaterialCode\n" +
//" LEFT JOIN ( SELECT * FROM Set_PriceList WHERE version = '{0}' ) f ON b.MaterialCode = f.MaterialCode\n" +
" LEFT JOIN Set_material g ON b.MaterialCode = g.CustomerPartCode \n" +
" ) temp1\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" Price,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_Invoice \n" +
" Set_PriceList \n" +
" WHERE\n" +
" version = '{0}' \n" +
" GROUP BY\n" +
" MaterialCode,Factory \n" +
" ) b\n" +
" LEFT JOIN ( SELECT SUM( QTY ) Qty, MaterialCode FROM Set_settle WHERE version = '{0}' GROUP BY MaterialCode ) c ON b.MaterialCode = c.MaterialCode\n" +
" LEFT JOIN ( SELECT SUM( QTY ) qty, MaterialCode FROM Set_KanbanSettle WHERE version = '{0}' GROUP BY MaterialCode ) d ON b.MaterialCode = d.MaterialCode\n" +
" LEFT JOIN ( SELECT * FROM Set_ScrapClaims WHERE version = '{0}' ) e ON b.MaterialCode = e.MaterialCode\n" +
" LEFT JOIN ( SELECT * FROM Set_PriceList WHERE version = '{0}' ) f ON b.MaterialCode = f.MaterialCode";
" version =(\n" +
" SELECT\n" +
" max( version ) \n" +
" FROM\n" +
" Set_PriceListVersion \n" +
" )) temp2 ON temp1.SapMaterialCode = temp2.MaterialCode";

2
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleFisDiffDetailDapperRepository.cs

@ -46,6 +46,8 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
public string SapCode { set; get; }
}
[ExcelExporter(Name = "未结汇总", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)]
public class SettleFisDiffSum
{

159
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettleDiffDapperRepository.cs

@ -32,6 +32,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
/// <summary>
/// 6.大众准时化未结差异比对表
/// </summary>
public class UnSettleDiffDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{
public UnSettleDiffDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) : base(dbContextProvider)
@ -44,71 +47,125 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
string str1 = "where 1=1 ";
string sql1 = "SELECT\n" +
" a.MaterialCode,\n" +
" a.KENNCode,\n" +
" a.ChassisNumber,\n" +
" a.qty unsettleQty,\n" +
" b.qty \n" +
" a.Cp5Time \n"+
"FROM\n" +
" Set_unsettle a\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" ItemCode,\n" +
" KENNCode,\n" +
" ChassisNumber2,\n" +
" sum( qty ) qty \n" +
" FROM\n" +
" Set_fis \n" +
" WHERE\n" +
" state = 0 \n" +
" OR state = 4 \n" +
" GROUP BY\n" +
" ItemCode,\n" +
" KENNCode,\n" +
" ChassisNumber2 \n" +
" ) b ON a.ChassisNumber = b.ChassisNumber2 \n" +
" AND a.MaterialCode = b.ItemCode \n" +
" AND a.KENNCode = b.KENNCode {0}";
string sql2 =
"SELECT\n" +
" a.*,\n" +
" b.Qty unsettleQty \n" +
string sql1 = "SELECT\n" +
" a.MaterialCode,\n" +
" a.KENNCode,\n" +
" a.ChassisNumber,\n" +
" a.qty UNSettleQty,\n" +
" b.qty,\n" +
" a.CP5A CP5Time,\n" +
" c.MaterialCode SapMaterialCode,\n" +
" c.MaterialDesc MaterialDesc,\n" +
" a.model Factory \n" +
"FROM\n" +
" (\n" +
" Set_unsettle a\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" WMSState,\n" +
" WMSBillNum,\n" +
" ItemCode,\n" +
" KENNCode,\n" +
" ChassisNumber2,\n" +
" sum( qty ) qty,\n" +
" ErpMaterialCode,\n" +
" ChassisNumber \n" +
" sum( qty ) qty \n" +
" FROM\n" +
" Set_fis \n" +
" WHERE\n" +
" state = 0 \n" +
" OR state = 4 \n" +
" GROUP BY\n" +
" ItemCode,\n" +
" KENNCode,\n" +
" ChassisNumber2,\n" +
" WMSState,\n" +
" WMSBillNum,\n" +
" ErpMaterialCode,\n" +
" ChassisNumber \n" +
" Cp5Time \n" +
" ) a\n" +
" LEFT JOIN Set_unsettle b ON a.ChassisNumber2 = b.ChassisNumber \n" +
" AND b.MaterialCode = a.ItemCode \n" +
" AND a.KENNCode = b.KENNCode {0}";
" Model \n" +
" ) b ON a.ChassisNumber = b.ChassisNumber2 \n" +
" AND a.MaterialCode = b.ItemCode \n" +
" AND a.KENNCode = b.KENNCode\n" +
" LEFT JOIN Set_material c ON a.MaterialCode = c.CustomerPartCode {0}";
string sql2 =
"SELECT\n" +
" t1.*,\n" +
" t1.Qty * T2.Price AMT,\n" +
" T2.Price,\n" +
" Qty -(\n" +
" ISNULL( UnSettleQty, 0 )) DiffQty,\n" +
" Qty -(\n" +
" ISNULL( UnSettleQty, 0 ))* isnull( t2.Price, 0 ) DiffPrice \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" temp1.WMSState,\n" +
" temp1.WMSBillNum,\n" +
" temp1.MaterialCode,\n" +
" temp1.KENNCode,\n" +
" temp1.ChassisNumber2,\n" +
" temp1.Qty,\n" +
" temp1.ChassisNumber,\n" +
" temp1.CP5Time,\n" +
" temp1.UnSettleQty,\n" +
" temp1.SapMaterialCode,\n" +
" temp1.MaterialDesc,\n" +
" temp1.MaterialGroup,\n" +
" temp2.MaterialCode AS ParentSapMaterialCode,\n" +
" temp2.MaterialDesc AS ParentMaterialDesc \n" +
" FROM\n" +
" (\n" +
" SELECT\n" +
" a.WMSState,\n" +
" a.WMSBillNum,\n" +
" a.MaterialCode,\n" +
" a.KENNCode,\n" +
" a.ChassisNumber2,\n" +
" a.Qty,\n" +
" a.ParentCode,\n" +
" a.ChassisNumber,\n" +
" a.CP5Time,\n" +
" b.Qty AS UnSettleQty,\n" +
" C.MaterialCode AS SapMaterialCode,\n" +
" C.MaterialDesc,\n" +
" C.EstimateTypeDesc AS MaterialGroup \n" +
" FROM\n" +
" (\n" +
" SELECT\n" +
" WMSState,\n" +
" WMSBillNum,\n" +
" ItemCode AS MaterialCode,\n" +
" KENNCode,\n" +
" ChassisNumber2,\n" +
" SUM( Qty ) AS Qty,\n" +
" ErpMaterialCode AS ParentCode,\n" +
" ChassisNumber,\n" +
" CP5Time \n" +
" FROM\n" +
" Set_fis \n" +
" WHERE\n" +
" ( State = 0 ) \n" +
" GROUP BY\n" +
" ItemCode,\n" +
" KENNCode,\n" +
" ChassisNumber2,\n" +
" WMSState,\n" +
" WMSBillNum,\n" +
" ErpMaterialCode,\n" +
" ChassisNumber,\n" +
" CP5Time \n" +
" ) AS a\n" +
" LEFT OUTER JOIN Set_Unsettle AS b ON a.ChassisNumber2 = b.ChassisNumber \n" +
" AND b.MaterialCode = a.MaterialCode \n" +
" AND a.KENNCode = b.KENNCode\n" +
" LEFT OUTER JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n" +
" ) AS temp1\n" +
" LEFT OUTER JOIN Set_material AS temp2 ON temp1.ParentCode = temp2.CustomerPartCode \n" +
" ) t1\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" MaterialCode,\n" +
" Price \n" +
" FROM\n" +
" Set_PriceList \n" +
"WHERE\n" +
" version = ( SELECT max( version ) FROM Set_PriceListVersion )) t2 ON t1.MaterialCode = t2.MaterialCode";
string _sql = string.Empty;

175
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/UnSettledDetailDapperRepository.cs

@ -11,18 +11,23 @@ using Dapper;
using Win.Sfs.SettleAccount.FISes;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report.ExportDto;
using Win.Sfs.SettleAccount.Entities.UnSettle;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.SettleAccount.Entities.Prices;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
/// <summary>
/// 7.大众准时化未结明细表(包含漏结,漏结要有标识)
/// </summary>
public class UnSettledDetailDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{
//ERP总成开票报表
public UnSettledDetailDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public virtual List<UnSettleDetailReport> GetDiffReport(string year, string begin, string end, string customcode, string version,string materialCode,string materialGroup,string sapCode)
public virtual List<UnSettleDetailReport> GetDiffReport(string year, string begin, string end, string customcode, string version, string materialCode, string materialGroup, string sapCode)
{
string str = string.Empty;
@ -30,7 +35,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
if (!string.IsNullOrEmpty(begin))
{
str += string.Format(" and beginTime>'{0}' ",begin);
str += string.Format(" and beginTime>'{0}' ", begin);
}
if (!string.IsNullOrEmpty(end))
{
@ -38,81 +43,113 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
if (!string.IsNullOrEmpty(materialCode))
{
str += string.Format(" and MaterialCode='{0}' ", materialCode);
str += string.Format(" and ItemCode='{0}' ", materialCode);
}
if (!string.IsNullOrEmpty(materialGroup))
{
str += string.Format(" and MaterialGroup='{0}' ", materialGroup);
}
if (!string.IsNullOrEmpty(sapCode))
{
str += string.Format(" and MaterialGroup='{0}' ", materialGroup);
}
//if (!string.IsNullOrEmpty(sapCode))
//{
// str += string.Format(" and SapCode='{0}' ", materialGroup);
//}
var sqlString =
" SELECT\n" +
" A.*,\n" +
" C.Price,\n" +
" ISNULL( A.QTY, 0 )* ISNULL( C.Price, 0 ) AMT \n" +
"FROM\n" +
" (\n" +
" SELECT DISTINCT\n" +
" '' WMSState,\n" +
" '' UnSettleVersion,\n" +
" '' WMSBillNum,\n" +
" BeginTime CP5Time,\n" +
" ErpMaterialCode MaterialCode,\n" +
" ChassisNumber,\n" +
" KENNCode,\n" +
" 1 QTY,\n" +
" ErpMaterialCode ParentMaterialCode,\n" +
" '' FLAG \n" +
" FROM\n" +
" Set_fis \n" +
" WHERE\n" +
" 1 = 1 \n" +
" AND STATE = 0 {0} UNION ALL\n" +
" SELECT\n" +
" WMSState,\n" +
" UnSettleVersion,\n" +
" WMSBillNum,\n" +
" BeginTime CP5Time,\n" +
" ItemCode MaterialCode,\n" +
" ChassisNumber,\n" +
" KENNCode,\n" +
" QTY,\n" +
" ErpMaterialCode,\n" +
" '' FLAG \n" +
" FROM\n" +
" [Set_fis] \n" +
" WHERE\n" +
" 1 = 1 \n" +
" AND STATE = 0 {0} UNION ALL\n" +
" SELECT\n" +
" WMSState,\n" +
" UnSettleVersion,\n" +
" WMSBillNum,\n" +
" BeginTime CP5Time,\n" +
" ItemCode MaterialCode,\n" +
" ChassisNumber,\n" +
" KENNCode,\n" +
" QTY,\n" +
" ErpMaterialCode,\n" +
" 'L' FLAG \n" +
" FROM\n" +
" [Set_fis] \n" +
" WHERE\n" +
" 1 = 1 \n" +
" AND STATE = 4 {0}\n" +
" ) A\n" +
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) ) C ON a.MaterialCode = c.MaterialCode";
string _sql = string.Format(sqlString, version);
"SELECT\n" +
" A.*,\n" +
" C.Price,\n" +
" ISNULL( A.QTY, 0 )* ISNULL( C.Price, 0 ) AMT,\n" +
" B.EstimateTypeDesc MaterialGroup,\n" +
" B.MaterialDesc MaterialDesc,\n" +
" d.MaterialDesc ParentMaterialDesc \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" WMSState,\n" +
" WMSBillNum,\n" +
" UnSettleVersion,\n" +
" BeginTime CP5Time,\n" +
" ItemCode MaterialCode,\n" +
" ChassisNumber,\n" +
" KENNCode,\n" +
" QTY,\n" +
" ErpMaterialCode ParentSapMaterialCode,\n" +
" '' FLAG \n" +
" FROM\n" +
" Set_fis {0} \n" +
" WHERE\n" +
" 1 = 1 \n" +
" AND STATE = 0 UNION ALL\n" +
" SELECT\n" +
" WMSState,\n" +
" UnSettleVersion,\n" +
" WMSBillNum,\n" +
" BeginTime CP5Time,\n" +
" ItemCode MaterialCode,\n" +
" ChassisNumber,\n" +
" KENNCode,\n" +
" QTY,\n" +
" ErpMaterialCode ParentSapMaterialCode,\n" +
" 'L' FLAG \n" +
" FROM\n" +
" Set_fis {0} \n" +
" WHERE\n" +
" 1 = 1 \n" +
" AND STATE = 4 \n" +
" ) A\n" +
" LEFT JOIN Set_material B ON a.MaterialCode = b.CustomerPartCode\n" +
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) ) C ON a.MaterialCode = c.MaterialCode\n" +
" LEFT JOIN Set_material d ON a.ParentSapMaterialCode = d.MaterialCode";
var _materialList = DbConnection.Query<Material>("select * from set_material").ToList();
var _priceList = DbConnection.Query<PriceList>("select MaterialCode,Price from Set_PriceList where version=(select max(version) from set_Set_PriceListVersion)").ToList();
string _sql = string.Format(sqlString, str);
;
var _query = DbConnection.Query<UnSettleDetailReport>(_sql);
return _query.ToList();
var _list = _query.ToList();
var _ls = _list.Where(p=>p.Flag!="L").GroupBy(p => new { p.KENNCode, p.ChassisNumber, p.ParentSapMaterialCode }).Select(p => p.FirstOrDefault()).ToList();
foreach (var itm in _ls)
{
var parentMaterial = new UnSettleDetailReport();
parentMaterial.WmsBillNum = itm.WmsBillNum;
parentMaterial.CP5Time = itm.CP5Time;
parentMaterial.KENNCode = itm.KENNCode;
parentMaterial.ChassisNumber = itm.ChassisNumber;
parentMaterial.WmsState = itm.WmsState;
parentMaterial.SapMaterialCode = itm.ParentSapMaterialCode;
parentMaterial.MaterialDesc = itm.ParentMaterialDesc;
parentMaterial.MaterialCode = itm.ParentSapMaterialCode;
parentMaterial.ParentSapMaterialCode = itm.ParentSapMaterialCode;
parentMaterial.ParentMaterialDesc = itm.ParentMaterialDesc;
var _price=_priceList.Where(p => p.MaterialCode == itm.ParentSapMaterialCode).FirstOrDefault();
if (_price != null)
{
parentMaterial.Price = _price.Price;
parentMaterial.Amt = _price.Price;
}
var _material=_materialList.Where(p => p.MaterialCode == itm.ParentSapMaterialCode).FirstOrDefault();
if (_material != null)
{
parentMaterial.MaterialGroup = _material.EstimateTypeDesc;
}
_list.Add(parentMaterial);
}
return _list;
}
}
}

20
src/Modules/SettleAccount/src/SettleAccount.Job/Services/OutputService.cs

@ -57,8 +57,26 @@ namespace SettleAccount.Job.Services
_taskjobRepository.UpdateTaskJob(Id, _task);
//保存导出文件到服务器存成二进制
}
public void Export<T1,T2>(Guid Id, string fileName, List<T1> p_list, List<T2> p_list1) where T1 : class, new()
where T2: class, new()
{
ExcelExporter _exporter = new ExcelExporter();//导出Excel
var result = _exporter
.Append(p_list, "sheet1")
.SeparateBySheet()
.Append(p_list1)
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(fileName, result.Result, true);
var _task = new Win.Sfs.SettleAccount.Entities.TaskJob() { DownFileName = fileName };
_taskjobRepository.UpdateTaskJob(Id, _task);
//保存导出文件到服务器存成二进制
}

8
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDiffExportService.cs

@ -70,8 +70,12 @@ namespace SettleAccount.Job.Services
SalePrice =itm. SalePrice ,
DiffPrice =itm. DiffPrice ,
SapMaterialCode =itm.SapMaterialCode ,
Factory = itm.Factory
MaterialDesc=itm.MaterialDesc,
Factory = itm.Factory,

139
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleFisDiffExportService.cs

@ -1,5 +1,8 @@
using System;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -12,12 +15,18 @@ using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
namespace SettleAccount.Job.Services.Report
{
/// <summary>
/// 3.大众准时化结算数量差异比对表
/// </summary>
public class SettleFisDiffExportService : ITransientDependency, IExportJob
{
private readonly SettleFisDiffDetailDapperRepository _dapper;
private readonly OutputService _outputService;
public SettleFisDiffExportService(SettleFisDiffDetailDapperRepository dapper, OutputService outputService)
{
_dapper = dapper;
@ -33,7 +42,7 @@ namespace SettleAccount.Job.Services.Report
var end = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value;
var _list= _dapper.GetReportList(version, materialCode, begin,end);
_list.GroupBy(p => new { p.MaterialCode,p.SapCode }).Select(p =>new SettleFisDiffSum
var _ls= _list.GroupBy(p => new { p.MaterialCode,p.SapCode }).Select(p =>new SettleFisDiffSum
{
MaterialCode= p.Key.MaterialCode,
@ -46,18 +55,132 @@ namespace SettleAccount.Job.Services.Report
});
//_outputService.Export(id, string.Format("大众准时化结算数量差异比对表_{0}.xlsx", Guid.NewGuid().ToString()),_list.ToList(),_ls.ToList());
_outputService.Export<SettleFisDiffSum>(id, string.Format("大众准时化结算数量合计_{0}.xlsx", Guid.NewGuid().ToString()), _ls.ToList());
_outputService.Export<SettleFisDiffDetail>(id,string.Format("大众准时化结算数量差异比对表_{0}.xlsx", Guid.NewGuid().ToString()), _list);
return id.ToString();
}
/// <summary>
/// 将数个Excel文件中的第一个工作表合并至一个Excel文件中
/// </summary>
/// <param name="excelFilePaths">需要合并的数个Excel文件路径</param>
/// <param name="desFilePath">合并成的一个Excel文件路径</param>
private void MergeExcels(string[] excelFilePaths, string desFilePath)
{
XSSFWorkbook mergeWorkBook = new XSSFWorkbook();
for (int i = 0; i < excelFilePaths.Length; i++)
{
if (File.Exists(excelFilePaths[i]))
{
using (FileStream fs = new FileStream(excelFilePaths[i], FileMode.Open, FileAccess.Read, FileShare.Write))
{
XSSFWorkbook tmpWorkBook = new XSSFWorkbook(fs);
XSSFSheet tmpSheet = tmpWorkBook.GetSheetAt(0) as XSSFSheet;
if (excelFilePaths[i].Contains("当月结算表"))
{
IRow row = null;
for (int j = 2; j < tmpSheet.PhysicalNumberOfRows && tmpSheet.GetRow(j) != null; j++)/*j=1 从索引的第一行开始过滤掉表头*/
{
row = tmpSheet.GetRow(j);
try
{
if (!string.IsNullOrWhiteSpace(row.GetCell(1).ToString()))/*验证数值非空*/
{
//cell.CSS("color:red;font-weight:bold;font-size:11;font-name:宋体;border-type:thin;")
/*修改样式关键代码*/
ICellStyle style = tmpWorkBook.CreateCellStyle();
style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Orange.Index;
style.FillPattern = FillPattern.SolidForeground;
style.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Orange.Index;
style.BorderTop = BorderStyle.Thin;//上
style.BorderBottom = BorderStyle.Thin;//下
style.BorderLeft = BorderStyle.Thin;//左
style.BorderRight = BorderStyle.Thin;//右
style.VerticalAlignment = VerticalAlignment.Center;
style.Alignment = HorizontalAlignment.Center;
IFont font = tmpWorkBook.CreateFont();
font.FontHeightInPoints = 10; // 字体大小 直接对应Excel中的字体大小
font.FontName = "宋体"; //跟Excel中的字体值一样,直接写对应的名称即可
font.IsBold = true;//加粗
style.SetFont(font);
/*修改指定单元格样式 如果要修改行样式则需要将row.Cells.Count循环出来,挨个设置!*/
for (int g = 0; g < row.Cells.Count; g++)
{
row.Cells[g].CellStyle = style;
}
row.RowStyle = style;
if (row.GetCell(1).ToString() == "核算表不存在")
{
ICellStyle style1 = tmpWorkBook.CreateCellStyle();
style1.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index;
style1.FillPattern = FillPattern.SolidForeground;
style1.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index;
style1.BorderTop = BorderStyle.Thin;//上
style1.BorderBottom = BorderStyle.Thin;//下
style1.BorderLeft = BorderStyle.Thin;//左
style1.BorderRight = BorderStyle.Thin;//右
style1.VerticalAlignment = VerticalAlignment.Center;
style1.Alignment = HorizontalAlignment.Center;
IFont font1 = tmpWorkBook.CreateFont();
font1.FontHeightInPoints = 10; // 字体大小 直接对应Excel中的字体大小
font1.FontName = "宋体"; //跟Excel中的字体值一样,直接写对应的名称即可
font1.IsBold = true;//加粗
font1.Color = NPOI.HSSF.Util.HSSFColor.White.Index;
style1.SetFont(font);
//style.fon
//HSSFFont font = workbookAll.CreateFont();
//font.FontHeightInPoints = 9; // 字体大小 直接对应Excel中的字体大小
//font.FontName = "宋体"; //跟Excel中的字体值一样,直接写对应的名称即可
//font.Boldweight = HSSFFont.BOLDWEIGHT_BOLD;//加粗
//style.SetFont(font);
/*修改指定单元格样式 如果要修改行样式则需要将row.Cells.Count循环出来,挨个设置!*/
for (int g = 0; g < row.Cells.Count; g++)
{
row.Cells[g].CellStyle = style1;
}
row.RowStyle = style1;
}
/*重新修改文件指定单元格样式*/
}
}
catch
{ }
}
}
tmpSheet.CopyTo(mergeWorkBook, Path.GetFileNameWithoutExtension(excelFilePaths[i]), true, true);
}
}
/* 考虑数据量,此处可以限制最多可以合并工作表的数量 */
//if (mergeWorkBook.NumberOfSheets >= 200)
//{
// break;
//}
}
if (mergeWorkBook.NumberOfSheets != 0)
{
FileStream fsDesFile = new FileStream(desFilePath, FileMode.OpenOrCreate, FileAccess.Write);
mergeWorkBook.Write(fsDesFile);
fsDesFile.Close();
mergeWorkBook.Close();
}
else
{
mergeWorkBook.Close();
}
}
_outputService.Export<SettleFisDiffDetail>(id,string.Format("大众准时化结算数量差异比对表_{0}.xlsx", Guid.NewGuid().ToString()), _list);
return id.ToString();
}
}
}

BIN
src/Shared/Win.Abp.Snowflakes/obj/Debug/netcoreapp5/Win.Abp.Snowflakes.csproj.AssemblyReference.cache

Binary file not shown.

BIN
src/Shared/Win.Sfs.Shared/obj/Debug/netcoreapp5/Win.Sfs.Shared.csproj.AssemblyReference.cache

Binary file not shown.
Loading…
Cancel
Save