| | |
| | | /// <summary> |
| | | /// 报警等级 |
| | | /// </summary> |
| | | public class PumpGroup : IPumpGroup |
| | | public class AssetsPumpGroup : IAssetsPumpGroup |
| | | { |
| | | private readonly HStation.Service.PumpGroup _service = new(); |
| | | private readonly HStation.Service.AssetsPumpGroup _service = new(); |
| | | |
| | | #region Query |
| | | |
| | | /// <summary> |
| | | /// 获取所有 |
| | | /// </summary> |
| | | public async Task<List<PumpGroupDto>> GetAll() |
| | | public async Task<List<AssetsPumpGroupDto>> GetAll() |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var list = _service.GetAll(); |
| | | var vm_list = list?.Select(x => new PumpGroupDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsPumpGroupDto(x)).ToList(); |
| | | return vm_list; |
| | | }); |
| | | } |
| | |
| | | /// <summary> |
| | | /// 通过 ID 获取 |
| | | /// </summary> |
| | | public async Task<PumpGroupDto> GetByID(long ID) |
| | | public async Task<AssetsPumpGroupDto> GetByID(long ID) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var model = _service.GetByID(ID); |
| | | return model == null ? null : new PumpGroupDto(model); |
| | | return model == null ? null : new AssetsPumpGroupDto(model); |
| | | }); |
| | | } |
| | | |
| | | public async Task<List<PumpGroupDto>> GetBySeriesID(long SeriesID) |
| | | public async Task<List<AssetsPumpGroupDto>> GetBySeriesID(long SeriesID) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var list = _service.GetBySeriesID(SeriesID); |
| | | var vm_list = list?.Select(x => new PumpGroupDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsPumpGroupDto(x)).ToList(); |
| | | return vm_list; |
| | | }); |
| | | } |
| | |
| | | /// <summary> |
| | | /// 通过 Ids 获取 |
| | | /// </summary> |
| | | public async Task<List<PumpGroupDto>> GetByIds(List<long> Ids) |
| | | public async Task<List<AssetsPumpGroupDto>> GetByIds(List<long> Ids) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var list = _service.GetByIds(Ids); |
| | | var vm_list = list?.Select(x => new PumpGroupDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsPumpGroupDto(x)).ToList(); |
| | | return vm_list; |
| | | }); |
| | | } |
| | |
| | | /// <summary> |
| | | /// 插入一条 |
| | | /// </summary> |
| | | public async Task<long> Insert(AddPumpGroupDto input) |
| | | public async Task<long> Insert(AddAssetsPumpGroupDto input) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var model = input.Adapt<AddPumpGroupDto, Model.PumpGroup>(); |
| | | var model = input.Adapt<AddAssetsPumpGroupDto, Model.AssetsPumpGroup>(); |
| | | model.SortCode = _service.GetMaxSortCode() + 1; |
| | | var id = _service.Insert(model); |
| | | return id; |
| | |
| | | /// <summary> |
| | | /// 批量插入 |
| | | /// </summary> |
| | | public async Task<bool> Inserts(List<AddPumpGroupDto> inputList) |
| | | public async Task<bool> Inserts(List<AddAssetsPumpGroupDto> inputList) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var list = inputList.Select(x => x.Adapt<AddPumpGroupDto, Model.PumpGroup>()).ToList(); |
| | | var list = inputList.Select(x => x.Adapt<AddAssetsPumpGroupDto, Model.AssetsPumpGroup>()).ToList(); |
| | | list.ForEach(x => |
| | | { |
| | | x.SortCode = _service.GetMaxSortCode() + 1 + list.IndexOf(x); |
| | |
| | | /// <summary> |
| | | /// 大批量插入 |
| | | /// </summary> |
| | | public async Task<bool> BulkInserts(List<AddPumpGroupDto> list) |
| | | public async Task<bool> BulkInserts(List<AddAssetsPumpGroupDto> list) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | |
| | | /// <summary> |
| | | /// 更新一条 |
| | | /// </summary> |
| | | public async Task<bool> Update(UpdatePumpGroupDto input) |
| | | public async Task<bool> Update(UpdateAssetsPumpGroupDto input) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在"); |
| | | } |
| | | |
| | | var rhs = new Model.PumpGroup(model); |
| | | var rhs = new Model.AssetsPumpGroup(model); |
| | | input.Adapt(rhs); |
| | | var bol = _service.Update(rhs); |
| | | return bol; |
| | |
| | | /// <summary> |
| | | /// 批量更新 |
| | | /// </summary> |
| | | public async Task<bool> Updates(List<UpdatePumpGroupDto> inputList) |
| | | public async Task<bool> Updates(List<UpdateAssetsPumpGroupDto> inputList) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var list = inputList.Select(x => x.Adapt<UpdatePumpGroupDto, Model.PumpGroup>()).ToList(); |
| | | var list = inputList.Select(x => x.Adapt<UpdateAssetsPumpGroupDto, Model.AssetsPumpGroup>()).ToList(); |
| | | var bol = _service.Updates(list); |
| | | return bol; |
| | | }); |
| | |
| | | /// <summary> |
| | | /// 大批量更新 |
| | | /// </summary> |
| | | public async Task<bool> BulkUpdates(List<UpdatePumpGroupDto> list) |
| | | public async Task<bool> BulkUpdates(List<UpdateAssetsPumpGroupDto> list) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |