91 lines
2.9 KiB
C#
91 lines
2.9 KiB
C#
using System;
|
|
using SqlSugar;
|
|
using Infrastructure.Attribute;
|
|
|
|
using MDM.Services.IPlantService;
|
|
|
|
using MDM.Service;
|
|
using MDM.Model;
|
|
using MDM.Model.Plant;
|
|
using MDM.Model.Plant.Dto;
|
|
using MDM.Repository;
|
|
|
|
namespace MDM.Services.Plant
|
|
{
|
|
/// <summary>
|
|
/// 工厂/站点Service业务层处理
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IPlantFactorySiteService), ServiceLifetime = LifeTime.Transient)]
|
|
public class PlantFactorySiteService : BaseService<PlantFactorySite>, IPlantFactorySiteService
|
|
{
|
|
/// <summary>
|
|
/// 查询工厂/站点列表
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<PlantFactorySiteDto> GetList(PlantFactorySiteQueryDto parm)
|
|
{
|
|
var predicate = Expressionable.Create<PlantFactorySite>()
|
|
.AndIF(!string.IsNullOrEmpty(parm.SiteCode), it => it.SiteCode.Contains(parm.SiteCode))
|
|
.AndIF(!string.IsNullOrEmpty(parm.SiteName), it => it.SiteCode.Contains(parm.SiteName))
|
|
.AndIF(!string.IsNullOrEmpty(parm.SiteType), it => it.SiteType == parm.SiteType)
|
|
.AndIF(parm.Status != null, it => it.Status == parm.Status)
|
|
;
|
|
|
|
var response = Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.ToPage<PlantFactorySite, PlantFactorySiteDto>(parm);
|
|
|
|
return response;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取详情
|
|
/// </summary>
|
|
/// <param name="SiteId"></param>
|
|
/// <returns></returns>
|
|
public PlantFactorySite GetInfo(int SiteId)
|
|
{
|
|
var response = Queryable()
|
|
.Where(x => x.SiteId == SiteId)
|
|
.First();
|
|
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加工厂/站点
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public PlantFactorySite AddPlantFactorySite(PlantFactorySite model)
|
|
{
|
|
return Context.Insertable(model).ExecuteReturnEntity();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改工厂/站点
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public int UpdatePlantFactorySite(PlantFactorySite model)
|
|
{
|
|
//var response = Update(w => w.SiteId == model.SiteId, it => new PlantFactorySite()
|
|
//{
|
|
// SiteName = model.SiteName,
|
|
// SiteType = model.SiteType,
|
|
// Description = model.Description,
|
|
// Address = model.Address,
|
|
// Status = model.Status,
|
|
// CreatedBy = model.CreatedBy,
|
|
// CreatedTime = model.CreatedTime,
|
|
// UpdatedBy = model.UpdatedBy,
|
|
// UpdatedTime = model.UpdatedTime,
|
|
//});
|
|
//return response;
|
|
return Update(model, true);
|
|
}
|
|
|
|
}
|
|
} |