Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
namespace Tnb.BasicData.Entities.Dto
|
||||
{
|
||||
public class MaterialQueryInput
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 查询条件
|
||||
/// </summary>
|
||||
public string queryJson { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 物料类型
|
||||
/// </summary>
|
||||
public string types { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 当前页码:pageIndex.
|
||||
/// </summary>
|
||||
public virtual int currentPage { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 每页行数.
|
||||
/// </summary>
|
||||
public virtual int pageSize { get; set; } = 50;
|
||||
}
|
||||
}
|
||||
@@ -25,5 +25,12 @@ namespace Tnb.BasicData.Interfaces
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetMaterialByType(Dictionary<string, string> dic);
|
||||
|
||||
/// <summary>
|
||||
/// 根据物料类型获取物料列表
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetMaterialByQueryJson(MaterialQueryInput input);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
@@ -174,6 +175,48 @@ namespace Tnb.BasicData
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetMaterialByQueryJson(MaterialQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, string>? queryJson = new Dictionary<string, string>();
|
||||
if (input!=null && !string.IsNullOrEmpty(input.queryJson))
|
||||
{
|
||||
queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input?.queryJson ?? "");
|
||||
}
|
||||
|
||||
List<string> typeList = new List<string>();
|
||||
if(!string.IsNullOrEmpty(input.types))
|
||||
{
|
||||
typeList = JsonConvert.DeserializeObject<List<string>>(input.types);
|
||||
}
|
||||
var query = db.Queryable<BasMaterial>()
|
||||
.Where(x => x.state == "1")
|
||||
.WhereIF(queryJson != null && queryJson.ContainsKey("name"), a => a.name.Contains(queryJson["name"]))
|
||||
.WhereIF(queryJson != null && queryJson.ContainsKey("code"), a => a.code.Contains(queryJson["code"]))
|
||||
.WhereIF(queryJson != null && queryJson.ContainsKey("material_standard"),
|
||||
a => a.material_standard.Contains(queryJson["material_standard"]))
|
||||
.Select(x => x);
|
||||
|
||||
var list = new List<ISugarQueryable<BasMaterial>>();
|
||||
foreach (var type in typeList)
|
||||
{
|
||||
list.Add(query.Clone().Where(x=>x.category_id.Contains(type)));
|
||||
}
|
||||
|
||||
if (list.Count <= 0)
|
||||
{
|
||||
var result = await query.ToPagedListAsync((input?.currentPage??1), (input?.pageSize??50));
|
||||
return PageResult<BasMaterial>.SqlSugarPageResult(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await db.UnionAll(list).Select<BasMaterial>().ToPagedListAsync((input?.currentPage??1), (input?.pageSize??50));
|
||||
return PageResult<BasMaterial>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料清单下所子集物料id
|
||||
|
||||
@@ -263,7 +263,9 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
tasks.Add(_carryService.UpdateNullCarry(carryIt));
|
||||
}
|
||||
await Task.WhenAll(tasks);
|
||||
var all = await Task.WhenAll(tasks);
|
||||
if (all.All(x => x > 0))
|
||||
isOk = all?.Length > 0;
|
||||
}
|
||||
}
|
||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||
|
||||
Reference in New Issue
Block a user