44673626
3 years ago
7 changed files with 515 additions and 144 deletions
@ -0,0 +1,186 @@ |
|||
using Dapper; |
|||
using Magicodes.ExporterAndImporter.Core; |
|||
using Microsoft.EntityFrameworkCore; |
|||
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.FISes; |
|||
using Win.Sfs.SettleAccount.FISes; |
|||
//using Win.Sfs.Shared.Enums.SettleAccount;
|
|||
|
|||
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report |
|||
{ |
|||
public class SharePartUnSettled |
|||
{ |
|||
[ExporterHeader(DisplayName = "交货单号")] |
|||
public string WMSDeliveryNote {set;get;} |
|||
[ExporterHeader(DisplayName = "发货日期")] |
|||
public string OrderDate {set;get;} |
|||
[ExporterHeader(DisplayName = "订单编号")] |
|||
public string PurchaseOrderNo {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 string MaterilGroup {set;get;} |
|||
[ExporterHeader(DisplayName = "发货数量")] |
|||
//public string PurchaseOrderNoText {set;get;}
|
|||
public decimal Qty {set;get;} |
|||
[ExporterHeader(DisplayName = "收货数量")] |
|||
public decimal ReceiptQty {set;get;} |
|||
[ExporterHeader(DisplayName = "数量差异")] |
|||
public decimal DiffQty {set;get;} |
|||
[ExporterHeader(DisplayName = "单价")] |
|||
public decimal Price { set; get; } |
|||
[ExporterHeader(DisplayName = "差异金额")] |
|||
public decimal DiffAMT { set; get; } |
|||
|
|||
|
|||
|
|||
//[ExporterHeader(DisplayName = "交货单号")]
|
|||
//public string WmsBillNum { set; get; }
|
|||
//[ExporterHeader(DisplayName = "发货日期")]
|
|||
//public string BeginDate { set; get; }
|
|||
//[ExporterHeader(DisplayName = "看板号")]
|
|||
//public string Kanban { set; get; }
|
|||
//[ExporterHeader(DisplayName = "零件号")]
|
|||
//public string SapCode { set; get; }
|
|||
//[ExporterHeader(DisplayName = "零件描述")]
|
|||
//public string MaterialDesc { set; get; }
|
|||
//[ExporterHeader(DisplayName = "客户零件号")]
|
|||
//public string CustomerPartCode { set; get; }
|
|||
//[ExporterHeader(DisplayName = "物料组")]
|
|||
//public string MaterialGroup { set; get; }
|
|||
//[ExporterHeader(DisplayName = "结算数量")]
|
|||
//public decimal SettleQty { set; get; }
|
|||
//[ExporterHeader(DisplayName = "发货数量")]
|
|||
//public decimal Qty { set; get; }
|
|||
//[ExporterHeader(DisplayName = "量差")]
|
|||
//public decimal DiffQty { set; get; }
|
|||
//[ExporterHeader(DisplayName = "单价")]
|
|||
//public decimal Price { set; get; }
|
|||
//[ExporterHeader(DisplayName = "差异金额")]
|
|||
//public decimal DiffAMT { set; get; }
|
|||
} |
|||
|
|||
public class SharePartUnSettledExtend |
|||
{ |
|||
[ExporterHeader(DisplayName = "物料编码")] |
|||
public string SAPCode {set;get;} |
|||
[ExporterHeader(DisplayName = "客户物料号")] |
|||
public string MaterialCode {set;get;} |
|||
[ExporterHeader(DisplayName = "物料描述")] |
|||
public string MaterialDesc {set;get;} |
|||
[ExporterHeader(DisplayName = "物料组(车型)")] |
|||
public string MaterilGroup {set;get;} |
|||
[ExporterHeader(DisplayName = "发货数量")] |
|||
public string Qty {set;get;} |
|||
[ExporterHeader(DisplayName = "收货数量")] |
|||
public string ReceiptQty {set;get;} |
|||
[ExporterHeader(DisplayName = "数量差异")] |
|||
public string DiffQty {set;get;} |
|||
[ExporterHeader(DisplayName = "单价")] |
|||
public decimal Price { set; get; } |
|||
[ExporterHeader(DisplayName = "差异金额")] |
|||
public string DiffAMT { set; get; } |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public class SharePartUnSettledDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency |
|||
{ |
|||
public SharePartUnSettledDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
|
|||
} |
|||
public virtual List<SharePartUnSettled> GetKanbanReportList( string version, string begintime, string endtime) |
|||
{ |
|||
|
|||
var sql = "SELECT\n" + |
|||
" temp1.*,\n" + |
|||
" ( temp2.Price * temp1.DiffQty ) DiffAMT, \n" + |
|||
" temp2.Price \n" + |
|||
"FROM\n" + |
|||
" (\n" + |
|||
" SELECT\n" + |
|||
" A.WMSDeliveryNote,\n" + |
|||
" A.SpareDate AS OrderDate,\n" + |
|||
" a.PurchaseOrderNo,\n" + |
|||
" C.MaterialCode AS SAPCode,\n" + |
|||
" a.MaterialCode,\n" + |
|||
" C.MaterialDesc,\n" + |
|||
" C.EstimateTypeDesc MaterilGroup,\n" + |
|||
" a.PurchaseOrderNoText,\n" + |
|||
" A.ReceiptQty Qty,\n" + |
|||
" ISNULL( B.ReceiptQty, 0 ) ReceiptQty,\n" + |
|||
" ISNULL( A.ReceiptQty, 0 )- ISNULL( B.ReceiptQty, 0 ) DiffQty \n" + |
|||
" FROM\n" + |
|||
" Set_WmsSparePart A\n" + |
|||
" LEFT JOIN Set_SparePart B ON A.PurchaseOrderNo = B.PurchaseOrderNo \n" + |
|||
" AND A.MaterialCode = B.MaterialCode\n" + |
|||
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n" + |
|||
" ) temp1\n" + |
|||
" LEFT JOIN (\n" + |
|||
" SELECT\n" + |
|||
" Price,\n" + |
|||
" MaterialCode \n" + |
|||
" FROM\n" + |
|||
" Set_PriceList \n" + |
|||
"WHERE\n" + |
|||
" version = ( SELECT MAX( Version ) FROM Set_PriceList )) temp2 ON temp1.SAPCode = temp2.MaterialCode"; |
|||
string str = string.Empty; |
|||
str += " where 1=1 "; |
|||
var _query = DbConnection.Query<SharePartUnSettled>(sql, null, null, true, 1200, null); |
|||
var _list = _query.ToList(); |
|||
return _list; |
|||
} |
|||
public virtual List<SharePartUnSettledExtend> GetNoOrderSharePartReportList( string version, string begintime, string endtime) |
|||
{ |
|||
var sql = "SELECT\n" + |
|||
" temp1.*,\n" + |
|||
" temp2.Price , Round( temp2.Price * temp1.DiffQty, 2 ) DiffAMT \n" + |
|||
"FROM\n" + |
|||
" (\n" + |
|||
" SELECT\n" + |
|||
" C.MaterialCode AS SAPCode,\n" + |
|||
" a.MaterialCode,\n" + |
|||
" C.MaterialDesc,\n" + |
|||
" C.EstimateTypeDesc MaterilGroup,\n" + |
|||
" A.Qty,\n" + |
|||
" ISNULL( B.ReceiptQty, 0 ) ReceiptQty,\n" + |
|||
" ISNULL( A.Qty, 0 )- ISNULL( B.ReceiptQty, 0 ) DiffQty \n" + |
|||
" FROM\n" + |
|||
" ( SELECT SUM( ReceiptQty ) Qty, MaterialCode FROM Set_WmsSparePart GROUP BY MaterialCode ) a\n" + |
|||
" LEFT JOIN Set_SparePart B ON A.MaterialCode = B.MaterialCode\n" + |
|||
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n" + |
|||
" ) temp1\n" + |
|||
" LEFT JOIN (\n" + |
|||
" SELECT\n" + |
|||
" Price,\n" + |
|||
" MaterialCode \n" + |
|||
" FROM\n" + |
|||
" Set_PriceList \n" + |
|||
"WHERE\n" + |
|||
" version = ( SELECT MAX( Version ) FROM Set_PriceList )) temp2 ON temp1.SAPCode = temp2.MaterialCode"; |
|||
string str = string.Empty; |
|||
str += " where 1=1 "; |
|||
var _query = DbConnection.Query<SharePartUnSettledExtend>(sql, null, null, true, 1200, null); |
|||
var _list = _query.ToList(); |
|||
return _list; |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,112 @@ |
|||
using Magicodes.ExporterAndImporter.Excel; |
|||
using Shouldly; |
|||
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.BlobStoring; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Win.Sfs.BaseData.ImportExcelCommon; |
|||
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; |
|||
|
|||
namespace SettleAccount.Job.Services.Report |
|||
{ |
|||
public class SharePartUnSettledExport : ITransientDependency, IExportJob |
|||
{ |
|||
|
|||
private readonly OutputService _outputService; |
|||
KanbanUnSettledDapperRepository _dapper; |
|||
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|||
|
|||
public SharePartUnSettledExport(KanbanUnSettledDapperRepository dapper, OutputService outputService, |
|||
|
|||
IBlobContainer<MyFileContainer> fileContainer |
|||
) |
|||
{ |
|||
|
|||
_dapper = dapper; |
|||
_outputService = outputService; |
|||
|
|||
_fileContainer = fileContainer; |
|||
} |
|||
|
|||
public string ExportFile(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 = _dapper.GetKanbanReportList(version, begin,end); |
|||
var _lst = _dapper.GetNoKanbanReportList(version, begin, end); |
|||
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(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(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(materialGroup)) |
|||
{ |
|||
var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList(); |
|||
if (_groupList.Count() > 0) |
|||
{ |
|||
_lst = _lst.Where(p => _groupList.Contains(p.MaterialGroup)).ToList(); |
|||
} |
|||
} |
|||
if (!string.IsNullOrEmpty(materialCode)) |
|||
{ |
|||
var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList(); |
|||
if (_groupList.Count() > 0) |
|||
{ |
|||
_lst = _lst.Where(p => _groupList.Contains(p.MaterialCode)).ToList(); |
|||
} |
|||
} |
|||
if (!string.IsNullOrEmpty(sapCode)) |
|||
{ |
|||
var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); |
|||
if (_groupList.Count() > 0) |
|||
{ |
|||
_lst = _lst.Where(p => _groupList.Contains(p.SapCode)).ToList(); |
|||
} |
|||
} |
|||
ExcelExporter _exporter = new ExcelExporter();//导出Excel
|
|||
var result = _exporter.Append(_ls.ToList(), "有看板号未结差异对比") |
|||
.SeparateBySheet() |
|||
.Append(_lst.ToList(), "无看板号未结差异对比") |
|||
.ExportAppendDataAsByteArray(); |
|||
result.ShouldNotBeNull(); |
|||
_fileContainer.SaveAsync(_filename, result.Result, true); |
|||
|
|||
|
|||
|
|||
return id.ToString(); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue