109 lines
3.8 KiB
C#
109 lines
3.8 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(IBaseDeviceService), ServiceLifetime = LifeTime.Transient)]
|
|
public class BaseDeviceService : BaseService<BaseDevice>, IBaseDeviceService
|
|
{
|
|
/// <summary>
|
|
/// 查询设备信息列表
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<BaseDeviceDto> GetList(BaseDeviceQueryDto parm)
|
|
{
|
|
var predicate = Expressionable.Create<BaseDevice>()
|
|
.AndIF(!string.IsNullOrEmpty(parm.DeviceCode), it => it.DeviceCode.Contains(parm.DeviceCode))
|
|
.AndIF(!string.IsNullOrEmpty(parm.DeviceName), it => it.DeviceName.Contains(parm.DeviceName))
|
|
.AndIF(!string.IsNullOrEmpty(parm.DeviceSpecification), it => it.DeviceSpecification.Contains(parm.DeviceSpecification))
|
|
.AndIF(!string.IsNullOrEmpty(parm.DeviceSupplier), it => it.DeviceSupplier.Contains(parm.DeviceSupplier))
|
|
.AndIF(parm.FkWorkStation > -1, it => it.FkWorkStation == parm.FkWorkStation)
|
|
.AndIF(parm.Status > -1, it => it.Status == parm.Status)
|
|
;
|
|
|
|
var response = Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.ToPage<BaseDevice, BaseDeviceDto>(parm);
|
|
|
|
return response;
|
|
}
|
|
/// <summary>
|
|
/// 查询设备信息列表 未绑定工位的设备
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public List<BaseDeviceDto> GetList_nobind(int id)
|
|
{
|
|
var response= Context.Queryable<BaseDevice>().Where(it => (it.Status==1&&it.FkWorkStation == null) || (it.Status == 1 && it.FkWorkStation == id))
|
|
.ToList().Adapt<List<BaseDeviceDto>>();
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取详情
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
/// <returns></returns>
|
|
public BaseDevice GetInfo(int Id)
|
|
{
|
|
var response = Queryable()
|
|
.Where(x => x.Id == Id)
|
|
.First();
|
|
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加设备信息
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public BaseDevice AddBaseDevice(BaseDevice model)
|
|
{
|
|
return Context.Insertable(model).ExecuteReturnEntity();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改设备信息
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public int UpdateBaseDevice(BaseDevice model)
|
|
{
|
|
//var response = Update(w => w.Id == model.Id, it => new BaseDevice()
|
|
//{
|
|
// FkWorkStation = model.FkWorkStation,
|
|
// DeviceCode = model.DeviceCode,
|
|
// DeviceName = model.DeviceName,
|
|
// DeviceSpecification = model.DeviceSpecification,
|
|
// PurchaseTime = model.PurchaseTime,
|
|
// DeviceSupplier = model.DeviceSupplier,
|
|
// Remark = model.Remark,
|
|
// Status = model.Status,
|
|
// CreatedBy = model.CreatedBy,
|
|
// CreatedTime = model.CreatedTime,
|
|
// UpdatedBy = model.UpdatedBy,
|
|
// UpdatedTime = model.UpdatedTime,
|
|
//});
|
|
//return response;
|
|
return Update(model, true);
|
|
}
|
|
|
|
}
|
|
} |