99 lines
3.2 KiB
C#
99 lines
3.2 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(IPlantWorkshopService), ServiceLifetime = LifeTime.Transient)]
|
|
public class PlantWorkshopService : BaseService<PlantWorkshop>, IPlantWorkshopService
|
|
{
|
|
/// <summary>
|
|
/// 查询车间列表
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<PlantWorkshopDto> GetList(PlantWorkshopQueryDto parm)
|
|
{
|
|
var predicate = Expressionable.Create<PlantWorkshop>()
|
|
.AndIF(!string.IsNullOrEmpty(parm.FkSiteCode),it=>it.FkSiteCode.Contains(parm.FkSiteCode))
|
|
.AndIF(!string.IsNullOrEmpty(parm.WorkshopCode),it=>it.WorkshopCode.Contains(parm.WorkshopCode))
|
|
.AndIF(!string.IsNullOrEmpty(parm.WorkshopName),it=>it.WorkshopName.Contains(parm.WorkshopName))
|
|
.AndIF(parm.Status != null, it => it.Status == parm.Status)
|
|
|
|
;
|
|
|
|
var response = Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.ToPage<PlantWorkshop, PlantWorkshopDto>(parm);
|
|
|
|
return response;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取详情
|
|
/// </summary>
|
|
/// <param name="WorkshopId"></param>
|
|
/// <returns></returns>
|
|
public PlantWorkshop GetInfo(int WorkshopId)
|
|
{
|
|
var response = Queryable()
|
|
.Where(x => x.WorkshopId == WorkshopId)
|
|
.First();
|
|
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加车间
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public PlantWorkshop AddPlantWorkshop(PlantWorkshop model)
|
|
{
|
|
return Context.Insertable(model).ExecuteReturnEntity();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改车间
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public int UpdatePlantWorkshop(PlantWorkshop model)
|
|
{
|
|
//var response = Update(w => w.WorkshopId == model.WorkshopId, it => new PlantWorkshop()
|
|
//{
|
|
// FkSiteCode = model.FkSiteCode,
|
|
// WorkshopName = model.WorkshopName,
|
|
// Description = model.Description,
|
|
// Status = model.Status,
|
|
// CreatedBy = model.CreatedBy,
|
|
// CreatedTime = model.CreatedTime,
|
|
// UpdatedBy = model.UpdatedBy,
|
|
// UpdatedTime = model.UpdatedTime,
|
|
//});
|
|
//return response;
|
|
return Update(model, true);
|
|
}
|
|
|
|
//public List<PlantFactorySite> GetFactorySite(string site_code)
|
|
//{
|
|
// return Context.Queryable<PlantFactorySite>().WhereIF(!string.IsNullOrEmpty(site_code), it => it.SiteCode.Contains(site_code)).ToList();
|
|
//}
|
|
public List<PlantFactorySite> GetFactorySite()
|
|
{
|
|
return Context.Queryable<PlantFactorySite>().ToList();
|
|
}
|
|
}
|
|
} |