137 lines
4.5 KiB
C#
137 lines
4.5 KiB
C#
using Infrastructure.Attribute;
|
|
using Infrastructure.Extensions;
|
|
using DOAN.Model.PBL.Dto;
|
|
using DOAN.Model.PBL;
|
|
using DOAN.Repository;
|
|
using DOAN.Service.PBL.IService;
|
|
|
|
|
|
namespace DOAN.Service.PBL
|
|
{
|
|
/// <summary>
|
|
/// 料架表Service业务层处理
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IStoragelocationService), ServiceLifetime = LifeTime.Transient)]
|
|
public class StoragelocationService : BaseService<Storagelocation>, IStoragelocationService
|
|
{
|
|
/// <summary>
|
|
/// 查询料架表列表
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<StoragelocationDto> GetList(StoragelocationQueryDto parm)
|
|
{
|
|
var predicate = QueryExp(parm);
|
|
|
|
var response = Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.ToPage<Storagelocation, StoragelocationDto>(parm);
|
|
|
|
return response;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取详情
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
/// <returns></returns>
|
|
public Storagelocation GetInfo(int Id)
|
|
{
|
|
var response = Queryable()
|
|
.Where(x => x.Id == Id)
|
|
.First();
|
|
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加料架表
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public Storagelocation AddStoragelocation(Storagelocation model)
|
|
{
|
|
return Insertable(model).ExecuteReturnEntity();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改料架表
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public int UpdateStoragelocation(Storagelocation model)
|
|
{
|
|
return Update(model, true);
|
|
}
|
|
|
|
public List<StoragelocationPartNumberGroupDto> GetPartNumberList()
|
|
{
|
|
var response = Queryable()
|
|
.GroupBy(it=>it.Partnumber)
|
|
.Select(it=>new StoragelocationPartNumberGroupDto()
|
|
{
|
|
RackCode = SqlFunc.AggregateMax(it.RackCode),
|
|
Partnumber = SqlFunc.AggregateMax( it.Partnumber),
|
|
PackageNum = SqlFunc.AggregateSum(it.PackageNum) ?? 0
|
|
})
|
|
.OrderBy(it => it.RackCode)
|
|
.ToList();
|
|
return response;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 查询导出表达式
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
private static Expressionable<Storagelocation> QueryExp(StoragelocationQueryDto parm)
|
|
{
|
|
var predicate = Expressionable.Create<Storagelocation>()
|
|
.AndIF(!string.IsNullOrEmpty(parm.Partnumber),it=>it.Partnumber.Contains( parm.Partnumber))
|
|
.AndIF(!string.IsNullOrEmpty(parm.RackCode),it=>it.RackCode.Contains( parm.RackCode))
|
|
;
|
|
|
|
return predicate;
|
|
}
|
|
|
|
public List<SelectOptionsDto> GetRackCodeOptions()
|
|
{
|
|
var response = Queryable()
|
|
.GroupBy(it => it.RackCode)
|
|
.OrderBy(it => it.RackCode)
|
|
.Select(it => new SelectOptionsDto()
|
|
{
|
|
Key = SqlFunc.AggregateMax(it.Id).ToString(),
|
|
Label = SqlFunc.AggregateMax(it.RackCode),
|
|
Value = SqlFunc.AggregateMax(it.RackCode)
|
|
})
|
|
.OrderBy(it => it.Key)
|
|
.ToList();
|
|
return response;
|
|
}
|
|
|
|
public List<SelectOptionsDto> GetPartNumberOptions()
|
|
{
|
|
var response = Context.Queryable<Billofmaterials>()
|
|
.Select(it => new SelectOptionsDto()
|
|
{
|
|
Key = it.Id.ToString(),
|
|
Label = it.Productname + it.Productcode + " " + it.MirrorshellName + it.MirrorshellCode,
|
|
Value = it.MirrorshellCode
|
|
})
|
|
.OrderBy(it => it.Key)
|
|
.ToList();
|
|
return response;
|
|
}
|
|
|
|
public int UpdateRackPartNumber(string rackCode, int layerNum, string partnumber)
|
|
{
|
|
return Context.Updateable<Storagelocation>()
|
|
.SetColumns(it => it.Partnumber == partnumber )
|
|
.Where(it => it.RackCode == rackCode && it.LayerNum == layerNum)
|
|
.ExecuteCommand();
|
|
}
|
|
}
|
|
} |