using Yw.Dto;
|
|
namespace HStation.CAL.LocalClient
|
{
|
/// <summary>
|
/// 报警等级
|
/// </summary>
|
public class AssetsPumpPartMain : IAssetsPumpPartMain
|
{
|
private readonly HStation.Service.AssetsPumpPartMain _service = new();
|
|
#region Query
|
|
/// <summary>
|
/// 获取所有
|
/// </summary>
|
public async Task<List<AssetsPumpPartMainDto>> GetAll()
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetAll();
|
var vm_list = list?.Select(x => new AssetsPumpPartMainDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
public async Task<AssetsPumpPartMainDto> GetByID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var model = _service.GetByID(ID);
|
return model == null ? null : new AssetsPumpPartMainDto(model);
|
});
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
public async Task<List<AssetsPumpPartMainDto>> GetByIds(List<long> Ids)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByIds(Ids);
|
var vm_list = list?.Select(x => new AssetsPumpPartMainDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
/// <summary>
|
/// 通过型号ID 获取
|
/// </summary>
|
public async Task<List<AssetsPumpPartMainDto>> GetByPumpMainID(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = _service.GetByMainID(ID);
|
var vm_list = list?.Select(x => new AssetsPumpPartMainDto(x)).ToList();
|
return vm_list;
|
});
|
}
|
|
#endregion Query
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
public async Task<long> Insert(AddAssetsPumpPartMainInput input)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var model = input.Adapt<AddAssetsPumpPartMainInput, Model.AssetsPumpPartMain>();
|
model.SortCode = _service.GetMaxSortCode() + 1;
|
var id = _service.Insert(model);
|
return id;
|
});
|
}
|
|
/// <summary>
|
/// 批量插入
|
/// </summary>
|
public async Task<bool> Inserts(List<AddAssetsPumpPartMainInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var list = inputList.Select(x => x.Adapt<AddAssetsPumpPartMainInput, Model.AssetsPumpPartMain>()).ToList();
|
list.ForEach(x =>
|
{
|
x.SortCode = _service.GetMaxSortCode() + 1 + list.IndexOf(x);
|
});
|
var bol = _service.Inserts(list);
|
return bol;
|
});
|
}
|
|
//插入拓展
|
public async Task<long> InsertEx(AddAssetsPumpPartMainInput part, List<AddAssetsPumpPropContentInput> propcontents, AddAssetsPumpMainAndPartMapInput partmap)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var partmodel = part.Adapt<AddAssetsPumpPartMainInput, Model.AssetsPumpPartMain>();
|
partmodel.SortCode = _service.GetMaxSortCode() + 1;
|
var propcontentlistmodel = propcontents.Select(x => x.Adapt<AddAssetsPumpPropContentInput, Model.AssetsPumpPropContent>()).ToList();
|
var partmapmodel = partmap.Adapt<AddAssetsPumpMainAndPartMapInput, Model.AssetsPumpMainAndPartMap>();
|
var id = _service.InsertEX(partmodel, propcontentlistmodel, partmapmodel);
|
return id;
|
});
|
}
|
|
/// <summary>
|
/// 大批量插入
|
/// </summary>
|
public async Task<bool> BulkInserts(List<AddAssetsPumpPartMainInput> list)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
#endregion Insert
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
public async Task<bool> Update(UpdateAssetsPumpPartMainInput 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 rhs = new Model.AssetsPumpPartMain(model);
|
input.Adapt(rhs);
|
var bol = _service.Update(rhs);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
/// 批量更新
|
/// </summary>
|
public async Task<bool> Updates(List<UpdateAssetsPumpPartMainInput> inputList)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
if (inputList == null || inputList.Count < 1)
|
{
|
return false;
|
}
|
var list = inputList.Select(x => x.Adapt<UpdateAssetsPumpPartMainInput, Model.AssetsPumpPartMain>()).ToList();
|
var bol = _service.Updates(list);
|
return bol;
|
});
|
}
|
|
/// <summary>
|
/// 大批量更新
|
/// </summary>
|
public async Task<bool> BulkUpdates(List<UpdateAssetsPumpPartMainInput> list)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
//编辑拓展
|
public async Task<bool> UpdateEx(UpdateAssetsPumpPartMainInput pumppart, List<UpdateAssetsPumpPropContentInput> updateAssetsPumpPropContentDtos)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var partmodel = pumppart.Adapt<UpdateAssetsPumpPartMainInput, Model.AssetsPumpPartMain>();
|
var propcontentlistmodel = updateAssetsPumpPropContentDtos.Select(x => x.Adapt<UpdateAssetsPumpPropContentInput, Model.AssetsPumpPropContent>()).ToList();
|
return _service.UpdateEX(partmodel, propcontentlistmodel);
|
});
|
}
|
|
/// <summary>
|
/// 更新编码
|
/// </summary>
|
public async Task<bool> UpdateCode(long ID, string Code)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
return false;
|
});
|
}
|
|
/// <summary>
|
/// 更新排序码
|
/// </summary>
|
public async Task<bool> UpdateSortCode(long ID, int SortCode)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.UpdateSortCode(ID, SortCode);
|
return bol;
|
});
|
}
|
|
/// <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;
|
});
|
}
|
|
#endregion Update
|
|
#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;
|
});
|
}
|
|
public async Task<bool> DeleteEx(long ID)
|
{
|
return await Task.Factory.StartNew(() =>
|
{
|
var bol = _service.DeleteExByID(ID);
|
if (!bol)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, "删除失败");
|
}
|
return true;
|
});
|
}
|
|
/// <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 Delete
|
}
|
}
|