Administrator
3 years ago
4 changed files with 305 additions and 21 deletions
@ -0,0 +1,149 @@ |
|||||
|
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 KanbanUnSettled |
||||
|
{ |
||||
|
[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 KanbanUnSettledExtend |
||||
|
{ |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "客户物料号")] |
||||
|
public string MaterialCode { set; get; } |
||||
|
[ExporterHeader(DisplayName = "物料号")] |
||||
|
public string SapCode { set; get; } |
||||
|
[ExporterHeader(DisplayName = "物料名称")] |
||||
|
public string MaterialDesc { set; get; } |
||||
|
//[ExporterHeader(DisplayName = "ERP物料号")]
|
||||
|
//public string CustomerPartCode { set; get; }
|
||||
|
[ExporterHeader(DisplayName = "物料组车型")] |
||||
|
public string MaterialGroup { set; get; } |
||||
|
[ExporterHeader(DisplayName = "发货数量")] |
||||
|
public string Qty { set; get; } |
||||
|
[ExporterHeader(DisplayName = "结算数量")] |
||||
|
public string SettleQty { set; get; } |
||||
|
[ExporterHeader(DisplayName = "量差")] |
||||
|
public string DiffQty { set; get; } |
||||
|
[ExporterHeader(DisplayName = "单价")] |
||||
|
public string Price { set; get; } |
||||
|
[ExporterHeader(DisplayName = "差异金额")] |
||||
|
public string DiffAMT { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
public class KanbanUnSettledDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency |
||||
|
{ |
||||
|
public KanbanUnSettledDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) : base(dbContextProvider) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
public virtual List<KanbanUnSettled> GetKanbanReportList( string version, string begintime, string endtime) |
||||
|
{ |
||||
|
|
||||
|
string sql = " SELECT\n" + |
||||
|
" TEMP1.*,\n" + |
||||
|
" TEMP2.Price,\n" + |
||||
|
" ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" + |
||||
|
"FROM\n" + |
||||
|
" (\n" + |
||||
|
" SELECT\n" + |
||||
|
" a.WMSDeliveryNote WmsBillNum,\n" + |
||||
|
" a.WMSActualGoodsDate BeginDate,\n" + |
||||
|
" a.Kanban,\n" + |
||||
|
" C.MaterialCode SapCode,\n" + |
||||
|
" C.MaterialDesc,\n" + |
||||
|
" C.CustomerPartCode,\n" + |
||||
|
" C.EstimateTypeDesc MaterialGroup,\n" + |
||||
|
" ISNULL( B.Qty, 0 ) SettleQty,\n" + |
||||
|
" a.Qty,\n" + |
||||
|
" (\n" + |
||||
|
" a.Qty - ISNULL( b.Qty, 0 )) AS DiffQty \n" + |
||||
|
" FROM\n" + |
||||
|
" Set_WMSKanBanSettle A\n" + |
||||
|
" LEFT JOIN ( SELECT * FROM Set_KanBanSettle WHERE version = '{0}' ) B ON A.Kanban = B.Kanban \n" + |
||||
|
" AND A.MaterialCode = B.MaterialCode\n" + |
||||
|
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n" + |
||||
|
" ) TEMP1\n" + |
||||
|
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE 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<KanbanUnSettled>(sql, null, null, true, 1200, null); |
||||
|
var _list = _query.ToList(); |
||||
|
return _list; |
||||
|
} |
||||
|
public virtual List<KanbanUnSettledExtend> GetNoKanbanReportList( string version, string begintime, string endtime) |
||||
|
{ |
||||
|
var sql = "SELECT\n" + |
||||
|
" TEMP1.*,\n" + |
||||
|
" TEMP2.Price,\n" + |
||||
|
" ROUND( TEMP2.Price * TEMP1.DiffQty, 2 ) AS DiffAMT \n" + |
||||
|
"FROM\n" + |
||||
|
" (\n" + |
||||
|
" SELECT\n" + |
||||
|
" a.MaterialCode,\n" + |
||||
|
" C.MaterialCode SapCode,\n" + |
||||
|
" C.MaterialDesc,\n" + |
||||
|
" C.CustomerPartCode,\n" + |
||||
|
" C.EstimateTypeDesc MaterialGroup,\n" + |
||||
|
" isnull( a.Qty, 0 ) Qty,\n" + |
||||
|
" isnull( b.Qty, 0 ) SettleQty,\n" + |
||||
|
" isnull( a.Qty, 0 )- isnull( b.Qty, 0 ) DiffQty \n" + |
||||
|
" FROM\n" + |
||||
|
" ( SELECT SUM( Qty ) Qty, MaterialCode FROM Set_WMSKanBanSettle WHERE PartType = 1 GROUP BY MaterialCode ) a\n" + |
||||
|
" LEFT JOIN ( SELECT sum( qty ) Qty, MaterialCode FROM Set_KanBanSettle GROUP BY MaterialCode ) b ON a.MaterialCode = b.MaterialCode\n" + |
||||
|
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n" + |
||||
|
" ) temp1\n" + |
||||
|
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE 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<KanbanUnSettledExtend>(sql, null, null, true, 1200, null); |
||||
|
var _list = _query.ToList(); |
||||
|
return _list; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,119 @@ |
|||||
|
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 KanBanUnSettledExport : ITransientDependency, IExportJob |
||||
|
{ |
||||
|
|
||||
|
private readonly OutputService _outputService; |
||||
|
KanbanUnSettledDapperRepository _dapper; |
||||
|
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
||||
|
|
||||
|
public KanBanUnSettledExport(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