using StandardLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace Model
{
    public class TestResult
    {
        public TestResult(string name)
        {
            Name = name;
        }
        public bool TestEnable { get; set; }
        public double OkRate { get; set; }
        public int Time { get; set; }
        public int OkNum { get; set; }
        public int NgNum { get; set; }
        public int TotalNum { get; set; }
        public string Name { get; }
    }
    public class BinBoxNum
    {
        public BinBoxNum(string name)
        {
            Name = name;
        }
        public int Count { get; set; }
        public int UpLimit { get; set; }
        public int TotalCount { get; set; }
        public string Name { get; }
    }
    public class Batch: IPlcAddressToPropertyPaths
    {
        public string StartUsername { get; set; }
        public string EndUsername { get; set; }
        public string BatchID { get; set; }
        public DateTime StartTime { get; set; }
        public User StartBatchUser { get; set; }
        public DateTime EndTime { get; set; }
        public User EndBatchUser { get; set; }
        public string RecipeName { get; set; }

        public bool Finished { get; set; }
        public uint MTBA { get; set; }
        public uint MTBF { get; set; }
        public uint MTTR { get; set; }
        public uint NormalWorkingTimeSpan { get; set; }
        public int MUBA { get; set; }
        public double UPH { get; set; }
        public int AlarmCount { get; set; }
        public uint ErrorTimeSpan { get; set; }
        public double WorkingTimeRate { get; set; }
        public int TotalNumOfBatch { get; set; }
        public int TapedNumOfBatch { get; set; }
        public TestResult 测试1 { get; set; } = new TestResult(nameof(测试1));
        public TestResult 测试2 { get; set; } = new TestResult(nameof(测试2));
        public TestResult 测试3 { get; set; } = new TestResult(nameof(测试3));
        public TestResult 测试4 { get; set; } = new TestResult(nameof(测试4));
        public TestResult 热测 { get; set; } = new TestResult(nameof(热测));
        public TestResult 镭射打标CCD { get; set; } = new TestResult(nameof(镭射打标CCD));
        public TestResult 测试5 { get; set; } = new TestResult(nameof(测试5));
        public TestResult _3D检测 { get; set; } = new TestResult(nameof(_3D检测));
        public TestResult 封装1CCD1 { get; set; } = new TestResult(nameof(封装1CCD1));
        public TestResult 封装1CCD2 { get; set; } = new TestResult(nameof(封装1CCD2));
        public TestResult 封装2CCD1 { get; set; } = new TestResult(nameof(封装2CCD1));
        public TestResult 封装2CCD2 { get; set; } = new TestResult(nameof(封装2CCD2));


        public BinBoxNum 方向NG料盒 { get; set; } = new BinBoxNum(nameof(方向NG料盒));

        public BinBoxNum 测试盒1格1 { get; set; } = new BinBoxNum(nameof(测试盒1格1));
        public BinBoxNum 测试盒1格2 { get; set; } = new BinBoxNum(nameof(测试盒1格2));
        public BinBoxNum 测试盒1格3 { get; set; } = new BinBoxNum(nameof(测试盒1格3));
        public BinBoxNum 测试盒1格4 { get; set; } = new BinBoxNum(nameof(测试盒1格4));

        public BinBoxNum 测试盒2格1 { get; set; } = new BinBoxNum(nameof(测试盒2格1));
        public BinBoxNum 测试盒2格2 { get; set; } = new BinBoxNum(nameof(测试盒2格2));
        public BinBoxNum 测试盒2格3 { get; set; } = new BinBoxNum(nameof(测试盒2格3));
        public BinBoxNum 测试盒2格4 { get; set; } = new BinBoxNum(nameof(测试盒2格4));

        public BinBoxNum 热测盒格1 { get; set; } = new BinBoxNum(nameof(热测盒格1));
        public BinBoxNum 热测盒格2 { get; set; } = new BinBoxNum(nameof(热测盒格2));
        public BinBoxNum 热测盒格3 { get; set; } = new BinBoxNum(nameof(热测盒格3));
        public BinBoxNum 热测盒格4 { get; set; } = new BinBoxNum(nameof(热测盒格4));

        public BinBoxNum _3D盒格1 { get; set; } = new BinBoxNum(nameof(_3D盒格1));
        public BinBoxNum _3D盒格2 { get; set; } = new BinBoxNum(nameof(_3D盒格2));
        public BinBoxNum _3D盒格3 { get; set; } = new BinBoxNum(nameof(_3D盒格3));
        public BinBoxNum _3D盒格4 { get; set; } = new BinBoxNum(nameof(_3D盒格4));

        public BinBoxNum 溢料盒 { get; set; } = new BinBoxNum(nameof(溢料盒));

        private Dictionary<string, string> PropertyPathPlcAddressPairs;

        public Dictionary<string, List<string>> PlcAddressPropertyPathsPairs { get; set; }
        public Batch()
        {
            /*
            var original = new Dictionary<string, string>
            {
                { "Alice", "Red" },
                { "Bob", "Blue" },
                { "Charlie", "Red" },
                { "David", "Green" }
            };

            // 反转：value -> List<key>
            var inverted = original
                .GroupBy(kvp => kvp.Value)
                .ToDictionary(
                    g => g.Key,
                    g => g.Select(kvp => kvp.Key).ToList()
                );
            //结果
            {
                { "Red",   ["Alice", "Charlie"] },
                { "Blue",  ["Bob"] },
                { "Green", ["David"] }
            }
            */

            PropertyPathPlcAddressPairs = new Dictionary<string, string>()
            {
                //{PropertyPathHelper.GetPath(()=>BatchID),"Application.Var_state.s当前批次" },
                {PropertyPathHelper.GetPath(()=>RecipeName),"" },
                //StartTime
                //EndTime
                {PropertyPathHelper.GetPath(()=>MTBA),"Application.Var_state.dw_mtba"},
                {PropertyPathHelper.GetPath(()=>MTBF),"Application.Var_state.dw_mtbf"},
                {PropertyPathHelper.GetPath(()=>MTTR),"Application.Var_state.dw_mttr"},
                {PropertyPathHelper.GetPath(()=>NormalWorkingTimeSpan),"Application.Var_state.dw设备运行时间"},
                {PropertyPathHelper.GetPath(()=>MUBA),"Application.Var_state.dw_muba"},
                {PropertyPathHelper.GetPath(()=>UPH),"Application.PieceDate.ui_UPH产量"},
                {PropertyPathHelper.GetPath(()=>AlarmCount),""},
                {PropertyPathHelper.GetPath(()=>ErrorTimeSpan),"Application.Var_state.dw设备故障时间"},
                {PropertyPathHelper.GetPath(()=>WorkingTimeRate),""},
                {PropertyPathHelper.GetPath(()=>TotalNumOfBatch),"Application.PieceDate.ui批次总数量"},
                {PropertyPathHelper.GetPath(()=>TapedNumOfBatch),"Application.PieceDate.ui编带总数量"},

                {PropertyPathHelper.GetPath(()=>测试1.TestEnable),"Application.Var_state.站位启用[5]"},
                {PropertyPathHelper.GetPath(()=>测试1.OkRate),"Application.PieceDate.re测试站1良率"},
                {PropertyPathHelper.GetPath(()=>测试1.Time),"Application.GVL_A05_Auto.iA05_周期运行时间"},
                {PropertyPathHelper.GetPath(()=>测试1.OkNum),"Application.PieceDate.ui测试站1良品数量"},
                {PropertyPathHelper.GetPath(()=>测试1.NgNum),"Application.PieceDate.ui测试站1不良数量"},
                {PropertyPathHelper.GetPath(()=>测试1.TotalNum),"Application.PieceDate.ui测试站1总数量"},

                {PropertyPathHelper.GetPath(()=>测试2.TestEnable),"Application.Var_state.站位启用[6]"},
                {PropertyPathHelper.GetPath(()=>测试2.OkRate),"Application.PieceDate.re测试站2良率"},
                {PropertyPathHelper.GetPath(()=>测试2.Time),"Application.GVL_A06_Auto.iA06_周期运行时间"},
                {PropertyPathHelper.GetPath(()=>测试2.OkNum),"Application.PieceDate.ui测试站2良品数量"},
                {PropertyPathHelper.GetPath(()=>测试2.NgNum),"Application.PieceDate.ui测试站2不良数量"},
                {PropertyPathHelper.GetPath(()=>测试2.TotalNum),"Application.PieceDate.ui测试站2总数量"},

                {PropertyPathHelper.GetPath(()=>测试3.TestEnable),"Application.Var_state.站位启用[7]"},
                {PropertyPathHelper.GetPath(()=>测试3.OkRate),"Application.PieceDate.re测试站3良率"},
                {PropertyPathHelper.GetPath(()=>测试3.Time),"Application.GVL_A07_Auto.iA07_周期运行时间"},
                {PropertyPathHelper.GetPath(()=>测试3.OkNum),"Application.PieceDate.ui测试站3良品数量"},
                {PropertyPathHelper.GetPath(()=>测试3.NgNum),"Application.PieceDate.ui测试站3不良数量"},
                {PropertyPathHelper.GetPath(()=>测试3.TotalNum),"Application.PieceDate.ui测试站3总数量"},

                {PropertyPathHelper.GetPath(()=>测试4.TestEnable),"Application.Var_state.站位启用[8]"},
                {PropertyPathHelper.GetPath(()=>测试4.OkRate),"Application.PieceDate.re测试站4良率"},
                {PropertyPathHelper.GetPath(()=>测试4.Time),"Application.GVL_A08_Auto.iA08_周期运行时间"},
                {PropertyPathHelper.GetPath(()=>测试4.OkNum),"Application.PieceDate.ui测试站4良品数量"},
                {PropertyPathHelper.GetPath(()=>测试4.NgNum),"Application.PieceDate.ui测试站4不良数量"},
                {PropertyPathHelper.GetPath(()=>测试4.TotalNum),"Application.PieceDate.ui测试站4总数量"},

                {PropertyPathHelper.GetPath(()=>热测.TestEnable),"Application.Var_state.站位启用[15]"},
                {PropertyPathHelper.GetPath(()=>热测.OkRate),"Application.PieceDate.re热测站良率"},
                {PropertyPathHelper.GetPath(()=>热测.Time),"Application.GVL_A15_Auto.iA15_周期运行时间"},
                {PropertyPathHelper.GetPath(()=>热测.OkNum),"Application.PieceDate.ui热测站良品数量"},
                {PropertyPathHelper.GetPath(()=>热测.NgNum),"Application.PieceDate.ui热测站不良数量"},
                {PropertyPathHelper.GetPath(()=>热测.TotalNum),"Application.PieceDate.ui热测站总数量"},

                {PropertyPathHelper.GetPath(()=>镭射打标CCD.TestEnable),"Application.Var_state.站位启用[24]"},
                {PropertyPathHelper.GetPath(()=>镭射打标CCD.OkRate),"Application.PieceDate.re镭射打标CCD良率"},
                {PropertyPathHelper.GetPath(()=>镭射打标CCD.Time),"Application.GVL_A24_Auto.iA24_周期运行时间"},
                {PropertyPathHelper.GetPath(()=>镭射打标CCD.OkNum),"Application.PieceDate.ui镭射打标CCD良品数量"},
                {PropertyPathHelper.GetPath(()=>镭射打标CCD.NgNum),"Application.PieceDate.ui镭射打标CCD不良数量"},
                {PropertyPathHelper.GetPath(()=>镭射打标CCD.TotalNum),"Application.PieceDate.ui镭射打标CCD总数量"},

                {PropertyPathHelper.GetPath(()=>测试5.TestEnable),"Application.Var_state.站位启用[27]"},
                {PropertyPathHelper.GetPath(()=>测试5.OkRate),"Application.PieceDate.re测试站5良率"},
                {PropertyPathHelper.GetPath(()=>测试5.Time),"Application.GVL_A27_Auto.iA27_周期运行时间"},
                {PropertyPathHelper.GetPath(()=>测试5.OkNum),"Application.PieceDate.ui测试站5良品数量"},
                {PropertyPathHelper.GetPath(()=>测试5.NgNum),"Application.PieceDate.ui测试站5不良数量"},
                {PropertyPathHelper.GetPath(()=>测试5.TotalNum),"Application.PieceDate.ui测试站5总数量"},

                {PropertyPathHelper.GetPath(()=>_3D检测.TestEnable),"Application.Var_state.站位启用[29]"},
                {PropertyPathHelper.GetPath(()=>_3D检测.OkRate),"Application.PieceDate.re_3D检测良率"},
                {PropertyPathHelper.GetPath(()=>_3D检测.Time),"Application.GVL_A29_Auto.iA29_周期运行时间"},
                {PropertyPathHelper.GetPath(()=>_3D检测.OkNum),"Application.PieceDate.ui_3D检测良品数量"},
                {PropertyPathHelper.GetPath(()=>_3D检测.NgNum),"Application.PieceDate.ui_3D检测不良数量"},
                {PropertyPathHelper.GetPath(()=>_3D检测.TotalNum),"Application.PieceDate.ui_3D检测总数量"},

                {PropertyPathHelper.GetPath(()=>封装1CCD1.TestEnable),"Application.Var_state.站位启用[33]"},
                {PropertyPathHelper.GetPath(()=>封装1CCD1.OkRate),"Application.PieceDate.re封装1CCD1良率"},
                {PropertyPathHelper.GetPath(()=>封装1CCD1.Time),"Application.Var_Auto_A33_Encapsulation1.ui_CT"},
                {PropertyPathHelper.GetPath(()=>封装1CCD1.OkNum),"Application.PieceDate.ui封装1CCD1良品数量"},
                {PropertyPathHelper.GetPath(()=>封装1CCD1.NgNum),"Application.PieceDate.ui封装1CCD1不良数量"},
                {PropertyPathHelper.GetPath(()=>封装1CCD1.TotalNum),"Application.PieceDate.ui封装1CCD1总数量"},

                {PropertyPathHelper.GetPath(()=>封装1CCD2.TestEnable),"Application.Var_state.站位启用[33]"},
                {PropertyPathHelper.GetPath(()=>封装1CCD2.OkRate),"Application.PieceDate.re封装1CCD2良率"},
                {PropertyPathHelper.GetPath(()=>封装1CCD2.Time),"Application.Var_Auto_A33_Encapsulation1.ui_CT"},
                {PropertyPathHelper.GetPath(()=>封装1CCD2.OkNum),"Application.PieceDate.ui封装1CCD2良品数量"},
                {PropertyPathHelper.GetPath(()=>封装1CCD2.NgNum),"Application.PieceDate.ui封装1CCD2不良数量"},
                {PropertyPathHelper.GetPath(()=>封装1CCD2.TotalNum),"Application.PieceDate.ui封装1CCD2总数量"},

                {PropertyPathHelper.GetPath(()=>封装2CCD1.TestEnable),"Application.Var_state.站位启用[37]"},
                {PropertyPathHelper.GetPath(()=>封装2CCD1.OkRate),"Application.PieceDate.re封装2CCD1良率"},
                {PropertyPathHelper.GetPath(()=>封装2CCD1.Time),"Application.Var_Auto_A37_Encapsulation2.ui_CT"},
                {PropertyPathHelper.GetPath(()=>封装2CCD1.OkNum),"Application.PieceDate.ui封装2CCD1良品数量"},
                {PropertyPathHelper.GetPath(()=>封装2CCD1.NgNum),"Application.PieceDate.ui封装2CCD1不良数量"},
                {PropertyPathHelper.GetPath(()=>封装2CCD1.TotalNum),"Application.PieceDate.ui封装2CCD1总数量"},

                {PropertyPathHelper.GetPath(()=>封装2CCD2.TestEnable),"Application.Var_state.站位启用[37]"},
                {PropertyPathHelper.GetPath(()=>封装2CCD2.OkRate),"Application.PieceDate.re封装2CCD2良率"},
                {PropertyPathHelper.GetPath(()=>封装2CCD2.Time),"Application.Var_Auto_A37_Encapsulation2.ui_CT"},
                {PropertyPathHelper.GetPath(()=>封装2CCD2.OkNum),"Application.PieceDate.ui封装2CCD2良品数量"},
                {PropertyPathHelper.GetPath(()=>封装2CCD2.NgNum),"Application.PieceDate.ui封装2CCD2不良数量"},
                {PropertyPathHelper.GetPath(()=>封装2CCD2.TotalNum),"Application.PieceDate.ui封装2CCD2总数量"},


                
                {PropertyPathHelper.GetPath(()=>方向NG料盒.Count),"Application.PieceDate.ui方向NG料盒数量"},
                {PropertyPathHelper.GetPath(()=>方向NG料盒.UpLimit),"Application.GVL_A03_Auto.uNG料盒数量设定"},
                {PropertyPathHelper.GetPath(()=>方向NG料盒.TotalCount),"Application.PieceDate.ui方向NG料盒总数量"},

                {PropertyPathHelper.GetPath(()=>测试盒1格1.Count),"Application.PieceDate.ui测试NG四排料盒1格1数量"},
                {PropertyPathHelper.GetPath(()=>测试盒1格1.UpLimit),"Application.GVL_A09_Auto.uNG料盒一数量设定"},
                {PropertyPathHelper.GetPath(()=>测试盒1格1.TotalCount),"Application.PieceDate.ui测试NG四排料盒1格1总数量"},

                {PropertyPathHelper.GetPath(()=>测试盒1格2.Count),"Application.PieceDate.ui测试NG四排料盒1格2数量"},
                {PropertyPathHelper.GetPath(()=>测试盒1格2.UpLimit),"Application.GVL_A09_Auto.uNG料盒二数量设定"},
                {PropertyPathHelper.GetPath(()=>测试盒1格2.TotalCount),"Application.PieceDate.ui测试NG四排料盒1格2总数量"},

                {PropertyPathHelper.GetPath(()=>测试盒1格3.Count),"Application.PieceDate.ui测试NG四排料盒1格3数量"},
                {PropertyPathHelper.GetPath(()=>测试盒1格3.UpLimit),"Application.GVL_A09_Auto.uNG料盒三数量设定"},
                {PropertyPathHelper.GetPath(()=>测试盒1格3.TotalCount),"Application.PieceDate.ui测试NG四排料盒1格3总数量"},

                {PropertyPathHelper.GetPath(()=>测试盒1格4.Count),"Application.PieceDate.ui测试NG四排料盒1格4数量"},
                {PropertyPathHelper.GetPath(()=>测试盒1格4.UpLimit),"Application.GVL_A09_Auto.uNG料盒四数量设定"},
                {PropertyPathHelper.GetPath(()=>测试盒1格4.TotalCount),"Application.PieceDate.ui测试NG四排料盒1格4总数量"},

                {PropertyPathHelper.GetPath(()=>测试盒2格1.Count),"Application.PieceDate.ui测试NG四排料盒2格1数量"},
                {PropertyPathHelper.GetPath(()=>测试盒2格1.UpLimit),"Application.GVL_A10_Auto.uNG料盒一数量设定"},
                {PropertyPathHelper.GetPath(()=>测试盒2格1.TotalCount),"Application.PieceDate.ui测试NG四排料盒2格1总数量"},

                {PropertyPathHelper.GetPath(()=>测试盒2格2.Count),"Application.PieceDate.ui测试NG四排料盒2格2数量"},
                {PropertyPathHelper.GetPath(()=>测试盒2格2.UpLimit),"Application.GVL_A10_Auto.uNG料盒二数量设定"},
                {PropertyPathHelper.GetPath(()=>测试盒2格2.TotalCount),"Application.PieceDate.ui测试NG四排料盒2格2总数量"},

                {PropertyPathHelper.GetPath(()=>测试盒2格3.Count),"Application.PieceDate.ui测试NG四排料盒2格3数量"},
                {PropertyPathHelper.GetPath(()=>测试盒2格3.UpLimit),"Application.GVL_A10_Auto.uNG料盒三数量设定"},
                {PropertyPathHelper.GetPath(()=>测试盒2格3.TotalCount),"Application.PieceDate.ui测试NG四排料盒2格3总数量"},

                {PropertyPathHelper.GetPath(()=>测试盒2格4.Count),"Application.PieceDate.ui测试NG四排料盒2格4数量"},
                {PropertyPathHelper.GetPath(()=>测试盒2格4.UpLimit),"Application.GVL_A10_Auto.uNG料盒四数量设定"},
                {PropertyPathHelper.GetPath(()=>测试盒2格4.TotalCount),"Application.PieceDate.ui测试NG四排料盒2格4总数量"},

                {PropertyPathHelper.GetPath(()=>热测盒格1.Count),"Application.PieceDate.ui热测NG四排料盒格1数量"},
                {PropertyPathHelper.GetPath(()=>热测盒格1.UpLimit),"Application.GVL_A22_Auto.uNG料盒一数量设定"},
                {PropertyPathHelper.GetPath(()=>热测盒格1.TotalCount),"Application.PieceDate.ui热测NG四排料盒格1总数量"},

                {PropertyPathHelper.GetPath(()=>热测盒格2.Count),"Application.PieceDate.ui热测NG四排料盒格2数量"},
                {PropertyPathHelper.GetPath(()=>热测盒格2.UpLimit),"Application.GVL_A22_Auto.uNG料盒二数量设定"},
                {PropertyPathHelper.GetPath(()=>热测盒格2.TotalCount),"Application.PieceDate.ui热测NG四排料盒格2总数量"},

                {PropertyPathHelper.GetPath(()=>热测盒格3.Count),"Application.PieceDate.ui热测NG四排料盒格3数量"},
                {PropertyPathHelper.GetPath(()=>热测盒格3.UpLimit),"Application.GVL_A22_Auto.uNG料盒三数量设定"},
                {PropertyPathHelper.GetPath(()=>热测盒格3.TotalCount),"Application.PieceDate.ui热测NG四排料盒格3总数量"},

                {PropertyPathHelper.GetPath(()=>热测盒格4.Count),"Application.PieceDate.ui热测NG四排料盒格4数量"},
                {PropertyPathHelper.GetPath(()=>热测盒格4.UpLimit),"Application.GVL_A22_Auto.uNG料盒四数量设定"},
                {PropertyPathHelper.GetPath(()=>热测盒格4.TotalCount),"Application.PieceDate.ui热测NG四排料盒格4总数量"},

                {PropertyPathHelper.GetPath(()=>_3D盒格1.Count),"Application.PieceDate.ui_3D检测NG四排料盒格1数量"},
                {PropertyPathHelper.GetPath(()=>_3D盒格1.UpLimit),"Application.GVL_A30_Auto.uNG料盒一数量设定"},
                {PropertyPathHelper.GetPath(()=>_3D盒格1.TotalCount),"Application.PieceDate.ui_3D检测NG四排料盒格1总数量"},

                {PropertyPathHelper.GetPath(()=>_3D盒格2.Count),"Application.PieceDate.ui_3D检测NG四排料盒格2数量"},
                {PropertyPathHelper.GetPath(()=>_3D盒格2.UpLimit),"Application.GVL_A30_Auto.uNG料盒二数量设定"},
                {PropertyPathHelper.GetPath(()=>_3D盒格2.TotalCount),"Application.PieceDate.ui_3D检测NG四排料盒格2总数量"},

                {PropertyPathHelper.GetPath(()=>_3D盒格3.Count),"Application.PieceDate.ui_3D检测NG四排料盒格3数量"},
                {PropertyPathHelper.GetPath(()=>_3D盒格3.UpLimit),"Application.GVL_A30_Auto.uNG料盒三数量设定"},
                {PropertyPathHelper.GetPath(()=>_3D盒格3.TotalCount),"Application.PieceDate.ui_3D检测NG四排料盒格3总数量"},

                {PropertyPathHelper.GetPath(()=>_3D盒格4.Count),"Application.PieceDate.ui_3D检测NG四排料盒格4数量"},
                {PropertyPathHelper.GetPath(()=>_3D盒格4.UpLimit),"Application.GVL_A30_Auto.uNG料盒四数量设定"},
                {PropertyPathHelper.GetPath(()=>_3D盒格4.TotalCount),"Application.PieceDate.ui_3D检测NG四排料盒格4总数量"},

                {PropertyPathHelper.GetPath(()=>溢料盒.Count),"Application.PieceDate.ui溢料盒数量"},
                {PropertyPathHelper.GetPath(()=>溢料盒.UpLimit),"Application.PieceDate.ui溢料盒上限"},
                {PropertyPathHelper.GetPath(()=>溢料盒.TotalCount),"Application.PieceDate.ui溢料盒总数量"},
            };

            //PlcAddressPropertyPathPairs= PropertyPathPlcAddressPairs.
            //    Where(kv=>!string.IsNullOrEmpty(kv.Value)).
            //    ToDictionary(kv => kv.Value, kv => RemoveUpToSecondDot(kv.Key));

            PlcAddressPropertyPathsPairs = PropertyPathPlcAddressPairs
                .GroupBy(kvp => kvp.Value)
                .ToDictionary(
                    g => g.Key,
                    g => g.Select(kvp => CommonLib.RemoveUpToSecondDot(kvp.Key)).ToList()
                );
        }

    }
}
