From db445b1e26587d676bcf4cb77f509a9391d6fb30 Mon Sep 17 00:00:00 2001
From: 44673626 <44673626@qq.com>
Date: Tue, 8 Mar 2022 16:45:03 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E6=97=97=E6=9C=AA=E7=BB=93=E6=A0=B8?=
=?UTF-8?q?=E5=AF=B9=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../UnHQSettleAccounts/UnHQSettleExportDto.cs | 24 +-
.../ReportServices/ReportMakeService.cs | 31 ++
...ttleAccountApplicationAutoMapperProfile.cs | 11 +-
.../HQFactorySettledDetailDapperRepository.cs | 238 ++++++++++++++
.../HQHSettledDetailDapperRepository.cs | 306 +++++++-----------
...FactoryUnSettledDetailDiffExportService.cs | 139 ++++++++
6 files changed, 536 insertions(+), 213 deletions(-)
create mode 100644 src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs
create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQFactoryUnSettledDetailDiffExportService.cs
diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/UnHQSettleAccounts/UnHQSettleExportDto.cs b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/UnHQSettleAccounts/UnHQSettleExportDto.cs
index 18ef6b80..3d93ae71 100644
--- a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/UnHQSettleAccounts/UnHQSettleExportDto.cs
+++ b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/UnHQSettleAccounts/UnHQSettleExportDto.cs
@@ -17,8 +17,8 @@ namespace Win.Sfs.SettleAccount.Entities.UnHQSettleAccounts
///
///外部看板编号
///
- [ExporterHeader(DisplayName = "外部看板编号")]
- public string ExternalKanbanNumber { get; set; }
+ //[ExporterHeader(DisplayName = "外部看板编号")]
+ //public string ExternalKanbanNumber { get; set; }
///
///看板编号
///
@@ -30,16 +30,16 @@ namespace Win.Sfs.SettleAccount.Entities.UnHQSettleAccounts
[ExporterHeader(DisplayName = "物料凭证号")]
public string MaterialVoucherNo { get; set; }
- ///
- ///会计年度
- ///
- [ExporterHeader(DisplayName = "会计年度")]
- public string Year { get; set; }
- ///
- /// 期间
- ///
- [ExporterHeader(DisplayName = "期间")]
- public string Period { set; get; }
+ /////
+ /////会计年度
+ /////
+ //[ExporterHeader(DisplayName = "会计年度")]
+ //public string Year { get; set; }
+ /////
+ ///// 期间
+ /////
+ //[ExporterHeader(DisplayName = "期间")]
+ //public string Period { set; get; }
///
/// 版本号
///
diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs
index 45bdb3e7..3df4b177 100644
--- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs
+++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs
@@ -29,6 +29,7 @@ using Win.Sfs.SettleAccount.Entities.Wms;
using Win.Sfs.SettleAccount.Entities.WMS;
using Win.Sfs.SettleAccount.FISes;
using Win.Sfs.SettleAccount.Reports.ReportRequestDto;
+using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
namespace Win.Sfs.SettleAccount.Reports.ReportServices
{
@@ -720,6 +721,36 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
return _taskid;
}
+ ///
+ ///红旗未结核对
+ ///
+ /// 上传的文件(前端已经限制只能上传一个附件)
+ ///
+ [HttpPost]
+ [Route("HQFactoryUnSettledDetailDiffExportService")]
+ [DisableRequestSizeLimit]
+ public async Task HQFactoryUnSettledDetailDiffExportService(
+ HQKanbanRequestDto input
+ )
+ {
+
+ List customConditionList = new List();
+ customConditionList.Add(new CustomCondition() { Name = "Version", Value = input.Version });
+ customConditionList.Add(new CustomCondition() { Name = "MaterialCode", Value = input.MaterialCode });
+ customConditionList.Add(new CustomCondition() { Name = "BeginTime", Value = input.Begin });
+ customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = input.End });
+ customConditionList.Add(new CustomCondition() { Name = "MaterialCode", Value = input.MaterialCode });
+ customConditionList.Add(new CustomCondition() { Name = "AcceptNo", Value = input.AcceptNo });
+ customConditionList.Add(new CustomCondition() { Name = "WarehouseDesc", Value = input.WarehouseDesc });
+ customConditionList.Add(new CustomCondition() { Name = "Kanban", Value = input.Kanban });
+ customConditionList.Add(new CustomCondition() { Name = "MaterialGroup", Value = string.IsNullOrEmpty(input.MaterialGroup) ? string.Empty : input.MaterialGroup });
+ customConditionList.Add(new CustomCondition() { Name = "SapCode", Value = string.IsNullOrEmpty(input.SapCode) ? string.Empty : input.SapCode });
+ var _taskid = await _service.ExportEnqueueAsync("红旗未结核对", ExportExtentsion.Excel, input.Version, string.IsNullOrEmpty(input.MaterialGroup) ? string.Empty : input.MaterialGroup, CurrentUser, typeof(HQFactorySettledDetailDapperRepository), customConditionList, (rs) =>
+ {
+ });
+ return _taskid;
+ }
+
///
/// 红旗工厂备件明细
///
diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
index 00983409..f9724738 100644
--- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
+++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
@@ -427,7 +427,6 @@ namespace Win.Sfs.SettleAccount
/// 红旗明细未结导入
///
private void CreateMapUnHQSettleAccount()
-
{
CreateMap().ReverseMap();
CreateMap().ReverseMap();
@@ -442,11 +441,11 @@ namespace Win.Sfs.SettleAccount
private void CreateMapUnHQSettleAccountVersion()
{
- CreateMap().ReverseMap();
- CreateMap();
- CreateMap();
- CreateMap();
- CreateMap();
+ CreateMap().ReverseMap();
+ CreateMap();
+ CreateMap();
+ CreateMap();
+ CreateMap();
}
///
diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs
new file mode 100644
index 00000000..29f7f275
--- /dev/null
+++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs
@@ -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, ITransientDependency
+ {
+ public HQFactorySettledDetailDapperRepository(IDbContextProvider dbContextProvider)
+ : base(dbContextProvider)
+ {
+ }
+ ///
+ /// 红旗主机厂未结比对红旗系统未对
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public virtual List GetHQFactoryDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup)
+ {
+
+ List _list = new List();
+
+ 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(_sql, null, null, true, 1200, null);
+ _list = _query.ToList();
+ return _list;
+
+ }
+
+
+ ///
+ /// 红旗系统未对比对红旗主机厂未结
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public virtual List GetSettleToFactoryDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup)
+ {
+
+ List _list = new List();
+
+ 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(_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; }
+
+
+
+ }
+
+
+
+ }
+}
diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs
index fe54d01a..cb342d91 100644
--- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs
+++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs
@@ -70,6 +70,99 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// condition += string.Format(" and b.LastModificationTime<='{0}' ", end);
//}
+ //string str = "SELECT\n" +
+ // " isnull( temp1.交货单号, '' ) 交货单号,\n" +
+ // " temp1.交货时间,\n" +
+ // " isnull( temp1.手工或自动, '' ) 手工或自动,\n" +
+ // " temp1.[工厂],\n" +
+ // " 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" +
+ // " temp3.Price AS 结算单价,\n" +
+ // " ( temp1.[结算数量] * ISNULL( temp3.Price, 0 ) ) AS 结算金额,\n" +
+ // " isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
+ // " isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
+ // " ( isnull( temp1.发货数量, 0 ) - isnull( temp1.[结算数量], 0 ) ) AS 数量差异,\n" +
+ // " ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
+ // " ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" +
+ // "FROM\n" +
+ // " (\n" +
+ // " SELECT\n" +
+ // " '' AS 交货单号,\n" +
+ // " NULL AS 交货时间,\n" +
+ // " '' AS 手工或自动,\n" +
+ // " a.StorageLocation AS 收货仓库,\n" +
+ // " a.StorageLocationDesc AS 收货仓库描述,\n" +
+ // " a.HQHKanBan AS 订货看板编号,\n" +
+ // " a.MaterialCode AS 订货零件号,\n" +
+ // " c.MaterialCode Sap编码,\n" +
+ // " a.MaterialCode 结算物料代码,\n" +
+ // " c.MaterialDesc AS 零件中文名称,\n" +
+ // " isnull( b.Qty, 0 ) AS 发货数量,\n" +
+ // " 2 AS 发货状态,\n" +
+ // " a.[AcceptanceNo] AS 结算验收单号,\n" +
+ // " isnull( a.Qty, 0 ) AS 结算数量,\n" +
+ // " C.EstimateTypeDesc AS 物料组,\n" +
+ // " a.Factory AS 工厂,\n" +
+ // " '' AS 看板编号,\n" +
+ // " '' AS 验收单日期 \n" +
+ // " FROM\n" +
+ // " (\n" +
+ // " SELECT SUM\n" +
+ // " ( Qty ) AS Qty,\n" +
+ // " HQHKanBan,\n" +
+ // " MaterialCode,\n" +
+ // " Version,\n" +
+ // " StorageLocation,\n" +
+ // " StorageLocationDesc,\n" +
+ // " Factory,AcceptanceNo \n" +
+ // " FROM\n" +
+ // " Set_HQ_H_Platform \n" +
+ // " GROUP BY\n" +
+ // " HQHKanBan,\n" +
+ // " MaterialCode,\n" +
+ // " Version,\n" +
+ // " StorageLocation,\n" +
+ // " StorageLocationDesc,\n" +
+ // " Factory,AcceptanceNo \n" +
+ // " ) AS a\n" +
+ // " INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n" +
+ // " AND a.MaterialCode = b.MaterialCode\n" +
+ // " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
+ // " WHERE\n" +
+ // " ( a.HQHKanBan <> 'BJ' AND a.HQHKanBan IS NOT NULL ) \n" +
+ // " AND a.Version= '{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 (\n" +
+ // " SELECT\n" +
+ // " ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n" +
+ // " HQHKanBan,\n" +
+ // " MaterialCode,\n" +
+ // " Version \n" +
+ // " FROM\n" +
+ // " Set_HQ_H_Platform \n" +
+ // " WHERE\n" +
+ // " HQHKanBan <> 'BJ' \n" +
+ // " AND Version = '{0}' \n" +
+ // " GROUP BY\n" +
+ // " HQHKanBan,\n" +
+ // " MaterialCode,\n" +
+ // " Version \n" +
+ // " ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
+ // " AND temp1.订货看板编号 = TEMP3.HQHKanBan";
+
+
string str = "SELECT\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" +
" temp1.交货时间,\n" +
@@ -92,9 +185,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ( temp1.[结算数量] * ISNULL( temp3.Price, 0 ) ) AS 结算金额,\n" +
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
" isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
- " ( isnull( temp1.发货数量, 0 ) - isnull( temp1.[结算数量], 0 ) ) AS 数量差异,\n" +
+ " ( isnull( temp1.发货数量, 0 ) - isnull( temp1.[结算数量], 0 ) - ISNULL( temp4.Qty, 0 ) ) AS 数量差异,\n" +
" ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
- " ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" +
+ " ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 ,\n" +
+ " temp4.Qty 退货数量 \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
@@ -125,7 +219,8 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Version,\n" +
" StorageLocation,\n" +
" StorageLocationDesc,\n" +
- " Factory,AcceptanceNo \n" +
+ " Factory,\n" +
+ " AcceptanceNo \n" +
" FROM\n" +
" Set_HQ_H_Platform \n" +
" GROUP BY\n" +
@@ -134,14 +229,15 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" Version,\n" +
" StorageLocation,\n" +
" StorageLocationDesc,\n" +
- " Factory,AcceptanceNo \n" +
+ " Factory,\n" +
+ " AcceptanceNo \n" +
" ) AS a\n" +
" INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n" +
" AND a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" +
- " ( a.HQHKanBan <> 'BJ' AND a.HQHKanBan IS NOT NULL ) \n" +
- " AND a.Version= '{0}' \n" +
+ " ( a.Version= '{0}' AND a.HQHKanBan IS NOT NULL ) \n" +
+ " AND a.HQHKanBan <> 'BJ' \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 (\n" +
@@ -153,202 +249,19 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" +
" Set_HQ_H_Platform \n" +
" WHERE\n" +
- " HQHKanBan <> 'BJ' \n" +
- " AND Version = '{0}' \n" +
+ " Version = '{0}' \n" +
+ " AND HQHKanBan <> 'BJ' \n" +
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" Version \n" +
" ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
- " AND temp1.订货看板编号 = TEMP3.HQHKanBan";
+ " AND temp1.订货看板编号 = TEMP3.HQHKanBan\n" +
+ " LEFT JOIN set_backQty temp4 ON temp1.订货看板编号 = temp4.Code \n" +
+ " AND temp1.Sap编码= temp4.MaterialCode";
+
- //string str = "SELECT\n" +
- // " aaaa.* \n" +
- // "FROM\n" +
- // " (\n" +
- // " SELECT\n" +
- // " isnull( temp1.交货单号, '' ) 交货单号,\n" +
- // " temp1.交货时间,\n" +
- // " isnull( temp1.手工或自动, '' ) 手工或自动,\n" +
- // " temp1.[工厂],\n" +
- // " 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" +
- // " temp3.Price AS 结算单价,\n" +
- // " ( temp1.[结算数量] * ISNULL( temp3.Price, 0 ) ) AS 结算金额,\n" +
- // " isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
- // " isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
- // " ( isnull( temp1.发货数量, 0 ) - isnull( temp1.[结算数量], 0 ) ) AS 数量差异,\n" +
- // " ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
- // " ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" +
- // " FROM\n" +
- // " (\n" +
- // " SELECT\n" +
- // " '' AS 交货单号,\n" +
- // " NULL AS 交货时间,\n" +
- // " '' AS 手工或自动,\n" +
- // " a.StorageLocation AS 收货仓库,\n" +
- // " a.StorageLocationDesc AS 收货仓库描述,\n" +
- // " a.HQHKanBan AS 订货看板编号,\n" +
- // " a.MaterialCode AS 订货零件号,\n" +
- // " c.MaterialCode Sap编码,\n" +
- // " a.MaterialCode 结算物料代码,\n" +
- // " c.MaterialDesc AS 零件中文名称,\n" +
- // " isnull( b.Qty, 0 ) AS 发货数量,\n" +
- // " 2 AS 发货状态,\n" +
- // " '' AS 结算验收单号,\n" +
- // " isnull( a.Qty, 0 ) AS 结算数量,\n" +
- // " C.EstimateTypeDesc AS 物料组,\n" +
- // " a.Factory AS 工厂,\n" +
- // " '' AS 看板编号,\n" +
- // " '' AS 验收单日期 \n" +
- // " FROM\n" +
- // " (\n" +
- // " SELECT SUM\n" +
- // " ( Qty ) AS Qty,\n" +
- // " HQHKanBan,\n" +
- // " MaterialCode,\n" +
- // " Version,\n" +
- // " StorageLocation,\n" +
- // " StorageLocationDesc,\n" +
- // " Factory \n" +
- // " FROM\n" +
- // " Set_HQ_H_Platform \n" +
- // " GROUP BY\n" +
- // " HQHKanBan,\n" +
- // " MaterialCode,\n" +
- // " Version,\n" +
- // " StorageLocation,\n" +
- // " StorageLocationDesc,\n" +
- // " Factory \n" +
- // " ) AS a\n" +
- // " INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n" +
- // " AND a.MaterialCode = b.MaterialCode\n" +
- // " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
- // " WHERE\n" +
- // " ( a.HQHKanBan <> 'BJ' AND a.HQHKanBan IS NOT NULL ) \n" +
- // " AND a.Version= '{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 (\n" +
- // " SELECT\n" +
- // " ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n" +
- // " HQHKanBan,\n" +
- // " MaterialCode,\n" +
- // " Version \n" +
- // " FROM\n" +
- // " Set_HQ_H_Platform \n" +
- // " WHERE\n" +
- // " HQHKanBan <> 'BJ' \n" +
- // " AND Version = '{0}' \n" +
- // " GROUP BY\n" +
- // " HQHKanBan,\n" +
- // " MaterialCode,\n" +
- // " Version \n" +
- // " ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
- // " AND temp1.订货看板编号 = TEMP3.HQHKanBan \n" +
- // " ) aaaa UNION ALL\n" +
- // "SELECT\n" +
- // " ccc.* \n" +
- // "FROM\n" +
- // " (\n" +
- // " SELECT\n" +
- // " isnull( temp1.交货单号, '' ) 交货单号,\n" +
- // " temp1.交货时间,\n" +
- // " isnull( temp1.手工或自动, '' ) 手工或自动,\n" +
- // " temp1.[工厂],\n" +
- // " 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" +
- // " temp3.Price AS 结算单价,\n" +
- // " ( temp1.[结算数量] * ISNULL( temp3.Price, 0 ) ) AS 结算金额,\n" +
- // " isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
- // " isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
- // " ( isnull( temp1.发货数量, 0 ) - isnull( temp1.[结算数量], 0 ) ) AS 数量差异,\n" +
- // " ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
- // " ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" +
- // " FROM\n" +
- // " (\n" +
- // " SELECT\n" +
- // " '' AS 交货单号,\n" +
- // " NULL AS 交货时间,\n" +
- // " '' AS 手工或自动,\n" +
- // " a.StorageLocation AS 收货仓库,\n" +
- // " a.StorageLocationDesc AS 收货仓库描述,\n" +
- // " '' AS 订货看板编号,\n" +
- // " a.MaterialCode AS 订货零件号,\n" +
- // " c.MaterialCode Sap编码,\n" +
- // " a.MaterialCode 结算物料代码,\n" +
- // " c.MaterialDesc AS 零件中文名称,\n" +
- // " 0 AS 发货数量,\n" +
- // " 2 AS 发货状态,\n" +
- // " '' AS 结算验收单号,\n" +
- // " isnull( a.Qty, 0 ) AS 结算数量,\n" +
- // " C.EstimateTypeDesc AS 物料组,\n" +
- // " a.Factory AS 工厂,\n" +
- // " '' AS 看板编号,\n" +
- // " '' AS 验收单日期 \n" +
- // " FROM\n" +
- // " (\n" +
- // " SELECT SUM\n" +
- // " ( Qty ) AS Qty,\n" +
- // " MaterialCode,\n" +
- // " Version,\n" +
- // " StorageLocation,\n" +
- // " StorageLocationDesc,\n" +
- // " Factory \n" +
- // " FROM\n" +
- // " Set_HQ_H_Platform \n" +
- // " WHERE\n" +
- // " HQHKanBan IS NULL \n" +
- // " GROUP BY\n" +
- // " MaterialCode,\n" +
- // " Version,\n" +
- // " StorageLocation,\n" +
- // " StorageLocationDesc,\n" +
- // " Factory \n" +
- // " ) AS a\n" +
- // " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
- // " WHERE\n" +
- // " a.Version= '{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 (\n" +
- // " SELECT\n" +
- // " ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n" +
- // " MaterialCode,\n" +
- // " Version \n" +
- // " FROM\n" +
- // " Set_HQ_H_Platform \n" +
- // " WHERE\n" +
- // " HQHKanBan IS NULL \n" +
- // " AND Version = '{0}' \n" +
- // " GROUP BY\n" +
- // " MaterialCode,\n" +
- // " Version \n" +
- // " ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
- // " ) ccc";
//var _sql = string.Format(str, version, condition);
var _sql = string.Format(str, version);
@@ -1410,6 +1323,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
[ExporterHeader(DisplayName = "验收单日期")]
public string 验收单日期 { set; get; }
+
+ [ExporterHeader(DisplayName = "退货数量")]
+ public string 退货数量 { set; get; }
}
diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQFactoryUnSettledDetailDiffExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQFactoryUnSettledDetailDiffExportService.cs
new file mode 100644
index 00000000..851cf776
--- /dev/null
+++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQFactoryUnSettledDetailDiffExportService.cs
@@ -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
+{
+ ///
+ /// 红旗工厂未结明细
+ ///
+ public class HQFactoryUnSettledDetailDiffExportService : ITransientDependency, IExportJob
+ {
+
+ private readonly HQFactorySettledDetailDapperRepository _dapperRepository;
+ private readonly ErpPartDapperRepository _erpdapperRepository;
+ private readonly IBlobContainer _fileContainer;
+
+ private readonly OutputService _outputService;
+ private readonly InputService _inputService;
+
+ public HQFactoryUnSettledDetailDiffExportService(
+
+ ErpPartDapperRepository erpdapperRepository,
+ HQFactorySettledDetailDapperRepository dapperRepository,
+
+ OutputService outputService,
+ InputService inputService
+ , IBlobContainer fileContainer
+ )
+ {
+ _inputService = inputService;
+ _outputService = outputService;
+ _erpdapperRepository = erpdapperRepository;
+ _fileContainer = fileContainer;
+ _dapperRepository = dapperRepository;
+ }
+
+ public string ExportFile(Guid id, List exportName, List 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();
+ }
+
+ }
+}