提交
This commit is contained in:
158
DOAN.Service/MES/Base/BaseMaterialBomService.cs
Normal file
158
DOAN.Service/MES/Base/BaseMaterialBomService.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.Dto;
|
||||
using DOAN.Model.MES.base_;
|
||||
using DOAN.Model.MES.base_.Dto;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.MES.base_.IService;
|
||||
|
||||
using System.Linq;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Mapster;
|
||||
using System.Xml.Linq;
|
||||
using static Org.BouncyCastle.Crypto.Engines.SM2Engine;
|
||||
using Infrastructure.Model;
|
||||
using Aliyun.OSS;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using MathNet.Numerics.Distributions;
|
||||
|
||||
|
||||
namespace DOAN.Service.MES.base_
|
||||
{
|
||||
/// <summary>
|
||||
/// Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IBaseMaterialBomService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class BaseMaterialBomService : BaseService<BaseMaterialBom>, IBaseMaterialBomService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<BaseMaterialBomDto> GetList(BaseMaterialBomQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<BaseMaterialBom>();
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<BaseMaterialBom, BaseMaterialBomDto>(parm);
|
||||
//Context.Queryable<BaseMaterialBom>().Where(predicate.ToExpression()).ToTree(it => it.Child, it => it.InvCode, 0, it => it.Id)
|
||||
|
||||
|
||||
//var response = Context.Queryable<BaseMaterialBom>()
|
||||
// .Where(predicate.ToExpression())
|
||||
// .Includes(x => x.Child).ToList();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取母件BOM清单
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<BaseMaterialBomDto> GetMonterInvList(BaseMaterialBomQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<BaseMaterialBom>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.InvCode),it=>it.InvCode.Contains(parm.InvCode))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.SubInvCode),it=>it.SubInvCode.Contains(parm.SubInvCode))
|
||||
;
|
||||
|
||||
var query = Context.Queryable<BaseMaterialBom>()
|
||||
.Where(predicate.ToExpression())
|
||||
.GroupBy(it => it.InvCode)
|
||||
.Select(it => new BaseMaterialBomDto()
|
||||
{
|
||||
|
||||
Id = SqlFunc.AggregateMax(it.Id),
|
||||
InvCode = SqlFunc.AggregateMax(it.InvCode),
|
||||
InvName = SqlFunc.AggregateMax(it.InvName),
|
||||
SubInvName = SqlFunc.AggregateMax(it.SubInvName),
|
||||
Iusequantity = SqlFunc.AggregateMax(it.Iusequantity),
|
||||
BOMVersion = SqlFunc.AggregateMax(it.BOMVersion),
|
||||
CreatedBy = SqlFunc.AggregateMax(it.CreatedBy),
|
||||
CreatedTime = SqlFunc.AggregateMax(it.CreatedTime),
|
||||
UpdatedBy = SqlFunc.AggregateMax(it.UpdatedBy),
|
||||
UpdatedTime = SqlFunc.AggregateMax(it.UpdatedTime)
|
||||
|
||||
|
||||
});
|
||||
var response = query.ToPage<BaseMaterialBomDto, BaseMaterialBomDto>(parm);
|
||||
|
||||
|
||||
return response;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取子件
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public List<BaseMaterialBom> GetSonInvList(BaseMaterialBomQueryDto parm)
|
||||
{
|
||||
return Context.Queryable<BaseMaterialBom>().Where(it => it.InvCode == parm.InvCode).ToList();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public BaseMaterialBom GetInfo(string Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public BaseMaterialBom AddBaseMaterialBom(BaseMaterialBom model)
|
||||
{
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateBaseMaterialBom(BaseMaterialBom model)
|
||||
{
|
||||
//var response = Update(w => w.Id == model.Id, it => new BaseMaterialBom()
|
||||
//{
|
||||
// InvCode = model.InvCode,
|
||||
// InvName = model.InvName,
|
||||
// SubInvCode = model.SubInvCode,
|
||||
// SubcInvName = model.SubcInvName,
|
||||
// Iusequantity = model.Iusequantity,
|
||||
// BOMVersion = model.BOMVersion,
|
||||
// CreatedBy = model.CreatedBy,
|
||||
// CreatedTime = model.CreatedTime,
|
||||
// UpdatedBy = model.UpdatedBy,
|
||||
// UpdatedTime = model.UpdatedTime,
|
||||
//});
|
||||
//return response;
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user