Administrator
3 years ago
5 changed files with 206 additions and 0 deletions
@ -0,0 +1,131 @@ |
|||
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.Reports; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report |
|||
{ |
|||
public class UnSettleDiff: ReportDetailBase |
|||
{ |
|||
[ExporterHeader(DisplayName = "结算平台未结数量")] |
|||
public decimal Qty { set; get; } |
|||
[ExporterHeader(DisplayName = "大众R3未结数量")] |
|||
public decimal UNSettleQty { set; get; } |
|||
[ExporterHeader(DisplayName = "定价")] |
|||
public decimal Price { set; get; } |
|||
[ExporterHeader(DisplayName = "金额")] |
|||
public decimal Amt { set; get; } |
|||
[ExporterHeader(DisplayName = "差异")] |
|||
public decimal DiffQty { set; get; } |
|||
[ExporterHeader(DisplayName = "差异金额")] |
|||
public decimal DiffAmt { set; get; } |
|||
|
|||
//交货单号 实际发货日期 KENN号 底盘号 底盘格式整理 M100交货状态 物料号 物料描述 客户物料 组件组物料 组件组物料描述 物料组(车型) 结算平台未结数量 定价 金额 大众R3未结数量 差异 差异金额
|
|||
|
|||
|
|||
|
|||
} |
|||
public class UnSettleDiffDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency |
|||
{ |
|||
public UnSettleDiffDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public virtual List<UnSettleDiff> GetDiffReport(int type,string year, string begin, string end, string materialCode, string sapCode) |
|||
{ |
|||
|
|||
|
|||
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" + |
|||
"FROM\n" + |
|||
" (\n" + |
|||
" SELECT\n" + |
|||
" WMSState,\n" + |
|||
" WMSBillNum,\n" + |
|||
" ItemCode,\n" + |
|||
" KENNCode,\n" + |
|||
" ChassisNumber2,\n" + |
|||
" sum( qty ) qty,\n" + |
|||
" ErpMaterialCode,\n" + |
|||
" ChassisNumber \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" + |
|||
" ) 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}"; |
|||
|
|||
|
|||
string _sql = string.Empty; |
|||
if (type == 1 ) |
|||
{ |
|||
_sql = string.Format(sql2, str1); |
|||
|
|||
} |
|||
else |
|||
{ |
|||
_sql = string.Format(sql1, str1); |
|||
|
|||
} |
|||
|
|||
var _query = DbConnection.Query<UnSettleDiff>(_sql); |
|||
return _query.ToList(); |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,75 @@ |
|||
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 UnSettleDiffExportService : ITransientDependency, IExportJob |
|||
{ |
|||
private readonly UnSettleDiffDapperRepository _dapper; |
|||
private readonly OutputService _outputService; |
|||
|
|||
public UnSettleDiffExportService(UnSettleDiffDapperRepository dapper, OutputService outputService) |
|||
{ |
|||
_dapper = dapper; |
|||
_outputService = outputService; |
|||
} |
|||
|
|||
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list) |
|||
{ |
|||
var type = p_list.Where(p => p.Name == "Type").FirstOrDefault().Value; |
|||
var year = p_list.Where(p => p.Name == "Year").FirstOrDefault().Value; |
|||
var materialCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value; |
|||
var sapCode = p_list.Where(p => p.Name == "SapMaterialCode").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 _first = exportName.FirstOrDefault(); |
|||
var _ls = new List<UnSettleDiff>(); |
|||
_ls = _dapper.GetDiffReport(int.Parse(type),year,beginTime,endTime, materialCode,sapCode); |
|||
var _id = Guid.NewGuid(); |
|||
|
|||
|
|||
|
|||
|
|||
List<UnSettleDiff> _lsExport = new List<UnSettleDiff>(); |
|||
//foreach (var itm in _ls)
|
|||
//{
|
|||
// var dto = new FISExportDto()
|
|||
// {
|
|||
// ChassisNumber = itm.ChassisNumber,
|
|||
// ChassisNumber2 = itm.ChassisNumber2,
|
|||
// CP5Time = itm.CP5Time,
|
|||
// ItemCode = itm.ItemCode,
|
|||
// CP7Time = itm.CP7Time,
|
|||
// KENNCode = itm.KENNCode,
|
|||
// OrderBillNum = itm.OrderBillNum,
|
|||
// //Model = itm.Model,
|
|||
// SequenceNumber = itm.SequenceNumber,
|
|||
// ErpMaterialCode = itm.ErpMaterialCode,
|
|||
// SettledQty = itm.SettledQty,
|
|||
// //State = itm.State,
|
|||
// Qty = itm.Qty,
|
|||
// Version = itm.Version,
|
|||
|
|||
// };
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
// _lsExport.Add(dto);
|
|||
//}
|
|||
_outputService.Export<UnSettleDiff>(id, _first, _lsExport); |
|||
return id.ToString(); |
|||
} |
|||
} |
|||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue