处理绑定问题
This commit is contained in:
parent
628c0659aa
commit
d17f184fdf
@ -37,6 +37,18 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
var response = _BaseDeviceService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询设备信息列表 未绑定工位的设备
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list_no_bind")]
|
||||
[ActionPermissionFilter(Permission = "baseManagement:basedevice:list")]
|
||||
public IActionResult QueryBaseDevice_nobind([FromQuery] BaseDeviceQueryDto parm)
|
||||
{
|
||||
var response = _BaseDeviceService.GetList_nobind(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -60,11 +60,11 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
[HttpPost]
|
||||
[ActionPermissionFilter(Permission = "baseManagement:baseworkstation:add")]
|
||||
[Log(Title = "工位", BusinessType = BusinessType.INSERT)]
|
||||
public IActionResult AddBaseWorkStation([FromBody] BaseWorkStationDto parm)
|
||||
public IActionResult AddBaseWorkStation([FromBody] BaseWorkStationDto2 parm)
|
||||
{
|
||||
var modal = parm.Adapt<BaseWorkStation>().ToCreate(HttpContext);
|
||||
|
||||
var response = _BaseWorkStationService.AddBaseWorkStation(modal);
|
||||
var response = _BaseWorkStationService.AddBaseWorkStation(modal,parm.BindedDeviceArray);
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
@ -76,10 +76,10 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
[HttpPut]
|
||||
[ActionPermissionFilter(Permission = "baseManagement:baseworkstation:edit")]
|
||||
[Log(Title = "工位", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult UpdateBaseWorkStation([FromBody] BaseWorkStationDto parm)
|
||||
public IActionResult UpdateBaseWorkStation([FromBody] BaseWorkStationDto2 parm)
|
||||
{
|
||||
var modal = parm.Adapt<BaseWorkStation>().ToUpdate(HttpContext);
|
||||
var response = _BaseWorkStationService.UpdateBaseWorkStation(modal);
|
||||
var response = _BaseWorkStationService.UpdateBaseWorkStation(modal, parm.BindedDeviceArray);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
@ -42,5 +42,36 @@ namespace DOAN.Model.MES.base_.Dto
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加工位和修改工位使用
|
||||
/// </summary>
|
||||
public class BaseWorkStationDto2
|
||||
{
|
||||
[Required(ErrorMessage = "主键不能为空")]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int? FkWorkProcesses { get; set; }
|
||||
|
||||
public string DictWorkType { get; set; }
|
||||
|
||||
public string WorkStationDescription { get; set; }
|
||||
|
||||
public int[] BindedDeviceArray { get; set; }
|
||||
|
||||
public int? Status { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
public string UpdatedBy { get; set; }
|
||||
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -41,7 +41,29 @@ namespace DOAN.Service.MES.base_
|
||||
|
||||
return response;
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询设备信息列表 未绑定工位的设备
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<BaseDeviceDto> GetList_nobind(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)
|
||||
.And(it=>it.FkWorkStation==null)
|
||||
;
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<BaseDevice, BaseDeviceDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
|
||||
@ -58,8 +58,12 @@ namespace DOAN.Service.MES.base_
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public BaseWorkStation AddBaseWorkStation(BaseWorkStation model)
|
||||
public BaseWorkStation AddBaseWorkStation(BaseWorkStation model, int[] BindedDeviceArray)
|
||||
{
|
||||
// 处理绑定
|
||||
Context.Updateable<BaseDevice>().SetColumns(it => it.FkWorkStation == model.Id)
|
||||
.Where(it => BindedDeviceArray.Contains(it.Id))
|
||||
.Where(it => it.FkWorkStation == null).ExecuteCommand();
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
@ -68,8 +72,12 @@ namespace DOAN.Service.MES.base_
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateBaseWorkStation(BaseWorkStation model)
|
||||
public int UpdateBaseWorkStation(BaseWorkStation model,int[] BindedDeviceArray)
|
||||
{
|
||||
// 处理绑定
|
||||
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,
|
||||
|
||||
@ -13,6 +13,7 @@ namespace DOAN.Service.Business.IBusinessService
|
||||
public interface IBaseDeviceService : IBaseService<BaseDevice>
|
||||
{
|
||||
PagedInfo<BaseDeviceDto> GetList(BaseDeviceQueryDto parm);
|
||||
PagedInfo<BaseDeviceDto> GetList_nobind(BaseDeviceQueryDto parm);
|
||||
|
||||
BaseDevice GetInfo(int Id);
|
||||
|
||||
|
||||
@ -15,9 +15,9 @@ namespace DOAN.Service.MES.base_.IService
|
||||
|
||||
BaseWorkStation GetInfo(int Id);
|
||||
|
||||
BaseWorkStation AddBaseWorkStation(BaseWorkStation parm);
|
||||
BaseWorkStation AddBaseWorkStation(BaseWorkStation parm, int[] BindedDeviceArray);
|
||||
|
||||
int UpdateBaseWorkStation(BaseWorkStation parm);
|
||||
int UpdateBaseWorkStation(BaseWorkStation parm, int[] BindedDeviceArray);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user