|
|
@@ -4,17 +4,12 @@ using System.Data;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
-using System.Text.RegularExpressions;
|
|
|
-using System.Threading.Tasks;
|
|
|
-using Business;
|
|
|
-using Business.Core.Utilities;
|
|
|
-using Business.Dto;
|
|
|
-using Business.ResourceExamineManagement;
|
|
|
+using Business.EntityFrameworkCore.SqlRepositories;
|
|
|
+using Business.StructuredDB.Sqe;
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
using NPOI.SS.UserModel;
|
|
|
using NPOI.XSSF.UserModel;
|
|
|
using Volo.Abp.Application.Services;
|
|
|
-using Volo.Abp.MultiTenancy;
|
|
|
|
|
|
namespace Business.VSM
|
|
|
{
|
|
|
@@ -23,11 +18,37 @@ namespace Business.VSM
|
|
|
/// </summary>
|
|
|
public class SqeExcelService : ApplicationService, ISqeExcelService
|
|
|
{
|
|
|
- private readonly ICurrentTenant _currentTenant;
|
|
|
- //LoggerHelper WLLog;
|
|
|
- public SqeExcelService()
|
|
|
+ LoggerHelper WLLog;
|
|
|
+
|
|
|
+ private readonly ISqeRepository<sqe_cto_process> _sqe_cto_process;
|
|
|
+ private readonly ISqeRepository<sqe_cto_process_data> _sqe_cto_process_data;
|
|
|
+ private readonly ISqeRepository<sqe_cto_process_standard> _sqe_cto_process_standard;
|
|
|
+ private readonly ISqeRepository<sqe_cto_test> _sqe_cto_test;
|
|
|
+ private readonly ISqeRepository<sqe_cto_test_data> _sqe_cto_test_data;
|
|
|
+ private readonly ISqeRepository<sqe_cto_test_standard> _sqe_cto_test_standard;
|
|
|
+ private readonly ISqeRepository<sqe_file_upload> _sqe_file_upload;
|
|
|
+ private readonly ISqeRepository<sqe_file_data> _sqe_file_data;
|
|
|
+
|
|
|
+
|
|
|
+ public SqeExcelService(ISqeRepository<sqe_cto_process> sqe_cto_process
|
|
|
+ , ISqeRepository<sqe_cto_process_data> sqe_cto_process_data
|
|
|
+ , ISqeRepository<sqe_cto_process_standard> sqe_cto_process_standard
|
|
|
+ , ISqeRepository<sqe_cto_test> sqe_cto_test
|
|
|
+ , ISqeRepository<sqe_cto_test_data> sqe_cto_test_data
|
|
|
+ , ISqeRepository<sqe_cto_test_standard> sqe_cto_test_standard
|
|
|
+ , ISqeRepository<sqe_file_upload> sqe_file_upload
|
|
|
+ , ISqeRepository<sqe_file_data> sqe_file_data
|
|
|
+ )
|
|
|
{
|
|
|
- // WLLog = new LoggerHelper();
|
|
|
+ WLLog = new LoggerHelper();
|
|
|
+ _sqe_cto_process = sqe_cto_process;
|
|
|
+ _sqe_cto_process_data = sqe_cto_process_data;
|
|
|
+ _sqe_cto_process_standard = sqe_cto_process_standard;
|
|
|
+ _sqe_cto_test = sqe_cto_test;
|
|
|
+ _sqe_cto_test_data = sqe_cto_test_data;
|
|
|
+ _sqe_cto_test_standard = sqe_cto_test_standard;
|
|
|
+ _sqe_file_upload = sqe_file_upload;
|
|
|
+ _sqe_file_data = sqe_file_data;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -175,8 +196,7 @@ namespace Business.VSM
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- //WLLog.Error("Excel导入问题:", ex);
|
|
|
- new NLogHelper("SqeExcelService").WriteLog("ImportExcelSheetToDataTable", "Excel导入问题" + ex.Message, _currentTenant.Id.ToString());
|
|
|
+ WLLog.Error("Excel导入问题:", ex);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
@@ -214,8 +234,7 @@ namespace Business.VSM
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- //WLLog.Error("Excel导入问题:", ex);
|
|
|
- new NLogHelper("SqeExcelService").WriteLog("ImportExcelSheetToDataTable", "Excel导入问题" + ex.Message, _currentTenant.Id.ToString());
|
|
|
+ WLLog.Error("Excel导入问题:", ex);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
@@ -360,8 +379,7 @@ namespace Business.VSM
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- //WLLog.Error("Excel导入问题:", ex);
|
|
|
- new NLogHelper("SqeExcelService").WriteLog("ImportExcelSheetToDataTable", "Excel导入问题" + ex.Message, _currentTenant.Id.ToString());
|
|
|
+ WLLog.Error("Excel导入问题:", ex);
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
@@ -399,8 +417,7 @@ namespace Business.VSM
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- //WLLog.Error("Excel导入问题:", ex);
|
|
|
- new NLogHelper("SqeExcelService").WriteLog("ImportExcelSheetToDataTable", "Excel导入问题" + ex.Message, _currentTenant.Id.ToString());
|
|
|
+ WLLog.Error("Excel导入问题:", ex);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
@@ -455,8 +472,7 @@ namespace Business.VSM
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- //WLLog.Error("Excel导入问题:", ex);
|
|
|
- new NLogHelper("SqeExcelService").WriteLog("ImportExcelSheetToDataTable", "Excel导入问题"+ex.Message, _currentTenant.Id.ToString());
|
|
|
+ WLLog.Error("Excel导入问题:", ex);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
@@ -469,5 +485,885 @@ namespace Business.VSM
|
|
|
return tables;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 导入数据到检验表 sqe_cto_test、sqe_cto_test_standard、sqe_cto_test_data
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="upload_id"></param>
|
|
|
+ /// <param name="create_by"></param>
|
|
|
+ /// <param name="create_date"></param>
|
|
|
+ /// <param name="create_org"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public string ImportData_From_Data(int upload_id, string create_by, DateTime create_date, string create_org)
|
|
|
+ {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ List<sqe_file_data> datas = LoadData_file_data(upload_id);
|
|
|
+ if (datas == null || datas.Count == 0)
|
|
|
+ {
|
|
|
+ stringBuilder.AppendLine("导入数据信息不存在!");
|
|
|
+ return stringBuilder.ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ string errorMsg;
|
|
|
+ sqe_cto_test test = File_data_ToModel_test(datas, create_by, create_date, create_org, out errorMsg);
|
|
|
+ if (errorMsg != null && errorMsg.Length > 0)
|
|
|
+ {
|
|
|
+ stringBuilder.AppendLine(errorMsg);
|
|
|
+ return stringBuilder.ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ _sqe_cto_test.BeginTransaction();
|
|
|
+ _sqe_cto_test.Insert(test);
|
|
|
+
|
|
|
+ errorMsg = null;
|
|
|
+ List<sqe_cto_test_standard> standards = File_data_ToModel_test_standard(datas, test, create_by, create_date, create_org, out errorMsg);
|
|
|
+ if (errorMsg != null && errorMsg.Length > 0)
|
|
|
+ {
|
|
|
+ _sqe_cto_test.Rollback();
|
|
|
+ stringBuilder.AppendLine(errorMsg);
|
|
|
+ return stringBuilder.ToString();
|
|
|
+ }
|
|
|
+ _sqe_cto_test_standard.BeginTransaction();
|
|
|
+ _sqe_cto_test_standard.Insert(standards);
|
|
|
+
|
|
|
+ List<sqe_cto_test_data> test_Datas = File_data_ToModel_test_data(datas, test, standards, create_by, create_date, create_org, out errorMsg);
|
|
|
+ if (errorMsg != null && errorMsg.Length > 0)
|
|
|
+ {
|
|
|
+ _sqe_cto_test.Rollback();
|
|
|
+ _sqe_cto_test_standard.Rollback();
|
|
|
+ stringBuilder.AppendLine(errorMsg);
|
|
|
+ return stringBuilder.ToString();
|
|
|
+ }
|
|
|
+ _sqe_cto_test_data.Insert(test_Datas);
|
|
|
+ _sqe_cto_test.CommitTransaction();
|
|
|
+ _sqe_cto_test_standard.CommitTransaction();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ stringBuilder.Append("数据导入失败!");
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ }
|
|
|
+ return stringBuilder.ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 依据id,从sqe_file_upload和sqe_file_data,加载数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="upload_id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public List<sqe_file_data> LoadData_file_data(int upload_id)
|
|
|
+ {
|
|
|
+ List<sqe_file_data> datas = _sqe_file_data.Select(a => a.file_id == upload_id).OrderBy(a => a.id).ToList();
|
|
|
+ return datas;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public sqe_cto_test File_data_ToModel_test(List<sqe_file_data> datas, string create_by, DateTime create_date, string create_org, out string errorMsg)
|
|
|
+ {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+
|
|
|
+ sqe_cto_test model = new sqe_cto_test();
|
|
|
+ DateTime timeValue;
|
|
|
+ decimal realValuel;
|
|
|
+ if (datas != null && datas.Count >= 5)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ sqe_file_data data = datas[1];
|
|
|
+ if (DateTime.TryParse(data.c2, out timeValue))
|
|
|
+ {
|
|
|
+ model.product_time = timeValue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ model.product_time = DateTime.Parse("2000-01-01");
|
|
|
+ }
|
|
|
+ model.shift_no = data.c4;
|
|
|
+ model.item_no = data.c6;
|
|
|
+ model.item_name = data.c8;
|
|
|
+
|
|
|
+ data = datas[2];
|
|
|
+ model.material_batch = data.c2;
|
|
|
+ if (decimal.TryParse(data.c4, out realValuel))
|
|
|
+ {
|
|
|
+ model.material_used = realValuel;
|
|
|
+ }
|
|
|
+ model.item_batch = data.c6;
|
|
|
+ if (decimal.TryParse(data.c8, out realValuel))
|
|
|
+ {
|
|
|
+ model.item_qty = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ data = datas[3];
|
|
|
+ model.op_pre = data.c2;
|
|
|
+ model.op_pre_batch = data.c4;
|
|
|
+ model.op_current = data.c6;
|
|
|
+ model.op_batch = data.c8;
|
|
|
+
|
|
|
+ data = datas[4];
|
|
|
+ model.device_name = data.c2;
|
|
|
+ model.device_no = data.c4;
|
|
|
+ if (decimal.TryParse(data.c8, out realValuel))
|
|
|
+ {
|
|
|
+ model.sampling_number = realValuel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ WLLog.Error("Excel数据解析问题:", ex);
|
|
|
+ }
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+ errorMsg = string.Empty;
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ errorMsg = stringBuilder.ToString();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<sqe_cto_test_standard> File_data_ToModel_test_standard(List<sqe_file_data> datas, sqe_cto_test test, string create_by, DateTime create_date, string create_org, out string errorMsg)
|
|
|
+ {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+
|
|
|
+ List<sqe_cto_test_standard> modelList = new List<sqe_cto_test_standard>();
|
|
|
+ decimal realValuel;
|
|
|
+ if (datas != null && datas.Count >= 14)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ sqe_file_data dataRow = datas[6];
|
|
|
+ #region 处理尺寸的表头
|
|
|
+ if (dataRow.c3 != null && dataRow.c3.Length > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = new sqe_cto_test_standard();
|
|
|
+ model.standard_no = dataRow.c3;
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+ model.test_id = test.id;
|
|
|
+ modelList.Add(model);
|
|
|
+ }
|
|
|
+ if (dataRow.c4 != null && dataRow.c4.Length > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = new sqe_cto_test_standard();
|
|
|
+ model.standard_no = dataRow.c4;
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+ model.test_id = test.id;
|
|
|
+ modelList.Add(model);
|
|
|
+ }
|
|
|
+ if (dataRow.c5 != null && dataRow.c5.Length > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = new sqe_cto_test_standard();
|
|
|
+ model.standard_no = dataRow.c5;
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+ model.test_id = test.id;
|
|
|
+ modelList.Add(model);
|
|
|
+ }
|
|
|
+ if (dataRow.c6 != null && dataRow.c6.Length > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = new sqe_cto_test_standard();
|
|
|
+ model.standard_no = dataRow.c6;
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+ model.test_id = test.id;
|
|
|
+ modelList.Add(model);
|
|
|
+ }
|
|
|
+ if (dataRow.c7 != null && dataRow.c7.Length > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = new sqe_cto_test_standard();
|
|
|
+ model.standard_no = dataRow.c7;
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+ model.test_id = test.id;
|
|
|
+ modelList.Add(model);
|
|
|
+ }
|
|
|
+ if (dataRow.c8 != null && dataRow.c8.Length > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = new sqe_cto_test_standard();
|
|
|
+ model.standard_no = dataRow.c8;
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+ model.test_id = test.id;
|
|
|
+ modelList.Add(model);
|
|
|
+ }
|
|
|
+ if (dataRow.c9 != null && dataRow.c9.Length > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = new sqe_cto_test_standard();
|
|
|
+ model.standard_no = dataRow.c9;
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+ model.test_id = test.id;
|
|
|
+ modelList.Add(model);
|
|
|
+ }
|
|
|
+ if (dataRow.c10 != null && dataRow.c10.Length > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = new sqe_cto_test_standard();
|
|
|
+ model.standard_no = dataRow.c10;
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+ model.test_id = test.id;
|
|
|
+ modelList.Add(model);
|
|
|
+ }
|
|
|
+ if (dataRow.c11 != null && dataRow.c11.Length > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = new sqe_cto_test_standard();
|
|
|
+ model.standard_no = dataRow.c11;
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+ model.test_id = test.id;
|
|
|
+ modelList.Add(model);
|
|
|
+ }
|
|
|
+ #endregion 处理尺寸的表头
|
|
|
+
|
|
|
+
|
|
|
+ if (modelList.Count > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = modelList[0];
|
|
|
+ dataRow = datas[7];
|
|
|
+ model.sampling_count = int.Parse(dataRow.c3);
|
|
|
+
|
|
|
+ dataRow = datas[8];
|
|
|
+ model.is_associated_size = dataRow.c3;
|
|
|
+
|
|
|
+ dataRow = datas[9];
|
|
|
+ if (dataRow.c3 != null && decimal.TryParse(dataRow.c3, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_value = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[10];
|
|
|
+ if (dataRow.c3 != null && decimal.TryParse(dataRow.c3, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_up = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[11];
|
|
|
+ if (dataRow.c3 != null && decimal.TryParse(dataRow.c3, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_down = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[12];
|
|
|
+ if (dataRow.c3 != null && decimal.TryParse(dataRow.c3, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_max = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[13];
|
|
|
+ if (dataRow.c3 != null && decimal.TryParse(dataRow.c3, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_min = realValuel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (modelList.Count > 1)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = modelList[0];
|
|
|
+ dataRow = datas[7];
|
|
|
+ model.sampling_count = int.Parse(dataRow.c4);
|
|
|
+
|
|
|
+ dataRow = datas[8];
|
|
|
+ model.is_associated_size = dataRow.c4;
|
|
|
+
|
|
|
+ dataRow = datas[9];
|
|
|
+ if (dataRow.c4 != null && decimal.TryParse(dataRow.c4, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_value = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[10];
|
|
|
+ if (dataRow.c4 != null && decimal.TryParse(dataRow.c4, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_up = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[11];
|
|
|
+ if (dataRow.c4 != null && decimal.TryParse(dataRow.c4, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_down = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[12];
|
|
|
+ if (dataRow.c4 != null && decimal.TryParse(dataRow.c4, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_max = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[13];
|
|
|
+ if (dataRow.c4 != null && decimal.TryParse(dataRow.c4, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_min = realValuel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (modelList.Count > 2)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = modelList[0];
|
|
|
+ dataRow = datas[7];
|
|
|
+ model.sampling_count = int.Parse(dataRow.c5);
|
|
|
+
|
|
|
+ dataRow = datas[8];
|
|
|
+ model.is_associated_size = dataRow.c5;
|
|
|
+
|
|
|
+ dataRow = datas[9];
|
|
|
+ if (dataRow.c5 != null && decimal.TryParse(dataRow.c5, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_value = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[10];
|
|
|
+ if (dataRow.c5 != null && decimal.TryParse(dataRow.c5, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_up = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[11];
|
|
|
+ if (dataRow.c5 != null && decimal.TryParse(dataRow.c5, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_down = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[12];
|
|
|
+ if (dataRow.c5 != null && decimal.TryParse(dataRow.c5, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_max = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[13];
|
|
|
+ if (dataRow.c5 != null && decimal.TryParse(dataRow.c5, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_min = realValuel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (modelList.Count > 3)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = modelList[0];
|
|
|
+ dataRow = datas[7];
|
|
|
+ model.sampling_count = int.Parse(dataRow.c6);
|
|
|
+
|
|
|
+ dataRow = datas[8];
|
|
|
+ model.is_associated_size = dataRow.c6;
|
|
|
+
|
|
|
+ dataRow = datas[9];
|
|
|
+ if (dataRow.c6 != null && decimal.TryParse(dataRow.c6, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_value = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[10];
|
|
|
+ if (dataRow.c6 != null && decimal.TryParse(dataRow.c6, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_up = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[11];
|
|
|
+ if (dataRow.c6 != null && decimal.TryParse(dataRow.c6, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_down = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[12];
|
|
|
+ if (dataRow.c6 != null && decimal.TryParse(dataRow.c6, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_max = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[13];
|
|
|
+ if (dataRow.c6 != null && decimal.TryParse(dataRow.c6, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_min = realValuel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (modelList.Count > 4)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = modelList[0];
|
|
|
+ dataRow = datas[7];
|
|
|
+ model.sampling_count = int.Parse(dataRow.c7);
|
|
|
+
|
|
|
+ dataRow = datas[8];
|
|
|
+ model.is_associated_size = dataRow.c7;
|
|
|
+
|
|
|
+ dataRow = datas[9];
|
|
|
+ if (dataRow.c7 != null && decimal.TryParse(dataRow.c7, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_value = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[10];
|
|
|
+ if (dataRow.c7 != null && decimal.TryParse(dataRow.c7, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_up = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[11];
|
|
|
+ if (dataRow.c7 != null && decimal.TryParse(dataRow.c7, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_down = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[12];
|
|
|
+ if (dataRow.c7 != null && decimal.TryParse(dataRow.c7, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_max = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[13];
|
|
|
+ if (dataRow.c7 != null && decimal.TryParse(dataRow.c7, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_min = realValuel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (modelList.Count > 5)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = modelList[0];
|
|
|
+ dataRow = datas[7];
|
|
|
+ model.sampling_count = int.Parse(dataRow.c8);
|
|
|
+
|
|
|
+ dataRow = datas[8];
|
|
|
+ model.is_associated_size = dataRow.c8;
|
|
|
+
|
|
|
+ dataRow = datas[9];
|
|
|
+ if (dataRow.c8 != null && decimal.TryParse(dataRow.c8, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_value = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[10];
|
|
|
+ if (dataRow.c8 != null && decimal.TryParse(dataRow.c8, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_up = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[11];
|
|
|
+ if (dataRow.c8 != null && decimal.TryParse(dataRow.c8, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_down = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[12];
|
|
|
+ if (dataRow.c8 != null && decimal.TryParse(dataRow.c8, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_max = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[13];
|
|
|
+ if (dataRow.c8 != null && decimal.TryParse(dataRow.c8, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_min = realValuel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (modelList.Count > 6)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = modelList[0];
|
|
|
+ dataRow = datas[7];
|
|
|
+ model.sampling_count = int.Parse(dataRow.c9);
|
|
|
+
|
|
|
+ dataRow = datas[8];
|
|
|
+ model.is_associated_size = dataRow.c9;
|
|
|
+
|
|
|
+ dataRow = datas[9];
|
|
|
+ if (dataRow.c9 != null && decimal.TryParse(dataRow.c9, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_value = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[10];
|
|
|
+ if (dataRow.c9 != null && decimal.TryParse(dataRow.c9, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_up = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[11];
|
|
|
+ if (dataRow.c9 != null && decimal.TryParse(dataRow.c9, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_down = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[12];
|
|
|
+ if (dataRow.c9 != null && decimal.TryParse(dataRow.c9, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_max = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[13];
|
|
|
+ if (dataRow.c9 != null && decimal.TryParse(dataRow.c9, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_min = realValuel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (modelList.Count > 7)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = modelList[0];
|
|
|
+ dataRow = datas[7];
|
|
|
+ model.sampling_count = int.Parse(dataRow.c10);
|
|
|
+
|
|
|
+ dataRow = datas[8];
|
|
|
+ model.is_associated_size = dataRow.c10;
|
|
|
+
|
|
|
+ dataRow = datas[9];
|
|
|
+ if (dataRow.c10 != null && decimal.TryParse(dataRow.c10, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_value = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[10];
|
|
|
+ if (dataRow.c10 != null && decimal.TryParse(dataRow.c10, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_up = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[11];
|
|
|
+ if (dataRow.c10 != null && decimal.TryParse(dataRow.c10, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_down = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[12];
|
|
|
+ if (dataRow.c10 != null && decimal.TryParse(dataRow.c10, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_max = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[13];
|
|
|
+ if (dataRow.c10 != null && decimal.TryParse(dataRow.c10, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_min = realValuel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (modelList.Count > 8)
|
|
|
+ {
|
|
|
+ sqe_cto_test_standard model = modelList[0];
|
|
|
+ dataRow = datas[7];
|
|
|
+ model.sampling_count = int.Parse(dataRow.c11);
|
|
|
+
|
|
|
+ dataRow = datas[8];
|
|
|
+ model.is_associated_size = dataRow.c11;
|
|
|
+
|
|
|
+ dataRow = datas[9];
|
|
|
+ if (dataRow.c11 != null && decimal.TryParse(dataRow.c11, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_value = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[10];
|
|
|
+ if (dataRow.c11 != null && decimal.TryParse(dataRow.c11, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_up = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[11];
|
|
|
+ if (dataRow.c11 != null && decimal.TryParse(dataRow.c11, out realValuel))
|
|
|
+ {
|
|
|
+ model.delta_down = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[12];
|
|
|
+ if (dataRow.c11 != null && decimal.TryParse(dataRow.c11, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_max = realValuel;
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow = datas[13];
|
|
|
+ if (dataRow.c11 != null && decimal.TryParse(dataRow.c11, out realValuel))
|
|
|
+ {
|
|
|
+ model.standard_min = realValuel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ WLLog.Error("Excel数据解析问题:", ex);
|
|
|
+ }
|
|
|
+ errorMsg = stringBuilder.ToString();
|
|
|
+ return modelList;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ errorMsg = stringBuilder.ToString();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<sqe_cto_test_data> File_data_ToModel_test_data(List<sqe_file_data> datas, sqe_cto_test test, List<sqe_cto_test_standard> standards, string create_by, DateTime create_date, string create_org, out string errorMsg)
|
|
|
+ {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+
|
|
|
+ List<sqe_cto_test_data> modelList = new List<sqe_cto_test_data>();
|
|
|
+ decimal realValuel;
|
|
|
+ if (datas != null && datas.Count >= 17)
|
|
|
+ {
|
|
|
+ for (int i = 16; i < datas.Count; i++)
|
|
|
+ {
|
|
|
+ sqe_file_data dataRow = datas[i];
|
|
|
+ if (dataRow.c1 == null || dataRow.c1.Length == 0)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //初始化每一层的数据集合
|
|
|
+ List<sqe_cto_test_data> test_datas = new List<sqe_cto_test_data>();
|
|
|
+ for (int j = 0; j < standards.Count; j++)
|
|
|
+ {
|
|
|
+ sqe_cto_test_data data = new sqe_cto_test_data();
|
|
|
+ data.test_id = standards[j].test_id;
|
|
|
+ data.standard_id = standards[j].id;
|
|
|
+ data.create_by = create_by;
|
|
|
+ data.create_date = create_date;
|
|
|
+ data.create_org = create_org;
|
|
|
+ test_datas.Add(data);
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //将每一个检测标准的值从记录行中取出来
|
|
|
+ if (test_datas.Count > 0)
|
|
|
+ {
|
|
|
+ sqe_cto_test_data data = test_datas[0];
|
|
|
+ data.data_no = dataRow.c1;
|
|
|
+ if (dataRow.c2 != null)
|
|
|
+ {
|
|
|
+ String s = dataRow.c2.ToString();
|
|
|
+ DateTime date;
|
|
|
+ if (DateTime.TryParse(test.product_time.ToString("yyyy-MM-dd ") + s, out date))
|
|
|
+ {
|
|
|
+ data.data_time = date.ToString("yyyy-MM-dd HH:mm");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataRow.c3 != null && dataRow.c3.Length > 0 && decimal.TryParse(dataRow.c3, out realValuel))
|
|
|
+ {
|
|
|
+ data.data_value = realValuel;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.data_value = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ modelList.AddRange(test_datas);
|
|
|
+
|
|
|
+ if (test_datas.Count > 1)
|
|
|
+ {
|
|
|
+ sqe_cto_test_data data = test_datas[1];
|
|
|
+ data.data_no = dataRow.c1;
|
|
|
+ if (dataRow.c2 != null)
|
|
|
+ {
|
|
|
+ String s = dataRow.c2.ToString();
|
|
|
+ DateTime date;
|
|
|
+ if (DateTime.TryParse(test.product_time.ToString("yyyy-MM-dd ") + s, out date))
|
|
|
+ {
|
|
|
+ data.data_time = date.ToString("yyyy-MM-dd HH:mm");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataRow.c4 != null && dataRow.c4.Length > 0 && decimal.TryParse(dataRow.c4, out realValuel))
|
|
|
+ {
|
|
|
+ data.data_value = realValuel;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.data_value = null;
|
|
|
+ }
|
|
|
+ modelList.AddRange(test_datas);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (test_datas.Count > 2)
|
|
|
+ {
|
|
|
+ sqe_cto_test_data data = test_datas[1];
|
|
|
+ data.data_no = dataRow.c1;
|
|
|
+ if (dataRow.c2 != null)
|
|
|
+ {
|
|
|
+ String s = dataRow.c2.ToString();
|
|
|
+ DateTime date;
|
|
|
+ if (DateTime.TryParse(test.product_time.ToString("yyyy-MM-dd ") + s, out date))
|
|
|
+ {
|
|
|
+ data.data_time = date.ToString("yyyy-MM-dd HH:mm");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataRow.c5 != null && dataRow.c5.Length > 0 && decimal.TryParse(dataRow.c5, out realValuel))
|
|
|
+ {
|
|
|
+ data.data_value = realValuel;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.data_value = null;
|
|
|
+ }
|
|
|
+ modelList.AddRange(test_datas);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (test_datas.Count > 3)
|
|
|
+ {
|
|
|
+ sqe_cto_test_data data = test_datas[1];
|
|
|
+ data.data_no = dataRow.c1;
|
|
|
+ if (dataRow.c2 != null)
|
|
|
+ {
|
|
|
+ String s = dataRow.c2.ToString();
|
|
|
+ DateTime date;
|
|
|
+ if (DateTime.TryParse(test.product_time.ToString("yyyy-MM-dd ") + s, out date))
|
|
|
+ {
|
|
|
+ data.data_time = date.ToString("yyyy-MM-dd HH:mm");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataRow.c6 != null && dataRow.c6.Length > 0 && decimal.TryParse(dataRow.c6, out realValuel))
|
|
|
+ {
|
|
|
+ data.data_value = realValuel;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.data_value = null;
|
|
|
+ }
|
|
|
+ modelList.AddRange(test_datas);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (test_datas.Count > 4)
|
|
|
+ {
|
|
|
+ sqe_cto_test_data data = test_datas[1];
|
|
|
+ data.data_no = dataRow.c1;
|
|
|
+ if (dataRow.c2 != null)
|
|
|
+ {
|
|
|
+ String s = dataRow.c2.ToString();
|
|
|
+ DateTime date;
|
|
|
+ if (DateTime.TryParse(test.product_time.ToString("yyyy-MM-dd ") + s, out date))
|
|
|
+ {
|
|
|
+ data.data_time = date.ToString("yyyy-MM-dd HH:mm");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataRow.c7 != null && dataRow.c7.Length > 0 && decimal.TryParse(dataRow.c7, out realValuel))
|
|
|
+ {
|
|
|
+ data.data_value = realValuel;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.data_value = null;
|
|
|
+ }
|
|
|
+ modelList.AddRange(test_datas);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (test_datas.Count > 5)
|
|
|
+ {
|
|
|
+ sqe_cto_test_data data = test_datas[1];
|
|
|
+ data.data_no = dataRow.c1;
|
|
|
+ if (dataRow.c2 != null)
|
|
|
+ {
|
|
|
+ String s = dataRow.c2.ToString();
|
|
|
+ DateTime date;
|
|
|
+ if (DateTime.TryParse(test.product_time.ToString("yyyy-MM-dd ") + s, out date))
|
|
|
+ {
|
|
|
+ data.data_time = date.ToString("yyyy-MM-dd HH:mm");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataRow.c8 != null && dataRow.c8.Length > 0 && decimal.TryParse(dataRow.c8, out realValuel))
|
|
|
+ {
|
|
|
+ data.data_value = realValuel;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.data_value = null;
|
|
|
+ }
|
|
|
+ modelList.AddRange(test_datas);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (test_datas.Count > 6)
|
|
|
+ {
|
|
|
+ sqe_cto_test_data data = test_datas[1];
|
|
|
+ data.data_no = dataRow.c1;
|
|
|
+ if (dataRow.c2 != null)
|
|
|
+ {
|
|
|
+ String s = dataRow.c2.ToString();
|
|
|
+ DateTime date;
|
|
|
+ if (DateTime.TryParse(test.product_time.ToString("yyyy-MM-dd ") + s, out date))
|
|
|
+ {
|
|
|
+ data.data_time = date.ToString("yyyy-MM-dd HH:mm");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataRow.c9 != null && dataRow.c9.Length > 0 && decimal.TryParse(dataRow.c9, out realValuel))
|
|
|
+ {
|
|
|
+ data.data_value = realValuel;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.data_value = null;
|
|
|
+ }
|
|
|
+ modelList.AddRange(test_datas);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (test_datas.Count > 7)
|
|
|
+ {
|
|
|
+ sqe_cto_test_data data = test_datas[1];
|
|
|
+ data.data_no = dataRow.c1;
|
|
|
+ if (dataRow.c2 != null)
|
|
|
+ {
|
|
|
+ String s = dataRow.c2.ToString();
|
|
|
+ DateTime date;
|
|
|
+ if (DateTime.TryParse(test.product_time.ToString("yyyy-MM-dd ") + s, out date))
|
|
|
+ {
|
|
|
+ data.data_time = date.ToString("yyyy-MM-dd HH:mm");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataRow.c10 != null && dataRow.c10.Length > 0 && decimal.TryParse(dataRow.c10, out realValuel))
|
|
|
+ {
|
|
|
+ data.data_value = realValuel;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.data_value = null;
|
|
|
+ }
|
|
|
+ modelList.AddRange(test_datas);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (test_datas.Count > 8)
|
|
|
+ {
|
|
|
+ sqe_cto_test_data data = test_datas[1];
|
|
|
+ data.data_no = dataRow.c1;
|
|
|
+ if (dataRow.c2 != null)
|
|
|
+ {
|
|
|
+ String s = dataRow.c2.ToString();
|
|
|
+ DateTime date;
|
|
|
+ if (DateTime.TryParse(test.product_time.ToString("yyyy-MM-dd ") + s, out date))
|
|
|
+ {
|
|
|
+ data.data_time = date.ToString("yyyy-MM-dd HH:mm");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataRow.c11 != null && dataRow.c11.Length > 0 && decimal.TryParse(dataRow.c11, out realValuel))
|
|
|
+ {
|
|
|
+ data.data_value = realValuel;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.data_value = null;
|
|
|
+ }
|
|
|
+ modelList.AddRange(test_datas);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ WLLog.Error("Excel数据解析_原始数据转换到对象实体的问题:", ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ errorMsg = string.Empty;
|
|
|
+ return modelList;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ errorMsg = stringBuilder.ToString();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|