|
@@ -55,7 +55,7 @@ namespace Uninpho.Tools.components.DataAnalysis
|
|
|
if (iszhengc)
|
|
|
{
|
|
|
bool boo = true;
|
|
|
- if (type != "微小" && type != "功率")
|
|
|
+ if (type != "微小" && type != "功率" && type != "缺口")
|
|
|
{
|
|
|
SuanFaFrom frm = new SuanFaFrom();
|
|
|
frm.StartPosition = FormStartPosition.CenterParent;
|
|
@@ -84,7 +84,7 @@ namespace Uninpho.Tools.components.DataAnalysis
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (type == "功率")
|
|
|
+ if (type == "功率"|| type == "缺口")
|
|
|
{
|
|
|
for (int i = 0; i < selectrow.Length; i++)
|
|
|
{
|
|
@@ -110,8 +110,15 @@ namespace Uninpho.Tools.components.DataAnalysis
|
|
|
b = false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- DataAnalysisToPG.DelUpdataDataDWGL(GV.GetRowCellValue(selectrow[i], "Id").ToString(), type);
|
|
|
+ if(type == "功率")
|
|
|
+ {
|
|
|
+ DataAnalysisToPG.DelUpdataDataDWGL(GV.GetRowCellValue(selectrow[i], "Id").ToString(), type);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DataAnalysisToPG.DelUpdataDataDWQK(GV.GetRowCellValue(selectrow[i], "Id").ToString(), type);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -271,8 +278,40 @@ namespace Uninpho.Tools.components.DataAnalysis
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- //提示
|
|
|
- if (boo)
|
|
|
+
|
|
|
+ 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);
|
|
|
}
|
|
@@ -838,13 +877,11 @@ namespace Uninpho.Tools.components.DataAnalysis
|
|
|
|
|
|
/// 功率算法
|
|
|
public void GL_new(T_dwfile_account whichfile)
|
|
|
- {
|
|
|
- //List<T_daocha_account> daochabiao = (List<T_daocha_account>)DataAnalysisToPG.QueryDCTZ(whichfile.Xlm, whichfile.Yswjm.Split('-')[0].ToCharArray());
|
|
|
- //List<T_quxian_account> quxianbiao = (List<T_quxian_account>)DataAnalysisToPG.QueryQXTZ(whichfile.Xlm, whichfile.Yswjm.Split('-')[0].ToCharArray());
|
|
|
+ {
|
|
|
string fname_dir0 = Path.GetDirectoryName(whichfile.Srlj) + "\\";
|
|
|
string fname0 = Path.GetFileName(whichfile.Srlj);
|
|
|
- Console.Write(fname_dir0);
|
|
|
- Console.Write(fname0);
|
|
|
+ //Console.Write(fname_dir0);
|
|
|
+ //Console.Write(fname0);
|
|
|
|
|
|
string xianlu = whichfile.Xianlu;
|
|
|
string chezhan = whichfile.Chezhan;
|
|
@@ -853,8 +890,7 @@ namespace Uninpho.Tools.components.DataAnalysis
|
|
|
try
|
|
|
{
|
|
|
var data = AnalysisAlgorithmcs.GLFX(fname_dir0, fname0, xianlu, chezhan, filename);
|
|
|
- readGLFX(data, whichfile);
|
|
|
- //readGLFX_TEST(data, whichfile);
|
|
|
+ readGLFX(data, whichfile);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -868,38 +904,64 @@ namespace Uninpho.Tools.components.DataAnalysis
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- MWCellArray output1 = agrsOut[0] as MWCellArray;
|
|
|
+ MWCellArray output1 = agrsOut[0] as MWCellArray;//数据
|
|
|
+ MWCellArray output2 = agrsOut[1] as MWCellArray;//时间
|
|
|
var table_data = output1.ToArray();
|
|
|
-
|
|
|
- //// 打印原始数据结构
|
|
|
- //Console.WriteLine("数据类型: " + table_data.GetType());
|
|
|
- //Console.WriteLine("数据维度: " + (table_data as Array).Rank);
|
|
|
-
|
|
|
+ var table_date = (object[,])output2.ToArray();
|
|
|
+
|
|
|
List<T_glanalysis_account> GLobjs = new List<T_glanalysis_account>();
|
|
|
|
|
|
// 假设是二维数组,从第2行开始
|
|
|
- for (int i = 2; i < (table_data as Array).GetLength(0); i++)
|
|
|
+ for (int i = 1; i < (table_data as Array).GetLength(0); i++)
|
|
|
{
|
|
|
T_glanalysis_account gldata = new T_glanalysis_account();
|
|
|
|
|
|
- // 安全地获取每列数据
|
|
|
- gldata.Curvenumber = SafeExtractInt(table_data, i, 2);
|
|
|
- gldata.Time = SafeExtractDecimal(table_data, i, 3);
|
|
|
- gldata.Directionalmarker = SafeExtractInt(table_data, i, 4);
|
|
|
- gldata.Curvetype = SafeExtractInt(table_data, i, 5);
|
|
|
- gldata.Totalwork = SafeExtractDecimal(table_data, i, 6);
|
|
|
- gldata.Changerate = SafeExtractDecimal(table_data, i, 7);
|
|
|
- gldata.Offsetvalue = SafeExtractDecimal(table_data, i, 8);
|
|
|
- gldata.Powervariance = SafeExtractDecimal(table_data, i, 9);
|
|
|
-
|
|
|
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; // 或者设置为默认值
|
|
|
+ }
|
|
|
+
|
|
|
GLobjs.Add(gldata);
|
|
|
}
|
|
|
|
|
|
//Console.WriteLine("解析完成,共 " + GLobjs.Count + " 条记录");
|
|
|
+
|
|
|
DataAnalysisToPG.updataTaskstatus(new string[] { whichfile.Id.ToString(), type + "算法执行完毕" });
|
|
|
DataAnalysisToPG.InsertGLFXDataToPG(GLobjs);
|
|
|
|
|
@@ -973,6 +1035,117 @@ namespace Uninpho.Tools.components.DataAnalysis
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ ///
|
|
|
+ /// 缺口算法
|
|
|
+ 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<T_qkanalysis_account> QKobjs = new List<T_qkanalysis_account>();
|
|
|
+
|
|
|
+ // 假设是二维数组,从第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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ///
|
|
|
+
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|