44673626 3 years ago
parent
commit
40be31569c
  1. 121
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs

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

@ -21,6 +21,17 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
public class CompareExtend1
{
public string AcceptanceNo { set; get; }
public string KanbanNumber { set; get; }
public string AcceptanceDate { set; get; }
public string HQHKanBan { set; get; }
public string MaterialCode { set; get; }
}
/// <summary>
/// 红旗H平台输出报表
@ -154,9 +165,16 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" AND A.MaterialCode = B.MaterialCode";
var listCompare= DbConnection.Query<CompareExtend>(sql2);
var sql3 = "SELECT\n" +
" a.WmsBillNum,\n" +
" a.MaterialCode,\n" +
@ -177,14 +195,113 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
var sql10= "SELECT DISTINCT\n" +
" t1.* \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.AcceptanceNo AS AcceptanceNo,\n" +
" a.KanbanNumber AS KanbanNumber,\n" +
" CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_HQ_H_Platform a \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<CompareExtend1>(string.Format(sql10, version));
var sql11 = "SELECT DISTINCT\n" +
" t1.* \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.AcceptanceNo AS AcceptanceNo,\n" +
" a.KanbanNumber AS KanbanNumber,\n" +
" CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_HQ_H_Platform a \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<CompareExtend1>(string.Format(sql11, version));
var sql12 = "SELECT\n" +
" a.AcceptanceNo AS AcceptanceNo,\n" +
" a.KanbanNumber AS KanbanNumber,\n" +
" CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
"FROM\n" +
" Set_HQ_H_Platform a \n" +
"WHERE\n" +
" Version = '{0}' \n" +
" AND HQHKanBan = 'BJ'";
var list13 = DbConnection.Query<CompareExtend1>(string.Format(sql12, version));
List<CompareExtend1> _lscopy = new List<CompareExtend1>();
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.AcceptanceNo += "," + itm.AcceptanceNo;
}
else
{
_lscopy.Add(itm);
}
}
foreach (var itm in list12)
{
_lscopy.Add(itm);
}
foreach (var itm in list13)
{
_lscopy.Add(itm);
}
List<CompareExtend> _ls = new List<CompareExtend>();
foreach (var itm in listCompare.ToList())
{
var first = _ls.FirstOrDefault(p => p.Kanban == itm.Kanban && p.MaterialCode == itm.MaterialCode);
if (first != null)
{
first.WmsBillNum += itm.WmsBillNum;
first.WmsDate += itm.WmsDate;
first.WmsBillNum += "," + itm.WmsBillNum;
first.WmsDate += "," + itm.WmsDate;
}
else
{
_ls.Add(itm);
}
}

Loading…
Cancel
Save