1.完成销售管理模块
2.修复档案查询与新增单据查询
This commit is contained in:
@@ -7,6 +7,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Entity;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Json;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
||||
@@ -28,27 +29,24 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
private static readonly MemoryCache _cache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(10) });
|
||||
|
||||
/// <summary>
|
||||
/// 查询生产订单
|
||||
/// 查询特定单据部分
|
||||
/// </summary>
|
||||
/// <param name="cAccId"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="cAccId">系统号</param>
|
||||
/// <param name="cCardNum">单据类型编码</param>
|
||||
/// <param name="input">查询条件</param>
|
||||
/// <param name="cCardPostion">查询所属区域 H:表头,B:表体</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
[HttpPost]
|
||||
[Route("api/U8/MO/MO21/Load")]
|
||||
public async Task<BaseResult<dynamic>> MO21_Load(string cAccId,[FromBody] Dictionary<string, object> input)
|
||||
[Route("api/U8/MO/{cCardNum}/Load")]
|
||||
[Route("api/U8/MO/{cCardNum}/Load/{cCardPostion}")]
|
||||
public async Task<BaseResult<dynamic>> Load(string cAccId, string cCardNum, [FromBody] Dictionary<string, object> input, string cCardPostion = "H")
|
||||
{
|
||||
var workId = SnowFlakeSingle.Instance.NextId();
|
||||
|
||||
try
|
||||
{
|
||||
//var userToken = Request.Headers.GetValues("userToken").First();
|
||||
|
||||
//if (userToken!= "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386")
|
||||
//{
|
||||
// throw new Exception("调用信息不正确,请确认参数");
|
||||
//}
|
||||
|
||||
_logInfo.Debug($"作业Id:{workId}-----单据:MO21,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}");
|
||||
_logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:查询,对接账套:{cAccId},条件:{input.ToJson()}");
|
||||
|
||||
if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin))
|
||||
{
|
||||
@@ -70,30 +68,122 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
_cache.Set($"U8_{cAccId}", baseLogin);
|
||||
}
|
||||
|
||||
var vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cCardNum);
|
||||
|
||||
if (vouchers == null)
|
||||
{
|
||||
throw new Exception("未能获取到单据配置信息");
|
||||
}
|
||||
|
||||
var db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
DbType = DbType.SqlServer,
|
||||
ConfigId = cAccId,
|
||||
ConnectionString = baseLogin.UFDataConnstringForNet
|
||||
ConnectionString = baseLogin.UFDataConnstringForNet,
|
||||
IsAutoCloseConnection = true,
|
||||
MoreSettings = new ConnMoreSettings()
|
||||
{
|
||||
IsWithNoLockQuery = true
|
||||
}
|
||||
});
|
||||
|
||||
var mo21Txt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/MO21.json"));
|
||||
var cBTTblName = vouchers.cBTTblName;
|
||||
var cBWTblName = vouchers.cBWTblName;
|
||||
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;
|
||||
|
||||
var mo21s = mo21Txt.ToObject<List<QuerySelect>>();
|
||||
|
||||
var query = db.Queryable<dynamic>().AS("v_mom_order_wf", "v_mom_order_wf")
|
||||
.AddJoinInfo("v_mom_orderdetail_wf", "v_mom_orderdetail_wf", "v_mom_order_wf.MoId=v_mom_orderdetail_wf.MoId");
|
||||
|
||||
if (db.DbMaintenance.IsAnyTable("mom_order_extradefine", false))
|
||||
if (cCardPostion == "H")
|
||||
{
|
||||
query.AddJoinInfo("mom_order_extradefine", "mom_order_extradefine",
|
||||
"v_mom_order_wf.MoId=mom_order_extradefine.MoId");
|
||||
tableName = cBTTblName;
|
||||
}
|
||||
|
||||
if (db.DbMaintenance.IsAnyTable("mom_orderdetail_extradefine", false))
|
||||
if (cCardPostion == "B")
|
||||
{
|
||||
query.AddJoinInfo("mom_orderdetail_extradefine", "mom_order_extradefine",
|
||||
"v_mom_orderdetail_wf.MoDId=mom_orderdetail_extradefine.MoDId");
|
||||
tableName = cBWTblName;
|
||||
}
|
||||
|
||||
if (cCardPostion == "L")
|
||||
{
|
||||
tableName = cBWTblName;
|
||||
}
|
||||
|
||||
var cDefWhere = vouchers.cDefWhere;
|
||||
|
||||
var query = db.Queryable<dynamic>().AS(cBTTblName, cBTTblName);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(cBWTblName))
|
||||
{
|
||||
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()}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var headCols = db.DbMaintenance.GetColumnInfosByTableName(cBTTblName);
|
||||
|
||||
if (headCols != null && headCols.Count > 0)
|
||||
{
|
||||
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}]");
|
||||
}
|
||||
|
||||
if (input != null)
|
||||
@@ -102,56 +192,30 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
|
||||
foreach (var o in input)
|
||||
{
|
||||
if (o.Key == "MoId" && input.ContainsKey($"{o.Key}__2"))
|
||||
if (o.Key == "dModifyDate")
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = "v_mom_order_wf.MoId",
|
||||
FieldName = "RelsTime",
|
||||
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
else if (o.Key == "MoId")
|
||||
else if (o.Key == "dModifyDate__2")
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = "v_mom_order_wf.MoId",
|
||||
ConditionalType = ConditionalType.Equal,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
else if (o.Key == "MoId__2")
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = "v_mom_order_wf.MoId",
|
||||
FieldName = "RelsTime",
|
||||
ConditionalType = ConditionalType.LessThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}else if (o.Key == "MoDId" && input.ContainsKey($"{o.Key}__2"))
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = "v_mom_orderdetail_wf.MoDId",
|
||||
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
else if (o.Key == "MoDId")
|
||||
else if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = "v_mom_orderdetail_wf.MoDId",
|
||||
ConditionalType = ConditionalType.Equal,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
else if (o.Key == "MoDId__2")
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = "v_mom_orderdetail_wf.MoDId",
|
||||
ConditionalType = ConditionalType.LessThanOrEqual,
|
||||
FieldName = $"{o.Key}",
|
||||
ConditionalType = ConditionalType.Like,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
@@ -187,193 +251,54 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
query.Where(conModels);
|
||||
}
|
||||
|
||||
if (mo21s != null && mo21s.Count > 0)
|
||||
query.Where(cDefWhere);
|
||||
|
||||
if (cCardPostion == "H")
|
||||
{
|
||||
var selector = new List<SelectModel>();
|
||||
|
||||
foreach (var mo21 in mo21s)
|
||||
if (bExtHead)
|
||||
{
|
||||
var model = new SelectModel() { FieldName = $"{mo21.TableName}.{mo21.FieldName}" };
|
||||
|
||||
if (mo21.AsName != null && !string.IsNullOrWhiteSpace(mo21.AsName))
|
||||
{
|
||||
model.AsName = mo21.AsName;
|
||||
}
|
||||
|
||||
selector.Add(model);
|
||||
query.Select($"{string.Join(",", colsHeadList)}").Distinct();
|
||||
}
|
||||
else
|
||||
{
|
||||
query.Select($"{string.Join(",", colsHeadList)}").Distinct();
|
||||
}
|
||||
|
||||
query.Select(selector);
|
||||
}
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_logInfo.Debug(query.ToSqlString());
|
||||
|
||||
return new BaseResult<dynamic>() { bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
||||
|
||||
await Task.Delay(1);
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询生产订单子件用料表
|
||||
/// </summary>
|
||||
/// <param name="cAccId"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/U8/MO/MO2101/Load")]
|
||||
public async Task<BaseResult<dynamic>> MO2101_Load(string cAccId, [FromBody] Dictionary<string, object> input)
|
||||
{
|
||||
var workId = SnowFlakeSingle.Instance.NextId();
|
||||
|
||||
try
|
||||
{
|
||||
//var userToken = Request.Headers.GetValues("userToken").First();
|
||||
|
||||
//if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386")
|
||||
//{
|
||||
// throw new Exception("调用信息不正确,请确认参数");
|
||||
//}
|
||||
|
||||
_logInfo.Debug($"作业Id:{workId}-----单据:MO2101,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}");
|
||||
|
||||
|
||||
if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin))
|
||||
{
|
||||
_logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建");
|
||||
|
||||
baseLogin = new BaseLogin();
|
||||
|
||||
var param = await CommUnit.GetLoginParamter(cAccId);
|
||||
|
||||
if (param == null)
|
||||
{
|
||||
throw new Exception("未能加载指定系统号的登录信息");
|
||||
}
|
||||
|
||||
baseLogin.Init(param, false);
|
||||
|
||||
_cache.Clear();
|
||||
|
||||
_cache.Set($"U8_{cAccId}", baseLogin);
|
||||
}
|
||||
|
||||
var db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
DbType = DbType.SqlServer,
|
||||
ConfigId = cAccId,
|
||||
ConnectionString = baseLogin.UFDataConnstringForNet
|
||||
});
|
||||
|
||||
var mo2101Txt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/MO2101.json"));
|
||||
|
||||
var mo2101s = mo2101Txt.ToObject<List<QuerySelect>>();
|
||||
|
||||
var query = db.Queryable<dynamic>().AS("mom_moallocate", "mom_moallocate");
|
||||
|
||||
if (db.DbMaintenance.IsAnyTable("mom_moallocate_extradefine", false))
|
||||
{
|
||||
query.AddJoinInfo("mom_moallocate_extradefine", "mom_moallocate_extradefinemom_moallocate_extradefine",
|
||||
"om_moallocate.AllocateId=mom_moallocate_extradefine.AllocateId");
|
||||
}
|
||||
|
||||
if (input != null)
|
||||
{
|
||||
var conModels = new List<IConditionalModel>();
|
||||
|
||||
foreach (var o in input)
|
||||
{
|
||||
if (o.Key == "AllocateId" && input.ContainsKey($"{o.Key}__2"))
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = "mom_moallocate.AllocateId",
|
||||
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
else if (o.Key == "AllocateId")
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = "mom_moallocate.AllocateId",
|
||||
ConditionalType = ConditionalType.Equal,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
else if (o.Key == "AllocateId__2")
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = "mom_moallocate.AllocateId",
|
||||
ConditionalType = ConditionalType.LessThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
else if (o.Key.EndsWith("__2"))
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{o.Key.Replace("__2", "")}",
|
||||
ConditionalType = ConditionalType.LessThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
else if (input.ContainsKey($"{o.Key}__2"))
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = $"{o.Key}",
|
||||
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
conModels.Add(new ConditionalModel
|
||||
{
|
||||
FieldName = o.Key,
|
||||
ConditionalType = ConditionalType.Equal,
|
||||
FieldValue = $"{o.Value}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
query.Where(conModels);
|
||||
}
|
||||
|
||||
if (mo2101s != null && mo2101s.Count > 0)
|
||||
{
|
||||
var selector = new List<SelectModel>();
|
||||
|
||||
foreach (var mo2101 in mo2101s)
|
||||
{
|
||||
var model = new SelectModel() { FieldName = $"{mo2101.TableName}.{mo2101.FieldName}" };
|
||||
|
||||
if (mo2101.AsName != null && !string.IsNullOrWhiteSpace(mo2101.AsName))
|
||||
{
|
||||
model.AsName = mo2101.AsName;
|
||||
}
|
||||
|
||||
selector.Add(model);
|
||||
}
|
||||
|
||||
query.Select(selector);
|
||||
}
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
||||
|
||||
await Task.Delay(1);
|
||||
_logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user