This commit is contained in:
yang.lee
2023-11-16 16:21:49 +08:00
4 changed files with 26 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
using Aop.Api.Domain;
using JNPF.Common.Core.Manager; using JNPF.Common.Core.Manager;
using JNPF.Common.Enums; using JNPF.Common.Enums;
using JNPF.Common.Filter; using JNPF.Common.Filter;
@@ -167,15 +168,21 @@ namespace Tnb.BasicData
public async Task<dynamic> GetMaterialByType(Dictionary<string, string> dic) public async Task<dynamic> GetMaterialByType(Dictionary<string, string> dic)
{ {
string types = dic["types"]; string types = dic["types"];
int currentPage = int.Parse(dic["currentPage"].ToString());
int pagesize = int.Parse(dic["pageSize"].ToString());
string queryJson = dic["queryJson"];
string[] typeArr = types.Split(","); string[] typeArr = types.Split(",");
List<BasMaterial> list = await _repository.AsSugarClient().Queryable<BasMaterial>().Where(x => x.state == "1").ToListAsync(); List<BasMaterial> list = await _repository.AsSugarClient().Queryable<BasMaterial>().Where(x => x.state == "1").ToListAsync();
List<BasMaterial> result = new(); List<string> ids = new();
foreach (string type in typeArr) foreach (string type in typeArr)
{ {
result.AddRange(list.Where(x => x.category_id.Contains(type))); ids.AddRange(list.Where(x => x.category_id.Contains(type)).Select(p => p.id));
} }
SqlSugarPagedList<BasMaterial> result = await _repository.AsSugarClient().Queryable<BasMaterial>()
return result; .WhereIF(ids.Count > 0, a => ids.Contains(a.id))
.WhereIF(!string.IsNullOrEmpty(queryJson), a => a.name.Contains(queryJson) || a.code.Contains(queryJson))
.Select(a => a).ToPagedListAsync(currentPage, pagesize);
return PageResult<BasMaterial>.SqlSugarPageResult(result);
} }
[HttpPost] [HttpPost]

View File

@@ -1,5 +1,6 @@
using JNPF.Common.Core.Manager; using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Filter;
using JNPF.DependencyInjection; using JNPF.DependencyInjection;
using JNPF.DynamicApiController; using JNPF.DynamicApiController;
using JNPF.Extras.CollectiveOAuth.Models; using JNPF.Extras.CollectiveOAuth.Models;
@@ -10,6 +11,8 @@ using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
using JNPF.VisualDev.Interfaces; using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Crypto;
using Spire.Doc.Documents;
using SqlSugar; using SqlSugar;
using Tnb.BasicData; using Tnb.BasicData;
using Tnb.BasicData.Entities; using Tnb.BasicData.Entities;
@@ -161,8 +164,14 @@ namespace Tnb.EquipMgr
{ {
string typeIds = dic["typeIds"]; string typeIds = dic["typeIds"];
string[] typeIdArr = typeIds.Split(","); string[] typeIdArr = typeIds.Split(",");
return await _repository.AsSugarClient().Queryable<EqpEquipment>().Where(x => typeIdArr.Contains(x.equip_type_id)) int currentPage = int.Parse(dic["currentPage"].ToString());
.ToListAsync(); int pagesize = int.Parse(dic["pageSize"].ToString());
string queryJson = dic["queryJson"];
SqlSugarPagedList<EqpEquipment> result = await _repository.AsSugarClient().Queryable<EqpEquipment>()
.WhereIF(typeIdArr.Length > 0, a => typeIdArr.Contains(a.equip_type_id))
.WhereIF(!string.IsNullOrEmpty(queryJson), a => a.name.Contains(queryJson) || a.code.Contains(queryJson))
.Select(a => a).ToPagedListAsync(currentPage, pagesize);
return PageResult<EqpEquipment>.SqlSugarPageResult(result);
} }
[HttpPost] [HttpPost]

View File

@@ -40,7 +40,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
/// </summary> /// </summary>
private async Task<Vmodel> GetVmodelAsync(string id) private async Task<Vmodel> GetVmodelAsync(string id)
{ {
if (_models.ContainsKey(id)) if (!_models.ContainsKey(id))
{ {
_models[id] = await _dataAccess.GetVmodelAsync(id, false); _models[id] = await _dataAccess.GetVmodelAsync(id, false);
} }
@@ -122,7 +122,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
private async Task<Vmodel> GetVmodelAsync(string areaCode, string vmCode) private async Task<Vmodel> GetVmodelAsync(string areaCode, string vmCode)
{ {
var key = areaCode + "/" + vmCode; var key = areaCode + "/" + vmCode;
if (_models.ContainsKey(key)) if (!_models.ContainsKey(key))
{ {
_models[key] = await _dataAccess.GetVmodelAsync(areaCode, vmCode, false); _models[key] = await _dataAccess.GetVmodelAsync(areaCode, vmCode, false);
} }

View File

@@ -57,7 +57,7 @@ public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGet
} }
if (!string.IsNullOrEmpty(id)) if (!string.IsNullOrEmpty(id))
{ {
if (_models.ContainsKey(id)) if (!_models.ContainsKey(id))
{ {
_models[id] = await _dataAccess.GetVmodelAsync(id, false); _models[id] = await _dataAccess.GetVmodelAsync(id, false);
//_models[_models[id].fullCode] = _models[id]; //_models[_models[id].fullCode] = _models[id];
@@ -76,7 +76,7 @@ public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGet
code = tp.Name.ToKebab(); code = tp.Name.ToKebab();
} }
var key = area + "/" + code; var key = area + "/" + code;
if (_models.ContainsKey(key)) if (!_models.ContainsKey(key))
{ {
_models[key] = await _dataAccess.GetVmodelAsync(area, code, false); _models[key] = await _dataAccess.GetVmodelAsync(area, code, false);
} }