private void GetTestSystemItemControlsSpecItems(List <SpecItem> newSpecItems)
        {
            var tempSetting      = specInfo.TempSetting.Split(",");
            var testSystemGroups = BaseSettingsManager.Get <SystemGroupSetting>().GetTestGroupByProductClass(classID);
            var groups           = SystemGroupSetting.GroupSystemByTempGroup(testSystemGroups);

            foreach (var group in groups)
            {     //规格组
                for (int temp = 0; temp < tempSetting.Length; temp++)
                { //温度
                    var tempstring = tempSetting[temp];
                    if (string.IsNullOrEmpty(tempstring))
                    {
                        continue;
                    }

                    foreach (var systemGroup in group.Value)
                    {//测试组
                        var list = new List <SpecItem>();
                        foreach (var testSystem in BaseSettingsManager.Get <SystemGroupSetting>().GetTestItemByGroup(systemGroup.TestGroupID))
                        {//测试指标
                            if (testSystem.TemperatureSetting != 0 && temp > 0)
                            {
                                continue;
                            }

                            var testSystemItemControl = GetTestSystemItemControl(testSystem.SystemID);
                            if (testSystemItemControl == null)
                            {
                                continue;
                            }

                            var settings = testSystemItemControl.GetSetting();
                            if (settings == null || settings.Length < 1)
                            {
                                continue;
                            }

                            var specs = testSystemItemControl.GetSpec(temp);
                            if (specs == null)
                            {
                                continue;
                            }

                            if (specs.Count < 1)
                            {
                                continue;
                            }

                            foreach (var setting in settings)
                            {
                                if (string.IsNullOrEmpty(setting))
                                {
                                    continue;
                                }

                                var olditem = specInfo.SpecItems.FirstOrDefault(
                                    q => q.SystemID == testSystem.SystemID &&
                                    q.TestTemp == tempstring &&
                                    q.TestInfo == setting
                                    );

                                if (olditem != null &&
                                    (newSpecItems.Any(q => q.SpecItemID == olditem.SpecItemID) ||
                                     list.Any(q => q.SpecItemID == olditem.SpecItemID)))
                                {
                                    olditem = null;
                                }

                                list.Add(
                                    new SpecItem()
                                {
                                    SpecItemID     = olditem == null ? Guid.NewGuid() : olditem.SpecItemID,
                                    SeqID          = specInfo.SeqID,
                                    SystemID       = testSystem.SystemID,
                                    ItemName       = MeasuringManager.GetSettingItemName(testSystem.DisplayName, setting, testSystem.PortSetting),
                                    TestTemp       = tempstring,
                                    TestInfo       = setting,
                                    ComputeSetting = specs.ToJsonString(),
                                    OrderID        = list.Count + 1
                                });
                            }
                        }

                        /*
                         * if (systemGroup.TestGroupTestType == "Point" ||
                         *  systemGroup.TestGroupTestType == "PointPDL" ||
                         *  systemGroup.TestGroupTestType == "RL")
                         * {
                         *  list.Sort((x, y) =>
                         *  {
                         *      var compare = x.TestInfo.CompareTo(y.TestInfo);
                         *      if (compare == 0)
                         *          compare = x.OrderID.CompareTo(y.OrderID);
                         *      return compare;
                         *  });
                         * }
                         */
                        foreach (var item in list)
                        {
                            item.OrderID = newSpecItems.Count + 1;
                            newSpecItems.Add(item);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public MeasurementJobSpec(SpecInfo specInfo, Guid classID)
        {
            SeqID            = specInfo.SeqID;
            SeqName          = specInfo.SeqName;
            CenterWavelenghs = specInfo.CenterWavelenghs.Split(',').Select(q => q.CastTo(1550D)).ToArray();
            WavelenghStart   = specInfo.WavelenghStart;
            WavelenghEnd     = specInfo.WavelenghEnd;
            WavelenghStep    = specInfo.WavelenghStep;
            TempSetting      = specInfo.TempSetting.Split(',');
            SeqData          = specInfo.SeqData;
            CreateTime       = specInfo.CreateTime;
            UpdateTime       = specInfo.UpdateTime;
            SeqVersion       = specInfo.SeqVersion;

            WorkInfoSpecItems = new List <WorkInfoSpecItem>();

            TestLists = new List <Dictionary <int, Dictionary <Guid, List <Guid> > > >();

            var groupSetting = BaseSettingsManager.Get <SystemGroupSetting>();

            TestSystemGroups = groupSetting.GetTestGroupByProductClass(classID).OrderBy(q => q.OrderID).ToList();
            Ports            = groupSetting.GetPorts(classID);

            foreach (var item in specInfo.SpecItems)
            {
                var systemItem = groupSetting.GetTestSystemItem(item.SystemID);
                if (systemItem == null)
                {
                    continue;
                }
                var systemGroup = TestSystemGroups.FirstOrDefault(q => q.TestGroupID == systemItem.TestGroupID);
                if (systemGroup == null)
                {
                    continue;
                }

                int tempIndex = Array.IndexOf(TempSetting, item.TestTemp);
                WorkInfoSpecItems.Add(
                    new WorkInfoSpecItem()
                {
                    SpecItemID         = item.SpecItemID,
                    TestGroupID        = systemGroup.TestGroupID,
                    TestGroupTestType  = systemGroup.TestGroupTestType,
                    SystemID           = item.SystemID,
                    SystemName         = systemItem.SystemName,
                    SystemTypeID       = systemItem.SystemTypeID,
                    PortSetting        = systemItem.PortSetting,
                    TemperatureSetting = systemItem.TemperatureSetting,
                    ItemName           = item.ItemName,
                    TestTemp           = item.TestTemp,
                    TestTempOrder      = tempIndex,
                    TestSetting        = item.TestInfo,
                    ComputeSetting     = item.ComputeSetting.FromJsonString <Dictionary <int, ComputeSettingItem> >(),
                    OrderID            = item.OrderID
                });
            }
            WorkInfoSpecItems.Sort((a, b) => a.OrderID.CompareTo(b.OrderID));

            var groups = SystemGroupSetting.GroupSystemByTempGroup(TestSystemGroups);

            foreach (var group in groups)
            {
                var groupItems = new Dictionary <int, Dictionary <Guid, List <Guid> > >();
                for (int temp = 0; temp < TempSetting.Length; temp++)
                {
                    var tempData = new Dictionary <Guid, List <Guid> >();
                    foreach (var systemGroup in group.Value)
                    {
                        var items = WorkInfoSpecItems.Where(q => q.TestGroupID == systemGroup.TestGroupID).ToList();
                        if (items.Count < 1)
                        {
                            continue;
                        }

                        var tempList = items.Where(q => q.TestTempOrder == temp).Select(q => q.SpecItemID).ToList();
                        if (tempList.Count < 1)
                        {
                            continue;
                        }

                        tempData[systemGroup.TestGroupID] = new List <Guid>(tempList);
                    }

                    if (tempData.Count > 0)
                    {
                        groupItems[temp] = tempData;
                    }
                }
                if (groupItems.Count > 0)
                {
                    TestLists.Add(groupItems);
                }
            }
        }