|
|
|
@ -40,7 +40,7 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, List<DeviceParam>> keyValues = new Dictionary<string, List<DeviceParam>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sheetNames = MiniExcel.GetSheetNames(filePath);
|
|
|
|
|
foreach (var sheetName in sheetNames)
|
|
|
|
|
{
|
|
|
|
@ -49,7 +49,7 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
List<dynamic> info = MiniExcel.Query(filePath, sheetName: sheetName).ToList();
|
|
|
|
|
if (info != null && info.Count() > paramBeginRowNumber)
|
|
|
|
|
{
|
|
|
|
|
for(int i=8; i<16; i++)
|
|
|
|
|
for (int i = 8; i < 16; i++)
|
|
|
|
|
{
|
|
|
|
|
DeviceParam deviceParam = new DeviceParam();
|
|
|
|
|
deviceParam.id = System.Guid.NewGuid().ToString("N");
|
|
|
|
@ -69,7 +69,7 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
param_17.deviceCode = "EVtest";
|
|
|
|
|
param_17.propertyCode = info[17].C;
|
|
|
|
|
param_17.dataType = 5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<PropertyValue> propertyValues = new List<PropertyValue>();
|
|
|
|
|
//tag9 监测明细
|
|
|
|
|
for (int i = 17; i < info.Count();)
|
|
|
|
@ -83,7 +83,7 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
{
|
|
|
|
|
PropertyValue propertyValue = new PropertyValue();
|
|
|
|
|
propertyValue.CHECK_ITEM = MidStrEx_New((string)info[i].D, "-", "-");
|
|
|
|
|
propertyValue.ITEM_VALUE = info[i].E == null ? " " : string.Format("{0}",info[i].E);
|
|
|
|
|
propertyValue.ITEM_VALUE = info[i].E == null ? " " : string.Format("{0}", info[i].E);
|
|
|
|
|
propertyValue.TEST_STATUS = info[i + 1].E == null ? " " : string.Format("{0}", info[i + 1].E);
|
|
|
|
|
propertyValue.STANDARDVALUE = info[i + 2].E == null ? " " : string.Format("{0}", info[i + 2].E);
|
|
|
|
|
propertyValue.STANDARDMAX = info[i + 3].E == null ? " " : string.Format("{0}", info[i + 3].E);
|
|
|
|
@ -98,7 +98,7 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
i = i + 6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
param_17.propertyValue = jsonChange.ModeToJson(propertyValues);
|
|
|
|
|
param_17.time = GetTimeStamp();
|
|
|
|
@ -112,7 +112,7 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
param_16.deviceCode = "EVtest";
|
|
|
|
|
param_16.propertyCode = info[16].C;
|
|
|
|
|
param_16.dataType = GetDataType(info[16].F == null ? "Text" : info[16].F);
|
|
|
|
|
param_16.propertyValue = info[16].E == null ? "":info[16].E;
|
|
|
|
|
param_16.propertyValue = info[16].E == null ? "" : info[16].E;
|
|
|
|
|
param_16.time = GetTimeStamp();
|
|
|
|
|
deviceParam_16.data = param_16;
|
|
|
|
|
deviceParams.Add(deviceParam_16);
|
|
|
|
@ -159,9 +159,9 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DeviceParametersValue parametersValue = new DeviceParametersValue();
|
|
|
|
|
if (item.A as string == null) continue;
|
|
|
|
|
parametersValue.paramNumber = item.A as string;
|
|
|
|
|
parametersValue.paramContent = item.B as string;
|
|
|
|
|
if (item.A.ToString() == null) continue;
|
|
|
|
|
parametersValue.paramNumber = item.A.ToString();
|
|
|
|
|
parametersValue.paramContent = item.A.ToString();
|
|
|
|
|
#region 备份修改 将double转为object
|
|
|
|
|
/*parametersValue.observedValue = item.C == null ? 0 : item.C;
|
|
|
|
|
parametersValue.nominalValue = item.D == null ? 0 : item.D;
|
|
|
|
@ -171,12 +171,12 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
parametersValue.state = item.H as string;*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
parametersValue.observedValue = string.IsNullOrEmpty(item.C) ? 0 : item.C;
|
|
|
|
|
parametersValue.nominalValue = string.IsNullOrEmpty(item.D)? 0 : item.D;
|
|
|
|
|
parametersValue.overproofValue = string.IsNullOrEmpty(item.E) ? 0 : item.E;
|
|
|
|
|
parametersValue.upperDeviation = string.IsNullOrEmpty(item.F) ? 0 : item.F;
|
|
|
|
|
parametersValue.lowerDeviation = string.IsNullOrEmpty(item.G) ? 0 : item.G;
|
|
|
|
|
parametersValue.state = item.H as string;
|
|
|
|
|
parametersValue.observedValue = string.IsNullOrEmpty(item.C.ToString()) ? 0 : item.C;
|
|
|
|
|
parametersValue.nominalValue = string.IsNullOrEmpty(item.D.ToString()) ? 0 : item.D;
|
|
|
|
|
parametersValue.overproofValue = string.IsNullOrEmpty(item.E.ToString()) ? 0 : item.E;
|
|
|
|
|
parametersValue.upperDeviation = string.IsNullOrEmpty(item.F.ToString()) ? 0 : item.F;
|
|
|
|
|
parametersValue.lowerDeviation = string.IsNullOrEmpty(item.G.ToString()) ? 0 : item.G;
|
|
|
|
|
parametersValue.state = item.H.ToString();
|
|
|
|
|
|
|
|
|
|
values.Add(parametersValue);
|
|
|
|
|
}
|
|
|
|
@ -191,7 +191,7 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
}
|
|
|
|
|
return formatFileData(result);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception(ex.Message);
|
|
|
|
|
}
|
|
|
|
@ -240,15 +240,18 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
{
|
|
|
|
|
PropertyValue propertyValue = new PropertyValue();
|
|
|
|
|
propertyValue.CHECK_ITEM = string.IsNullOrEmpty(item.paramContent) ? "" : item.paramContent;
|
|
|
|
|
propertyValue.ITEM_VALUE = string.IsNullOrEmpty(item.nominalValue.ToString()) ? "" : item.nominalValue.ToString();
|
|
|
|
|
propertyValue.ACCURACYVALUE = string.IsNullOrEmpty(item.observedValue.ToString()) ? "" : item.observedValue.ToString();
|
|
|
|
|
propertyValue.ITEM_VALUE = string.IsNullOrEmpty(item.observedValue.ToString()) ? "" : item.observedValue.ToString();
|
|
|
|
|
|
|
|
|
|
propertyValue.TEST_STATUS = string.IsNullOrEmpty(item.state) ? "" : item.state;
|
|
|
|
|
propertyValue.STANDARDVALUE = string.IsNullOrEmpty(item.overproofValue.ToString()) ? "" : item.overproofValue.ToString();
|
|
|
|
|
propertyValue.STANDARDMAX = string.IsNullOrEmpty(item.upperDeviation.ToString()) ? "" : item.upperDeviation.ToString();
|
|
|
|
|
propertyValue.STANDARDMIN = string.IsNullOrEmpty(item.lowerDeviation.ToString()) ? "" : item.lowerDeviation.ToString();
|
|
|
|
|
propertyValue.STANDARDVALUE = string.IsNullOrEmpty(item.nominalValue.ToString()) ? "" : item.nominalValue.ToString();
|
|
|
|
|
|
|
|
|
|
propertyValue.STANDARDMAX = CalculateThreshold(item.nominalValue.ToString(), item.upperDeviation.ToString());
|
|
|
|
|
//propertyValue.STANDARDMIN = string.IsNullOrEmpty(item.lowerDeviation.ToString()) ? "" : item.lowerDeviation.ToString();
|
|
|
|
|
propertyValue.STANDARDMIN = CalculateThreshold(item.nominalValue.ToString(), item.lowerDeviation.ToString());
|
|
|
|
|
propertyValue.TEST_DETAIL_ID = System.Guid.NewGuid().ToString("N");
|
|
|
|
|
|
|
|
|
|
//空值处理
|
|
|
|
|
propertyValue.ACCURACYVALUE = "";
|
|
|
|
|
propertyValue.DEVICE_NAME = "";
|
|
|
|
|
propertyValue.UOM = "";
|
|
|
|
|
propertyValues.Add(propertyValue);
|
|
|
|
@ -256,13 +259,14 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
param.propertyValue = jsonChange.ModeToJson(propertyValues);
|
|
|
|
|
logHelper.Info($"propertyValue:{jsonChange.ModeToJson(propertyValues)}");
|
|
|
|
|
//param.propertyValue = propertyValues;
|
|
|
|
|
param.time = GetTimeStamp();
|
|
|
|
|
deviceParam.data = param;
|
|
|
|
|
|
|
|
|
|
deviceParams.Add(deviceParam);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//推送标志位
|
|
|
|
|
DeviceParam deviceParam_16 = new DeviceParam();
|
|
|
|
@ -279,7 +283,7 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
keyValues.Add("排气阀片", deviceParams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return keyValues;
|
|
|
|
|
}
|
|
|
|
@ -287,7 +291,7 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
private string getNodeValue(string nodeStr)
|
|
|
|
|
{
|
|
|
|
|
string info = "";
|
|
|
|
|
switch(nodeStr)
|
|
|
|
|
switch (nodeStr)
|
|
|
|
|
{
|
|
|
|
|
case "tag1":
|
|
|
|
|
info = appConfig.产线;
|
|
|
|
@ -350,6 +354,34 @@ namespace FileDataUpload.FileOperate
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据名义值、上公差/下公差计算最大/最小值
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="nominalValue"></param>
|
|
|
|
|
/// <param name="difference"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private string CalculateThreshold(string nominalValue, string difference)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string threshold = "";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(nominalValue)) return threshold;
|
|
|
|
|
|
|
|
|
|
decimal nominalValueDecimal = decimal.Parse(nominalValue);
|
|
|
|
|
decimal differenceDecimal = decimal.Parse(string.IsNullOrEmpty(difference) ? "0" : difference);
|
|
|
|
|
|
|
|
|
|
threshold = (nominalValueDecimal + differenceDecimal).ToString();
|
|
|
|
|
|
|
|
|
|
return threshold;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("CalculateThreshold异常", e);
|
|
|
|
|
return threshold;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取时间戳
|
|
|
|
|
/// </summary>
|
|
|
|
|