tx
8 天以前 e0b138b3e057de6f57021e6c8963868f5c5acc5a
TProduct.BLL/TProduct.BLL.Main/测试台/测试台信息/WorkBenchBase.cs
@@ -85,7 +85,6 @@
        /// </summary>
        public bool Copy(Model.WorkBenchBase workBench)
        {
            if (workBench.LinkType == Model.eLinkType.KeDi)
            {
                var new_workBench = new Model.WorkBenchBase(workBench);
@@ -101,22 +100,22 @@
                var new_workBench_id = _dal.Insert(entity_new_workBench);
                new_workBench.ID = new_workBench_id;
                var bllMp = new BLL.WorkBenchMonitorPoint();
                var allMonitorPoints = bllMp.GetByBenchID(workBench.ID);
                if (allMonitorPoints != null && allMonitorPoints.Count > 0)
                {
                    var new_allMonitorPoints = new List<Model.WorkBenchMonitorPoint>();
                    var mp_codes = bllMp.CreateNO(allMonitorPoints.Count);
                    for (int i = 0; i < allMonitorPoints.Count; i++)
                    {
                        Model.WorkBenchMonitorPoint new_monitorPoint = new Model.WorkBenchMonitorPoint(allMonitorPoints[i]);
                        new_monitorPoint.ID = 0;
                        new_monitorPoint.Code = mp_codes[i];
                        new_monitorPoint.BenchID = new_workBench_id;
                        new_allMonitorPoints.Add(new_monitorPoint);
                    }
                    bllMp.Inserts(new_allMonitorPoints);
                }
                //var bllMp = new BLL.WorkBenchMonitorPoint();
                //var allMonitorPoints = bllMp.GetByBenchID(workBench.ID);
                //if (allMonitorPoints != null && allMonitorPoints.Count > 0)
                //{
                //    var new_allMonitorPoints = new List<Model.WorkBenchMonitorPoint>();
                //    var mp_codes = bllMp.CreateNO(allMonitorPoints.Count);
                //    for (int i = 0; i < allMonitorPoints.Count; i++)
                //    {
                //        Model.WorkBenchMonitorPoint new_monitorPoint = new Model.WorkBenchMonitorPoint(allMonitorPoints[i]);
                //        new_monitorPoint.ID = 0;
                //        new_monitorPoint.Code = mp_codes[i];
                //        new_monitorPoint.BenchID = new_workBench_id;
                //        new_allMonitorPoints.Add(new_monitorPoint);
                //    }
                //    bllMp.Inserts(new_allMonitorPoints);
                //}
                var allInstruments = new BLL.WorkBenchInstrumentKedi().GetByBenchID(workBench.ID);
                if (allInstruments != null && allInstruments.Count > 0)
                {
@@ -156,23 +155,23 @@
                new_workBench.ID = new_workBench_id;
                var bllMp = new BLL.WorkBenchMonitorPoint();
                var old_allMonitorPoints = bllMp.GetByBenchID(workBench.ID);
                if (old_allMonitorPoints != null && old_allMonitorPoints.Count > 0)
                {
                    List<Model.WorkBenchMonitorPoint> new_allMonitorPoints1 = new List<Model.WorkBenchMonitorPoint>();
                    var mp_codes = bllMp.CreateNO(old_allMonitorPoints.Count);
                    for (int i = 0; i < old_allMonitorPoints.Count; i++)
                    {
                        Model.WorkBenchMonitorPoint new_monitorPoint = new Model.WorkBenchMonitorPoint(old_allMonitorPoints[i]);
                        new_monitorPoint.ID = 0;
                        new_monitorPoint.Code = mp_codes[i];
                        new_monitorPoint.BenchID = new_workBench_id;
                        new_allMonitorPoints1.Add(new_monitorPoint);
                    }
                    bllMp.Inserts(new_allMonitorPoints1);
                }
                var new_allMonitorPoints = bllMp.GetByBenchID(new_workBench_id);
                //var bllMp = new BLL.WorkBenchMonitorPoint();
                //var old_allMonitorPoints = bllMp.GetByBenchID(workBench.ID);
                //if (old_allMonitorPoints != null && old_allMonitorPoints.Count > 0)
                //{
                //    List<Model.WorkBenchMonitorPoint> new_allMonitorPoints1 = new List<Model.WorkBenchMonitorPoint>();
                //    var mp_codes = bllMp.CreateNO(old_allMonitorPoints.Count);
                //    for (int i = 0; i < old_allMonitorPoints.Count; i++)
                //    {
                //        Model.WorkBenchMonitorPoint new_monitorPoint = new Model.WorkBenchMonitorPoint(old_allMonitorPoints[i]);
                //        new_monitorPoint.ID = 0;
                //        new_monitorPoint.Code = mp_codes[i];
                //        new_monitorPoint.BenchID = new_workBench_id;
                //        new_allMonitorPoints1.Add(new_monitorPoint);
                //    }
                //    bllMp.Inserts(new_allMonitorPoints1);
                //}
                //var new_allMonitorPoints = bllMp.GetByBenchID(new_workBench_id);
                var bll_sz02 = new BLL.WorkBenchInstrumentShun();
                var old_allSz02s = bll_sz02.GetByBenchID(workBench.ID);
@@ -202,13 +201,13 @@
                                Model.WorkBenchInstrumentShunPortAna new_ana_port =
                                     new Model.WorkBenchInstrumentShunPortAna(old_ana);
                                new_ana_port.LinkID = new_sz02.ID;
                                if (old_ana.MonitorPointID > 0)
                                {
                                    var old_Monitor = old_allMonitorPoints.Find(x => x.ID == old_ana.MonitorPointID);
                                    var new_Monitor = new_allMonitorPoints.Find(x => x.MonitorType == old_Monitor.MonitorType &&
                                     x.Property == old_Monitor.Property);
                                    new_ana_port.MonitorPointID = new_Monitor.ID;
                                }
                                //if (old_ana.MonitorPointID > 0)
                                //{
                                //    var old_Monitor = old_allMonitorPoints.Find(x => x.ID == old_ana.MonitorPointID);
                                //    var new_Monitor = new_allMonitorPoints.Find(x => x.MonitorType == old_Monitor.MonitorType &&
                                //     x.Property == old_Monitor.Property);
                                //    new_ana_port.MonitorPointID = new_Monitor.ID;
                                //}
                                bll_ana.Insert(new_ana_port);
                            }
                        }
@@ -265,7 +264,7 @@
        /// </summary>
        public long InsertExParas(
            Model.WorkBenchBase BenchBase,
            List<Model.WorkBenchMonitorPoint> allMonitorPoints)
            List<long> allMonitorPointIDs)
        {
            _allWorkBenchs = null;
            BLL.WorkBenchMonitorPoint.ClearChache();
@@ -284,23 +283,23 @@
            var entity_base = Model2Entity(BenchBase);
            List<Entity.WorkBenchMonitorPoint> entities_allMonitorPoints = null;
            if (allMonitorPoints != null && allMonitorPoints.Count > 0)
            {
                var bll_point = new BLL.WorkBenchMonitorPoint();
                var Codes = bll_point.CreateNO(allMonitorPoints.Count);
                for (int i = 0; i < allMonitorPoints.Count; i++)
                {
                    var item = allMonitorPoints[i];
                    item.CreateTime = DateTime.Now;
                    item.UpdateTime = DateTime.Now;
                    item.Code = Codes[i];
                }
                var mapper = new MapperConfiguration(cfg => cfg.CreateMap<TProduct.Model.WorkBenchMonitorPoint, TProduct.Entity.WorkBenchMonitorPoint>()).CreateMapper();
                entities_allMonitorPoints = mapper.Map<List<TProduct.Model.WorkBenchMonitorPoint>, List<TProduct.Entity.WorkBenchMonitorPoint>>(allMonitorPoints);
            }
            //List<Entity.WorkBenchMonitorPoint> entities_allMonitorPoints = null;
            //if (allMonitorPoints != null && allMonitorPoints.Count > 0)
            //{
            //    var bll_point = new BLL.WorkBenchMonitorPoint();
            //    var Codes = bll_point.CreateNO(allMonitorPoints.Count);
            //    for (int i = 0; i < allMonitorPoints.Count; i++)
            //    {
            //        var item = allMonitorPoints[i];
            //        item.CreateTime = DateTime.Now;
            //        item.UpdateTime = DateTime.Now;
            //        item.Code = Codes[i];
            //    }
            //    var mapper = new MapperConfiguration(cfg => cfg.CreateMap<TProduct.Model.WorkBenchMonitorPoint, TProduct.Entity.WorkBenchMonitorPoint>()).CreateMapper();
            //    entities_allMonitorPoints = mapper.Map<List<TProduct.Model.WorkBenchMonitorPoint>, List<TProduct.Entity.WorkBenchMonitorPoint>>(allMonitorPoints);
            //}
            return _dal.InsertExParas(entity_base, entities_allMonitorPoints);
            return _dal.InsertExParas(entity_base, allMonitorPointIDs);
        }
        #endregion
@@ -381,7 +380,8 @@
        /// </summary>
        public bool Delete(Model.WorkBenchBase workBench)
        {
            new BLL.WorkBenchMonitorPoint().DeleteByWorkBenchID(workBench.ID);
            new BLL.WorkBenchMonitorPointMap().DeleteByWorkBenchID(workBench.ID);
            if (workBench.LinkType == Model.eLinkType.KeDi)
            {
                new BLL.WorkBenchInstrumentKedi().DeleteByWorkBenchID(workBench.ID);