提交
This commit is contained in:
128
DOAN.Service/MES/Base/BaseWorkStationService.cs
Normal file
128
DOAN.Service/MES/Base/BaseWorkStationService.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.MES.base_.Dto;
|
||||
using DOAN.Model.MES.base_;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.MES.base_.IService;
|
||||
using System.Linq;
|
||||
using Mapster;
|
||||
|
||||
namespace DOAN.Service.MES.base_
|
||||
{
|
||||
/// <summary>
|
||||
/// 工位Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IBaseWorkStationService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class BaseWorkStationService : BaseService<BaseWorkStation>, IBaseWorkStationService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询工位列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<BaseWorkStationDto> GetList(BaseWorkStationQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<BaseWorkStation>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.WorkStationDescription),it=>it.WorkStationDescription.Contains(parm.WorkStationDescription))
|
||||
.AndIF(parm.Status>-1,it=>it.Status==parm.Status)
|
||||
;
|
||||
|
||||
var response = Queryable()
|
||||
.Includes(x => x.BindedDeviceArray)
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<BaseWorkStation, BaseWorkStationDto>(parm);
|
||||
// Context.Queryable<BaseWorkStation>().InnerJoin<BaseDevice>((w,d)=>w.Id==d.FkWorkStation).Select
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public List<BaseWorkStationDto> GetList_Drop_down(int id)
|
||||
{
|
||||
var response = Context.Queryable<BaseWorkStation>().Where(it => (it.Status == 1 && it.FkWorkProcesses == null) || (it.Status == 1 && it.FkWorkProcesses == id))
|
||||
.ToList().Adapt<List<BaseWorkStationDto>>();
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public BaseWorkStation GetInfo(int Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Includes(x => x.BindedDeviceArray)
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加工位
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public BaseWorkStation AddBaseWorkStation(BaseWorkStation model, int[] BindedDeviceArray)
|
||||
{
|
||||
BaseWorkStation resp= Context.Insertable(model).ExecuteReturnEntity();
|
||||
// 处理绑定
|
||||
Context.Updateable<BaseDevice>()
|
||||
.SetColumns(it => it.FkWorkStation == resp.Id)
|
||||
.Where(it => BindedDeviceArray.Contains(it.Id))
|
||||
.Where(it => it.FkWorkStation == null).ExecuteCommand();
|
||||
return resp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改工位
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateBaseWorkStation(BaseWorkStation model,int[] BindedDeviceArray)
|
||||
{
|
||||
UseTran2(() =>
|
||||
{
|
||||
//解绑
|
||||
Context.Updateable<BaseDevice>().SetColumns(it => it.FkWorkStation == null)
|
||||
.Where(it => it.FkWorkStation == model.Id)
|
||||
.ExecuteCommand();
|
||||
// 处理绑定
|
||||
Context.Updateable<BaseDevice>().SetColumns(it => it.FkWorkStation == model.Id)
|
||||
.Where(it => BindedDeviceArray.Contains(it.Id))
|
||||
.Where(it => it.FkWorkStation == null).ExecuteCommand();
|
||||
});
|
||||
|
||||
//var response = Update(w => w.Id == model.Id, it => new BaseWorkStation()
|
||||
//{
|
||||
// FkWorkProcesses = model.FkWorkProcesses,
|
||||
// DictWorkType = model.DictWorkType,
|
||||
// WorkStationDescription = model.WorkStationDescription,
|
||||
// Status = model.Status,
|
||||
// Remark = model.Remark,
|
||||
// CreatedBy = model.CreatedBy,
|
||||
// CreatedTime = model.CreatedTime,
|
||||
// UpdatedBy = model.UpdatedBy,
|
||||
// UpdatedTime = model.UpdatedTime,
|
||||
//});
|
||||
//return response;
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除绑定关系
|
||||
/// </summary>
|
||||
/// <param name="idsArr"></param>
|
||||
public void DeleteHandle(int[] idsArr)
|
||||
{
|
||||
Context.Updateable<BaseDevice>().SetColumns(it => it.FkWorkStation == null)
|
||||
.Where(it => idsArr.Contains(it.FkWorkStation.Value))
|
||||
.ExecuteCommand();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user