提交
This commit is contained in:
123
DOAN.Service/MES/Base/BaseMaterialListService.cs
Normal file
123
DOAN.Service/MES/Base/BaseMaterialListService.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.MES.base_.Dto;
|
||||
using DOAN.Model.MES.base_;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.MES.base_.IService;
|
||||
using System.Linq;
|
||||
using Mapster;
|
||||
|
||||
using System.Buffers;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DOAN.Service.MES.base_
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料清单Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IBaseMaterialListService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class BaseMaterialListService : BaseService<BaseMaterialList>, IBaseMaterialListService
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询物料清单列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<BaseMaterialListDto2> GetList(BaseMaterialListQueryDto parm)
|
||||
{
|
||||
|
||||
|
||||
var predicate = Expressionable.Create<BaseMaterialList>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name.Contains(parm.Name))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.Code), it => it.Code.Contains (parm.Code))
|
||||
|
||||
.AndIF(!string.IsNullOrEmpty(parm.FkMaterialTypeCode) , it => it.FkMaterialTypeCode.Contains(parm.FkMaterialTypeCode))
|
||||
|
||||
.AndIF(parm.TimeRange != null && parm.TimeRange.Length == 2 && parm.TimeRange[0] > DateTime.MinValue, it => it.CreatedTime >= parm.TimeRange[0])
|
||||
.AndIF(parm.TimeRange != null && parm.TimeRange.Length == 2 && parm.TimeRange[1] > DateTime.MinValue, it => it.CreatedTime <= parm.TimeRange[1]);
|
||||
|
||||
var query01 = Queryable()
|
||||
|
||||
.Where(predicate.ToExpression());
|
||||
|
||||
var response = Context.Queryable(query01).LeftJoin<BaseMaterialType>((q, t) => q.FkMaterialTypeCode == t.Code)
|
||||
// .LeftJoin<BaseSupplier>((q, t, s) => q.FkSupplierId == s.Id)
|
||||
.Select((q, t) => new BaseMaterialListDto2
|
||||
{
|
||||
|
||||
FkMaterialTypeName = t.Name,
|
||||
FkMaterialTypeCode = t.Code,
|
||||
|
||||
|
||||
}, true).ToPage<BaseMaterialListDto2, BaseMaterialListDto2>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public BaseMaterialList GetInfo(string Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加物料清单
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public BaseMaterialList AddBaseMaterialList(BaseMaterialList model)
|
||||
{
|
||||
model.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改物料清单
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateBaseMaterialList(BaseMaterialList model)
|
||||
{
|
||||
//var response = Update(w => w.Id == model.Id, it => new BaseMaterialList()
|
||||
//{
|
||||
// Name = model.Name,
|
||||
// Code = model.Code,
|
||||
// Customer code = model.Customer code,
|
||||
// Color = model.Color,
|
||||
// Specification = model.Specification,
|
||||
// Unit = model.Unit,
|
||||
// Description = model.Description,
|
||||
// ExpirationUnit = model.ExpirationUnit,
|
||||
// ExpirationDate = model.ExpirationDate,
|
||||
// ShelfLifeWarningDays = model.ShelfLifeWarningDays,
|
||||
// IsShelfLife = model.IsShelfLife,
|
||||
// StartTime = model.StartTime,
|
||||
// StopTime = model.StopTime,
|
||||
// BarCode = model.BarCode,
|
||||
// IsBatch = model.IsBatch,
|
||||
// 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