1564 lines
62 KiB
C#
1564 lines
62 KiB
C#
using log4net;
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Http;
|
|
using UFIDA.U8.Framework.Api.ControlObject.Entity;
|
|
using UFIDA.U8.Framework.Api.ControlObject.Json;
|
|
using UFIDA.U8.Framework.Api.ControlObject.U8M;
|
|
using UFIDA.U8.Framework.Api.Entity;
|
|
using UFIDA.U8.Framework.Api.Unit;
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
namespace UFIDA.U8.Framework.Api.Controllers.U8
|
|
{
|
|
/// <summary>
|
|
/// 基础资料
|
|
/// </summary>
|
|
public class AAController : ApiController
|
|
{
|
|
/// <summary>
|
|
/// 日志组件
|
|
/// </summary>
|
|
private readonly ILog _logInfo = LogManager.GetLogger("logInfo");
|
|
|
|
private static readonly MemoryCache _cache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(10) });
|
|
|
|
/// <summary>
|
|
/// 查询存货档案
|
|
/// </summary>
|
|
/// <param name="cAccId"></param>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("api/U8/AA/Inventory/Load")]
|
|
public async Task<BaseResult<dynamic>> Inventory_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}-----档案:Inventory,操作:查询,对接账套:{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 inventoryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"App_Data/Inventory.json"));
|
|
|
|
var inventorys = inventoryTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer, ConfigId = cAccId, ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("Inventory", "Inventory")
|
|
.AddJoinInfo("Inventory_Sub", "Inventory_Sub", "Inventory.cInvCode=Inventory_Sub.cInvSubCode");
|
|
|
|
if (db.DbMaintenance.IsAnyTable("Inventory_extradefine", false))
|
|
{
|
|
query.AddJoinInfo("Inventory_extradefine", "Inventory_extradefine",
|
|
"Inventory.cInvCode=Inventory_extradefine.cInvCode");
|
|
}
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
FieldValue = $"{o.Value}"
|
|
});
|
|
}
|
|
else if (o.Key == "cInvCode" && input.ContainsKey($"{o.Key}__2"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = "Inventory.cInvCode",
|
|
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
|
FieldValue = $"{o.Value}"
|
|
});
|
|
}
|
|
else if (o.Key == "cInvCode")
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = "Inventory.cInvCode",
|
|
ConditionalType = ConditionalType.Equal,
|
|
FieldValue = $"{o.Value}"
|
|
});
|
|
}
|
|
else if (o.Key == "cInvCode__2")
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = "Inventory.cInvCode",
|
|
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 (inventorys != null && inventorys.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var inventory in inventorys)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{inventory.TableName}.{inventory.FieldName}" };
|
|
|
|
if (inventory.AsName != null && !string.IsNullOrWhiteSpace(inventory.AsName))
|
|
{
|
|
model.AsName = inventory.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
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/AA/ComputationUnit/Load")]
|
|
public async Task<BaseResult<dynamic>> ComputationUnit_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}-----档案:ComputationUnit,操作:查询,对接账套:{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 computationunitTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/ComputationUnit.json"));
|
|
|
|
var computationunits = computationunitTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("ComputationUnit", "ComputationUnit");
|
|
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
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 (computationunits != null && computationunits.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var computationunit in computationunits)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{computationunit.TableName}.{computationunit.FieldName}" };
|
|
|
|
if (computationunit.AsName != null && !string.IsNullOrWhiteSpace(computationunit.AsName))
|
|
{
|
|
model.AsName = computationunit.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
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/AA/Department/Load")]
|
|
public async Task<BaseResult<dynamic>> Department_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}-----档案:Department,操作:查询,对接账套:{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 departmentTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Department.json"));
|
|
|
|
var departments = departmentTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("Department", "Department");
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
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 (departments != null && departments.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var department in departments)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{department.TableName}.{department.FieldName}" };
|
|
|
|
if (department.AsName != null && !string.IsNullOrWhiteSpace(department.AsName))
|
|
{
|
|
model.AsName = department.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
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/AA/Warehouse/Load")]
|
|
public async Task<BaseResult<dynamic>> Warehouse_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}-----档案:Warehouse,操作:查询,对接账套:{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 warehouseTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Warehouse.json"));
|
|
|
|
var warehouses = warehouseTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("Warehouse", "Warehouse");
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
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 (warehouses != null && warehouses.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var warehouse in warehouses)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{warehouse.TableName}.{warehouse.FieldName}" };
|
|
|
|
if (warehouse.AsName != null && !string.IsNullOrWhiteSpace(warehouse.AsName))
|
|
{
|
|
model.AsName = warehouse.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
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/AA/InventoryClass/Load")]
|
|
public async Task<BaseResult<dynamic>> InventoryClass_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}-----档案:InventoryClass,操作:查询,对接账套:{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 inventoryclassTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/InventoryClass.json"));
|
|
|
|
var inventoryclasss = inventoryclassTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("InventoryClass", "InventoryClass");
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
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 (inventoryclasss != null && inventoryclasss.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var inventoryclass in inventoryclasss)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{inventoryclass.TableName}.{inventoryclass.FieldName}" };
|
|
|
|
if (inventoryclass.AsName != null && !string.IsNullOrWhiteSpace(inventoryclass.AsName))
|
|
{
|
|
model.AsName = inventoryclass.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
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/AA/Vendor/Load")]
|
|
public async Task<BaseResult<dynamic>> Vendor_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}-----档案:Vendor,操作:查询,对接账套:{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 vendorTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Vendor.json"));
|
|
|
|
var vendors = vendorTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("Vendor", "Vendor");
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
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 (vendors != null && vendors.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var vendor in vendors)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{vendor.TableName}.{vendor.FieldName}" };
|
|
|
|
if (vendor.AsName != null && !string.IsNullOrWhiteSpace(vendor.AsName))
|
|
{
|
|
model.AsName = vendor.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
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/AA/VendorClass/Load")]
|
|
public async Task<BaseResult<dynamic>> VendorClass_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}-----档案:VendorClass,操作:查询,对接账套:{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 queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/VendorClass.json"));
|
|
|
|
var querys = queryTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("VendorClass", "VendorClass");
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
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 (querys != null && querys.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var q in querys)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" };
|
|
|
|
if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName))
|
|
{
|
|
model.AsName = q.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
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/AA/Customer/Load")]
|
|
public async Task<BaseResult<dynamic>> Customer_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}-----档案:Customer,操作:查询,对接账套:{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 queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Customer.json"));
|
|
|
|
var querys = queryTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("Customer", "Customer");
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
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 (querys != null && querys.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var q in querys)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" };
|
|
|
|
if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName))
|
|
{
|
|
model.AsName = q.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
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/AA/CustomerClass/Load")]
|
|
public async Task<BaseResult<dynamic>> CustomerClass_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}-----档案:CustomerClass,操作:查询,对接账套:{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 queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/CustomerClass.json"));
|
|
|
|
var querys = queryTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("CustomerClass", "CustomerClass");
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
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 (querys != null && querys.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var q in querys)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" };
|
|
|
|
if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName))
|
|
{
|
|
model.AsName = q.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
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/AA/Person/Load")]
|
|
public async Task<BaseResult<dynamic>> Person_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}-----档案:CustomerClass,操作:查询,对接账套:{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 queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Person.json"));
|
|
|
|
var querys = queryTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("hr_hi_person", "hr_hi_person");
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
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 (querys != null && querys.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var q in querys)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" };
|
|
|
|
if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName))
|
|
{
|
|
model.AsName = q.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
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/AA/Operation/Load")]
|
|
public async Task<BaseResult<dynamic>> Operation_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}-----档案:Operation,操作:查询,对接账套:{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 queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Operation.json"));
|
|
|
|
var querys = queryTxt.ToObject<List<QuerySelect>>();
|
|
|
|
var db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
DbType = DbType.SqlServer,
|
|
ConfigId = cAccId,
|
|
ConnectionString = baseLogin.UFDataConnstringForNet
|
|
});
|
|
|
|
var query = db.Queryable<dynamic>().AS("sfc_operation", "sfc_operation");
|
|
|
|
if (input != null)
|
|
{
|
|
var conModels = new List<IConditionalModel>();
|
|
|
|
foreach (var o in input)
|
|
{
|
|
if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%"))
|
|
{
|
|
conModels.Add(new ConditionalModel
|
|
{
|
|
FieldName = $"{o.Key}",
|
|
ConditionalType = ConditionalType.Like,
|
|
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 (querys != null && querys.Count > 0)
|
|
{
|
|
var selector = new List<SelectModel>();
|
|
|
|
foreach (var q in querys)
|
|
{
|
|
var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" };
|
|
|
|
if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName))
|
|
{
|
|
model.AsName = q.AsName;
|
|
}
|
|
|
|
selector.Add(model);
|
|
}
|
|
|
|
query.Select(selector);
|
|
}
|
|
|
|
_logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}");
|
|
|
|
return new BaseResult<dynamic>
|
|
{ bSuccess = true, message = "查询成功", result = await query.ToListAsync() };
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
|
|
|
|
return new BaseResult<dynamic> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|