using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraGrid; using Uninpho.DBOperation.Model; using Uninpho.DBOperation.Operation; using System.Windows.Forms; using DevExpress.XtraEditors; using MathWorks.MATLAB.NET.Arrays; using System.Globalization; using System.Threading; //数据库表重置; //TRUNCATE TABLE public.t_jihefenxi_boxing;//删除表内所有数据 //ALTER TABLE public.t_jihefenxi_boxing DROP COLUMN id;//删除id序号 //alter table public.t_jihefenxi_boxing add id serial PRIMARY KEY;//重置新加id序号 namespace Uninpho.Tools.components.DataAnalysis { /// /// 进行算法处理的类 /// public class DataAnalysisClass { GridControl GC; GridView GV; string type; int[] selectrow; bool iszhengc = true; /// /// 算法执行 /// /// 算法类型;“几何”、“轮轨力”、“微小” /// table中选择的数据的索引 /// GridControl /// GridView public DataAnalysisClass(string type, int[] selectrow, ref GridControl GC, ref GridView GV) { DataAnalysisToPG.InitBXID(); this.GC = GC; this.GV = GV; this.type = type; this.selectrow = selectrow; DataAnalysisFun(); } private void DataAnalysisFun() { //1.检查任务状态 checkedStatus(); //2.执行算法 if (iszhengc) { bool boo = true; if (type != "微小" && type != "功率" && type != "缺口") { SuanFaFrom frm = new SuanFaFrom(); frm.StartPosition = FormStartPosition.CenterParent; frm.changeLabel(type == "几何" ? true : false); if (frm.ShowDialog() != DialogResult.OK) { boo = false; } } if (boo) { AsyncFun(); } } } /// /// 检查任务状态 /// private void checkedStatus() { bool b = true; if (selectrow.Length <= 0) { XtraMessageBox.Show("请先选择要执行的文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); iszhengc = false; } else { if (type == "功率"|| type == "缺口") { for (int i = 0; i < selectrow.Length; i++) { var a = GV.GetRowCellValue(selectrow[i], "Taskstatus").ToString(); if (GV.GetRowCellValue(selectrow[i], "Filestatus").ToString().Trim() != "正常") { XtraMessageBox.Show("存在文件状态异常文件,请检查后再执行算法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); iszhengc = false; break; } else if (GV.GetRowCellValue(selectrow[i], "Taskstatus").ToString() == type + "算法执行完毕" || GV.GetRowCellValue(selectrow[i], "Taskstatus").ToString() == "算法执行失败") { if (b) { if (XtraMessageBox.Show(type + "算法已执行,是否重新执行?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { iszhengc = false; break; } else { b = false; } } if(type == "功率") { DataAnalysisToPG.DelUpdataDataDWGL(GV.GetRowCellValue(selectrow[i], "Id").ToString(), type); } else { DataAnalysisToPG.DelUpdataDataDWQK(GV.GetRowCellValue(selectrow[i], "Id").ToString(), type); } } } } else { for (int i = 0; i < selectrow.Length; i++) { var a = GV.GetRowCellValue(selectrow[i], "Rwzt").ToString(); if (GV.GetRowCellValue(selectrow[i], "Wjzt").ToString().Trim() != "正常") { XtraMessageBox.Show("存在文件状态异常文件,请检查后再执行算法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); iszhengc = false; break; } else if (GV.GetRowCellValue(selectrow[i], "Jccxx").ToString() == " " || GV.GetRowCellValue(selectrow[i], "Jccxx").ToString() == "") { XtraMessageBox.Show("没有选定检测车信息,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); iszhengc = false; break; } else if (GV.GetRowCellValue(selectrow[i], "Rwzt").ToString() == type + "算法执行完毕" || GV.GetRowCellValue(selectrow[i], "Rwzt").ToString() == "算法执行失败") { if (type != "微小") { if (b) { if (XtraMessageBox.Show(type + "算法已执行,是否重新执行?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { iszhengc = false; break; } else { b = false; } } DataAnalysisToPG.DelUpdataData(GV.GetRowCellValue(selectrow[i], "Id").ToString(), type); } else { XtraMessageBox.Show("微小算法不能重新执行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); iszhengc = false; break; } } else if (GV.GetRowCellValue(selectrow[i], "Rwzt").ToString() == "算法未执行" && type == "微小") { XtraMessageBox.Show("请先执行几何算法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); iszhengc = false; break; } } } } } private async Task AsyncFun() { bool boo = true; if (type == "几何" || type == "轮轨力") { for (int i = 0; i < selectrow.Length; i++) { boo = true; GV.SetRowCellValue(selectrow[i], "Rwzt", "正在执行" + type + "算法..."); T_file_account whichfile = (T_file_account)DataAnalysisToPG.QueryToPGById(Convert.ToInt32(GV.GetRowCellValue(selectrow[i], "Id").ToString().Trim())); try { await Task.Run(() => { if (type == "几何") { JHMain(whichfile); } else if (type == "轮轨力") { LGLMain(whichfile); } }); } catch (Exception ex) { boo = false; throw; } if (boo) { GV.SetRowCellValue(selectrow[i], "Rwzt", type + "算法执行完毕"); } else { GV.SetRowCellValue(selectrow[i], "Rwzt", "算法执行失败"); } } } else if (type == "微小") { boo = true; List whichfile = new List(); for (int i = 0; i < selectrow.Length; i++) { whichfile.Add((T_file_account)DataAnalysisToPG.QueryToPGById(Convert.ToInt32(GV.GetRowCellValue(selectrow[i], "Id").ToString().Trim()))); GV.SetRowCellValue(selectrow[i], "Rwzt", "正在执行" + type + "算法..."); } try { await Task.Run(() => { WXSFMain(whichfile); }); } catch (Exception ex) { boo = false; throw; } for (int i = 0; i < selectrow.Length; i++) { if (boo) { GV.SetRowCellValue(selectrow[i], "Rwzt", type + "算法执行完毕"); } else { GV.SetRowCellValue(selectrow[i], "Rwzt", type + "算法执行失败"); } } } else if (type == "功率") { for (int i = 0; i < selectrow.Length; i++) { boo = true; GV.SetRowCellValue(selectrow[i], "Taskstatus", "正在执行" + type + "算法..."); T_dwfile_account whichfile = (T_dwfile_account)DataAnalysisToPG.QueryToPGByIdGL(Convert.ToInt32(GV.GetRowCellValue(selectrow[i], "Id").ToString().Trim())); try { await Task.Run(() => { GL_new(whichfile); }); } catch (Exception ex) { boo = false; throw; } if (boo) { GV.SetRowCellValue(selectrow[i], "Taskstatus", type + "算法执行完毕"); } else { GV.SetRowCellValue(selectrow[i], "Taskstatus", "算法执行失败"); } } } else if (type == "缺口") { for (int i = 0; i < selectrow.Length; i++) { boo = true; GV.SetRowCellValue(selectrow[i], "Taskstatus", "正在执行" + type + "算法..."); T_dwqkfile_account whichfile = (T_dwqkfile_account)DataAnalysisToPG.QueryToPGByIdQK(Convert.ToInt32(GV.GetRowCellValue(selectrow[i], "Id").ToString().Trim())); try { await Task.Run(() => { QK_new(whichfile); }); } catch (Exception ex) { boo = false; throw; } if (boo) { GV.SetRowCellValue(selectrow[i], "Taskstatus", type + "算法执行完毕"); } else { GV.SetRowCellValue(selectrow[i], "Taskstatus", "算法执行失败"); } } } //提示 if (boo) { XtraMessageBox.Show(type + "算法执行完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("算法执行失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void JHMain(T_file_account whichfile) { JH_new(whichfile); } private void LGLMain(T_file_account whichfile) { LGL_new(whichfile); } private void WXSFMain(List whichfile) { WXSFFun(whichfile); } #region 几何算法 public void JH_new(T_file_account whichfile) { List daochabiao = (List)DataAnalysisToPG.QueryDCTZ(whichfile.Xlm, whichfile.Yswjm.Split('-')[0].ToCharArray()); List quxianbiao = (List)DataAnalysisToPG.QueryQXTZ(whichfile.Xlm, whichfile.Yswjm.Split('-')[0].ToCharArray()); string fname_dir0 = Path.GetDirectoryName(whichfile.Srlj) + "\\"; string fname0 = Path.GetFileName(whichfile.Srlj); T_xianlulicheng_sf sf = (T_xianlulicheng_sf)DataAnalysisToPG.QueryToString(fname0.Split('-')[0]); double mile_min = sf.Qslc == null ? Convert.ToDouble(0) : Convert.ToDouble(sf.Qslc); double mile_max = sf.Zzlc == null ? Convert.ToDouble(180) : Convert.ToDouble(sf.Zzlc); int mile_id = DACommon.xzlcBool ? 0 : 1; string line_name = fname0.Split('-')[0]; double[] tz_curv = getTZQX(quxianbiao, true); double[] tz_turnout = getTZDC(daochabiao); double[] distance_table = getTZJGJX(); string carname = whichfile.Jccxx; try { var data = AnalysisAlgorithmcs.JHFX(fname_dir0, fname0, mile_id, line_name, mile_min, mile_max, tz_curv, tz_turnout, distance_table, carname); readJHFX(data, whichfile); } catch (Exception ex) { XtraMessageBox.Show("文件:" + whichfile.Yswjm + "执行失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); throw; } } /// /// 读几何分析数据 /// /// /// private void readJHFX(MWArray[] agrsOut, T_file_account whichfile) { MWCellArray output1 = agrsOut[0] as MWCellArray;//第1个输出参数 MWNumericArray output2 = agrsOut[1] as MWNumericArray;//第2个输出参数 MWArray output3 = agrsOut[2] as MWArray;//第3个输出参数 MWCellArray output4 = agrsOut[3] as MWCellArray;//第4个输出参数 MWCellArray output5 = agrsOut[4] as MWCellArray;//第5个输出参数 MWNumericArray output6 = agrsOut[5] as MWNumericArray;//第6个输出参数 MWCellArray output7 = agrsOut[6] as MWCellArray;//第7个输出参数 MWCellArray output10 = agrsOut[7] as MWCellArray;//第7个输出参数 MWCellArray output11 = agrsOut[8] as MWCellArray;//第7个输出参数 MWNumericArray output8 = agrsOut[9] as MWNumericArray;//第8个输出参数 MWNumericArray output9 = agrsOut[10] as MWNumericArray;//第9个输出参数 MWNumericArray output12 = agrsOut[11] as MWNumericArray;//第12个输出参数 var table_header = output1.ToArray(); var table_data = (double[,])output2.ToArray(); var table_zc = (object[,])output3.ToArray(); var table_date = (object[,])output4.ToArray(); var table_zf = (object[,])output5.ToArray(); var table_tqi = (double[,])output6.ToArray(); var table_car = (object[,])output7.ToArray(); var table_name = (object[,])output10.ToArray(); var table_xb = (object[,])output11.ToArray(); var wave_id = (double[,])output8.ToArray(); var wave_sw = (double[,])output9.ToArray(); var wave_loc = (double[,])output12.ToArray(); List JHobjs = new List(); DataAnalysisToPG.InsertGetIdMAX(new T_jihefenxi_boxing() { Yswjm = "?????" }); int idindex = DataAnalysisToPG.QueryMaxID("jh") + 1; #region 录入T_jihefenxi_account for (int i = 0; i < table_data.GetLength(0); i++) { int bxidq = (int)wave_id[i, 0]; int bxidz = (int)wave_id[i, 1]; int bxindex = bxidz - bxidq; T_jihefenxi_account jhojb = new T_jihefenxi_account(); jhojb.Xuhao = table_data[i, 0].ToString(); jhojb.Jgjlc = Convert.ToDecimal(table_data[i, 1]); jhojb.Sudu_jhfx = Convert.ToDecimal(table_data[i, 2]); jhojb.Cthjfz = Convert.ToDecimal(table_data[i, 3]); jhojb.Cthjffz = Convert.ToDecimal(table_data[i, 4]); jhojb.Ctcjfz = Convert.ToDecimal(table_data[i, 5]); jhojb.Ctcjffz = Convert.ToDecimal(table_data[i, 6]); jhojb.Zgjfz = Convert.ToDecimal(table_data[i, 7]); jhojb.Zgjffz_jhfx = Convert.ToDecimal(table_data[i, 8]); jhojb.Ygjfz = Convert.ToDecimal(table_data[i, 9]); jhojb.Ygjffz = Convert.ToDecimal(table_data[i, 10]); jhojb.Zgdfz = Convert.ToDecimal(table_data[i, 11]); jhojb.Ygdfz = Convert.ToDecimal(table_data[i, 12]); jhojb.Zgxfz = Convert.ToDecimal(table_data[i, 13]); jhojb.Ygxfz = Convert.ToDecimal(table_data[i, 14]); jhojb.Spfz = Convert.ToDecimal(table_data[i, 15]); jhojb.Sjkfz = Convert.ToDecimal(table_data[i, 16]); jhojb.Cbzgdfz = Convert.ToDecimal(table_data[i, 17]); jhojb.Cbygdfz = Convert.ToDecimal(table_data[i, 18]); jhojb.Cbzgxfz = Convert.ToDecimal(table_data[i, 19]); jhojb.Cbygxfz = Convert.ToDecimal(table_data[i, 20]); jhojb.Zcx = Char2String((char[,])table_zc[i, 0]); jhojb.Riqi = Char2String((char[,])table_date[i, 0]); jhojb.Zfx = Char2String((char[,])table_zf[i, 0]); jhojb.Dcqtqi = Convert.ToDecimal(table_tqi[i, 0]); jhojb.Jcc = Char2String((char[,])table_car[i, 0]); jhojb.Filename_jh = whichfile.Id.ToString(); jhojb.Boxingid_jhfx = wave_id[i, 0].ToString() + "," + wave_id[i, 1].ToString(); jhojb.Jgjcydxh = Convert.ToDecimal(wave_loc[i, 0]); jhojb.Xgjcydxh = Convert.ToDecimal(wave_loc[i, 1]); jhojb.Xlm = whichfile.Xlm; //jhojb.Xlm = Char2String((char[,])table_name[i, 0]); jhojb.Yswjm_jhfx = idindex.ToString() + "," + (idindex + bxindex).ToString(); jhojb.Xingbie = whichfile.Hangbie; //jhojb.Xingbie = Char2String((char[,])table_xb[i, 0]); jhojb.Gjhy = Math.Abs(jhojb.Zgjfz) > Math.Abs(jhojb.Ygjfz) ? jhojb.Zgjfz : jhojb.Ygjfz; jhojb.Gjhyffz = Math.Abs(jhojb.Zgjffz_jhfx) > Math.Abs(jhojb.Ygjffz) ? jhojb.Zgjffz_jhfx : jhojb.Ygjffz; jhojb.Gdfz = Math.Abs(jhojb.Zgdfz) > Math.Abs(jhojb.Ygdfz) ? jhojb.Zgdfz : jhojb.Ygdfz; jhojb.Gxfz = Math.Abs(jhojb.Zgxfz) > Math.Abs(jhojb.Ygxfz) ? jhojb.Zgxfz : jhojb.Ygxfz; jhojb.Cbgdfz = Math.Abs(jhojb.Cbzgdfz) > Math.Abs(jhojb.Cbygdfz) ? jhojb.Cbzgdfz : jhojb.Cbygdfz; jhojb.Cbgxfz = Math.Abs(jhojb.Cbzgxfz) > Math.Abs(jhojb.Cbygxfz) ? jhojb.Cbzgxfz : jhojb.Cbygxfz; JHobjs.Add(jhojb); idindex += bxindex + 1; } DataAnalysisToPG.InsertJHDataToPG(JHobjs); #endregion #region 录入波形 List Bolist = new List(); for (int i = 0; i < wave_sw.GetLength(0); i++) { T_jihefenxi_boxing bolist = new T_jihefenxi_boxing(); bolist.Licheng = Convert.ToDecimal(wave_sw[i, 0]); bolist.Sudu_jhbx = Convert.ToDecimal(wave_sw[i, 1]); bolist.Cthj = Convert.ToDecimal(wave_sw[i, 2]); bolist.Ctcj = Convert.ToDecimal(wave_sw[i, 3]); bolist.Gjzhy = Convert.ToDecimal(wave_sw[i, 4]); bolist.Gjyhy = Convert.ToDecimal(wave_sw[i, 5]); bolist.Zgd = Convert.ToDecimal(wave_sw[i, 6]); bolist.Ygd = Convert.ToDecimal(wave_sw[i, 7]); bolist.Zgx = Convert.ToDecimal(wave_sw[i, 8]); bolist.Ygx = Convert.ToDecimal(wave_sw[i, 9]); bolist.Gj = Convert.ToDecimal(wave_sw[i, 10]); bolist.Sp = Convert.ToDecimal(wave_sw[i, 11]); bolist.Sjk = Convert.ToDecimal(wave_sw[i, 12]); bolist.Cbzgd = Convert.ToDecimal(wave_sw[i, 13]); bolist.Cbygd = Convert.ToDecimal(wave_sw[i, 14]); bolist.Cbzgx = Convert.ToDecimal(wave_sw[i, 15]); bolist.Cbygx = Convert.ToDecimal(wave_sw[i, 16]); bolist.Dcdw = Convert.ToDecimal(wave_sw[i, 17]); bolist.Bxid = i + 1; Bolist.Add(bolist); } DataAnalysisToPG.InsertJHBXDataToPG(Bolist); DataAnalysisToPG.updataRWZT(new string[] { whichfile.Id.ToString(), type + "算法执行完毕" }); #endregion } #endregion #region 轮轨力算法 public void LGL_new(T_file_account whichfile) { List daochabiao = (List)DataAnalysisToPG.QueryDCTZ(whichfile.Xlm, whichfile.Yswjm.Split('_')[2].Split('.')[0].ToCharArray()); List quxianbiao = (List)DataAnalysisToPG.QueryQXTZ(whichfile.Xlm, whichfile.Yswjm.Split('_')[2].Split('.')[0].ToCharArray()); string fname_dir0 = Path.GetDirectoryName(whichfile.Srlj) + "\\"; string fname0 = Path.GetFileName(whichfile.Srlj); string line_name = fname0.Split('_')[2].Split('.')[0]; T_xianlulicheng_sf sf = (T_xianlulicheng_sf)DataAnalysisToPG.QueryToString(line_name); double mile_min = Convert.ToDouble(sf.Qslc); double mile_max = Convert.ToDouble(sf.Zzlc); double[] tz_curv = getTZQX(quxianbiao, false); double[] tz_turnout = getTZDC(daochabiao); double[] distance_table = getTZJGJX(); string carname = whichfile.Jccxx; try { var data = AnalysisAlgorithmcs.LGLFX(fname_dir0, fname0, line_name, mile_min, mile_max, tz_curv, tz_turnout, distance_table, carname); readLGLFX(data, whichfile); } catch (Exception ex) { if (quxianbiao.Count == 0) { XtraMessageBox.Show("曲线表缺少数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (daochabiao.Count == 0) { XtraMessageBox.Show("道岔表缺少数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("文件:" + whichfile.Yswjm + "执行失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } throw; } } /// /// 读轮轨力分析数据 /// /// /// private void readLGLFX(MWArray[] agrsOut, T_file_account whichfile) { MWCellArray output1 = agrsOut[0] as MWCellArray;//第1个输出参数 MWNumericArray output2 = agrsOut[1] as MWNumericArray;//第2个输出参数 MWNumericArray output3 = agrsOut[6] as MWNumericArray;//第3个输出参数 MWNumericArray output4 = agrsOut[7] as MWNumericArray;//第4个输出参数 MWCellArray output5 = agrsOut[2] as MWCellArray;//第3个输出参数 MWCellArray output6 = agrsOut[4] as MWCellArray;//第4个输出参数 MWCellArray output7 = agrsOut[5] as MWCellArray;//第4个输出参数 MWCellArray output8 = agrsOut[3] as MWCellArray;//第4个输出参数 var table_header = (object[,])output1.ToArray(); var table_data = (double[,])output2.ToArray(); var table_name = (object[,])output5.ToArray(); var table_xb = (object[,])output6.ToArray(); var table_date = (object[,])output7.ToArray(); var wave_sw = (double[,])output4.ToArray(); var boxingid = (double[,])output3.ToArray(); var table_car = (object[,])output8.ToArray(); List JHobjs = new List(); DataAnalysisToPG.InsertGetIdMAX(new T_lunguili_boxing() { Yswjm = "?????" }); int idindex = DataAnalysisToPG.QueryMaxID("lgl") + 1; for (int i = 0; i < table_data.GetLength(0); i++) { int bxidq = (int)boxingid[i, 0]; int bxidz = (int)boxingid[i, 1]; int bxindex = bxidz - bxidq; T_lunguili_account jhojb = new T_lunguili_account(); jhojb.Xuhao = table_data[i, 0].ToString(); jhojb.Jgjlc = Convert.ToDecimal(table_data[i, 1]); jhojb.Sudu_lgl = Convert.ToDecimal(table_data[i, 2]); jhojb.Zzcfz = Convert.ToDecimal(table_data[i, 3]); jhojb.Zzhfz = Convert.ToDecimal(table_data[i, 4]); jhojb.Yzcfz = Convert.ToDecimal(table_data[i, 5]); jhojb.Yzhfz = Convert.ToDecimal(table_data[i, 6]); jhojb.Lzlfz = Convert.ToDecimal(table_data[i, 7]); jhojb.Lzjzl = Convert.ToDecimal(table_data[i, 8]); jhojb.Ztgxs = Convert.ToDecimal(table_data[i, 9]); jhojb.Ytgxs = Convert.ToDecimal(table_data[i, 10]); jhojb.Filename_lgl = whichfile.Id.ToString(); jhojb.Boxingid_lgl = bxidq.ToString() + "," + bxidz.ToString(); //jhojb.Xlm = Char2String((char[,])table_name[i, 0]); jhojb.Xlm = whichfile.Xlm; //jhojb.Xingbie = Char2String((char[,])table_xb[i, 0]); jhojb.Xingbie = whichfile.Hangbie; jhojb.Yswjm = idindex.ToString() + "," + (idindex + bxindex).ToString(); jhojb.Jcrq = Char2String((char[,])table_date[i, 0]); jhojb.Lgcxl = Math.Abs(jhojb.Zzcfz) > Math.Abs(jhojb.Yzcfz) ? jhojb.Zzcfz : jhojb.Yzcfz; jhojb.Lghxl = Math.Abs(jhojb.Zzhfz) > Math.Abs(jhojb.Yzhfz) ? jhojb.Zzhfz : jhojb.Yzhfz; jhojb.Tgxs = jhojb.Ztgxs > jhojb.Ytgxs ? jhojb.Ztgxs : jhojb.Ytgxs; JHobjs.Add(jhojb); idindex += bxindex + 1; } DataAnalysisToPG.InsertLGLDataToPG(JHobjs); #region 录入波形 List Bolist = new List(); for (int i = 0; i < wave_sw.GetLength(0); i++) { T_lunguili_boxing bolist = new T_lunguili_boxing(); bolist.Licheng = Convert.ToDecimal(wave_sw[i, 0]); bolist.Sudu_lglbx = Convert.ToDecimal(wave_sw[i, 1]); bolist.Zzc = Convert.ToDecimal(wave_sw[i, 2]); bolist.Zzh = Convert.ToDecimal(wave_sw[i, 3]); bolist.Yzc = Convert.ToDecimal(wave_sw[i, 4]); bolist.Yzh = Convert.ToDecimal(wave_sw[i, 5]); bolist.Bxid = i + 1; Bolist.Add(bolist); } DataAnalysisToPG.InsertLGLBXDataToPG(Bolist); DataAnalysisToPG.updataRWZT(new string[] { whichfile.Id.ToString(), type + "算法执行完毕" }); #endregion } #endregion #region 微小算法 /// /// 微小算法 /// /// public void WXSFFun(List whichfile) { //1.采集数据 List jhfe_account = new List(); for (int i = 0; i < whichfile.Count; i++) { var aa = DataAnalysisToPG.QueryToPGByNameWXSF(whichfile[i].Id.ToString()) as List; jhfe_account = jhfe_account.Union(aa).ToList(); } //2.添加参考数据 addWXSFReference(ref jhfe_account); //3.构造参数及执行微小算法 string[] date = new string[jhfe_account.Count]; string[] car = new string[jhfe_account.Count]; double[] mile = new double[jhfe_account.Count]; List wave_data = new List(); List id_wave_all = new List(); List jx_loc_all = new List(); string[] line = new string[jhfe_account.Count]; double[] velo = new double[jhfe_account.Count]; string[] zc = new string[jhfe_account.Count]; getdataWXSF(jhfe_account, ref date, ref car, ref mile, ref wave_data, ref id_wave_all, ref jx_loc_all, ref line, ref velo, ref zc); try {//存在问题,wave_data if (date.Distinct().ToArray().Length > 1) { var data = AnalysisAlgorithmcs.WXSF(date, car, mile, wave_data.ToArray(), id_wave_all.ToArray(), jx_loc_all.ToArray(), line, velo, zc); readWXSF(data, jhfe_account); for (int i = 0; i < whichfile.Count; i++) { DataAnalysisToPG.updataRWZT(new string[] { whichfile[i].Id.ToString(), type + "算法执行完毕" }); } } else { XtraMessageBox.Show("日期相同,不能执行微小算法", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { throw; } } //读取微小算法分析数据 private void readWXSF(MWArray[] agrsOut, List jhfe_account) { List GeoJHReturn = new List(); MWCellArray output1 = agrsOut[0] as MWCellArray;//第1个输出参数 MWCellArray output2 = agrsOut[1] as MWCellArray;//第2个输出参数 MWCellArray output3 = agrsOut[2] as MWCellArray;//第3个输出参数 MWNumericArray output4 = agrsOut[3] as MWNumericArray;//第4个输出参数 MWNumericArray output5 = agrsOut[4] as MWNumericArray;//第5个输出参数 MWCellArray output6 = agrsOut[5] as MWCellArray;//第6个输出参数 MWCellArray output7 = agrsOut[6] as MWCellArray;//第7个输出参数 MWNumericArray output8 = agrsOut[7] as MWNumericArray;//第8个输出参数 MWNumericArray output9 = agrsOut[8] as MWNumericArray;//第9个输出参数 MWNumericArray output10 = agrsOut[9] as MWNumericArray;//第10个输出参数 MWCellArray output11 = agrsOut[10] as MWCellArray;//第11个输出参数 var table_header = (object[,])output1.ToArray(); var tableline = (object[,])output2.ToArray(); var table_xb = (object[,])output3.ToArray(); var table_milej = (double[,])output4.ToArray(); var table_milex = (double[,])output5.ToArray(); var table_date = (object[,])output6.ToArray(); var table_car = (object[,])output7.ToArray(); var table_data = (double[,])output8.ToArray(); var wave_id = (double[,])output9.ToArray(); var wave_sw = (double[,])output10.ToArray(); var table_check = (object[,])output11.ToArray(); List JHWXobjs = new List(); #region 录入T_jihefenxi_account for (int i = 0; i < table_data.GetLength(0); i++) { T_jihefenxi_account jhwxojb = new T_jihefenxi_account(); jhwxojb.Xlm = (DataAnalysisToPG.QueryToXlm(Char2String((char[,])tableline[i, 0])) as T_luxianming_sf).Xlm; if (Char2String((char[,])table_xb[i, 0]) == "X") { jhwxojb.Xingbie = "下"; } else if (Char2String((char[,])table_xb[i, 0]) == "S") { jhwxojb.Xingbie = "上"; } else { //待定 jhwxojb.Xingbie = "上"; } jhwxojb.Jgjlc = Convert.ToDecimal(table_milej[i, 0]); jhwxojb.Jcc = Char2String((char[,])table_car[i, 0]) == "轨检车" ? "轨检车" : GetJccFun(Char2String((char[,])table_car[i, 0])); jhwxojb.Riqi = DateTime.Parse(Char2String((char[,])table_date[i, 0])).ToString("yyyy年MM月dd日"); jhwxojb.Boxingid_jhfx = wave_id[i, 0].ToString() + "," + wave_id[i, 1].ToString(); //心轨尖里程 jhwxojb.Wx_xgjlc = Convert.ToDecimal(table_milex[i, 0]); //轨道几何变化量 jhwxojb.Wx_bhl_gd = Convert.ToDecimal(table_data[i, 0]); jhwxojb.Wx_bhl_gx = Convert.ToDecimal(table_data[i, 1]); jhwxojb.Wx_bhl_sp = Convert.ToDecimal(table_data[i, 2]); jhwxojb.Wx_bhl_sjk = Convert.ToDecimal(table_data[i, 3]); jhwxojb.Wx_bhl_gj = Convert.ToDecimal(table_data[i, 4]); jhwxojb.Wx_check = Char2String((char[,])table_check[i, 0]); JHWXobjs.Add(jhwxojb); } DataAnalysisToPG.UpdataJHDataToPG(JHWXobjs); #endregion #region 更新波形 //记录成功运算的数据 foreach (var it in jhfe_account) { foreach (var item in JHWXobjs) { if (it.Xlm == item.Xlm && it.Xingbie == item.Xingbie && it.Jgjlc == item.Jgjlc && it.Jcc == item.Jcc && it.Riqi == item.Riqi) { it.Boxingid_jhfx = item.Boxingid_jhfx; GeoJHReturn.Add(it); break; } } } //使用线路名、行别、尖轨尖里程匹配得到的波形数据,去更新范围、id for (int k = 0; k < GeoJHReturn.Count; k++) { string[] bxxuhaostring = GeoJHReturn[k].Boxingid_jhfx.Split(','); int[] bxxuhaos = new int[] { Convert.ToInt32(bxxuhaostring[0]), Convert.ToInt32(bxxuhaostring[1]) }; string[] bxidsstring = GeoJHReturn[k].Yswjm_jhfx.Split(','); int[] bxids = new int[] { Convert.ToInt32(bxidsstring[0]), Convert.ToInt32(bxidsstring[1]) }; int id = bxids[0]; List Bolist = new List(); for (int i = bxxuhaos[0] - 1; i < bxxuhaos[1]; i++) { T_jihefenxi_boxing bolist = new T_jihefenxi_boxing(); bolist.Licheng = Convert.ToDecimal(wave_sw[i, 0]); bolist.Sudu_jhbx = Convert.ToDecimal(wave_sw[i, 1]); bolist.Cthj = Convert.ToDecimal(wave_sw[i, 2]); bolist.Ctcj = Convert.ToDecimal(wave_sw[i, 3]); bolist.Gjzhy = Convert.ToDecimal(wave_sw[i, 4]); bolist.Gjyhy = Convert.ToDecimal(wave_sw[i, 5]); bolist.Zgd = Convert.ToDecimal(wave_sw[i, 6]); bolist.Ygd = Convert.ToDecimal(wave_sw[i, 7]); bolist.Zgx = Convert.ToDecimal(wave_sw[i, 8]); bolist.Ygx = Convert.ToDecimal(wave_sw[i, 9]); bolist.Gj = Convert.ToDecimal(wave_sw[i, 10]); bolist.Sp = Convert.ToDecimal(wave_sw[i, 11]); bolist.Sjk = Convert.ToDecimal(wave_sw[i, 12]); bolist.Cbzgd = Convert.ToDecimal(wave_sw[i, 13]); bolist.Cbygd = Convert.ToDecimal(wave_sw[i, 14]); bolist.Cbzgx = Convert.ToDecimal(wave_sw[i, 15]); bolist.Cbygx = Convert.ToDecimal(wave_sw[i, 16]); bolist.Dcdw = Convert.ToDecimal(wave_sw[i, 17]); bolist.Id = bxids[0]; bolist.Bxid = i + 1; bolist.Id = id; bolist.Yswjm = "微小算法执行了"; id++; Bolist.Add(bolist); } DataAnalysisToPG.UpdataJHBXDataToPG(Bolist); } #endregion } /// /// 添加每条道岔之前最新一次微小算法执行结果(添加参考数据) /// public static void addWXSFReference(ref List jhfe_account) { try { //按照线路名、行别、尖轨尖里程匹配最新一次执行的数据 // 1.去重,获取未执行微小算法的数据的线路名、行别、尖轨尖里程 List quchong = WXSFquchong(jhfe_account); // 2.查数据(条件:线路名、行别、尖轨尖里程、未执行微小算法wx_isload = 1) List> datalist = DataAnalysisToPG.QueryToPGByNameWXSFZDReference(quchong); // 3.date比大小,保留每条线路名、行别、尖轨尖里程匹配的最新参考数据 List cankao = dateCompare(datalist); for (int i = 0; i < cankao.Count; i++) { jhfe_account.Add(cankao[i]); } } catch (Exception ex) { throw; } } /// /// 去重,获取未执行微小算法的数据的线路名、行别、尖轨尖里程 /// /// /// public static List WXSFquchong(List datalist) { List cankaolist = new List(); foreach (var item in datalist) { cankaolist.Add(new T_jihefenxi_account() { Xlm = item.Xlm, Xingbie = item.Xingbie, Jgjlc = item.Jgjlc, Riqi = item.Riqi, Jcc = item.Jcc }); } cankaolist = cankaolist.Distinct().ToList(); return cankaolist; } /// /// date比大小,可以理解为去重 /// public static List dateCompare(List> datalist) { List cankaolist = new List(); foreach (var item in datalist) { T_jihefenxi_account cancan = new T_jihefenxi_account(); cancan.Riqi = "1800年1月1日"; foreach (var it in item) { var date1 = DateTime.Parse(cancan.Riqi); var date2 = DateTime.Parse(it.Riqi); if (DateTime.Compare(date1, date2) < 0) { cancan = it; } } cankaolist.Add(cancan); } return cankaolist; //大概看一下 } /// /// 查询检测车 /// /// public string GetJccFun(string str) { foreach (var item in DACommon.jccList) { if (item.Split('-')[1] == str) { return item; } } return "轨检车"; } #endregion /// 功率算法 public void GL_new(T_dwfile_account whichfile) { string fname_dir0 = Path.GetDirectoryName(whichfile.Srlj) + "\\"; string fname0 = Path.GetFileName(whichfile.Srlj); //Console.Write(fname_dir0); //Console.Write(fname0); string xianlu = whichfile.Xianlu; string chezhan = whichfile.Chezhan; string filename = whichfile.Filename; try { var data = AnalysisAlgorithmcs.GLFX(fname_dir0, fname0, xianlu, chezhan, filename); readGLFX(data, whichfile); } catch (Exception ex) { XtraMessageBox.Show("文件:" + whichfile.Filename + "执行失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); throw; } } /// 读功率分析数据 private void readGLFX(MWArray[] agrsOut, T_dwfile_account whichfile) { try { MWCellArray output1 = agrsOut[0] as MWCellArray;//数据 MWCellArray output2 = agrsOut[1] as MWCellArray;//时间 var table_data = output1.ToArray(); var table_date = (object[,])output2.ToArray(); List GLobjs = new List(); // 假设是二维数组,从第2行开始 for (int i = 1; i < (table_data as Array).GetLength(0); i++) { T_glanalysis_account gldata = new T_glanalysis_account(); gldata.Filename = whichfile.Filename; gldata.Xianlu = whichfile.Xianlu; gldata.Chezhan = whichfile.Chezhan; // 安全地获取每列数据 gldata.Curvenumber = SafeExtractInt(table_data, i, 2); gldata.Directionalmarker = SafeExtractInt(table_data, i, 3); gldata.Curvetype = SafeExtractInt(table_data, i, 4); gldata.Totalwork = SafeExtractDecimal(table_data, i, 5); gldata.Changerate = SafeExtractDecimal(table_data, i, 6); gldata.Offsetvalue = SafeExtractDecimal(table_data, i, 7); gldata.Powervariance = SafeExtractDecimal(table_data, i, 8); // 解析时间 try { // 检查时间是否为空 if (table_date[i, 0] is char[,]) { string timeString = Char2String((char[,])table_date[i, 0]); if (!string.IsNullOrEmpty(timeString)) { DateTime parsedTime = DateTime.Parse(timeString); // 解析为 DateTime gldata.Time = parsedTime.ToString("yyyy-MM-dd HH:mm:ss"); // 格式化为字符串 } else { gldata.Time = null; // 或者设置为默认值 } } else { gldata.Time = null; // 或者设置为默认值 } } catch (FormatException ex) { Console.WriteLine($"时间解析失败: {ex.Message}"); gldata.Time = null; // 或者设置为默认值 } // 检查关键字段是否为空或默认值 if (gldata.Curvenumber != 0 && gldata.Directionalmarker != 0 && gldata.Curvetype != 0 && gldata.Totalwork != 0 && gldata.Changerate != 0 && gldata.Offsetvalue != 0 && gldata.Powervariance != 0 && gldata.Time != null) { GLobjs.Add(gldata); } // GLobjs.Add(gldata); } //Console.WriteLine("解析完成,共 " + GLobjs.Count + " 条记录"); DataAnalysisToPG.updataTaskstatus(new string[] { whichfile.Id.ToString(), type + "算法执行完毕" }); DataAnalysisToPG.InsertGLFXDataToPG(GLobjs); CalculateAndInsertAnalysisProData(whichfile.Filename); } catch (Exception ex) { //Console.WriteLine("解析出错: " + ex.Message); // Console.WriteLine("堆栈跟踪: " + ex.StackTrace); } } private int SafeExtractInt(object table_data, int row, int col) { try { // 尝试直接获取数组元素 var cellArray = (table_data as Array).GetValue(row, col); // 处理 MWNumericArray if (cellArray is MWNumericArray) { var numArray = cellArray as MWNumericArray; return (int)Math.Round(numArray.ToScalarDouble()); } // 处理 double 数组 if (cellArray is double[,]) { var doubleArray = cellArray as double[,]; return (int)Math.Round(doubleArray[0, 0]); } // 其他转换尝试 return Convert.ToInt32(cellArray); } catch (Exception ex) { //Console.WriteLine($"提取整数失败(row:{row},col:{col}): {ex.Message}"); return 0; } } private decimal SafeExtractDecimal(object table_data, int row, int col) { try { // 尝试直接获取数组元素 var cellArray = (table_data as Array).GetValue(row, col); // 处理 MWNumericArray if (cellArray is MWNumericArray) { var numArray = cellArray as MWNumericArray; return (decimal)Math.Round(numArray.ToScalarDouble(), 15); } // 处理 double 数组 if (cellArray is double[,]) { var doubleArray = cellArray as double[,]; return (decimal)Math.Round(doubleArray[0, 0], 15); } // 其他转换尝试 return Convert.ToDecimal(cellArray); } catch (Exception ex) { // Console.WriteLine($"提取小数失败(row:{row},col:{col}): {ex.Message}"); return 0; } } private void CalculateAndInsertAnalysisProData(string filename) { try { // 1. 从 T_glanalysis_account 表中获取数据 var analysisData = DataAnalysisToPG.QueryAllGLAnalysisData(filename) as List; ; if (analysisData == null || !analysisData.Any()) { Console.WriteLine($"没有找到文件 {filename} 的分析数据"); return; } // 2. 按日期分组 var groupedData = analysisData .GroupBy(x => DateTime.Parse(x.Time).Date.ToString("yyyy-MM-dd")) .ToList(); foreach (var group in groupedData) { var proAccount = new T_glanalysispro_account { Xianlu = group.First().Xianlu, Chezhan = group.First().Chezhan, Time = group.Key, Filename = filename, Curvetype = group.First().Curvetype, Curvenumber = group.First().Curvenumber, // 计算总功率的最大、最小、平均值 Totalworkmax = group.Max(x => x.Totalwork), Totalworkmin = group.Min(x => x.Totalwork), Totalworkavg = group.Average(x => x.Totalwork), // 计算变化率的最大、最小、平均值 Changeratemax = group.Max(x => x.Changerate), Changeratemin = group.Min(x => x.Changerate), Changerateavg = group.Average(x => x.Changerate), // 计算偏差值的最大、最小、平均值 Offsetvaluemax = group.Max(x => x.Offsetvalue), Offsetvaluemin = group.Min(x => x.Offsetvalue), Offsetvalueavg = group.Average(x => x.Offsetvalue), // 计算功率方差的最大、最小、平均值 Powervariancemax = group.Max(x => x.Powervariance), Powervariancemin = group.Min(x => x.Powervariance), Powervarianceavg = group.Average(x => x.Powervariance) }; // 3. 插入数据到 T_glanalysispro_account 表 try { DataAnalysisToPG.InsertGLAnalysisProData(proAccount); Console.WriteLine($"成功插入日期 {group.Key} 的统计数据"); } catch (Exception ex) { Console.WriteLine($"插入数据失败: {ex.Message}"); } } } catch (Exception ex) { Console.WriteLine($"处理数据时出错: {ex.Message}"); Console.WriteLine($"堆栈跟踪: {ex.StackTrace}"); } } /// /// 缺口算法 public void QK_new(T_dwqkfile_account whichfile) { string fname_dir0 = Path.GetDirectoryName(whichfile.Srlj) + "\\"; string fname0 = Path.GetFileName(whichfile.Srlj); //Console.Write(fname_dir0); //Console.Write(fname0); string xianlu = whichfile.Xianlu; string chezhan = whichfile.Chezhan; string filename = whichfile.Filename; try { var data = AnalysisAlgorithmcs.QKFX(fname_dir0, fname0, xianlu, chezhan, filename); readQKFX(data, whichfile); } catch (Exception ex) { XtraMessageBox.Show("文件:" + whichfile.Filename + "执行失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); throw; } } /// 读缺口分析数据 private void readQKFX(MWArray[] agrsOut, T_dwqkfile_account whichfile) { try { MWCellArray output1 = agrsOut[0] as MWCellArray;//数据 MWCellArray output2 = agrsOut[1] as MWCellArray;//时间 var table_data = output1.ToArray(); var table_date = (object[,])output2.ToArray(); List QKobjs = new List(); // 假设是二维数组,从第2行开始 for (int i = 1; i < (table_data as Array).GetLength(0); i++) { T_qkanalysis_account qkdata = new T_qkanalysis_account(); qkdata.Filename = whichfile.Filename; qkdata.Xianlu = whichfile.Xianlu; qkdata.Chezhan = whichfile.Chezhan; // 安全地获取每列数据 qkdata.Gapnumber = SafeExtractInt(table_data, i, 0); qkdata.Gaptype = SafeExtractInt(table_data, i, 1); qkdata.Movechange = SafeExtractDecimal(table_data, i, 3); qkdata.Change = SafeExtractDecimal(table_data, i, 4); qkdata.Passchange = SafeExtractDecimal(table_data, i, 5); // 解析时间 try { if (table_date[i, 0] is char[,]) { string timeString = Char2String((char[,])table_date[i, 0]); if (!string.IsNullOrEmpty(timeString)) { DateTime parsedTime; // 尝试解析两种格式 if (DateTime.TryParseExact(timeString, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedTime)) { qkdata.Time = parsedTime.ToString("yyyy-MM-dd HH:mm:ss"); // 格式化为字符串 } else if (DateTime.TryParseExact(timeString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedTime)) { qkdata.Time = parsedTime.ToString("yyyy-MM-dd HH:mm:ss"); // 格式化为字符串 } else { qkdata.Time = null; // 或者设置为默认值 } } else { qkdata.Time = null; // 或者设置为默认值 } } else { qkdata.Time = null; // 或者设置为默认值 } } catch (FormatException ex) { Console.WriteLine($"时间解析失败: {ex.Message}"); qkdata.Time = null; // 或者设置为默认值 } QKobjs.Add(qkdata); } //Console.WriteLine("解析完成,共 " + GLobjs.Count + " 条记录"); DataAnalysisToPG.updataTaskstatusQK(new string[] { whichfile.Id.ToString(), type + "算法执行完毕" }); DataAnalysisToPG.InsertQKFXDataToPG(QKobjs); } catch (Exception ex) { //Console.WriteLine("解析出错: " + ex.Message); // Console.WriteLine("堆栈跟踪: " + ex.StackTrace); } } /// /// /// /// /// /// /// /// /// /// /// /// /// /// private void getdataWXSF(List jhfe_account, ref string[] date, ref string[] car, ref double[] mile, ref List wave_data, ref List id_wave_all, ref List jx_loc_all, ref string[] line, ref double[] velo, ref string[] zc) { int bxindex = 0; for (int i = 0; i < jhfe_account.Count; i++) { date[i] = jhfe_account[i].Riqi; car[i] = jhfe_account[i].Jcc== "轨检车" ? "轨检车" : jhfe_account[i].Jcc.Split('-')[1]; mile[i] = Convert.ToDouble(jhfe_account[i].Jgjlc); jx_loc_all.Add(Convert.ToDouble(jhfe_account[i].Jgjcydxh)); jx_loc_all.Add(Convert.ToDouble(jhfe_account[i].Xgjcydxh)); line[i] = ((T_file_account)DataAnalysisToPG.QueryToPGById(Convert.ToInt32(jhfe_account[i].Filename_jh.Trim()))).Yswjm.Split('-')[0]; velo[i] = Convert.ToDouble(jhfe_account[i].Sudu_jhfx); zc[i] = jhfe_account[i].Zcx; getWXSFBXdata(jhfe_account[i].Yswjm_jhfx, ref bxindex, ref wave_data, ref id_wave_all); } } private void getWXSFBXdata(string ids, ref int index, ref List wave_data, ref List id_wave_all) { List bolist = DMControl.GetJHFX_BXDataByIDS(ids); index = index + 1; id_wave_all.Add(index); for (int i = 0; i < bolist.Count; i++) { wave_data.Add((double)(bolist[i].Licheng)); wave_data.Add((double)(bolist[i].Sudu_jhbx)); wave_data.Add((double)(bolist[i].Cthj)); wave_data.Add((double)(bolist[i].Ctcj)); wave_data.Add((double)(bolist[i].Gjzhy)); wave_data.Add((double)(bolist[i].Gjyhy)); wave_data.Add((double)(bolist[i].Zgd)); wave_data.Add((double)(bolist[i].Ygd)); wave_data.Add((double)(bolist[i].Zgx)); wave_data.Add((double)(bolist[i].Ygx)); wave_data.Add((double)(bolist[i].Gj)); wave_data.Add((double)(bolist[i].Sp)); wave_data.Add((double)(bolist[i].Sjk)); wave_data.Add((double)(bolist[i].Cbzgd)); wave_data.Add((double)(bolist[i].Cbygd)); wave_data.Add((double)(bolist[i].Cbzgx)); wave_data.Add((double)(bolist[i].Cbygx)); wave_data.Add((double)(bolist[i].Dcdw)); } index += bolist.Count - 1; id_wave_all.Add(index); } /// /// 从数据库获取对应符合要求的道岔台账信息 /// private double[] getTZDC(List taizhang) { //StreamWriter FileWriter = new StreamWriter("E://get2pgTZ.txt", true); //写文件 string txtDetail = ""; //StreamWriter sr = new StreamWriter("E://DDD.txt"); List result = new List(); for (int i = 0; i < taizhang.Count; i++) { result.Add(Convert.ToDouble(taizhang[i].Jgjlc)); result.Add(Convert.ToDouble(taizhang[i].Zch)); result.Add(Convert.ToDouble(taizhang[i].Quanchang)); txtDetail += taizhang[i].Jgjlc + "\t" + taizhang[i].Zch + "\t" + taizhang[i].Quanchang + "\n"; } //FileWriter.Write(txtDetail);//将字符串写入 //FileWriter.Close(); //关闭StreamWriter对象k //******构造二维数组****** double[] ret = new double[result.Count]; for (int i = 0; i < result.Count; i++) { ret[i] = result[i]; } return ret; } /// /// 从数据库获取对应符合要求的曲线台账信息 /// private double[] getTZQX(List taizhang, bool isjh) { List result = new List(); for (int i = 0; i < taizhang.Count; i++) { result.Add(Convert.ToDouble(taizhang[i].Qzlc)); result.Add(Convert.ToDouble(taizhang[i].Jslc)); if (taizhang[i].Qxfx.Trim() == "左") { result.Add(1); } else { result.Add(-1); } if (isjh) { result.Add(Convert.ToDouble(taizhang[i].Chaogao)); } else { result.Add(Convert.ToDouble(taizhang[i].Qxbj)); } result.Add(Convert.ToDouble(taizhang[i].Qhhxc)); result.Add(Convert.ToDouble(taizhang[i].Zhhxc)); } //******构造二维数组****** double[] ret = new double[result.Count]; for (int i = 0; i < result.Count; i++) { ret[i] = result[i]; } return ret; } /// /// 从数据库获取对应符合要求的曲线台账信息 /// private double[] getTZJGJX() { List tabledata = new List(); List tablelist = DataAnalysisToPG.QueryJGJXGJJ(); List GS = tablelist.Where(i => i.Sudutype == 0).ToList(); List DS = tablelist.Where(i => i.Sudutype == 1).ToList(); if (DACommon.gdsBool == 0) { tabledata = GS; } else if (DACommon.gdsBool == 1) { tabledata = DS; } else { tabledata = tablelist; } List result = new List(); for (int i = 0; i < tabledata.Count; i++) { result.Add(Convert.ToDouble(tabledata[i].Zch)); result.Add(Convert.ToDouble(tabledata[i].Dcqc)); result.Add(Convert.ToDouble(tabledata[i].Gdjxgjj)); } //******构造二维数组****** double[] ret = new double[result.Count]; for (int i = 0; i < result.Count; i++) { ret[i] = result[i]; } return ret; } private double[] getTZXX1(List taizhang) { List result = new List(); for (int i = 0; i < taizhang.Count; i++) { result.Add(Convert.ToDouble(taizhang[i].Jgjlc)); } //******构造二维数组****** double[] ret = new double[result.Count]; for (int i = 0; i < result.Count; i++) { ret[i] = result[i]; } return ret; } /// /// 几何读台账txt /// private double[] readtxt(string txtPath) { List result = new List(); StreamReader SR = new StreamReader(txtPath); while (!SR.EndOfStream) { string[] str = SR.ReadLine().Replace("\t", " ").Split(' '); for (int i = 0; i < str.Length; i++) { result.Add(Convert.ToDouble(str[i])); } } //******构造二维数组****** double[] ret = new double[result.Count]; for (int i = 0; i < result.Count; i++) { ret[i] = result[i]; } return ret; } /// /// 轮轨力读台账txt获取尖轨尖里程 /// private double[] readtxt2(string txtPath) { List result = new List(); StreamReader SR = new StreamReader(txtPath); while (!SR.EndOfStream) { string[] str = SR.ReadLine().Replace("\t", " ").Split(' '); result.Add(Convert.ToDouble(str[0])); } //******构造二维数组****** double[] ret = new double[result.Count]; for (int i = 0; i < result.Count; i++) { ret[i] = result[i]; } return ret; } /// /// char[]转string /// private string Char2String(char[,] chararr) { string arr = ""; for (int j = 0; j < chararr.GetLength(1); j++) { arr += chararr[0, j].ToString(); } return arr; } } }