Browse Source

红旗结算未结核对更改

FoShanPG
44673626 3 years ago
parent
commit
5a8313363e
  1. 143
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs

143
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs

@ -580,142 +580,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
var listCompare1 = DbConnection.Query<CompareFactoryExtend>(sql3);
string contionCompare = string.Empty;
//选中,是否过滤掉当期结算数据
if (iscontionversion == "0")
{
contionCompare += string.Format(" WHERE Version <'{0}' AND HQHKanBan <> 'BJ' ", version);
}
else
{
contionCompare += " WHERE 1=1 ";
}
//红旗结算数据中,看板号+物料号没有重复的数据
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" +
" {0} \n" +
" ) t1\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_HQ_H_Platform a \n" +
" {0} \n" +
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" HAVING\n" +
" COUNT ( * ) > 1 \n" +
" ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" +
" AND t1.MaterialCode = t2.MaterialCode \n" +
"WHERE\n" +
" t2.HQHKanBan IS NULL";
var list_leftjoin_hplatform = DbConnection.Query<CompareFactoryExtend1>(string.Format(sql10, contionCompare));
//红旗结算数据中,看板号+物料号有重复的数据
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" +
" {0}\n" +
" ) t1\n" +
" INNER JOIN (\n" +
" SELECT\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_HQ_H_Platform a \n" +
" {0}\n" +
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" HAVING\n" +
" COUNT ( * ) > 1 \n" +
" ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" +
" AND t1.MaterialCode = t2.MaterialCode \n" +
"ORDER BY\n" +
" t1.HQHKanBan,\n" +
" t1.MaterialCode";
var list_innerjoin_hplatform = DbConnection.Query<CompareFactoryExtend1>(string.Format(sql11, contionCompare));
string contionCompareBJ = string.Empty;
//选中,是否过滤掉当期结算数据
if (iscontionversion == "0")
{
contionCompareBJ += string.Format(" WHERE Version <'{0}' AND HQHKanBan = 'BJ' ", version);
}
else
{
contionCompareBJ += " WHERE 1=1 ";
}
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" +
"{0}";
var list_hplaform_bj = DbConnection.Query<CompareFactoryExtend1>(string.Format(sql12, contionCompareBJ));
//结算数据比较
List<CompareFactoryExtend1> _lscopy = new List<CompareFactoryExtend1>();
foreach (var itm in list_leftjoin_hplatform)
{
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 list_innerjoin_hplatform)
{
_lscopy.Add(itm);
}
foreach (var itm in list_hplaform_bj)
{
_lscopy.Add(itm);
}
//发运数据比较
@ -765,14 +630,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
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;
}
}

Loading…
Cancel
Save