ÎļþÃû´Ó BLL/HStation.BLL.Assets.Core/03-localclient/17-Flowmeter/AssetsFlowmeterSeries.cs ÐÞ¸Ä |
| | |
| | | using HStation.Dto; |
| | | using Yw.Dto; |
| | | |
| | | namespace HStation.CAL.LocalClient |
| | | namespace HStation.CAL.LocalClient |
| | | { |
| | | /// <summary> |
| | | /// æµé计系å |
| | | ///</summary> |
| | | /// |
| | | /// </summary> |
| | | public class AssetsFlowmeterSeries : IAssetsFlowmeterSeries |
| | | { |
| | | private readonly Service.AssetsFlowmeterSeries _service = new(); |
| | | private readonly HStation.Service.AssetsFlowmeterSeries _service = new(); |
| | | |
| | | #region Query |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åæå¤§æåºç |
| | | /// </summary> |
| | | public async Task<int> GetMaxSortCode() |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var sort_code = _service.GetMaxSortCode(); |
| | | return sort_code; |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åæå¤§æåºç |
| | | /// </summary> |
| | | public async Task<int> GetMaxSortCode(long ParentID) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var sort_code = _service.GetMaxSortCode(ParentID); |
| | | return sort_code; |
| | | }); |
| | | } |
| | | |
| | | #endregion Query |
| | | #endregion |
| | | |
| | | #region Insert |
| | | |
| | |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var parentIds = new List<long>(); |
| | | if (input.ParentID > 0) |
| | | { |
| | | var parent = _service.GetByID(input.ParentID); |
| | | if (parent == null) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ParentID:{input.ParentID} æ°æ®ä¸åå¨"); |
| | | } |
| | | parentIds = TreeParentIdsHelper.GetChildParentIds(parent.ID, parent.ParentIds); |
| | | } |
| | | if (!string.IsNullOrEmpty(input.TagName)) |
| | | { |
| | | if (_service.IsExistTagName(input.TagName)) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"TagName:{input.TagName}", "æ è®°å·²åå¨"); |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"TagName:{input.TagName} æ è®°å·²åå¨"); |
| | | } |
| | | } |
| | | var model = input.Adapt<AddAssetsFlowmeterSeriesInput, Model.AssetsFlowmeterSeries>(); |
| | | var parent_id = Yw.Untity.TreeParentIdsHelper.GetLastParentID(input.ParentIds); |
| | | model.SortCode = _service.GetMaxSortCode(parent_id) + 1; |
| | | model.ParentIds = parentIds; |
| | | model.SortCode = _service.GetMaxSortCode(input.ParentID) + 1; |
| | | var id = _service.Insert(model); |
| | | return id; |
| | | }); |
| | |
| | | }); |
| | | } |
| | | |
| | | #endregion Insert |
| | | #endregion |
| | | |
| | | #region Update |
| | | |
| | |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} æ°æ®ä¸åå¨"); |
| | | } |
| | | |
| | | if (!string.IsNullOrEmpty(input.TagName)) |
| | | { |
| | | if (_service.IsExistTagNameExceptID(input.TagName, input.ID)) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"TagName:{input.TagName}", "æ è®°å·²åå¨"); |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"TagName:{input.TagName} æ è®°å·²åå¨"); |
| | | } |
| | | } |
| | | var rhs = new Model.AssetsFlowmeterSeries(model); |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ´æ°æ æåº |
| | | /// æ´æ°æ æåºç |
| | | /// </summary> |
| | | public async Task<bool> UpdateTreeSortCode(long ID, long ParentID, int SortCode) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var bol = _service.UpdateTreeSortCode(ID, new List<long>() { ParentID }, SortCode); |
| | | return bol; |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ´æ°æ æåºç |
| | | /// </summary> |
| | | public async Task<bool> UpdateTreeSortCode(long ID, List<long> ParentIds, int SortCode) |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | | { |
| | | var bol = _service.UpdateTreeSortCode(ID, ParentIds, SortCode); |
| | | var model = _service.GetByID(ID); |
| | | if (model == null) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{ID} æ°æ®ä¸åå¨"); |
| | | } |
| | | var parentIds = new List<long>(); |
| | | if (ParentID > 0) |
| | | { |
| | | var parent = _service.GetByID(ParentID); |
| | | if (parent == null) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ParentID:{ParentID} æ°æ®ä¸åå¨"); |
| | | } |
| | | parentIds = TreeParentIdsHelper.GetChildParentIds(parent.ID, parent.ParentIds); |
| | | } |
| | | var sorterList = new List<Yw.Model.TreeSorter>() |
| | | { |
| | | new Yw.Model.TreeSorter() |
| | | { |
| | | ID=ID, |
| | | ParentIds=parentIds, |
| | | SortCode=SortCode |
| | | } |
| | | }; |
| | | if (TreeParentIdsHelper.ToString(parentIds) != TreeParentIdsHelper.ToString(model.ParentIds)) |
| | | { |
| | | var children = _service.GetChildrenByID(ID); |
| | | if (children != null && children.Count > 0) |
| | | { |
| | | foreach (var item in children) |
| | | { |
| | | var itemParent = sorterList.Find(x => x.ID == item.ParentIds.Last()); |
| | | var itemParentIds = TreeParentIdsHelper.GetChildParentIds(itemParent.ID, itemParent.ParentIds); |
| | | var sorter = new Yw.Model.TreeSorter() |
| | | { |
| | | ID = item.ID, |
| | | ParentIds = itemParentIds, |
| | | SortCode = item.SortCode |
| | | }; |
| | | sorterList.Add(sorter); |
| | | } |
| | | } |
| | | } |
| | | var bol = _service.UpdateTreeSorter(sorterList); |
| | | return bol; |
| | | }); |
| | | } |
| | |
| | | }); |
| | | } |
| | | |
| | | #endregion Update |
| | | |
| | | #endregion |
| | | |
| | | #region Exist |
| | | |
| | | /// <summary> |
| | | /// 夿TagNameæ¯å¦åå¨ |
| | | /// |
| | | /// </summary> |
| | | public async Task<bool> IsExistTagName(string TagName) |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 夿TagNameæ¯å¦åå¨ ExceptID |
| | | /// |
| | | /// </summary> |
| | | public async Task<bool> IsExistTagNameExceptID(string TagName, long ExceptID) |
| | | { |
| | |
| | | }); |
| | | } |
| | | |
| | | #endregion Exist |
| | | #endregion |
| | | |
| | | #region Delete |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¨é¨å é¤ |
| | | /// å é¤å
¨é¨ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<bool> DeleteAll() |
| | | { |
| | | return await Task.Factory.StartNew(() => |
| | |
| | | }); |
| | | } |
| | | |
| | | #endregion Delete |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | } |