From 1f82d0a16bddcf74a4059a70ad2d8807ed819c32 Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Fri, 25 Mar 2022 18:13:16 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=BA=A2=E6=97=97=E6=9C=AA=E7=BB=93?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8A=A5=E8=A1=A8=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HQHSettledDetailDapperRepository.cs | 228 +++++++++++++++++- .../HQHUnSettledDetailDiffExportService.cs | 3 +- 2 files changed, 224 insertions(+), 7 deletions(-) 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 78d18374..12c1b718 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 @@ -576,7 +576,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report - public virtual List GetReverseSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup) + public virtual List GetReverseSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup string iscontionversion) { List _list = new List(); @@ -591,6 +591,17 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { condition += string.Format(" and a.LastModificationTime<='{0}' ", end); } + + string contion = string.Empty; + //选中,是否过滤掉当期结算数据 + if (iscontionversion == "0") + { + contion += string.Format(" WHERE Version <'{0}' ", version); + } + else + { + contion += " WHERE 1=1 "; + } //更改:按照财务要求,将有发货有结算中发货数量大于结算数据的数据整合到未结报表中20220324 string str = "SELECT\n" + " * \n" + @@ -640,12 +651,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " C.EstimateTypeDesc AS 物料组 \n" + " FROM\n" + " Set_HQ_H_Kanban AS a\n" + - " LEFT OUTER JOIN Set_HQ_H_Platform AS b ON a.Kanban = b.HQHKanBan \n" + + " LEFT OUTER JOIN (select * from Set_HQ_H_Platform {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 {0}\n" + + " AND b.MaterialCode IS NULL {1}\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 set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + @@ -699,20 +710,225 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " C.EstimateTypeDesc AS 物料组 \n" + " FROM\n" + " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, WmsBillNum, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, WmsBillNum, LastModificationTime ) AS a\n" + - " INNER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform GROUP BY HQHKanBan, MaterialCode ) AS b ON a.Kanban = b.HQHKanBan \n" + + " INNER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode ) 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" + - " a.Qty> b.Qty {0}\n" + + " a.Qty> b.Qty {1}\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 set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + " AND temp1.订货看板编号 = tt.Code \n" + " ) UNION2"; - var _sql = string.Format(str, condition); + var _sql = string.Format(str,version, condition); + + + + + var sql2 = "SELECT\n" + + " a.WmsBillNum,\n" + + " t1.MaterialCode MaterialCode,\n" + + " a.Kanban ,\n" + + " A.LastModificationTime WmsDate \n" + + "FROM\n" + + " Set_HQ_H_Kanban A\n" + + " INNER JOIN ( SELECT MaterialCode, Kanban FROM Set_HQ_H_Kanban GROUP BY MaterialCode, Kanban HAVING COUNT(*)> 1 ) B ON A.Kanban = B.Kanban \n" + + " AND A.MaterialCode = B.MaterialCode " + + " left join Set_material t1 on a.MaterialCode=t1.CustomerPartCode "; + + + + + + + + var listCompare = DbConnection.Query(sql2); + + + + + + var sql3 = "SELECT\n" + + " a.WmsBillNum,\n" + + " t1.MaterialCode MaterialCode,\n" + + " a.Kanban,\n" + + " A.LastModificationTime WmsDate \n" + + "FROM\n" + + " Set_HQ_H_Kanban A\n" + + " LEFT JOIN ( SELECT MaterialCode, Kanban FROM Set_HQ_H_Kanban GROUP BY MaterialCode, Kanban HAVING COUNT(*)> 1 ) B ON A.Kanban = B.Kanban \n" + + " AND A.MaterialCode = B.MaterialCode \n" + + " left join Set_material t1 on a.MaterialCode=t1.CustomerPartCode \n" + + + "WHERE\n" + + " B.Kanban IS NULL"; + + + + var listCompare1 = DbConnection.Query(sql3); + + + + + + var sql10 = "SELECT DISTINCT\n" + + " t1.* \n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + + " a.KanbanNumber AS KanbanNumber,\n" + + " CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" + + " HQHKanBan,\n" + + " b2.MaterialCode \n" + + " FROM\n" + + " Set_HQ_H_Platform a \n" + + + " left join Set_material b2 on a.MaterialCode = b2.CustomerPartCode \n" + + + " WHERE\n" + + " Version = '{0}' \n" + + " AND HQHKanBan <> 'BJ' \n" + + " ) t1\n" + + " LEFT JOIN ( SELECT HQHKanBan, MaterialCode FROM Set_HQ_H_Platform a WHERE Version = '{0}' AND HQHKanBan <> 'BJ' GROUP BY HQHKanBan, MaterialCode HAVING count(*)> 1 ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" + + " AND t1.MaterialCode = t2.MaterialCode \n" + + "WHERE\n" + + " t2.HQHKanBan IS NULL"; + + + var list11 = DbConnection.Query(string.Format(sql10, version)); + + + + + + var sql11 = "SELECT DISTINCT\n" + + " t1.* \n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + + " a.KanbanNumber AS KanbanNumber,\n" + + " CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" + + " HQHKanBan,\n" + + " b2.MaterialCode \n" + + " FROM\n" + + " Set_HQ_H_Platform a \n" + + + " left join Set_material b2 on a.MaterialCode = b2.CustomerPartCode \n" + + + " WHERE\n" + + " Version = '{0}' \n" + + " AND HQHKanBan <> 'BJ' \n" + + " ) t1\n" + + " INNER JOIN ( SELECT HQHKanBan, MaterialCode FROM Set_HQ_H_Platform a WHERE Version = '{0}' AND HQHKanBan <> 'BJ' GROUP BY HQHKanBan, MaterialCode HAVING count(*)> 1 ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" + + " AND t1.MaterialCode = t2.MaterialCode \n" + + "ORDER BY\n" + + " t1.HQHKanBan,\n" + + " t1.MaterialCode"; + + + var list12 = DbConnection.Query(string.Format(sql11, version)); + + + var sql12 = "SELECT\n" + + " a.ExternalKanbanNumber AS ExternalKanbanNumber,\n" + + " a.KanbanNumber AS KanbanNumber,\n" + + " CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" + + " HQHKanBan,\n" + + " b2.MaterialCode \n" + + "FROM\n" + + " Set_HQ_H_Platform a \n" + + " left join Set_material b2 on a.MaterialCode = b2.CustomerPartCode \n" + + + "WHERE\n" + + " Version = '{0}' \n" + + " AND HQHKanBan = 'BJ'"; + + var list13 = DbConnection.Query(string.Format(sql12, version)); + + + List _lscopy = new List(); + + foreach (var itm in list11) + { + var first = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm.HQHKanBan && p.MaterialCode == itm.MaterialCode); + if (first != null) + { + first.KanbanNumber += "," + itm.KanbanNumber; + first.AcceptanceDate += "," + itm.AcceptanceDate; + first.ExternalKanbanNumber += "," + itm.ExternalKanbanNumber; + } + else + { + _lscopy.Add(itm); + } + } + foreach (var itm in list12) + { + _lscopy.Add(itm); + } + foreach (var itm in list13) + { + _lscopy.Add(itm); + } + + + List _ls = new List(); + foreach (var itm in listCompare.ToList()) + { + var first = _ls.FirstOrDefault(p => p.Kanban == itm.Kanban && p.MaterialCode == itm.MaterialCode); + if (first != null) + { + if (!string.IsNullOrEmpty(itm.WmsDate)) + { + itm.WmsDate = DateTime.Parse(itm.WmsDate).ToShortDateString(); + } + + first.WmsBillNum += "," + itm.WmsBillNum; + first.WmsDate += "," + itm.WmsDate; + } + else + { + if (!string.IsNullOrEmpty(itm.WmsDate)) + { + itm.WmsDate = DateTime.Parse(itm.WmsDate).ToShortDateString(); + } + _ls.Add(itm); + } + + } + + foreach (var itm in listCompare1.ToList()) + { + if (!string.IsNullOrEmpty(itm.WmsDate)) + { + itm.WmsDate = DateTime.Parse(itm.WmsDate).ToShortDateString(); + } + _ls.Add(itm); + } var _query = DbConnection.Query(_sql, null, null, true, 1200, null); _list = _query.ToList(); + + foreach (var itm1 in _list) + { + var itm = _ls.FirstOrDefault(p => p.Kanban == itm1.订货看板编号 && p.MaterialCode == itm1.Sap编码); + if (itm != null) + { + itm1.交货单号 = itm.WmsBillNum; + itm1.交货时间 = itm.WmsDate; + } + + var itmcopy = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm1.订货看板编号 && p.MaterialCode == itm1.Sap编码); + if (itmcopy != null) + { + itm1.看板编号 = itmcopy.KanbanNumber; + itm1.验收单日期 = itmcopy.AcceptanceDate; + itm1.外部验收单号 = itmcopy.ExternalKanbanNumber; + } + } + + return _list; } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs index 2643bd34..ad00f4a1 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs @@ -56,11 +56,12 @@ namespace SettleAccount.Job.Services.Report 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 iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; //有发货无结算,单独拿出去,财务要求 - var _ls = _dapperRepository.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup); + var _ls = _dapperRepository.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion); From 84e5db932f40471bb0320c35a34c9f001446637e Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Sat, 26 Mar 2022 13:09:07 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Report/HQHSettledDetailDapperRepository.cs | 2 +- .../SettleAccount.Job/Services/Report/UnSettledSumService.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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 12c1b718..651f1653 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 @@ -576,7 +576,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report - public virtual List GetReverseSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup string iscontionversion) + public virtual List GetReverseSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup, string iscontionversion) { List _list = new List(); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs index 5d74c73a..a93f45be 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs @@ -229,8 +229,9 @@ namespace SettleAccount.Job.Services.Report 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 iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; //有发货无结算,单独拿出去,财务要求 - var _ls = _hqkanbanDapper.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup); + var _ls = _hqkanbanDapper.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion); if (!string.IsNullOrEmpty(sapCode)) { var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); From 5c5c18f6405e58fc78806fa70997291fa393f8f6 Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Sat, 26 Mar 2022 16:33:54 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=BA=A2=E6=97=97=E6=9C=AA=E7=BB=93?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E8=B0=83=E6=95=B4=E6=9C=AA=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReportRequestDto/ReportRequestDto.cs | 8 +- .../ReportServices/ReportMakeService.cs | 1 + .../HQHSettledDetailDapperRepository.cs | 269 +++++++++++++++--- .../HQHUnSettledDetailDiffExportService.cs | 60 +--- 4 files changed, 243 insertions(+), 95 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Reports/ReportRequestDto/ReportRequestDto.cs b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Reports/ReportRequestDto/ReportRequestDto.cs index 0fdd3de8..659aba97 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Reports/ReportRequestDto/ReportRequestDto.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Reports/ReportRequestDto/ReportRequestDto.cs @@ -29,9 +29,13 @@ namespace Win.Sfs.SettleAccount.Reports.ReportRequestDto public string State { set; get; } - - + + public string IsContainVersion { 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 c6f0afa0..9e1e93e5 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -755,6 +755,7 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices 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 }); + customConditionList.Add(new CustomCondition() { Name = "IsContainVersion", Value = input.IsContainVersion }); var _taskid = await _service.ExportEnqueueAsync("红旗工厂未结明细", ExportExtentsion.Excel, input.Version, string.IsNullOrEmpty(input.MaterialGroup) ? string.Empty : input.MaterialGroup, CurrentUser, typeof(HQHUnSettledDetailDiffExportService), customConditionList, (rs) => { }); 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 651f1653..4d3f1990 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 @@ -382,17 +382,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } - //var _ls_1 = from itm1 in _list - // join itm2 in _ls on new { Kanban = itm1.订货看板编号, MaterialCode=itm1.Sap编码 } - // equals new { itm2.Kanban, itm2.MaterialCode } into g - // from t in g.DefaultIfEmpty() - // select new HQHSettledDetailDiff - // { - - // } ; - - - return _list; @@ -575,7 +564,16 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } - + /// + /// 红旗未结比对(包含有发货有结算中发货大于结算的数据) + /// + /// + /// + /// + /// + /// + /// + /// public virtual List GetReverseSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup, string iscontionversion) { @@ -610,8 +608,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " SELECT\n" + " temp1.交货时间,\n" + " isnull( temp1.交货单号, '' ) 交货单号,\n" + - " temp1.收货仓库,\n" + - " temp1.收货仓库描述,\n" + " temp1.订货看板编号,\n" + " temp1.订货零件号,\n" + " temp1.Sap编码,\n" + @@ -619,7 +615,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " temp1.物料组,\n" + " temp1.零件中文名称,\n" + " temp1.发货数量,\n" + - " temp1.发货状态,\n" + " temp1.外部验收单号,\n" + " temp1.结算数量,\n" + " temp1.结算单价,\n" + @@ -635,23 +630,20 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " SELECT\n" + " a.WmsBillNum AS 交货单号,\n" + " CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" + - " b.StorageLocation AS 收货仓库,\n" + - " b.StorageLocationDesc AS 收货仓库描述,\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" + - " isnull( a.State, 0 ) AS 发货状态,\n" + - " b.ExternalKanbanNumber AS 外部验收单号,\n" + + " '' AS 外部验收单号,\n" + " isnull( b.Qty, 0 ) AS 结算数量,\n" + - " isnull( b.Price, 0 ) AS 结算单价,\n" + - " isnull( b.Amt, 0 ) AS 结算金额 ,\n" + + " 0 AS 结算单价,\n" + + " 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 {0}) AS b ON a.Kanban = b.HQHKanBan \n" + + " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, WmsBillNum, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, WmsBillNum, LastModificationTime ) AS a\n" + + " LEFT OUTER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode ) 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" + @@ -669,8 +661,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " SELECT\n" + " temp1.交货时间,\n" + " isnull( temp1.交货单号, '' ) 交货单号,\n" + - " temp1.收货仓库,\n" + - " temp1.收货仓库描述,\n" + " temp1.订货看板编号,\n" + " temp1.订货零件号,\n" + " temp1.Sap编码,\n" + @@ -678,7 +668,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " temp1.物料组,\n" + " temp1.零件中文名称,\n" + " temp1.发货数量,\n" + - " temp1.发货状态,\n" + " temp1.外部验收单号,\n" + " temp1.结算数量,\n" + " temp1.结算单价,\n" + @@ -694,15 +683,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " SELECT\n" + " a.WmsBillNum AS 交货单号,\n" + " CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" + - " '' AS 收货仓库,\n" + - " '' AS 收货仓库描述,\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" + - " 0 AS 发货状态,\n" + " '' AS 外部验收单号,\n" + " isnull( b.Qty, 0 ) AS 结算数量,\n" + " 0 AS 结算单价,\n" + @@ -714,17 +700,19 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " AND a.MaterialCode = b.MaterialCode\n" + " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + " WHERE\n" + - " a.Qty> b.Qty {1}\n" + + " a.Qty> b.Qty {1}\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 set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + " AND temp1.订货看板编号 = tt.Code \n" + " ) UNION2"; - var _sql = string.Format(str,version, condition); + var _sql = string.Format(str, contion, condition); + + //发运数据中,查出看板号+物料号相同的重复数据 var sql2 = "SELECT\n" + " a.WmsBillNum,\n" + " t1.MaterialCode MaterialCode,\n" + @@ -735,19 +723,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " INNER JOIN ( SELECT MaterialCode, Kanban FROM Set_HQ_H_Kanban GROUP BY MaterialCode, Kanban HAVING COUNT(*)> 1 ) B ON A.Kanban = B.Kanban \n" + " AND A.MaterialCode = B.MaterialCode " + " left join Set_material t1 on a.MaterialCode=t1.CustomerPartCode "; - - - - - - - var listCompare = DbConnection.Query(sql2); - + //查询发运表中,看权号+物料号没有重复的数据 var sql3 = "SELECT\n" + " a.WmsBillNum,\n" + " t1.MaterialCode MaterialCode,\n" + @@ -762,14 +743,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report "WHERE\n" + " B.Kanban IS NULL"; - - var listCompare1 = DbConnection.Query(sql3); - + //红旗结算数据中,看板号+物料号没有重复的 var sql10 = "SELECT DISTINCT\n" + " t1.* \n" + "FROM\n" + @@ -800,7 +779,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report - + //红旗结算数据中,看板号+物料号有重复的数据 var sql11 = "SELECT DISTINCT\n" + " t1.* \n" + "FROM\n" + @@ -825,8 +804,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report "ORDER BY\n" + " t1.HQHKanBan,\n" + " t1.MaterialCode"; - - var list12 = DbConnection.Query(string.Format(sql11, version)); @@ -847,6 +824,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report var list13 = DbConnection.Query(string.Format(sql12, version)); + //结算数据比较 List _lscopy = new List(); foreach (var itm in list11) @@ -873,6 +851,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } + //发运数据比较 List _ls = new List(); foreach (var itm in listCompare.ToList()) { @@ -933,8 +912,208 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } + /// + /// 原始红旗未结数据(不包括有发货有结算中发货大于结算的数据) + /// + /// + /// + /// + /// + /// + /// + /// + public virtual List GetOriginalSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup, string iscontionversion) + { + + 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 contion = string.Empty; + //选中,是否过滤掉当期结算数据 + if (iscontionversion == "0") + { + contion += string.Format(" WHERE Version <'{0}' ", version); + } + else + { + contion += " WHERE 1=1 "; + } + string str = "SELECT\n" + + " * \n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " 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" + + " isnull( tt.Qty, 0 ) 退货数量,\n" + + " isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) AS 数量差异,\n" + + " temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" + + " ( temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 差异总金额 \n" + + " FROM\n" + + " (\n" + + " SELECT\n" + + " a.WmsBillNum AS 交货单号,\n" + + " CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" + + " b.StorageLocation AS 收货仓库,\n" + + " b.StorageLocationDesc AS 收货仓库描述,\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" + + " isnull( a.State, 0 ) AS 发货状态,\n" + + " b.ExternalKanbanNumber 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 {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 {1}\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 set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + + " AND temp1.订货看板编号 = tt.Code \n" + + " ) UNION1 " ; + var _sql = string.Format(str, contion, condition); + + + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + _list = _query.ToList(); + + return _list; + + } + + /// + /// 有发货有结算数据且发货数量大于结算数量 + /// + /// + /// + /// + /// + /// + /// + /// + public virtual List GetInnerJoinSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup, string iscontionversion) + { + + 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 contion = string.Empty; + //选中,是否过滤掉当期结算数据 + if (iscontionversion == "0") + { + contion += string.Format(" WHERE Version <'{0}' ", version); + } + else + { + contion += " WHERE 1=1 "; + } + string str = "SELECT\n" + + " * \n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " temp1.交货时间,\n" + + " isnull( 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" + + " isnull( TEMP2.Price, 0 ) AS 发货定价,\n" + + " isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" + + " isnull( tt.Qty, 0 ) 退货数量,\n" + + " isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 ) AS 数量差异,\n" + + " temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" + + " ( temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 差异总金额 \n" + + " FROM\n" + + " (\n" + + " SELECT\n" + + " a.WmsBillNum AS 交货单号,\n" + + " CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\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" + + " '' AS 外部验收单号,\n" + + " isnull( b.Qty, 0 ) AS 结算数量,\n" + + " 0 AS 结算单价,\n" + + " 0 AS 结算金额 ,\n" + + " C.EstimateTypeDesc AS 物料组 \n" + + " FROM\n" + + " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, WmsBillNum, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, WmsBillNum, LastModificationTime ) AS a\n" + + " INNER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode ) 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" + + " a.Qty> b.Qty {1}\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 set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" + + " AND temp1.订货看板编号 = tt.Code \n" + + " ) UNION2"; + var _sql = string.Format(str, contion, condition); + + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + _list = _query.ToList(); + return _list; + + } public virtual List GetDiffQtyList(string version) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs index ad00f4a1..ba0eb0b0 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs @@ -60,53 +60,15 @@ namespace SettleAccount.Job.Services.Report - //有发货无结算,单独拿出去,财务要求 + //有发货无结算+有发货有结算中发货数量大于结算数量的数据-----组合 var _ls = _dapperRepository.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion); + //原始正常的红旗未结数据(不包含有发货有结算中发货大于结算的数据,数量也未求和) + var _ls_original = _dapperRepository.GetOriginalSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion); - - //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(); - // } - //} + //有发货有结算,发货数量大于结算数量 + var _ls_innerjoin = _dapperRepository.GetInnerJoinSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion); + if (!string.IsNullOrEmpty(sapCode)) { @@ -118,12 +80,14 @@ namespace SettleAccount.Job.Services.Report } - + ExcelExporter _exporter = new ExcelExporter();//导出Excel - var result = _exporter.Append(_ls.ToList(), "有发货无结算对比") - //.SeparateBySheet() - //.Append(_lsnoSettle.ToList(), "有结算无发货对比") + var result = _exporter.Append(_ls.ToList(), "有发货对比(无结算加指定条件结算)") + .SeparateBySheet() + .Append(_ls_original.ToList(), "原始红旗未结数据") + .SeparateBySheet() + .Append(_ls_innerjoin.ToList(), "有发货有结算(发货数量大于结算)") .ExportAppendDataAsByteArray(); result.ShouldNotBeNull(); _fileContainer.SaveAsync(_filename, result.Result, true); From 4359c5771990dd5158c3df051c165741f3d54ec7 Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Sat, 26 Mar 2022 17:34:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=BA=A2=E6=97=97=E6=9C=AA=E7=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HQHSettledDetailDapperRepository.cs | 27 ++++++++++--------- .../HQHUnSettledDetailDiffExportService.cs | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) 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 4d3f1990..9e14c83d 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 @@ -563,7 +563,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } - + /// /// 红旗未结比对(包含有发货有结算中发货大于结算的数据) /// @@ -600,7 +600,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { contion += " WHERE 1=1 "; } - //更改:按照财务要求,将有发货有结算中发货数量大于结算数据的数据整合到未结报表中20220324 + //更改:按照财务要求,将有发货有结算中发货数量大于结算数据的数据整合到未结报表中20220324,sum求和不带交货单号,后算出来 string str = "SELECT\n" + " * \n" + "FROM\n" + @@ -628,7 +628,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " FROM\n" + " (\n" + " SELECT\n" + - " a.WmsBillNum AS 交货单号,\n" + + " '' AS 交货单号,\n" + " CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" + " a.Kanban AS 订货看板编号,\n" + " b.MaterialCode AS 订货零件号,\n" + @@ -642,7 +642,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " 0 AS 结算金额 ,\n" + " C.EstimateTypeDesc AS 物料组 \n" + " FROM\n" + - " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, WmsBillNum, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, WmsBillNum, LastModificationTime ) AS a\n" + + " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, LastModificationTime ) AS a\n" + " LEFT OUTER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode ) 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" + @@ -681,7 +681,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " FROM\n" + " (\n" + " SELECT\n" + - " a.WmsBillNum AS 交货单号,\n" + + " '' AS 交货单号,\n" + " CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" + " a.Kanban AS 订货看板编号,\n" + " b.MaterialCode AS 订货零件号,\n" + @@ -695,7 +695,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " 0 AS 结算金额 ,\n" + " C.EstimateTypeDesc AS 物料组 \n" + " FROM\n" + - " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, WmsBillNum, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, WmsBillNum, LastModificationTime ) AS a\n" + + " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, LastModificationTime ) AS a\n" + " INNER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode ) 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" + @@ -748,7 +748,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report - //红旗结算数据中,看板号+物料号没有重复的 + //红旗结算数据中,看板号+物料号没有重复的数据 var sql10 = "SELECT DISTINCT\n" + " t1.* \n" + "FROM\n" + @@ -774,7 +774,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " t2.HQHKanBan IS NULL"; - var list11 = DbConnection.Query(string.Format(sql10, version)); + var list_leftjoin_hplatform = DbConnection.Query(string.Format(sql10, version)); @@ -804,7 +804,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report "ORDER BY\n" + " t1.HQHKanBan,\n" + " t1.MaterialCode"; - var list12 = DbConnection.Query(string.Format(sql11, version)); + var list_innerjoin_hplatform = DbConnection.Query(string.Format(sql11, version)); var sql12 = "SELECT\n" + @@ -821,13 +821,13 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " Version = '{0}' \n" + " AND HQHKanBan = 'BJ'"; - var list13 = DbConnection.Query(string.Format(sql12, version)); + var list_hplaform_bj = DbConnection.Query(string.Format(sql12, version)); //结算数据比较 List _lscopy = new List(); - foreach (var itm in list11) + foreach (var itm in list_leftjoin_hplatform) { var first = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm.HQHKanBan && p.MaterialCode == itm.MaterialCode); if (first != null) @@ -841,11 +841,11 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report _lscopy.Add(itm); } } - foreach (var itm in list12) + foreach (var itm in list_innerjoin_hplatform) { _lscopy.Add(itm); } - foreach (var itm in list13) + foreach (var itm in list_hplaform_bj) { _lscopy.Add(itm); } @@ -889,6 +889,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report var _query = DbConnection.Query(_sql, null, null, true, 1200, null); _list = _query.ToList(); + //数据整合,相同看板号+物料号的交货单号合并成一行中以逗号分隔 foreach (var itm1 in _list) { var itm = _ls.FirstOrDefault(p => p.Kanban == itm1.订货看板编号 && p.MaterialCode == itm1.Sap编码); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs index ba0eb0b0..430b4560 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs @@ -66,7 +66,7 @@ namespace SettleAccount.Job.Services.Report //原始正常的红旗未结数据(不包含有发货有结算中发货大于结算的数据,数量也未求和) var _ls_original = _dapperRepository.GetOriginalSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion); - //有发货有结算,发货数量大于结算数量 + //有发货有结算,且发货数量大于结算数量的数据汇总 var _ls_innerjoin = _dapperRepository.GetInnerJoinSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion);