/// <summary> /// 统计,使用固定的规范列表 /// </summary> /// <param name="eu"></param> /// <param name="pattern"></param> /// <param name="Perfect"></param> /// <param name="strCompany"></param> /// <param name="strType"></param> /// <param name="tempName"></param> /// <returns></returns> public bool Statistic(ExcelUtility eu, int pattern, bool Perfect, string strCompany, string strType, string tempName, string certstr) { int stateIndex = -1; int lineIndex = 0; int limitPosition = 24; int newline = -1; bool needInitialState = true; bool checkClear; bool firstTime = true; bool canPass = true, canPass1 = false; string insNumber = ""; Dictionary<int, string> exSheets = null; Dictionary<int, string> cert = new Dictionary<int, string>(); Dictionary<DoseCriterion, int> existDoseCriList = new Dictionary<DoseCriterion, int>() { { DoseCriterion.RQR2_40 , DoseCriterion.RQR2_40.Column }, { DoseCriterion.RQR3_50 , DoseCriterion.RQR3_50.Column }, { DoseCriterion.RQR4_60 , DoseCriterion.RQR4_60.Column }, { DoseCriterion.RQR5_70 , DoseCriterion.RQR5_70.Column }, { DoseCriterion.RQR6_80 , DoseCriterion.RQR6_80.Column }, { DoseCriterion.RQR7_90 , DoseCriterion.RQR7_90.Column }, { DoseCriterion.RQR8_100 , DoseCriterion.RQR8_100.Column }, { DoseCriterion.RQR9_120 , DoseCriterion.RQR9_120.Column }, { DoseCriterion.RQR_140 , DoseCriterion.RQR_140.Column }, { DoseCriterion.RQR10_150, DoseCriterion.RQR10_150.Column} }; Dictionary<KVCriterion, int> existKVCriList = new Dictionary<KVCriterion, int>() { { KVCriterion.RQR2_40 , KVCriterion.RQR2_40.Column }, { KVCriterion.RQR3_50 , KVCriterion.RQR3_50.Column }, { KVCriterion.RQR4_60 , KVCriterion.RQR4_60.Column }, { KVCriterion.RQR5_70 , KVCriterion.RQR5_70.Column }, { KVCriterion.RQR6_80 , KVCriterion.RQR6_80.Column }, { KVCriterion.RQR7_90 , KVCriterion.RQR7_90.Column }, { KVCriterion.RQR8_100 , KVCriterion.RQR8_100.Column }, { KVCriterion.RQR9_120 , KVCriterion.RQR9_120.Column }, { KVCriterion.RQR_140 , KVCriterion.RQR_140.Column }, { KVCriterion.RQR10_150, KVCriterion.RQR10_150.Column} }; //1.初始化:规范统计sheet结构,写入固定内容 stateIndex = eu.InitialStatisticSheet(eu.ExcelWorkbook, out exSheets, out needInitialState, out checkClear); if (!checkClear) { return false; } switch (pattern) { case 0: if (needInitialState) { eu.WriteStateTitle(eu.ExcelWorkbook, pattern, stateIndex, existDoseCriList, limitPosition); //写入送校单位 eu.WriteValue(eu.ExcelWorkbook, stateIndex, 2, 2, strCompany, out checkClear); //写入仪器名称 eu.WriteValue(eu.ExcelWorkbook, stateIndex, 3, 2, strType, out checkClear); } //1.搬运数据:先根据年份排序,然后复制数据 int[] indexDose = new int[exSheets.Count]; foreach (int item in exSheets.Keys) { indexDose[lineIndex] = item; lineIndex++; } DataUtility.DataUtility.QuickSort(indexDose, exSheets, 0, indexDose.Length - 1); lineIndex = 8; for (int i = 0; i < exSheets.Count; i++) { cert.Add(lineIndex, exSheets[indexDose[i]]); eu.CopyDoseOneYearData(eu.ExcelWorkbook, indexDose[i], stateIndex, lineIndex, exSheets[indexDose[i]], limitPosition, existDoseCriList, out insNumber); if (exSheets[indexDose[i]] == certstr) { newline = lineIndex; } if (firstTime && Perfect) { eu.DesiredName = tempName; firstTime = false; } lineIndex++; } //2.分析数据 if (exSheets.Count > 1) { eu.WriteValue(eu.ExcelWorkbook, stateIndex, lineIndex, 1, @"重复性", out checkClear); eu.ExcelWorkbook.Save(); eu.ExcelWorkbook.Saved = true; //计算平均值和年稳定性 canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 4, cert, "RQR2(40kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 6, cert, "RQR3(50kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 8, cert, "RQR4(60kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 10, cert, "RQR5(70kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 12, cert, "RQR6(80kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 14, cert, "RQR7(90kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 16, cert, "RQR8(100kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 18, cert, "RQR9(120kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 20, cert, "RQR(140kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 22, cert, "RQR10(150kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; } break; case 1: //TODO: CT统计代码 if (needInitialState) { eu.WriteStateTitle(eu.ExcelWorkbook, pattern, stateIndex, existDoseCriList, limitPosition); //写入送校单位 eu.WriteValue(eu.ExcelWorkbook, stateIndex, 2, 2, strCompany, out checkClear); //写入仪器名称 eu.WriteValue(eu.ExcelWorkbook, stateIndex, 3, 2, strType, out checkClear); } //1.搬运数据:先根据年份排序,然后复制数据 int[] indexCT = new int[exSheets.Count]; foreach (int item in exSheets.Keys) { indexCT[lineIndex] = item; lineIndex++; } DataUtility.DataUtility.QuickSort(indexCT, exSheets, 0, indexCT.Length - 1); lineIndex = 8; for (int i = 0; i < exSheets.Count; i++) { cert.Add(lineIndex, exSheets[indexCT[i]]); //TODO:复制数据格式 eu.CopyCTOneYearData(eu.ExcelWorkbook, indexCT[i], stateIndex, lineIndex, exSheets[indexCT[i]], limitPosition, existDoseCriList, out insNumber); if (exSheets[indexCT[i]] == certstr) { newline = lineIndex; } if (firstTime && Perfect) { eu.DesiredName = tempName; firstTime = false; } lineIndex++; } //2.分析数据 if (exSheets.Count > 1) { eu.WriteValue(eu.ExcelWorkbook, stateIndex, lineIndex, 1, @"重复性", out checkClear); eu.ExcelWorkbook.Save(); eu.ExcelWorkbook.Saved = true; //计算平均值和年稳定性 canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 4, cert, "RQR2(40kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 6, cert, "RQR3(50kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 8, cert, "RQR4(60kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 10, cert, "RQR5(70kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 12, cert, "RQR6(80kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 14, cert, "RQR7(90kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 16, cert, "RQR8(100kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 18, cert, "RQR9(120kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 20, cert, "RQR(140kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 22, cert, "RQR10(150kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; } break; case 2: //TODO:KV统计代码 limitPosition = 44; if (needInitialState) { eu.WriteStateTitle(eu.ExcelWorkbook, pattern, stateIndex, existKVCriList, limitPosition); //写入送校单位 eu.WriteValue(eu.ExcelWorkbook, stateIndex, 2, 2, strCompany, out checkClear); //写入仪器名称 eu.WriteValue(eu.ExcelWorkbook, stateIndex, 3, 2, strType, out checkClear); } //1.搬运数据:先根据年份排序,然后复制数据 int[] indexKV = new int[exSheets.Count]; foreach (int item in exSheets.Keys) { indexKV[lineIndex] = item; lineIndex++; } DataUtility.DataUtility.QuickSort(indexKV, exSheets, 0, indexKV.Length - 1); lineIndex = 8; for (int i = 0; i < exSheets.Count; i++) { cert.Add(lineIndex, exSheets[indexKV[i]]); //TODO:复制数据格式 if (exSheets[indexKV[i]] == certstr) { eu.CopyKVOneYearData(eu.ExcelWorkbook, indexKV[i], stateIndex, lineIndex, exSheets[indexKV[i]], limitPosition, existKVCriList, true, out insNumber); } else { eu.CopyKVOneYearData(eu.ExcelWorkbook, indexKV[i], stateIndex, lineIndex, exSheets[indexKV[i]], limitPosition, existKVCriList, false, out insNumber); } if (exSheets[indexKV[i]] == certstr) { newline = lineIndex; } if (firstTime && Perfect) { eu.DesiredName = tempName; firstTime = false; } lineIndex++; } //2.分析数据 eu.ExcelWorkbook.Save(); eu.ExcelWorkbook.Saved = true; //计算平均值和年稳定性 canPass1 = eu.StatisticsKVOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 4, cert, "RQR2(40kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsKVOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 8, cert, "RQR3(50kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsKVOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 12, cert, "RQR4(60kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsKVOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 16, cert, "RQR5(70kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsKVOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 20, cert, "RQR6(80kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsKVOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 24, cert, "RQR7(90kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsKVOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 28, cert, "RQR8(100kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsKVOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 32, cert, "RQR9(120kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsKVOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 36, cert, "RQR(140kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; canPass1 = eu.StatisticsKVOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 40, cert, "RQR10(150kV)", exSheets.Count > 1, true, newline); canPass = canPass1 && canPass; break; } eu.ExcelWorkbook.Save(); return canPass; }
/// <summary> /// 统计,采集真实的规范列表 /// </summary> /// <param name="eu"></param> /// <param name="pattern"></param> /// <returns></returns> public bool Statistic(ExcelUtility eu, int pattern) { int stateIndex = -1; int lineIndex = 0; int limitPosition = 14; bool needInitialState = true; bool checkClear; bool firstTime = true; bool canPass = true, canPass1 = false; string insNumber = ""; Dictionary<int, string> exSheets = null; Dictionary<int, string> cert = new Dictionary<int, string>(); Dictionary<DoseCriterion, int> existCriList = new Dictionary<DoseCriterion, int>(); //1.初始化:规范统计sheet结构,写入固定内容 stateIndex = eu.InitialStatisticSheet(eu.ExcelWorkbook, out exSheets, out needInitialState, out existCriList, out limitPosition, out checkClear); if (!checkClear) { return false; } if (!needInitialState) { eu.WriteStateTitle(eu.ExcelWorkbook, pattern, stateIndex, existCriList, limitPosition); switch (pattern) { case 0: //1.搬运数据:先根据年份排序,然后复制数据 int[] indexDose = new int[exSheets.Count]; lineIndex = 0; foreach (int item in exSheets.Keys) { indexDose[lineIndex] = item; lineIndex++; } DataUtility.DataUtility.QuickSort(indexDose, exSheets, 0, indexDose.Length - 1); lineIndex = 8; for (int i = 0; i < exSheets.Count; i++) { cert.Add(lineIndex, exSheets[indexDose[i]]); eu.CopyDoseOneYearData(eu.ExcelWorkbook, indexDose[i], stateIndex, lineIndex, exSheets[indexDose[i]], limitPosition, existCriList, out insNumber); if (firstTime) { firstTime = false; } lineIndex++; } //2.分析数据 if (exSheets.Count > 1) { eu.WriteValue(eu.ExcelWorkbook, stateIndex, lineIndex, 1, @"重复性", out checkClear); eu.ExcelWorkbook.Save(); eu.ExcelWorkbook.Saved = true; //计算平均值和年稳定性 canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 4, cert, "RQR2(40kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 6, cert, "RQR3(50kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 8, cert, "RQR4(60kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 10, cert, "RQR5(70kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 12, cert, "RQR6(80kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 14, cert, "RQR7(90kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 16, cert, "RQR8(100kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 18, cert, "RQR9(120kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 20, cert, "RQR(140kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 22, cert, "RQR10(150kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; } break; case 1: //TODO: CT统计代码 //1.搬运数据:先根据年份排序,然后复制数据 //indexCT[数字序号]=页序号 //exSheets[页序号]=证书编号 int[] indexCT = new int[exSheets.Count]; lineIndex = 0; foreach (int item in exSheets.Keys) { indexCT[lineIndex] = item; lineIndex++; } DataUtility.DataUtility.QuickSort(indexCT, exSheets, 0, indexCT.Length - 1); lineIndex = 8; for (int i = 0; i < exSheets.Count; i++) { cert.Add(lineIndex, exSheets[indexCT[i]]); //TODO:复制数据格式 eu.CopyCTOneYearData(eu.ExcelWorkbook, indexCT[i], stateIndex, i + 8, exSheets[indexCT[i]], limitPosition, existCriList, out insNumber); if (firstTime) { firstTime = false; } lineIndex++; } //2.分析数据 if (exSheets.Count > 1) { eu.WriteValue(eu.ExcelWorkbook, stateIndex, lineIndex, 1, @"重复性", out checkClear); eu.ExcelWorkbook.Save(); eu.ExcelWorkbook.Saved = true; //计算平均值和年稳定性 canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 4, cert, "RQR2(40kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 6, cert, "RQR3(50kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 8, cert, "RQR4(60kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 10, cert, "RQR5(70kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 12, cert, "RQR6(80kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 14, cert, "RQR7(90kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 16, cert, "RQR8(100kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 18, cert, "RQR9(120kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 20, cert, "RQR(140kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; canPass1 = eu.StatisticsCTDoseOneColumn(eu.ExcelWorkbook, stateIndex, lineIndex, 22, cert, "RQR10(150kV)", exSheets.Count > 1, true, -1); canPass = canPass1 && canPass; } break; case 2: //TODO:KV统计代码 break; } } eu.ExcelWorkbook.Save(); return canPass; }