128 lines
4.0 KiB
C#
128 lines
4.0 KiB
C#
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;
|
|
|
|
|
|
namespace DOAN.Service.MES.base_
|
|
{
|
|
/// <summary>
|
|
/// 物料清单Service业务层处理
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IBaseMaterialBOMService), ServiceLifetime = LifeTime.Transient)]
|
|
public class BaseMaterialBOMService : BaseService<BaseMaterialList>, IBaseMaterialBOMService
|
|
{
|
|
/// <summary>
|
|
/// 查询物料清单列表
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<BaseMaterialListDto> GetList(BaseMaterialListQueryDto2 parm)
|
|
{
|
|
var predicate = Expressionable.Create<BaseMaterialList>();
|
|
|
|
var response = Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.ToPage<BaseMaterialList, BaseMaterialListDto>(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)
|
|
{
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取bom结构
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public List<BaseMaterialListDto> Achieve_BOM(string id)
|
|
{
|
|
var query1 = Context.Queryable<BaseMaterialBom>().Where(it => it.FkParentId == id);
|
|
return Context.Queryable(query1).LeftJoin<BaseMaterialList>((q, m) => q.FkId == m.Id)
|
|
.Select((q, m) => m)
|
|
.Adapt<List<BaseMaterialListDto>>()
|
|
;
|
|
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除绑定关系
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public int DeleteBOMBind(string id, string parent_id)
|
|
{
|
|
return Context.Deleteable<BaseMaterialBom>().Where(it => it.FkId == id)
|
|
.Where(it => it.FkParentId == parent_id)
|
|
.ExecuteCommand();
|
|
}
|
|
}
|
|
} |