| | |
| | | /// <summary> |
| | | /// 报警等级 |
| | | /// </summary> |
| | | public class PumpPartMain : IPumpPartMain |
| | | public class AssetsPumpPartMain : IAssetsPumpPartMain |
| | | { |
| | | private readonly HStation.Service.PumpPartMain _service = new(); |
| | | private readonly HStation.Service.AssetsPumpPartMain _service = new(); |
| | | |
| | | #region Query |
| | | |
| | | /// <summary> |
| | | /// 获取所有 |
| | | /// </summary> |
| | | public async Task<List<PumpPartMainDto>> GetAll() |
| | | public async Task<List<AssetsPumpPartMainDto>> GetAll() |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var list = _service.GetAll(); |
| | | var vm_list = list?.Select(x => new PumpPartMainDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsPumpPartMainDto(x)).ToList(); |
| | | return vm_list; |
| | | }); |
| | | } |
| | |
| | | /// <summary> |
| | | /// 通过 ID 获取 |
| | | /// </summary> |
| | | public async Task<PumpPartMainDto> GetByID(long ID) |
| | | public async Task<AssetsPumpPartMainDto> GetByID(long ID) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var model = _service.GetByID(ID); |
| | | return model == null ? null : new PumpPartMainDto(model); |
| | | return model == null ? null : new AssetsPumpPartMainDto(model); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 Ids 获取 |
| | | /// </summary> |
| | | public async Task<List<PumpPartMainDto>> GetByIds(List<long> Ids) |
| | | 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 PumpPartMainDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsPumpPartMainDto(x)).ToList(); |
| | | return vm_list; |
| | | }); |
| | | } |
| | |
| | | /// <summary> |
| | | /// 通过型号ID 获取 |
| | | /// </summary> |
| | | public async Task<List<PumpPartMainDto>> GetByPumpMainID(long ID) |
| | | 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 PumpPartMainDto(x)).ToList(); |
| | | var vm_list = list?.Select(x => new AssetsPumpPartMainDto(x)).ToList(); |
| | | return vm_list; |
| | | }); |
| | | } |
| | |
| | | /// <summary> |
| | | /// 插入一条 |
| | | /// </summary> |
| | | public async Task<long> Insert(AddPumpPartMainInput input) |
| | | public async Task<long> Insert(AddAssetsPumpPartMainInput input) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var model = input.Adapt<AddPumpPartMainInput, Model.PumpPartMain>(); |
| | | 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<AddPumpPartMainInput> inputList) |
| | | public async Task<bool> Inserts(List<AddAssetsPumpPartMainInput> inputList) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var list = inputList.Select(x => x.Adapt<AddPumpPartMainInput, Model.PumpPartMain>()).ToList(); |
| | | var list = inputList.Select(x => x.Adapt<AddAssetsPumpPartMainInput, Model.AssetsPumpPartMain>()).ToList(); |
| | | list.ForEach(x => |
| | | { |
| | | x.SortCode = _service.GetMaxSortCode() + 1 + list.IndexOf(x); |
| | |
| | | } |
| | | |
| | | //插入拓展 |
| | | public async Task<long> InsertEx(AddPumpPartMainInput part, List<AddPumpPropContentInput> propcontents, AddPumpMainAndPartMapDto partmap) |
| | | public async Task<long> InsertEx(AddAssetsPumpPartMainInput part, List<AddAssetsPumpPropContentInput> propcontents, AddAssetsPumpMainAndPartMapDto partmap) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var partmodel = part.Adapt<AddPumpPartMainInput, Model.PumpPartMain>(); |
| | | var partmodel = part.Adapt<AddAssetsPumpPartMainInput, Model.AssetsPumpPartMain>(); |
| | | partmodel.SortCode = _service.GetMaxSortCode() + 1; |
| | | var propcontentlistmodel = propcontents.Select(x => x.Adapt<AddPumpPropContentInput, Model.PumpPropContent>()).ToList(); |
| | | var partmapmodel = partmap.Adapt<AddPumpMainAndPartMapDto, Model.PumpMainAndPartMap>(); |
| | | var propcontentlistmodel = propcontents.Select(x => x.Adapt<AddAssetsPumpPropContentInput, Model.AssetsPumpPropContent>()).ToList(); |
| | | var partmapmodel = partmap.Adapt<AddAssetsPumpMainAndPartMapDto, Model.AssetsPumpMainAndPartMap>(); |
| | | var id = _service.InsertEX(partmodel, propcontentlistmodel, partmapmodel); |
| | | return id; |
| | | }); |
| | |
| | | /// <summary> |
| | | /// 大批量插入 |
| | | /// </summary> |
| | | public async Task<bool> BulkInserts(List<AddPumpPartMainInput> list) |
| | | public async Task<bool> BulkInserts(List<AddAssetsPumpPartMainInput> list) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | |
| | | /// <summary> |
| | | /// 更新一条 |
| | | /// </summary> |
| | | public async Task<bool> Update(UpdatePumpPartMainInput input) |
| | | public async Task<bool> Update(UpdateAssetsPumpPartMainInput input) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在"); |
| | | } |
| | | |
| | | var rhs = new Model.PumpPartMain(model); |
| | | var rhs = new Model.AssetsPumpPartMain(model); |
| | | input.Adapt(rhs); |
| | | var bol = _service.Update(rhs); |
| | | return bol; |
| | |
| | | /// <summary> |
| | | /// 批量更新 |
| | | /// </summary> |
| | | public async Task<bool> Updates(List<UpdatePumpPartMainInput> inputList) |
| | | public async Task<bool> Updates(List<UpdateAssetsPumpPartMainInput> inputList) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var list = inputList.Select(x => x.Adapt<UpdatePumpPartMainInput, Model.PumpPartMain>()).ToList(); |
| | | 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<UpdatePumpPartMainInput> list) |
| | | public async Task<bool> BulkUpdates(List<UpdateAssetsPumpPartMainInput> list) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | |
| | | } |
| | | |
| | | //编辑拓展 |
| | | public async Task<bool> UpdateEx(UpdatePumpPartMainInput pumppart, List<UpdatePumpPropContentInput> updatePumpPropContentDtos) |
| | | public async Task<bool> UpdateEx(UpdateAssetsPumpPartMainInput pumppart, List<UpdateAssetsPumpPropContentInput> updateAssetsPumpPropContentDtos) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var partmodel = pumppart.Adapt<UpdatePumpPartMainInput, Model.PumpPartMain>(); |
| | | var propcontentlistmodel = updatePumpPropContentDtos.Select(x => x.Adapt<UpdatePumpPropContentInput, Model.PumpPropContent>()).ToList(); |
| | | var partmodel = pumppart.Adapt<UpdateAssetsPumpPartMainInput, Model.AssetsPumpPartMain>(); |
| | | var propcontentlistmodel = updateAssetsPumpPropContentDtos.Select(x => x.Adapt<UpdateAssetsPumpPropContentInput, Model.AssetsPumpPropContent>()).ToList(); |
| | | return _service.UpdateEX(partmodel, propcontentlistmodel); |
| | | }); |
| | | } |
| | |
| | | |
| | | 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; |
| | | }); |
| | | /* return await Task.Factory.StartNew(() => |
| | | { |
| | | var bol = _service.DeleteExByID(ID); |
| | | if (!bol) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, "删除失败"); |
| | | } |
| | | return true; |
| | | });*/ |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |