zhuangpei-mesbackend/MDM/Services/Plant/PlantProductlinebodyService.cs
2026-01-04 18:55:19 +08:00

112 lines
4.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(IPlantProductlinebodyService), ServiceLifetime = LifeTime.Transient)]
public class PlantProductlinebodyService : BaseService<PlantProductlinebody>, IPlantProductlinebodyService
{
/// <summary>
/// 查询产线/线体/工作中心列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<PlantProductlinebodyDto> GetList(PlantProductlinebodyQueryDto parm)
{
var predicate = Expressionable.Create<PlantProductlinebody>()
.AndIF(!string.IsNullOrEmpty(parm.FkFactorySiteCode),it=>it.FkFactorySiteCode.Contains(parm.FkFactorySiteCode))
.AndIF(!string.IsNullOrEmpty(parm.FkWorkshopCode),it=>it.FkWorkshopCode.Contains(parm.FkWorkshopCode))
.AndIF(!string.IsNullOrEmpty(parm.LineCode),it=>it.LineCode.Contains(parm.LineCode))
.AndIF(!string.IsNullOrEmpty(parm.LineName),it=>it.LineName.Contains(parm.LineName))
;
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<PlantProductlinebody, PlantProductlinebodyDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="LineId"></param>
/// <returns></returns>
public PlantProductlinebody GetInfo(int LineId)
{
var response = Queryable()
.Where(x => x.LineId == LineId)
.First();
return response;
}
/// <summary>
/// 添加产线/线体/工作中心
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public PlantProductlinebody AddPlantProductlinebody(PlantProductlinebody model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改产线/线体/工作中心
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdatePlantProductlinebody(PlantProductlinebody model)
{
//var response = Update(w => w.LineId == model.LineId, it => new PlantProductlinebody()
//{
// FkFactorySiteCode = model.FkFactorySiteCode,
// FkWorkshopCode = model.FkWorkshopCode,
// LineName = model.LineName,
// LineType = model.LineType,
// Description = model.Description,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
public List<PlantWorkstation> GetWorkstationList(int id)
{
PlantProductlinebody productlinebody= Context.Queryable<PlantProductlinebody>().Where(it => it.LineId == id).First();
return Context.Queryable<PlantWorkstation>().Where(it => it.FkFactorySiteCode == productlinebody.FkFactorySiteCode && it.FkWorkshopCode == productlinebody.FkWorkshopCode && it.FkProductlinebody == productlinebody.LineCode).ToList();
}
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<PlantWorkshop> GetWorkShop(string site_code, string workshop_code)
{
return Context.Queryable<PlantWorkshop>()
.WhereIF(!string.IsNullOrEmpty(site_code), it => it.FkSiteCode.Contains(site_code))
.WhereIF(!string.IsNullOrEmpty(workshop_code), it => it.WorkshopCode.Contains(workshop_code))
.ToList();
}
}
}