2024-05-21 18:58:03 +08:00
|
|
|
using System;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using Infrastructure.Attribute;
|
|
|
|
|
using Infrastructure.Extensions;
|
|
|
|
|
using ZR.Model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using ZR.Repository;
|
2024-06-03 18:26:07 +08:00
|
|
|
|
2024-05-21 18:58:03 +08:00
|
|
|
using System.Linq;
|
|
|
|
|
using ZR.Service.MES.dev.IService;
|
|
|
|
|
using ZR.Model.MES.dev;
|
2024-06-03 18:26:07 +08:00
|
|
|
using ZR.Model.MES.dev;
|
|
|
|
|
using ZR.Model.MES.dev.Dto;
|
|
|
|
|
using ZR.Service.MES.dev.IService;
|
2024-05-21 18:58:03 +08:00
|
|
|
|
|
|
|
|
namespace ZR.Service.MES.dev
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备检查项Service业务层处理
|
|
|
|
|
/// </summary>
|
|
|
|
|
[AppService(ServiceType = typeof(IDeviceInspectService), ServiceLifetime = LifeTime.Transient)]
|
|
|
|
|
public class DeviceInspectService : BaseService<DeviceInspect>, IDeviceInspectService
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询设备检查项列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public PagedInfo<DeviceInspectDto> GetList(DeviceInspectQueryDto parm)
|
|
|
|
|
{
|
|
|
|
|
var predicate = Expressionable.Create<DeviceInspect>();
|
|
|
|
|
|
2024-05-21 19:41:57 +08:00
|
|
|
predicate.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name.Contains(parm.Name))
|
|
|
|
|
.AndIF(parm.Status >= 0, it => it.Status == parm.Status);
|
|
|
|
|
|
2024-05-21 18:58:03 +08:00
|
|
|
var response = Queryable()
|
|
|
|
|
.Where(predicate.ToExpression())
|
|
|
|
|
.ToPage<DeviceInspect, DeviceInspectDto>(parm);
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 14:29:14 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 设备绑定模块 查询未绑定且状态为1 的设备检查项
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public PagedInfo<DeviceInspectDto> GetList2(DeviceInspectQueryDto2 parm)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var predicate = Expressionable.Create<DeviceRelAccountInspect,DeviceInspect>();
|
|
|
|
|
|
|
|
|
|
predicate
|
|
|
|
|
.AndIF(!string.IsNullOrEmpty(parm.Name), (r, i) => i.Name.Contains(parm.Name))
|
|
|
|
|
.And((r, i) => i.Status == 1)
|
|
|
|
|
.AndIF(parm.Isbind == 1, (r, i) => r.FkAccountId == parm.FkAccountId)
|
2024-05-27 14:29:14 +08:00
|
|
|
.AndIF(parm.Isbind == 0, (r, i) => r.FkAccountId != parm.FkAccountId||r.FkInspectId==null);
|
2024-05-27 14:29:14 +08:00
|
|
|
|
|
|
|
|
ISugarQueryable<DeviceInspect> query = Context.Queryable<DeviceRelAccountInspect>()
|
2024-05-27 14:29:14 +08:00
|
|
|
.RightJoin<DeviceInspect>((r, i) => r.FkInspectId == i.Id)
|
2024-05-27 14:29:14 +08:00
|
|
|
.Where(predicate.ToExpression())
|
2024-05-27 16:05:33 +08:00
|
|
|
.OrderBy((r, i)=>r.Sort)
|
2024-05-27 14:29:14 +08:00
|
|
|
.Select((r, i) => i);
|
|
|
|
|
|
2024-05-27 16:05:33 +08:00
|
|
|
|
2024-05-27 14:29:14 +08:00
|
|
|
var response = query.ToPage<DeviceInspect, DeviceInspectDto>(parm);
|
|
|
|
|
|
|
|
|
|
return response;
|
2024-05-27 14:29:14 +08:00
|
|
|
|
|
|
|
|
|
2024-05-27 14:29:14 +08:00
|
|
|
}
|
2024-05-21 18:58:03 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DeviceInspect GetInfo(int Id)
|
|
|
|
|
{
|
|
|
|
|
var response = Queryable()
|
|
|
|
|
.Where(x => x.Id == Id)
|
|
|
|
|
.First();
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加设备检查项
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DeviceInspect AddDeviceInspect(DeviceInspect model)
|
|
|
|
|
{
|
2024-06-18 09:04:17 +08:00
|
|
|
|
2024-05-21 18:58:03 +08:00
|
|
|
return Context.Insertable(model).ExecuteReturnEntity();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 修改设备检查项
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public int UpdateDeviceInspect(DeviceInspect model)
|
|
|
|
|
{
|
|
|
|
|
//var response = Update(w => w.Id == model.Id, it => new DeviceInspect()
|
|
|
|
|
//{
|
|
|
|
|
// Image = model.Image,
|
|
|
|
|
// Sort = model.Sort,
|
|
|
|
|
// Type = model.Type,
|
|
|
|
|
// Remark = model.Remark,
|
|
|
|
|
// Status = model.Status,
|
|
|
|
|
// Name = model.Name,
|
|
|
|
|
// CreatedBy = model.CreatedBy,
|
|
|
|
|
// CreatedTime = model.CreatedTime,
|
|
|
|
|
// UpdatedBy = model.UpdatedBy,
|
|
|
|
|
// UpdatedTime = model.UpdatedTime,
|
|
|
|
|
//});
|
|
|
|
|
//return response;
|
|
|
|
|
return Update(model, true);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 14:29:14 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 增加绑定关系
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
/// <returns></returns>
|
2024-05-27 16:05:33 +08:00
|
|
|
public int AddBindrelative(DeviceInspectQueryDto3 parm,string name)
|
2024-05-27 14:29:14 +08:00
|
|
|
{
|
|
|
|
|
int result = 0;
|
|
|
|
|
List<DeviceRelAccountInspect> rel_account_inspect_list=new List<DeviceRelAccountInspect> ();
|
|
|
|
|
|
|
|
|
|
if(parm.inspect_ids != null&& parm.inspect_ids.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach(var id in parm.inspect_ids)
|
|
|
|
|
{
|
|
|
|
|
DeviceRelAccountInspect inspect = new DeviceRelAccountInspect();
|
|
|
|
|
inspect.FkAccountId = parm.account_id;
|
|
|
|
|
inspect.FkInspectId = id;
|
2024-05-27 16:05:33 +08:00
|
|
|
inspect.CreatedBy = name;
|
2024-05-27 14:29:14 +08:00
|
|
|
inspect.CreatedTime= DateTime.Now;
|
|
|
|
|
inspect.Sort = 1;
|
|
|
|
|
rel_account_inspect_list.Add(inspect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result= Context.Insertable(rel_account_inspect_list).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除绑定接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="account_id"></param>
|
|
|
|
|
/// <param name="inspect_id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
|
|
public int RemoveBindrelative(int account_id,int inspect_id)
|
|
|
|
|
{
|
|
|
|
|
return Context.Deleteable<DeviceRelAccountInspect>().Where(it => it.FkAccountId == account_id).Where(it => it.FkInspectId == inspect_id).ExecuteCommand();
|
|
|
|
|
}
|
2024-05-27 16:05:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
public int SortBindrelative(List<DeviceRelAccountInspect> parm)
|
|
|
|
|
{
|
|
|
|
|
return Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-05-21 18:58:03 +08:00
|
|
|
}
|
|
|
|
|
}
|