|
|
@@ -1,15 +1,12 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
-using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Reflection;
|
|
|
using System.Text;
|
|
|
using Business.EntityFrameworkCore.SqlRepositories;
|
|
|
using Business.StructuredDB.Sqe;
|
|
|
-using NPOI.HSSF.UserModel;
|
|
|
-using NPOI.SS.UserModel;
|
|
|
-using NPOI.XSSF.UserModel;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
using Volo.Abp.Application.Services;
|
|
|
|
|
|
namespace Business.VSM
|
|
|
@@ -3139,5 +3136,92 @@ namespace Business.VSM
|
|
|
#endregion OQC
|
|
|
|
|
|
|
|
|
+ #region Fct
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 将字符串插入到数据库
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="data"></param>
|
|
|
+ /// <param name="create_by"></param>
|
|
|
+ /// <param name="create_date"></param>
|
|
|
+ /// <param name="create_org"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public string Import_Fct_From_Data(String data, string create_by, DateTime create_date, string create_org)
|
|
|
+ {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ sqe_fct model = new sqe_fct();
|
|
|
+ List<sqe_fct_data> modelList = new List<sqe_fct_data>();
|
|
|
+ DateTime timeValue;
|
|
|
+ decimal realValuel;
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ JObject json = JObject.Parse(data);
|
|
|
+ model.SpID = json["SpID"].ToString();
|
|
|
+ model.WLID = json["WLID"].ToString();
|
|
|
+ model.WPID = json["WPID"].ToString();
|
|
|
+ model.op_side = json["OpSide"].ToString();
|
|
|
+ model.LineID = json["LineID"].ToString();
|
|
|
+ model.OpID = json["OpID"].ToString();
|
|
|
+ model.bar_code = json["BarCode"].ToString();
|
|
|
+ model.WONO = json["WONO"].ToString();
|
|
|
+ model.program = json["Program"].ToString();
|
|
|
+ model.pro_version = json["ProVersion"].ToString();
|
|
|
+ model.test_result = json["testResult"].ToString();
|
|
|
+ model.msg = json["Msg"].ToString();
|
|
|
+ model.create_by = create_by;
|
|
|
+ model.create_date = create_date;
|
|
|
+ model.create_org = create_org;
|
|
|
+
|
|
|
+ JArray array = JArray.Parse(json["testData"].ToString());
|
|
|
+
|
|
|
+ //将每一个检测标准的值从记录行中取出来
|
|
|
+ for (int j = 0; array != null && j < array.Count; j++)
|
|
|
+ {
|
|
|
+ sqe_fct_data data1 = new sqe_fct_data();
|
|
|
+ data1.name = array[j]["Name"].ToString();
|
|
|
+ data1.unit = array[j]["Unit"].ToString();
|
|
|
+ data1.lower = decimal.Parse(array[j]["Lower"].ToString());
|
|
|
+ data1.upper = decimal.Parse(array[j]["Upper"].ToString());
|
|
|
+ data1.actual = decimal.Parse(array[j]["Actual"].ToString());
|
|
|
+ data1.result = array[j]["result"].ToString();
|
|
|
+ data1.start_time = DateTime.Parse(array[j]["StartTime"].ToString());
|
|
|
+ data1.end_time = DateTime.Parse(array[j]["endTime"].ToString());
|
|
|
+ data1.detial = array[j]["Detial"].ToString();
|
|
|
+ data1.create_by = create_by;
|
|
|
+ data1.create_date = create_date;
|
|
|
+ data1.create_org = create_org;
|
|
|
+ modelList.Add(data1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ stringBuilder.Append(ex.ToString());
|
|
|
+ WLLog.Error("Fct上传数据解析_原始数据转换到对象实体的问题:", ex);
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ _sqe_fct.BeginTransaction();
|
|
|
+ _sqe_fct.Insert(model);
|
|
|
+ foreach (var item in modelList)
|
|
|
+ {
|
|
|
+ item.fct_id = model.id;
|
|
|
+ }
|
|
|
+ _sqe_fct_data.BeginTransaction();
|
|
|
+ _sqe_fct_data.Insert(modelList);
|
|
|
+ _sqe_fct_data.CommitTransaction();
|
|
|
+ _sqe_fct.CommitTransaction();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _sqe_fct_data.Rollback();
|
|
|
+ _sqe_fct.Rollback();
|
|
|
+ stringBuilder.Append(ex.ToString());
|
|
|
+ }
|
|
|
+
|
|
|
+ return stringBuilder.ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion Fct
|
|
|
}
|
|
|
}
|