Browse Source

红旗工厂报表提交

FoShanPG
44673626 3 years ago
parent
commit
ac1d288d19
  1. 120
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs
  2. 34
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHSettledDetailDiffExportService.cs

120
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs

@ -20,6 +20,16 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
: base(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<HQHSettledDetailDiff> GetInvoiceSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup) public virtual List<HQHSettledDetailDiff> GetInvoiceSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup)
{ {
@ -62,15 +72,17 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
//// condition += string.Format(" B.chassisNumber='{0}' ", materialGroup); //// condition += string.Format(" B.chassisNumber='{0}' ", materialGroup);
////} ////}
string str = "SELECT\n" + string str = "SELECT\n" +
" temp1.交货日期,\n" + " temp1.交货时间,\n" +
" isnull( temp1.手工或自动, '' ) 手工或自动,\n" + " isnull( temp1.手工或自动, '' ) 手工或自动,\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" + " isnull( temp1.交货单号, '' ) 交货单号,\n" +
" temp1.[工厂],\n" +
" temp1.收货仓库,\n" + " temp1.收货仓库,\n" +
" temp1.收货仓库描述,\n" + " temp1.收货仓库描述,\n" +
" temp1.订货看板编号,\n" + " temp1.订货看板编号,\n" +
" temp1.订货零件号,\n" + " temp1.订货零件号,\n" +
" temp1.验收单日期,\n" +
" temp1.Sap编码,\n" + " temp1.Sap编码,\n" +
" temp1.发货零件号,\n" + " temp1.看板编号,\n" +
" temp1.物料组,\n" + " temp1.物料组,\n" +
" temp1.零件中文名称,\n" + " temp1.零件中文名称,\n" +
" temp1.发货数量,\n" + " temp1.发货数量,\n" +
@ -88,14 +100,13 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" (\n" + " (\n" +
" SELECT\n" + " SELECT\n" +
" b.WmsBillNum AS 交货单号,\n" + " b.WmsBillNum AS 交货单号,\n" +
" b.LastModificationTime AS 交货日期,\n" + " b.LastModificationTime AS 交货时间,\n" +
" b.IsAuto AS 手工或自动,\n" + " b.IsAuto AS 手工或自动,\n" +
" a.StorageLocation AS 收货仓库,\n" + " a.StorageLocation AS 收货仓库,\n" +
" a.StorageLocationDesc AS 收货仓库描述,\n" + " a.StorageLocationDesc AS 收货仓库描述,\n" +
" a.HQHKanBan AS 订货看板编号,\n" + " a.HQHKanBan AS 订货看板编号,\n" +
" a.MaterialCode AS 订货零件号,\n" + " a.MaterialCode AS 订货零件号,\n" +
" c.MaterialCode Sap编码,\n" + " c.MaterialCode Sap编码,\n" +
" '' AS 发货零件号,\n" +
" c.MaterialDesc AS 零件中文名称,\n" + " c.MaterialDesc AS 零件中文名称,\n" +
" isnull( b.Qty, 0 ) AS 发货数量,\n" + " isnull( b.Qty, 0 ) AS 发货数量,\n" +
" isnull( b.State, 0 ) AS 发货状态,\n" + " isnull( b.State, 0 ) AS 发货状态,\n" +
@ -103,7 +114,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" isnull( a.Qty, 0 ) AS 结算数量,\n" + " isnull( a.Qty, 0 ) AS 结算数量,\n" +
" isnull( a.Price, 0 ) AS 结算单价,\n" + " isnull( a.Price, 0 ) AS 结算单价,\n" +
" isnull( a.Amt, 0 ) AS 结算金额 ,\n" + " isnull( a.Amt, 0 ) AS 结算金额 ,\n" +
" C.EstimateTypeDesc AS 物料组 \n" + " C.EstimateTypeDesc AS 物料组,\n" +
" a.Factory AS 工厂,\n" +
" a.KanbanNumber AS 看板编号,\n" +
" a.AcceptanceDate AS 验收单日期 \n" +
" FROM\n" + " FROM\n" +
" Set_HQ_H_Platform AS a\n" + " Set_HQ_H_Platform AS a\n" +
" LEFT OUTER JOIN Set_HQ_H_Kanban AS b ON a.HQHKanBan = b.Kanban \n" + " LEFT OUTER JOIN Set_HQ_H_Kanban AS b ON a.HQHKanBan = b.Kanban \n" +
@ -122,6 +136,91 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
} }
/// <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<HQHSettledDetailDiff> GetReverseSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup)
{
List<HQHSettledDetailDiff> _list = new List<HQHSettledDetailDiff>();
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" +
" isnull( temp1.手工或自动, '' ) 手工或自动,\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" +
" temp1.收货仓库,\n" +
" temp1.收货仓库描述,\n" +
" temp1.订货看板编号,\n" +
" temp1.订货零件号,\n" +
" temp1.Sap编码,\n" +
" temp1.发货零件号,\n" +
" temp1.物料组,\n" +
" temp1.零件中文名称,\n" +
" temp1.发货数量,\n" +
" temp1.发货状态,\n" +
" temp1.结算验收单号,\n" +
" temp1.结算数量,\n" +
" temp1.结算单价,\n" +
" temp1.结算金额,\n" +
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
" isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
" 0 AS 数量差异,\n" +
" temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
" ( temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.WmsBillNum AS 交货单号,\n" +
" a.LastModificationTime AS 交货时间,\n" +
" a.IsAuto AS 手工或自动,\n" +
" b.StorageLocation AS 收货仓库,\n" +
" b.StorageLocationDesc AS 收货仓库描述,\n" +
" b.HQHKanBan AS 订货看板编号,\n" +
" b.MaterialCode AS 订货零件号,\n" +
" c.MaterialCode Sap编码,\n" +
" '' AS 发货零件号,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" isnull( a.Qty, 0 ) AS 发货数量,\n" +
" isnull( a.State, 0 ) AS 发货状态,\n" +
" b.AcceptanceNo AS 结算验收单号,\n" +
" isnull( b.Qty, 0 ) AS 结算数量,\n" +
" isnull( b.Price, 0 ) AS 结算单价,\n" +
" isnull( b.Amt, 0 ) 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' AND Version = '{0}' ) 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\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";
var _sql = string.Format(str, version, condition);
var _query = DbConnection.Query<HQHSettledDetailDiff>(_sql, null, null, true, 1200, null);
_list = _query.ToList();
return _list;
}
public virtual List<HQHSettleQtyDiff> GetDiffQtyList(string version) public virtual List<HQHSettleQtyDiff> GetDiffQtyList(string version)
@ -224,8 +323,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
} }
} }
public class HQHSharePartSettledDetailDiff public class HQHSharePartSettledDetailDiff
@ -302,6 +399,15 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "差异总金额")] [ExporterHeader(DisplayName = "差异总金额")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "工厂")]
public string { set; get; }
[ExporterHeader(DisplayName = "看板编号")]
public string { set; get; }
[ExporterHeader(DisplayName = "验收单日期",Format ="yyyy-MM-dd")]
public DateTime { set; get; }
} }
public class HQHSettleQtyDiff public class HQHSettleQtyDiff
{ {

34
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHSettledDetailDiffExportService.cs

@ -1,11 +1,15 @@
using System; using Magicodes.ExporterAndImporter.Excel;
using Shouldly;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TaskJob.EventArgs; using TaskJob.EventArgs;
using TaskJob.Interfaces; using TaskJob.Interfaces;
using Volo.Abp.BlobStoring;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
namespace SettleAccount.Job.Services.Report namespace SettleAccount.Job.Services.Report
@ -18,6 +22,7 @@ namespace SettleAccount.Job.Services.Report
private readonly HQHSettledDetailDapperRepository _dapperRepository; private readonly HQHSettledDetailDapperRepository _dapperRepository;
private readonly ErpPartDapperRepository _erpdapperRepository; private readonly ErpPartDapperRepository _erpdapperRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
private readonly OutputService _outputService; private readonly OutputService _outputService;
private readonly InputService _inputService; private readonly InputService _inputService;
@ -26,14 +31,16 @@ namespace SettleAccount.Job.Services.Report
ErpPartDapperRepository erpdapperRepository, ErpPartDapperRepository erpdapperRepository,
HQHSettledDetailDapperRepository dapperRepository, HQHSettledDetailDapperRepository dapperRepository,
OutputService outputService, OutputService outputService,
InputService inputService InputService inputService
, IBlobContainer<MyFileContainer> fileContainer
) )
{ {
_inputService = inputService; _inputService = inputService;
_outputService = outputService; _outputService = outputService;
_erpdapperRepository = erpdapperRepository; _erpdapperRepository = erpdapperRepository;
_fileContainer = fileContainer;
_dapperRepository = dapperRepository; _dapperRepository = dapperRepository;
} }
@ -49,7 +56,13 @@ namespace SettleAccount.Job.Services.Report
var acceptNo = p_list.Where(p => p.Name == "AcceptNo").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 sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value;
var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value; var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value;
var _ls = _dapperRepository.GetInvoiceSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup); var _ls = _dapperRepository.GetInvoiceSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup);
//反向对比,有发货无结算
var _reversels = _dapperRepository.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup);
var _lst = _dapperRepository.GetDiffQtyList(version); var _lst = _dapperRepository.GetDiffQtyList(version);
foreach (var itm in _lst) foreach (var itm in _lst)
{ {
@ -109,7 +122,22 @@ namespace SettleAccount.Job.Services.Report
_ls = _ls.Where(p => _groupList.Contains(p.Sap编码)).ToList(); _ls = _ls.Where(p => _groupList.Contains(p.Sap编码)).ToList();
} }
} }
_outputService.Export<HQHSettledDetailDiff>(id, _filename, _ls);
//_outputService.Export<HQHSettledDetailDiff>(id, _filename, _ls);
ExcelExporter _exporter = new ExcelExporter();//导出Excel
var result = _exporter.Append(_ls.ToList(), "红旗工厂核对明细")
.SeparateBySheet()
.Append(_reversels.ToList(), "有发货无结算对比")
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(_filename, result.Result, true);
return id.ToString(); return id.ToString();
} }

Loading…
Cancel
Save