44673626
3 years ago
4 changed files with 188 additions and 0 deletions
@ -0,0 +1,102 @@ |
|||
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 |
|||
{ |
|||
public class SettleDoorPanelDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency |
|||
{ |
|||
public SettleDoorPanelDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ } |
|||
|
|||
|
|||
public virtual List<SettleDoorPanelExport> GetSettleDoorPanelReportList(string estimateTypeDesc, string version, string sapCode, string matialCode) |
|||
{ |
|||
string sqlString = "SELECT\n" + |
|||
" * ,\n" + |
|||
" ISNULL( Price - InvoicePrice, 0 ) AS InvoiceDiffPrice --单价差异\n" + |
|||
" \n" + |
|||
"FROM\n" + |
|||
" (\n" + |
|||
" SELECT\n" + |
|||
" c.EstimateTypeDesc,--物料组(车型)\n" + |
|||
" a.MaterialCode,--物料代码\n" + |
|||
" c.MaterialCode AS SAPCode,--厂内零件号\n" + |
|||
" c.CustomerPartCode,--客户物料\n" + |
|||
" c.MaterialDesc,--物料描述\n" + |
|||
" d.InvoicePrice \n" + |
|||
" FROM\n" + |
|||
" Set_Settle AS a\n" + |
|||
" INNER JOIN Set_fis AS b ON a.KENNCode= b.KENNCode \n" + |
|||
" AND a.ChassisNumber= b.ChassisNumber2 \n" + |
|||
" AND a.MaterialCode= b.ItemCode\n" + |
|||
" LEFT JOIN Set_material AS c ON a.MaterialCode= c.CustomerPartCode\n" + |
|||
" LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE version = '{0}' GROUP BY materialcode ) d ON a.MaterialCode= d.MaterialCode \n" + |
|||
" WHERE\n" + |
|||
" b.Version= '{0}' \n" + |
|||
" ) TEMP1\n" + |
|||
" LEFT JOIN ( SELECT Price, --定价\n" + |
|||
" MaterialCode --厂内物料号\n" + |
|||
" FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode \n" + |
|||
"WHERE\n" + |
|||
" 1=1 "; |
|||
string addwhere = string.Empty; |
|||
string addSqlStr = string.Format(sqlString, version); |
|||
if (!string.IsNullOrEmpty(estimateTypeDesc)) |
|||
{ |
|||
addwhere += string.Format(" AND EstimateTypeDesc LIKE '{0}%' ", estimateTypeDesc); |
|||
} |
|||
else if (!string.IsNullOrEmpty(sapCode)) |
|||
{ |
|||
addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode); |
|||
} |
|||
else if (!string.IsNullOrEmpty(matialCode)) |
|||
{ |
|||
addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode); |
|||
} |
|||
string _sql = string.Format(addSqlStr, addwhere); |
|||
//string _sql = string.Format(sqlString, version);
|
|||
var _query = DbConnection.Query<SettleDoorPanelExport>(_sql, null, null, true, 1200, null); |
|||
return _query.ToList(); |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 大众看板有条码报表
|
|||
/// </summary>
|
|||
//[ExcelExporter(Name = "未结明细", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)]
|
|||
public class SettleDoorPanelExport |
|||
{ |
|||
[ExporterHeader(DisplayName = "物料组(车型)")] |
|||
public string EstimateTypeDesc { set; get; } |
|||
|
|||
[ExporterHeader(DisplayName = "物料号")] |
|||
public string SAPCode { set; get; } |
|||
|
|||
[ExporterHeader(DisplayName = "客户物料")] |
|||
public string MaterialCode { set; get; } |
|||
|
|||
[ExporterHeader(DisplayName = "物料描述")] |
|||
public string MaterialDesc { set; get; } |
|||
|
|||
[ExporterHeader(DisplayName = "开票单价")] |
|||
public decimal InvoicePrice { set; get; } |
|||
|
|||
[ExporterHeader(DisplayName = "定价")] |
|||
public decimal Price { set; get; } |
|||
|
|||
[ExporterHeader(DisplayName = "单价差异")] |
|||
public decimal InvoiceDiffPrice { set; get; } |
|||
|
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
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 SettleDoorPanelExportService : ITransientDependency, IExportJob |
|||
{ |
|||
private readonly SettleDoorPanelDapperRepository _dapper; |
|||
private readonly OutputService _outputService; |
|||
|
|||
public SettleDoorPanelExportService(SettleDoorPanelDapperRepository dapper, OutputService outputService) |
|||
{ |
|||
_dapper = dapper; |
|||
_outputService = outputService; |
|||
} |
|||
|
|||
//public virtual List<SettleDoorPanelExport> GetSettleDoorPanelReportList(string purchaseOrderNo, string version, string sapCode, string matialCode)
|
|||
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list) |
|||
{ |
|||
var estimateTypeDesc = p_list.Where(p => p.Name == "EstimateTypeDesc").FirstOrDefault().Value; |
|||
var sapCode = p_list.Where(p => p.Name == "SAPCode").FirstOrDefault().Value; |
|||
var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; |
|||
var customerPartCode = p_list.Where(p => p.Name == "CustomerPartCode").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 _list = _dapper.GetSettleDoorPanelReportList(estimateTypeDesc, version, sapCode, customerPartCode); |
|||
|
|||
_outputService.Export<SettleKBWithCode>(id, string.Format("大众看板结算与交货核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _list); |
|||
|
|||
return id.ToString(); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue