修改设备绑定点检项
This commit is contained in:
parent
91429efd09
commit
fad7e978d4
@ -48,25 +48,38 @@ namespace ZR.Service.MES.dev
|
||||
/// <returns></returns>
|
||||
public PagedInfo<DeviceInspectDto> GetList2(DeviceInspectQueryDto2 parm)
|
||||
{
|
||||
// 获取未绑定
|
||||
if (parm.Isbind == 0)
|
||||
{
|
||||
int[] binded = Context.Queryable<DeviceRelAccountInspect>()
|
||||
.Where(it => it.FkAccountId == parm.FkAccountId)
|
||||
.Select(it => it.FkInspectId.Value).ToArray();
|
||||
|
||||
var predicate = Expressionable.Create<DeviceRelAccountInspect,DeviceInspect>();
|
||||
var exp = Expressionable.Create<DeviceInspect>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.Name),it=>it.Name.Contains(parm.Name));
|
||||
return Context.Queryable<DeviceInspect>()
|
||||
.Where(it => !binded.Contains(it.Id))
|
||||
.Where(exp.ToExpression())
|
||||
.ToPage<DeviceInspect, DeviceInspectDto>(parm);
|
||||
|
||||
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)
|
||||
.AndIF(parm.Isbind == 0, (r, i) => r.FkAccountId != parm.FkAccountId||r.FkInspectId==null);
|
||||
|
||||
ISugarQueryable<DeviceInspect> query = Context.Queryable<DeviceRelAccountInspect>()
|
||||
.RightJoin<DeviceInspect>((r, i) => r.FkInspectId == i.Id)
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy((r, i)=>r.Sort)
|
||||
.Select((r, i) => i);
|
||||
}
|
||||
else if (parm.Isbind == 1)
|
||||
{
|
||||
|
||||
var exp = Expressionable.Create<DeviceRelAccountInspect, DeviceInspect>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.Name), (r, i) => i.Name.Contains(parm.Name));
|
||||
// 获取绑定
|
||||
return Context.Queryable<DeviceRelAccountInspect>()
|
||||
.RightJoin<DeviceInspect>((r, i) => r.FkInspectId == i.Id)
|
||||
.Where((r, i) => r.FkAccountId == parm.FkAccountId)
|
||||
.Where(exp.ToExpression())
|
||||
.OrderBy((r, i) => r.Sort)
|
||||
.Select((r, i) => i).ToPage<DeviceInspect, DeviceInspectDto>(parm);
|
||||
}
|
||||
return null;
|
||||
|
||||
|
||||
var response = query.ToPage<DeviceInspect, DeviceInspectDto>(parm);
|
||||
|
||||
return response;
|
||||
|
||||
|
||||
}
|
||||
@ -92,7 +105,7 @@ namespace ZR.Service.MES.dev
|
||||
/// <returns></returns>
|
||||
public DeviceInspect AddDeviceInspect(DeviceInspect model)
|
||||
{
|
||||
|
||||
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
@ -125,25 +138,25 @@ namespace ZR.Service.MES.dev
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public int AddBindrelative(DeviceInspectQueryDto3 parm,string name)
|
||||
public int AddBindrelative(DeviceInspectQueryDto3 parm, string name)
|
||||
{
|
||||
int result = 0;
|
||||
List<DeviceRelAccountInspect> rel_account_inspect_list=new List<DeviceRelAccountInspect> ();
|
||||
|
||||
if(parm.inspect_ids != null&& parm.inspect_ids.Count() > 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)
|
||||
foreach (var id in parm.inspect_ids)
|
||||
{
|
||||
DeviceRelAccountInspect inspect = new DeviceRelAccountInspect();
|
||||
inspect.FkAccountId = parm.account_id;
|
||||
inspect.FkInspectId = id;
|
||||
inspect.CreatedBy = name;
|
||||
inspect.CreatedTime= DateTime.Now;
|
||||
inspect.CreatedTime = DateTime.Now;
|
||||
inspect.Sort = 1;
|
||||
rel_account_inspect_list.Add(inspect);
|
||||
}
|
||||
|
||||
result= Context.Insertable(rel_account_inspect_list).ExecuteCommand();
|
||||
result = Context.Insertable(rel_account_inspect_list).ExecuteCommand();
|
||||
|
||||
}
|
||||
|
||||
@ -155,16 +168,16 @@ namespace ZR.Service.MES.dev
|
||||
/// <param name="account_id"></param>
|
||||
/// <param name="inspect_id"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public int RemoveBindrelative(int account_id,int inspect_id)
|
||||
|
||||
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();
|
||||
return Context.Deleteable<DeviceRelAccountInspect>().Where(it => it.FkAccountId == account_id).Where(it => it.FkInspectId == inspect_id).ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
public int SortBindrelative(List<DeviceRelAccountInspect> parm)
|
||||
{
|
||||
return Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
return Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user