namespace HStation.CAL.LocalClient
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public class XhsPumpPhartMapping : IXhsPumpPhartMapping
|
{
|
private readonly HStation.Service.XhsPumpPhartMapping _service = new();
|
|
#region Query
|
|
/// <summary>
|
/// 获取所有
|
/// </summary>
|
public async Task<List<XhsPumpPhartMappingDto>> GetAll()
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetAll();
|
var vm_list = list?.Select(x => new XhsPumpPhartMappingDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
public async Task<XhsPumpPhartMappingDto> GetByID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var model = _service.GetByID(ID);
|
return model == null ? null : new XhsPumpPhartMappingDto(model);
|
});
|
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
public async Task<List<XhsPumpPhartMappingDto>> GetByIds(List<long> Ids)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByIds(Ids);
|
var vm_list = list?.Select(x => new XhsPumpPhartMappingDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 PumpID 获取
|
/// </summary>
|
public async Task<List<XhsPumpPhartMappingDto>> GetByPumpID(long PumpID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByPumpID(PumpID);
|
var vm_list = list?.Select(x => new XhsPumpPhartMappingDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 PumpIds 获取
|
/// </summary>
|
public async Task<List<XhsPumpPhartMappingDto>> GetByPumpIds(List<long> PumpIds)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByPumpIds(PumpIds);
|
var vm_list = list?.Select(x => new XhsPumpPhartMappingDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
|
/// <summary>
|
/// 获取最大排序码
|
/// </summary>
|
/// <returns></returns>
|
public async Task<int> GetMaxSortCode(long PumpID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return _service.GetMaxSortCode(PumpID);
|
});
|
}
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 添加一条
|
/// </summary>
|
public async Task<long> Insert(AddXhsPumpPhartMappingInput input)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var equipment = new Service.PumpMain().GetByID(input.PumpID);
|
if (equipment == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"PumpID:{input.PumpID} 数据不存在");
|
}
|
var diagram = new Service.XhsPhartDiagram().GetByID(input.DiagramID);
|
if (diagram == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"DiagramID:{input.DiagramID} 数据不存在");
|
}
|
var model = input.Adapt<AddXhsPumpPhartMappingInput, Model.XhsPumpPhartMapping>();
|
model.SortCode = _service.GetMaxSortCode(input.PumpID) + 1;
|
var id = _service.Insert(model);
|
return id;
|
});
|
}
|
|
/// <summary>
|
/// 批量插入
|
/// </summary>
|
public async Task<bool> Inserts(List<AddXhsPumpPhartMappingInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
|
/// <summary>
|
/// 大批量插入
|
/// </summary>
|
public async Task<bool> BulkInserts(List<AddXhsPumpPhartMappingInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
#endregion
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
public async Task<bool> Update(UpdateXhsPumpPhartMappingInput input)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var model = _service.GetByID(input.ID);
|
if (model == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在");
|
}
|
var equipment = new Service.PumpMain().GetByID(input.PumpID);
|
if (equipment == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"PumpID:{input.PumpID} 数据不存在");
|
}
|
var diagram = new Service.XhsPhartDiagram().GetByID(input.DiagramID);
|
if (diagram == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"DiagramID:{input.DiagramID} 数据不存在");
|
}
|
var rhs = new Model.XhsPumpPhartMapping(model);
|
input.Adapt(rhs);
|
var bol = _service.Update(rhs);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
/// 批量更新
|
/// </summary>
|
public async Task<bool> Updates(List<UpdateXhsPumpPhartMappingInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
|
/// <summary>
|
/// 大批量更新
|
/// </summary>
|
public async Task<bool> BulkUpdates(List<UpdateXhsPumpPhartMappingInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
/// 更新排序码
|
/// </summary>
|
public async Task<bool> UpdateSortCode(long ID, int SortCode)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return _service.UpdateSortCode(ID, SortCode);
|
});
|
}
|
|
/// <summary>
|
/// 更新排序
|
/// </summary>
|
public async Task<bool> UpdateSorter(List<UpdateSortCodeInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = inputList.Select(x => x.Adapt<Yw.Model.Sorter>()).ToList();
|
var bol = _service.UpdateSorter(list);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
/// 更新 OtherName
|
/// </summary>
|
public async Task<bool> UpdateOtherName(long ID, string OtherName)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return _service.UpdateOtherName(ID, OtherName);
|
});
|
|
}
|
|
/// <summary>
|
/// 更新 Importance
|
/// </summary>
|
public async Task<bool> UpdateImportance(long ID, int Importance)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return _service.UpdateImportance(ID, Importance);
|
});
|
}
|
|
#endregion
|
|
#region Delete
|
|
/// <summary>
|
/// 通过 ID 删除
|
/// </summary>
|
public async Task<bool> DeleteByID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.DeleteByID(ID, out string msg);
|
if (!bol)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, msg);
|
}
|
return true;
|
});
|
}
|
|
/// <summary>
|
/// 通过 PumpID 删除
|
/// </summary>
|
public async Task<bool> DeleteByPumpID(long PumpID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.DeleteByPumpID(PumpID, out string Msg);
|
if (!bol)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, Msg);
|
}
|
return bol;
|
});
|
}
|
|
|
/// <summary>
|
/// 通过 Ids 删除
|
/// </summary>
|
public async Task<bool> DeleteByIds(List<long> Ids)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
/// 删除全部
|
/// </summary>
|
/// <returns></returns>
|
public async Task<bool> DeleteAll()
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
#endregion
|
|
}
|
}
|