duheng
2024-10-15 21d9f7bcbe8c82d2af9dbdc18f189a3bb1672d74
BLL/HStation.BLL.PhartRelation.Core/03-localclient/02-valve-main/XhsValveMainPhartMappingExtensions.cs
@@ -1,7 +1,7 @@
namespace HStation.CAL.LocalClient
{
    /// <summary>
    ///
    ///
    /// </summary>
    public class XhsValveMainPhartMappingExtensions : IXhsValveMainPhartMappingExtensions
    {
@@ -12,7 +12,7 @@
        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        /// <returns></returns>
        public async Task<List<XhsValveMainPhartMappingExtensionsDto>> GetAll()
        {
            return await Task.Factory.StartNew(() =>
@@ -21,9 +21,8 @@
            });
        }
        /// <summary>
        ///  通过 ValveMainID 获取
        ///  通过 ValveMainID 获取
        /// </summary>
        public async Task<List<XhsValveMainPhartMappingExtensionsDto>> GetByValveMainID(long ValveMainID)
        {
@@ -64,7 +63,7 @@
            });
        }
        #endregion
        #endregion Query
        #region Insert
@@ -100,7 +99,6 @@
            });
        }
        /// <summary>
        /// 大批量插入
        /// </summary>
@@ -112,7 +110,7 @@
            });
        }
        #endregion
        #endregion Insert
        #region Update
@@ -123,70 +121,67 @@
        {
            return await Task.Factory.StartNew(() =>
            {
                //var mapping = _service.GetByID(input.ID);
                //if (mapping == null)
                //{
                //    throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在");
                //}
                //var equipment = new Service.ValveMain().GetByID(input.ValveMainID);
                //if (equipment == null)
                //{
                //    throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ValveMainID:{input.ValveMainID} 数据不存在");
                //}
                //var diagram = new Yw.Service.PhartDiagram().GetByID(input.DiagramID);
                //if (diagram == null)
                //{
                //    throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"DiagramID:{input.DiagramID} 数据不存在");
                //}
                var mapping = _service.GetByID(input.ID);
                if (mapping == null)
                {
                    throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在");
                }
                var equipment = new Service.AssetsValveMain().GetByID(input.ValveMainID);
                if (equipment == null)
                {
                    throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ValveMainID:{input.ValveMainID} 数据不存在");
                }
                var diagram = new Yw.Service.PhartDiagram().GetByID(input.DiagramID);
                if (diagram == null)
                {
                    throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"DiagramID:{input.DiagramID} 数据不存在");
                }
                //if (input.Diagram != null)
                //{
                //    if (input.Diagram.ID != input.DiagramID)
                //    {
                //        throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"图表数据不匹配");
                //    }
                //    if (input.Diagram.GraphList != null && input.Diagram.GraphList.Count > 0)
                //    {
                //        if (input.Diagram.GraphList.Exists(x => x.DiagramID != input.DiagramID))
                //        {
                //            throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"图形数据不匹配");
                //        }
                //    }
                //}
                if (input.Diagram != null)
                {
                    if (input.Diagram.ID != input.DiagramID)
                    {
                        throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"图表数据不匹配");
                    }
                    if (input.Diagram.GraphList != null && input.Diagram.GraphList.Count > 0)
                    {
                        if (input.Diagram.GraphList.Exists(x => x.DiagramID != input.DiagramID))
                        {
                            throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"图形数据不匹配");
                        }
                    }
                }
                //var mapping_rhs = new Model.XhsValveMainPhartMapping(mapping);
                //input.Adapt(mapping_rhs);
                var mapping_rhs = new Model.XhsValveMainPhartMapping(mapping);
                input.Adapt(mapping_rhs);
                //Yw.Model.PhartDiagram diagram_rhs = null;
                //List<Yw.Model.PhartGraph> graph_rhs_list = null;
                //if (input.Diagram != null)
                //{
                //    diagram_rhs = new Yw.Model.PhartDiagram(diagram);
                //    input.Diagram.Adapt(diagram_rhs);
                //    if (input.Diagram.GraphList != null && input.Diagram.GraphList.Count > 0)
                //    {
                //        var service_graph = new Yw.Service.PhartGraph();
                //        graph_rhs_list = new List<Yw.Model.PhartGraph>();
                //        foreach (var graph in input.Diagram.GraphList)
                //        {
                //            var graph_model = service_graph.GetByID(graph.ID);
                //            if (graph_model == null)
                //            {
                //                throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"GraphID:{graph.ID} 数据不存在");
                //            }
                //            var graph_rhs = new Yw.Model.PhartGraph(graph_model);
                //            graph.Adapt(graph_rhs);
                //            graph_rhs_list.Add(graph_rhs);
                //        }
                //    }
                //}
                Yw.Model.PhartDiagram diagram_rhs = null;
                List<Yw.Model.PhartGraph> graph_rhs_list = null;
                if (input.Diagram != null)
                {
                    diagram_rhs = new Yw.Model.PhartDiagram(diagram);
                    input.Diagram.Adapt(diagram_rhs);
                    if (input.Diagram.GraphList != null && input.Diagram.GraphList.Count > 0)
                    {
                        var service_graph = new Yw.Service.PhartGraph();
                        graph_rhs_list = new List<Yw.Model.PhartGraph>();
                        foreach (var graph in input.Diagram.GraphList)
                        {
                            var graph_model = service_graph.GetByID(graph.ID);
                            if (graph_model == null)
                            {
                                throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"GraphID:{graph.ID} 数据不存在");
                            }
                            var graph_rhs = new Yw.Model.PhartGraph(graph_model);
                            graph.Adapt(graph_rhs);
                            graph_rhs_list.Add(graph_rhs);
                        }
                    }
                }
                //var bol = _service.UpdateEx(mapping_rhs, diagram_rhs, graph_rhs_list);
                //return bol;
                return false;
                var bol = _service.UpdateEx(mapping_rhs, diagram_rhs, graph_rhs_list);
                return bol;
            });
        }
        /// <summary>
@@ -200,7 +195,6 @@
            });
        }
        /// <summary>
        /// 大批量更新
        /// </summary>
@@ -212,7 +206,7 @@
            });
        }
        #endregion
        #endregion Update
        #region Delete
@@ -229,7 +223,7 @@
        /// <summary>
        /// 通过 DiagramID 删除
        /// </summary>
        /// </summary>
        public async Task<bool> DeleteByDiagramID(long DiagramID)
        {
            return await Task.Factory.StartNew(() =>
@@ -241,7 +235,6 @@
                }
                return bol;
            });
        }
        /// <summary>
@@ -266,6 +259,7 @@
                return false;
            });
        }
        #endregion
        #endregion Delete
    }
}
}