using AutoMapper;
|
using HStation.Vmo;
|
using System.Collections.Generic;
|
using Yw;
|
using Yw.Dto;
|
|
namespace HStation.BLL
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class AssetsPumpMain
|
{
|
private readonly HStation.CAL.IAssetsPumpMain _cal = CALCreateHelper.CreateCAL<HStation.CAL.IAssetsPumpMain>();
|
|
#region Query
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<List<Vmo.AssetsPumpMainVmo>> GetAll()
|
{
|
var DtoList = await _cal.GetAll();
|
return Dto2Vmos(DtoList);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<Vmo.AssetsPumpMainVmo> GetByID(long ID)
|
{
|
var Dto = await _cal.GetByID(ID);
|
return Dto2Vmo(Dto);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<Vmo.PumpExInformationVmo> GetByIDEx(long ID)
|
{
|
var Dto = await _cal.GetByID(ID);
|
var partList = await GetPartByID(ID);
|
var vmo = new PumpExInformationVmo();
|
if (partList.Count > 0 && partList != null)
|
{
|
var contentList = await new BLL.AssetsPumpPropContent().GetByPumpPartID(partList.First().ID);
|
vmo.PropContent = contentList;
|
}
|
return vmo;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<List<Vmo.AssetsPumpMainVmo>> GetByIds(List<long> Ids)
|
{
|
var DtoList = await _cal.GetByIds(Ids);
|
return Dto2Vmos(DtoList);
|
}
|
|
/// <summary>
|
///通过泵ID获取产品列表
|
/// </summary>
|
public async Task<List<Vmo.AssetsPumpPartMainVmo>> GetPartByID(long ID)
|
{
|
var DtoList = await _cal.GetPartByID(ID);
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Dto.Assets.AssetsPumpPartMainDto, Vmo.AssetsPumpPartMainVmo>()
|
).CreateMapper();
|
var vmoList = mapper.Map<List<Dto.Assets.AssetsPumpPartMainDto>, List<Vmo.AssetsPumpPartMainVmo>>(DtoList);
|
return vmoList;
|
}
|
|
/// <summary>
|
/// 获取数量
|
/// </summary>
|
public virtual async Task<int> GetCount()
|
{
|
var count = await _cal.GetCount();
|
return count;
|
}
|
|
#endregion Query
|
|
#region Insert
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<long> Insert(Vmo.AssetsPumpMainVmo model)
|
{
|
var dto = Vmo2AddDto(model);
|
var id = await _cal.Insert(dto);
|
return id;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> Inserts(List<Vmo.AssetsPumpMainVmo> list)
|
{
|
var dtoList = Vmo2AddDtos(list);
|
var bol = await _cal.Inserts(dtoList);
|
return bol;
|
}
|
|
/// <summary>
|
/// 插入拓展
|
/// </summary>
|
/// <param name="input"></param>
|
/// <param name="map"></param>
|
/// <returns></returns>
|
/// <exception cref="NotImplementedException"></exception>
|
public async Task<long> InsertEx(Vmo.AssetsPumpMainVmo input, Vmo.AssetsPumpGroupAndMainMapVmo map)
|
{
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Vmo.AssetsPumpMainVmo, AddAssetsPumpMainInput>()
|
).CreateMapper();
|
var vmo = mapper.Map<Vmo.AssetsPumpMainVmo, AddAssetsPumpMainInput>(input);
|
var MappingMapper = new MapperConfiguration(cfg => cfg.CreateMap<Vmo.AssetsPumpGroupAndMainMapVmo, AddAssetsPumpGroupAndMainMapInput>()
|
).CreateMapper();
|
var MappingVmo = MappingMapper.Map<Vmo.AssetsPumpGroupAndMainMapVmo, AddAssetsPumpGroupAndMainMapInput>(map);
|
return await _cal.InsertEx(vmo, MappingVmo);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> BulkInserts(List<Vmo.AssetsPumpMainVmo> list)
|
{
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Vmo.AssetsPumpMainVmo, AddAssetsPumpMainInput>()
|
).CreateMapper();
|
var VmoList = mapper.Map<List<Vmo.AssetsPumpMainVmo>, List<AddAssetsPumpMainInput>>(list);
|
return await _cal.BulkInserts(VmoList);
|
}
|
|
#endregion Insert
|
|
#region Update
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> Update(Vmo.AssetsPumpMainVmo model)
|
{
|
var dto = Vmo2UpdateDto(model);
|
var bol = await _cal.Update(dto);
|
return bol;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> Updates(List<Vmo.AssetsPumpMainVmo> list)
|
{
|
var dtoList = Vmo2UpdateDtos(list);
|
var bol = await _cal.Updates(dtoList);
|
return bol;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> BulkUpdates(List<Vmo.AssetsPumpMainVmo> list)
|
{
|
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Vmo.AssetsPumpMainVmo, UpdateAssetsPumpMainInput>()
|
).CreateMapper();
|
var VmoList = mapper.Map<List<Vmo.AssetsPumpMainVmo>, List<UpdateAssetsPumpMainInput>>(list);
|
|
return await _cal.BulkUpdates(VmoList);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> UpdateSortCode(long ID, int SortCode)
|
{
|
return await _cal.UpdateSortCode(ID, SortCode);
|
}
|
|
public async Task<bool> UpdateSorter(List<UpdateSortCodeInput> Sorters)
|
{
|
return await _cal.UpdateSorter(Sorters);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public Task<bool> UpdateParas(long ID, Dictionary<string, string> Paras)
|
{
|
return _cal.UpdateParas(ID, Paras);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public Task<bool> UpdateFlags(long ID, List<string> Flags)
|
{
|
return _cal.UpdateFlags(ID, Flags);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public Task<bool> UpdateTagName(long ID, string TagName)
|
{
|
return _cal.UpdateTagName(ID, TagName);
|
}
|
|
#endregion Update
|
|
#region Delete
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> DeleteByID(long ID)
|
{
|
return await _cal.DeleteByID(ID);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> DeleteByIds(List<long> Ids)
|
{
|
return await _cal.DeleteByIds(Ids);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public async Task<bool> DeleteAll()
|
{
|
return await _cal.DeleteAll();
|
}
|
|
public async Task<List<Vmo.AssetsPumpMainVmo>> GetByPumpSeriesID(long ID)
|
{
|
var DtoList = await _cal.GetByPumpSeriesID(ID);
|
var dtoList = Dto2Vmos(DtoList);
|
return dtoList;
|
}
|
|
/// <summary>
|
///通过型号ID删除Map中对应数据
|
/// </summary>
|
public async Task<bool> DeleteMapByMainID(long ID)
|
{
|
return await _cal.DeleteMapByMainID(ID);
|
}
|
|
#endregion Delete
|
}
|
}
|