根据类型获取往来单位下拉及业务信息列表 修改

dev
cjy 1 month ago
parent 7e7df62599
commit 574bd2d263

@ -1,6 +1,7 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Enums;
using LanguageExt.TypeClasses;
using SqlSugar;
namespace DS.WMS.Core.Info.Entity;
@ -460,9 +461,16 @@ public class InfoClient : SharedOrgModel<long>
[Navigate(NavigateType.OneToMany, nameof(InfoClientContact.ClientId))]
public List<InfoClientContact>? Contacts { get; set; }
/// <summary>
/// 干系人列表
/// </summary>
//[SqlSugar.SugarColumn(IsIgnore = true)]
[Navigate(NavigateType.OneToMany, nameof(InfoClientStakeholder.ClientId))]
public List<InfoClientStakeholder>? Stakeholders { get; set; }
/// <summary>
/// 干系人列表
/// </summary>
[SqlSugar.SugarColumn(IsIgnore = true)]
public List<long> UserIds { get; set; }
public List<long>? UserIds { get; set; }
}

@ -106,7 +106,7 @@ public interface IClientCommonService
/// 根据类型获取往来单位下拉及业务信息列表
/// </summary>
/// <returns></returns>
public DataResult<ClientSelectInfoRes> GetClientSelectInfoByCode(ClientSelectInfoReq req);
public Task<DataResult<ClientSelectInfoRes>> GetClientSelectInfoByCode(ClientSelectInfoReq req);
/// <summary>
/// 获取往来单位下拉集合列表
/// </summary>

@ -22,6 +22,7 @@ using Masuit.Tools;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System.Linq;
namespace DS.WMS.Core.Sys.Method;
@ -186,7 +187,11 @@ public class ClientCommonService : IClientCommonService
var orglist = db.Queryable<SysOrg>().ToList();
//var query = tenantDb.Queryable<InfoClient>()
var contacts = await tenantDb.Queryable<InfoClientContact>().Where(x => x.Status == StatusEnum.Enable && x.IsDefault == true)
.Select<ClientContactRes>().ToListAsync();
//var query = tenantDb.Queryable<InfoClient>()//.Includes(a=>a.Stakeholders)
// .InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
// .Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsController == true)
// .WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey) || a.Description.Contains(queryKey))
@ -194,17 +199,19 @@ public class ClientCommonService : IClientCommonService
// {
// Id = a.Id,
// PinYinCode = a.ShortName + "(" + a.CodeName + ")",
// //UserIds = SqlFunc.MappingColumn<string>(sql)
// //UserIds = a.Stakeholders.Where(c => c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now).Select(n=>n.CreateBy).ToList()
// //UserIds = SqlFunc.Subqueryable<InfoClientStakeholder>().Where(c => c.ClientId == a.Id && c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now).ToList(it=>it.CreateBy)
// //SaleOrgName = string.IsNullOrEmpty(a.SaleOrgId) ? "": orglist.Where(x=>x.Id == long.Parse(a.SaleOrgId)).FirstOrDefault().OrgName
// }, true
// )
// .Mapper(it =>
// {
// it.ClientContact = tenantDb.Queryable<InfoClientContact>().Where(x => x.ClientId == it.Id && x.Status == StatusEnum.Enable && x.IsDefault == true)
// .Select<ClientContactRes>().First();
// it.UserIds = SqlFunc.Subqueryable<InfoClientStakeholder>().Where(c => c.ClientId == it.Id && c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now).ToList(n => n.CreateBy);
// //it.ClientContact = tenantDb.Queryable<InfoClientContact>().Where(x => x.ClientId == it.Id && x.Status == StatusEnum.Enable && x.IsDefault == true).Select<ClientContactRes>().First();
// //it.ClientContact = contacts.Where(x => x.ClientId == it.Id).FirstOrDefault();
// //it.UserIds = tenantDb.Queryable<InfoClientStakeholder>().Where(c => c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now && c.ClientId == it.Id).Select(n => n.CreateBy).ToList();
// });
//(query, _) = await commonService.GetVisibleDataRuleFilter<ControllerClientRes>(query,tenantDb);
//(query, _) = await commonService.GetVisibleDataRuleFilter<ControllerClientRes>(query, tenantDb);
//var data = await query
// .Take(20).WithCache($"{SqlSugarCacheConst.InfoClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync();
var data = await tenantDb.Queryable<InfoClient>()
@ -453,12 +460,21 @@ public class ClientCommonService : IClientCommonService
/// 根据类型获取往来单位下拉及业务信息列表
/// </summary>
/// <returns></returns>
public DataResult<ClientSelectInfoRes> GetClientSelectInfoByCode(ClientSelectInfoReq req)
public async Task<DataResult<ClientSelectInfoRes>> GetClientSelectInfoByCode(ClientSelectInfoReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//var data = new ClientSelectInfoRes();
var code = req.Code.ToLower();
var list = tenantDb.Queryable<InfoClient>()
var contacts = await tenantDb.Queryable<InfoClientContact>().Where(x => x.Status == StatusEnum.Enable && x.IsDefault == true).Select<ClientContactRes>().ToListAsync();
var code = req.Code.ToLower();
if (req.BusinessType == BusinessType.OceanShippingExport)
{
var info = tenantDb.Queryable<SeaExport>().First(x => x.Id == req.BusinessId);
if (info.IsNull())
{
return DataResult<ClientSelectInfoRes>.Failed("业务信息不存在!");
}
var list = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt())
//.WhereIF(code == "carrier", (a, b) => b.IsCarrier == true)
@ -492,27 +508,20 @@ public class ClientCommonService : IClientCommonService
BLContent = a.BLContent,
}
)
.Mapper(it =>
{
it.ClientContact = tenantDb.Queryable<InfoClientContact>().Where(x => x.ClientId == it.Id && x.Status == StatusEnum.Enable && x.IsDefault == true)
.Select<ClientContactRes>().First();
}).ToList();
if (req.BusinessType == BusinessType.OceanShippingExport)
{
var info = tenantDb.Queryable<SeaExport>().First(x => x.Id == req.BusinessId);
if (info.IsNull())
{
return DataResult<ClientSelectInfoRes>.Failed("业务信息不存在!");
}
//.Mapper(it =>
//{
// //it.ClientContact = tenantDb.Queryable<InfoClientContact>().Where(x => x.ClientId == it.Id && x.Status == StatusEnum.Enable && x.IsDefault == true)
// //.Select<ClientContactRes>().First();
// it.ClientContact = contacts.Where(x => x.ClientId == it.Id).FirstOrDefault();
//})
.ToListAsync();
var data = GetSeaExportClientInfo(info, code);
data.ClientList = list;
return DataResult<ClientSelectInfoRes>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
return await Task.FromResult(DataResult<ClientSelectInfoRes>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess));
}
else
{
return DataResult<ClientSelectInfoRes>.Failed("非法业务类型");
return await Task.FromResult(DataResult<ClientSelectInfoRes>.Failed("非法业务类型"));
}
}

@ -227,9 +227,9 @@ public class ClientCommonController : ApiController
/// <returns></returns>
[HttpPost]
[Route("GetClientSelectInfoByCode")]
public DataResult<ClientSelectInfoRes> GetClientSelectInfoByCode([FromBody] ClientSelectInfoReq req)
public async Task<DataResult<ClientSelectInfoRes>> GetClientSelectInfoByCode([FromBody] ClientSelectInfoReq req)
{
var res = _invokeService.GetClientSelectInfoByCode(req);
var res = await _invokeService.GetClientSelectInfoByCode(req);
return res;
}

Loading…
Cancel
Save