1.修复接口查询的报错问题
2.增加库存模块的单据查询
This commit is contained in:
@@ -34,7 +34,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
/// <param name="cAccId">系统号</param>
|
||||
/// <param name="cCardNum">单据类型编码</param>
|
||||
/// <param name="input">查询条件</param>
|
||||
/// <param name="cCardPostion">查询所属区域 H:表头,B:表体</param>
|
||||
/// <param name="cCardPostion">查询所属区域 H:表头,B:表体, L:列表</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
[HttpPost]
|
||||
@@ -87,103 +87,105 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
}
|
||||
});
|
||||
|
||||
var cBTTblName = vouchers.cBTTblName;
|
||||
var cBWTblName = vouchers.cBWTblName;
|
||||
var cBTQName = vouchers.cBTTblName;
|
||||
var cBWQName = vouchers.cBWTblName;
|
||||
|
||||
var cBTTblExtName = $"{vouchers.cBTTblName}_extradefine";
|
||||
var cBWTblExtName = $"{vouchers.cBWTblName}_extradefine";
|
||||
|
||||
var voucherIdFieldName = vouchers.voucherIdFieldName;
|
||||
var vouchersIdFieldName = "";
|
||||
var tableName = cBTTblName;
|
||||
var colsHeadList = new List<string>();
|
||||
var colsBodyList = new List<string>();
|
||||
|
||||
var bExtHead = false;
|
||||
var bExtBody = false;
|
||||
|
||||
if (cCardPostion == "H")
|
||||
var colList = new Dictionary<string, string>();
|
||||
var colListHead = new Dictionary<string, string>();
|
||||
var colListBody = new Dictionary<string, string>();
|
||||
|
||||
var cols = db.DbMaintenance.GetColumnInfosByTableName(cBTQName);
|
||||
|
||||
if (cols != null && cols.Count > 0)
|
||||
{
|
||||
tableName = cBTTblName;
|
||||
foreach (var col in cols.Where(col => !colList.ContainsKey(col.DbColumnName.ToLower())))
|
||||
{
|
||||
if (cCardPostion == "H" || cCardPostion == "L")
|
||||
colList.Add(col.DbColumnName.ToLower(), $"{cBTQName}.[{col.DbColumnName}]");
|
||||
|
||||
colListHead.Add(col.DbColumnName.ToLower(), $"{cBTQName}.[{col.DbColumnName}]");
|
||||
}
|
||||
}
|
||||
|
||||
if (cCardPostion == "B")
|
||||
if (db.DbMaintenance.IsAnyTable($"{cBTTblExtName}"))
|
||||
{
|
||||
tableName = cBWTblName;
|
||||
bExtHead = true;
|
||||
|
||||
var extcols = db.DbMaintenance.GetColumnInfosByTableName($"{cBTTblExtName}");
|
||||
|
||||
if (extcols != null && extcols.Count > 0)
|
||||
{
|
||||
foreach (var col in extcols.Where(col => !colList.ContainsKey(col.DbColumnName.ToLower())))
|
||||
{
|
||||
if (cCardPostion == "H" || cCardPostion == "L")
|
||||
colList.Add(col.DbColumnName.ToLower(), $"{cBTTblExtName}.[{col.DbColumnName}]");
|
||||
|
||||
colListHead.Add(col.DbColumnName.ToLower(), $"{cBTTblExtName}.[{col.DbColumnName}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cCardPostion == "L")
|
||||
cols = db.DbMaintenance.GetColumnInfosByTableName(cBWQName);
|
||||
|
||||
if (cols != null && cols.Count > 0)
|
||||
{
|
||||
tableName = cBWTblName;
|
||||
foreach (var col in cols.Where(col => !colList.ContainsKey(col.DbColumnName.ToLower())))
|
||||
{
|
||||
if (cCardPostion == "B" || cCardPostion == "L")
|
||||
colList.Add(col.DbColumnName.ToLower(), $"{cBWQName}.[{col.DbColumnName}]");
|
||||
|
||||
colListBody.Add(col.DbColumnName.ToLower(), $"{cBWQName}.[{col.DbColumnName}]");
|
||||
}
|
||||
}
|
||||
|
||||
if (db.DbMaintenance.IsAnyTable(cBWTblExtName))
|
||||
{
|
||||
bExtBody = true;
|
||||
|
||||
var extcols = db.DbMaintenance.GetColumnInfosByTableName($"{cBWTblExtName}");
|
||||
|
||||
if (extcols != null && extcols.Count > 0)
|
||||
{
|
||||
foreach (var col in extcols)
|
||||
{
|
||||
if (colList.ContainsKey(col.DbColumnName.ToLower()))
|
||||
{
|
||||
vouchersIdFieldName = col.DbColumnName.ToLower();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cCardPostion == "B" || cCardPostion == "L")
|
||||
colList.Add(col.DbColumnName.ToLower(), $"{cBWTblExtName}.[{col.DbColumnName}]");
|
||||
|
||||
colListBody.Add(col.DbColumnName.ToLower(), $"{cBWTblExtName}.[{col.DbColumnName}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var cDefWhere = vouchers.cDefWhere;
|
||||
|
||||
var query = db.Queryable<dynamic>().AS(cBTTblName, cBTTblName);
|
||||
var query = db.Queryable<dynamic>().AS(cBTQName, cBTQName);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(cBWTblName))
|
||||
if (bExtHead)
|
||||
{
|
||||
query.AddJoinInfo(cBWTblName, cBWTblName, $"{cBTTblName}.[{voucherIdFieldName}]={cBWTblName}.[{voucherIdFieldName}]");
|
||||
|
||||
var bodyCols = db.DbMaintenance.GetColumnInfosByTableName(cBWTblName);
|
||||
|
||||
if (bodyCols != null && bodyCols.Count > 0)
|
||||
{
|
||||
colsBodyList.AddRange(from col in bodyCols where !col.DbColumnName.ToLower().Contains("ufts") && col.DbColumnName.ToLower() != voucherIdFieldName.ToLower() select $"{cBWTblName}.[{col.DbColumnName.ToLower()}]");
|
||||
|
||||
if (cCardPostion=="B" && !colsBodyList.Contains(voucherIdFieldName.ToLower()))
|
||||
{
|
||||
colsBodyList.Add($"{cBWTblName}.[{voucherIdFieldName.ToLower()}]");
|
||||
}
|
||||
}
|
||||
query.AddJoinInfo(cBTTblExtName, cBTTblExtName, $"{cBTQName}.[{voucherIdFieldName}]={cBTTblExtName}.[{voucherIdFieldName}]");
|
||||
}
|
||||
|
||||
var headCols = db.DbMaintenance.GetColumnInfosByTableName(cBTTblName);
|
||||
query.AddJoinInfo(cBWQName, cBWQName, $"{cBTQName}.[{voucherIdFieldName}]={cBWQName}.[{voucherIdFieldName}]");
|
||||
|
||||
if (headCols != null && headCols.Count > 0)
|
||||
if (bExtBody)
|
||||
{
|
||||
colsHeadList.AddRange(from col in headCols where !col.DbColumnName.ToLower().Contains("ufts") select $"{cBTTblName}.[{col.DbColumnName}]");
|
||||
}
|
||||
|
||||
if (db.DbMaintenance.IsAnyTable($"{cBTTblName}_extradefine", false))
|
||||
{
|
||||
bExtHead = true;
|
||||
var cols = db.DbMaintenance.GetColumnInfosByTableName($"{cBTTblName}_extradefine");
|
||||
|
||||
if (cols != null && cols.Count > 0)
|
||||
{
|
||||
foreach (var col in cols)
|
||||
{
|
||||
if (col.DbColumnName.ToLower().StartsWith("chdefine"))
|
||||
{
|
||||
colsHeadList.Add($"{cBTTblName}_extradefine.[{col.DbColumnName.ToLower()}]");
|
||||
}
|
||||
else
|
||||
{
|
||||
vouchersIdFieldName = col.DbColumnName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query.AddJoinInfo($"{cBTTblName}_extradefine", $"{cBTTblName}_extradefine", $"{cBTTblName}.[{voucherIdFieldName}]={cBTTblName}_extradefine.[{voucherIdFieldName}]");
|
||||
}
|
||||
|
||||
if (db.DbMaintenance.IsAnyTable($"{cBWTblName}_extradefine", false))
|
||||
{
|
||||
bExtBody = true;
|
||||
var cols = db.DbMaintenance.GetColumnInfosByTableName($"{cBWTblName}_extradefine");
|
||||
|
||||
if (cols != null && cols.Count > 0)
|
||||
{
|
||||
foreach (var col in cols)
|
||||
{
|
||||
if (col.DbColumnName.ToLower().StartsWith("cbdefine"))
|
||||
{
|
||||
colsBodyList.Add($"{cBWTblName}_extradefine.[{col.DbColumnName.ToLower()}]");
|
||||
}
|
||||
else
|
||||
{
|
||||
vouchersIdFieldName = col.DbColumnName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query.AddJoinInfo($"{cBWTblName}_extradefine", $"{cBWTblName}_extradefine", $"{cBWTblName}.[{vouchersIdFieldName}]={cBWTblName}_extradefine.[{vouchersIdFieldName}]");
|
||||
query.AddJoinInfo(cBWTblExtName, cBWTblExtName, $"{cBWQName}.[{vouchersIdFieldName}]={cBWTblExtName}.[{vouchersIdFieldName}]");
|
||||
}
|
||||
|
||||
if (input != null)
|
||||
@@ -194,54 +196,130 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
{
|
||||
if (o.Key == "dModifyDate")
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
if (colListHead.Any(a => string.Equals(a.Key, "RelsTime", StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, "RelsTime", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
FieldName = "RelsTime",
|
||||
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
var col = colListHead.First(a => string.Equals(a.Key, "RelsTime", StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, "RelsTime", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{col.Value}",
|
||||
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (o.Key == "dModifyDate__2")
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
if (colListHead.Any(a => string.Equals(a.Key, "dnveriRelsTimefytime", StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, "RelsTime", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
FieldName = "RelsTime",
|
||||
ConditionalType = ConditionalType.LessThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
var col = colListHead.First(a => string.Equals(a.Key, "RelsTime", StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, "RelsTime", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{col.Value}",
|
||||
ConditionalType = ConditionalType.LessThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
}
|
||||
else if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
if (colListHead.Any(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
FieldName = $"{o.Key}",
|
||||
ConditionalType = ConditionalType.Like,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
var col = colListHead.First(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{col.Value}",
|
||||
ConditionalType = ConditionalType.Like,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
|
||||
if (colListBody.Any(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var col = colListBody.First(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{col.Value}",
|
||||
ConditionalType = ConditionalType.Like,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (o.Key.EndsWith("__2"))
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
if (colListHead.Any(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
FieldName = $"{o.Key.Replace("__2", "")}",
|
||||
ConditionalType = ConditionalType.LessThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
var col = colListHead.First(a => string.Equals(a.Key, o.Key.Replace("__2", ""), StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key.Replace("__2", ""), StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{col.Value}",
|
||||
ConditionalType = ConditionalType.LessThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
|
||||
if (colListBody.Any(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var col = colListBody.First(a => string.Equals(a.Key, o.Key.Replace("__2", ""), StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key.Replace("__2", ""), StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{col.Value}",
|
||||
ConditionalType = ConditionalType.LessThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (input.ContainsKey($"{o.Key}__2"))
|
||||
{
|
||||
if (colListHead.Any(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var col = colListHead.First(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{col.Value}",
|
||||
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
|
||||
if (colListBody.Any(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var col = colListBody.First(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{col.Value}",
|
||||
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (colListHead.Any(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var col = colListHead.First(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{o.Key}",
|
||||
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
||||
FieldName = col.Value,
|
||||
ConditionalType = ConditionalType.Equal,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
else
|
||||
else if (colListBody.Any(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var col = colListBody.First(a => string.Equals(a.Key, o.Key, StringComparison.OrdinalIgnoreCase) || string.Equals(a.Value, o.Key, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = o.Key,
|
||||
FieldName = col.Value,
|
||||
ConditionalType = ConditionalType.Equal,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
@@ -253,44 +331,10 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
|
||||
query.Where(cDefWhere);
|
||||
|
||||
if (cCardPostion == "H")
|
||||
{
|
||||
if (bExtHead)
|
||||
{
|
||||
query.Select($"{string.Join(",", colsHeadList)}").Distinct();
|
||||
}
|
||||
else
|
||||
{
|
||||
query.Select($"{string.Join(",", colsHeadList)}").Distinct();
|
||||
}
|
||||
}
|
||||
|
||||
if (cCardPostion == "B")
|
||||
{
|
||||
if (bExtBody)
|
||||
{
|
||||
query.Select($"{string.Join(",", colsBodyList)}").Distinct();
|
||||
}
|
||||
else
|
||||
{
|
||||
query.Select($"{string.Join(",", colsBodyList)}").Distinct();
|
||||
}
|
||||
}
|
||||
|
||||
if (cCardPostion == "L")
|
||||
{
|
||||
colsBodyList.AddRange(colsHeadList);
|
||||
|
||||
if (bExtBody)
|
||||
{
|
||||
query.Select($"{string.Join(",", colsBodyList)}").Distinct();
|
||||
}
|
||||
else
|
||||
{
|
||||
query.Select($"{string.Join(",", colsBodyList)}").Distinct();
|
||||
}
|
||||
}
|
||||
var selector = colList.Select(col => new SelectModel { FieldName = $"{col.Value}", AsName = col.Key }).ToList();
|
||||
|
||||
query.Select(selector).Distinct();
|
||||
|
||||
_logInfo.Debug(query.ToSqlString());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user