Browse Source

红旗未结相关报表更改

FoShanPG
44673626 3 years ago
parent
commit
1f82d0a16b
  1. 228
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs
  2. 3
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HQHUnSettledDetailDiffExportService.cs

228
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<HQHUnSettledDetailDiff> GetReverseSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup)
public virtual List<HQHUnSettledDetailDiff> GetReverseSettledDetailDiffReportList(string version, string materialCode, string begin, string end, string materialGroup string iscontionversion)
{
List<HQHUnSettledDetailDiff> _list = new List<HQHUnSettledDetailDiff>();
@ -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<CompareExtend>(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<CompareExtend>(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<CompareExtend1>(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<CompareExtend1>(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<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.ExternalKanbanNumber += "," + itm.ExternalKanbanNumber;
}
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)
{
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<HQHUnSettledDetailDiff>(_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;
}

3
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);

Loading…
Cancel
Save