Administrator
3 years ago
6 changed files with 536 additions and 213 deletions
@ -0,0 +1,238 @@ |
|||||
|
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 HQFactorySettledDetailDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency |
||||
|
{ |
||||
|
public HQFactorySettledDetailDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) |
||||
|
: base(dbContextProvider) |
||||
|
{ |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 红旗主机厂未结比对红旗系统未对
|
||||
|
/// </summary>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <param name="materialCode"></param>
|
||||
|
/// <param name="begin"></param>
|
||||
|
/// <param name="end"></param>
|
||||
|
/// <param name="materialGroup"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public virtual List<HQFactoryUnSettledDetailDiff> GetHQFactoryDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup) |
||||
|
{ |
||||
|
|
||||
|
List<HQFactoryUnSettledDetailDiff> _list = new List<HQFactoryUnSettledDetailDiff>(); |
||||
|
|
||||
|
string condition = " "; |
||||
|
|
||||
|
//if (!string.IsNullOrEmpty(begin))
|
||||
|
//{
|
||||
|
// condition += string.Format(" and a.LastModificationTime>='{0}' ", begin);
|
||||
|
//}
|
||||
|
//if (!string.IsNullOrEmpty(end))
|
||||
|
//{
|
||||
|
// condition += string.Format(" and a.LastModificationTime<='{0}' ", end);
|
||||
|
//}
|
||||
|
|
||||
|
string str = "SELECT\n" + |
||||
|
" temp3.StorageLocation 收货仓库,\n" + |
||||
|
" temp3.StorageLocationDesc 收货仓库描述,\n" + |
||||
|
" temp3.HQHKanBan 订货看板编号,\n" + |
||||
|
" temp3.AcceptanceNo 结算验收单号,\n" + |
||||
|
" temp3.MaterialCode Sap编码,\n" + |
||||
|
" temp3.CustomerPartCode 客户物料号,\n" + |
||||
|
" temp3.EstimateTypeDesc 物料组,\n" + |
||||
|
" temp3.MaterialDesc 零件中文名称,\n" + |
||||
|
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" + |
||||
|
" temp3.UnHQAmt 金额,\n" + |
||||
|
" temp3.系统未结数量,\n" + |
||||
|
" temp3.UnHQQty 红旗未结数量,\n" + |
||||
|
" ( ISNULL( temp3.系统未结数量, 0 ) - ISNULL( temp3.UnHQQty, 0 ) ) 差异 \n" + |
||||
|
"FROM\n" + |
||||
|
" (\n" + |
||||
|
" SELECT\n" + |
||||
|
" * \n" + |
||||
|
" FROM\n" + |
||||
|
" (\n" + |
||||
|
" SELECT\n" + |
||||
|
" h.StorageLocation,\n" + |
||||
|
" h.StorageLocationDesc,\n" + |
||||
|
" h.HQHKanBan,\n" + |
||||
|
" h.AcceptanceNo,\n" + |
||||
|
" m.MaterialCode,\n" + |
||||
|
" m.CustomerPartCode,\n" + |
||||
|
" m.MaterialDesc,\n" + |
||||
|
" m.EstimateTypeDesc,\n" + |
||||
|
" ISNULL( h.Qty, 0 ) AS UnHQQty,\n" + |
||||
|
" ISNULL( h.Amt, 0 ) AS UnHQAmt \n" + |
||||
|
" FROM\n" + |
||||
|
" Set_UnHQSettleAccount AS h\n" + |
||||
|
" LEFT JOIN Set_material AS m ON h.MaterialCode = m.CustomerPartCode \n" + |
||||
|
" ) AS unhq\n" + |
||||
|
" LEFT JOIN (\n" + |
||||
|
" SELECT\n" + |
||||
|
" a.Kanban AS 订货看板编号,\n" + |
||||
|
" b.MaterialCode AS 订货零件号,\n" + |
||||
|
" c.MaterialCode Sap编码,\n" + |
||||
|
" c.CustomerPartCode 客户物料号,\n" + |
||||
|
" c.MaterialDesc AS 零件中文名称,\n" + |
||||
|
" isnull( a.Qty, 0 ) AS 系统未结数量,\n" + |
||||
|
" b.AcceptanceNo AS 结算验收单号,\n" + |
||||
|
" C.EstimateTypeDesc AS 物料组 \n" + |
||||
|
" FROM\n" + |
||||
|
" Set_HQ_H_Kanban AS a\n" + |
||||
|
" LEFT OUTER JOIN ( SELECT * FROM Set_HQ_H_Platform WHERE HQHKanBan <> 'BJ' ) AS b ON a.Kanban = b.HQHKanBan \n" + |
||||
|
" AND a.MaterialCode = b.MaterialCode\n" + |
||||
|
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + |
||||
|
" WHERE\n" + |
||||
|
" b.HQHKanBan IS NULL \n" + |
||||
|
" AND b.MaterialCode IS NULL \n" + |
||||
|
" ) AS temp1 ON unhq.HQHKanBan = temp1.[订货看板编号] \n" + |
||||
|
" AND unhq.CustomerPartCode= temp1.客户物料号 -- WHERE\n" + |
||||
|
"-- temp1.[订货看板编号] IS NULL \n" + |
||||
|
"-- AND temp1.客户物料号 IS NULL\n" + |
||||
|
" \n" + |
||||
|
" ) temp3\n" + |
||||
|
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp3.MaterialCode = TEMP2.MaterialCode"; |
||||
|
var _sql = string.Format(str, condition); |
||||
|
|
||||
|
var _query = DbConnection.Query<HQFactoryUnSettledDetailDiff>(_sql, null, null, true, 1200, null); |
||||
|
_list = _query.ToList(); |
||||
|
return _list; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 红旗系统未对比对红旗主机厂未结
|
||||
|
/// </summary>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <param name="materialCode"></param>
|
||||
|
/// <param name="begin"></param>
|
||||
|
/// <param name="end"></param>
|
||||
|
/// <param name="materialGroup"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public virtual List<HQFactoryUnSettledDetailDiff> GetSettleToFactoryDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup) |
||||
|
{ |
||||
|
|
||||
|
List<HQFactoryUnSettledDetailDiff> _list = new List<HQFactoryUnSettledDetailDiff>(); |
||||
|
|
||||
|
string condition = " "; |
||||
|
|
||||
|
if (!string.IsNullOrEmpty(begin)) |
||||
|
{ |
||||
|
condition += string.Format(" and a.LastModificationTime>='{0}' ", begin); |
||||
|
} |
||||
|
if (!string.IsNullOrEmpty(end)) |
||||
|
{ |
||||
|
condition += string.Format(" and a.LastModificationTime<='{0}' ", end); |
||||
|
} |
||||
|
|
||||
|
string str = "SELECT\n" + |
||||
|
" temp1.交货单号,\n" + |
||||
|
" temp1.交货日期,\n" + |
||||
|
" temp1.收货仓库,\n" + |
||||
|
" temp1.收货仓库描述,\n" + |
||||
|
" temp1.订货看板编号,\n" + |
||||
|
" temp1.结算验收单号,\n" + |
||||
|
" temp1.Sap编码,\n" + |
||||
|
" temp1.[客户物料号],\n" + |
||||
|
" temp1.物料组,\n" + |
||||
|
" temp1.零件中文名称,\n" + |
||||
|
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" + |
||||
|
" ISNULL( temp1.系统未结数量, 0 ) 系统未结数量,\n" + |
||||
|
" isnull( temp3.Qty, 0 ) AS 红旗未结数量,\n" + |
||||
|
" ( ISNULL( temp1.系统未结数量, 0 ) - ISNULL( temp3.Qty, 0 ) ) 差异 \n" + |
||||
|
"FROM\n" + |
||||
|
" (\n" + |
||||
|
" SELECT\n" + |
||||
|
" a.WmsBillNum [交货单号],\n" + |
||||
|
" CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) 交货日期,\n" + |
||||
|
" b.StorageLocation AS 收货仓库,\n" + |
||||
|
" b.StorageLocationDesc AS 收货仓库描述,\n" + |
||||
|
" a.Kanban AS 订货看板编号,\n" + |
||||
|
" c.MaterialCode Sap编码,\n" + |
||||
|
" c.CustomerPartCode 客户物料号,\n" + |
||||
|
" c.MaterialDesc AS 零件中文名称,\n" + |
||||
|
" isnull( a.Qty, 0 ) AS 系统未结数量,\n" + |
||||
|
" b.AcceptanceNo AS 结算验收单号,\n" + |
||||
|
" C.EstimateTypeDesc AS 物料组 \n" + |
||||
|
" FROM\n" + |
||||
|
" Set_HQ_H_Kanban AS a\n" + |
||||
|
" LEFT OUTER JOIN ( SELECT * FROM Set_HQ_H_Platform WHERE HQHKanBan <> 'BJ' ) AS b ON a.Kanban = b.HQHKanBan \n" + |
||||
|
" AND a.MaterialCode = b.MaterialCode\n" + |
||||
|
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + |
||||
|
" WHERE\n" + |
||||
|
" b.HQHKanBan IS NULL \n" + |
||||
|
" AND b.MaterialCode IS NULL {0}\n" + |
||||
|
" ) AS temp1\n" + |
||||
|
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.Sap编码 = TEMP2.MaterialCode\n" + |
||||
|
" LEFT JOIN ( SELECT Qty, HQHKanBan, MaterialCode FROM Set_UnHQSettleAccount ) temp3 ON temp1.[结算验收单号] = temp3.HQHKanBan \n" + |
||||
|
" AND temp1.[客户物料号] = temp3.MaterialCode"; |
||||
|
var _sql = string.Format(str, condition); |
||||
|
|
||||
|
var _query = DbConnection.Query<HQFactoryUnSettledDetailDiff>(_sql, null, null, true, 1200, null); |
||||
|
_list = _query.ToList(); |
||||
|
return _list; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
public class HQFactoryUnSettledDetailDiff |
||||
|
{ |
||||
|
[ExporterHeader(DisplayName = "收货仓库")] |
||||
|
public string 收货仓库 { set; get; } |
||||
|
[ExporterHeader(DisplayName = "收货仓库描述")] |
||||
|
public string 收货仓库描述 { set; get; } |
||||
|
[ExporterHeader(DisplayName = "订货看板编号")] |
||||
|
public string 订货看板编号 { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "结算验收单号")] |
||||
|
public string 结算验收单号 { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "Sap编码")] |
||||
|
public string Sap编码 { set; get; } |
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "客户物料号")] |
||||
|
public string 客户物料号 { set; get; } |
||||
|
[ExporterHeader(DisplayName = "零件中文名称")] |
||||
|
public string 零件中文名称 { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "物料组")] |
||||
|
public string 物料组 { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "验收单日期",IsIgnore =true)] |
||||
|
public string 验收单日期 { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "发货定价")] |
||||
|
public decimal 发货定价 { set; get; } |
||||
|
[ExporterHeader(DisplayName = "金额")] |
||||
|
public decimal 金额 { set; get; } |
||||
|
[ExporterHeader(DisplayName = "系统未结数量")] |
||||
|
public decimal 系统未结数量 { set; get; } |
||||
|
[ExporterHeader(DisplayName = "红旗未结数量")] |
||||
|
public decimal 红旗未结数量 { set; get; } |
||||
|
[ExporterHeader(DisplayName = "差异")] |
||||
|
public decimal 差异 { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "工厂", IsIgnore = true)] |
||||
|
public string 工厂 { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,139 @@ |
|||||
|
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 |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 红旗工厂未结明细
|
||||
|
/// </summary>
|
||||
|
public class HQFactoryUnSettledDetailDiffExportService : ITransientDependency, IExportJob |
||||
|
{ |
||||
|
|
||||
|
private readonly HQFactorySettledDetailDapperRepository _dapperRepository; |
||||
|
private readonly ErpPartDapperRepository _erpdapperRepository; |
||||
|
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
||||
|
|
||||
|
private readonly OutputService _outputService; |
||||
|
private readonly InputService _inputService; |
||||
|
|
||||
|
public HQFactoryUnSettledDetailDiffExportService( |
||||
|
|
||||
|
ErpPartDapperRepository erpdapperRepository, |
||||
|
HQFactorySettledDetailDapperRepository dapperRepository, |
||||
|
|
||||
|
OutputService outputService, |
||||
|
InputService inputService |
||||
|
, IBlobContainer<MyFileContainer> fileContainer |
||||
|
) |
||||
|
{ |
||||
|
_inputService = inputService; |
||||
|
_outputService = outputService; |
||||
|
_erpdapperRepository = erpdapperRepository; |
||||
|
_fileContainer = fileContainer; |
||||
|
_dapperRepository = dapperRepository; |
||||
|
} |
||||
|
|
||||
|
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 kanban = p_list.Where(p => p.Name == "Kanban").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 materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value; |
||||
|
var acceptNo = p_list.Where(p => p.Name == "AcceptNo").FirstOrDefault().Value; |
||||
|
var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value; |
||||
|
var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value; |
||||
|
|
||||
|
|
||||
|
|
||||
|
//红旗系统未对比对红旗主机厂未结
|
||||
|
var _ls = _dapperRepository.GetSettleToFactoryDetailDiffReportList(version, materialCode, begin, end, materialGroup); |
||||
|
|
||||
|
//红旗主机厂未结比对红旗系统未对
|
||||
|
var _ls_reversal = _dapperRepository.GetHQFactoryDetailDiffReportList(version, materialCode, begin, end, materialGroup); |
||||
|
|
||||
|
|
||||
|
//if (!string.IsNullOrEmpty(kanban))
|
||||
|
//{
|
||||
|
// var _groupList = kanban.Split(new char[] { '\n' }).Distinct().ToList();
|
||||
|
// if (_groupList.Count() > 0)
|
||||
|
// {
|
||||
|
// _ls = _ls.Where(p => _groupList.Contains(p.订货看板编号)).ToList();
|
||||
|
// }
|
||||
|
//}
|
||||
|
|
||||
|
//if (!string.IsNullOrEmpty(warehouseDesc))
|
||||
|
//{
|
||||
|
// var _groupList = warehouseDesc.Split(new char[] { '\n' }).Distinct().ToList();
|
||||
|
// if (_groupList.Count() > 0)
|
||||
|
// {
|
||||
|
// _ls = _ls.Where(p => _groupList.Contains(p.收货仓库描述)).ToList();
|
||||
|
// }
|
||||
|
//}
|
||||
|
|
||||
|
//if (!string.IsNullOrEmpty(acceptNo))
|
||||
|
//{
|
||||
|
// var _groupList = acceptNo.Split(new char[] { '\n' }).Distinct().ToList();
|
||||
|
// if (_groupList.Count() > 0)
|
||||
|
// {
|
||||
|
// _ls = _ls.Where(p => _groupList.Contains(p.结算验收单号)).ToList();
|
||||
|
// }
|
||||
|
//}
|
||||
|
if (!string.IsNullOrEmpty(materialGroup)) |
||||
|
{ |
||||
|
var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList(); |
||||
|
if (_groupList.Count() > 0) |
||||
|
{ |
||||
|
_ls = _ls.Where(p => _groupList.Contains(p.物料组)).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.客户物料号)).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.Sap编码)).ToList(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
ExcelExporter _exporter = new ExcelExporter();//导出Excel
|
||||
|
var result = _exporter.Append(_ls.ToList(), "红旗系统未对比对红旗主机厂未结") |
||||
|
.SeparateBySheet() |
||||
|
.Append(_ls_reversal.ToList(), "红旗主机厂未结比对红旗系统未对") |
||||
|
.ExportAppendDataAsByteArray(); |
||||
|
result.ShouldNotBeNull(); |
||||
|
_fileContainer.SaveAsync(_filename, result.Result, true); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
return id.ToString(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
Loading…
Reference in new issue